Re: [PATCH] D13909: clang-offload-bundler - offload files bundling/unbundling tool

2016-08-16 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added inline comments.


Comment at: test/CMakeLists.txt:27-33
@@ -26,8 +26,9 @@
 
 list(APPEND CLANG_TEST_DEPS
   clang clang-headers
   clang-format
   c-index-test diagtool
   clang-tblgen
+  clang-offload-bundler
   )
   

Most users will get it anyway because it is built for the `install` target and 
I think the build system should do its best to build and install all needed 
dependencies.

I think this currently only fails when using `make clang` and then trying to 
invoke the compiler from the build directory. I agree that this should be quite 
rare but that could be fixed by `add_dependencies(clang clang-offload-bundler)` 
which has worked for me. However I now don't have a really strong opinion here 
because it works with the `install` target.


https://reviews.llvm.org/D13909



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


r278783 - [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms

2016-08-16 Thread Marina Yatsina via cfe-commits
Author: myatsina
Date: Tue Aug 16 03:13:36 2016
New Revision: 278783

URL: http://llvm.org/viewvc/llvm-project?rev=278783&view=rev
Log:
[X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms

commit on behalf of guyblank

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Aug 16 03:13:36 2016
@@ -644,6 +644,8 @@ TARGET_BUILTIN(__builtin_ia32_fxsave64,
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 16 03:13:36 2016
@@ -6915,7 +6915,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_xsavec:
   case X86::BI__builtin_ia32_xsavec64:
   case X86::BI__builtin_ia32_xsaves:
-  case X86::BI__builtin_ia32_xsaves64: {
+  case X86::BI__builtin_ia32_xsaves64:
+  case X86::BI__builtin_ia32_xsetbv: {
 Intrinsic::ID ID;
 #define INTRINSIC_X86_XSAVE_ID(NAME) \
 case X86::BI__builtin_ia32_##NAME: \
@@ -6935,6 +6936,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 INTRINSIC_X86_XSAVE_ID(xsavec64);
 INTRINSIC_X86_XSAVE_ID(xsaves);
 INTRINSIC_X86_XSAVE_ID(xsaves64);
+INTRINSIC_X86_XSAVE_ID(xsetbv);
 }
 #undef INTRINSIC_X86_XSAVE_ID
 Value *Mhi = Builder.CreateTrunc(
@@ -6944,6 +6946,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
+  case X86::BI__builtin_ia32_xgetbv:
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);
   case X86::BI__builtin_ia32_storedqudi128_mask:
   case X86::BI__builtin_ia32_storedqusi128_mask:
   case X86::BI__builtin_ia32_storedquhi128_mask:

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue Aug 16 03:13:36 2016
@@ -289,10 +289,6 @@ static __inline__
 void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
-static __inline__
-#define _XCR_XFEATURE_ENABLED_MASK 0
-unsigned __int64 __cdecl _xgetbv(unsigned int);
-void __cdecl _xsetbv(unsigned int, unsigned __int64);
 
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
 #ifdef __x86_64__
@@ -908,12 +904,6 @@ __cpuidex(int __info[4], int __level, in
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), 
"=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {
   __asm__ volatile ("hlt");

Modified: cfe/trunk/lib/Headers/xsaveintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/lib/Headers/xsaveintrin.h (original)
+++ cfe/trunk/lib/Headers/xsaveintrin.h Tue Aug 16 03:13:36 2016
@@ -28,6 +28,8 @@
 #ifndef __XSAVEINTRIN_H
 #define __XSAVEINTRIN_H
 
+#define _XCR_XFEATURE_ENABLED_MASK 0
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("xsave")))
 
@@ -41,6 +43,16 @@ _xrstor(void *__p, unsigned long long __
 

Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-08-16 Thread Marina Yatsina via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278783: [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics 
to non-windows platforms (authored by myatsina).

Changed prior to commit:
  https://reviews.llvm.org/D21959?vs=65676&id=68146#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21959

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/intrin.h
  cfe/trunk/lib/Headers/xsaveintrin.h
  cfe/trunk/test/CodeGen/builtins-x86.c
  cfe/trunk/test/CodeGen/x86_32-xsave.c
  cfe/trunk/test/CodeGen/x86_64-xsave.c
  cfe/trunk/test/Headers/ms-intrin.cpp

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -644,6 +644,8 @@
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt")
Index: cfe/trunk/test/Headers/ms-intrin.cpp
===
--- cfe/trunk/test/Headers/ms-intrin.cpp
+++ cfe/trunk/test/Headers/ms-intrin.cpp
@@ -50,7 +50,6 @@
   int info[4];
   __cpuid(info, 0);
   __cpuidex(info, 0, 0);
-  _xgetbv(0);
   __halt();
   __readmsr(0);
 
Index: cfe/trunk/test/CodeGen/x86_64-xsave.c
===
--- cfe/trunk/test/CodeGen/x86_64-xsave.c
+++ cfe/trunk/test/CodeGen/x86_64-xsave.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVE
 
+// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XGETBV
+// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSETBV
+
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVEOPT
 
@@ -10,9 +13,16 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=XSAVES
 
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+#include 
+
+
 void test() {
-  unsigned long long tmp_ULLi = 0;
-  void*  tmp_vp = 0;
+  unsigned long long tmp_ULLi;
+  unsigned int   tmp_Ui;
+  void*  tmp_vp;
+  tmp_ULLi = 0; tmp_Ui = 0; tmp_vp = 0;
 
 #ifdef TEST_XSAVE
 // XSAVE: [[tmp_vp_1:%[0-9a-zA-z]+]] = load i8*, i8** %tmp_vp, align 8
@@ -46,6 +56,18 @@
 // XSAVE: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32
 // XSAVE: call void @llvm.x86.xrstor64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])
   (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave
+  (void)_xsave(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave64
+  (void)_xsave64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor
+  (void)_xrstor(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor64
+  (void)_xrstor64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEOPT
@@ -64,6 +86,12 @@
 // XSAVEOPT: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEOPT: call void @llvm.x86.xsaveopt64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])
   (void)__builtin_ia32_xsaveopt64(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt
+  (void)_xsaveopt(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt64
+  (void)_xsaveopt64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEC
@@ -82,6 +110,12 @@
 // XSAVEC: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEC: call void @llvm.x86.xsavec64(i8* [[tmp_vp_2]], i32 [[high32_2]], i

Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-16 Thread Martin Böhme via cfe-commits
mboehme updated this revision to Diff 68147.
mboehme added a comment.

Responses to reviewer comments.


https://reviews.llvm.org/D23353

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UseAfterMoveCheck.cpp
  clang-tidy/misc/UseAfterMoveCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-use-after-move.rst
  test/clang-tidy/misc-use-after-move.cpp

Index: test/clang-tidy/misc-use-after-move.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-use-after-move.cpp
@@ -0,0 +1,1039 @@
+// RUN: %check_clang_tidy %s misc-use-after-move %t
+
+typedef decltype(nullptr) nullptr_t;
+
+namespace std {
+typedef unsigned size_t;
+
+template 
+struct unique_ptr {
+  unique_ptr();
+  T *get() const;
+};
+
+template 
+struct shared_ptr {
+  shared_ptr();
+  T *get() const;
+};
+
+#define DECLARE_STANDARD_CONTAINER(name) \
+  template   \
+  struct name {  \
+name();  \
+void clear();\
+bool empty();\
+  }
+
+#define DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(name) \
+  template   \
+  struct name {  \
+name();  \
+void clear();\
+bool empty();\
+void assign(size_t, const T &);  \
+  }
+
+DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(basic_string);
+DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(vector);
+DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(deque);
+DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(forward_list);
+DECLARE_STANDARD_CONTAINER_WITH_ASSIGN(list);
+DECLARE_STANDARD_CONTAINER(set);
+DECLARE_STANDARD_CONTAINER(map);
+DECLARE_STANDARD_CONTAINER(multiset);
+DECLARE_STANDARD_CONTAINER(multimap);
+DECLARE_STANDARD_CONTAINER(unordered_set);
+DECLARE_STANDARD_CONTAINER(unordered_map);
+DECLARE_STANDARD_CONTAINER(unordered_multiset);
+DECLARE_STANDARD_CONTAINER(unordered_multimap);
+
+typedef basic_string string;
+
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept {
+  return static_cast::type &&>(__t);
+}
+
+} // namespace std
+
+class A {
+public:
+  A();
+  A(const A &);
+  A(A &&);
+
+  A &operator=(const A &);
+  A &operator=(A &&);
+
+  void foo() const;
+  int getInt() const;
+
+  operator bool() const;
+
+  int i;
+};
+
+
+// General tests.
+
+// Simple case.
+void simple() {
+  A a;
+  a.foo();
+  A other_a = std::move(a);
+  a.foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+}
+
+// A warning should only be emitted for one use-after-move.
+void onlyFlagOneUseAfterMove() {
+  A a;
+  a.foo();
+  A other_a = std::move(a);
+  a.foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:15: note: move occurred here
+  a.foo();
+}
+
+void moveAfterMove() {
+  // Move-after-move also counts as a use.
+  {
+A a;
+std::move(a);
+std::move(a);
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: 'a' used after it was moved
+// CHECK-MESSAGES: [[@LINE-3]]:5: note: move occurred here
+  }
+  // This is also true if the move itself turns into the use on the second loop
+  // iteration.
+  {
+A a;
+for (int i = 0; i < 10; ++i) {
+  std::move(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'a' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-2]]:7: note: move occurred here
+}
+  }
+}
+
+// Checks also works on function parameters that have a use-after move.
+void parameters(A a) {
+  std::move(a);
+  a.foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-MESSAGES: [[@LINE-3]]:3: note: move occurred here
+}
+
+void uniquePtrAndSharedPtr() {
+  // Use-after-moves on std::unique_ptr<> or std::shared_ptr<> aren't flagged.
+  {
+std::unique_ptr ptr;
+std::move(ptr);
+ptr.get();
+  }
+  {
+std::shared_ptr ptr;
+std::move(ptr);
+ptr.get();
+  }
+  // This is also true if the std::unique_ptr<> or std::shared_ptr<> is wrapped
+  // in a typedef.
+  {
+typedef std::unique_ptr PtrToA;
+PtrToA ptr;
+std::move(ptr);
+ptr.get();
+  }
+  {
+typedef std::shared_ptr PtrToA;
+PtrToA ptr;
+std::move(ptr);
+ptr.get();
+  }
+  // And it's also true if the template argument is a little more involved.
+  {
+struct B {
+  typedef A AnotherNa

Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread James Molloy via cfe-commits
jmolloy added a comment.

Hi Filipe,

Did this look good to you after those changes?

Cheers,

James


https://reviews.llvm.org/D23498



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


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-16 Thread Martin Böhme via cfe-commits
mboehme marked 9 inline comments as done.


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:493
@@ +492,3 @@
+if (!S)
+  continue;
+

For some reason, I thought I had read that they weren't compatible with CFG / 
CFGBlock -- but obviously I must have been imagining things. ;)

Also changed the other occurrences.


Comment at: docs/clang-tidy/checks/misc-use-after-move.rst:16
@@ +15,3 @@
+The last line will trigger a warning that ``str`` is used after it has been
+moved.
+

There doesn't seem to be a clear preference here (see alexfh's comments on 
similar cases), so I'll leave this open until it's resolved one way or the 
other.


Comment at: docs/clang-tidy/checks/misc-use-after-move.rst:182
@@ +181,3 @@
+
+struct S {
+  std::string str;

Sorry -- forgot to check that the documentation compiles (it does now).


Comment at: test/clang-tidy/misc-use-after-move.cpp:159
@@ +158,3 @@
+ptr.get();
+  }
+  // This is also true if the std::unique_ptr<> or std::shared_ptr<> is wrapped

No, it doesn't. At the moment, the check intentionally disregards all uses of 
unique_ptr and shared_ptr (see also the documentation).

I agree that it definitely makes sense to check for scenarios like the one you 
mention. They're a bit of a different beast though because unique_ptr and 
shared_ptr have a well-defined state after they've been moved from. This means 
they would require some special logic -- we'd want to disallow ptr->Foo() after 
a std::move, but not ptr.get(). For this reason, I've left them out of this 
initial version.

Also, I'm not sure whether this check is the best place for these unique_ptr 
and shared_ptr checks to live. Because the after-move state of unique_ptr and 
shared_ptr is well defined, the "use, then dereference" case is really just a 
subset of what could be a more general "dereference null pointer" check.


Comment at: test/clang-tidy/misc-use-after-move.cpp:280
@@ +279,3 @@
+A a;
+std::move(a);
+auto lambda = [&]() { a.foo(); };

> can you add tests with reference capture?

Done.

> also what about: [snip]

The check won't warn about this. More generally, it doesn't do any kind of 
inter-procedural analysis.

Inter-procedural analysis would certainly help in a number of ways. For 
example, it could be used to answer the following:

- If a function takes a non-const reference to an object, does it reinitialize 
that object? (Currently, we optimistically assume that it always does.)
- If a function (that isn't a move constructor or move assignment operator) 
takes an rvalue reference to an object, does it actually move from that object, 
and does it do so unconditionally?

However, this would take significant additional implementation effort and would 
also run more slowly.


https://reviews.llvm.org/D23353



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


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-16 Thread Martin Böhme via cfe-commits
mboehme marked 4 inline comments as done.
mboehme added a comment.

In https://reviews.llvm.org/D23353#511362, @Prazek wrote:

> I will review it later, but my first thoughts:
>
> 1. I think we should make some other group, because misc seems to be 
> overloaded. I discussed it with Alex months ago - something like bugprone 
> would be good.


Agree that "misc" seems pretty overcrowded. I'll defer to those who have been 
working on clang-tidy longer than me to make this call.

> 2. Also it would be good to make link in cppcoreguidelines.


How exactly would I create such a "link"? Are you just thinking of a link in 
the documentation, or is there a way to have one clang-tidy check activate 
another (and is this what you're thinking of)?


https://reviews.llvm.org/D23353



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


Re: [PATCH] D7511: [libc++] Change how CMake links libc++ with OS X.

2016-08-16 Thread Eric Fiselier via cfe-commits
EricWF abandoned this revision.
EricWF added a comment.

Abandoning


https://reviews.llvm.org/D7511



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


Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread Davide Italiano via cfe-commits
davide added a comment.

The `Sema` bits look fine to me. I'll let Filipe comment on the sanitizer part.


https://reviews.llvm.org/D23498



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


Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread Filipe Cabecinhas via cfe-commits
LGTM.

Thank you,

 Filipe

On Tue, Aug 16, 2016 at 10:23 AM, Davide Italiano  wrote:
> davide added a comment.
>
> The `Sema` bits look fine to me. I'll let Filipe comment on the sanitizer 
> part.
>
>
> https://reviews.llvm.org/D23498
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-16 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a subscriber: omtcyfz.


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:659
@@ +658,3 @@
+  UseAfterMove Use;
+  if (finder.find(FunctionBody, MovingCall, MovedVariable, &Use)) {
+emitDiagnostic(MovingCall, MovedVariable, Use, this, Result.Context);

Nit: As I discussed with Alex, it is better to omit `{}` in conditional 
statements if the body only contains one statement. Even if it wasn't so, it'd 
be better to use one "style" (i.e. either always omit `{}` or always have `{}`) 
at least inside a single check and you have no `{}` in many places inside this 
file (L637, L647, L577, ...).

Just a stylistic thing, doesn't matter too much, though.


https://reviews.llvm.org/D23353



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


r278786 - Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread James Molloy via cfe-commits
Author: jamesm
Date: Tue Aug 16 04:45:36 2016
New Revision: 278786

URL: http://llvm.org/viewvc/llvm-project?rev=278786&view=rev
Log:
Left shifts of negative values are defined if -fwrapv is set

This means we shouldn't emit ubsan detection code or warn.
Fixes PR25552.

Added:
cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
cfe/trunk/test/Sema/negative-shift-wrapv.c
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=278786&r1=278785&r2=278786&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 16 04:45:36 2016
@@ -2714,7 +2714,8 @@ Value *ScalarExprEmitter::EmitShl(const
 RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false, "sh_prom");
 
   bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
-  Ops.Ty->hasSignedIntegerRepresentation();
+  Ops.Ty->hasSignedIntegerRepresentation() &&
+  !CGF.getLangOpts().isSignedOverflowDefined();
   bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
   if (CGF.getLangOpts().OpenCL)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278786&r1=278785&r2=278786&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 16 04:45:36 2016
@@ -8670,7 +8670,7 @@ static void DiagnoseBadShiftValues(Sema&
 
   // If LHS does not have a signed type and non-negative value
   // then, the behavior is undefined. Warn about it.
-  if (Left.isNegative()) {
+  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
 << LHS.get()->getSourceRange());

Added: cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c?rev=278786&view=auto
==
--- cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c (added)
+++ cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c Tue Aug 16 04:45:36 2016
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple 
x86_64-linux-gnu -fwrapv | FileCheck %s
+
+// CHECK-LABEL: @lsh_overflow
+int lsh_overflow(int a, int b) {
+  // CHECK-NOT: br
+  // CHECK-NOT: call void @__ubsan_
+  // CHECK-NOT: call void @llvm.trap
+  
+  // CHECK:  %[[RET:.*]] = shl i32
+  // CHECK-NEXT: ret i32 %[[RET]]
+  return a << b;
+}

Added: cfe/trunk/test/Sema/negative-shift-wrapv.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/negative-shift-wrapv.c?rev=278786&view=auto
==
--- cfe/trunk/test/Sema/negative-shift-wrapv.c (added)
+++ cfe/trunk/test/Sema/negative-shift-wrapv.c Tue Aug 16 04:45:36 2016
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
+
+int test() {
+  int i;
+  i = -1 << 1; // no-warning
+  return i;
+}
+
+// expected-no-diagnostics


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


Re: [PATCH] D23498: Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread James Molloy via cfe-commits
jmolloy accepted this revision.
jmolloy added a reviewer: jmolloy.
jmolloy added a comment.
This revision is now accepted and ready to land.

Thanks, r278786!


https://reviews.llvm.org/D23498



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


[PATCH] D23544: [clang-tidy] readability-implicit-bool-cast forgets to store its options.

2016-08-16 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D23544

Files:
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.h

Index: clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -28,6 +28,7 @@
 Options.get("AllowConditionalIntegerCasts", 0) != 0),
 AllowConditionalPointerCasts(
 Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,14 @@
 
 } // anonymous namespace
 
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.


Index: clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -28,6 +28,7 @@
 Options.get("AllowConditionalIntegerCasts", 0) != 0),
 AllowConditionalPointerCasts(
 Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,14 @@
 
 } // anonymous namespace
 
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Nomination for 3.9: r278786 - Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread James Molloy via cfe-commits
Hi Hans,

[cc. Richard as code owner]

I'd like to nominate this commit for 3.9. The actual code churn is tiny,
and this fixes a problem noticed by and causing pain to the qemu project.

Cheers,

James

On Tue, 16 Aug 2016 at 10:53 James Molloy via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jamesm
> Date: Tue Aug 16 04:45:36 2016
> New Revision: 278786
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278786&view=rev
> Log:
> Left shifts of negative values are defined if -fwrapv is set
>
> This means we shouldn't emit ubsan detection code or warn.
> Fixes PR25552.
>
> Added:
> cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
> cfe/trunk/test/Sema/negative-shift-wrapv.c
> Modified:
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=278786&r1=278785&r2=278786&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 16 04:45:36 2016
> @@ -2714,7 +2714,8 @@ Value *ScalarExprEmitter::EmitShl(const
>  RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
> "sh_prom");
>
>bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
> -  Ops.Ty->hasSignedIntegerRepresentation();
> +  Ops.Ty->hasSignedIntegerRepresentation() &&
> +  !CGF.getLangOpts().isSignedOverflowDefined();
>bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
>// OpenCL 6.3j: shift values are effectively % word size of LHS.
>if (CGF.getLangOpts().OpenCL)
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278786&r1=278785&r2=278786&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 16 04:45:36 2016
> @@ -8670,7 +8670,7 @@ static void DiagnoseBadShiftValues(Sema&
>
>// If LHS does not have a signed type and non-negative value
>// then, the behavior is undefined. Warn about it.
> -  if (Left.isNegative()) {
> +  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
>  S.DiagRuntimeBehavior(Loc, LHS.get(),
>S.PDiag(diag::warn_shift_lhs_negative)
>  << LHS.get()->getSourceRange());
>
> Added: cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c?rev=278786&view=auto
>
> ==
> --- cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c (added)
> +++ cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c Tue Aug 16 04:45:36 2016
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple
> x86_64-linux-gnu -fwrapv | FileCheck %s
> +
> +// CHECK-LABEL: @lsh_overflow
> +int lsh_overflow(int a, int b) {
> +  // CHECK-NOT: br
> +  // CHECK-NOT: call void @__ubsan_
> +  // CHECK-NOT: call void @llvm.trap
> +
> +  // CHECK:  %[[RET:.*]] = shl i32
> +  // CHECK-NEXT: ret i32 %[[RET]]
> +  return a << b;
> +}
>
> Added: cfe/trunk/test/Sema/negative-shift-wrapv.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/negative-shift-wrapv.c?rev=278786&view=auto
>
> ==
> --- cfe/trunk/test/Sema/negative-shift-wrapv.c (added)
> +++ cfe/trunk/test/Sema/negative-shift-wrapv.c Tue Aug 16 04:45:36 2016
> @@ -0,0 +1,9 @@
> +// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
> +
> +int test() {
> +  int i;
> +  i = -1 << 1; // no-warning
> +  return i;
> +}
> +
> +// expected-no-diagnostics
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23544: [clang-tidy] readability-implicit-bool-cast forgets to store its options.

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

LG


https://reviews.llvm.org/D23544



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


Re: [PATCH] D23544: [clang-tidy] readability-implicit-bool-cast forgets to store its options.

2016-08-16 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/readability/ImplicitBoolCastCheck.h:25
@@ -24,3 +24,3 @@
 public:
   ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context),

BTW, could you move the constructor body to the .cpp file? It's more 
convenient, when both reading and storing options are placed together.


https://reviews.llvm.org/D23544



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


[PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Alexander Shaposhnikov via cfe-commits
alexshap created this revision.
alexshap added a reviewer: lattner.
alexshap added a subscriber: cfe-commits.
alexshap changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

The struct LineNoCacheTy is in SourceMgr.cpp inside anonymous namespace.
This diff changes the order of fields and removes the excessive padding (8 
bytes).
Test plan: make -j8 check-llvm-unit (passed).

https://reviews.llvm.org/D23546

Files:
  lib/Support/SourceMgr.cpp

Index: lib/Support/SourceMgr.cpp
===
--- lib/Support/SourceMgr.cpp
+++ lib/Support/SourceMgr.cpp
@@ -26,8 +26,8 @@
 
 namespace {
   struct LineNoCacheTy {
+const char *LastQuery;
 unsigned LastQueryBufferID;
-const char *LastQuery;
 unsigned LineNoOfQuery;
   };
 }


Index: lib/Support/SourceMgr.cpp
===
--- lib/Support/SourceMgr.cpp
+++ lib/Support/SourceMgr.cpp
@@ -26,8 +26,8 @@
 
 namespace {
   struct LineNoCacheTy {
+const char *LastQuery;
 unsigned LastQueryBufferID;
-const char *LastQuery;
 unsigned LineNoOfQuery;
   };
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

F2274214: Screen Shot 2016-08-16 at 3.34.00 AM.png 



https://reviews.llvm.org/D23546



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


Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

2016-08-16 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D23086#515590, @yaxunl wrote:

> In https://reviews.llvm.org/D23086#515506, @Anastasia wrote:
>
> >
>
>
>
>
> > Surely vendors can re-implement all OpenCL types with an implicit typedef. 
> > For example this would just work:
>
> > 
>
> >   typedef int queue_t;
>
> >   void bar(queue_t q);
>
> >
>
> > 
>
> > I am afraid we will need to provide some implementation to ndrange_t in 
> > Clang itself, otherwise I don't see how it could work. Also it would be 
> > good to offer standard functionality without any extra includes just like 
> > it worked up to now for all other features.
>
>
> It will work if we have a way to identify whether a type is ndrange_t type. 
> So far I have suggested to compare the canonical types. Basically when we see 
> a declaration of typedef with name 'ndrange_t', we save its canonical type X 
> to ASTContext. When we need to check if type Y is ndrange_t, we just need to 
> check Y->getCanonicalType() == X.
>
> On the other hand, pre-define ndrange_t in Clang does not solve the problem 
> of how to decide if a type is ndrange_t, since user can define typedefs for 
> ndrange_t, e.g.
>
>   typedef ndrange_t my_ndrange_t;
>   
>
> In this case, we still need to check the canonical type.


Why not to just identify the type by the name? It seems much easier and also 
gives flexibility to implement the type in different ways if needed. 
Considering that similar approach is already used for some C++ types, it should 
be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



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


Re: [PATCH] D23544: [clang-tidy] readability-implicit-bool-cast forgets to store its options.

2016-08-16 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 68154.
hokein added a comment.

Move ctor body to .cpp file.


https://reviews.llvm.org/D23544

Files:
  clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tidy/readability/ImplicitBoolCastCheck.h

Index: clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -22,12 +22,9 @@
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-AllowConditionalIntegerCasts(
-Options.get("AllowConditionalIntegerCasts", 0) != 0),
-AllowConditionalPointerCasts(
-Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,22 @@
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowConditionalIntegerCasts(
+  Options.get("AllowConditionalIntegerCasts", false)),
+  AllowConditionalPointerCasts(
+  Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.


Index: clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -22,12 +22,9 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-AllowConditionalIntegerCasts(
-Options.get("AllowConditionalIntegerCasts", 0) != 0),
-AllowConditionalPointerCasts(
-Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
Index: clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,22 @@
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowConditionalIntegerCasts(
+  Options.get("AllowConditionalIntegerCasts", false)),
+  AllowConditionalPointerCasts(
+  Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23544: [clang-tidy] readability-implicit-bool-cast forgets to store its options.

2016-08-16 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278791: [clang-tidy] readability-implicit-bool-cast forgets 
to store its options. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D23544?vs=68154&id=68158#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23544

Files:
  clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h

Index: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,22 @@
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowConditionalIntegerCasts(
+  Options.get("AllowConditionalIntegerCasts", false)),
+  AllowConditionalPointerCasts(
+  Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.
Index: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -22,12 +22,9 @@
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-AllowConditionalIntegerCasts(
-Options.get("AllowConditionalIntegerCasts", 0) != 0),
-AllowConditionalPointerCasts(
-Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 


Index: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -299,6 +299,22 @@
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowConditionalIntegerCasts(
+  Options.get("AllowConditionalIntegerCasts", false)),
+  AllowConditionalPointerCasts(
+  Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.
Index: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
@@ -22,12 +22,9 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-AllowConditionalIntegerCasts(
-Options.get("AllowConditionalIntegerCasts", 0) != 0),
-AllowConditionalPointerCasts(
-Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers:

[clang-tools-extra] r278791 - [clang-tidy] readability-implicit-bool-cast forgets to store its options.

2016-08-16 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Aug 16 06:15:05 2016
New Revision: 278791

URL: http://llvm.org/viewvc/llvm-project?rev=278791&view=rev
Log:
[clang-tidy] readability-implicit-bool-cast forgets to store its options.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=278791&r1=278790&r2=278791&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Tue Aug 16 06:15:05 2016
@@ -299,6 +299,22 @@ bool isAllowedConditionalCast(const Impl
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowConditionalIntegerCasts(
+  Options.get("AllowConditionalIntegerCasts", false)),
+  AllowConditionalPointerCasts(
+  Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.

Modified: clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h?rev=278791&r1=278790&r2=278791&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.h Tue 
Aug 16 06:15:05 2016
@@ -22,12 +22,9 @@ namespace readability {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-AllowConditionalIntegerCasts(
-Options.get("AllowConditionalIntegerCasts", 0) != 0),
-AllowConditionalPointerCasts(
-Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 


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


Re: [PATCH] D15227: [analyzer] Valist checkers.

2016-08-16 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 68157.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Improvements according to review comments.


https://reviews.llvm.org/D15227

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/Inputs/system-header-simulator-for-valist.h
  test/Analysis/valist-uninitialized.c
  test/Analysis/valist-unterminated.c

Index: test/Analysis/valist-unterminated.c
===
--- /dev/null
+++ test/Analysis/valist-unterminated.c
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+
+#include "Inputs/system-header-simulator-for-valist.h"
+
+void f1(int fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  return; // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+}
+
+void f2(int fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  va_end(va); // expected-note{{Ended va_list}}
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}}
+
+void f3(int fst, ...) {
+  va_list va, va2;
+  va_start(va, fst);
+  va_copy(va2, va); // expected-note{{Initialized va_list}}
+  va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list 'va2' is leaked}}
+}
+
+void f4(va_list *fst, ...) {
+  va_start(*fst, fst); // expected-note{{Initialized va_list}}
+  return; // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+}
+
+void f5(va_list fst, ...) {
+  va_start(fst, fst);
+  //FIXME: this should cause a warning
+} // no-warning
+
+void f6(va_list *fst, ...) {
+  va_start(*fst, fst); // expected-note{{Initialized va_list}}
+  (void)va_arg(*fst, int);
+  //FIXME: this should NOT cause a warning
+  va_end(*fst); // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+}
+
+void f7(int *fst, ...) {
+  va_list x;
+  va_list *y = &x;
+  va_start(*y,fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list 'x' is leaked}} expected-note{{Initialized va_list 'x' is leaked}}
+
+void f8(int *fst, ...) {
+  va_list x;
+  va_list *y = &x;
+  va_start(*y,fst);
+  va_end(x);
+} // no-warning 
+
+void reinit(int *fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}} expected-note{{Initialized va_list}}
+  va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}} expected-note{{Initialized va_list 'va' is initialized again}}
+} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+
+void reinitOk(int *fst, ...) {
+  va_list va;
+  va_start(va, fst);
+  va_end(va);
+  va_start(va, fst);
+  va_end(va);
+} // no-warning
+
+void copyself(int fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}}
+  va_end(va);
+} // no-warning
+
+void copyselfUninit(int fst, ...) {
+  va_list va;
+  va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}} 
+} // no-warning
+
+void copyOverwrite(int fst, ...) {
+  va_list va, va2;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  va_copy(va, va2); // expected-warning{{Initialized va_list 'va' is overwritten by an uninitialized one}} expected-note{{Initialized va_list 'va' is overwritten by an uninitialized one}}
+} // no-warning
+
+//This only generates a warning for the valist.Uninitialized checker
+void copyUnint(int fst, ...) {
+  va_list va, va2;
+  va_copy(va, va2);
+} // no-warning
+
+void recopy(int fst, ...) {
+  va_list va, va2;
+  va_start(va, fst);
+  va_copy(va2, va); // expected-note{{Initialized va_list}}
+  va_copy(va2, va); // expected-warning{{Initialized va_list 'va2' is initialized again}} expected-note{{Initialized va_list 'va2' is initialized again}}
+  va_end(va);
+  va_end(va2);
+} //no-warning
+
+void doublemsg(int fst, ...) {
+  va_list va, va2;
+  va_start(va, fst), va_start(va2, fst); // expected-warning{{Initialized va_list 'va' is leaked}} expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list 'va' is leaked}} 
+} 
+
+void in_array(int fst, ...) {
+  va_list va_array[8];
+  va_start(va_array[3], fst); // expected-note{{I

Re: [PATCH] D23284: Add -Rpass-with-hotness

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This LGTM, but you should wait for confirmation on the behavior of the R_Group 
behavior from @dnovillo or @rsmith before committing.


https://reviews.llvm.org/D23284



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


Re: [PATCH] D23528: [OpenMP] Sema and parsing for 'teams distribute simd' pragma

2016-08-16 Thread Alexey Bataev via cfe-commits
ABataev requested changes to this revision.
ABataev added a comment.
This revision now requires changes to proceed.

No tests for serialization/deserialization/AST printing


https://reviews.llvm.org/D23528



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


[PATCH] D23550: [analyzer] Small cleanups when checkers retrieving statements from exploded nodes.

2016-08-16 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, NoQ.
xazax.hun added a subscriber: cfe-commits.

Small cleanup to utilize PathDiagnosticLocation::getStmt where appropriate.

https://reviews.llvm.org/D23550

Files:
  lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -2418,12 +2418,7 @@
   // FIXME: This will crash the analyzer if an allocation comes from an
   // implicit call (ex: a destructor call).
   // (Currently there are no such allocations in Cocoa, though.)
-  const Stmt *AllocStmt = nullptr;
-  ProgramPoint P = AllocNode->getLocation();
-  if (Optional Exit = P.getAs())
-AllocStmt = Exit->getCalleeContext()->getCallSite();
-  else
-AllocStmt = P.castAs().getStmt();
+  const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
   assert(AllocStmt && "Cannot find allocation statement");
 
   PathDiagnosticLocation AllocLocation =
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -325,10 +325,7 @@
   // Retrieve the associated statement.
   const Stmt *S = TrackedNullab->getNullabilitySource();
   if (!S) {
-ProgramPoint ProgLoc = N->getLocation();
-if (Optional SP = ProgLoc.getAs()) {
-  S = SP->getStmt();
-}
+S = PathDiagnosticLocation::getStmt(N);
   }
 
   if (!S)
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2094,12 +2094,7 @@
   const MemRegion *Region = nullptr;
   std::tie(AllocNode, Region) = getAllocationSite(N, Sym, C);
 
-  ProgramPoint P = AllocNode->getLocation();
-  const Stmt *AllocationStmt = nullptr;
-  if (Optional Exit = P.getAs())
-AllocationStmt = Exit->getCalleeContext()->getCallSite();
-  else if (Optional SP = P.getAs())
-AllocationStmt = SP->getStmt();
+  const Stmt *AllocationStmt = PathDiagnosticLocation::getStmt(AllocNode);
   if (AllocationStmt)
 LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocationStmt,
   C.getSourceManager(),
@@ -2626,29 +2621,16 @@
   if (!RS)
 return nullptr;
 
-  const Stmt *S = nullptr;
-  const char *Msg = nullptr;
-  StackHintGeneratorForSymbol *StackHint = nullptr;
-
-  // Retrieve the associated statement.
-  ProgramPoint ProgLoc = N->getLocation();
-  if (Optional SP = ProgLoc.getAs()) {
-S = SP->getStmt();
-  } else if (Optional Exit = ProgLoc.getAs()) {
-S = Exit->getCalleeContext()->getCallSite();
-  } else if (Optional Edge = ProgLoc.getAs()) {
-// If an assumption was made on a branch, it should be caught
-// here by looking at the state transition.
-S = Edge->getSrc()->getTerminator();
-  }
-
+  const Stmt *S = PathDiagnosticLocation::getStmt(N);
   if (!S)
 return nullptr;
 
   // FIXME: We will eventually need to handle non-statement-based events
   // (__attribute__((cleanup))).
 
   // Find out if this is an interesting point and what is the kind.
+  const char *Msg = nullptr;
+  StackHintGeneratorForSymbol *StackHint = nullptr;
   if (Mode == Normal) {
 if (isAllocated(RS, RSPrev, S)) {
   Msg = "Memory is allocated";
Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -524,12 +524,7 @@
   // allocated, and only report a single path.
   PathDiagnosticLocation LocUsedForUniqueing;
   const ExplodedNode *AllocNode = getAllocationNode(N, AP.first, C);
-  const Stmt *AllocStmt = nullptr;
-  ProgramPoint P = AllocNode->getLocation();
-  if (Optional Exit = P.getAs())
-AllocStmt = Exit->getCalleeContext()->getCallSite();
-  else if (Optional PS = P.getAs())
-AllocStmt = PS->getStmt();
+  const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
 
   if (AllocStmt)
 LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocStmt,
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -90

Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.

2016-08-16 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 68170.
teemperor added a comment.

- Renamed FoldingSetWrapper to FoldingSetNodeIDWrapper
- Added missing // end anonymous namespace


https://reviews.llvm.org/D22515

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp

Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -51,15 +51,6 @@
  "Related code clone is here.");
 
 for (CloneDetector::CloneGroup &Group : CloneGroups) {
-  // For readability reasons we sort the clones by line numbers.
-  std::sort(Group.Sequences.begin(), Group.Sequences.end(),
-[&SM](const StmtSequence &LHS, const StmtSequence &RHS) {
-  return SM.isBeforeInTranslationUnit(LHS.getStartLoc(),
-  RHS.getStartLoc()) &&
- SM.isBeforeInTranslationUnit(LHS.getEndLoc(),
-  RHS.getEndLoc());
-});
-
   // We group the clones by printing the first as a warning and all others
   // as a note.
   DiagEngine.Report(Group.Sequences.front().getStartLoc(), WarnID);
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -244,46 +244,35 @@
 /// This class defines what a code clone is: If it collects for two statements
 /// the same data, then those two statements are considered to be clones of each
 /// other.
-class StmtDataCollector : public ConstStmtVisitor {
+///
+/// All collected data is forwarded to the given data consumer of the type T.
+/// The data consumer class needs to provide a member method with the signature:
+///   write(const char *Data, size_t Size)
+template 
+class StmtDataCollector : public ConstStmtVisitor> {
 
   ASTContext &Context;
-  std::vector &CollectedData;
+  /// \brief The data sink to which all data is forwarded.
+  T &DataConsumer;
 
 public:
   /// \brief Collects data of the given Stmt.
   /// \param S The given statement.
   /// \param Context The ASTContext of S.
-  /// \param D The given data vector to which all collected data is appended.
-  StmtDataCollector(const Stmt *S, ASTContext &Context,
-std::vector &D)
-  : Context(Context), CollectedData(D) {
-Visit(S);
+  /// \param D The data sink to which all data is forwarded.
+  StmtDataCollector(const Stmt *S, ASTContext &Context, T &DataConsumer)
+  : Context(Context), DataConsumer(DataConsumer) {
+this->Visit(S);
   }
 
   // Below are utility methods for appending different data to the vector.
 
   void addData(CloneDetector::DataPiece Integer) {
-CollectedData.push_back(Integer);
+DataConsumer.write(reinterpret_cast(&Integer), sizeof(Integer));
   }
 
-  // FIXME: The functions below add long strings to the data vector which are
-  // probably not good for performance. Replace the strings with pointer values
-  // or a some other unique integer.
-
   void addData(llvm::StringRef Str) {
-if (Str.empty())
-  return;
-
-const size_t OldSize = CollectedData.size();
-
-const size_t PieceSize = sizeof(CloneDetector::DataPiece);
-// Calculate how many vector units we need to accomodate all string bytes.
-size_t RoundedUpPieceNumber = (Str.size() + PieceSize - 1) / PieceSize;
-// Allocate space for the string in the data vector.
-CollectedData.resize(CollectedData.size() + RoundedUpPieceNumber);
-
-// Copy the string to the allocated space at the end of the vector.
-std::memcpy(CollectedData.data() + OldSize, Str.data(), Str.size());
+DataConsumer.write(Str.data(), Str.size());
   }
 
   void addData(const QualType &QT) { addData(QT.getAsString()); }
@@ -429,8 +418,10 @@
 // Create an empty signature that will be filled in this method.
 CloneDetector::CloneSignature Signature;
 
+llvm::hash_stream Hash;
+
 // Collect all relevant data from S and put it into the empty signature.
-StmtDataCollector(S, Context, Signature.Data);
+StmtDataCollector(S, Context, Hash);
 
 // Macro-generated code should increase the complexity value of its
 // containing clone by about the same value as an variable reference or
@@ -479,7 +470,8 @@
   auto ChildSignature = generateSignatures(Child, StartMacroName);
 
   // Add the collected data to the signature of the current statement.
-  Signature.add(ChildSignature);
+  Signature.Complexity += ChildSignature.Complexity;
+  Hash << static_cast(ChildSignature.Hash);
 
   // If the current statement is a CompoundStatement, we need to store the
   // signature for the generation of the sub-sequ

Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:46-56
@@ +45,13 @@
+// std::move(). This will hopefully prevent erroneous replacements if the
+// code does unusual things (e.g. create an alias for std::move() in
+// another namespace).
+NestedNameSpecifier *NNS = Callee->getQualifier();
+if (!NNS) {
+  // Called as "move" (i.e. presumably the code had a "using std::move;").
+  // We still conservatively put a "std::" in front of the forward because
+  // we don't know whether the code also had a "using std::forward;".
+  Diag << FixItHint::CreateReplacement(CallRange, "std::" + ForwardName);
+} else if (const NamespaceDecl *Namespace = NNS->getAsNamespace()) {
+  if (Namespace->getName() == "std") {
+if (!NNS->getPrefix()) {
+  // Called as "std::move".

This code can be combined with the Global check below with something like:
```
Diag << ..., Twine(NNS->getPrefix()->getKind() == NestedNameSpecifier::Global ? 
"::" : "") + "std::" + ForwardName);
```


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:124-125
@@ +123,4 @@
+  auto Diag = diag(CallMove->getExprLoc(),
+   "forwarding reference passed to std::move(); did you mean "
+   "to use std::forward() instead?");
+

Given that the user is possibly in a confused state when they wrote 
`std::move()` rather than `std::forward()`, I wonder if it makes more sense to 
word the diagnostic as an imperative rather than a question? The diagnostic as 
it is doesn't really explain why `std::forward()` would be right while 
`std::move()` could be wrong.

Perhaps: "forwarding reference passed to `std::move()` may unexpectedly leave 
lvalue references in an indeterminate state; use `std::forward()` instead for 
perfect forwarding"


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.h:27
@@ +26,3 @@
+///
+/// This has a consequence that is usually unwanted and possibly surprising: If
+/// the function that takes the forwarding reference as its parameter is called

"If" should not be capitalized here.


Comment at: docs/ReleaseNotes.rst:78
@@ -77,1 +77,3 @@
 
+- New `misc-move-forwarding-reference
+  
`_
 check

Uncertain whether we're doing this or not, but should we keep this list 
alphabetized?


Comment at: docs/clang-tidy/checks/misc-move-forwarding-reference.rst:32
@@ +31,3 @@
+
+Code like the example above is often written in the expectation that ``T&&``
+will always end up being an rvalue reference, no matter what type is deduced 
for

"is often written in the" -> "is sometimes written with the"


https://reviews.llvm.org/D0



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


Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.

2016-08-16 Thread Raphael Isemann via cfe-commits
teemperor marked 2 inline comments as done.
teemperor added a comment.

https://reviews.llvm.org/D22515



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


Re: [PATCH] D23427: [Clang-tidy] Comparison Misuse

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Thank you for working on this check!

We already have a frontend diagnostic for comparisons between string literals 
and pointers, so I'm not certain of the utility of adding a clang-tidy check 
for that case (see -Wstring-compare, aka, 
http://coliru.stacked-crooked.com/a/6f6ca7fd2f6db09a).

Comparisons against nullptr seems like it could also be handled as a frontend 
check as well, perhaps.



Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:23
@@ +22,3 @@
+  Finder->addMatcher(
+  binaryOperator(hasEitherOperand(ignoringImpCasts(stringLiteral())),
+ hasEitherOperand(hasType(pointsTo(isAnyCharacter()

Should constrain this matcher to comparison operators, no? 


Comment at: clang-tidy/misc/ComparisonMisuseCheck.h:21
@@ +20,3 @@
+/// It should warn for the following cases:
+///   - strcmp,strncmp,memcmp misuse.
+///   - char* is compared to a string literal

hokein wrote:
> Eugene.Zelenko wrote:
> > Spaces after commas,
> Seems like your check doesn't warn any usage about the strcmp family 
> functions.
Should remove the period at the end of this comment. Also, the w-variants for 
these APIs?

I don't see any code related to strcmp and friends, so perhaps this comment is 
spurious and should be removed?


Comment at: docs/clang-tidy/checks/misc-comparison-misuse.rst:1
@@ +1,2 @@
+.. title:: clang-tidy - misc-comparison-misuse
+

The code examples in the documentation should be formatted with our usual style 
guidelines, such as `char *` rather than `char*`, etc.


Comment at: docs/clang-tidy/checks/misc-comparison-misuse.rst:10
@@ +9,3 @@
+Case 1:
+  ``char*`` is compared to a string literal.
+

hokein wrote:
> Does the case cover `char[]` ?
The check is covering any character type, including `char32_t`, `wchar_t`, etc.


Comment at: test/clang-tidy/misc-comparison-misuse.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s misc-comparison-misuse %t
+

hokein wrote:
> Also clang-format this example.
Should be tests for other character types.


Repository:
  rL LLVM

https://reviews.llvm.org/D23427



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


StaticAnalyzer: Fix GCC 6 indention warning in ArrayBoundCheckerV2.cpp

2016-08-16 Thread Christoph Grüninger via cfe-commits
Dear Clang developers,
please find attached a tiny patch which fixes a indentation warning from
GCC 6 within ArrayBoundCheckerV2.cpp

Proposed commit message:
> StaticAnalyzer: Fix GCC 6 indention warning in ArrayBoundCheckerV2.cpp
>
> Patch by Christoph Grüninger

Bye
Christoph
Index: lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp	(Revision 278795)
+++ lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp	(Arbeitskopie)
@@ -157,9 +157,10 @@
 
 // If we are under constrained and the index variables are tainted, report.
 if (state_exceedsUpperBound && state_withinUpperBound) {
-  if (state->isTainted(rawOffset.getByteOffset()))
+  if (state->isTainted(rawOffset.getByteOffset())) {
 reportOOB(checkerContext, state_exceedsUpperBound, OOB_Tainted);
-return;
+  }
+  return;
 }
 
 // If we are constrained enough to definitely exceed the upper bound, report.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with one minor nit (you can fix it during the commit).



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(anyOf(isPrivate(), isProtected(;
+

Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), isProtected())`?


https://reviews.llvm.org/D23343



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


[PATCH] D23555: [analyzer] CloneDetector now checks template arguments of function calls.

2016-08-16 Thread Raphael Isemann via cfe-commits
teemperor created this revision.
teemperor added reviewers: v.g.vassilev, NoQ.
teemperor added a subscriber: cfe-commits.

The CloneDetector currently ignores template arguments in function calls which 
leads to false-positive clones such as `isa(S)` and `isa(S)`.

This patch adds functionality to handle template arguments for those function 
calls.

https://reviews.llvm.org/D23555

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/call.cpp

Index: test/Analysis/copypaste/call.cpp
===
--- test/Analysis/copypaste/call.cpp
+++ test/Analysis/copypaste/call.cpp
@@ -34,3 +34,32 @@
 return funcPtr(1);
   return true;
 }
+
+// Test that we respect the template arguments of function templates
+
+template
+bool tempFunc() { unsigned i = N; return false; }
+
+bool fooTemp1(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
+
+bool fooTemp2(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
+
+bool fooTemp3(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -151,8 +151,24 @@
   //--- Calls --//
   DEF_ADD_DATA(CallExpr, {
 // Function pointers don't have a callee and we just skip hashing it.
-if (S->getDirectCallee())
+if (S->getDirectCallee()) {
+  // If the function is a template instantiation, we also need to handle
+  // the template arguments as they are no included in the qualified name.
+  if (S->getDirectCallee()->isTemplateInstantiation()) {
+auto Args = S->getDirectCallee()->getTemplateSpecializationArgs();
+std::string ArgString;
+
+// Print all template arguments into ArgString
+llvm::raw_string_ostream OS(ArgString);
+for (unsigned i = 0; i < Args->size(); ++i) {
+  Args->get(i).print(Context.getLangOpts(), OS);
+}
+OS.flush();
+
+addData(ArgString);
+  }
   addData(S->getDirectCallee()->getQualifiedNameAsString());
+}
   })
 
   //--- Exceptions -//


Index: test/Analysis/copypaste/call.cpp
===
--- test/Analysis/copypaste/call.cpp
+++ test/Analysis/copypaste/call.cpp
@@ -34,3 +34,32 @@
 return funcPtr(1);
   return true;
 }
+
+// Test that we respect the template arguments of function templates
+
+template
+bool tempFunc() { unsigned i = N; return false; }
+
+bool fooTemp1(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
+
+bool fooTemp2(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
+
+bool fooTemp3(int x) {
+  if (x > 0)
+return false;
+  else if (x < 0)
+return tempFunc();
+  return true;
+}
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -151,8 +151,24 @@
   //--- Calls --//
   DEF_ADD_DATA(CallExpr, {
 // Function pointers don't have a callee and we just skip hashing it.
-if (S->getDirectCallee())
+if (S->getDirectCallee()) {
+  // If the function is a template instantiation, we also need to handle
+  // the template arguments as they are no included in the qualified name.
+  if (S->getDirectCallee()->isTemplateInstantiation()) {
+auto Args = S->getDirectCallee()->getTemplateSpecializationArgs();
+std::string ArgString;
+
+// Print all template arguments into ArgString
+llvm::raw_string_ostream OS(ArgString);
+for (unsigned i = 0; i < Args->size(); ++i) {
+  Args->get(i).print(Context.getLangOpts(), OS);
+}
+OS.flush();
+
+addData(ArgString);
+  }
   addData(S->getDirectCallee()->getQualifiedNameAsString());
+}
   })
 
   //--- Exceptions -//
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23533: [clang-tidy] Rewrite compilation database test to not require shell

2016-08-16 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:11
@@ -10,3 @@
-// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
-// RUN: sed 's|test_dir|%T/compilation-database-test|g' 
%S/Inputs/compilation-database/template.json > %T/compile_commands.json
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T 
%T/compilation-database-test/b/not-exist -header-filter=.*

This sed call substitutes placeholders with absolute paths, which is an 
important part of this test. So we can't get rid of the sed call. Furthermore, 
the test verifies that clang-tidy doesn't crash when applying fixes (which it 
used to, IIRC), so I'm not sure this change doesn't make the test less 
informative.

If you need to test correct handling of GCC-style command lines in JSON 
compilation databases on Windows, we can add another test, but this one should 
stay as it is.


Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:36
@@ +35,1 @@
+// CHECK-YAML: ReplacementText: nullptr
\ No newline at end of file


Please fix "No newline at end of file".


https://reviews.llvm.org/D23533



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


Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.

2016-08-16 Thread Raphael Isemann via cfe-commits
teemperor planned changes to this revision.
teemperor added a comment.

- As the hash_stream patch will take a while to land upstream, we will change 
this to use FoldingSetNodeID and change it to hash_stream once that landed.


https://reviews.llvm.org/D22515



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


r278806 - Add empty --gcc-toolchain empty to cuda-detect test.

2016-08-16 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Aug 16 09:31:39 2016
New Revision: 278806

URL: http://llvm.org/viewvc/llvm-project?rev=278806&view=rev
Log:
Add empty --gcc-toolchain empty to cuda-detect test.

Unless we overload the default gcc toolchain with an empty string 
the system root used in the tests will be ignored if the user builds
clang  with a custom gcc toolchain.
 

Modified:
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278806&r1=278805&r2=278806&view=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Tue Aug 16 09:31:39 2016
@@ -75,6 +75,7 @@
 // Verify that C++ include paths are passed for both host and device frontends.
 // RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
 // RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 
2>&1 \
+// RUN: --gcc-toolchain="" \
 // RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
 
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda


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


r278811 - Reorder stderr redirection in test command.

2016-08-16 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Tue Aug 16 09:38:39 2016
New Revision: 278811

URL: http://llvm.org/viewvc/llvm-project?rev=278811&view=rev
Log:
Reorder stderr redirection in test command.

Modified:
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=278811&r1=278810&r2=278811&view=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Tue Aug 16 09:38:39 2016
@@ -74,8 +74,8 @@
 
 // Verify that C++ include paths are passed for both host and device frontends.
 // RUN: %clang -### -no-canonical-prefixes -target x86_64-linux-gnu %s \
-// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 
2>&1 \
-// RUN: --gcc-toolchain="" \
+// RUN: --stdlib=libstdc++ --sysroot=%S/Inputs/ubuntu_14.04_multiarch_tree2 \
+// RUN: --gcc-toolchain="" 2>&1 \
 // RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE
 
 // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda


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


r278812 - Reduce the number of allocations required for AST attributes. In test cases, the max resident memory changed from 65760k to 64476k which is 1.9% improvement. Allocations in grow_pod changed

2016-08-16 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Aug 16 09:48:39 2016
New Revision: 278812

URL: http://llvm.org/viewvc/llvm-project?rev=278812&view=rev
Log:
Reduce the number of allocations required for AST attributes. In test cases, 
the max resident memory changed from 65760k to 64476k which is 1.9% 
improvement. Allocations in grow_pod changed from 8847 to 4872 according to 
tcmalloc heap profiler. Overall running time remained the same.

Patch by Eugene Kosov

Modified:
cfe/trunk/include/clang/AST/AttrIterator.h

Modified: cfe/trunk/include/clang/AST/AttrIterator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/AttrIterator.h?rev=278812&r1=278811&r2=278812&view=diff
==
--- cfe/trunk/include/clang/AST/AttrIterator.h (original)
+++ cfe/trunk/include/clang/AST/AttrIterator.h Tue Aug 16 09:48:39 2016
@@ -39,8 +39,7 @@ void operator delete[](void *Ptr, const
 namespace clang {
 
 /// AttrVec - A vector of Attr, which is how they are stored on the AST.
-typedef SmallVector AttrVec;
-typedef SmallVector ConstAttrVec;
+typedef SmallVector AttrVec;
 
 /// specific_attr_iterator - Iterates over a subrange of an AttrVec, only
 /// providing attributes that are of a specific type.


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


Re: [PATCH] D23329: [NFC] Reducing allocations in AST attributes

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you! I've commit in r278812.


https://reviews.llvm.org/D23329



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


Re: [PATCH] D15332: new clang-tidy checker readability-non-const-parameter

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


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:95-98
@@ +94,6 @@
+const QualType T = VD->getType();
+if (T->isPointerType() && !T->getPointeeType().isConstQualified())
+  markCanNotBeConst(VD->getInit(), true);
+else if (T->isArrayType())
+  markCanNotBeConst(VD->getInit(), true);
+  }

danielmarjamaki wrote:
> Prazek wrote:
> > This looks like it could be in the same if.
> Yes it could. But would it make the code more or less readable? It wouldn't 
> be a 1-line condition anymore then.
I also think that it makes sense to merge the conditions. The problem with the 
current code is that it is suspicious ("Why is the same action is done in two 
branches? Is it a bug?"). One line condition vs two lines seems secondary in 
this case.


Comment at: clang-tidy/readability/NonConstParameterCheck.cpp:103
@@ +102,3 @@
+void NonConstParameterCheck::addParm(const ParmVarDecl *Parm) {
+  // Only add nonconst integer/float pointer parameters.
+  const QualType T = Parm->getType();

This seems too strict. What about other primitive types? 


Comment at: docs/clang-tidy/checks/readability-non-const-parameter.rst:22
@@ +21,3 @@
+  // interface safer.
+  char f1(char *p)
+  {

Please put braces on the same line with the function header. We should keep 
documentation consistent with LLVM style (where there's no good reason to do 
otherwise).


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:210
@@ +209,3 @@
+// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: pointer parameter 'p' can be
+int functionpointer2(int *p)
+{

Put braces on the previous line, please. A few other instances below.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:238
@@ +237,3 @@
+  // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: pointer parameter 'p' can be
+  C2(int *p) : p(p) {}
+private:

Add a CHECK-FIXES, please.


Comment at: test/clang-tidy/readability-non-const-parameter.cpp:253
@@ +252,3 @@
+class Warn {
+public:
+  // CHECK-MESSAGES: :[[@LINE+1]]:21: warning: pointer parameter 'p' can be

Clang-tidy can't yet analyze multiple translation units simultaneously, so we 
just need to keep cases that can't be correctly handled by analyzing a single 
translation unit at a time in mind (and also in documentation and in tests), so 
that they are less surprising to the user.

However, the check can and should take care of correctly handling this case in 
a single translation unit (as in this test, `use_functionpointer2`). I'm not 
sure it's a frequent case, so I don't insist on fixing this right away. May be 
fine for a follow up.


https://reviews.llvm.org/D15332



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


Re: [PATCH] D22515: [analyzer] Added custom hashing to the CloneDetector.

2016-08-16 Thread Vassil Vassilev via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.

LGTM.


https://reviews.llvm.org/D22515



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


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-16 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1688-1689
@@ -1687,3 +1687,4 @@
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;

David, since we're doing this check to work around a limitation of PDB-based 
debuggers, do you think we should guard check with EmitCodeView, so that we 
don't emit the full type if we're emitting DWARF?

After that, I'd add a comment like:
  // Only emit complete debug info for a dynamic class when its vtable is 
emitted. However,
  // Microsoft debuggers are unable to resolve type information across DLL 
boundaries,
  // so skip this optimization if the class is marked dllimport.


https://reviews.llvm.org/D23462



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


Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-16 Thread Daniel Dunbar via cfe-commits
The original motivation for organizing things this way was to try and
always be in the situation where, when linking against the latest
deployment target, we should never need the extra library (because the
content will be present in libSystem). This is useful in helping to ensure
we don't unnecessarily embed copies of system provided functions.

I know it is quite cumbersome to maintain that policy, but have we
explicitly given it up? Nick, what is your opinion here?

 - Daniel

On Mon, Aug 15, 2016 at 3:51 PM, Chris Bieneman  wrote:

> beanz created this revision.
> beanz added reviewers: ddunbar, bob.wilson.
> beanz added a subscriber: cfe-commits.
>
> The eprintf library was added before the general OS X builtins library
> existed as a place to store one builtin function. Since we have for several
> years had an actual mandated builtin library for OS X > 10.5, we should
> just merge eprintf into the main library.
>
> This change will resolve PR28855.
>
> As a follow up I'll also patch compiler-rt to not generate the eprintf
> library anymore.
>
> https://reviews.llvm.org/D23531
>
> Files:
>   lib/Driver/ToolChains.cpp
>
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -483,8 +483,6 @@
>  if (isMacosxVersionLT(10, 5)) {
>AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
>  } else {
> -  if (getTriple().getArch() == llvm::Triple::x86)
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
>AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
>  }
>}
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

2016-08-16 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D23086#516365, @Anastasia wrote:

> Why not to just identify the type by the name? It seems much easier and also 
> gives flexibility to implement the type in different ways if needed. 
> Considering that similar approach is already used for some C++ types, it 
> should be fine.


This does not work. For example, user could define

  typedef ndrange_t my_ndrange_t;

and pass a variable X of type my_ndrange_t to enqueue_kernel. If we identify 
ndrange_t by type name, X would be identified as not an ndrange_t type and an 
error will be emitted, which is wrong. Therefore we have to check the canonical 
type.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



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


Re: [PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Chris Lattner via cfe-commits
lattner resigned from this revision.
lattner removed a reviewer: lattner.
lattner added a comment.

Seems obvious to me, but it would be best to find another reviewer, I haven't 
worked on this code for some time.


https://reviews.llvm.org/D23546



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


r278814 - Revert "[X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms"

2016-08-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug 16 11:04:14 2016
New Revision: 278814

URL: http://llvm.org/viewvc/llvm-project?rev=278814&view=rev
Log:
Revert "[X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows 
platforms"

This reverts commit r278783.  It breaks usage of _xgetbv on Windows.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=278814&r1=278813&r2=278814&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Aug 16 11:04:14 2016
@@ -644,8 +644,6 @@ TARGET_BUILTIN(__builtin_ia32_fxsave64,
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave")
-TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave")
-TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=278814&r1=278813&r2=278814&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 16 11:04:14 2016
@@ -6915,8 +6915,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_xsavec:
   case X86::BI__builtin_ia32_xsavec64:
   case X86::BI__builtin_ia32_xsaves:
-  case X86::BI__builtin_ia32_xsaves64:
-  case X86::BI__builtin_ia32_xsetbv: {
+  case X86::BI__builtin_ia32_xsaves64: {
 Intrinsic::ID ID;
 #define INTRINSIC_X86_XSAVE_ID(NAME) \
 case X86::BI__builtin_ia32_##NAME: \
@@ -6936,7 +6935,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 INTRINSIC_X86_XSAVE_ID(xsavec64);
 INTRINSIC_X86_XSAVE_ID(xsaves);
 INTRINSIC_X86_XSAVE_ID(xsaves64);
-INTRINSIC_X86_XSAVE_ID(xsetbv);
 }
 #undef INTRINSIC_X86_XSAVE_ID
 Value *Mhi = Builder.CreateTrunc(
@@ -6946,8 +6944,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
-  case X86::BI__builtin_ia32_xgetbv:
-return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);
   case X86::BI__builtin_ia32_storedqudi128_mask:
   case X86::BI__builtin_ia32_storedqusi128_mask:
   case X86::BI__builtin_ia32_storedquhi128_mask:

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=278814&r1=278813&r2=278814&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue Aug 16 11:04:14 2016
@@ -289,6 +289,10 @@ static __inline__
 void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
+static __inline__
+#define _XCR_XFEATURE_ENABLED_MASK 0
+unsigned __int64 __cdecl _xgetbv(unsigned int);
+void __cdecl _xsetbv(unsigned int, unsigned __int64);
 
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
 #ifdef __x86_64__
@@ -904,6 +908,12 @@ __cpuidex(int __info[4], int __level, in
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), 
"=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
+static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
+_xgetbv(unsigned int __xcr_no) {
+  unsigned int __eax, __edx;
+  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
+  return ((unsigned __int64)__edx << 32) | __eax;
+}
 static __inline__ void __DEFAULT_FN_ATTRS
 __halt(void) {
   __asm__ volatile ("hlt");

Modified: cfe/trunk/lib/Headers/xsaveintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xsaveintrin.h?rev=278814&r1=278813&r2=278814&view=diff
==
--- cfe/trunk/lib/Headers/xsaveintrin.h (original)
+++ cfe/trunk/lib/Headers/xsaveintrin.h Tue Aug 16 11:04:14 2016
@@ -28,8 +28,6 @@
 #ifndef __XSAVEINTRIN_H
 #define __XSAVEINTRIN_H
 
-#define _XCR_XFEATURE_ENABLED_MASK 0
-
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("xsave")))
 
@@ -43,16 +41,6 @@ _xrstor(void *__p, unsigned long long __
   return __b

Re: r278783 - [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms

2016-08-16 Thread Reid Kleckner via cfe-commits
Reverted in r278814, it appears to break usage of _xgetbv on Windows:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin%28dll%29/builds/5846/steps/compile/logs/stdio
../../base/cpu.cc(194,10):  error: use of undeclared identifier '_xgetbv'
(_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;

You removed the test in ms-intrin.cpp that would have prevented this
breakage, too.

On Tue, Aug 16, 2016 at 1:13 AM, Marina Yatsina via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: myatsina
> Date: Tue Aug 16 03:13:36 2016
> New Revision: 278783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278783&view=rev
> Log:
> [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows
> platforms
>
> commit on behalf of guyblank
>
> Differential Revision: https://reviews.llvm.org/D21959
>
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/intrin.h
> cfe/trunk/lib/Headers/xsaveintrin.h
> cfe/trunk/test/CodeGen/builtins-x86.c
> cfe/trunk/test/CodeGen/x86_32-xsave.c
> cfe/trunk/test/CodeGen/x86_64-xsave.c
> cfe/trunk/test/Headers/ms-intrin.cpp
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/BuiltinsX86.def?rev=278783&r1=278782&r2=278783&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Aug 16 03:13:36 2016
> @@ -644,6 +644,8 @@ TARGET_BUILTIN(__builtin_ia32_fxsave64,
>  // XSAVE
>  TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave")
> +TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave")
> +TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave")
>  TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGBuiltin.cpp?rev=278783&r1=278782&r2=278783&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 16 03:13:36 2016
> @@ -6915,7 +6915,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>case X86::BI__builtin_ia32_xsavec:
>case X86::BI__builtin_ia32_xsavec64:
>case X86::BI__builtin_ia32_xsaves:
> -  case X86::BI__builtin_ia32_xsaves64: {
> +  case X86::BI__builtin_ia32_xsaves64:
> +  case X86::BI__builtin_ia32_xsetbv: {
>  Intrinsic::ID ID;
>  #define INTRINSIC_X86_XSAVE_ID(NAME) \
>  case X86::BI__builtin_ia32_##NAME: \
> @@ -6935,6 +6936,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  INTRINSIC_X86_XSAVE_ID(xsavec64);
>  INTRINSIC_X86_XSAVE_ID(xsaves);
>  INTRINSIC_X86_XSAVE_ID(xsaves64);
> +INTRINSIC_X86_XSAVE_ID(xsetbv);
>  }
>  #undef INTRINSIC_X86_XSAVE_ID
>  Value *Mhi = Builder.CreateTrunc(
> @@ -6944,6 +6946,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  Ops.push_back(Mlo);
>  return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
>}
> +  case X86::BI__builtin_ia32_xgetbv:
> +return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv),
> Ops);
>case X86::BI__builtin_ia32_storedqudi128_mask:
>case X86::BI__builtin_ia32_storedqusi128_mask:
>case X86::BI__builtin_ia32_storedquhi128_mask:
>
> Modified: cfe/trunk/lib/Headers/intrin.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/
> intrin.h?rev=278783&r1=278782&r2=278783&view=diff
> 
> ==
> --- cfe/trunk/lib/Headers/intrin.h (original)
> +++ cfe/trunk/lib/Headers/intrin.h Tue Aug 16 03:13:36 2016
> @@ -289,10 +289,6 @@ static __inline__
>  void _WriteBarrier(void);
>  unsigned __int32 xbegin(void);
>  void _xend(void);
> -static __inline__
> -#define _XCR_XFEATURE_ENABLED_MASK 0
> -unsigned __int64 __cdecl _xgetbv(unsigned int);
> -void __cdecl _xsetbv(unsigned int, unsigned __int64);
>
>  /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
>  #ifdef __x86_64__
> @@ -908,12 +904,6 @@ __cpuidex(int __info[4], int __level, in
>__asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]),
> "=d"(__info[3])
> : "a"(__level), "c"(__ecx));
>  }
> -static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
> -_xgetbv(unsigned int __xcr_no) {
> -  unsigned int __eax, __edx;
> -  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
> -  return ((unsigned __int64)__edx << 32) | __eax;
> -}
>  static __inline__ void __DEFAULT_FN_ATTRS
>  __halt(void) {
>__asm__ volatile

[clang-tools-extra] r278815 - Remove most instances of REQUIRES: shell from the tools/extra tests

2016-08-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug 16 11:07:46 2016
New Revision: 278815

URL: http://llvm.org/viewvc/llvm-project?rev=278815&view=rev
Log:
Remove most instances of REQUIRES: shell from the tools/extra tests

None of these tests actually require bash, they just have quoting bugs
when paths contain backslashes and colons. Fix them with the "%/T" lit
substitution variants.

Modified:
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp
clang-tools-extra/trunk/test/include-fixer/exit_on_fatal.cpp
clang-tools-extra/trunk/test/include-fixer/fixeddb.cpp
clang-tools-extra/trunk/test/include-fixer/include_path.cpp
clang-tools-extra/trunk/test/include-fixer/merge.test
clang-tools-extra/trunk/test/include-fixer/prefix_variable.cpp
clang-tools-extra/trunk/test/include-fixer/yamldb.cpp
clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp?rev=278815&r1=278814&r2=278815&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp 
Tue Aug 16 11:07:46 2016
@@ -1,4 +1,3 @@
-// REQUIRES: shell
 // RUN: mkdir -p %T/compilation-database-test/include
 // RUN: mkdir -p %T/compilation-database-test/a
 // RUN: mkdir -p %T/compilation-database-test/b
@@ -8,7 +7,7 @@
 // RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
 // RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
 // RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
-// RUN: sed 's|test_dir|%T/compilation-database-test|g' 
%S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: sed 's|test_dir|%/T/compilation-database-test|g' 
%S/Inputs/compilation-database/template.json > %T/compile_commands.json
 // RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T 
%T/compilation-database-test/b/not-exist -header-filter=.*
 // RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T 
%T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp 
%T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp 
%T/compilation-database-test/b/d.cpp -header-filter=.* -fix
 // RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s 
-check-prefix=CHECK-FIX1

Modified: clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp?rev=278815&r1=278814&r2=278815&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp Tue Aug 16 11:07:46 
2016
@@ -1,4 +1,3 @@
-// REQUIRES: shell
 // RUN: mkdir -p %T/clang-tidy/list-checks/
 // RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
 // RUN: cd %T/clang-tidy/list-checks

Modified: clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp?rev=278815&r1=278814&r2=278815&view=diff
==
--- clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp 
(original)
+++ clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp Tue Aug 
16 11:07:46 2016
@@ -1,9 +1,8 @@
-// REQUIRES: shell
 // RUN: echo "foo f;" > %t.cpp
 // RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' 
-output-headers %t.cpp -- | FileCheck %s
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{FilePath: 
%t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 
3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"}]}' %t.cpp | 
FileCheck %s -check-prefix=CHECK-CODE
-// RUN: cat %t.cpp | not clang-include-fixer -stdin -insert-header='{FilePath: 
%t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 
3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "foo"},{Header: 
"\"foo2.h\"", QualifiedName: "foo"}]}' %t.cpp
-// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{FilePath: 
%t.cpp, QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 
3}}], HeaderInfos: [{Header: "\"foo.h\"", QualifiedName: "a:foo"},{Header: 
"\"foo.h\"", QualifiedName: "b:foo"}]}' %t.cpp
+// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='{FilePath: 
"%/t.cpp", QuerySymbolInfos: [{RawIdentifier: foo, Range: {Offset: 0, Length: 
3}}], HeaderInfos

Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-08-16 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

Reverted in r278814, it appears to break usage of _xgetbv on Windows:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin%28dll%29/builds/5846/steps/compile/logs/stdio
../../base/cpu.cc(194,10):  error: use of undeclared identifier '_xgetbv'

  (_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;

You removed the test in ms-intrin.cpp that would have prevented this breakage, 
too.


Repository:
  rL LLVM

https://reviews.llvm.org/D21959



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-16 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D23455#515527, @rnk wrote:

> In https://reviews.llvm.org/D23455#515486, @brad.king wrote:
>
> > > the feasibility of emitting 'arguments' instead of 'command' into the 
> > > JSON compilation database.
> >
> >
> > CMake constructs the command lines internally using string replacement on 
> > templates.  We never actually know the exact arguments.  Therefore 
> > providing arguments instead of the whole command would require parsing to 
> > be done on the CMake side instead.  This is theoretically possible because 
> > we do know the shell for which we are generating (Windows `cmd` versus MSYS 
> > `sh`).  However, it may also require a bunch of logic we don't have yet but 
> > that LLVM does.
> >
> > Alternatively, the JSON could have an additional `command_shell="..."` 
> > field that indicates the shell for which the command line is encoded.
>
>
> Bummer. Given that this is hard to do in CMake, then I think we should just 
> tokenize in Clang. Let's use llvm::sys::getProcessTriple() instead of 
> LLVM_ON_WIN32 and check if that is an MSVC environment as a proxy for the 
> shell type.


Do I understand correctly that `llvm::sys::getProcessTriple()` returns 
basically a compile-time constant? If yes, it won't allow the same clang tool 
binary to be used with both command line formats. Should we instead allow 
runtime selection of the command line format? For example, by extending JSON 
compilation database with the aforementioned `command_shell="..."` option.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-16 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Adding Aaron, since he seems to have interest in Windows support for clang-tidy.


https://reviews.llvm.org/D23455



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


Re: r278763 - PR28978: If we need overload resolution for the move constructor of an

2016-08-16 Thread Hans Wennborg via cfe-commits
r278817. Many thanks.

On Mon, Aug 15, 2016 at 5:36 PM, Richard Smith  wrote:
> Hi Hans, Eric Fiselier requested that we fix this bug for 3.9 (it affects
> libc++'s std::optional implementation), so this would be a good candidate
> for the branch.
>
> On Mon, Aug 15, 2016 at 5:13 PM, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Mon Aug 15 19:13:47 2016
>> New Revision: 278763
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=278763&view=rev
>> Log:
>> PR28978: If we need overload resolution for the move constructor of an
>> anonymous union member of a class, we need overload resolution for the
>> move
>> constructor of the class itself too; we can't rely on Sema to do the right
>> thing for us for anonymous union types.
>>
>> Modified:
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>>
>> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=278763&r1=278762&r2=278763&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 15 19:13:47 2016
>> @@ -807,6 +807,17 @@ void CXXRecordDecl::addedMember(Decl *D)
>>  data().DefaultedDestructorIsDeleted = true;
>>  }
>>
>> +// For an anonymous union member, our overload resolution will
>> perform
>> +// overload resolution for its members.
>> +if (Field->isAnonymousStructOrUnion()) {
>> +  data().NeedOverloadResolutionForMoveConstructor |=
>> +  FieldRec->data().NeedOverloadResolutionForMoveConstructor;
>> +  data().NeedOverloadResolutionForMoveAssignment |=
>> +  FieldRec->data().NeedOverloadResolutionForMoveAssignment;
>> +  data().NeedOverloadResolutionForDestructor |=
>> +  FieldRec->data().NeedOverloadResolutionForDestructor;
>> +}
>> +
>>  // C++0x [class.ctor]p5:
>>  //   A default constructor is trivial [...] if:
>>  //-- for all the non-static data members of its class that
>> are of
>>
>> Modified: cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp?rev=278763&r1=278762&r2=278763&view=diff
>>
>> ==
>> --- cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp (original)
>> +++ cfe/trunk/test/CXX/special/class.copy/p11.0x.move.cpp Mon Aug 15
>> 19:13:47 2016
>> @@ -4,6 +4,9 @@ struct Trivial {};
>>  struct NonTrivial {
>>NonTrivial(NonTrivial&&); // expected-note{{copy constructor is
>> implicitly deleted}}
>>  };
>> +struct DeletedCopy {
>> +  DeletedCopy(const DeletedCopy&) = delete;
>> +};
>>
>>  // A defaulted move constructor for a class X is defined as deleted if X
>> has:
>>
>> @@ -22,6 +25,15 @@ struct DeletedNTVariant2 {
>>  };
>>  DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; //
>> expected-error{{would delete}}
>>
>> +// Note, move constructor is not a candidate because it is deleted.
>> +template struct DeletedNTVariant3 { // expected-note
>> 2{{default}} expected-note 2{{copy}}
>> +  union {
>> +T NT;
>> +  };
>> +};
>> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
>> matching}}
>> +extern DeletedNTVariant3 dntv3a(0); // expected-error {{no
>> matching}}
>> +
>>  // -- a non-static data member of class type M (or array thereof) that
>> cannot be
>>  //copied because overload resolution results in an ambiguity or a
>> function
>>  //that is deleted or inaccessible
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r278783 - [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms

2016-08-16 Thread Yatsina, Marina via cfe-commits
Adding Guy, the author of this commit.

From: Reid Kleckner [mailto:r...@google.com]
Sent: Tuesday, August 16, 2016 19:14
To: Yatsina, Marina 
Cc: cfe-commits 
Subject: Re: r278783 - [X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to 
non-windows platforms

Reverted in r278814, it appears to break usage of _xgetbv on Windows:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin%28dll%29/builds/5846/steps/compile/logs/stdio
../../base/cpu.cc(194,10):  error: use of undeclared identifier '_xgetbv'
(_xgetbv(0) & 6) == 6 /* XSAVE enabled by kernel */;

You removed the test in ms-intrin.cpp that would have prevented this breakage, 
too.

On Tue, Aug 16, 2016 at 1:13 AM, Marina Yatsina via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: myatsina
Date: Tue Aug 16 03:13:36 2016
New Revision: 278783

URL: http://llvm.org/viewvc/llvm-project?rev=278783&view=rev
Log:
[X86] Add xgetbv/x[X86] Add xgetbv xsetbv intrinsics to non-windows platforms

commit on behalf of guyblank

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/intrin.h
cfe/trunk/lib/Headers/xsaveintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/x86_32-xsave.c
cfe/trunk/test/CodeGen/x86_64-xsave.c
cfe/trunk/test/Headers/ms-intrin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Aug 16 03:13:36 2016
@@ -644,6 +644,8 @@ TARGET_BUILTIN(__builtin_ia32_fxsave64,
 // XSAVE
 TARGET_BUILTIN(__builtin_ia32_xsave, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsave64, "vv*ULLi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xgetbv, "ULLiUi", "", "xsave")
+TARGET_BUILTIN(__builtin_ia32_xsetbv, "vUiULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xrstor64, "vv*ULLi", "", "xsave")
 TARGET_BUILTIN(__builtin_ia32_xsaveopt, "vv*ULLi", "", "xsaveopt")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 16 03:13:36 2016
@@ -6915,7 +6915,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_xsavec:
   case X86::BI__builtin_ia32_xsavec64:
   case X86::BI__builtin_ia32_xsaves:
-  case X86::BI__builtin_ia32_xsaves64: {
+  case X86::BI__builtin_ia32_xsaves64:
+  case X86::BI__builtin_ia32_xsetbv: {
 Intrinsic::ID ID;
 #define INTRINSIC_X86_XSAVE_ID(NAME) \
 case X86::BI__builtin_ia32_##NAME: \
@@ -6935,6 +6936,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 INTRINSIC_X86_XSAVE_ID(xsavec64);
 INTRINSIC_X86_XSAVE_ID(xsaves);
 INTRINSIC_X86_XSAVE_ID(xsaves64);
+INTRINSIC_X86_XSAVE_ID(xsetbv);
 }
 #undef INTRINSIC_X86_XSAVE_ID
 Value *Mhi = Builder.CreateTrunc(
@@ -6944,6 +6946,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Ops.push_back(Mlo);
 return Builder.CreateCall(CGM.getIntrinsic(ID), Ops);
   }
+  case X86::BI__builtin_ia32_xgetbv:
+return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_xgetbv), Ops);
   case X86::BI__builtin_ia32_storedqudi128_mask:
   case X86::BI__builtin_ia32_storedqusi128_mask:
   case X86::BI__builtin_ia32_storedquhi128_mask:

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=278783&r1=278782&r2=278783&view=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Tue Aug 16 03:13:36 2016
@@ -289,10 +289,6 @@ static __inline__
 void _WriteBarrier(void);
 unsigned __int32 xbegin(void);
 void _xend(void);
-static __inline__
-#define _XCR_XFEATURE_ENABLED_MASK 0
-unsigned __int64 __cdecl _xgetbv(unsigned int);
-void __cdecl _xsetbv(unsigned int, unsigned __int64);

 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
 #ifdef __x86_64__
@@ -908,12 +904,6 @@ __cpuidex(int __info[4], int __level, in
   __asm__ ("cpuid" : "=a"(__info[0]), "=b" (__info[1]), "=c"(__info[2]), 
"=d"(__info[3])
: "a"(__level), "c"(__ecx));
 }
-static __inline__ unsigned __int64 __cdecl __DEFAULT_FN_ATTRS
-_xgetbv(unsigned int __xcr_no) {
-  unsigned int __eax, __edx;
-  __asm__ ("xgetbv" : "=a" (__eax), "=d" (__edx) : "c" (__xcr_no));
-  return ((unsigned __int64)__edx << 32) | __eax;
-}
 static __inline__ 

Re: Nomination for 3.9: r278786 - Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread Hans Wennborg via cfe-commits
Seems reasonable to me if Richard agrees.

On Tue, Aug 16, 2016 at 3:01 AM, James Molloy  wrote:
> Hi Hans,
>
> [cc. Richard as code owner]
>
> I'd like to nominate this commit for 3.9. The actual code churn is tiny, and
> this fixes a problem noticed by and causing pain to the qemu project.
>
> Cheers,
>
> James
>
> On Tue, 16 Aug 2016 at 10:53 James Molloy via cfe-commits
>  wrote:
>>
>> Author: jamesm
>> Date: Tue Aug 16 04:45:36 2016
>> New Revision: 278786
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=278786&view=rev
>> Log:
>> Left shifts of negative values are defined if -fwrapv is set
>>
>> This means we shouldn't emit ubsan detection code or warn.
>> Fixes PR25552.
>>
>> Added:
>> cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>> cfe/trunk/test/Sema/negative-shift-wrapv.c
>> Modified:
>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=278786&r1=278785&r2=278786&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 16 04:45:36 2016
>> @@ -2714,7 +2714,8 @@ Value *ScalarExprEmitter::EmitShl(const
>>  RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
>> "sh_prom");
>>
>>bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
>> -  Ops.Ty->hasSignedIntegerRepresentation();
>> +  Ops.Ty->hasSignedIntegerRepresentation() &&
>> +  !CGF.getLangOpts().isSignedOverflowDefined();
>>bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
>>// OpenCL 6.3j: shift values are effectively % word size of LHS.
>>if (CGF.getLangOpts().OpenCL)
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278786&r1=278785&r2=278786&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 16 04:45:36 2016
>> @@ -8670,7 +8670,7 @@ static void DiagnoseBadShiftValues(Sema&
>>
>>// If LHS does not have a signed type and non-negative value
>>// then, the behavior is undefined. Warn about it.
>> -  if (Left.isNegative()) {
>> +  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
>>  S.DiagRuntimeBehavior(Loc, LHS.get(),
>>S.PDiag(diag::warn_shift_lhs_negative)
>>  << LHS.get()->getSourceRange());
>>
>> Added: cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c?rev=278786&view=auto
>>
>> ==
>> --- cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c (added)
>> +++ cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c Tue Aug 16 04:45:36 2016
>> @@ -0,0 +1,12 @@
>> +// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple
>> x86_64-linux-gnu -fwrapv | FileCheck %s
>> +
>> +// CHECK-LABEL: @lsh_overflow
>> +int lsh_overflow(int a, int b) {
>> +  // CHECK-NOT: br
>> +  // CHECK-NOT: call void @__ubsan_
>> +  // CHECK-NOT: call void @llvm.trap
>> +
>> +  // CHECK:  %[[RET:.*]] = shl i32
>> +  // CHECK-NEXT: ret i32 %[[RET]]
>> +  return a << b;
>> +}
>>
>> Added: cfe/trunk/test/Sema/negative-shift-wrapv.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/negative-shift-wrapv.c?rev=278786&view=auto
>>
>> ==
>> --- cfe/trunk/test/Sema/negative-shift-wrapv.c (added)
>> +++ cfe/trunk/test/Sema/negative-shift-wrapv.c Tue Aug 16 04:45:36 2016
>> @@ -0,0 +1,9 @@
>> +// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
>> +
>> +int test() {
>> +  int i;
>> +  i = -1 << 1; // no-warning
>> +  return i;
>> +}
>> +
>> +// expected-no-diagnostics
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-16 Thread Zachary Turner via cfe-commits
zturner added a comment.

In https://reviews.llvm.org/D23455#516753, @alexfh wrote:

> In https://reviews.llvm.org/D23455#515527, @rnk wrote:
>
> > In https://reviews.llvm.org/D23455#515486, @brad.king wrote:
> >
> > > > the feasibility of emitting 'arguments' instead of 'command' into the 
> > > > JSON compilation database.
> > >
> > >
> > > CMake constructs the command lines internally using string replacement on 
> > > templates.  We never actually know the exact arguments.  Therefore 
> > > providing arguments instead of the whole command would require parsing to 
> > > be done on the CMake side instead.  This is theoretically possible 
> > > because we do know the shell for which we are generating (Windows `cmd` 
> > > versus MSYS `sh`).  However, it may also require a bunch of logic we 
> > > don't have yet but that LLVM does.
> > >
> > > Alternatively, the JSON could have an additional `command_shell="..."` 
> > > field that indicates the shell for which the command line is encoded.
> >
> >
> > Bummer. Given that this is hard to do in CMake, then I think we should just 
> > tokenize in Clang. Let's use llvm::sys::getProcessTriple() instead of 
> > LLVM_ON_WIN32 and check if that is an MSVC environment as a proxy for the 
> > shell type.
>
>
> Do I understand correctly that `llvm::sys::getProcessTriple()` returns 
> basically a compile-time constant? If yes, it won't allow the same clang tool 
> binary to be used with both command line formats. Should we instead allow 
> runtime selection of the command line format? For example, by extending JSON 
> compilation database with the aforementioned `command_shell="..."` option.


It does return a compile time constant, but it is a compile time constant 
representing the platform that clang-tidy is running on.  I don't see a need to 
have a single clang-tidy binary be able to parse both command line formats.  In 
fact, it seems actively harmful.

If you are running on a Windows system with windows command line parsing rules, 
and someone has generated a command line on linux, then this command line was 
never intended to be run on Windows in the first place.  The JSON compilation 
database spec already says that the command line represents "the exact command 
to be run **in the environment of the build system**".  By adding the 
flexibility to change the environment, this is no longer true.  If I try to run 
a command generated for one build system in the environment of another build 
system, even if I tokenize it correctly whose to say it will work?

I understand the desire to make sure we get the right change so we don't have 
to revisit this in the future, but to me this sounds like YAGNI and actually 
increasing the risk of someone using the software and getting unexpected 
results, not less risk.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D21134: clang-tidy: new check readability-misplaced-array-index

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


Comment at: clang-tidy/readability/MisplacedArrayIndexCheck.cpp:56
@@ +55,3 @@
+  if (hasMacroID(ArraySubscriptE) ||
+  
!Result.SourceManager->isWrittenInSameFile(ArraySubscriptE->getLocStart(),
+ ArraySubscriptE->getLocEnd()))

Both ranges seem to be using `ArraySubscriptE->getLHS()->getSourceRange()`. I 
guess, the second one should refer to 
`ArraySubscriptE->getRHS()->getSourceRange()` instead?


Comment at: docs/clang-tidy/checks/readability-misplaced-array-index.rst:12
@@ +11,3 @@
+
+  void f(int *x, int y)
+  {

Please format examples according to LLVM style (specifically, leave braces at 
the end of the previous line.


Comment at: test/clang-tidy/readability-misplaced-array-index.cpp:16
@@ +15,3 @@
+  10[xy->x] = 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: confusing array subscript 
expression, usually the index is inside the []
+  // CHECK-FIXES: xy->x[10] = 0;

Please truncate all CHECK-MESSAGES except for the first one after "confusing 
array subscript expression".


Comment at: test/clang-tidy/readability-misplaced-array-index.cpp:25
@@ +24,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: confusing array subscript 
expression, usually the index is inside the []
+  // No fixit, we don't want to replace with "abc"[1]
+

Please add a CHECK-FIXES to verify the original code is left intact. Same for 
other places where no fixits are expected.


https://reviews.llvm.org/D21134



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


Re: Nomination for 3.9: r278786 - Left shifts of negative values are defined if -fwrapv is set

2016-08-16 Thread Aaron Ballman via cfe-commits
I'm not Richard, but I agree with merging it into 3.9 nonetheless. :-)

~Aaron

On Tue, Aug 16, 2016 at 12:30 PM, Hans Wennborg via cfe-commits
 wrote:
> Seems reasonable to me if Richard agrees.
>
> On Tue, Aug 16, 2016 at 3:01 AM, James Molloy  wrote:
>> Hi Hans,
>>
>> [cc. Richard as code owner]
>>
>> I'd like to nominate this commit for 3.9. The actual code churn is tiny, and
>> this fixes a problem noticed by and causing pain to the qemu project.
>>
>> Cheers,
>>
>> James
>>
>> On Tue, 16 Aug 2016 at 10:53 James Molloy via cfe-commits
>>  wrote:
>>>
>>> Author: jamesm
>>> Date: Tue Aug 16 04:45:36 2016
>>> New Revision: 278786
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=278786&view=rev
>>> Log:
>>> Left shifts of negative values are defined if -fwrapv is set
>>>
>>> This means we shouldn't emit ubsan detection code or warn.
>>> Fixes PR25552.
>>>
>>> Added:
>>> cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>>> cfe/trunk/test/Sema/negative-shift-wrapv.c
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=278786&r1=278785&r2=278786&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 16 04:45:36 2016
>>> @@ -2714,7 +2714,8 @@ Value *ScalarExprEmitter::EmitShl(const
>>>  RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
>>> "sh_prom");
>>>
>>>bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
>>> -  Ops.Ty->hasSignedIntegerRepresentation();
>>> +  Ops.Ty->hasSignedIntegerRepresentation() &&
>>> +  !CGF.getLangOpts().isSignedOverflowDefined();
>>>bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent);
>>>// OpenCL 6.3j: shift values are effectively % word size of LHS.
>>>if (CGF.getLangOpts().OpenCL)
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278786&r1=278785&r2=278786&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 16 04:45:36 2016
>>> @@ -8670,7 +8670,7 @@ static void DiagnoseBadShiftValues(Sema&
>>>
>>>// If LHS does not have a signed type and non-negative value
>>>// then, the behavior is undefined. Warn about it.
>>> -  if (Left.isNegative()) {
>>> +  if (Left.isNegative() && !S.getLangOpts().isSignedOverflowDefined()) {
>>>  S.DiagRuntimeBehavior(Loc, LHS.get(),
>>>S.PDiag(diag::warn_shift_lhs_negative)
>>>  << LHS.get()->getSourceRange());
>>>
>>> Added: cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c?rev=278786&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c (added)
>>> +++ cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c Tue Aug 16 04:45:36 2016
>>> @@ -0,0 +1,12 @@
>>> +// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple
>>> x86_64-linux-gnu -fwrapv | FileCheck %s
>>> +
>>> +// CHECK-LABEL: @lsh_overflow
>>> +int lsh_overflow(int a, int b) {
>>> +  // CHECK-NOT: br
>>> +  // CHECK-NOT: call void @__ubsan_
>>> +  // CHECK-NOT: call void @llvm.trap
>>> +
>>> +  // CHECK:  %[[RET:.*]] = shl i32
>>> +  // CHECK-NEXT: ret i32 %[[RET]]
>>> +  return a << b;
>>> +}
>>>
>>> Added: cfe/trunk/test/Sema/negative-shift-wrapv.c
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/negative-shift-wrapv.c?rev=278786&view=auto
>>>
>>> ==
>>> --- cfe/trunk/test/Sema/negative-shift-wrapv.c (added)
>>> +++ cfe/trunk/test/Sema/negative-shift-wrapv.c Tue Aug 16 04:45:36 2016
>>> @@ -0,0 +1,9 @@
>>> +// RUN: %clang_cc1 -Wall -ffreestanding -fsyntax-only -fwrapv -verify %s
>>> +
>>> +int test() {
>>> +  int i;
>>> +  i = -1 << 1; // no-warning
>>> +  return i;
>>> +}
>>> +
>>> +// expected-no-diagnostics
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

2016-08-16 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D23086#516741, @yaxunl wrote:

> In https://reviews.llvm.org/D23086#516365, @Anastasia wrote:
>
> > Why not to just identify the type by the name? It seems much easier and 
> > also gives flexibility to implement the type in different ways if needed. 
> > Considering that similar approach is already used for some C++ types, it 
> > should be fine.
>
>
> This does not work. For example, user could define
>
>   typedef ndrange_t my_ndrange_t;
>   
>
> and pass a variable X of type my_ndrange_t to enqueue_kernel. If we identify 
> ndrange_t by type name, X would be identified as not an ndrange_t type and an 
> error will be emitted, which is wrong. Therefore we have to check the 
> canonical type.


Right. I am wondering if in C++ use cases, that David have mentioned, they 
already handle this.

@majnemer, do you have any solution for this issue in your use cases? Checking 
for the name of the type seems to be unsafe in case of custom typedefs creating 
aliases of the same type with different names? Also forcing the structure in 
Clang is undesirable for us because vendors might have different (more 
suitable) implementations of the type.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086



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


r278826 - [ObjC] Warn on unguarded use of partial declaration

2016-08-16 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Aug 16 12:44:11 2016
New Revision: 278826

URL: http://llvm.org/viewvc/llvm-project?rev=278826&view=rev
Log:
[ObjC] Warn on unguarded use of partial declaration

This commit adds a traversal of the AST after Sema of a function that diagnoses
unguarded references to declarations that are partially available (based on
availability attributes). This traversal is only done when we would otherwise
emit -Wpartial-availability.

This commit is part of a feature I proposed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

Differential revision: https://reviews.llvm.org/D23003

Added:
cfe/trunk/test/SemaObjC/unguarded-availability.m
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Sema/JumpDiagnostics.cpp
cfe/trunk/lib/Sema/ScopeInfo.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Parser/objc-available.m
cfe/trunk/test/Sema/attr-availability.c
cfe/trunk/test/SemaObjC/attr-availability.m
cfe/trunk/test/SemaObjC/property-deprecated-warning.m

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=278826&r1=278825&r2=278826&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Aug 16 12:44:11 2016
@@ -933,6 +933,8 @@ public:
   bool isConstexpr() const { return IfStmtBits.IsConstexpr; }
   void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; }
 
+  bool isObjCAvailabilityCheck() const;
+
   SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; }
   SourceLocation getLocEnd() const LLVM_READONLY {
 if (SubExprs[ELSE])

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=278826&r1=278825&r2=278826&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Aug 16 12:44:11 2016
@@ -95,8 +95,9 @@ def CXX11CompatDeprecatedWritableStr :
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
-def PartialAvailability : DiagGroup<"partial-availability">;
 def UnguardedAvailability : DiagGroup<"unguarded-availability">;
+// partial-availability is an alias of unguarded-availability.
+def : DiagGroup<"partial-availability", [UnguardedAvailability]>;
 def DeprecatedImplementations :DiagGroup<"deprecated-implementations">;
 def DeprecatedIncrementBool : DiagGroup<"deprecated-increment-bool">;
 def DeprecatedRegister : DiagGroup<"deprecated-register">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278826&r1=278825&r2=278826&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 16 12:44:11 
2016
@@ -2656,8 +2656,20 @@ def note_overridden_method : Note<
 def note_protocol_method : Note<
   "protocol method is here">;
 
-def warn_available_using_star_case : Warning<
-  "using '*' case here, platform %0 is not accounted for">, 
InGroup;
+def warn_unguarded_availability :
+  Warning<"%0 is only available on %1 %2 or newer">,
+  InGroup, DefaultIgnore;
+def warn_partial_availability : Warning<"%0 is only available conditionally">,
+InGroup, DefaultIgnore;
+def note_partial_availability_silence : Note<
+  "explicitly redeclare %0 to silence this warning">;
+def note_unguarded_available_silence : Note<
+  "enclose %0 in an @available check to silence this warning">;
+def warn_partial_message : Warning<"%0 is partial: %1">,
+InGroup, DefaultIgnore;
+def warn_partial_fwdclass_message : Warning<
+"%0 may be partial because the receiver type is unknown">,
+InGroup, DefaultIgnore;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<
@@ -4279,15 +4291,6 @@ def err_not_found_by_two_phase_lookup :
 def note_not_found_by_two_phase_lookup : Note<"%0 should be declared prior to 
the "
 "call site%select{| or in %2| or in an associated namespace of one of its 
arguments}1">;
 def err_undeclared_use : Error<"use of undeclared %0">;
-def warn_partial_availability : Warning<"%0 is only available condit

Re: [PATCH] D23003: [ObjC Availability] Warn upon unguarded use of partially available declaration

2016-08-16 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278826: [ObjC] Warn on unguarded use of partial declaration 
(authored by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D23003?vs=67713&id=68218#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23003

Files:
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/ScopeInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/Sema/JumpDiagnostics.cpp
  cfe/trunk/lib/Sema/ScopeInfo.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/test/Parser/objc-available.m
  cfe/trunk/test/Sema/attr-availability.c
  cfe/trunk/test/SemaObjC/attr-availability.m
  cfe/trunk/test/SemaObjC/property-deprecated-warning.m
  cfe/trunk/test/SemaObjC/unguarded-availability.m

Index: cfe/trunk/test/Sema/attr-availability.c
===
--- cfe/trunk/test/Sema/attr-availability.c
+++ cfe/trunk/test/Sema/attr-availability.c
@@ -30,7 +30,7 @@
   ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in macOS 9.0 - use ATSFontGetFullPostScriptName}}
 
 #if defined(WARN_PARTIAL)
-  // expected-warning@+2 {{is partial: introduced in macOS 10.8}} expected-note@+2 {{explicitly redeclare 'PartiallyAvailable' to silence this warning}}
+  // expected-warning@+2 {{is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'PartiallyAvailable' in an @available check to silence this warning}}
 #endif
   PartiallyAvailable();
 }
Index: cfe/trunk/test/SemaObjC/property-deprecated-warning.m
===
--- cfe/trunk/test/SemaObjC/property-deprecated-warning.m
+++ cfe/trunk/test/SemaObjC/property-deprecated-warning.m
@@ -9,7 +9,7 @@
 @property(nonatomic,assign) id ptarget __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'ptarget' is declared deprecated here}} expected-note {{'ptarget' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note@+2 {{property 'partialPtarget' is declared partial here}} expected-note@+2 {{'partialPtarget' has been explicitly marked partial here}}
+// expected-note@+2 {{'partialPtarget' has been explicitly marked partial here}}
 #endif
 @property(nonatomic,assign) id partialPtarget __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -24,7 +24,7 @@
 @property(nonatomic,assign) id target __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{property 'target' is declared deprecated here}} expected-note {{'setTarget:' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note@+2 {{property 'partialTarget' is declared partial here}} expected-note@+2 {{'setPartialTarget:' has been explicitly marked partial here}}
+// expected-note@+2 {{'setPartialTarget:' has been explicitly marked partial here}}
 #endif
 @property(nonatomic,assign) id partialTarget __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -40,7 +40,7 @@
 // expected-note 2 {{'setDep_target:' has been explicitly marked deprecated here}}
 
 #if defined(WARN_PARTIAL)
-// expected-note@+2 4 {{property 'partial_dep_target' is declared partial here}} expected-note@+2 2 {{'partial_dep_target' has been explicitly marked partial here}} expected-note@+2 2 {{'setPartial_dep_target:' has been explicitly marked partial here}}
+// expected-note@+2 2 {{'partial_dep_target' has been explicitly marked partial here}} expected-note@+2 2 {{'setPartial_dep_target:' has been explicitly marked partial here}}
 #endif
 @property(nonatomic,assign) id partial_dep_target  __attribute__((availability(ios,introduced=5.0)));
 @end
@@ -57,7 +57,7 @@
   [self setPtarget: (id)0]; // no-warning
   [self setPartialTarget: (id)0]; // no-warning
 #if defined(WARN_PARTIAL)
-  // expected-warning@+2 {{'partial_dep_target' is partial: introduced in iOS 5.0}} expected-warning@+2 {{'setPartial_dep_target:' is partial: introduced in iOS 5.0}} expected-note@+2 {{explicitly redeclare 'partial_dep_target' to silence this warning}} expected-note@+2 {{explicitly redeclare 'setPartial_dep_target:' to silence this warning}}
+  // expected-warning@+2 {{'partial_dep_target' is only available on iOS 5.0 or newer}} expected-warning@+2 {{'setPartial_dep_target:' is only available on iOS 5.0 or newer}} expected-note@+2 {{enclose 'partial_dep_target' in an @available check to silence this warning}} expected-note@+2 {{enclose 'setPartial_dep_target:' in an @available check to silence this warning}}
 #endif
   [self setPartial_dep_target: [self partial_dep_t

Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-16 Thread Manuel Klimek via cfe-commits
klimek added a reviewer: diltsman.
klimek added a comment.

+Daniel dilts who wrote the arguments support

One problem is that getting into the game of parsing arbitrary shell modes is 
rather ugly.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-16 Thread Adrian McCarthy via cfe-commits
amccarth updated this revision to Diff 68225.
amccarth added a comment.

Add comment as requested.


https://reviews.llvm.org/D23462

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-dllimport-base-class.cpp

Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview 
-debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show 
the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,12 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  // Only emit complete debug info for a dynamic class when its vtable is
+  // emitted.  However, Microsoft debuggers don't resolve type information
+  // across DLL boundaries, so skip this optimization if the class is marked
+  // dllimport.
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;


Index: test/CodeGenCXX/debug-info-dllimport-base-class.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-dllimport-base-class.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview -debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1685,7 +1685,12 @@
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  // Only emit complete debug info for a dynamic class when its vtable is
+  // emitted.  However, Microsoft debuggers don't resolve type information
+  // across DLL boundaries, so skip this optimization if the class is marked
+  // dllimport.
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-16 Thread Adrian McCarthy via cfe-commits
amccarth added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1688-1689
@@ -1687,3 +1687,4 @@
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;

rnk wrote:
> David, since we're doing this check to work around a limitation of PDB-based 
> debuggers, do you think we should guard check with EmitCodeView, so that we 
> don't emit the full type if we're emitting DWARF?
> 
> After that, I'd add a comment like:
>   // Only emit complete debug info for a dynamic class when its vtable is 
> emitted. However,
>   // Microsoft debuggers are unable to resolve type information across DLL 
> boundaries,
>   // so skip this optimization if the class is marked dllimport.
Comment added.

I don't think the EmitCodeView check is necessary because it seems unlikely the 
DLLImportAttr would be set with DWARF debug info, and, even if it is, I 
wouldn't expect it to do any harm.  But I'll defer to dblaikie or other DWARF 
experts.


https://reviews.llvm.org/D23462



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


[PATCH] D23573: [OpenCL] Add extension cl_khr_subgroups to clang

2016-08-16 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: yaxunl, Anastasia.
ashi1 added a subscriber: cfe-commits.
ashi1 set the repository for this revision to rL LLVM.

Adding extension cl_khr_subgroups to clang's OpenCL Extensions and initiated 
inside AMDGPU Target. Similar to https://reviews.llvm.org/D22637 

Repository:
  rL LLVM

https://reviews.llvm.org/D23573

Files:
  lib/Basic/Targets.cpp
  test/Misc/amdgcn.languageOptsOpenCL.cl
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -247,6 +247,9 @@
 #error "Missing cl_khr_subgroups define"
 #endif
 #else
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -199,11 +199,17 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 
'cl_khr_srgb_image_writes' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroups
+#error "Missing cl_khr_subgroups define"
+#endif
+#else
 #ifdef cl_khr_subgroups
 #error "Incorrect cl_khr_subgroups define"
 #endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
+#endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 
 #ifdef cl_khr_terminate_context
 #error "Incorrect cl_khr_terminate_context define"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2127,6 +2127,7 @@
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
+  Opts.cl_khr_subgroups = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }


Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -247,6 +247,9 @@
 #error "Missing cl_khr_subgroups define"
 #endif
 #else
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
Index: test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- test/Misc/amdgcn.languageOptsOpenCL.cl
+++ test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -199,11 +199,17 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_srgb_image_writes' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroups
+#error "Missing cl_khr_subgroups define"
+#endif
+#else
 #ifdef cl_khr_subgroups
 #error "Incorrect cl_khr_subgroups define"
 #endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
+#endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 
 #ifdef cl_khr_terminate_context
 #error "Incorrect cl_khr_terminate_context define"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2127,6 +2127,7 @@
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
+  Opts.cl_khr_subgroups = 1;
   Opts.cl_khr_3d_image_writes = 1;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-16 Thread Chris Bieneman via cfe-commits
Today, the code includes the eprintf archive on all linker invocations for i386 
that include the OS X archive.

Removing the eprintf library from the command and including eprintf only for 
i386 in the OS X archive should be equivalent to what we have today.

-Chris

> On Aug 16, 2016, at 8:27 AM, Daniel Dunbar via cfe-commits 
>  wrote:
> 
> The original motivation for organizing things this way was to try and always 
> be in the situation where, when linking against the latest deployment target, 
> we should never need the extra library (because the content will be present 
> in libSystem). This is useful in helping to ensure we don't unnecessarily 
> embed copies of system provided functions.
> 
> I know it is quite cumbersome to maintain that policy, but have we explicitly 
> given it up? Nick, what is your opinion here?
> 
>  - Daniel
> 
> On Mon, Aug 15, 2016 at 3:51 PM, Chris Bieneman  > wrote:
> beanz created this revision.
> beanz added reviewers: ddunbar, bob.wilson.
> beanz added a subscriber: cfe-commits.
> 
> The eprintf library was added before the general OS X builtins library 
> existed as a place to store one builtin function. Since we have for several 
> years had an actual mandated builtin library for OS X > 10.5, we should just 
> merge eprintf into the main library.
> 
> This change will resolve PR28855.
> 
> As a follow up I'll also patch compiler-rt to not generate the eprintf 
> library anymore.
> 
> https://reviews.llvm.org/D23531 
> 
> Files:
>   lib/Driver/ToolChains.cpp
> 
> Index: lib/Driver/ToolChains.cpp
> ===
> --- lib/Driver/ToolChains.cpp
> +++ lib/Driver/ToolChains.cpp
> @@ -483,8 +483,6 @@
>  if (isMacosxVersionLT(10, 5)) {
>AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
>  } else {
> -  if (getTriple().getArch() == llvm::Triple::x86)
> -AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
>AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
>  }
>}
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D23375: Add kfree( ) to MallocChecker.cpp

2016-08-16 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

I would recommend putting the tests in existing test files next to tests that 
for similar diagnostics for other allocation/free schemes. So the test for 
printExpectedAllocName() should go in test/Analysis/free.c and the test for 
printExpectedDeallocName() should probably go in 
test/Analysis/MismatchedDeallocator-checker-test.mm.


https://reviews.llvm.org/D23375



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


Re: [PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good, thanks. Do you have commit access?


https://reviews.llvm.org/D23546



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


Re: [PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thanks, no, i don't. I will be grateful to you if you land this patch.


https://reviews.llvm.org/D23546



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


Re: [PATCH] D23361: [OpenCL] AMDGCN: Fix size_t type

2016-08-16 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:101
@@ -100,3 +100,3 @@
   DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
   PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
   PointerAlignInBytes =

joey wrote:
> What if you create a new function in TargetInfo called 
> getMaxPointerWidth(unsigned AddrSpace), and call that here? That would by 
> default just call 'getPointerWidth', but in your AMDGPU TargetInfo you can 
> override that.
> That feels more generic.
Thanks for your suggestion. There are some other changes needed in addition to 
that.


https://reviews.llvm.org/D23361



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


Re: [PATCH] D23555: [analyzer] CloneDetector now checks template arguments of function calls.

2016-08-16 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/Analysis/CloneDetection.cpp:154
@@ -153,2 +153,3 @@
 // Function pointers don't have a callee and we just skip hashing it.
-if (S->getDirectCallee())
+if (S->getDirectCallee()) {
+  // If the function is a template instantiation, we also need to handle

Maybe `if (const FunctionDecl *D = S->getDirectCallee())` here, and then use 
`D` everywhere inside the `if`?


Comment at: lib/Analysis/CloneDetection.cpp:164
@@ +163,3 @@
+for (unsigned i = 0; i < Args->size(); ++i) {
+  Args->get(i).print(Context.getLangOpts(), OS);
+}

We don't discriminate between `foo()` and `foo()` here, because 
in both cases the stuff we hash gets concatenated to `AAA`. Just thought that 
we might be having this common problem everywhere, even though it barely shows 
up "in real life".


Comment at: test/Analysis/copypaste/call.cpp:41
@@ +40,3 @@
+template
+bool tempFunc() { unsigned i = N; return false; }
+

"temp" feels a lot more like "temporary" than like "template" (?)


https://reviews.llvm.org/D23555



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


Re: [PATCH] D23546: Remove excessive padding from LineNoCacheTy

2016-08-16 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278838: Remove excessive padding from LineNoCacheTy 
(authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D23546?vs=68153&id=68240#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23546

Files:
  llvm/trunk/lib/Support/SourceMgr.cpp

Index: llvm/trunk/lib/Support/SourceMgr.cpp
===
--- llvm/trunk/lib/Support/SourceMgr.cpp
+++ llvm/trunk/lib/Support/SourceMgr.cpp
@@ -26,8 +26,8 @@
 
 namespace {
   struct LineNoCacheTy {
-unsigned LastQueryBufferID;
 const char *LastQuery;
+unsigned LastQueryBufferID;
 unsigned LineNoOfQuery;
   };
 }


Index: llvm/trunk/lib/Support/SourceMgr.cpp
===
--- llvm/trunk/lib/Support/SourceMgr.cpp
+++ llvm/trunk/lib/Support/SourceMgr.cpp
@@ -26,8 +26,8 @@
 
 namespace {
   struct LineNoCacheTy {
-unsigned LastQueryBufferID;
 const char *LastQuery;
+unsigned LastQueryBufferID;
 unsigned LineNoOfQuery;
   };
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23361: [OpenCL] AMDGCN: Fix size_t type

2016-08-16 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 68241.
yaxunl added a comment.

Remove language dependency. Choose proper integer types for pointer arithmetic.


https://reviews.llvm.org/D23361

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypeCache.h
  test/CodeGenOpenCL/size_t.cl

Index: test/CodeGenOpenCL/size_t.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/size_t.cl
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir-unknown-unknown -o - | FileCheck --check-prefix=SZ32 %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple spir64-unknown-unknown -o - | FileCheck --check-prefix=SZ64 --check-prefix=SZ64ONLY %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -finclude-default-header -emit-llvm -O0 -triple amdgcn-- -o - | FileCheck --check-prefix=SZ64 --check-prefix=AMDONLY %s
+
+//SZ32: define{{.*}} i32 @test_ptrtoint_private(i8* %x)
+//SZ32: ptrtoint i8* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_ptrtoint_private(i8* %x)
+//SZ64: ptrtoint i8* %{{.*}} to i64
+size_t test_ptrtoint_private(private char* x) {
+  return (size_t)x;
+}
+
+//SZ32: define{{.*}} i32 @test_ptrtoint_global(i8 addrspace(1)* %x)
+//SZ32: ptrtoint i8 addrspace(1)* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_ptrtoint_global(i8 addrspace(1)* %x)
+//SZ64: ptrtoint i8 addrspace(1)* %{{.*}} to i64
+intptr_t test_ptrtoint_global(global char* x) {
+  return (intptr_t)x;
+}
+
+//SZ32: define{{.*}} i32 @test_ptrtoint_constant(i8 addrspace(2)* %x)
+//SZ32: ptrtoint i8 addrspace(2)* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_ptrtoint_constant(i8 addrspace(2)* %x)
+//SZ64: ptrtoint i8 addrspace(2)* %{{.*}} to i64
+uintptr_t test_ptrtoint_constant(constant char* x) {
+  return (uintptr_t)x;
+}
+
+//SZ32: define{{.*}} i32 @test_ptrtoint_local(i8 addrspace(3)* %x)
+//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_ptrtoint_local(i8 addrspace(3)* %x)
+//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
+size_t test_ptrtoint_local(local char* x) {
+  return (size_t)x;
+}
+
+//SZ32: define{{.*}} i32 @test_ptrtoint_generic(i8 addrspace(4)* %x)
+//SZ32: ptrtoint i8 addrspace(4)* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_ptrtoint_generic(i8 addrspace(4)* %x)
+//SZ64: ptrtoint i8 addrspace(4)* %{{.*}} to i64
+size_t test_ptrtoint_generic(generic char* x) {
+  return (size_t)x;
+}
+
+//SZ32: define{{.*}} i8* @test_inttoptr_private(i32 %x)
+//SZ32: inttoptr i32 %{{.*}} to i8*
+//SZ64: define{{.*}} i8* @test_inttoptr_private(i64 %x)
+//SZ64: inttoptr i64 %{{.*}} to i8*
+private char* test_inttoptr_private(size_t x) {
+  return (private char*)x;
+}
+
+//SZ32: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i32 %x)
+//SZ32: inttoptr i32 %{{.*}} to i8 addrspace(1)*
+//SZ64: define{{.*}} i8 addrspace(1)* @test_inttoptr_global(i64 %x)
+//SZ64: inttoptr i64 %{{.*}} to i8 addrspace(1)*
+global char* test_inttoptr_global(size_t x) {
+  return (global char*)x;
+}
+
+//SZ32: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i32 %y)
+//SZ32: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
+//SZ64: define{{.*}} i8 addrspace(3)* @test_add_local(i8 addrspace(3)* %x, i64 %y)
+//AMDONLY: trunc i64 %{{.*}} to i32
+//AMDONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i32
+//SZ64ONLY: getelementptr inbounds i8, i8 addrspace(3)* %{{.*}}, i64
+local char* test_add_local(local char* x, ptrdiff_t y) {
+  return x + y;
+}
+
+//SZ32: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i32 %y)
+//SZ32: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i32
+//SZ64: define{{.*}} i8 addrspace(1)* @test_add_global(i8 addrspace(1)* %x, i64 %y)
+//SZ64: getelementptr inbounds i8, i8 addrspace(1)* %{{.*}}, i64
+global char* test_add_global(global char* x, ptrdiff_t y) {
+  return x + y;
+}
+
+//SZ32: define{{.*}} i32 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
+//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
+//SZ32: ptrtoint i8 addrspace(3)* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_sub_local(i8 addrspace(3)* %x, i8 addrspace(3)* %y)
+//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
+//SZ64: ptrtoint i8 addrspace(3)* %{{.*}} to i64
+ptrdiff_t test_sub_local(local char* x, local char *y) {
+  return x - y;
+}
+
+//SZ32: define{{.*}} i32 @test_sub_private(i8* %x, i8* %y)
+//SZ32: ptrtoint i8* %{{.*}} to i32
+//SZ32: ptrtoint i8* %{{.*}} to i32
+//SZ64: define{{.*}} i64 @test_sub_private(i8* %x, i8* %y)
+//SZ64: ptrtoint i8* %{{.*}} to i64
+//SZ64: ptrtoint i8* %{{.*}} to i64
+ptrdiff_t test_sub_private(private char* x, private char *y) {
+  return x - y;
+}
+
+//SZ32: define{{.*}} i32 @test_sub_mix(i8* %x, i8 addrspace(4)* %y)
+//SZ32: ptrtoint i8* %{{.*}} to i32
+//SZ32: ptrtoint i8 ad

Re: [PATCH] D23573: [OpenCL] Add extension cl_khr_subgroups to clang

2016-08-16 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!

Better update the title to be `[OpenCL] AMDGPU: add support of 
cl_khr_subgroups` since cl_khr_subgroups is already in clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D23573



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


Re: [PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-08-16 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

I didn't think of this case, but no, it isn't a good idea. We shouldn't issue a 
warning unless we know the returned pointer is nullable.



Comment at: lib/Sema/SemaDecl.cpp:9739
@@ +9738,3 @@
+  DeducedType = DeducedType.setNullability(
+  Init->getType()->getNullability(Context), Context);
+

manmanren wrote:
> Do we propagate other attributes for deduced types?
QualType::setNullability can drop attributes on typedefs because it desugars 
the type until all nullability specifiers are stripped. I didn't try very hard 
to make sure QualType::setNullability preserve all the attributes because I 
couldn't come up with a case where dropping an attribute attached to a typedef 
for a pointer type would cause clang to mis-compile or issue a wrong 
diagnostic, so I thought it was safe.


https://reviews.llvm.org/D22794



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


r278842 - Try to work around an MSVC 2013 bug around defaulted default ctors

2016-08-16 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Aug 16 15:20:56 2016
New Revision: 278842

URL: http://llvm.org/viewvc/llvm-project?rev=278842&view=rev
Log:
Try to work around an MSVC 2013 bug around defaulted default ctors

An UnresolvedSetIterator() is supposed to be zeroed out, but MSVC 2013
does not do that.

Modified:
cfe/trunk/include/clang/AST/UnresolvedSet.h

Modified: cfe/trunk/include/clang/AST/UnresolvedSet.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/UnresolvedSet.h?rev=278842&r1=278841&r2=278842&view=diff
==
--- cfe/trunk/include/clang/AST/UnresolvedSet.h (original)
+++ cfe/trunk/include/clang/AST/UnresolvedSet.h Tue Aug 16 15:20:56 2016
@@ -38,7 +38,9 @@ class UnresolvedSetIterator : public llv
   : iterator_adaptor_base(const_cast(Iter)) {}
 
 public:
-  UnresolvedSetIterator() = default;
+  // Work around a bug in MSVC 2013 where explicitly default constructed
+  // temporaries with defaulted ctors are not zero initialized.
+  UnresolvedSetIterator() : iterator_adaptor_base(nullptr) {}
 
   NamedDecl *getDecl() const { return I->getDecl(); }
   void setDecl(NamedDecl *ND) const { return I->setDecl(ND); }


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


Re: [PATCH] D23536: Remove excessive padding from ImmOp and RegOp.

2016-08-16 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r278844


https://reviews.llvm.org/D23536



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


Re: [PATCH] D23361: [OpenCL] AMDGCN: Fix size_t type

2016-08-16 Thread Matt Arsenault via cfe-commits
arsenm added inline comments.


Comment at: lib/CodeGen/CodeGenModule.h:664
@@ +663,3 @@
+  /// Get integer type of the same size as a pointer type.
+  llvm::IntegerType *getIntPtrTy(llvm::PointerType *PT);
+

This has the same purpose as DataLayout::getIntPtrType, should probably just 
use that


https://reviews.llvm.org/D23361



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


r278850 - [CMake] Fixing typo in Info.plist generation

2016-08-16 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug 16 15:49:49 2016
New Revision: 278850

URL: http://llvm.org/viewvc/llvm-project?rev=278850&view=rev
Log:
[CMake] Fixing typo in Info.plist generation

This is causing an error in the generation of the clang info plist.

Modified:
cfe/trunk/tools/driver/Info.plist.in

Modified: cfe/trunk/tools/driver/Info.plist.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/Info.plist.in?rev=278850&r1=278849&r2=278850&view=diff
==
--- cfe/trunk/tools/driver/Info.plist.in (original)
+++ cfe/trunk/tools/driver/Info.plist.in Tue Aug 16 15:49:49 2016
@@ -7,7 +7,7 @@
 CFBundleInfoDictionaryVersion
 6.0
 CFBundleName
-@TOOL_INFO_NAME
+@TOOL_INFO_NAME@
CFBundleShortVersionString
@TOOL_INFO_VERSION@
 CFBundleVersion


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


r278851 - [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

2016-08-16 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Aug 16 15:49:49 2016
New Revision: 278851

URL: http://llvm.org/viewvc/llvm-project?rev=278851&view=rev
Log:
[OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

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

Modified:
cfe/trunk/include/clang/Basic/OpenCLExtensions.def
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
cfe/trunk/test/SemaOpenCL/extension-version.cl

Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=278851&r1=278850&r2=278851&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Tue Aug 16 15:49:49 2016
@@ -75,6 +75,10 @@ OPENCLEXT_INTERNAL(cl_khr_terminate_cont
 // Clang Extensions.
 OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)
 
+// AMD OpenCL extensions
+OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U)
+
 #undef OPENCLEXT_INTERNAL
 
 #ifdef OPENCLEXT

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=278851&r1=278850&r2=278851&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Aug 16 15:49:49 2016
@@ -2153,6 +2153,8 @@ public:
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
+  Opts.cl_amd_media_ops = 1;
+  Opts.cl_amd_media_ops2 = 1;
 }
   }
 

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=278851&r1=278850&r2=278851&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Tue Aug 16 15:49:49 2016
@@ -16843,6 +16843,196 @@ double  __ovld sub_group_scan_inclusive_
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#ifdef cl_amd_media_ops
+uint __ovld amd_bitalign(uint a, uint b, uint c);
+uint2 __ovld amd_bitalign(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_bitalign(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_bitalign(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_bitalign(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_bitalign(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_bytealign(uint a, uint b, uint c);
+uint2 __ovld amd_bytealign(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_bytealign(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_bytealign(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_bytealign(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_bytealign(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_lerp(uint a, uint b, uint c);
+uint2 __ovld amd_lerp(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_lerp(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_lerp(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_lerp(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_lerp(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_pack(float4 v);
+
+uint __ovld amd_sad4(uint4 x, uint4 y, uint z);
+
+uint __ovld amd_sadhi(uint a, uint b, uint c);
+uint2 __ovld amd_sadhi(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_sadhi(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_sadhi(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_sadhi(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_sadhi(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_sad(uint a, uint b, uint c);
+uint2 __ovld amd_sad(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_sad(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_sad(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_sad(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_sad(uint16 a, uint16 b, uint16 c);
+
+float __ovld amd_unpack0(uint a);
+float2 __ovld amd_unpack0(uint2 a);
+float3 __ovld amd_unpack0(uint3 a);
+float4 __ovld amd_unpack0(uint4 a);
+float8 __ovld amd_unpack0(uint8 a);
+float16 __ovld amd_unpack0(uint16 a);
+
+float __ovld amd_unpack1(uint a);
+float2 __ovld amd_unpack1(uint2 a);
+float3 __ovld amd_unpack1(uint3 a);
+float4 __ovld amd_unpack1(uint4 a);
+float8 __ovld amd_unpack1(uint8 a);
+float16 __ovld amd_unpack1(uint16 a);
+
+float __ovld amd_unpack2(uint a);
+float2 __ovld amd_unpack2(uint2 a);
+float3 __ovld amd_unpack2(uint3 a);
+float4 __ovld amd_unpack2(uint4 a);
+float8 __ovld amd_unpack2(uint8 a);
+float16 __ovld amd_unpack2(uint16 a);
+
+float __ovld amd_unpack3(uint a);
+float2 __ovld amd_unpack3(uint2 a);
+float3 __ovld amd_unpack3(uint3 a);
+float4 __ovld amd_unpack3(uint4 a);
+float8 __ovld amd_unpack3(uint8 a);
+float16 __ovld amd_unpack3(uint16 a);
+#endif // cl_amd_media_ops
+
+#ifdef cl_amd_media_ops2
+int __ovld amd_bfe(int src0, uint src1, uint src2

Re: [PATCH] D23322: [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and cl_amd_media_ops2

2016-08-16 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278851: [OpenCL] AMDGPU: Add extensions cl_amd_media_ops and 
cl_amd_media_ops2 (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D23322?vs=67358&id=68250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23322

Files:
  cfe/trunk/include/clang/Basic/OpenCLExtensions.def
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Headers/opencl-c.h
  cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
  cfe/trunk/test/SemaOpenCL/extension-version.cl

Index: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
===
--- cfe/trunk/include/clang/Basic/OpenCLExtensions.def
+++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def
@@ -75,6 +75,10 @@
 // Clang Extensions.
 OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)
 
+// AMD OpenCL extensions
+OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U)
+OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U)
+
 #undef OPENCLEXT_INTERNAL
 
 #ifdef OPENCLEXT
Index: cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -210,3 +210,14 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_terminate_context: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_terminate_context' - ignoring}}
+
+#ifndef cl_amd_media_ops
+#error "Missing cl_amd_media_ops define"
+#endif
+#pragma OPENCL EXTENSION cl_amd_media_ops: enable
+
+#ifndef cl_amd_media_ops2
+#error "Missing cl_amd_media_ops2 define"
+#endif
+#pragma OPENCL EXTENSION cl_amd_media_ops2: enable
+
Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -259,3 +259,14 @@
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_terminate_context' - ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_terminate_context: enable
+
+#ifndef cl_amd_media_ops
+#error "Missing cl_amd_media_ops define"
+#endif
+#pragma OPENCL EXTENSION cl_amd_media_ops: enable
+
+#ifndef cl_amd_media_ops2
+#error "Missing cl_amd_media_ops2 define"
+#endif
+#pragma OPENCL EXTENSION cl_amd_media_ops2: enable
+
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2153,6 +2153,8 @@
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
   Opts.cl_khr_3d_image_writes = 1;
+  Opts.cl_amd_media_ops = 1;
+  Opts.cl_amd_media_ops2 = 1;
 }
   }
 
Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -16843,6 +16843,196 @@
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#ifdef cl_amd_media_ops
+uint __ovld amd_bitalign(uint a, uint b, uint c);
+uint2 __ovld amd_bitalign(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_bitalign(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_bitalign(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_bitalign(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_bitalign(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_bytealign(uint a, uint b, uint c);
+uint2 __ovld amd_bytealign(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_bytealign(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_bytealign(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_bytealign(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_bytealign(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_lerp(uint a, uint b, uint c);
+uint2 __ovld amd_lerp(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_lerp(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_lerp(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_lerp(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_lerp(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_pack(float4 v);
+
+uint __ovld amd_sad4(uint4 x, uint4 y, uint z);
+
+uint __ovld amd_sadhi(uint a, uint b, uint c);
+uint2 __ovld amd_sadhi(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_sadhi(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_sadhi(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_sadhi(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_sadhi(uint16 a, uint16 b, uint16 c);
+
+uint __ovld amd_sad(uint a, uint b, uint c);
+uint2 __ovld amd_sad(uint2 a, uint2 b, uint2 c);
+uint3 __ovld amd_sad(uint3 a, uint3 b, uint3 c);
+uint4 __ovld amd_sad(uint4 a, uint4 b, uint4 c);
+uint8 __ovld amd_sad(uint8 a, uint8 b, uint8 c);
+uint16 __ovld amd_sad(uint16 a, uint16 b, uint16 c);
+
+float __ovld amd_unpack0(uint a);
+float2 __ovld amd_unpack0(uint2 a);
+float3 __ovld amd_unpack0(uint3 a);
+float4 __ovld amd_unpack0(uint4 a);
+float8 __ovld amd_unpack0(uint8 a);
+float16 __ovld amd_u

r278849 - [CMake] [Apple Cache] Set CLANG_VENDOR_UTI for Apple builds

2016-08-16 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug 16 15:44:58 2016
New Revision: 278849

URL: http://llvm.org/viewvc/llvm-project?rev=278849&view=rev
Log:
[CMake] [Apple Cache] Set CLANG_VENDOR_UTI for Apple builds

This is just a minor update to the Apple packaging configuration.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=278849&r1=278848&r2=278849&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Aug 16 15:44:58 2016
@@ -3,6 +3,7 @@
 
 set(LLVM_TARGETS_TO_BUILD X86 ARM AArch64 CACHE STRING "") 
 set(PACKAGE_VENDOR Apple CACHE STRING "")
+set(CLANG_VENDOR_UTI com.apple.clang CACHE STRING "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")


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


Re: r266775 - Pass dwarf-version to cc1as.

2016-08-16 Thread Dimitry Andric via cfe-commits
Hi Hans,

Can we please merge this one to release_39 too?  I forgot all about it, sorry.

Doug, can you please approve?

-Dimitry

> On 19 Apr 2016, at 19:43, Douglas Katzman via cfe-commits 
>  wrote:
> 
> Author: dougk
> Date: Tue Apr 19 12:43:54 2016
> New Revision: 266775
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=266775&view=rev
> Log:
> Pass dwarf-version to cc1as.
> 
> Fix PR26999 - crashing in cc1as with any '*bsd' target.
> 
> Modified:
>cfe/trunk/lib/Driver/Tools.cpp
>cfe/trunk/test/Driver/save-temps.c
> 
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266775&r1=266774&r2=266775&view=diff
> ==
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 19 12:43:54 2016
> @@ -6314,6 +6314,12 @@ void ClangAs::ConstructJob(Compilation &
>   // FIXME: Stop lying and consume only the appropriate driver flags
>   Args.ClaimAllArgs(options::OPT_W_Group);
> 
> +  // Assemblers that want to know the dwarf version can't assume a value,
> +  // since the defaulting logic resides in the driver. Put in something
> +  // reasonable now, in case a subsequent "-Wa,-g" changes it.
> +  RenderDebugEnablingArgs(Args, CmdArgs, codegenoptions::NoDebugInfo,
> +  getToolChain().GetDefaultDwarfVersion(),
> +  llvm::DebuggerKind::Default);
>   CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
> getToolChain().getDriver());
> 
> 
> Modified: cfe/trunk/test/Driver/save-temps.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-temps.c?rev=266775&r1=266774&r2=266775&view=diff
> ==
> --- cfe/trunk/test/Driver/save-temps.c (original)
> +++ cfe/trunk/test/Driver/save-temps.c Tue Apr 19 12:43:54 2016
> @@ -77,3 +77,8 @@
> // CHECK-OBJ-NOO: "-o" "save-temps.s"
> // CHECK-OBJ-NOO: "-o" "save-temps.o"
> // CHECK-OBJ-NOO: "-o" "a.out"
> +
> +// RUN: %clang -target i386-unknown-freebsd -save-temps -g -c %s -### 2>&1 \
> +// RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS
> +// CHECK-SAVE-TEMPS: "-cc1as"
> +// CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23581: [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-16 Thread Tim Shen via cfe-commits
timshen created this revision.
timshen added a reviewer: dblaikie.
timshen added a subscriber: cfe-commits.

Corresponding LLVM patch: D23580

https://reviews.llvm.org/D23581

Files:
  lib/Serialization/ModuleManager.cpp

Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

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

lgtm


https://reviews.llvm.org/D23462



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


Re: [PATCH] D9403: llvm.noalias - Clang CodeGen for local restrict-qualified pointers

2016-08-16 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.


Comment at: lib/CodeGen/CGStmt.cpp:537
@@ +536,3 @@
+  llvm::LLVMContext::MD_noalias),
+  NewScopeList));
+

rjmccall wrote:
> This is a very strange representation.  Every memory operation in the lexical 
> block is annotated with a list of all of the scopes that were entered within 
> the block, even if they were entered after the operation.  But for some 
> reason, not with nested scopes?
> 
> What's the right patch for me to read about this representation?
Perhaps unfortunately, this is an artifact of the way that restrict is defined 
in C. It applies to all accesses in the block in which the variable is 
declared, even those before the declaration of the restrict-qualified local 
itself.

It should work with nested scopes, in the sense that we add these things as we 
complete each scope. So we add things to the inner scope, and then when we 
complete the outer scope, we go back over the instructions (including those in 
the inner scope because the scope recording recurses up the scope hierarchy), 
and adds the outer scopes - it concatenates them to any added by the inner 
(nested) scopes.

The noalias intrinsic's LangRef updates are in D9375.


https://reviews.llvm.org/D9403



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


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-16 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: test/CodeGenObjCXX/encode.mm:231
@@ +230,3 @@
+struct S {
+  typedef T Ty;
+  Ty *t;

manmanren wrote:
> I wonder if we can further reduce the testing case. Is this necessary to 
> cause the infinite recursion?
Yes. If I remove the typedef and declare "t" as a pointer to "T", clang 
terminates normally. If you look at the code near ASTContext.cpp:5960, you'll 
see getObjCEncodingForTypeImpl is called recursively only if the pointee type 
is a typedef, which is why the typedef is necessary to cause infinite recursion 
in this case.


https://reviews.llvm.org/D22929



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


Re: [PATCH] D9403: llvm.noalias - Clang CodeGen for local restrict-qualified pointers

2016-08-16 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: lib/CodeGen/CGStmt.cpp:525
@@ +524,3 @@
+void CodeGenFunction::LexicalNoAliasInfo::addNoAliasMD() {
+  if (MemoryInsts.empty() || NoAliasScopes.empty())
+return;

It's much more likely that NoAliasScopes will be empty than that MemoryInsts 
will be empty.  You should probably fast-path using that, or better yet, with 
the RecordMemoryInsts bit.


Comment at: lib/CodeGen/CGStmt.cpp:537
@@ +536,3 @@
+  llvm::LLVMContext::MD_noalias),
+  NewScopeList));
+

hfinkel wrote:
> rjmccall wrote:
> > This is a very strange representation.  Every memory operation in the 
> > lexical block is annotated with a list of all of the scopes that were 
> > entered within the block, even if they were entered after the operation.  
> > But for some reason, not with nested scopes?
> > 
> > What's the right patch for me to read about this representation?
> Perhaps unfortunately, this is an artifact of the way that restrict is 
> defined in C. It applies to all accesses in the block in which the variable 
> is declared, even those before the declaration of the restrict-qualified 
> local itself.
> 
> It should work with nested scopes, in the sense that we add these things as 
> we complete each scope. So we add things to the inner scope, and then when we 
> complete the outer scope, we go back over the instructions (including those 
> in the inner scope because the scope recording recurses up the scope 
> hierarchy), and adds the outer scopes - it concatenates them to any added by 
> the inner (nested) scopes.
> 
> The noalias intrinsic's LangRef updates are in D9375.
Ah, I see the recursion now.  Please add a comment explaining that expectation 
here.


Comment at: lib/CodeGen/CodeGenFunction.cpp:1900
@@ +1899,3 @@
+
+  if (I->mayReadOrWriteMemory())
+recordMemoryInstruction(I);

Is it intentional that this includes calls and invokes?  If so, please leave a 
comment describing which instructions we want to apply this to and why.

In general, this entire patch is really light on comments.


Comment at: lib/CodeGen/CodeGenFunction.h:541
@@ +540,3 @@
+
+LexicalNoAliasInfo(bool RMI = false) : RecordMemoryInsts(RMI) {}
+

Why this is defaultable?


https://reviews.llvm.org/D9403



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


r278861 - Emit debug info for dynamic classes if they are imported from a DLL.

2016-08-16 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Tue Aug 16 17:11:18 2016
New Revision: 278861

URL: http://llvm.org/viewvc/llvm-project?rev=278861&view=rev
Log:
Emit debug info for dynamic classes if they are imported from a DLL.

With -debug-info-kind=limited, we omit debug info for dynamic classes that live 
in other TUs. This reduces duplicate type information. When statically linked, 
the type information comes together. But if your binary has a class derived 
from a base in a DLL, the base class info is not available to the debugger.

The decision is made in shouldOmitDefinition (CGDebugInfo.cpp). Per a 
suggestion from rnk, I've tweaked the decision so that we do include 
definitions for classes marked as DLL imports. This should be a relatively 
small number of classes, so we don't pay a large price for duplication of the 
type info, yet it should cover most cases on Windows.

Essentially this makes debug info for DLLs independent, but we still assume 
that all TUs within the same DLL will be consistently built with (or without) 
debug info and the debugger will be able to search across the debug info within 
that scope to resolve any declarations into definitions, etc.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=278861&r1=278860&r2=278861&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Aug 16 17:11:18 2016
@@ -1685,7 +1685,12 @@ static bool shouldOmitDefinition(codegen
   if (!CXXDecl)
 return false;
 
-  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass())
+  // Only emit complete debug info for a dynamic class when its vtable is
+  // emitted.  However, Microsoft debuggers don't resolve type information
+  // across DLL boundaries, so skip this optimization if the class is marked
+  // dllimport.
+  if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
+  !CXXDecl->hasAttr())
 return true;
 
   TemplateSpecializationKind Spec = TSK_Undeclared;

Added: cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp?rev=278861&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-dllimport-base-class.cpp Tue Aug 16 
17:11:18 2016
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-pc-windows -emit-llvm -gcodeview 
-debug-info-kind=limited -fms-compatibility %s -x c++ -o - | FileCheck %s
+
+// Ensure we emit debug info for the full definition of base classes that will
+// be imported from a DLL.  Otherwise, the debugger wouldn't be able to show 
the
+// members.
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
+// CHECK-NOT:  DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct __declspec(dllimport) ImportedBase {
+  ImportedBase();
+  virtual void Foo();
+};
+
+struct DerivedFromImported : public ImportedBase {};
+
+int main() {
+  DerivedFromImported d;
+}


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


r278862 - [CMake] Workflow improvements to PGO generation

2016-08-16 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue Aug 16 17:16:29 2016
New Revision: 278862

URL: http://llvm.org/viewvc/llvm-project?rev=278862&view=rev
Log:
[CMake] Workflow improvements to PGO generation

This patch adds a few new convenience options used by the PGO CMake cache to 
setup options on bootstrap stages. The new options are:

PGO_INSTRUMENT_LTO - Builds the instrumented and final builds with LTO
PGO_BUILD_CONFIGURATION - Accepts a CMake cache script that can be used for 
complex configuration of the stage2-instrumented and stage2 builds.

The patch also includes a fix for bootstrap dependencies so that the 
instrumented LTO tools don't get used when building the final stage, and it 
adds distribution targets to the passthrough.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
cfe/trunk/cmake/caches/PGO.cmake

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=278862&r1=278861&r2=278862&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Tue Aug 16 17:16:29 2016
@@ -571,11 +571,22 @@ if (CLANG_ENABLE_BOOTSTRAP)
   if(LLVM_BUILD_INSTRUMENTED)
 set(PGO_DEP generate-profdata)
 set(PGO_OPT 
-DLLVM_PROFDATA_FILE=${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/clang.profdata)
-set(COMPILER_OPTIONS
-  -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-  -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-  -DCMAKE_ASM_COMPILER=${CMAKE_ASM_COMPILER})
+# Use the current tools for LTO instead of the instrumented ones
+list(APPEND _BOOTSTRAP_DEFAULT_PASSTHROUGH
+  CMAKE_CXX_COMPILER
+  CMAKE_C_COMPILER
+  CMAKE_ASM_COMPILER
+  CMAKE_AR
+  CMAKE_RANLIB
+  DARWIN_LTO_LIBRARY
+  DYLD_LIBRARY_PATH)
+
+set(COMPILER_OPTIONS)
+set(LTO_LIBRARY)
 set(RUNTIME_DEP) # Don't set runtime dependencies
+set(LTO_DEP) # Don't need to depend on LTO
+set(LTO_AR)
+set(LTO_RANLIB)
   endif()
 
   # Find all variables that start with BOOTSTRAP_ and populate a variable with

Modified: cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake?rev=278862&r1=278861&r2=278862&view=diff
==
--- cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake (original)
+++ cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake Tue Aug 16 17:16:29 
2016
@@ -1,9 +1,21 @@
-set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
-set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_TARGETS
+  distribution
+  install-distribution
+  check-all
+  check-llvm
+  check-clang
+  test-suite CACHE STRING "")
 
-set(CLANG_BOOTSTRAP_TARGETS check-all check-llvm check-clang test-suite CACHE 
STRING "")
+if(PGO_BUILD_CONFIGURATION)
+  include(${PGO_BUILD_CONFIGURATION})
+  set(CLANG_BOOTSTRAP_CMAKE_ARGS
+-C ${PGO_BUILD_CONFIGURATION}
+CACHE STRING "")
+else()
+  include(${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake)
 
-set(CLANG_BOOTSTRAP_CMAKE_ARGS
-  -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake
-  CACHE STRING "")
+  set(CLANG_BOOTSTRAP_CMAKE_ARGS
+-C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2.cmake
+CACHE STRING "")
+endif()

Modified: cfe/trunk/cmake/caches/PGO.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO.cmake?rev=278862&r1=278861&r2=278862&view=diff
==
--- cfe/trunk/cmake/caches/PGO.cmake (original)
+++ cfe/trunk/cmake/caches/PGO.cmake Tue Aug 16 17:16:29 2016
@@ -7,11 +7,23 @@ set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED ON
 set(CLANG_BOOTSTRAP_TARGETS
   generate-profdata
   stage2
+  stage2-distribution
+  stage2-install-distribution
   stage2-check-all
   stage2-check-llvm
   stage2-check-clang
   stage2-test-suite CACHE STRING "")
 
+if(PGO_INSTRUMENT_LTO)
+  set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+  set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+endif()
+
+if(PGO_BUILD_CONFIGURATION)
+  set(EXTRA_ARGS -DPGO_BUILD_CONFIGURATION=${PGO_BUILD_CONFIGURATION})
+endif()
+
 set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
   -C ${CMAKE_CURRENT_LIST_DIR}/PGO-stage2-instrumented.cmake
   CACHE STRING "")


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


Re: [PATCH] D23462: Emit debug info for dynamic classes if they are imported from a DLL

2016-08-16 Thread Adrian McCarthy via cfe-commits
amccarth closed this revision.
amccarth added a comment.

Closed by r278861


https://reviews.llvm.org/D23462



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-16 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(anyOf(isPrivate(), isProtected(;
+

aaron.ballman wrote:
> Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), isProtected())`?
POD types doesn't have public constructors so it will fail :)


https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(anyOf(isPrivate(), isProtected(;
+

Prazek wrote:
> aaron.ballman wrote:
> > Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), 
> > isProtected())`?
> POD types doesn't have public constructors so it will fail :)
Don't they have an implicit one for the purposes of a CXXConstructExpr? Looking 
at an AST dump for:
```
struct S {
  int i;
};
```
yields:
```
|-CXXRecordDecl 0x26d74ae5348  line:25:8 referenced 
struct S definition
| |-CXXRecordDecl 0x26d74ae5460  col:8 implicit struct S
| |-FieldDecl 0x26d74ae7880  col:7 i 'int'
| |-CXXConstructorDecl 0x26d74ae87b8  col:8 implicit used S 'void 
(void) noexcept' inline
| | `-CompoundStmt 0x26d74ae3850 
| |-CXXConstructorDecl 0x26d74ae34a8  col:8 implicit constexpr S 'void 
(const struct S &)' inline noexcept-unevaluated 0x26d74ae34a8
| | `-ParmVarDecl 0x26d74ae35e0  col:8 'const struct S &'
| `-CXXConstructorDecl 0x26d74ae3678  col:8 implicit constexpr S 'void 
(struct S &&)' inline noexcept-unevaluated 0x26d74ae3678
|   `-ParmVarDecl 0x26d74ae37b0  col:8 'struct S &&'
```


https://reviews.llvm.org/D23343



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


[PATCH] D23585: [ASTMatchers] Add narrowing matcher: hasExternalFormalLinkage

2016-08-16 Thread Visoiu Mistrih Francis via cfe-commits
thegameg created this revision.
thegameg added reviewers: bkramer, alexfh, hokein.
thegameg added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Matches NamedDecl nodes whose linkage is external.

https://reviews.llvm.org/D23585

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

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1937,5 +1937,15 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(HasExternalFormalLinkage, Basic) {
+  EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_FALSE(
+  matches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_FALSE(matches("static void f(void) { int a = 0; }",
+   namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(matches("void f(void) { int a = 0; }",
+  namedDecl(hasExternalFormalLinkage(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -226,6 +226,7 @@
   REGISTER_MATCHER(hasEitherOperand);
   REGISTER_MATCHER(hasElementType);
   REGISTER_MATCHER(hasElse);
+  REGISTER_MATCHER(hasExternalFormalLinkage);
   REGISTER_MATCHER(hasFalseExpression);
   REGISTER_MATCHER(hasGlobalStorage);
   REGISTER_MATCHER(hasImplicitDestinationType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5476,6 +5476,20 @@
   return false;
 }
 
+/// \brief Matches a declaration that has external formal linkage.
+///
+/// Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
+/// \code
+/// void f() {
+///   int x;
+///   static int y;
+/// }
+/// int z;
+/// \endcode
+AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
+  return Node.hasExternalFormalLinkage();
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -2771,6 +2771,17 @@
 
 
 
+MatcherNamedDecl>hasExternalFormalLinkage
+Matches 
NamedDecl nodes whose linkage is external.
+
+Example matches foo
+  void foo(void) { }
+
+Example matches i
+  int i = 0;
+
+
+
 MatcherNamespaceDecl>isAnonymous
 Matches anonymous 
namespace declarations.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1937,5 +1937,15 @@
   EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant(;
 }
 
+TEST(HasExternalFormalLinkage, Basic) {
+  EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_FALSE(
+  matches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_FALSE(matches("static void f(void) { int a = 0; }",
+   namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(matches("void f(void) { int a = 0; }",
+  namedDecl(hasExternalFormalLinkage(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -226,6 +226,7 @@
   REGISTER_MATCHER(hasEitherOperand);
   REGISTER_MATCHER(hasElementType);
   REGISTER_MATCHER(hasElse);
+  REGISTER_MATCHER(hasExternalFormalLinkage);
   REGISTER_MATCHER(hasFalseExpression);
   REGISTER_MATCHER(hasGlobalStorage);
   REGISTER_MATCHER(hasImplicitDestinationType);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5476,6 +5476,20 @@
   return false;
 }
 
+/// \brief Matches a declaration that has external formal linkage.
+///
+/// Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
+/// \code
+/// void f() {
+///   int x;
+///   static int y;
+/// }
+/// int z;
+/// \endcode
+AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
+  return Node.hasExternalFormalLinkage();
+}
+
 } // end namespace ast_matchers
 

Re: [PATCH] D23585: [ASTMatchers] Add narrowing matcher: hasExternalFormalLinkage

2016-08-16 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

A few minor nits, but thank you for the patch!



Comment at: include/clang/ASTMatchers/ASTMatchers.h:5481
@@ +5480,3 @@
+///
+/// Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
+/// \code

It might also be good to point out the case of an anonymous namespace member 
which has external linkage (despite having internal semantic linkage because 
the member has a unique name in all translation units).


Comment at: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:1942
@@ +1941,3 @@
+  EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_FALSE(
+  matches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;

Should use `EXPECT_TRUE` with `notMatches()` here and below.


https://reviews.llvm.org/D23585



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


Re: r266775 - Pass dwarf-version to cc1as.

2016-08-16 Thread Hans Wennborg via cfe-commits
Looks like it was committed back in April, so unless I'm missing
something it should already be in the branch (which was cut mid-July).

Thanks,
Hans

On Tue, Aug 16, 2016 at 2:16 PM, Dimitry Andric  wrote:
> Hi Hans,
>
> Can we please merge this one to release_39 too?  I forgot all about it, sorry.
>
> Doug, can you please approve?
>
> -Dimitry
>
>> On 19 Apr 2016, at 19:43, Douglas Katzman via cfe-commits 
>>  wrote:
>>
>> Author: dougk
>> Date: Tue Apr 19 12:43:54 2016
>> New Revision: 266775
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=266775&view=rev
>> Log:
>> Pass dwarf-version to cc1as.
>>
>> Fix PR26999 - crashing in cc1as with any '*bsd' target.
>>
>> Modified:
>>cfe/trunk/lib/Driver/Tools.cpp
>>cfe/trunk/test/Driver/save-temps.c
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266775&r1=266774&r2=266775&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Tue Apr 19 12:43:54 2016
>> @@ -6314,6 +6314,12 @@ void ClangAs::ConstructJob(Compilation &
>>   // FIXME: Stop lying and consume only the appropriate driver flags
>>   Args.ClaimAllArgs(options::OPT_W_Group);
>>
>> +  // Assemblers that want to know the dwarf version can't assume a value,
>> +  // since the defaulting logic resides in the driver. Put in something
>> +  // reasonable now, in case a subsequent "-Wa,-g" changes it.
>> +  RenderDebugEnablingArgs(Args, CmdArgs, codegenoptions::NoDebugInfo,
>> +  getToolChain().GetDefaultDwarfVersion(),
>> +  llvm::DebuggerKind::Default);
>>   CollectArgsForIntegratedAssembler(C, Args, CmdArgs,
>> getToolChain().getDriver());
>>
>>
>> Modified: cfe/trunk/test/Driver/save-temps.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/save-temps.c?rev=266775&r1=266774&r2=266775&view=diff
>> ==
>> --- cfe/trunk/test/Driver/save-temps.c (original)
>> +++ cfe/trunk/test/Driver/save-temps.c Tue Apr 19 12:43:54 2016
>> @@ -77,3 +77,8 @@
>> // CHECK-OBJ-NOO: "-o" "save-temps.s"
>> // CHECK-OBJ-NOO: "-o" "save-temps.o"
>> // CHECK-OBJ-NOO: "-o" "a.out"
>> +
>> +// RUN: %clang -target i386-unknown-freebsd -save-temps -g -c %s -### 2>&1 \
>> +// RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS
>> +// CHECK-SAVE-TEMPS: "-cc1as"
>> +// CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-16 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a reviewer: manmanren.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


https://reviews.llvm.org/D22929



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


Re: [PATCH] D23585: [ASTMatchers] Add narrowing matcher: hasExternalFormalLinkage

2016-08-16 Thread Visoiu Mistrih Francis via cfe-commits
thegameg marked an inline comment as done.
thegameg added a comment.

https://reviews.llvm.org/D23585



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


Re: [PATCH] D23585: [ASTMatchers] Add narrowing matcher: hasExternalFormalLinkage

2016-08-16 Thread Visoiu Mistrih Francis via cfe-commits
thegameg marked an inline comment as done.
thegameg added a comment.

https://reviews.llvm.org/D23585



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


Re: [PATCH] D23585: [ASTMatchers] Add narrowing matcher: hasExternalFormalLinkage

2016-08-16 Thread Visoiu Mistrih Francis via cfe-commits
thegameg updated this revision to Diff 68288.
thegameg added a comment.

Mention UniqueExternalLinkage type, add a test according to it.
`EXPECT_FALSE(matches(` -> `EXPECT_TRUE(notMatches(`


https://reviews.llvm.org/D23585

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1939,12 +1939,18 @@
 
 TEST(HasExternalFormalLinkage, Basic) {
   EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage(;
-  EXPECT_FALSE(
-  matches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
-  EXPECT_FALSE(matches("static void f(void) { int a = 0; }",
-   namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(
+  notMatches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(notMatches("static void f(void) { int a = 0; }",
+ namedDecl(hasExternalFormalLinkage(;
   EXPECT_TRUE(matches("void f(void) { int a = 0; }",
   namedDecl(hasExternalFormalLinkage(;
+
+  // Despite having internal semantic linkage, the anonymous namespace member
+  // has external linkage because the member has a unique name in all
+  // translation units.
+  EXPECT_TRUE(matches("namespace { int a = 0; }",
+  namedDecl(hasExternalFormalLinkage(;
 }
 
 } // namespace ast_matchers
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5486,6 +5486,22 @@
 /// }
 /// int z;
 /// \endcode
+///
+/// From clang/Basic/Linkage.h:
+/// > UniqueExternalLinkage:
+/// > External linkage within a unique namespace.
+/// > From the language perspective, these entities have external
+/// > linkage. However, since they reside in an anonymous namespace,
+/// > their names are unique to this translation unit, which is
+/// > equivalent to having internal linkage from the code-generation
+/// > point of view.
+///
+/// Example matches f (matcher = functionDecl(hasExternalFormalLinkage()))
+/// \code
+/// namespace {
+/// void f() {}
+/// }
+/// \endcode
 AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
   return Node.hasExternalFormalLinkage();
 }


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1939,12 +1939,18 @@
 
 TEST(HasExternalFormalLinkage, Basic) {
   EXPECT_TRUE(matches("int a = 0;", namedDecl(hasExternalFormalLinkage(;
-  EXPECT_FALSE(
-  matches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
-  EXPECT_FALSE(matches("static void f(void) { int a = 0; }",
-   namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(
+  notMatches("static int a = 0;", namedDecl(hasExternalFormalLinkage(;
+  EXPECT_TRUE(notMatches("static void f(void) { int a = 0; }",
+ namedDecl(hasExternalFormalLinkage(;
   EXPECT_TRUE(matches("void f(void) { int a = 0; }",
   namedDecl(hasExternalFormalLinkage(;
+
+  // Despite having internal semantic linkage, the anonymous namespace member
+  // has external linkage because the member has a unique name in all
+  // translation units.
+  EXPECT_TRUE(matches("namespace { int a = 0; }",
+  namedDecl(hasExternalFormalLinkage(;
 }
 
 } // namespace ast_matchers
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5486,6 +5486,22 @@
 /// }
 /// int z;
 /// \endcode
+///
+/// From clang/Basic/Linkage.h:
+/// > UniqueExternalLinkage:
+/// > External linkage within a unique namespace.
+/// > From the language perspective, these entities have external
+/// > linkage. However, since they reside in an anonymous namespace,
+/// > their names are unique to this translation unit, which is
+/// > equivalent to having internal linkage from the code-generation
+/// > point of view.
+///
+/// Example matches f (matcher = functionDecl(hasExternalFormalLinkage()))
+/// \code
+/// namespace {
+/// void f() {}
+/// }
+/// \endcode
 AST_MATCHER(NamedDecl, hasExternalFormalLinkage) {
   return Node.hasExternalFormalLinkage();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >