r286098 - [OPENMP] Fixed capturing of VLA variables.

2016-11-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Nov  7 02:07:25 2016
New Revision: 286098

URL: http://llvm.org/viewvc/llvm-project?rev=286098&view=rev
Log:
[OPENMP] Fixed capturing of VLA variables.

After some changes in codegen capturing of VLA variables in OpenMP
regions was broken, causing compiler crash. Patch fixes this issue.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 02:07:25 2016
@@ -2127,12 +2127,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
   if (auto *FD = LambdaCaptureFields.lookup(VD))
 return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
   else if (CapturedStmtInfo) {
-auto it = LocalDeclMap.find(VD);
-if (it != LocalDeclMap.end()) {
-  if (auto RefTy = VD->getType()->getAs()) {
-return EmitLoadOfReferenceLValue(it->second, RefTy);
-  }
-  return MakeAddrLValue(it->second, T);
+auto I = LocalDeclMap.find(VD);
+if (I != LocalDeclMap.end()) {
+  if (auto RefTy = VD->getType()->getAs())
+return EmitLoadOfReferenceLValue(I->second, RefTy);
+  return MakeAddrLValue(I->second, T);
 }
 LValue CapLVal =
 EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 02:07:25 2016
@@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
 if (ArgLVal.getType()->isLValueReferenceType()) {
   ArgAddr = EmitLoadOfReference(
   ArgAddr, ArgLVal.getType()->castAs());
-} else {
+} else if (!VarTy->isVariablyModifiedType() || 
!VarTy->isPointerType()) {
   assert(ArgLVal.getType()->isPointerType());
   ArgAddr = EmitLoadOfPointer(
   ArgAddr, ArgLVal.getType()->castAs());

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 02:07:25 2016
@@ -10,7 +10,7 @@
 // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %ident_t 
{ i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* 
[[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
 // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
 
 template 
@@ -24,17 +24,19 @@ int tmain(T argc) {
 }
 
 int main (int argc, char **argv) {
+  int a[argc];
 #pragma omp parallel
-  foo(argc);
+  foo(a[1]);
   return tmain(argv);
 }
 
 // CHECK-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}} %argc, 
i8** %argv)
 // CHECK: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
-// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, 
...)*), i32* [[ARGC_ADDR]])
+// CHECK: [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
+// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i64, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, 
i32*, ...)*), i64 [[VLA_SIZE]], i32* [[VLA]])
 // CHECK-NEXT:  [[ARGV:%.+]] = load i8**, i8*** {{%[a-z0-9.]+}}
 // CHECK-NEXT:  [[RET:%.+]] = call {{[a-z\_\b]*[ ]?i32}} 
[[TMAIN:@.+tmain.+]](i8** [[ARGV]])
-// CHECK-NEXT:  ret i32 [[RET]]
+// CHECK:   ret i32
 // CHECK-NEXT:  }
 // CHECK-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %ident_t
@@ -42,30 +44,33 @@ int main (int argc, char **argv) {
 

[PATCH] D26142: Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 77018.
rogfer01 added a comment.

Updated with changes suggested by @EricWF


https://reviews.llvm.org/D26142

Files:
  
test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -56,10 +57,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 struct ConstSwappable {
@@ -231,6 +232,7 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 optional opt2;
@@ -307,4 +309,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // constexpr const T& optional::value() const;
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::in_place_t;
 using std::experimental::in_place;
@@ -40,6 +41,7 @@
 const optional opt(in_place);
 assert(opt.value().test() == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 const optional opt;
 try
@@ -51,4 +53,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // T& optional::value();
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::bad_optional_access;
 
@@ -35,6 +36,7 @@
 opt.emplace();
 assert(opt.value().test() == 4);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt;
 try
@@ -46,4 +48,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 //
 // UNSUPPORTED: c++9

[libcxx] r286099 - Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov  7 02:23:59 2016
New Revision: 286099

URL: http://llvm.org/viewvc/llvm-project?rev=286099&view=rev
Log:
Protect std::experimental::optional tests under libcpp-no-exceptions

In these tests there are some paths that explicitly throw, so use
the TEST_THROW macro that was proposed for this and then skip the tests
that may enter the throwing path.

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


Modified:

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff
==
--- 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
 Mon Nov  7 02:23:59 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // optional& operator=(const optional& rhs);
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 struct AllowConstAssign {
@@ -34,7 +35,7 @@ struct X
 X(const X&)
 {
 if (throw_now)
-throw 6;
+TEST_THROW(6);
 }
 };
 
@@ -79,6 +80,7 @@ int main()
 assert(static_cast(opt) == static_cast(opt2));
 assert(*opt == *opt2);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt;
 optional opt2(X{});
@@ -95,4 +97,5 @@ int main()
 assert(static_cast(opt) == false);
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff
==
--- 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
 Mon Nov  7 02:23:59 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void optional::emplace(Args&&... args);
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -48,7 +49,7 @@ class Z
 public:
 static bool dtor_called;
 Z() = default;
-Z(int) {throw 6;}
+Z(int) {TEST_THROW(6);}
 ~Z() {dtor_called = true;}
 };
 
@@ -131,6 +132,7 @@ int main()
 assert(Y::dtor_called == true);
 }
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 Z z;
 optional opt(z);
@@ -147,4 +149,5 @@ int main()
 assert(Z::dtor_called == true);
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff

[PATCH] D26142: Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286099: Protect std::experimental::optional tests under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26142?vs=77018&id=77019#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26142

Files:
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -56,10 +57,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 struct ConstSwappable {
@@ -231,6 +232,7 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 optional opt2;
@@ -307,4 +309,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif
 }
Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 //
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 
 // 
 
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -42,7 +43,7 @@
 {
 public:
 Z(int)  {}
-Z(const Z&) {throw 6;}
+Z(const Z&) {TEST_THROW(6);}
 };
 
 
@@ -97,6 +98,7 @@
 };
 
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 typedef Z T;
 try
@@ -110,4 +112,5 @@
 assert(i == 6);
 }
 }
+#endif
 }
Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // optional(optional&& rhs) noexcept(is_nothrow_move_constructible::value);
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 template 
@@ -26,16 +27,24 @@
 static_assert(std::is_nothrow_move_constructible>::value ==
   std::is_nothrow_move_constructible::value, "");
 bool rhs_engaged = static_cast(rhs);
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (is_going_to_throw)
+return;
+#else
 

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-07 Thread Alpha Abdoulaye via cfe-commits
Alpha added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


Re: r286098 - [OPENMP] Fixed capturing of VLA variables.

2016-11-07 Thread Diana Picus via cfe-commits
Hi,

This has been breaking the bots for almost an hour. Can you fix/revert?

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/304
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/657
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/347

Thanks,
Diana

On 7 November 2016 at 10:07, Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Mon Nov  7 02:07:25 2016
> New Revision: 286098
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286098&view=rev
> Log:
> [OPENMP] Fixed capturing of VLA variables.
>
> After some changes in codegen capturing of VLA variables in OpenMP
> regions was broken, causing compiler crash. Patch fixes this issue.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> cfe/trunk/test/OpenMP/parallel_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=286098&r1=286097&r2=286098&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 02:07:25 2016
> @@ -2127,12 +2127,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
>if (auto *FD = LambdaCaptureFields.lookup(VD))
>  return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
>else if (CapturedStmtInfo) {
> -auto it = LocalDeclMap.find(VD);
> -if (it != LocalDeclMap.end()) {
> -  if (auto RefTy = VD->getType()->getAs()) {
> -return EmitLoadOfReferenceLValue(it->second, RefTy);
> -  }
> -  return MakeAddrLValue(it->second, T);
> +auto I = LocalDeclMap.find(VD);
> +if (I != LocalDeclMap.end()) {
> +  if (auto RefTy = VD->getType()->getAs())
> +return EmitLoadOfReferenceLValue(I->second, RefTy);
> +  return MakeAddrLValue(I->second, T);
>  }
>  LValue CapLVal =
>  EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),
>
> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGStmtOpenMP.cpp?rev=286098&r1=286097&r2=286098&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 02:07:25 2016
> @@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
>  if (ArgLVal.getType()->isLValueReferenceType()) {
>ArgAddr = EmitLoadOfReference(
>ArgAddr, ArgLVal.getType()->castAs());
> -} else {
> +} else if (!VarTy->isVariablyModifiedType() ||
> !VarTy->isPointerType()) {
>assert(ArgLVal.getType()->isPointerType());
>ArgAddr = EmitLoadOfPointer(
>ArgAddr, ArgLVal.getType()->castAs());
>
> Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> parallel_codegen.cpp?rev=286098&r1=286097&r2=286098&view=diff
> 
> ==
> --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 02:07:25 2016
> @@ -10,7 +10,7 @@
>  // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
>  // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x
> i8] c";unknown;unknown;0;0;;\00"
>  // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant
> %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x
> i8], [23 x i8]* [[STR]], i32 0, i32 0) }
> -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}}
> x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
> +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}}
> x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
>  // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}}
> x i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
>
>  template 
> @@ -24,17 +24,19 @@ int tmain(T argc) {
>  }
>
>  int main (int argc, char **argv) {
> +  int a[argc];
>  #pragma omp parallel
> -  foo(argc);
> +  foo(a[1]);
>return tmain(argv);
>  }
>
>  // CHECK-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}}
> %argc, i8** %argv)
>  // CHECK: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
> -// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)
> @__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)*
> bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*,
> i32*, ...)*), i32* [[ARGC_ADDR]])
> +// CHECK: [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
> +// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...)
> @__kmpc_fork_call(%ident_t* [[DEF_L

[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS

2016-11-07 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

This test is extremely fragile. Maybe, it is better to disable it, or even 
delete it altogether.


https://reviews.llvm.org/D26150



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


[PATCH] D25608: [libclang] Make tests for python bindings pass on Windows.

2016-11-07 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping.


https://reviews.llvm.org/D25608



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


Re: r286098 - [OPENMP] Fixed capturing of VLA variables.

2016-11-07 Thread Alexey Bataev via cfe-commits
Hi Diana, will fix it in couple hours.

Best regards,
Alexey Bataev

7 нояб. 2016 г., в 12:38, Diana Picus 
mailto:diana.pi...@linaro.org>> написал(а):

Hi,

This has been breaking the bots for almost an hour. Can you fix/revert?

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/304
http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/657
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/347

Thanks,
Diana

On 7 November 2016 at 10:07, Alexey Bataev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: abataev
Date: Mon Nov  7 02:07:25 2016
New Revision: 286098

URL: http://llvm.org/viewvc/llvm-project?rev=286098&view=rev
Log:
[OPENMP] Fixed capturing of VLA variables.

After some changes in codegen capturing of VLA variables in OpenMP
regions was broken, causing compiler crash. Patch fixes this issue.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 02:07:25 2016
@@ -2127,12 +2127,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
   if (auto *FD = LambdaCaptureFields.lookup(VD))
 return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
   else if (CapturedStmtInfo) {
-auto it = LocalDeclMap.find(VD);
-if (it != LocalDeclMap.end()) {
-  if (auto RefTy = VD->getType()->getAs()) {
-return EmitLoadOfReferenceLValue(it->second, RefTy);
-  }
-  return MakeAddrLValue(it->second, T);
+auto I = LocalDeclMap.find(VD);
+if (I != LocalDeclMap.end()) {
+  if (auto RefTy = VD->getType()->getAs())
+return EmitLoadOfReferenceLValue(I->second, RefTy);
+  return MakeAddrLValue(I->second, T);
 }
 LValue CapLVal =
 EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 02:07:25 2016
@@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
 if (ArgLVal.getType()->isLValueReferenceType()) {
   ArgAddr = EmitLoadOfReference(
   ArgAddr, ArgLVal.getType()->castAs());
-} else {
+} else if (!VarTy->isVariablyModifiedType() || 
!VarTy->isPointerType()) {
   assert(ArgLVal.getType()->isPointerType());
   ArgAddr = EmitLoadOfPointer(
   ArgAddr, ArgLVal.getType()->castAs());

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=286098&r1=286097&r2=286098&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 02:07:25 2016
@@ -10,7 +10,7 @@
 // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %ident_t 
{ i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* 
[[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
 // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"

 template 
@@ -24,17 +24,19 @@ int tmain(T argc) {
 }

 int main (int argc, char **argv) {
+  int a[argc];
 #pragma omp parallel
-  foo(argc);
+  foo(a[1]);
   return tmain(argv);
 }

 // CHECK-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}} %argc, 
i8** %argv)
 // CHECK: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
-// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, 
...)*), i32* [[ARGC_ADDR]])
+// CHECK: [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
+// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i3

r286102 - Revert "[OPENMP] Fixed capturing of VLA variables."

2016-11-07 Thread Diana Picus via cfe-commits
Author: rovka
Date: Mon Nov  7 04:01:43 2016
New Revision: 286102

URL: http://llvm.org/viewvc/llvm-project?rev=286102&view=rev
Log:
Revert "[OPENMP] Fixed capturing of VLA variables."

This reverts commit r286098 because the modified test breaks on many of the
buildbots.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286102&r1=286101&r2=286102&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 04:01:43 2016
@@ -2127,11 +2127,12 @@ LValue CodeGenFunction::EmitDeclRefLValu
   if (auto *FD = LambdaCaptureFields.lookup(VD))
 return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
   else if (CapturedStmtInfo) {
-auto I = LocalDeclMap.find(VD);
-if (I != LocalDeclMap.end()) {
-  if (auto RefTy = VD->getType()->getAs())
-return EmitLoadOfReferenceLValue(I->second, RefTy);
-  return MakeAddrLValue(I->second, T);
+auto it = LocalDeclMap.find(VD);
+if (it != LocalDeclMap.end()) {
+  if (auto RefTy = VD->getType()->getAs()) {
+return EmitLoadOfReferenceLValue(it->second, RefTy);
+  }
+  return MakeAddrLValue(it->second, T);
 }
 LValue CapLVal =
 EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=286102&r1=286101&r2=286102&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 04:01:43 2016
@@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
 if (ArgLVal.getType()->isLValueReferenceType()) {
   ArgAddr = EmitLoadOfReference(
   ArgAddr, ArgLVal.getType()->castAs());
-} else if (!VarTy->isVariablyModifiedType() || 
!VarTy->isPointerType()) {
+} else {
   assert(ArgLVal.getType()->isPointerType());
   ArgAddr = EmitLoadOfPointer(
   ArgAddr, ArgLVal.getType()->castAs());

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=286102&r1=286101&r2=286102&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 04:01:43 2016
@@ -10,7 +10,7 @@
 // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %ident_t 
{ i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* 
[[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
 // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
 
 template 
@@ -24,19 +24,17 @@ int tmain(T argc) {
 }
 
 int main (int argc, char **argv) {
-  int a[argc];
 #pragma omp parallel
-  foo(a[1]);
+  foo(argc);
   return tmain(argv);
 }
 
 // CHECK-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}} %argc, 
i8** %argv)
 // CHECK: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
-// CHECK: [[VLA:%.+]] = alloca i32, i64 [[VLA_SIZE:%[^,]+]],
-// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i64, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, 
i32*, ...)*), i64 [[VLA_SIZE]], i32* [[VLA]])
+// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, 
...)*), i32* [[ARGC_ADDR]])
 // CHECK-NEXT:  [[ARGV:%.+]] = load i8**, i8*** {{%[a-z0-9.]+}}
 // CHECK-NEXT:  [[RET:%.+]] = call {{[a-z\_\b]*[ ]?i32}} 
[[TMAIN:@.+tmain.+]](i8** [[ARGV]])
-// CHECK:   ret i32
+// CHECK-NEXT:  ret i32 [[RET]]
 // CHECK-NEXT:  }
 // CHECK-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %ident_t
@@ -44,33 +42,30 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG-NEXT:  [[KMPC_DEFAULT_LOC_

Re: r286098 - [OPENMP] Fixed capturing of VLA variables.

2016-11-07 Thread Diana Picus via cfe-commits
Hi Alexey,

If it is not a simple, quick fix that you can do, it is customary to revert
so the buildbots become green again. Otherwise, if people commit other
things that break the build they will not get emails and it will be much
harder to fix the whole thing.

I'll revert this for you and you can commit the fixed version later on,
when it's ready.

Thanks,
Diana

On 7 November 2016 at 11:54, Alexey Bataev  wrote:

> Hi Diana, will fix it in couple hours.
>
> Best regards,
> Alexey Bataev
>
> 7 нояб. 2016 г., в 12:38, Diana Picus  написал(а):
>
> Hi,
>
> This has been breaking the bots for almost an hour. Can you fix/revert?
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/304
> http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/657
> http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/347
>
> Thanks,
> Diana
>
> On 7 November 2016 at 10:07, Alexey Bataev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: abataev
>> Date: Mon Nov  7 02:07:25 2016
>> New Revision: 286098
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=286098&view=rev
>> Log:
>> [OPENMP] Fixed capturing of VLA variables.
>>
>> After some changes in codegen capturing of VLA variables in OpenMP
>> regions was broken, causing compiler crash. Patch fixes this issue.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGExpr.cpp
>> cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>> cfe/trunk/test/OpenMP/parallel_codegen.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CG
>> Expr.cpp?rev=286098&r1=286097&r2=286098&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 02:07:25 2016
>> @@ -2127,12 +2127,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
>>if (auto *FD = LambdaCaptureFields.lookup(VD))
>>  return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
>>else if (CapturedStmtInfo) {
>> -auto it = LocalDeclMap.find(VD);
>> -if (it != LocalDeclMap.end()) {
>> -  if (auto RefTy = VD->getType()->getAs()) {
>> -return EmitLoadOfReferenceLValue(it->second, RefTy);
>> -  }
>> -  return MakeAddrLValue(it->second, T);
>> +auto I = LocalDeclMap.find(VD);
>> +if (I != LocalDeclMap.end()) {
>> +  if (auto RefTy = VD->getType()->getAs())
>> +return EmitLoadOfReferenceLValue(I->second, RefTy);
>> +  return MakeAddrLValue(I->second, T);
>>  }
>>  LValue CapLVal =
>>  EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),
>>
>> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CG
>> StmtOpenMP.cpp?rev=286098&r1=286097&r2=286098&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 02:07:25 2016
>> @@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
>>  if (ArgLVal.getType()->isLValueReferenceType()) {
>>ArgAddr = EmitLoadOfReference(
>>ArgAddr, ArgLVal.getType()->castAs());
>> -} else {
>> +} else if (!VarTy->isVariablyModifiedType() ||
>> !VarTy->isPointerType()) {
>>assert(ArgLVal.getType()->isPointerType());
>>ArgAddr = EmitLoadOfPointer(
>>ArgAddr, ArgLVal.getType()->castAs());
>>
>> Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/pa
>> rallel_codegen.cpp?rev=286098&r1=286097&r2=286098&view=diff
>> 
>> ==
>> --- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
>> +++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 02:07:25 2016
>> @@ -10,7 +10,7 @@
>>  // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
>>  // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x
>> i8] c";unknown;unknown;0;0;;\00"
>>  // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant
>> %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x
>> i8], [23 x i8]* [[STR]], i32 0, i32 0) }
>> -// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant
>> [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
>> +// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant
>> [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
>>  // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant
>> [{{.+}} x i8] c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
>>
>>  template 
>> @@ -24,17 +24,19 @@ int tmain(T argc) {
>>  }
>>
>>  int main (int argc, char **argv) {
>> +  int a[argc];
>>  #pragma

[PATCH] D24998: Add a new optimization option -Og

2016-11-07 Thread Sylvestre Ledru via cfe-commits
sylvestre.ledru updated this revision to Diff 77023.
Herald added a subscriber: mehdi_amini.

https://reviews.llvm.org/D24998

Files:
  docs/CommandGuide/clang.rst
  lib/Frontend/CompilerInvocation.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Og %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og  :#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines 
-check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,9 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g")
+  return 1;
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,9 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`. In future versions, this option might 
+disable different optimizations in order to improve debuggability.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -205,6 +205,12 @@
 // O1:#define __OPTIMIZE__ 1
 //
 //
+// RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Og %s
+//
+// Og-NOT:#define __OPTIMIZE_SIZE__
+// Og	:#define __OPTIMIZE__ 1
+//
+//
 // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Os %s
 //
 // Os:#define __OPTIMIZE_SIZE__ 1
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -98,6 +98,9 @@
 if (S == "s" || S == "z" || S.empty())
   return 2;
 
+if (S == "g")
+  return 1;
+
 return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags);
   }
 
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -226,7 +226,7 @@
 Code Generation Options
 ~~~
 
-.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -O, -O4
+.. option:: -O0, -O1, -O2, -O3, -Ofast, -Os, -Oz, -Og, -O, -O4
 
   Specify which optimization level to use:
 
@@ -252,6 +252,9 @@
 :option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
 size further.
 
+:option:`-Og` Like :option:`-O1`. In future versions, this option might 
+disable different optimizations in order to improve debuggability.
+
 :option:`-O` Equivalent to :option:`-O2`.
 
 :option:`-O4` and higher
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286103 - [OPENMP] Fixed capturing of VLA variables.

2016-11-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Nov  7 05:16:04 2016
New Revision: 286103

URL: http://llvm.org/viewvc/llvm-project?rev=286103&view=rev
Log:
[OPENMP] Fixed capturing of VLA variables.

After some changes in codegen capturing of VLA variables in OpenMP regions was 
broken, causing compiler crash. Patch fixes this issue.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286103&r1=286102&r2=286103&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 05:16:04 2016
@@ -2127,12 +2127,11 @@ LValue CodeGenFunction::EmitDeclRefLValu
   if (auto *FD = LambdaCaptureFields.lookup(VD))
 return EmitCapturedFieldLValue(*this, FD, CXXABIThisValue);
   else if (CapturedStmtInfo) {
-auto it = LocalDeclMap.find(VD);
-if (it != LocalDeclMap.end()) {
-  if (auto RefTy = VD->getType()->getAs()) {
-return EmitLoadOfReferenceLValue(it->second, RefTy);
-  }
-  return MakeAddrLValue(it->second, T);
+auto I = LocalDeclMap.find(VD);
+if (I != LocalDeclMap.end()) {
+  if (auto RefTy = VD->getType()->getAs())
+return EmitLoadOfReferenceLValue(I->second, RefTy);
+  return MakeAddrLValue(I->second, T);
 }
 LValue CapLVal =
 EmitCapturedFieldLValue(*this, CapturedStmtInfo->lookup(VD),

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=286103&r1=286102&r2=286103&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Mon Nov  7 05:16:04 2016
@@ -307,7 +307,7 @@ CodeGenFunction::GenerateOpenMPCapturedS
 if (ArgLVal.getType()->isLValueReferenceType()) {
   ArgAddr = EmitLoadOfReference(
   ArgAddr, ArgLVal.getType()->castAs());
-} else {
+} else if (!VarTy->isVariablyModifiedType() || 
!VarTy->isPointerType()) {
   assert(ArgLVal.getType()->isPointerType());
   ArgAddr = EmitLoadOfPointer(
   ArgAddr, ArgLVal.getType()->castAs());

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=286103&r1=286102&r2=286103&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 05:16:04 2016
@@ -10,7 +10,7 @@
 // CHECK-DEBUG-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
 // CHECK-DEBUG-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] 
c";unknown;unknown;0;0;;\00"
 // CHECK-DEBUG-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant %ident_t 
{ i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* 
[[STR]], i32 0, i32 0) }
-// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+14]];9;;\00"
+// CHECK-DEBUG-DAG: [[LOC1:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;main;[[@LINE+15]];9;;\00"
 // CHECK-DEBUG-DAG: [[LOC2:@.+]] = private unnamed_addr constant [{{.+}} x i8] 
c";{{.*}}parallel_codegen.cpp;tmain;[[@LINE+7]];9;;\00"
 
 template 
@@ -24,17 +24,19 @@ int tmain(T argc) {
 }
 
 int main (int argc, char **argv) {
+  int a[argc];
 #pragma omp parallel
-  foo(argc);
+  foo(a[1]);
   return tmain(argv);
 }
 
 // CHECK-LABEL: define {{[a-z\_\b]*[ ]?i32}} @main({{i32[ ]?[a-z]*}} %argc, 
i8** %argv)
 // CHECK: store i32 %argc, i32* [[ARGC_ADDR:%.+]],
-// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 1, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i32*)* [[OMP_OUTLINED:@.+]] to void (i32*, i32*, 
...)*), i32* [[ARGC_ADDR]])
+// CHECK: [[VLA:%.+]] = alloca i32, i{{[0-9]+}} [[VLA_SIZE:%[^,]+]],
+// CHECK:  call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(%ident_t* [[DEF_LOC_2]], i32 2, void (i32*, i32*, ...)* 
bitcast (void (i32*, i32*, i{{[0-9]+}}, i32*)* [[OMP_OUTLINED:@.+]] to void 
(i32*, i32*, ...)*), i{{[0-9]+}} [[VLA_SIZE]], i32* [[VLA]])
 // CHECK-NEXT:  [[ARGV:%.+]] = load i8**, i8*** {{%[a-z0-9.]+}}
 // CHECK-NEXT:  [[RET:%.+]] = call {{[a-z\_\b]*[ ]?i32}} 
[[TMAIN:@.+tmain.+]](i8** [[ARGV]])
-// CHECK-NEXT:  ret i32 [[RET]]
+// CHECK:   ret i32
 // CHECK-NEXT:  }
 // CHECK-DEBUG-LABEL: define i32 @main(i32 %argc, i8** %argv)
 // CHECK-DEBUG:   [[LOC_2_ADDR:%.+]] = alloca %ident_t
@@ -42,30 +44,33 @@ int main (i

[PATCH] D21126: Fix crash when rewriting call to match placeholder

2016-11-07 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

This has already been fixed in r276352. I closed PR25961.


https://reviews.llvm.org/D21126



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


[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-07 Thread Alex Lorenz via cfe-commits
arphaman accepted this revision.
arphaman added a reviewer: arphaman.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM, Thanks.


https://reviews.llvm.org/D22770



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-11-07 Thread Gergely Angeli via cfe-commits
SilverGeri updated this revision to Diff 77015.
SilverGeri added a comment.

checks `if (p != 0)` conditions, too


https://reviews.llvm.org/D21298

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DeleteNullPointerCheck.cpp
  clang-tidy/misc/DeleteNullPointerCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-delete-null-pointer.rst
  test/clang-tidy/misc-delete-null-pointer.cpp

Index: test/clang-tidy/misc-delete-null-pointer.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-delete-null-pointer.cpp
@@ -0,0 +1,49 @@
+// RUN: %check_clang_tidy %s misc-delete-null-pointer %t
+
+#include 
+
+void f() {
+  int *p = 0;
+  if (p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+  int *p3 = new int[3];
+  if (p3)
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete[] p3;
+  // CHECK-FIXES: delete[] p3;
+
+  if (NULL != p) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+
+  if (p != nullptr) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+
+  if (p != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: if statement is unnecessary (deleting null pointer has no effect) [misc-delete-null-pointer]
+delete p;
+  }
+  // CHECK-FIXES: delete p;
+}
+
+void g() {
+  int *p, *p2;
+  if (p)
+delete p2;
+
+  if (p && p2)
+delete p;
+
+  if (p2) {
+int x = 5;
+delete p2;
+  }
+}
Index: docs/clang-tidy/checks/misc-delete-null-pointer.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-delete-null-pointer.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - misc-delete-null-pointer
+
+misc-delete-null-pointer
+
+
+Checks the if statements where a pointer's existence is checked and then deletes the pointer.
+The check is unnecessary as deleting a nullpointer has no effect.
+
+.. code:: c++
+  int *p;
+  if (p)
+delete p;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -58,6 +58,7 @@
misc-bool-pointer-implicit-conversion
misc-dangling-handle
misc-definitions-in-headers
+   misc-delete-null-pointer
misc-fold-init-type
misc-forward-declaration-namespace
misc-inaccurate-erase
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "ArgumentCommentCheck.h"
 #include "AssertSideEffectCheck.h"
+#include "DeleteNullPointerCheck.h"
 #include "MisplacedConstCheck.h"
 #include "UnconventionalAssignOperatorCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
@@ -63,6 +64,8 @@
 CheckFactories.registerCheck("misc-argument-comment");
 CheckFactories.registerCheck(
 "misc-assert-side-effect");
+CheckFactories.registerCheck(
+"misc-delete-null-pointer");
 CheckFactories.registerCheck(
 "misc-misplaced-const");
 CheckFactories.registerCheck(
Index: clang-tidy/misc/DeleteNullPointerCheck.h
===
--- /dev/null
+++ clang-tidy/misc/DeleteNullPointerCheck.h
@@ -0,0 +1,35 @@
+//===--- DeleteNullPointerCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DELETE_NULL_POINTER_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DELETE_NULL_POINTER_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// FIXME: Write a short description.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-delete-null-pointer.html
+class DeleteNullPointerCheck : public ClangTidyCheck {
+public:
+  DeleteNullPointerCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+

[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-07 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I don't suppose there's a testcase we could generate for this fix?


https://reviews.llvm.org/D22770



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


r286106 - [OPENMP] Fixed test on MIPS-based buildbots.

2016-11-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Nov  7 07:37:34 2016
New Revision: 286106

URL: http://llvm.org/viewvc/llvm-project?rev=286106&view=rev
Log:
[OPENMP] Fixed test on MIPS-based buildbots.

Modified:
cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=286106&r1=286105&r2=286106&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Mon Nov  7 07:37:34 2016
@@ -53,7 +53,7 @@ int main (int argc, char **argv) {
 // CHECK-DEBUG:   ret i32
 // CHECK-DEBUG-NEXT:  }
 
-// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i{{[0-9]+}} [[VLA_SIZE:%.+]], i32* 
[[VLA_ADDR:%[^)]+]])
+// CHECK:   define internal {{.*}}void [[OMP_OUTLINED]](i32* noalias 
%.global_tid., i32* noalias %.bound_tid., i{{[0-9]+}}{{.*}} [[VLA_SIZE:%.+]], 
i32* [[VLA_ADDR:%[^)]+]])
 // CHECK-SAME:   #[[FN_ATTRS:[0-9]+]]
 // CHECK:   store i32* [[VLA_ADDR]], i32** [[VLA_PTR_ADDR:%.+]],
 // CHECK:   [[VLA_REF:%.+]] = load i32*, i32** [[VLA_PTR_ADDR]]


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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-07 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:423
+
+void IteratorPastEndChecker::handleComparison(CheckerContext &C,
+  const SVal &LVal,

NoQ wrote:
> a.sidorin wrote:
> > What will happen if we write something like this:
> > ```
> > bool Eq1 = it1 == it2;
> > bool Eq2 = it3 == it4;
> > if (Eq1) {...}?
> > ```
> > 
> > As I understand, we'll assume the second condition instead of first.
> Had a look. So the problem is, we obtain the result of the comparison as a 
> symbol, from which it is too hard to recover the operands in order to move 
> iterator position data from one value to another.
> 
> Normally we obtain a simple SymbolConjured for the return value of the 
> `operator==()` call (or, similarly, `operator!=()`). For plain-value 
> iterators (eg. `typedef T *iterator`) we might be obtaining an actual binary 
> symbolic expression, but even then it's not quite clear how to obtain 
> operands (the structure of the expression might have changed due to algebraic 
> simplifications). Additionally, LHS and RHS aren't necessarily symbols (they 
> might be semi-concrete), so composing symbolic expressions from them in 
> general is problematic with our symbol hierarchy, which is rarely a problem 
> for numbers but for structural symbols it'd be a mess.
> 
> For now i suggest, instead of storing only the last LHS and RHS, to save a 
> map from symbols (which are results of comparisons) to (LHS value, RHS value) 
> pairs. This map should, apart from the obvious, be cleaned up whenever one of 
> the iterators in the pair gets mutated (incremented or decremented). This 
> should take care of the problem Alexey points out, and should work with 
> semi-concrete stuff.
> 
> For the future i suggest to let users construct their own symbols and 
> symbolic expressions more easily. In fact, if only we had all iterators as 
> regions, we should have probably used SymbolMetadata for this purpose: it's 
> easy to both recover the parent region from it and use it in symbolic 
> expressions. We could also deprecate the confusing structural symbols 
> (provide default-bound lazy compound values for conjured structures instead), 
> and then it'd be possible to transition to SymbolMetadata entirely.
Thank you for the suggestion. I am not sure if I fully understand you. If I 
create a map where the key is the resulting symbol of the comparison, it will 
not work because evalAssume is called for the innermost comparison. So if the 
body of operator== (or operator!=) is inlined, then I get a binary symbolic 
expression in evalAssume, not the SymbolConjured. This binary Symbolic 
expression is a comparison of the internals of the iterators, e.g. the internal 
pointer. So the key will not match any LHS and RHS value pair in the map. I 
also thought on such solution earlier but I dismissed it because of this.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:580
+  C.addTransition(stateFound);
+  C.addTransition(stateNotFound);
+}

NoQ wrote:
> NoQ wrote:
> > Ouch, i have one more concern, which can be expressed with the following 
> > false-positive test which currently fails:
> > 
> > ```
> > void foo() {
> >   std::vector vec;
> >   vec.push_back(2016);
> >   auto i = vec.find(vec.begin(), vec.end(), 2016);
> >   *i; // no-warning
> > }
> > ```
> > 
> > Not instantly sure what to do with this. You can avoid state splits until 
> > you are actually sure if both branches are possible, but that'd suppress a 
> > lot of useful positives. Such positives could be suppressed with 
> > assertions, of course, but i'd still hope there aren't too many of those.
> I mean, `std::find(...` ><
False positives can occur whenever we are sure that we will find the element so 
we do not check for the result to be equal with end().


https://reviews.llvm.org/D25660



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


[PATCH] D19979: [analyzer] ScopeContext - initial implementation

2016-11-07 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Hm. A pretty nice example. But we should check if the initial patch supports 
`goto`s; afair, it doesn't.


https://reviews.llvm.org/D19979



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-07 Thread Alpha Abdoulaye via cfe-commits
Alpha updated this revision to Diff 77029.
Alpha added a comment.

Ignore export of empty fixes.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/DiagnosticsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,43 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager &Sources,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, Diagnostic::Level DiagLevel)
+: CheckName(CheckName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, DiagnosticMessage &Message,
+   llvm::StringMap &Fix,
+   SmallVector &Notes,
+   Level DiagLevel)
+: CheckName(CheckName), Message(Message), Fix(Fix), Notes(Notes),
+  DiagLevel(DiagLevel) {}
+
+} // end namespace tooling
+} // end namespace clang
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -4,6 +4,7 @@
   Lookup.cpp
   Replacement.cpp
   QualTypeNames.cpp
+  Diagnostic.cpp
 
   LINK_LIBS
   clangAST
Index: include/clang/Tooling/DiagnosticsYaml.h
===
--- include/clang/Tooling/DiagnosticsYaml.h
+++ include/clang/Tooling/DiagnosticsYaml.h
@@ -0,0 +1,90 @@
+//===-- DiagnosticsYaml.h -- Serialiazation for Diagnosticss ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file defines the structure of a YAML document for serializing
+/// diagnostics.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+#define LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::Diagnostic)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  /// \brief Helper to (de)serialize a Diagnostic since we don't have direct
+  /// access to its data members.
+  class NormalizedDiagnostic {
+  public:
+NormalizedDiagnostic(const IO &)
+: CheckName(""), Message(), Fix(), Notes(), DiagLevel() {}
+
+NormalizedDiagnostic(const IO &, const clang::tooling::Diagnostic &D)
+: CheckName(D.CheckName), Message(Message), Fix(D.Fix), Notes(D.Notes),
+  DiagLevel(D.DiagLevel) {}
+
+clang::tooling::Diagnostic denormalize(const IO &) {
+  return clang::tooling::Diagnostic(CheckName, Message, Fix, Notes,
+DiagLevel);
+}
+
+std::string CheckName;
+clang::tooling::DiagnosticMessage Message;
+llvm::StringMap Fix;
+SmallVector Notes;
+clang::tooling::Diagnostic::Level DiagLevel;
+  };
+
+  static void mapping(IO &Io, clang::tooling::Diagnostic &D) {
+MappingNormalization Keys(
+Io, D);
+Io.mapRequired("CheckName", Keys->CheckName);
+std::vector Fixes;
+for (auto & Replacements : Keys->Fi

[PATCH] D26350: Keep invalid Switch in the AST

2016-11-07 Thread Olivier Goffart via cfe-commits
ogoffart created this revision.
ogoffart added reviewers: rsmith, cfe-commits.

- When the condition is invalid, replace it by an OpaqueValueExpr

- When parsing an invalid CaseStmt, don't drop the sub statement, just return  
it instead.

- In Sema::ActOnStartOfSwitchStmt, always keep the SwitchStmt, even if it has 
duplicate case or defaults statement or that the condition cannot be converted 
to an integral type.




https://reviews.llvm.org/D26350

Files:
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmt.cpp
  test/Misc/ast-dump-invalid-switch.cpp

Index: test/Misc/ast-dump-invalid-switch.cpp
===
--- /dev/null
+++ test/Misc/ast-dump-invalid-switch.cpp
@@ -0,0 +1,105 @@
+// RUN: not %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -fms-extensions -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
+
+/* This test ensures that the AST is still complete, even for invalid code */
+
+namespace TestInvalidSwithCondition {
+int f(int x) {
+  switch (_invalid_) {
+  case 0:
+return 1;
+  default:
+return 2;
+  }
+}
+}
+
+// CHECK: NamespaceDecl {{.*}} TestInvalidSwithCondition
+// CHECK-NEXT: `-FunctionDecl
+// CHECK-NEXT:   |-ParmVarDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: `-SwitchStmt
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-OpaqueValueExpr
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: |-CaseStmt
+// CHECK-NEXT: | |-IntegerLiteral {{.*}} 'int' 0
+// CHECK-NEXT: | |-<<>>
+// CHECK-NEXT: | `-ReturnStmt
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 'int' 1
+// CHECK-NEXT: `-DefaultStmt
+// CHECK-NEXT:   `-ReturnStmt
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+
+namespace TestSwitchConditionNotIntegral {
+int g(int *x) {
+  switch (x) {
+  case 0:
+return 1;
+  default:
+return 2;
+  }
+}
+}
+
+// CHECK: NamespaceDecl {{.*}} TestSwitchConditionNotIntegral
+// CHECK-NEXT: `-FunctionDecl
+// CHECK-NEXT:   |-ParmVarDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: `-SwitchStmt
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-ImplicitCastExpr
+// CHECK-NEXT:   | `-DeclRefExpr {{.*}} 'x' 'int *'
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: |-CaseStmt
+// CHECK-NEXT: | |-IntegerLiteral {{.*}} 'int' 0
+// CHECK-NEXT: | |-<<>>
+// CHECK-NEXT: | `-ReturnStmt
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 'int' 1
+// CHECK-NEXT: `-DefaultStmt
+// CHECK-NEXT:   `-ReturnStmt
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 2
+
+namespace TestSwitchInvalidCases {
+int g(int x) {
+  switch (x) {
+  case _invalid_:
+return 1;
+  case _invalid_:
+return 2;
+  case x:
+return 3;
+  default:
+return 4;
+  default:
+return 5;
+  }
+}
+}
+
+// CHECK: NamespaceDecl {{.*}} TestSwitchInvalidCases
+// CHECK-NEXT: `-FunctionDecl
+// CHECK-NEXT:   |-ParmVarDecl
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: `-SwitchStmt
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-<<>>
+// CHECK-NEXT:   |-ImplicitCastExpr
+// CHECK-NEXT:   | `-DeclRefExpr {{.*}}'x' 'int'
+// CHECK-NEXT:   `-CompoundStmt
+// CHECK-NEXT: |-ReturnStmt
+// CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 1
+// CHECK-NEXT: |-ReturnStmt
+// CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 2
+// CHECK-NEXT: |-CaseStmt
+// CHECK-NEXT: | |-DeclRefExpr {{.*}} 'x' 'int'
+// CHECK-NEXT: | |-<<>>
+// CHECK-NEXT: | `-ReturnStmt
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 'int' 3
+// CHECK-NEXT: |-DefaultStmt
+// CHECK-NEXT: | `-ReturnStmt
+// CHECK-NEXT: |   `-IntegerLiteral {{.*}} 'int' 4
+// CHECK-NEXT: `-DefaultStmt
+// CHECK-NEXT:   `-ReturnStmt
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 5
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -666,7 +666,12 @@
 StmtResult Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
 Stmt *InitStmt, ConditionResult Cond) {
   if (Cond.isInvalid())
-return StmtError();
+Cond = ConditionResult(
+*this, nullptr,
+MakeFullExpr(new (Context) OpaqueValueExpr(SourceLocation(),
+   Context.IntTy, VK_RValue),
+ SwitchLoc),
+false);
 
   getCurFunction()->setHasBranchIntoScope();
 
@@ -768,7 +773,7 @@
 // type, when we started the switch statement. If we don't have an
 // appropriate type now, just return an error.
 if (!CondType->isIntegralOrEnumerationType())
-  return StmtError();
+  return SS;
 
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {..

[PATCH] D26350: Keep invalid Switch in the AST

2016-11-07 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

I believe only the change in ActOnFinishSwitchStmt might be controversial. 
Is it breaking an invariant than having switches kept in the AST?


https://reviews.llvm.org/D26350



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-07 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 77033.
baloghadamsoftware added a comment.

Interim version, updated according to some of the comments.


https://reviews.llvm.org/D25660

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/Inputs/system-header-simulator-for-iterators.h
  test/Analysis/iterator-past-end.cpp

Index: test/Analysis/iterator-past-end.cpp
===
--- /dev/null
+++ test/Analysis/iterator-past-end.cpp
@@ -0,0 +1,180 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd %s -verify
+
+#include "Inputs/system-header-simulator-for-iterators.h"
+
+void simple_good(const std::vector &v) {
+  auto i = v.end();
+  if (i != v.end())
+*i; // no-warning
+}
+
+void simple_bad(const std::vector &v) {
+  auto i = v.end();
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void decrease(const std::vector &v) {
+  auto i = v.end();
+  --i;
+  *i; // no-warning
+}
+
+void copy_and_decrease1(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i1; // no-warning
+}
+
+void copy_and_decrease2(const std::vector &v) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy_and_increase1(const std::vector &v) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i1 == v.end())
+*i2; // no-warning
+}
+
+void copy_and_increase2(const std::vector &v) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i2 == v.end())
+*i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find(std::vector &vec, int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find(std::vector &vec, int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_end(std::vector &vec, std::vector &seq) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_find_end(std::vector &vec, std::vector &seq) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_first_of(std::vector &vec, std::vector &seq) {
+  auto first =
+  std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_first_of(std::vector &vec, std::vector &seq) {
+  auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+bool odd(int i) { return i % 2; }
+
+void good_find_if(std::vector &vec) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if(std::vector &vec, int e) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_if_not(std::vector &vec) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if_not(std::vector &vec, int e) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_lower_bound(std::vector &vec, int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_lower_bound(std::vector &vec, int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_upper_bound(std::vector &vec, int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_upper_bound(std::vector &vec, int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_search(std::vector &vec, std::vector &seq) {
+  auto first = std::search(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_search(std::vector &vec, std::vector &seq) {
+  auto first = std::search(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_search_n(std::vector &vec, std::vector &seq) {
+  auto nth = std::search_n(vec.begin

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-11-07 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware marked 9 inline comments as done.
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:337
+  const auto *RPos = getIteratorPosition(State, Right);
+  if (LPos && !RPos) {
+if ((LPos->isInRange() && ((Opc == BO_EQ) == Assumption)) ||

a.sidorin wrote:
> Maybe we should just swap Rhs and Lhs if LPos is null? So, we can avoid code 
> duplication.
Instead of swapping I moved the code into a separate function and I call this 
functions now with differenet parameters.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:573
+
+  auto RetVal = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, 
C.blockCount());
+  auto SecondParam = state->getSVal(CE->getArg(1), C.getLocationContext());

a.sidorin wrote:
> You can use overload which does not require the tag.
There is an overload that does not requires a tag, but it requires a type 
instad.


https://reviews.llvm.org/D25660



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


[PATCH] D26160: [PowerPC] Implement remaining vector comparison builtins

2016-11-07 Thread Tony Jiang via cfe-commits
jtony updated this revision to Diff 77036.
jtony added a comment.

I migrated the commit from the old anonymous repository to the new jtony 
repository to prepare for committing upstream (use git svn dcommit).  Should 
not have any difference with the previous patches, update it just in case.


https://reviews.llvm.org/D26160

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c

Index: test/CodeGen/builtins-ppc-p8vector.c
===
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -151,6 +151,11 @@
 // CHECK-PPC: warning: implicit declaration of function 'vec_mergeo'
   
   /* vec_cmpeq */
+  res_vbll = vec_cmpeq(vbll, vbll);
+// CHECK: @llvm.ppc.altivec.vcmpequd
+// CHECK-LE: @llvm.ppc.altivec.vcmpequd
+// CHECK-PPC: error: call to 'vec_cmpeq' is ambiguous
+
   res_vbll = vec_cmpeq(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd
 // CHECK-LE: @llvm.ppc.altivec.vcmpequd
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -938,6 +938,14 @@
 // CHECK: @llvm.ppc.altivec.vcmpequb
 // CHECK-LE: @llvm.ppc.altivec.vcmpequb
 
+  res_vbc = vec_cmpeq(vbc, vbc);
+// CHECK: @llvm.ppc.altivec.vcmpequb
+// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+
+  res_vbc = vec_cmpeq(vbc, vbc);
+// CHECK: @llvm.ppc.altivec.vcmpequb
+// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+
   res_vbs = vec_cmpeq(vs, vs);
 // CHECK: @llvm.ppc.altivec.vcmpequh
 // CHECK-LE: @llvm.ppc.altivec.vcmpequh
@@ -946,6 +954,14 @@
 // CHECK: @llvm.ppc.altivec.vcmpequh
 // CHECK-LE: @llvm.ppc.altivec.vcmpequh
 
+  res_vbs = vec_cmpeq(vbs, vbs);
+// CHECK: @llvm.ppc.altivec.vcmpequh
+// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+
+  res_vbs = vec_cmpeq(vbs, vbs);
+// CHECK: @llvm.ppc.altivec.vcmpequh
+// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+
   res_vbi = vec_cmpeq(vi, vi);
 // CHECK: @llvm.ppc.altivec.vcmpequw
 // CHECK-LE: @llvm.ppc.altivec.vcmpequw
@@ -954,6 +970,14 @@
 // CHECK: @llvm.ppc.altivec.vcmpequw
 // CHECK-LE: @llvm.ppc.altivec.vcmpequw
 
+  res_vbi = vec_cmpeq(vbi, vbi);
+// CHECK: @llvm.ppc.altivec.vcmpequw
+// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+
+  res_vbi = vec_cmpeq(vbi, vbi);
+// CHECK: @llvm.ppc.altivec.vcmpequw
+// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+
   res_vbi = vec_cmpeq(vf, vf);
 // CHECK: @llvm.ppc.altivec.vcmpeqfp
 // CHECK-LE: @llvm.ppc.altivec.vcmpeqfp
Index: lib/Headers/altivec.h
===
--- lib/Headers/altivec.h
+++ lib/Headers/altivec.h
@@ -1564,6 +1564,12 @@
   (vector char)__b);
 }
 
+static __inline__ vector bool char __ATTRS_o_ai
+vec_cmpeq(vector bool char __a, vector bool char __b) {
+  return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
+  (vector char)__b);
+}
+
 static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
vector short __b) {
   return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
@@ -1575,6 +1581,12 @@
(vector short)__b);
 }
 
+static __inline__ vector bool short __ATTRS_o_ai
+vec_cmpeq(vector bool short __a, vector bool short __b) {
+  return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
+   (vector short)__b);
+}
+
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
  vector int __b) {
   return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
@@ -1586,6 +1598,12 @@
  (vector int)__b);
 }
 
+static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
+ vector bool int __b) {
+  return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
+ (vector int)__b);
+}
+
 #ifdef __POWER8_VECTOR__
 static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpeq(vector signed long long __a, vector signed long long __b) {
@@ -1597,6 +1615,13 @@
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+  return (vector bool long long)__builtin_altivec_vcmpequd(
+  (vector long long)__a, (vector long long)__b);
+}
+
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2298,14 +2323,15 @@
  result if either is zero.
   */
   vector bool char __tmp1 = vec_cm

[PATCH] D26282: [PowerPC] Implement plain VSX load/store builtins.

2016-11-07 Thread Tony Jiang via cfe-commits
jtony updated this revision to Diff 77037.
jtony added a comment.

I also migrated this commit from the old anonymous repository to the new jtony 
repository to prepare for committing upstream (use git svn dcommit). Should not 
have any difference with the previous patch, update it just in case.


https://reviews.llvm.org/D26282

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-quadword.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -21,6 +21,7 @@
 vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
 double d = 23.4;
+signed long long sll = 618LL;
 float af[4] = {23.4f, 56.7f, 89.0f, 12.3f};
 double ad[2] = {23.4, 56.7};
 signed char asc[16] = { -8,  9, -10, 11, -12, 13, -14, 15,
@@ -31,8 +32,8 @@
 unsigned short aus[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 signed int asi[4] = { -1, 2, -3, 4 };
 unsigned int aui[4] = { 0, 1, 2, 3 };
-signed long asl[2] = { -1L, 2L };
-unsigned long aul[2] = { 1L, 2L };
+signed long long asll[2] = { -1L, 2L };
+unsigned long long aull[2] = { 1L, 2L };
 
 vector float res_vf;
 vector double res_vd;
@@ -1248,4 +1249,28 @@
   res_vull = vec_sro(vull, vuc);
 // CHECK: @llvm.ppc.altivec.vsro
 // CHECK-LE: @llvm.ppc.altivec.vsro
+
+res_vsll = vec_xl(sll, asll);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vull = vec_xl(sll, aull);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vd = vec_xl(sll, ad);
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+
+vec_xst(vsll, sll, asll);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vull, sll, aull);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vd, sll, ad);
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 }
Index: test/CodeGen/builtins-ppc-quadword.c
===
--- test/CodeGen/builtins-ppc-quadword.c
+++ test/CodeGen/builtins-ppc-quadword.c
@@ -15,6 +15,12 @@
 // CHECK-PPC: error: __int128 is not supported on this target
 vector unsigned __int128 vulll = { 1 };
 
+signed long long param_sll;
+// CHECK-PPC: error: __int128 is not supported on this target
+signed __int128 param_lll;
+// CHECK-PPC: error: __int128 is not supported on this target
+unsigned __int128 param_ulll;
+
 // CHECK-PPC: error: __int128 is not supported on this target
 vector signed __int128 res_vlll;
 // CHECK-PPC: error: __int128 is not supported on this target
@@ -165,4 +171,26 @@
 // CHECK-LE: xor <16 x i8>
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}})
 // CHECK_PPC: error: call to 'vec_revb' is ambiguous
+
+  /* vec_xl */
+  res_vlll = vec_xl(param_sll, ¶m_lll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xl' is ambiguous
+
+  res_vulll = vec_xl(param_sll, ¶m_ulll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xl' is ambiguous
+
+  /* vec_xst */
+   vec_xst(vlll, param_sll, ¶m_lll);
+  // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xst' is ambiguous
+
+   vec_xst(vulll, param_sll, ¶m_ulll);
+  // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xst' is ambiguous
 }
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -45,6 +45,7 @@
 int param_i;
 unsigned int param_ui;
 float param_f;
+signed long long param_sll;
 
 int res_sc;
 int res_uc;
@@ -9224,3 +9225,69 @@
 // CHECK-LE: xor <16 x i8>
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}})
 }
+
+/* -- vec_xl  */
+void test9() {
+  // CHECK-LABEL: define void @test9
+  // CHE

[PATCH] D26302: [OpenCL] Remove redundant test for OpenCL header file

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

In https://reviews.llvm.org/D26302#587480, @Anastasia wrote:

> LGTM! Thanks! Do you know the runtime of this test now?


It takes about 1s in releaser build and 20s in debug build on my machine.


https://reviews.llvm.org/D26302



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


r286114 - [OpenCL] Remove redundant test for OpenCL header file

2016-11-07 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Mon Nov  7 09:55:51 2016
New Revision: 286114

URL: http://llvm.org/viewvc/llvm-project?rev=286114&view=rev
Log:
[OpenCL] Remove redundant test for OpenCL header file
Differential Revision: https://reviews.llvm.org/D26302

Modified:
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=286114&r1=286113&r2=286114&view=diff
==
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Mon Nov  7 09:55:51 2016
@@ -1,33 +1,6 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// 

[PATCH] D26302: [OpenCL] Remove redundant test for OpenCL header file

2016-11-07 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286114: [OpenCL] Remove redundant test for OpenCL header 
file (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D26302?vs=76932&id=77039#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26302

Files:
  cfe/trunk/test/Headers/opencl-c-header.cl


Index: cfe/trunk/test/Headers/opencl-c-header.cl
===
--- cfe/trunk/test/Headers/opencl-c-header.cl
+++ cfe/trunk/test/Headers/opencl-c-header.cl
@@ -1,33 +1,6 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple spir64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple ppc64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple powerpc-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -fblocks -emit-llvm -o - %s 
-cl-std=CL2.0| FileCheck --check-prefix=CHECK20 %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.2| 
FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -internal-isystem 
../../lib/Headers -include opencl-c.h -

[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-07 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

I looked at the way `HasFallthroughStmt` is used, and it didn't seem so, no. 
It's used in the following manner in AnalysisBasedWarnings.cpp:

  bool FallThroughDiagFull =
  !Diags.isIgnored(diag::warn_unannotated_fallthrough, D->getLocStart());
  bool FallThroughDiagPerFunction = !Diags.isIgnored(
  diag::warn_unannotated_fallthrough_per_function, D->getLocStart());
  if (FallThroughDiagFull || FallThroughDiagPerFunction ||
  fscope->HasFallthroughStmt) {
DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull);
  }

So it seems to me that even if `HasFallthroughStmt` isn't cleared, the analysis 
won't show up anything different for a function that re-used the scope info, 
because when diagnostics are ignored and the flag actually leads to incorrect 
call to `DiagnoseSwitchLabelsFallthrough `, the analysis won't show any 
warnings since the diagnostics are ignored. And likewise if one of the 
diagnostics is enabled then it doesn't matter if `HasFallthroughStmt` is true, 
so we won't be able to observe a difference there.


https://reviews.llvm.org/D22770



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


[PATCH] D24235: [OpenCL] Improve double literal handling

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



Comment at: test/SemaOpenCL/extensions.cl:28
+#ifdef FP64
+// expected-no-diagnostics
+#endif

expected-no-diagnostics applies to the whole file. better move to the beginning 
of the file.

otherwise LGTM. Thanks!


https://reviews.llvm.org/D24235



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


r286121 - [www] Update the link to the 'include what you use' project

2016-11-07 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Nov  7 10:56:19 2016
New Revision: 286121

URL: http://llvm.org/viewvc/llvm-project?rev=286121&view=rev
Log:
[www] Update the link to the 'include what you use' project

Modified:
cfe/trunk/www/related.html

Modified: cfe/trunk/www/related.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/related.html?rev=286121&r1=286120&r2=286121&view=diff
==
--- cfe/trunk/www/related.html (original)
+++ cfe/trunk/www/related.html Mon Nov  7 10:56:19 2016
@@ -64,7 +64,7 @@
   
 
   Site:
-http://code.google.com/p/include-what-you-use/";>http://code.google.com/p/include-what-you-use/
+https://github.com/include-what-you-use/include-what-you-use";>https://github.com/include-what-you-use/include-what-you-use
 
 
 Analyze #includes in C and C++ source files


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


[PATCH] D23657: Remove some false positives when taking the address of packed members

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

Some minor changes then this looks good to go.




Comment at: lib/Sema/SemaChecking.cpp:11348-11350
+  // Not the scope of this diagnostic.
+  if (!AnyIsPacked)
+return;

Move this to immediately after the loop.



Comment at: lib/Sema/SemaChecking.cpp:11367
+  // Compute the EffectiveAlignment as the alignment of the whole chain.
+  CharUnits EffectiveAlignment = Context.getTypeAlignInChars(
+  ReverseMemberChain.back()->getParent()->getTypeForDecl());

I think this would be a lot clearer as `CompleteObjectAlignment` or something 
like that.



Comment at: lib/Sema/SemaChecking.cpp:11383
+  // lower than the expected expression alignment.
+  || EffectiveAlignment < ExpectedAlignment) {
+// If this happens, we want to determine a sensible culprit of this.

`||` should go on the previous line.


https://reviews.llvm.org/D23657



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


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-11-07 Thread Kirill Romanenkov via cfe-commits
kromanenkov updated this revision to Diff 77041.
kromanenkov added a comment.

According to dcoughlin suggestion PointerToMember SVal is now modeled as a 
PointerUnion of DeclaratorDecl and bump pointer-allocated object stored 
DeclaratorDecl and immutable linked list of CXXBaseSpecifiers.


https://reviews.llvm.org/D25475

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SVals.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/pointer-to-member.cpp

Index: test/Analysis/pointer-to-member.cpp
===
--- test/Analysis/pointer-to-member.cpp
+++ test/Analysis/pointer-to-member.cpp
@@ -35,8 +35,7 @@
   clang_analyzer_eval(&A::getPtr == &A::getPtr); // expected-warning{{TRUE}}
   clang_analyzer_eval(&A::getPtr == 0); // expected-warning{{FALSE}}
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{TRUE}}
 }
 
 namespace PR15742 {
@@ -62,21 +61,114 @@
   }
 }
 
-// ---
-// FALSE NEGATIVES
-// ---
-
 bool testDereferencing() {
   A obj;
   obj.m_ptr = 0;
 
   A::MemberPointer member = &A::m_ptr;
 
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(obj.*member == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(obj.*member == 0); // expected-warning{{TRUE}}
 
   member = 0;
 
-  // FIXME: Should emit a null dereference.
-  return obj.*member; // no-warning
+  return obj.*member; // expected-warning{{}}
+}
+
+namespace testPointerToMemberFunction {
+  struct A {
+virtual int foo() { return 1; }
+int bar() { return 2;  }
+  };
+
+  struct B : public A {
+virtual int foo() { return 3; }
+  };
+
+  typedef int (A::*AFnPointer)();
+  typedef int (B::*BFnPointer)();
+
+  void testPointerToMemberCasts() {
+AFnPointer AFP = &A::bar;
+BFnPointer StaticCastedBase2Derived = static_cast(&A::bar),
+   CCastedBase2Derived = (BFnPointer) (&A::bar);
+A a;
+B b;
+
+clang_analyzer_eval((a.*AFP)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval((b.*StaticCastedBase2Derived)() == 2); // expected-warning{{TRUE}}
+clang_analyzer_eval(((b.*CCastedBase2Derived)() == 2)); // expected-warning{{TRUE}}
+  }
+
+  void testPointerToMemberVirtualCall() {
+A a;
+B b;
+A *APtr = &a;
+AFnPointer AFP = &A::foo;
+
+clang_analyzer_eval((APtr->*AFP)() == 1); // expected-warning{{TRUE}}
+
+APtr = &b;
+
+clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberFunction namespace
+
+namespace testPointerToMemberData {
+  struct A {
+int i;
+  };
+
+  void testPointerToMemberData() {
+int A::*AMdPointer = &A::i;
+A a;
+
+a.i = 42;
+a.*AMdPointer += 1;
+
+clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+  }
+} // end of testPointerToMemberData namespace
+
+namespace testPointerToMemberMiscCasts {
+struct B {
+  int f;
+};
+
+struct D : public B {
+  int g;
+};
+
+void foo() {
+  D d;
+  d.f = 7;
+
+  int B::* pfb = &B::f;
+  int D::* pfd = pfb;
+  int v = d.*pfd;
+
+  clang_analyzer_eval(v == 7); // expected-warning{{TRUE}}
+}
+} // end of testPointerToMember namespace
+
+namespace testPointerToMemberMiscCasts2 {
+struct B {
+  int f;
+};
+struct L : public B { };
+struct R : public B { };
+struct D : public L, R { };
+
+void foo() {
+  D d;
+
+  int B::* pb = &B::f;
+  int L::* pl = pb;
+  int R::* pr = pb;
+
+  int D::* pdl = pl;
+  int D::* pdr = pr;
+
+  clang_analyzer_eval(pdl == pdr); // expected-warning{{FALSE}}
+  clang_analyzer_eval(pb == pl); // expected-warning{{TRUE}}
 }
+} // end of testPointerToMemberMiscCasts2 namespace
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -69,6 +69,9 @@
 
   bool isLocType = Loc::isLocType(castTy);
 
+  if (val.getAs())
+return val;
+
   if (Optional LI = val.getAs()) {
 if (isLocType)
   return LI->getLoc();
@@ -335,6 +338,21 @@
 switch (lhs.getSubKind()) {
 default:
   return makeSymExprValNN(state, op, lhs, rhs, resultTy);
+case nonloc::PointerToMemberKind: {
+  assert(rhs.getSubKind() == nonloc::PointerToMemberKind &&
+ "Both SVals should have pointer-to-member-type");
+  auto LPTM = lhs.castAs(),
+   RPTM = rhs.castAs();
+  auto LPTMD = LPTM.getPTMData(), RPT

r286122 - Fix use-of-temporary with StringRef in code coverage

2016-11-07 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Mon Nov  7 11:28:04 2016
New Revision: 286122

URL: http://llvm.org/viewvc/llvm-project?rev=286122&view=rev
Log:
Fix use-of-temporary with StringRef in code coverage

The fixed code is basically identical to the same loop below, which
might indicate an opportunity for refactoring. I just wanted to fix
the use-of-temporary issue.

Caught by adding a similar check to StringRef as r283798 did for
ArrayRef. I'll be upstreaming that soon.

Reviewed by Vedant Kumar as https://reviews.llvm.org/D26317.

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

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=286122&r1=286121&r2=286122&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Nov  7 11:28:04 2016
@@ -1039,10 +1039,15 @@ void CoverageMappingModuleGen::addFuncti
 std::vector Filenames;
 std::vector Expressions;
 std::vector Regions;
+llvm::SmallVector FilenameStrs;
 llvm::SmallVector FilenameRefs;
+FilenameStrs.resize(FileEntries.size());
 FilenameRefs.resize(FileEntries.size());
-for (const auto &Entry : FileEntries)
-  FilenameRefs[Entry.second] = normalizeFilename(Entry.first->getName());
+for (const auto &Entry : FileEntries) {
+  auto I = Entry.second;
+  FilenameStrs[I] = normalizeFilename(Entry.first->getName());
+  FilenameRefs[I] = FilenameStrs[I];
+}
 RawCoverageMappingReader Reader(CoverageMapping, FilenameRefs, Filenames,
 Expressions, Regions);
 if (Reader.read())


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


[PATCH] D26317: Fix use-of-temporary with StringRef in code coverage

2016-11-07 Thread Jordan Rose via cfe-commits
jordan_rose closed this revision.
jordan_rose added a comment.

Committed as r286122.


Repository:
  rL LLVM

https://reviews.llvm.org/D26317



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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Sean Callanan via cfe-commits
spyffe added a comment.

Aleksei, thank you for your review.
I don't quite follow what you'd like me to do with the `Input` files, though.  
Some of them certainly appear to be input files in the same way that all the 
other files in `Inputs` are.  Are you suggesting that I move `macro.modulemap` 
and `macro1.h` somewhere else (say, `Modules/`) or are you making a general 
comment about the layout of all of the tests?


https://reviews.llvm.org/D26054



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


[libcxxabi] r286123 - Add some facilities to work with a git monorepo (experimental setup)

2016-11-07 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Nov  7 11:40:28 2016
New Revision: 286123

URL: http://llvm.org/viewvc/llvm-project?rev=286123&view=rev
Log:
Add some facilities to work with a git monorepo (experimental setup)

Summary:
Some changes are made to cmake, especially the addition of a new
LLVM_ENABLE_PROJECTS option that makes the build system aware of
the monorepo directory structure.

Also a new script is added in llvm/utils/git-svn/. When present in
the $PATH, it enables a `git llvm` command. It is providing at this
point only the ability to push from the git monorepo: `git llvm push`.
It is intended to evolves with more features, for instance I plan on
features like `git llvm show r284955` to help working with sequential
revision numbers.
The push feature is taken from Justin Lebar's script available here:
https://github.com/jlebar/llvm-repo-tools/

Reviewers: jlebar

Subscribers: mgorny, modocache, llvm-commits

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286123&r1=286122&r2=286123&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Nov  7 11:40:28 2016
@@ -144,6 +144,7 @@ find_path(
 ${LIBCXXABI_LIBCXX_PATH}/include
 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
 ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
+${LLVM_MAIN_SRC_DIR}/../libcxx/include
 ${LLVM_INCLUDE_DIR}/c++/v1
   )
 
@@ -156,6 +157,7 @@ find_path(
   PATHS ${LIBCXXABI_LIBCXX_PATH}
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LLVM_MAIN_SRC_DIR}/projects/libcxx/
+${LLVM_MAIN_SRC_DIR}/../libcxx/
   NO_DEFAULT_PATH
   )
 


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


[libcxxabi] r286124 - Revert "Add some facilities to work with a git monorepo (experimental setup)"

2016-11-07 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Nov  7 11:43:08 2016
New Revision: 286124

URL: http://llvm.org/viewvc/llvm-project?rev=286124&view=rev
Log:
Revert "Add some facilities to work with a git monorepo (experimental setup)"

This reverts commit r286123, accidentally commited while testing itself...

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286124&r1=286123&r2=286124&view=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Mon Nov  7 11:43:08 2016
@@ -144,7 +144,6 @@ find_path(
 ${LIBCXXABI_LIBCXX_PATH}/include
 ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBCXX_INCLUDES}
 ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
-${LLVM_MAIN_SRC_DIR}/../libcxx/include
 ${LLVM_INCLUDE_DIR}/c++/v1
   )
 
@@ -157,7 +156,6 @@ find_path(
   PATHS ${LIBCXXABI_LIBCXX_PATH}
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LLVM_MAIN_SRC_DIR}/projects/libcxx/
-${LLVM_MAIN_SRC_DIR}/../libcxx/
   NO_DEFAULT_PATH
   )
 


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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

Hi Sean!
I meant that I'd like to have a layout like this:
macro-loc.m
Inputs/macro-loc/macro.modulemap
Inputs/macro-loc/macro1.h
Inputs/macro-loc/macro1.m
Inputs/macro-loc/macro2.m

By the way, I see that we use another workaround for this issue: we use 
`getDecomposedExpansionLoc()` instead of `getDecomposedLoc()` with removing 
previous line at all. I wonder if we are incorrect in our suggestion.


https://reviews.llvm.org/D26054



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


Re: [PATCH] Warning for main returning a bool.

2016-11-07 Thread Manuel Klimek via cfe-commits
On Sun, Nov 6, 2016 at 1:18 AM Michał Górny via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Fri, 14 Oct 2016 17:17:59 +
> Joshua Hurwitz via cfe-commits  wrote:
>
> > See attached.
> >
> > Returning a bool from main is a special case of return type mismatch. The
> > common convention when returning a bool is that 'true' (== 1) indicates
> > success and 'false' (== 0) failure. But since main expects a return value
> > of 0 on success, returning a bool is usually unintended.
>
> This triggers a false positive if you use a boolean expression like:
>
>   return !foo;
>
> i.e. whenever user intentionally inverts a 'non-zero success' into 'zero
> success'.
>

I would imagine that not everybody's going to switch on that warning, but I
wouldn't consider this a false positive on !foo, mainly because it still
looks unclear whether the author thought about the semantics of the return
value.


>
> --
> Best regards,
> Michał Górny
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel

2016-11-07 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for upstreaming this! (And it was great to meet you at the developer 
conference.)




Comment at: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp:61
+
+const ErrorCategoryStr LockInfo::LockErrCategory("Lock Error");
+const FunctionNameStr LockInfo::SpinLockFuncName("spin_lock");

In the LLVM/clang codebase we try very hard to avoid running constructors for 
globals, as this can have adverse effects on startup time. Typically we try to 
lazily initialize things like these or have them refer to constant data that 
the linker will handle automatically (such as a c string constant).

Can these be a C string constant instead? Or can they be instance members of 
the  SpinLockChecker class? (See the note about `CallDescription` below, which 
may be helpful.)



Comment at: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp:118
+
+  FunctionNameStr CalleeName = Call.getCalleeIdentifier()->getName();
+  if (CalleeName != LockInfo::getSpinLockFuncName() &&

In the analyzer codebase we try to use IdentifierInfo pointers to compare 
identifiers. Since these are interned it lets us perform pointer comparisons 
rather than expensive string comparisons.

There is a `CallDescription` class in `CallEvent.h` that encapsulates this 
logic. You can see an example of how it is used in SimpleStreamChecker.cpp.




Comment at: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp:182
+  Report->markInteresting(SpinLockLocation);
+  C.emitReport(std::move(Report));
+}

For these kinds of diagnostics it is often very helpful to emit a path note 
indicating where the first unlock was.

To do this, you can add a custom bug report visitor that will get called on 
each node in the path to a diagnostic and emit a note, if appropriate. In this 
case you would look for nodes with calls to unlock taking the same region as 
the one you are now reporting for.

There is an example of how to implement a bug report visitor in 
'SuperDeallocBRVisitor'.



Comment at: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp:192
+
+  auto Report = llvm::make_unique(
+  *DoubleLockBugType,

It would be good to emit a path note for the first lock, too.


https://reviews.llvm.org/D26340



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-07 Thread Eric Liu via cfe-commits
ioeric marked an inline comment as done.
ioeric added a comment.

ping.


https://reviews.llvm.org/D25771



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


r286129 - [OPENMP] Fixed codegen for __real/__imag expressions in atomic

2016-11-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Nov  7 12:15:02 2016
New Revision: 286129

URL: http://llvm.org/viewvc/llvm-project?rev=286129&view=rev
Log:
[OPENMP] Fixed codegen for __real/__imag expressions in atomic
constructs.

For __real/__imag unary expressions clang emits lvalue with the
associated type from the original complex expression, but not the
underlying builtin integer or float type. This causes crash in codegen
for atomic constructs, if __real/__imag expression are used in atomic
  constructs.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/OpenMP/atomic_write_codegen.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286129&r1=286128&r2=286129&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 12:15:02 2016
@@ -2276,13 +2276,15 @@ LValue CodeGenFunction::EmitUnaryOpLValu
   return LV;
 }
 
-assert(E->getSubExpr()->getType()->isAnyComplexType());
+QualType T = ExprTy->castAs()->getElementType();
 
 Address Component =
   (E->getOpcode() == UO_Real
  ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
  : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
-return MakeAddrLValue(Component, ExprTy, LV.getAlignmentSource());
+LValue ElemLV = MakeAddrLValue(Component, T, LV.getAlignmentSource());
+ElemLV.getQuals().addQualifiers(LV.getQuals());
+return ElemLV;
   }
   case UO_PreInc:
   case UO_PreDec: {

Modified: cfe/trunk/test/OpenMP/atomic_write_codegen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_write_codegen.c?rev=286129&r1=286128&r2=286129&view=diff
==
--- cfe/trunk/test/OpenMP/atomic_write_codegen.c (original)
+++ cfe/trunk/test/OpenMP/atomic_write_codegen.c Mon Nov  7 12:15:02 2016
@@ -78,6 +78,9 @@ float2 float2x;
 register int rix __asm__("esp");
 
 int main() {
+// CHECK: store atomic i32 1, i32* getelementptr inbounds ({ i32, i32 }, { 
i32, i32 }* @civ, i32 0, i32 1) monotonic,
+#pragma omp atomic write
+ __imag(civ) = 1;
 // CHECK: load i8, i8*
 // CHECK: store atomic i8
 #pragma omp atomic write


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


[PATCH] D26311: Use AnalyzerOptions::getRegisteredCheckers() instead of clang/StaticAnalyzer/Checkers/Checkers.inc

2016-11-07 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/ClangTidy.cpp:297
+  const auto &RegisteredCheckers =
+  AnalyzerOptions::getRegisteredCheckers(IncludeExperimentalCheckers);
+  bool AnalyzerChecksEnabled = false;

Since the default argument of  this function is `false` already. Can we use 
`AnalyzerOptions::getRegisteredCheckers();` directly?


https://reviews.llvm.org/D26311



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


[PATCH] D26328: [ASTImporter] Added ability to import AtomicType nodes

2016-11-07 Thread Sean Callanan via cfe-commits
spyffe accepted this revision.
spyffe added a comment.
This revision is now accepted and ready to land.

Looks good to me.  Thanks, Kareem!


https://reviews.llvm.org/D26328



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


Re: r286096 - Deduplicate replacements by FileEntry instead of file names.

2016-11-07 Thread Kostya Serebryany via cfe-commits
Hi Eric,

the asan bootstrap bot shows a leak in this newly added tests. Please fix
or revert ASAP.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/136/steps/check-clang%20asan/logs/stdio

Direct leak of 720 byte(s) in 1 object(s) allocated from:
#0 0x6ace50 in operator new(unsigned long)
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
#1 0xc83f64 in
clang::tooling::DeduplicateByFileTest_NonExistingFilePath_Test::TestBody()
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/Tooling/Re


On Sun, Nov 6, 2016 at 10:08 PM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Mon Nov  7 00:08:23 2016
> New Revision: 286096
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286096&view=rev
> Log:
> Deduplicate replacements by FileEntry instead of file names.
>
> Summary:
> The current version does not deduplicate equivalent file paths correctly.
> For example, a relative path and an absolute path are considered
> inequivalent.
> Comparing FileEnry addresses these issues.
>
> Reviewers: djasper
>
> Subscribers: alexshap, klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D26288
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/lib/Tooling/Refactoring.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Tooling/Core/Replacement.h?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Nov  7
> 00:08:23 2016
> @@ -19,6 +19,7 @@
>  #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>  #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>
> +#include "clang/Basic/FileManager.h"
>  #include "clang/Basic/LangOptions.h"
>  #include "clang/Basic/SourceLocation.h"
>  #include "llvm/ADT/StringRef.h"
> @@ -293,9 +294,10 @@ calculateRangesAfterReplacements(const R
>   const std::vector &Ranges);
>
>  /// \brief If there are multiple  pairs with the same
> file
> -/// path after removing dots, we only keep one pair (with path after dots
> being
> -/// removed) and discard the rest.
> +/// entry, we only keep one pair and discard the rest.
> +/// If a file does not exist, its corresponding replacements will be
> ignored.
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces);
>
>  template 
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> Core/Replacement.cpp?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Nov  7 00:08:23 2016
> @@ -20,6 +20,7 @@
>  #include "clang/Basic/SourceManager.h"
>  #include "clang/Lex/Lexer.h"
>  #include "clang/Rewrite/Core/Rewriter.h"
> +#include "llvm/ADT/SmallPtrSet.h"
>  #include "llvm/Support/FileSystem.h"
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/raw_os_ostream.h"
> @@ -566,12 +567,16 @@ llvm::Expected applyAllRepl
>  }
>
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces) {
>std::map Result;
> +  llvm::SmallPtrSet ProcessedFileEntries;
>for (const auto &Entry : FileToReplaces) {
> -llvm::SmallString<256> CleanPath(Entry.first);
> -llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
> -Result[CleanPath.str()] = std::move(Entry.second);
> +const FileEntry *FE = FileMgr.getFile(Entry.first);
> +if (!FE)
> +  llvm::errs() << "File path " << Entry.first << " is invalid.\n";
> +else if (ProcessedFileEntries.insert(FE).second)
> +  Result[Entry.first] = std::move(Entry.second);
>}
>return Result;
>  }
>
> Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> Refactoring.cpp?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
> +++ cfe/trunk/lib/Tooling/Refactoring.cpp Mon Nov  7 00:08:23 2016
> @@ -57,7 +57,8 @@ int RefactoringTool::runAndSave(Frontend
>
>  bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
>bool Result = true;
> -  for (const auto &Entry : groupReplacementsByFile(FileToReplaces))
> +  for (const auto &Entry : groupReplacementsByFile(
> +   Rewrite.getSourceMgr().getFileManager(), FileToReplaces

[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Sean Callanan via cfe-commits
spyffe added a comment.

That seems reasonable, and would go a long way toward cleaning up the `Inputs` 
and making clear exactly which inputs correspond to which test file.
Do you think it would be reasonable to take this diff the way it currently it 
is, and start a new one that pulls all the input fiels into test-specific 
subdirectories?
That way the desired layout of the `Inputs` directory will be clear to future 
developers touching the source base.


https://reviews.llvm.org/D26054



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


[PATCH] D26354: Use -fsanitize-recover instead of -mllvm -msan-keep-going: clang.

2016-11-07 Thread Evgeniy Stepanov via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM

It appears that this code is not testable in clang. There is a compiler-rt test 
in https://reviews.llvm.org/D26355.


https://reviews.llvm.org/D26354



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


Re: r286096 - Deduplicate replacements by FileEntry instead of file names.

2016-11-07 Thread Eric Liu via cfe-commits
Thanks Kostya! I'll look into this now.

On Mon, Nov 7, 2016 at 10:39 AM Kostya Serebryany  wrote:

> Hi Eric,
>
> the asan bootstrap bot shows a leak in this newly added tests. Please fix
> or revert ASAP.
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/136/steps/check-clang%20asan/logs/stdio
>
> Direct leak of 720 byte(s) in 1 object(s) allocated from:
> #0 0x6ace50 in operator new(unsigned long) 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
> #1 0xc83f64 in 
> clang::tooling::DeduplicateByFileTest_NonExistingFilePath_Test::TestBody() 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/Tooling/Re
>
>
> On Sun, Nov 6, 2016 at 10:08 PM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Mon Nov  7 00:08:23 2016
> New Revision: 286096
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286096&view=rev
> Log:
> Deduplicate replacements by FileEntry instead of file names.
>
> Summary:
> The current version does not deduplicate equivalent file paths correctly.
> For example, a relative path and an absolute path are considered
> inequivalent.
> Comparing FileEnry addresses these issues.
>
> Reviewers: djasper
>
> Subscribers: alexshap, klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D26288
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/lib/Tooling/Refactoring.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=286096&r1=286095&r2=286096&view=diff
>
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Nov  7 00:08:23
> 2016
> @@ -19,6 +19,7 @@
>  #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>  #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>
> +#include "clang/Basic/FileManager.h"
>  #include "clang/Basic/LangOptions.h"
>  #include "clang/Basic/SourceLocation.h"
>  #include "llvm/ADT/StringRef.h"
> @@ -293,9 +294,10 @@ calculateRangesAfterReplacements(const R
>   const std::vector &Ranges);
>
>  /// \brief If there are multiple  pairs with the same
> file
> -/// path after removing dots, we only keep one pair (with path after dots
> being
> -/// removed) and discard the rest.
> +/// entry, we only keep one pair and discard the rest.
> +/// If a file does not exist, its corresponding replacements will be
> ignored.
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces);
>
>  template 
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=286096&r1=286095&r2=286096&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Nov  7 00:08:23 2016
> @@ -20,6 +20,7 @@
>  #include "clang/Basic/SourceManager.h"
>  #include "clang/Lex/Lexer.h"
>  #include "clang/Rewrite/Core/Rewriter.h"
> +#include "llvm/ADT/SmallPtrSet.h"
>  #include "llvm/Support/FileSystem.h"
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/raw_os_ostream.h"
> @@ -566,12 +567,16 @@ llvm::Expected applyAllRepl
>  }
>
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces) {
>std::map Result;
> +  llvm::SmallPtrSet ProcessedFileEntries;
>for (const auto &Entry : FileToReplaces) {
> -llvm::SmallString<256> CleanPath(Entry.first);
> -llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
> -Result[CleanPath.str()] = std::move(Entry.second);
> +const FileEntry *FE = FileMgr.getFile(Entry.first);
> +if (!FE)
> +  llvm::errs() << "File path " << Entry.first << " is invalid.\n";
> +else if (ProcessedFileEntries.insert(FE).second)
> +  Result[Entry.first] = std::move(Entry.second);
>}
>return Result;
>  }
>
> Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring.cpp?rev=286096&r1=286095&r2=286096&view=diff
>
> ==
> --- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
> +++ cfe/trunk/lib/Tooling/Refactoring.cpp Mon Nov  7 00:08:23 2016
> @@ -57,7 +57,8 @@ int RefactoringTool::runAndSave(Frontend
>
>  bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
>bool Result = true;
> -  for (const auto &Entry : groupReplacementsByFile(FileToReplace

[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Aleksei Sidorin via cfe-commits
a.sidorin added a comment.

> Do you think it would be reasonable to take this diff the way it currently it 
> is, and start a new one that pulls all the input fiels into test-specific 
> subdirectories?
>  That way the desired layout of the `Inputs` directory will be clear to 
> future developers touching the source base.

I'm totally OK with a new diff. Nice suggestion. Thank you!


https://reviews.llvm.org/D26054



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


r286132 - Fix memory leak caused by r286096.

2016-11-07 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Nov  7 12:40:41 2016
New Revision: 286132

URL: http://llvm.org/viewvc/llvm-project?rev=286132&view=rev
Log:
Fix memory leak caused by r286096.

Modified:
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=286132&r1=286131&r2=286132&view=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Mon Nov  7 12:40:41 2016
@@ -977,7 +977,7 @@ TEST(DeduplicateByFileTest, PathsWithDot
   std::map FileToReplaces;
   llvm::IntrusiveRefCntPtr VFS(
   new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "a/b/.././c.h";
   StringRef Path2 = "a/c.h";
@@ -989,7 +989,7 @@ TEST(DeduplicateByFileTest, PathsWithDot
   EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
   EXPECT_EQ(Path1, FileToReplaces.begin()->first);
 }
@@ -998,7 +998,7 @@ TEST(DeduplicateByFileTest, PathWithDotS
   std::map FileToReplaces;
   llvm::IntrusiveRefCntPtr VFS(
   new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "./a/b/c.h";
   StringRef Path2 = "a/b/c.h";
@@ -1010,7 +1010,7 @@ TEST(DeduplicateByFileTest, PathWithDotS
   EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
   EXPECT_EQ(Path1, FileToReplaces.begin()->first);
 }
@@ -1019,7 +1019,7 @@ TEST(DeduplicateByFileTest, NonExistingF
   std::map FileToReplaces;
   llvm::IntrusiveRefCntPtr VFS(
   new vfs::InMemoryFileSystem());
-  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
+  FileManager FileMgr(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
   StringRef Path1 = "./a/b/c.h";
   StringRef Path2 = "a/b/c.h";
@@ -1029,7 +1029,7 @@ TEST(DeduplicateByFileTest, NonExistingF
 #endif
   FileToReplaces[Path1] = Replacements();
   FileToReplaces[Path2] = Replacements();
-  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(FileMgr, FileToReplaces);
   EXPECT_TRUE(FileToReplaces.empty());
 }
 


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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-07 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D26157#586867, @pekka.jaaskelainen wrote:

> Indeed, it requires wider scale discussion to get it right, and e.g. to pass 
> the info to AA. But to be honest, I think OpenCL and CUDA are still 
> considered 'minority' languages in Clang/LLVM which makes me usually lean 
> towards least intrusive implementation solutions whenever possible.
>
> The matter was discussed 5 years ago: 
> http://clang-developers.42468.n3.nabble.com/OpenCL-Address-Spaces-and-Runtimes-td2814865.html
>
> The current situation of having the target AS in the MD is clearly not the 
> way to go due to the loss of info for flat AS machines, so I think this 
> discussion should be mostly about what should those designated IDs be.
>
> Sure, we could use strings such as "opencl.global" there instead, but I'm not 
> sure how much that adds value to simply having known integer IDs instead. 
> SPIR 1.2-2.0 is based on LLVM and designed to store info of OpenCL C kernels, 
> therefore I thought the SPIR IDs are logical as we can just refer to SPIR 
> specs in this case. Other alternative might be to retain the Clang's logical 
> IDs, but I recall there was some special semantics/handling for AS IDs > 255. 
> I might be wrong though.


Actually the solution from Ettore looks like a good compromise to me to what 
we've discussed so far being more generic than hard-coded numbers but less 
heavy than putting strings for each kernel.

However, I also see that the issue is in absence of common agreement and 
understanding of the compiler flow which perhaps is also due to absence of any 
documentation (I am hoping to improve). I still think that this particular 
problem originates from the fact that compiler removes relevant source 
information too early. It seems to me that the compiler has to keep the AS 
information as late as possible until it's no longer being used anywhere in the 
toolchain. In this case if this is being queried by RT, it expects that this 
information is relevant for some reason (i.e. for example to optimize for a 
particular target architecture). So if there are no memory segments, nothing 
can be done to optimize for this and therefore providing the "fake" segment 
information doesn't seem to be useful? I am just trying to understand the use 
case.

I am not too picky on the exact implementation details here. Perhaps well 
documented hard coded numbers should work too. I am just trying to see the use 
case for this and whether the current compilation flow is suboptimal to support 
it properly. But perhaps also the issue is that those MDs are OpenCL specific 
anyways, but the IR itself is supposed to be source language agnostic.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


Re: r286096 - Deduplicate replacements by FileEntry instead of file names.

2016-11-07 Thread Eric Liu via cfe-commits
r286132 should fix this.

On Mon, Nov 7, 2016 at 10:40 AM Eric Liu  wrote:

Thanks Kostya! I'll look into this now.

On Mon, Nov 7, 2016 at 10:39 AM Kostya Serebryany  wrote:

Hi Eric,

the asan bootstrap bot shows a leak in this newly added tests. Please fix
or revert ASAP.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/136/steps/check-clang%20asan/logs/stdio

Direct leak of 720 byte(s) in 1 object(s) allocated from:
#0 0x6ace50 in operator new(unsigned long)
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
#1 0xc83f64 in
clang::tooling::DeduplicateByFileTest_NonExistingFilePath_Test::TestBody()
/mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/Tooling/Re


On Sun, Nov 6, 2016 at 10:08 PM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

Author: ioeric
Date: Mon Nov  7 00:08:23 2016
New Revision: 286096

URL: http://llvm.org/viewvc/llvm-project?rev=286096&view=rev
Log:
Deduplicate replacements by FileEntry instead of file names.

Summary:
The current version does not deduplicate equivalent file paths correctly.
For example, a relative path and an absolute path are considered
inequivalent.
Comparing FileEnry addresses these issues.

Reviewers: djasper

Subscribers: alexshap, klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/lib/Tooling/Refactoring.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=286096&r1=286095&r2=286096&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Nov  7 00:08:23
2016
@@ -19,6 +19,7 @@
 #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
 #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H

+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringRef.h"
@@ -293,9 +294,10 @@ calculateRangesAfterReplacements(const R
  const std::vector &Ranges);

 /// \brief If there are multiple  pairs with the same
file
-/// path after removing dots, we only keep one pair (with path after dots
being
-/// removed) and discard the rest.
+/// entry, we only keep one pair and discard the rest.
+/// If a file does not exist, its corresponding replacements will be
ignored.
 std::map groupReplacementsByFile(
+FileManager &FileMgr,
 const std::map &FileToReplaces);

 template 

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=286096&r1=286095&r2=286096&view=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Nov  7 00:08:23 2016
@@ -20,6 +20,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -566,12 +567,16 @@ llvm::Expected applyAllRepl
 }

 std::map groupReplacementsByFile(
+FileManager &FileMgr,
 const std::map &FileToReplaces) {
   std::map Result;
+  llvm::SmallPtrSet ProcessedFileEntries;
   for (const auto &Entry : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first);
-llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
-Result[CleanPath.str()] = std::move(Entry.second);
+const FileEntry *FE = FileMgr.getFile(Entry.first);
+if (!FE)
+  llvm::errs() << "File path " << Entry.first << " is invalid.\n";
+else if (ProcessedFileEntries.insert(FE).second)
+  Result[Entry.first] = std::move(Entry.second);
   }
   return Result;
 }

Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring.cpp?rev=286096&r1=286095&r2=286096&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring.cpp Mon Nov  7 00:08:23 2016
@@ -57,7 +57,8 @@ int RefactoringTool::runAndSave(Frontend

 bool RefactoringTool::applyAllReplacements(Rewriter &Rewrite) {
   bool Result = true;
-  for (const auto &Entry : groupReplacementsByFile(FileToReplaces))
+  for (const auto &Entry : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces))
 Result = tooling::applyAll

Re: r286096 - Deduplicate replacements by FileEntry instead of file names.

2016-11-07 Thread Kostya Serebryany via cfe-commits
Thanks!

On Mon, Nov 7, 2016 at 10:53 AM, Eric Liu  wrote:

> r286132 should fix this.
>
> On Mon, Nov 7, 2016 at 10:40 AM Eric Liu  wrote:
>
> Thanks Kostya! I'll look into this now.
>
> On Mon, Nov 7, 2016 at 10:39 AM Kostya Serebryany  wrote:
>
> Hi Eric,
>
> the asan bootstrap bot shows a leak in this newly added tests. Please fix
> or revert ASAP.
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-bootstrap/builds/136/steps/check-clang%20asan/logs/stdio
>
> Direct leak of 720 byte(s) in 1 object(s) allocated from:
> #0 0x6ace50 in operator new(unsigned long) 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:82
> #1 0xc83f64 in 
> clang::tooling::DeduplicateByFileTest_NonExistingFilePath_Test::TestBody() 
> /mnt/b/sanitizer-buildbot2/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/unittests/Tooling/Re
>
>
> On Sun, Nov 6, 2016 at 10:08 PM, Eric Liu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Mon Nov  7 00:08:23 2016
> New Revision: 286096
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286096&view=rev
> Log:
> Deduplicate replacements by FileEntry instead of file names.
>
> Summary:
> The current version does not deduplicate equivalent file paths correctly.
> For example, a relative path and an absolute path are considered
> inequivalent.
> Comparing FileEnry addresses these issues.
>
> Reviewers: djasper
>
> Subscribers: alexshap, klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D26288
>
> Modified:
> cfe/trunk/include/clang/Tooling/Core/Replacement.h
> cfe/trunk/lib/Tooling/Core/Replacement.cpp
> cfe/trunk/lib/Tooling/Refactoring.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>
> Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Tooling/Core/Replacement.h?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
> +++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Mon Nov  7
> 00:08:23 2016
> @@ -19,6 +19,7 @@
>  #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>  #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
>
> +#include "clang/Basic/FileManager.h"
>  #include "clang/Basic/LangOptions.h"
>  #include "clang/Basic/SourceLocation.h"
>  #include "llvm/ADT/StringRef.h"
> @@ -293,9 +294,10 @@ calculateRangesAfterReplacements(const R
>   const std::vector &Ranges);
>
>  /// \brief If there are multiple  pairs with the same
> file
> -/// path after removing dots, we only keep one pair (with path after dots
> being
> -/// removed) and discard the rest.
> +/// entry, we only keep one pair and discard the rest.
> +/// If a file does not exist, its corresponding replacements will be
> ignored.
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces);
>
>  template 
>
> Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> Core/Replacement.cpp?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
> +++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Mon Nov  7 00:08:23 2016
> @@ -20,6 +20,7 @@
>  #include "clang/Basic/SourceManager.h"
>  #include "clang/Lex/Lexer.h"
>  #include "clang/Rewrite/Core/Rewriter.h"
> +#include "llvm/ADT/SmallPtrSet.h"
>  #include "llvm/Support/FileSystem.h"
>  #include "llvm/Support/Path.h"
>  #include "llvm/Support/raw_os_ostream.h"
> @@ -566,12 +567,16 @@ llvm::Expected applyAllRepl
>  }
>
>  std::map groupReplacementsByFile(
> +FileManager &FileMgr,
>  const std::map &FileToReplaces) {
>std::map Result;
> +  llvm::SmallPtrSet ProcessedFileEntries;
>for (const auto &Entry : FileToReplaces) {
> -llvm::SmallString<256> CleanPath(Entry.first);
> -llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
> -Result[CleanPath.str()] = std::move(Entry.second);
> +const FileEntry *FE = FileMgr.getFile(Entry.first);
> +if (!FE)
> +  llvm::errs() << "File path " << Entry.first << " is invalid.\n";
> +else if (ProcessedFileEntries.insert(FE).second)
> +  Result[Entry.first] = std::move(Entry.second);
>}
>return Result;
>  }
>
> Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
> Refactoring.cpp?rev=286096&r1=286095&r2=286096&view=diff
> 
> ==
> --- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
> +++ cfe/trunk/lib/Tooling/Refactoring.cpp Mon Nov  7 00:08:23 2016
> @@ -57,7 +57,8 @@ int RefactoringTool::runAndSave(Frontend
>
>  b

[PATCH] D26302: [OpenCL] Remove redundant test for OpenCL header file

2016-11-07 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Cool! Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D26302



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


[PATCH] D26335: [ms] Reinstate https://reviews.llvm.org/D14748 after https://reviews.llvm.org/D20291

2016-11-07 Thread Hans Wennborg via cfe-commits
hans added inline comments.



Comment at: lib/Headers/x86intrin.h:49
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__tzcnt_u32(unsigned int __X) { return __X ? __builtin_ctz(__X) : 32; }
+#ifdef __x86_64__

I'm worried about the conditional here. IIRC, ffmpeg uses TZCNT just as a 
faster encoding for BSF, but now we're putting a conditional in the way, so 
this will be slower actually. On the other hand, the alternative is weird too 
:-/


https://reviews.llvm.org/D26335



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


[PATCH] D26328: [ASTImporter] Added ability to import AtomicType nodes

2016-11-07 Thread Kareem Khazem via cfe-commits
khazem added a comment.

Thank you Sean! I've asked Petr Hosek to commit this change.


https://reviews.llvm.org/D26328



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


[PATCH] D26335: [ms] Reinstate https://reviews.llvm.org/D14748 after https://reviews.llvm.org/D20291

2016-11-07 Thread Paul Robinson via cfe-commits
probinson added inline comments.



Comment at: lib/Headers/x86intrin.h:49
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__tzcnt_u32(unsigned int __X) { return __X ? __builtin_ctz(__X) : 32; }
+#ifdef __x86_64__

hans wrote:
> I'm worried about the conditional here. IIRC, ffmpeg uses TZCNT just as a 
> faster encoding for BSF, but now we're putting a conditional in the way, so 
> this will be slower actually. On the other hand, the alternative is weird too 
> :-/
I thought there was a peephole to notice a guard like this and do the right 
thing? In which case having the guard is fine.


https://reviews.llvm.org/D26335



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


[PATCH] D26354: Use -fsanitize-recover instead of -mllvm -msan-keep-going: clang.

2016-11-07 Thread Aleksey Shlyapnikov via cfe-commits
alekseyshl created this revision.
alekseyshl added a reviewer: eugenis.
alekseyshl added a subscriber: cfe-commits.

Use -fsanitize-recover instead of -mllvm -msan-keep-going: pass 
-fsanitize-recover value to msan.


https://reviews.llvm.org/D26354

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -200,7 +200,9 @@
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
-  PM.add(createMemorySanitizerPass(CGOpts.SanitizeMemoryTrackOrigins));
+  int TrackOrigins = CGOpts.SanitizeMemoryTrackOrigins;
+  bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Memory);
+  PM.add(createMemorySanitizerPass(TrackOrigins, Recover));
 
   // MemorySanitizer inserts complex instrumentation that mostly follows
   // the logic of the original code, but operates on "shadow" values.


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -200,7 +200,9 @@
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
-  PM.add(createMemorySanitizerPass(CGOpts.SanitizeMemoryTrackOrigins));
+  int TrackOrigins = CGOpts.SanitizeMemoryTrackOrigins;
+  bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Memory);
+  PM.add(createMemorySanitizerPass(TrackOrigins, Recover));
 
   // MemorySanitizer inserts complex instrumentation that mostly follows
   // the logic of the original code, but operates on "shadow" values.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26301: [clang-tidy] Fix a regression issue introduced by r285239.

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

Thank you for tracking and fixing this! One nit inline.




Comment at: clang-tidy/modernize/UseNullptrCheck.cpp:194
+// Catch the castExpr inside cxxDefaultArgExpr.
+if (CXXDefaultArgExpr *E = dyn_cast(S))
+  C = dyn_cast(E->getExpr());

Use `auto *`.


https://reviews.llvm.org/D26301



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


[PATCH] D25074: [clang-tidy] Improve rename_check.py

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

One nit. Otherwise looks good. Thank you!




Comment at: clang-tidy/rename_check.py:89
 
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', 
'_')
-  header_guard_new = module.upper() + '_' + 
check_name_new.upper().replace('-', '_')
+  header_guard_old = args.module.upper() + '_' + \
+  args.old_check_name.upper().replace('-', '_')

Does PEP8 have any preferences with regard to using a terminating backslash 
over enclosing an expression that needs to be wrapped in parentheses? If no, 
I'd better use parentheses.


https://reviews.llvm.org/D25074



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


[PATCH] D26236: [clang-move] Move all codes from old.h/cc if old.h only contains one moved declaration.

2016-11-07 Thread Eric Liu via cfe-commits
ioeric added a comment.

First round of comments.

The patch summary says "one moved declaration."  Why it is just one moved 
declaration? Doesn't this also support moving all classes in one file?

Maybe also mention the new behavior in the class comment.




Comment at: clang-move/ClangMove.h:72
   /// \param FileName The name of file where the IncludeHeader comes from.
+  /// \param IncludeRange The source range for the old.h of #include in old.cc.
   /// \param SM The SourceManager.

It took me a while to understand this comment...

IIUC, this is the source range of the #include directive of old.h (i.e. 
#include "old.h") in old.cc?



Comment at: clang-move/ClangMove.h:109
+  // The source range for the old.h of #include in old.cc, including the
+  // enclosing quotes or angle brackets.
+  clang::CharSourceRange OldHeaderIncludeRange;

What about trailing comments or whitespaces?



Comment at: test/clang-move/Inputs/test.h:3
+#define TEST_H
 namespace a {
 class Foo {

Maybe add some white spaces or something in the file to demonstrate that the 
file is copied over.



Comment at: unittests/clang-move/ClangMoveTests.cpp:267
 
+TEST(ClangMove, MoveAll) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;

Can you add tests for move all (multiple) classes in file?

Not related to this patch...but it seems that we are missing test case for 
moving template class? 



Comment at: unittests/clang-move/ClangMoveTests.cpp:278
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A")};
+  Spec.OldHeader = "foo.h";

Maybe just insert or push back?



Comment at: unittests/clang-move/ClangMoveTests.cpp:280
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";

Where is foo.cc?



Comment at: unittests/clang-move/ClangMoveTests.cpp:299
+"using Int=int;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nusing namespace a;\nclass A {\npublic:\n  int f();\n};",
+"class B {};\nclass A {\npublic:\n  int f();\n};",

I think using namespace decl should also be ignored?


https://reviews.llvm.org/D26236



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-07 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:566
+  break;
+if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) 
{
+  for (const auto *UsingShadow : Using->shadows()) {

ioeric wrote:
> ioeric wrote:
> > ioeric wrote:
> > > hokein wrote:
> > > > Yeah, it works for most cases, but it can not guarantee that they are 
> > > > still in the same DeclContext after changing to new namespace.
> > > > 
> > > > For example, the following case where an using-decl is used in the 
> > > > namespace being renamed, we change `b::c` to `d::e`, although 
> > > > DeclContext `d` of callexpr `f()` is a nested DeclContext of `b` (also 
> > > > DeclContext of `using a::f`), but this assumption is wrong after 
> > > > changing namespace because we keep `using a::f` in its original 
> > > > namespace.
> > > > 
> > > > ```
> > > > namespace a { void f(); }
> > > > 
> > > > namespace b {
> > > > using a::f;
> > > > namespace c {
> > > > void d() { f(); }
> > > > }  // c
> > > > } // b
> > > > ```
> > > > 
> > > > Not sure whether we should do this in our tool. I suspect there might 
> > > > be a lot of corner cases.
> > > > 
> > > I thought using decls in old namespaces should be moved with along with 
> > > namespaces. If this is the case, the moving of using decls is unexpected 
> > > (looking into this), but this patch is handling this correctly if using 
> > > decls are not moved.
> > Ahh, I was wrong. `using a::f` should not be moved. Hmm, I think we can 
> > solve or at least workaround this. But I still think we should support 
> > shortening namespace specifier based on using decls; it is quite not nice 
> > to add long specifiers if there are already using decls present.
> This should be fixed with the new matcher.
OK, let's try to make it work perfectly.



Comment at: change-namespace/ChangeNamespace.cpp:270
+  auto Pos = StringRef(FullOldNs).rfind(':');
+  // Ignore leading "::".
+  if (Pos != StringRef::npos && Pos > 1)

leading? looks like you are removing trailing  `;`



Comment at: change-namespace/ChangeNamespace.cpp:277
+  auto IsVisibleInOldNs =
+  anyOf(IsInMovedNs, unless(hasAncestor(namespaceDecl(hasName(Prefix);
+  // Match using declarations.

Ignoring using-decls in `Prefix` namespace-decl doesn't work perfectly. The 
same example:

```
namespace a { void f(); }

namespace b {
using a::f;
namespace c {
void d() { f(); }
} 
}
```

When changing `b::c` to `b::e`, the `using a::f;` will be excluded by this 
filter. As a result, `a::` will be added to `f()`.


https://reviews.llvm.org/D25771



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


Re: r286129 - [OPENMP] Fixed codegen for __real/__imag expressions in atomic

2016-11-07 Thread Dimitry Andric via cfe-commits
Hi Alexey,

Does this look like a good candidate for 3.9.1?

-Dimitry

> On 07 Nov 2016, at 19:15, Alexey Bataev via cfe-commits 
>  wrote:
> 
> Author: abataev
> Date: Mon Nov  7 12:15:02 2016
> New Revision: 286129
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=286129&view=rev
> Log:
> [OPENMP] Fixed codegen for __real/__imag expressions in atomic
> constructs.
> 
> For __real/__imag unary expressions clang emits lvalue with the
> associated type from the original complex expression, but not the
> underlying builtin integer or float type. This causes crash in codegen
> for atomic constructs, if __real/__imag expression are used in atomic
>  constructs.
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGExpr.cpp
>cfe/trunk/test/OpenMP/atomic_write_codegen.c
> 
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286129&r1=286128&r2=286129&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 12:15:02 2016
> @@ -2276,13 +2276,15 @@ LValue CodeGenFunction::EmitUnaryOpLValu
>   return LV;
> }
> 
> -assert(E->getSubExpr()->getType()->isAnyComplexType());
> +QualType T = ExprTy->castAs()->getElementType();
> 
> Address Component =
>   (E->getOpcode() == UO_Real
>  ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
>  : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
> -return MakeAddrLValue(Component, ExprTy, LV.getAlignmentSource());
> +LValue ElemLV = MakeAddrLValue(Component, T, LV.getAlignmentSource());
> +ElemLV.getQuals().addQualifiers(LV.getQuals());
> +return ElemLV;
>   }
>   case UO_PreInc:
>   case UO_PreDec: {
> 
> Modified: cfe/trunk/test/OpenMP/atomic_write_codegen.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_write_codegen.c?rev=286129&r1=286128&r2=286129&view=diff
> ==
> --- cfe/trunk/test/OpenMP/atomic_write_codegen.c (original)
> +++ cfe/trunk/test/OpenMP/atomic_write_codegen.c Mon Nov  7 12:15:02 2016
> @@ -78,6 +78,9 @@ float2 float2x;
> register int rix __asm__("esp");
> 
> int main() {
> +// CHECK: store atomic i32 1, i32* getelementptr inbounds ({ i32, i32 }, { 
> i32, i32 }* @civ, i32 0, i32 1) monotonic,
> +#pragma omp atomic write
> + __imag(civ) = 1;
> // CHECK: load i8, i8*
> // CHECK: store atomic i8
> #pragma omp atomic write
> 
> 
> ___
> 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] D26137: [clang-tidy] Add check name to YAML export

2016-11-07 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Thank you for resurrecting this patch! A few comments inline.




Comment at: include/clang/Tooling/Core/Diagnostic.h:35
+  DiagnosticMessage(llvm::StringRef Message, const SourceManager &Sources,
+SourceLocation Loc);
+  std::string Message;

What are the constraints on the location? Should it be a file location or macro 
locations are fine too? Please add a (doxygen-style) comment.



Comment at: include/clang/Tooling/Core/Diagnostic.h:57
+
+  std::string CheckName;
+  DiagnosticMessage Message;

`CheckName` is somewhat clang-tidy specific. We need something more generic 
here, e.g. `DiagnosticName`, `Category` or somesuch.

Please add a (doxygen-style) comment to this and other fields here.



Comment at: include/clang/Tooling/Core/Diagnostic.h:68-71
+  /// A freeform chunk of text to describe the context of the replacements.
+  /// Will be printed, for example, when detecting conflicts during replacement
+  /// deduplication.
+  std::string Context;

That's too vague. Are you intending to use it only for reporting problems with 
replacement deduplication? Should it be in this structure at all?



Comment at: include/clang/Tooling/DiagnosticsYaml.h:82
+ }
+ }
+  Io.mapRequired("Diagnostics", Diagnostics);

nit: Formatting is off.



Comment at: tools/extra/clang-tidy/ClangTidy.cpp:578
 raw_ostream &OS) {
-  TranslationUnitReplacements TUR;
-  for (const ClangTidyError &Error : Errors) {
-for (const auto &FileAndFixes : Error.Fix)
-  TUR.Replacements.insert(TUR.Replacements.end(),
-  FileAndFixes.second.begin(),
-  FileAndFixes.second.end());
-  }
-
+  TranslationUnitDiagnostics TUD;
+  TUD.Diagnostics.insert(TUD.Diagnostics.end(), Errors.begin(), Errors.end());

This function neither fills `TUD.MainSourceFile` nor `TUD.Context` (which I'm 
not sure even belongs to this structure).



Comment at: tools/extra/clang-tidy/ClangTidy.cpp:579
+  TranslationUnitDiagnostics TUD;
+  TUD.Diagnostics.insert(TUD.Diagnostics.end(), Errors.begin(), Errors.end());
   yaml::Output YAML(OS);

I somewhat dislike the implicit object slicing that happens here. I'd prefer to 
make this a loop with explicit conversion.



Comment at: tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:116
+   bool IsWarningAsError, StringRef BuildDirectory)
+: clang::tooling::Diagnostic(CheckName, DiagLevel),
+  BuildDirectory(BuildDirectory), IsWarningAsError(IsWarningAsError) {}

No need for `clang::` here.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


Re: r286129 - [OPENMP] Fixed codegen for __real/__imag expressions in atomic

2016-11-07 Thread Alexey Bataev via cfe-commits
Hi Dimitry,
I think so

Best regards,
Alexey Bataev

> 7 нояб. 2016 г., в 22:36, Dimitry Andric  написал(а):
> 
> Hi Alexey,
> 
> Does this look like a good candidate for 3.9.1?
> 
> -Dimitry
> 
>> On 07 Nov 2016, at 19:15, Alexey Bataev via cfe-commits 
>>  wrote:
>> 
>> Author: abataev
>> Date: Mon Nov  7 12:15:02 2016
>> New Revision: 286129
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=286129&view=rev
>> Log:
>> [OPENMP] Fixed codegen for __real/__imag expressions in atomic
>> constructs.
>> 
>> For __real/__imag unary expressions clang emits lvalue with the
>> associated type from the original complex expression, but not the
>> underlying builtin integer or float type. This causes crash in codegen
>> for atomic constructs, if __real/__imag expression are used in atomic
>> constructs.
>> 
>> Modified:
>>   cfe/trunk/lib/CodeGen/CGExpr.cpp
>>   cfe/trunk/test/OpenMP/atomic_write_codegen.c
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=286129&r1=286128&r2=286129&view=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Nov  7 12:15:02 2016
>> @@ -2276,13 +2276,15 @@ LValue CodeGenFunction::EmitUnaryOpLValu
>>  return LV;
>>}
>> 
>> -assert(E->getSubExpr()->getType()->isAnyComplexType());
>> +QualType T = ExprTy->castAs()->getElementType();
>> 
>>Address Component =
>>  (E->getOpcode() == UO_Real
>> ? emitAddrOfRealComponent(LV.getAddress(), LV.getType())
>> : emitAddrOfImagComponent(LV.getAddress(), LV.getType()));
>> -return MakeAddrLValue(Component, ExprTy, LV.getAlignmentSource());
>> +LValue ElemLV = MakeAddrLValue(Component, T, LV.getAlignmentSource());
>> +ElemLV.getQuals().addQualifiers(LV.getQuals());
>> +return ElemLV;
>>  }
>>  case UO_PreInc:
>>  case UO_PreDec: {
>> 
>> Modified: cfe/trunk/test/OpenMP/atomic_write_codegen.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/atomic_write_codegen.c?rev=286129&r1=286128&r2=286129&view=diff
>> ==
>> --- cfe/trunk/test/OpenMP/atomic_write_codegen.c (original)
>> +++ cfe/trunk/test/OpenMP/atomic_write_codegen.c Mon Nov  7 12:15:02 2016
>> @@ -78,6 +78,9 @@ float2 float2x;
>> register int rix __asm__("esp");
>> 
>> int main() {
>> +// CHECK: store atomic i32 1, i32* getelementptr inbounds ({ i32, i32 }, { 
>> i32, i32 }* @civ, i32 0, i32 1) monotonic,
>> +#pragma omp atomic write
>> + __imag(civ) = 1;
>> // CHECK: load i8, i8*
>> // CHECK: store atomic i8
>> #pragma omp atomic write
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2016-11-07 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Hi Jordan,

It seems that this patch doesn't apply cleanly. Can you rebase it?


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


r286144 - When the ASTImporter imports a source location, it avoids importing macro

2016-11-07 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Mon Nov  7 14:42:25 2016
New Revision: 286144

URL: http://llvm.org/viewvc/llvm-project?rev=286144&view=rev
Log:
When the ASTImporter imports a source location, it avoids importing macro
expansions by calling getSpellingLoc(). That's great in most cases, but for
macros defined in the '' source file, the source file is invalid
and does not import correctly, causing an assertion failure (the assertion
is Invalid SLocOffset or bad function choice).

A more reliable way to avoid this is to use getFileLoc(), which does not
return built-in locations. This avoids the crash but still preserves valid
source locations.

I've added a testcase that covers the previously crashing scenario.

https://reviews.llvm.org/D26054

Added:
cfe/trunk/test/ASTMerge/Inputs/macro.modulemap
cfe/trunk/test/ASTMerge/Inputs/macro1.h
cfe/trunk/test/ASTMerge/Inputs/macro1.m
cfe/trunk/test/ASTMerge/Inputs/macro2.m
cfe/trunk/test/ASTMerge/macro.m
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=286144&r1=286143&r2=286144&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Nov  7 14:42:25 2016
@@ -6943,10 +6943,10 @@ SourceLocation ASTImporter::Import(Sourc
 
   SourceManager &FromSM = FromContext.getSourceManager();
   
-  // For now, map everything down to its spelling location, so that we
+  // For now, map everything down to its file location, so that we
   // don't have to import macro expansions.
   // FIXME: Import macro expansions!
-  FromLoc = FromSM.getSpellingLoc(FromLoc);
+  FromLoc = FromSM.getFileLoc(FromLoc);
   std::pair Decomposed = FromSM.getDecomposedLoc(FromLoc);
   SourceManager &ToSM = ToContext.getSourceManager();
   FileID ToFileID = Import(Decomposed.first);

Added: cfe/trunk/test/ASTMerge/Inputs/macro.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/macro.modulemap?rev=286144&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/macro.modulemap (added)
+++ cfe/trunk/test/ASTMerge/Inputs/macro.modulemap Mon Nov  7 14:42:25 2016
@@ -0,0 +1,4 @@
+module macro1 [extern_c] {
+  header "macro1.h"
+  export *
+}

Added: cfe/trunk/test/ASTMerge/Inputs/macro1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/macro1.h?rev=286144&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/macro1.h (added)
+++ cfe/trunk/test/ASTMerge/Inputs/macro1.h Mon Nov  7 14:42:25 2016
@@ -0,0 +1,5 @@
+typedef void *VoidRef;
+
+void maybeNull(
+  int i,
+  __nullable VoidRef *__nullable);

Added: cfe/trunk/test/ASTMerge/Inputs/macro1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/macro1.m?rev=286144&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/macro1.m (added)
+++ cfe/trunk/test/ASTMerge/Inputs/macro1.m Mon Nov  7 14:42:25 2016
@@ -0,0 +1,5 @@
+@import macro1;
+
+void foo() {
+  maybeNull(0, 0);
+}

Added: cfe/trunk/test/ASTMerge/Inputs/macro2.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/macro2.m?rev=286144&view=auto
==
--- cfe/trunk/test/ASTMerge/Inputs/macro2.m (added)
+++ cfe/trunk/test/ASTMerge/Inputs/macro2.m Mon Nov  7 14:42:25 2016
@@ -0,0 +1,5 @@
+void foo();
+
+void bar() {
+  foo();
+}

Added: cfe/trunk/test/ASTMerge/macro.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/macro.m?rev=286144&view=auto
==
--- cfe/trunk/test/ASTMerge/macro.m (added)
+++ cfe/trunk/test/ASTMerge/macro.m Mon Nov  7 14:42:25 2016
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/cache
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.1.ast 
%S/Inputs/macro1.m
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache 
-fmodule-map-file=%S/Inputs/macro.modulemap -I%S/Inputs -emit-pch -o %t.2.ast 
%S/Inputs/macro2.m
+// RUN: %clang_cc1 -fmodules -ast-merge %t.1.ast -ast-merge %t.2.ast 
-fsyntax-only -verify %s
+// expected-no-diagnostics


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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Sean Callanan via cfe-commits
spyffe closed this revision.
spyffe added a comment.

  $ svn commit lib test
  Sendinglib/AST/ASTImporter.cpp
  Adding test/ASTMerge/Inputs/macro.modulemap
  Adding test/ASTMerge/Inputs/macro1.h
  Adding test/ASTMerge/Inputs/macro1.m
  Adding test/ASTMerge/Inputs/macro2.m
  Adding test/ASTMerge/macro.m
  Transmitting file data ..done
  Committing transaction...
  Committed revision 286144.


https://reviews.llvm.org/D26054



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


[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

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

I'd like to preserve the old behavior under -Wshadow-all. The last time I came 
here to try to quiet a shadowing warning on constructor parameters, we went to 
great lengths to try to satisfy users who really want to warn on any and all 
kinds of shadowing. I think you can do it by adding a new diagnostic with the 
same text in a new group, and using the new diagnostic id if appropriate 
instead of returning like you do now.


Repository:
  rL LLVM

https://reviews.llvm.org/D26278



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


[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS

2016-11-07 Thread Shoaib Meenai via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D26150#587973, @ikudrin wrote:

> This test is extremely fragile. Maybe, it is better to disable it, or even 
> delete it altogether.


I'll take your word for it, as the original author of the test, though I'm 
curious about where the fragility is coming in from :)

Are you planning to disable/delete, or should I?


https://reviews.llvm.org/D26150



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


r286148 - Use -fsanitize-recover instead of -mllvm -msan-keep-going: clang.

2016-11-07 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Mon Nov  7 15:02:11 2016
New Revision: 286148

URL: http://llvm.org/viewvc/llvm-project?rev=286148&view=rev
Log:
Use -fsanitize-recover instead of -mllvm -msan-keep-going: clang.

Summary: Use -fsanitize-recover instead of -mllvm -msan-keep-going: pass 
-fsanitize-recover value to msan.

Reviewers: eugenis

Subscribers: cfe-commits

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

Patch by Aleksey Shlyapnikov.

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=286148&r1=286147&r2=286148&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Nov  7 15:02:11 2016
@@ -200,7 +200,9 @@ static void addMemorySanitizerPass(const
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
-  PM.add(createMemorySanitizerPass(CGOpts.SanitizeMemoryTrackOrigins));
+  int TrackOrigins = CGOpts.SanitizeMemoryTrackOrigins;
+  bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Memory);
+  PM.add(createMemorySanitizerPass(TrackOrigins, Recover));
 
   // MemorySanitizer inserts complex instrumentation that mostly follows
   // the logic of the original code, but operates on "shadow" values.


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


Re: [PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-11-07 Thread Aaron Ballman via cfe-commits
On Mon, Nov 7, 2016 at 11:44 AM, Alex Lorenz  wrote:
> arphaman added a comment.
>
> I looked at the way `HasFallthroughStmt` is used, and it didn't seem so, no. 
> It's used in the following manner in AnalysisBasedWarnings.cpp:
>
>   bool FallThroughDiagFull =
>   !Diags.isIgnored(diag::warn_unannotated_fallthrough, D->getLocStart());
>   bool FallThroughDiagPerFunction = !Diags.isIgnored(
>   diag::warn_unannotated_fallthrough_per_function, D->getLocStart());
>   if (FallThroughDiagFull || FallThroughDiagPerFunction ||
>   fscope->HasFallthroughStmt) {
> DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull);
>   }
>
> So it seems to me that even if `HasFallthroughStmt` isn't cleared, the 
> analysis won't show up anything different for a function that re-used the 
> scope info, because when diagnostics are ignored and the flag actually leads 
> to incorrect call to `DiagnoseSwitchLabelsFallthrough `, the analysis won't 
> show any warnings since the diagnostics are ignored. And likewise if one of 
> the diagnostics is enabled then it doesn't matter if `HasFallthroughStmt` is 
> true, so we won't be able to observe a difference there.

Thank you for looking into this! Drat on the lack of tests, but your
analysis makes sense to me.

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


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
flx created this revision.
flx added reviewers: alexfh, aaron.ballman, sbenza.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

Move in complete type test which does not compile into its own test file.


Repository:
  rL LLVM

https://reviews.llvm.org/D26369

Files:
  test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,25 +238,11 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);
 // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A);
 void PositiveConstDeclaration(ExpensiveToCopyType A) {
   // CHECK-MESSAGES: [[@LINE-1]]:51: warning: the parameter 'A' is copied
   // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A) {
 }
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);
-void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
-  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
-  // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& 
A) {
-}
Index: test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
+}
+


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,25 +238,11 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);
 // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A);
 void PositiveConstDeclaration(ExpensiveToCopyType A) {
   // CHECK-MESSAGES: [[@LINE-1]]:51: warning: the parameter 'A' is copied
   // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A) {
 }
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);
-void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
-  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
-  // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A) {
-}
Index: test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+
+// Ensure that 

[PATCH] D26195: Ignore incomplete types when determining whether they are expensive to copy

2016-11-07 Thread Felix Berger via cfe-commits
flx added a comment.






Comment at: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp:241
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.

alexfh wrote:
> Please move this test to a separate test file and revert the RUN line here. 
Done in https://reviews.llvm.org/D26369.  


Repository:
  rL LLVM

https://reviews.llvm.org/D26195



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


r286152 - Name some anonymous structs to avoid using a (very common) extension.

2016-11-07 Thread John McCall via cfe-commits
Author: rjmccall
Date: Mon Nov  7 15:13:27 2016
New Revision: 286152

URL: http://llvm.org/viewvc/llvm-project?rev=286152&view=rev
Log:
Name some anonymous structs to avoid using a (very common) extension.

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

Modified: cfe/trunk/lib/CodeGen/CGCall.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.h?rev=286152&r1=286151&r2=286152&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.h (original)
+++ cfe/trunk/lib/CodeGen/CGCall.h Mon Nov  7 15:13:27 2016
@@ -73,16 +73,19 @@ namespace CodeGen {
   Last = PseudoDestructor
 };
 
+struct BuiltinInfoStorage {
+  const FunctionDecl *Decl;
+  unsigned ID;
+};
+struct PseudoDestructorInfoStorage {
+  const CXXPseudoDestructorExpr *Expr;
+};
+
 SpecialKind KindOrFunctionPointer;
 union {
   CGCalleeInfo AbstractInfo;
-  struct {
-const FunctionDecl *Decl;
-unsigned ID;
-  } BuiltinInfo;
-  struct {
-const CXXPseudoDestructorExpr *Expr;
-  } PseudoDestructorInfo;
+  BuiltinInfoStorage BuiltinInfo;
+  PseudoDestructorInfoStorage PseudoDestructorInfo;
 };
 
 explicit CGCallee(SpecialKind kind) : KindOrFunctionPointer(kind) {}


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


Re: r285258 - Refactor call emission to package the function pointer together with

2016-11-07 Thread John McCall via cfe-commits
> On Nov 4, 2016, at 12:36 AM, Yaron Keren  wrote:
> Hi John, 
> 
> clang warns on this:
> 
> /llvm/tools/zapccs/../clang/include/../lib/CodeGen/CGCall.h:79:7: warning: 
> anonymous types declared in an anonymous union are an extension 
> [-Wnested-anon-types]
>   struct {
>   ^
> /llvm/tools/zapccs/../clang/include/../lib/CodeGen/CGCall.h:83:7: warning: 
> anonymous types declared in an anonymous union are an extension 
> [-Wnested-anon-types]
>   struct {
>   ^
> 

Thanks.  Should be fixed in r286152.

John.

> 
> 
> 2016-10-27 2:46 GMT+03:00 John McCall via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>>:
> Author: rjmccall
> Date: Wed Oct 26 18:46:34 2016
> New Revision: 285258
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=285258&view=rev 
> 
> Log:
> Refactor call emission to package the function pointer together with
> abstract information about the callee.  NFC.
> 
> The goal here is to make it easier to recognize indirect calls and
> trigger additional logic in certain cases.  That logic will come in
> a later patch; in the meantime, I felt that this was a significant
> improvement to the code.
> 
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
> cfe/trunk/lib/AST/Expr.cpp
> cfe/trunk/lib/CodeGen/CGAtomic.cpp
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/CodeGen/CGCUDARuntime.cpp
> cfe/trunk/lib/CodeGen/CGCXX.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.h
> cfe/trunk/lib/CodeGen/CGCall.cpp
> cfe/trunk/lib/CodeGen/CGCall.h
> cfe/trunk/lib/CodeGen/CGClass.cpp
> cfe/trunk/lib/CodeGen/CGDecl.cpp
> cfe/trunk/lib/CodeGen/CGException.cpp
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CGExprCXX.cpp
> cfe/trunk/lib/CodeGen/CGExprComplex.cpp
> cfe/trunk/lib/CodeGen/CGObjC.cpp
> cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
> cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> cfe/trunk/lib/CodeGen/CGVTables.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/CodeGen/CodeGenModule.h
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> 
> 

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


[PATCH] D26335: [ms] Reinstate https://reviews.llvm.org/D14748 after https://reviews.llvm.org/D20291

2016-11-07 Thread Hans Wennborg via cfe-commits
hans added inline comments.



Comment at: lib/Headers/x86intrin.h:49
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__tzcnt_u32(unsigned int __X) { return __X ? __builtin_ctz(__X) : 32; }
+#ifdef __x86_64__

probinson wrote:
> hans wrote:
> > I'm worried about the conditional here. IIRC, ffmpeg uses TZCNT just as a 
> > faster encoding for BSF, but now we're putting a conditional in the way, so 
> > this will be slower actually. On the other hand, the alternative is weird 
> > too :-/
> I thought there was a peephole to notice a guard like this and do the right 
> thing? In which case having the guard is fine.
But for non-BMI targets it won't be able to remove the guard (unless it can 
prove the argument is zero).

MSVC will just emit the raw 'tzcnt' instruction here, and that's what ffmpeg 
wants.


https://reviews.llvm.org/D26335



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


r286151 - Updated ASTMerge/macro.m to use _Nullable.

2016-11-07 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Mon Nov  7 15:10:31 2016
New Revision: 286151

URL: http://llvm.org/viewvc/llvm-project?rev=286151&view=rev
Log:
Updated ASTMerge/macro.m to use _Nullable.

Modified:
cfe/trunk/test/ASTMerge/Inputs/macro1.h

Modified: cfe/trunk/test/ASTMerge/Inputs/macro1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/Inputs/macro1.h?rev=286151&r1=286150&r2=286151&view=diff
==
--- cfe/trunk/test/ASTMerge/Inputs/macro1.h (original)
+++ cfe/trunk/test/ASTMerge/Inputs/macro1.h Mon Nov  7 15:10:31 2016
@@ -2,4 +2,4 @@ typedef void *VoidRef;
 
 void maybeNull(
   int i,
-  __nullable VoidRef *__nullable);
+  _Nullable VoidRef *_Nullable);


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


[PATCH] D26054: Use `getFileLoc()` instead of `getSpellingLoc()` in the ASTImporter

2016-11-07 Thread Sean Callanan via cfe-commits
spyffe added a comment.

Fixed the testcase to use _Nullable instead of __nullable, for Linux buildbots

  $ svn commit test
  Sendingtest/ASTMerge/Inputs/macro1.h
  Transmitting file data .done
  Committing transaction...
  Committed revision 286151.


https://reviews.llvm.org/D26054



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


r286154 - [index] Handle properly C++14's template variables.

2016-11-07 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Nov  7 15:20:15 2016
New Revision: 286154

URL: http://llvm.org/viewvc/llvm-project?rev=286154&view=rev
Log:
[index] Handle properly C++14's template variables.

- Infer the right symbol kind.
- Provide a templated USR, similar to how we handle class templates.

rdar://28980398

Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=286154&r1=286153&r2=286154&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Mon Nov  7 15:20:15 2016
@@ -91,6 +91,25 @@ SymbolInfo index::getSymbolInfo(const De
   Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
 }
 
+  } else if (auto *VD = dyn_cast(D)) {
+Info.Kind = SymbolKind::Variable;
+if (isa(D->getDeclContext())) {
+  Info.Kind = SymbolKind::StaticProperty;
+  Info.Lang = SymbolLanguage::CXX;
+}
+if (isa(D)) {
+  Info.Lang = SymbolLanguage::CXX;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+  Info.SubKinds |= (unsigned)SymbolSubKind::TemplatePartialSpecialization;
+} else if (isa(D)) {
+  Info.Lang = SymbolLanguage::CXX;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+  Info.SubKinds |= (unsigned)SymbolSubKind::TemplateSpecialization;
+} else if (VD->getDescribedVarTemplate()) {
+  Info.Lang = SymbolLanguage::CXX;
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+}
+
   } else {
 switch (D->getKind()) {
 case Decl::Import:
@@ -101,16 +120,6 @@ SymbolInfo index::getSymbolInfo(const De
 case Decl::Function:
   Info.Kind = SymbolKind::Function;
   break;
-case Decl::ParmVar:
-  Info.Kind = SymbolKind::Variable;
-  break;
-case Decl::Var:
-  Info.Kind = SymbolKind::Variable;
-  if (isa(D->getDeclContext())) {
-Info.Kind = SymbolKind::StaticProperty;
-Info.Lang = SymbolLanguage::CXX;
-  }
-  break;
 case Decl::Field:
   Info.Kind = SymbolKind::Field;
   if (const CXXRecordDecl *

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=286154&r1=286153&r2=286154&view=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Mon Nov  7 15:20:15 2016
@@ -130,9 +130,10 @@ bool IndexingContext::isTemplateImplicit
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
 TKind = SD->getSpecializationKind();
-  }
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
 TKind = FD->getTemplateSpecializationKind();
+  } else if (auto *VD = dyn_cast(D)) {
+TKind = VD->getTemplateSpecializationKind();
   }
   switch (TKind) {
 case TSK_Undeclared:
@@ -164,9 +165,10 @@ static const Decl *adjustTemplateImplici
   if (const ClassTemplateSpecializationDecl *
   SD = dyn_cast(D)) {
 return SD->getTemplateInstantiationPattern();
-  }
-  if (const FunctionDecl *FD = dyn_cast(D)) {
+  } else if (const FunctionDecl *FD = dyn_cast(D)) {
 return FD->getTemplateInstantiationPattern();
+  } else if (auto *VD = dyn_cast(D)) {
+return VD->getTemplateInstantiationPattern();
   }
   return nullptr;
 }

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=286154&r1=286153&r2=286154&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Nov  7 15:20:15 2016
@@ -286,6 +286,15 @@ void USRGenerator::VisitVarDecl(const Va
 
   VisitDeclContext(D->getDeclContext());
 
+  if (VarTemplateDecl *VarTmpl = D->getDescribedVarTemplate()) {
+Out << "@VT";
+VisitTemplateParameterList(VarTmpl->getTemplateParameters());
+  } else if (const VarTemplatePartialSpecializationDecl *PartialSpec
+ = dyn_cast(D)) {
+Out << "@VP";
+VisitTemplateParameterList(PartialSpec->getTemplateParameters());
+  }
+
   // Variables always have simple names.
   StringRef s = D->getName();
 
@@ -297,6 +306,17 @@ void USRGenerator::VisitVarDecl(const Va
 IgnoreResults = true;
   else
 Out << '@' << s;
+
+  // For a template specialization, mangle the template arguments.
+  if (const VarTemplateSpecializationDecl *Spec
+  = dyn_cast(D)) {
+const TemplateArgumentList &Args = Spec->getTemplateInstantiationArgs();
+Out << '>';
+for (unsigned I = 0, N = Args.size(); I != N;

r286153 - [index] Make sure to mark class template symbols as having 'generic' sub-kind.

2016-11-07 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Nov  7 15:20:08 2016
New Revision: 286153

URL: http://llvm.org/viewvc/llvm-project?rev=286153&view=rev
Log:
[index] Make sure to mark class template symbols as having 'generic' sub-kind.

Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=286153&r1=286152&r2=286153&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Mon Nov  7 15:20:08 2016
@@ -74,9 +74,14 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::Enum; break;
 }
 
-if (const CXXRecordDecl *CXXRec = dyn_cast(D))
-  if (!CXXRec->isCLike())
+if (const CXXRecordDecl *CXXRec = dyn_cast(D)) {
+  if (!CXXRec->isCLike()) {
 Info.Lang = SymbolLanguage::CXX;
+if (CXXRec->getDescribedClassTemplate()) {
+  Info.SubKinds |= (unsigned)SymbolSubKind::Generic;
+}
+  }
+}
 
 if (isa(D)) {
   Info.SubKinds |= (unsigned)SymbolSubKind::Generic;

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=286153&r1=286152&r2=286153&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Mon Nov  7 15:20:08 2016
@@ -2,12 +2,16 @@
 
 template 
 class TemplCls {
-// CHECK: [[@LINE-1]]:7 | class/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Def | rel: 0
+// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Def | rel: 0
+public:
   TemplCls(int x);
   // CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | 
c:@ST>1#T@TemplCls@F@TemplCls#I# |  | Decl,RelChild | rel: 1
   // CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T@TemplCls
 };
 
+TemplCls gtv(0);
+// CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Ref | rel: 0
+
 template 
 class BT {
   struct KLR {


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


[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.

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

Address review comments.


https://reviews.llvm.org/D26236

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -173,24 +173,25 @@
  "} // namespace a\n";
 
 std::map
-runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec,
+   const char *const Header = TestHeader,
+   const char *const CC = TestCC) {
   clang::RewriterTestContext Context;
 
   std::map FileToFileID;
   std::vector> FileToSourceText = {
-  {TestHeaderName, TestHeader}, {TestCCName, TestCC}};
+  {TestHeaderName, Header}, {TestCCName, CC}};
 
   auto CreateFiles = [&FileToSourceText, &Context, &FileToFileID](
   llvm::StringRef Name, llvm::StringRef Code) {
 if (!Name.empty()) {
-  FileToSourceText.emplace_back(Name, Code);
   FileToFileID[Name] = Context.createInMemoryFile(Name, Code);
 }
   };
   CreateFiles(Spec.NewCC, "");
   CreateFiles(Spec.NewHeader, "");
-  CreateFiles(Spec.OldHeader, TestHeader);
-  CreateFiles(Spec.OldCC, TestCC);
+  CreateFiles(Spec.OldHeader, Header);
+  CreateFiles(Spec.OldCC, CC);
 
   std::map FileToReplacements;
   llvm::SmallString<128> InitialDirectory;
@@ -201,7 +202,7 @@
   Spec, FileToReplacements, InitialDirectory.str(), "LLVM");
 
   tooling::runToolOnCodeWithArgs(
-  Factory->create(), TestCC, {"-std=c++11", "-fparse-all-comments"},
+  Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
   TestCCName, "clang-move", std::make_shared(),
   FileToSourceText);
   formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
@@ -263,6 +264,72 @@
   EXPECT_EQ(0u, Results.size());
 }
 
+TEST(ClangMove, MoveAll) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  std::vector TestHeaders = {
+"class A {\npublic:\n  int f();\n};",
+// forward declaration.
+"class B;\nclass A {\npublic:\n  int f();\n};",
+// template forward declaration.
+"template  class B;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nclass A {\npublic:\n  int f();\n};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A")};
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+  }
+}
+
+TEST(ClangMove, MoveAllMultipleClasses) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  std::vector TestHeaders = {
+"class C;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+"class C;\nclass B;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A"), std::string("B")};
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+  }
+}
+
+TEST(ClangMove, DontMoveAll) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n"
+"#define NEW_FOO_H\n"
+"class A {\npublic:\n  int f();\n};\n"
+"#endif // NEW_FOO_H\n";
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  std::vector TestHeaders = {
+"typedef int Int;\nclass A {\npublic:\n  int f();\n};",
+"using Int=int;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nusing namespace a;\nclass A {\npublic:\n  int f();\n};",
+"class B {};\nclass A {\npublic:\n  int f();\n};",
+"void f {};\nclass A {\npublic:\n  int f();\n};",
+"enum Color { RED };\nclass A {\npublic:\n  int f();\n};",
+  };
+  Spec.Names = {std::string("A")};
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(ExpectedHeader, Results[Spec.NewHeader]);
+  }
+}
+
 } // namespace
 } // namespce move
 } // namespace clang
Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move

[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.

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

> The patch summary says "one moved declaration." Why it is just one moved 
> declaration? Doesn't this also support moving all classes in one file?

Oh, the patch summary is not totally correct. It actually does what you mention 
above. Have updated the summary.




Comment at: clang-move/ClangMove.h:72
   /// \param FileName The name of file where the IncludeHeader comes from.
+  /// \param IncludeRange The source range for the old.h of #include in old.cc.
   /// \param SM The SourceManager.

ioeric wrote:
> It took me a while to understand this comment...
> 
> IIUC, this is the source range of the #include directive of old.h (i.e. 
> #include "old.h") in old.cc?
Sorry for the confusion.

Indeed this a range for the written file name of `#include`, i.e. if the 
#include is `#include "old.h"`, then the range here is for `"old.h"`. Have 
updated the comment.



Comment at: clang-move/ClangMove.h:109
+  // The source range for the old.h of #include in old.cc, including the
+  // enclosing quotes or angle brackets.
+  clang::CharSourceRange OldHeaderIncludeRange;

ioeric wrote:
> What about trailing comments or whitespaces?
The trailing comments or whitespaces will be ignored here. We just copy this 
field from `InclusionDirective` interface, and seems there is no explicit way 
to retrieve the comments or whitespaces.



Comment at: unittests/clang-move/ClangMoveTests.cpp:267
 
+TEST(ClangMove, MoveAll) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;

ioeric wrote:
> Can you add tests for move all (multiple) classes in file?
> 
> Not related to this patch...but it seems that we are missing test case for 
> moving template class? 
> Not related to this patch...but it seems that we are missing test case for 
> moving template class?

Yeah, moving template classes doesn't support perfectly right now.



Comment at: unittests/clang-move/ClangMoveTests.cpp:278
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A")};
+  Spec.OldHeader = "foo.h";

ioeric wrote:
> Maybe just insert or push back?
I think using `insert` or `push_back` doesn't make the code as clear as 
initialization here. Code readers might pull up the source file to find the 
code for the initialized value of this variable.



Comment at: unittests/clang-move/ClangMoveTests.cpp:280
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";

ioeric wrote:
> Where is foo.cc?
The `Code` variable above represents the source code of `foo.cc`.



Comment at: unittests/clang-move/ClangMoveTests.cpp:299
+"using Int=int;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nusing namespace a;\nclass A {\npublic:\n  int f();\n};",
+"class B {};\nclass A {\npublic:\n  int f();\n};",

ioeric wrote:
> I think using namespace decl should also be ignored?
This case should rarely happen in source code, as many code styles prohibit 
`using-namespace` decls in headers.
I'd like to keep the current behavior because the using-namespace decl will 
populate the namespace in all the files which include this header. Ignoring it 
might break a lot of code.


https://reviews.llvm.org/D26236



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


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

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



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:257
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);

Why are these tests being removed?


Repository:
  rL LLVM

https://reviews.llvm.org/D26369



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


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 77094.

https://reviews.llvm.org/D26369

Files:
  test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,13 +238,6 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);
Index: test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
+}
+


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,13 +238,6 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);
Index: test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
+}
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
flx marked an inline comment as done.
flx added inline comments.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:257
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);

aaron.ballman wrote:
> Why are these tests being removed?
They should not be removed. Restored them.


https://reviews.llvm.org/D26369



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


[PATCH] D26203: [ClangTidy - performance-unnecessary-value-param]: Do not issue fix for functions that are referenced outside of callExpr

2016-11-07 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.

Aside from a commenting nit, LGTM.




Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:130
+  // Do not propose fixes when:
+  // 1. in macros since we cannot place them correctly
+  // 2. the function is virtual as it might break overrides

Not grammatically correct; should be "1. when the ParmVarDecl is in a macro, 
since..."


Repository:
  rL LLVM

https://reviews.llvm.org/D26203



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


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 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!




Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:257
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);

flx wrote:
> aaron.ballman wrote:
> > Why are these tests being removed?
> They should not be removed. Restored them.
Yay code review process! :-)


https://reviews.llvm.org/D26369



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


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
flx marked an inline comment as done.
flx added inline comments.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:257
-
-void PositiveNonConstDeclaration(ExpensiveToCopyType A);
-// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);

aaron.ballman wrote:
> flx wrote:
> > aaron.ballman wrote:
> > > Why are these tests being removed?
> > They should not be removed. Restored them.
> Yay code review process! :-)
Absolutely. Thanks for the quick review!


https://reviews.llvm.org/D26369



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


LLVM buildmaster will be restarted at 5 PM Pacific time today

2016-11-07 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted at 5 PM Pacific time today for
maintenance.

Thanks

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


[clang-tools-extra] r286155 - [clang-tidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
Author: flx
Date: Mon Nov  7 15:45:58 2016
New Revision: 286155

URL: http://llvm.org/viewvc/llvm-project?rev=286155&view=rev
Log:
[clang-tidy] Move incomplete type test into separate test file

Summary: Move in complete type test which does not compile into its own test 
file.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
Modified:

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Added: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp?rev=286155&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
 Mon Nov  7 15:45:58 2016
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
+}
+

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=286155&r1=286154&r2=286155&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
Mon Nov  7 15:45:58 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,13 +238,6 @@ void PositiveConstRefNotMoveAssignable(E
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);


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


[PATCH] D26301: [clang-tidy] Fix a regression issue introduced by r285239.

2016-11-07 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286156: [clang-tidy] Fix a regression issue introduced by 
r285239. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D26301?vs=76920&id=77096#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26301

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,13 +190,21 @@
   // within a cast expression.
   bool VisitStmt(Stmt *S) {
 CastExpr *C = dyn_cast(S);
+// Catch the castExpr inside cxxDefaultArgExpr.
+if (auto *E = dyn_cast(S))
+  C = dyn_cast(E->getExpr());
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
 }
+
 if (!FirstSubExpr)
   FirstSubExpr = C->getSubExpr()->IgnoreParens();
 
+// Ignore the expr if it is already a nullptr literal expr.
+if (isa(FirstSubExpr))
+  return true;
+
 if (C->getCastKind() != CK_NullToPointer &&
 C->getCastKind() != CK_NullToMemberPointer) {
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -217,3 +217,14 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
 // CHECK-FIXES: C c;
 #undef F
+
+// Test default argument expression.
+struct D {
+  explicit D(void *t, int *c = NULL) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use nullptr
+  // CHECK-FIXES: explicit D(void *t, int *c = nullptr) {}
+};
+
+void test_default_argument() {
+  D(nullptr);
+}


Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,13 +190,21 @@
   // within a cast expression.
   bool VisitStmt(Stmt *S) {
 CastExpr *C = dyn_cast(S);
+// Catch the castExpr inside cxxDefaultArgExpr.
+if (auto *E = dyn_cast(S))
+  C = dyn_cast(E->getExpr());
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
 }
+
 if (!FirstSubExpr)
   FirstSubExpr = C->getSubExpr()->IgnoreParens();
 
+// Ignore the expr if it is already a nullptr literal expr.
+if (isa(FirstSubExpr))
+  return true;
+
 if (C->getCastKind() != CK_NullToPointer &&
 C->getCastKind() != CK_NullToMemberPointer) {
   return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
@@ -217,3 +217,14 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
 // CHECK-FIXES: C c;
 #undef F
+
+// Test default argument expression.
+struct D {
+  explicit D(void *t, int *c = NULL) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use nullptr
+  // CHECK-FIXES: explicit D(void *t, int *c = nullptr) {}
+};
+
+void test_default_argument() {
+  D(nullptr);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26369: [ClangTidy] Move incomplete type test into separate test file

2016-11-07 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286155: [clang-tidy] Move incomplete type test into separate 
test file (authored by flx).

Changed prior to commit:
  https://reviews.llvm.org/D26369?vs=77094&id=77095#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26369

Files:
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
+}
+
Index: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- 
-fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,13 +238,6 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 
'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);


Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-incomplete-type.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
+}
+
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
 
 // CHECK-FIXES: #include 
 
@@ -238,13 +238,6 @@
   B = A;
 }
 
-// Ensure that incomplete types result in an error from the frontend and not a
-// clang-tidy diagnostic about IncompleteType being expensive to copy.
-struct IncompleteType;
-void NegativeForIncompleteType(IncompleteType I) {
-  // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
-}
-
 // Case where parameter in declaration is already const-qualified but not in
 // implementation. Make sure a second 'const' is not added to the declaration.
 void PositiveConstDeclaration(const ExpensiveToCopyType A);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r286156 - [clang-tidy] Fix a regression issue introduced by r285239.

2016-11-07 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Nov  7 15:46:24 2016
New Revision: 286156

URL: http://llvm.org/viewvc/llvm-project?rev=286156&view=rev
Log:
[clang-tidy] Fix a regression issue introduced by r285239.

Summary:
r285239 changes the behavior of AST CXXDefaultArgExpr node.

Update `modernize-use-nullptr` to handle CXXDefaultArgExpr correctly.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=286156&r1=286155&r2=286156&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Mon Nov  7 
15:46:24 2016
@@ -190,13 +190,21 @@ public:
   // within a cast expression.
   bool VisitStmt(Stmt *S) {
 CastExpr *C = dyn_cast(S);
+// Catch the castExpr inside cxxDefaultArgExpr.
+if (auto *E = dyn_cast(S))
+  C = dyn_cast(E->getExpr());
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
 }
+
 if (!FirstSubExpr)
   FirstSubExpr = C->getSubExpr()->IgnoreParens();
 
+// Ignore the expr if it is already a nullptr literal expr.
+if (isa(FirstSubExpr))
+  return true;
+
 if (C->getCastKind() != CK_NullToPointer &&
 C->getCastKind() != CK_NullToMemberPointer) {
   return true;

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=286156&r1=286155&r2=286156&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Mon Nov  
7 15:46:24 2016
@@ -217,3 +217,14 @@ C c;
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
 // CHECK-FIXES: C c;
 #undef F
+
+// Test default argument expression.
+struct D {
+  explicit D(void *t, int *c = NULL) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use nullptr
+  // CHECK-FIXES: explicit D(void *t, int *c = nullptr) {}
+};
+
+void test_default_argument() {
+  D(nullptr);
+}


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


[PATCH] D25911: [clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy-initialization.

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

friendly ping.


https://reviews.llvm.org/D25911



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


[PATCH] D26196: [WIP] Add support for non-zero null pointers

2016-11-07 Thread Yaxun Liu via cfe-commits
yaxunl retitled this revision from "AMDGPU: Translate null pointers in private 
and local addr space" to "[WIP] Add support for non-zero null pointers".
yaxunl updated this revision to Diff 77097.
yaxunl added a comment.

This is work in progress. Revised by John's comments.

Refactored getNullPtr to add a QualType parameter for the original pointer type 
in source language.
Added support of non-zero null pointer in default initialization of global 
variables, including struct and array types.


https://reviews.llvm.org/D26196

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,373 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test default initialization of pointers.
+
+// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *p1;
+
+// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *p2;
+
+// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *p3;
+
+// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *p4;
+
+// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *p5;
+
+// Test default initialization of sturcture.
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4
+StructTy1 S1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4
+StructTy2 S2;
+
+// Test default initialization of array.
+// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4
+StructTy1 A1[2];
+
+// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 4
+StructTy2 A2[2];
+
+// Test comparison with 0.
+
+// CHECK-LABEL: cmp_private
+// CHECK: icmp eq i8* %p, addrspacecast (i8 addrspace(4)* null to i

[PATCH] D26310: Add a method to get the list of registered static analyzer checkers.

2016-11-07 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 77098.
alexfh added a comment.

- Don't expose debug checkers.


https://reviews.llvm.org/D26310

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp


Index: unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
===
--- unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -14,6 +14,23 @@
 namespace clang {
 namespace ento {
 
+TEST(StaticAnalyzerOptions, getRegisteredCheckers) {
+  auto IsDebugChecker = [](StringRef CheckerName) {
+return CheckerName.startswith("debug");
+  };
+  auto IsAlphaChecker = [](StringRef CheckerName) {
+return CheckerName.startswith("alpha");
+  };
+  const auto &AllCheckers =
+  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
+  EXPECT_FALSE(llvm::any_of(AllCheckers, IsDebugChecker));
+  EXPECT_TRUE(llvm::any_of(AllCheckers, IsAlphaChecker));
+
+  const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers();
+  EXPECT_FALSE(llvm::any_of(StableCheckers, IsDebugChecker));
+  EXPECT_FALSE(llvm::any_of(StableCheckers, IsAlphaChecker));
+}
+
 TEST(StaticAnalyzerOptions, SearchInParentPackageTests) {
   AnalyzerOptions Opts;
   Opts.Config["Outer.Inner.CheckerOne:Option"] = "true";
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -23,6 +23,25 @@
 using namespace ento;
 using namespace llvm;
 
+std::vector
+AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) 
{
+  static const StringRef StaticAnalyzerChecks[] = {
+#define GET_CHECKERS
+#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   
\
+  FULLNAME,
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER
+#undef GET_CHECKERS
+  };
+  std::vector Result;
+  for (StringRef CheckName : StaticAnalyzerChecks) {
+if (!CheckName.startswith("debug.") &&
+(IncludeExperimental || !CheckName.startswith("alpha.")))
+  Result.push_back(CheckName);
+  }
+  return Result;
+}
+
 AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
   if (UserMode == UMK_NotSet) {
 StringRef ModeStr =
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -125,6 +125,9 @@
 public:
   typedef llvm::StringMap ConfigTable;
 
+  static std::vector
+  getRegisteredCheckers(bool IncludeExperimental = false);
+
   /// \brief Pair of checker name and enable/disable.
   std::vector > CheckersControlList;
   


Index: unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
===
--- unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -14,6 +14,23 @@
 namespace clang {
 namespace ento {
 
+TEST(StaticAnalyzerOptions, getRegisteredCheckers) {
+  auto IsDebugChecker = [](StringRef CheckerName) {
+return CheckerName.startswith("debug");
+  };
+  auto IsAlphaChecker = [](StringRef CheckerName) {
+return CheckerName.startswith("alpha");
+  };
+  const auto &AllCheckers =
+  AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
+  EXPECT_FALSE(llvm::any_of(AllCheckers, IsDebugChecker));
+  EXPECT_TRUE(llvm::any_of(AllCheckers, IsAlphaChecker));
+
+  const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers();
+  EXPECT_FALSE(llvm::any_of(StableCheckers, IsDebugChecker));
+  EXPECT_FALSE(llvm::any_of(StableCheckers, IsAlphaChecker));
+}
+
 TEST(StaticAnalyzerOptions, SearchInParentPackageTests) {
   AnalyzerOptions Opts;
   Opts.Config["Outer.Inner.CheckerOne:Option"] = "true";
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -23,6 +23,25 @@
 using namespace ento;
 using namespace llvm;
 
+std::vector
+AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) {
+  static const StringRef StaticAnalyzerChecks[] = {
+#define GET_CHECKERS
+#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)   \
+  FULLNAME,
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER
+#undef GET_CHECKERS
+  };
+  std::vector Result;
+  for (StringRef CheckName : StaticAnalyzerChecks) {
+if (!CheckName.startswith("debug.") &&
+(IncludeExperimental || !CheckName.startswith("alpha.")))
+  Result.push_back(CheckName);
+  }
+  return Result;
+}
+
 AnalyzerOptions::UserModeKind AnalyzerOption

  1   2   >