Re: [PATCH] D19957: clang-rename: when renaming a field, rename initializers of that field as well

2016-05-07 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
This revision is now accepted and ready to land.


Comment at: test/clang-rename/FieldTest.cpp:7-9
@@ +6,5 @@
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+

Any reason you put the run lines down there, btw? Usually we put them at the 
top :)


http://reviews.llvm.org/D19957



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


Re: [PATCH] D19957: clang-rename: when renaming a field, rename initializers of that field as well

2016-05-07 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Not really, I just copied VarTest.cpp. I'll put it to top for new tests.


Repository:
  rL LLVM

http://reviews.llvm.org/D19957



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


[libcxx] r268860 - Enable Pthread threading API on Solaris. Fix PR27677

2016-05-07 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat May  7 12:05:46 2016
New Revision: 268860

URL: http://llvm.org/viewvc/llvm-project?rev=268860&view=rev
Log:
Enable Pthread threading API on Solaris. Fix PR27677

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=268860&r1=268859&r2=268860&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sat May  7 12:05:46 2016
@@ -818,7 +818,8 @@ extern "C" void __sanitizer_annotate_con
 defined(__NetBSD__) || \
 defined(__linux__) || \
 defined(__APPLE__) || \
-defined(__CloudABI__)
+defined(__CloudABI__) || \
+defined(__sun__)
 #  define _LIBCPP_THREAD_API_PTHREAD
 # else
 #  error "No thread API"


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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-07 Thread Vedran Miletić via cfe-commits
rivanvx added inline comments.


Comment at: lib/Parse/ParseDecl.cpp:3519
@@ +3518,3 @@
+   / 100);
+const char *VerSpec = (VerMajor + std::string (".") + 
VerMinor).c_str();
+Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;

Anastasia wrote:
> I think it will be nicer to use string (not char*) here too.
Other Spec are const char*, so I did it for consistency. But I don't care 
either way.


http://reviews.llvm.org/D19780



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


Re: [PATCH] D17092: [X86] Add -mseparate-stack-seg

2016-05-07 Thread Michael Kuperstein via cfe-commits
mkuper resigned from this revision.
mkuper removed a reviewer: mkuper.
mkuper added a comment.

I really don't know enough about this part of clang either.


http://reviews.llvm.org/D17092



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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-07 Thread Vedran Miletić via cfe-commits
rivanvx updated this revision to Diff 56478.
rivanvx marked 3 inline comments as done.
rivanvx added a comment.

I am neither aware how to convert ints to StringRef nor how to concatenate 
StringRefs. Apologies if I missed something in the API.

In any case, this approach looks pretty clean to me.


http://reviews.llvm.org/D19780

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDecl.cpp
  test/Parser/opencl-cl20.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -13,7 +13,7 @@
   constant int L1 = 0;
   local int L2;
 
-  auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+  auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
 }
 
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -10,5 +10,5 @@
 #ifdef CL20
 void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
 #else
-void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
+void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL version 2.0}}
 #endif
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -2,10 +2,10 @@
 
 void test_storage_class_specs()
 {
-  static int a;// expected-error {{OpenCL does not support the 'static' storage class specifier}}
-  register int b;  // expected-error {{OpenCL does not support the 'register' storage class specifier}}
-  extern int c;// expected-error {{OpenCL does not support the 'extern' storage class specifier}}
-  auto int d;  // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
+  static int a;// expected-error {{OpenCL version 1.0 does not support the 'static' storage class specifier}}
+  register int b;  // expected-error {{OpenCL version 1.0 does not support the 'register' storage class specifier}}
+  extern int c;// expected-error {{OpenCL version 1.0 does not support the 'extern' storage class specifier}}
+  auto int d;  // expected-error {{OpenCL version 1.0 does not support the 'auto' storage class specifier}}
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
   static int e; // expected-error {{static local variable must reside in constant address space}}
Index: test/Parser/opencl-cl20.cl
===
--- test/Parser/opencl-cl20.cl
+++ test/Parser/opencl-cl20.cl
@@ -10,17 +10,17 @@
   return var;  
 }
 #ifndef CL20
-// expected-error@-5 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
+// expected-error@-5 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
 #endif
 
 generic int * generic_test(generic int *arg) {
   generic int *var;
   return var;  
 }
 #ifndef CL20
-// expected-error@-5 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
+// expected-error@-5 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
 #endif
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 
@@ -3507,9 +3508,13 @@
   if (DiagID == diag::ext_duplicate_declspec)
 Diag(Tok, DiagID)
   << PrevSpec << FixItHint::CreateRemov

Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-07 Thread Vedran Miletić via cfe-commits
rivanvx added a comment.

@Anastasia would you still prefer to make VerSpec a std::string?


http://reviews.llvm.org/D19780



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


Re: [PATCH] RHEL: Look in more places to find g++ headers and runtime

2016-05-07 Thread Michael Lampe via cfe-commits

No, I'm hoping on someone else to commit this. (You?)

Same with this one:

https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg18696.html

-Michael

Rafael Espíndola wrote:

LGTM. Do you have commit access?

Cheers,
Rafael


On 11 April 2016 at 14:49, Michael Lampe  wrote:

New patch attached.

-Michael


Rafael Espíndola wrote:


LGTM with a comment saying why it is needed.

Cheers,
Rafael


On 22 March 2016 at 23:02, Michael Lampe via cfe-commits
 wrote:


Some distros with ten years of support ship an old gcc but later offer
more
recent versions for installation in parallel. These versions are
typically
not only needed for the compilation of llvm/clang, but also to properly
use
the clang binary that comes out.

Clang already searches /usr at runtime for the most recent installation
of
gcc. This patch appends paths for add-on installations of gcc in RHEL.


___
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


[clang-tools-extra] r268857 - clang-rename: when renaming a field, rename initializers of that field as well

2016-05-07 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sat May  7 09:32:59 2016
New Revision: 268857

URL: http://llvm.org/viewvc/llvm-project?rev=268857&view=rev
Log:
clang-rename: when renaming a field, rename initializers of that field as well

Summary: The second check failed, the initializer wasn't renamed.

Reviewers: cfe-commits, klimek

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

Added:
clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=268857&r1=268856&r2=268857&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Sat May  7 09:32:59 
2016
@@ -57,6 +57,19 @@ public:
 return true;
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (clang::CXXConstructorDecl::init_const_iterator it = 
ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
+  const clang::CXXCtorInitializer* Initializer = *it;
+  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+if (getUSRForDecl(FieldDecl) == USR) {
+  // The initializer refers to a field that is to be renamed.
+  LocationsFound.push_back(Initializer->getSourceLocation());
+}
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {

Added: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp?rev=268857&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp Sat May  7 09:32:59 
2016
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.


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


r268740 - Revert "AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels."

2016-05-07 Thread Nikolay Haustov via cfe-commits
Author: nhaustov
Date: Fri May  6 10:00:51 2016
New Revision: 268740

URL: http://llvm.org/viewvc/llvm-project?rev=268740&view=rev
Log:
Revert "AMDGPU/SI: Use amdgpu_kernel calling convention for OpenCL kernels."

This reverts commit f7053ec90d0fc56f0837e43c2c759e85b56c21a1.

It broke calling OpenCL kernel from another kernel.

Removed:
cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=268740&r1=268739&r2=268740&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May  6 10:00:51 2016
@@ -6826,14 +6826,6 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   if (!FD)
 return;
 
-  if (M.getLangOpts().OpenCL) {
-if (FD->hasAttr()) {
-  // Set amdgpu_kernel calling convention for OpenCL kernels.
-  llvm::Function *Fn = cast(GV);
-  Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
-}
-  }
-
   if (const auto Attr = FD->getAttr()) {
 llvm::Function *F = cast(GV);
 uint32_t NumVGPR = Attr->getNumVGPR();

Removed: cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl?rev=268739&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-calling-conv.cl (removed)
@@ -1,12 +0,0 @@
-// REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
-
-// CHECK: define amdgpu_kernel void @calling_conv_amdgpu_kernel()
-kernel void calling_conv_amdgpu_kernel()
-{
-}
-
-// CHECK: define void @calling_conv_none()
-void calling_conv_none()
-{
-}

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl?rev=268740&r1=268739&r2=268740&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl Fri May  6 10:00:51 2016
@@ -5,23 +5,23 @@
 
 __attribute__((amdgpu_num_vgpr(64))) // expected-no-diagnostics
 kernel void test_num_vgpr64() {
-// CHECK: define amdgpu_kernel void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
+// CHECK: define void @test_num_vgpr64() [[ATTR_VGPR64:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_sgpr(32))) // expected-no-diagnostics
 kernel void test_num_sgpr32() {
-// CHECK: define amdgpu_kernel void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
+// CHECK: define void @test_num_sgpr32() [[ATTR_SGPR32:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(64), amdgpu_num_sgpr(32))) // 
expected-no-diagnostics
 kernel void test_num_vgpr64_sgpr32() {
-// CHECK: define amdgpu_kernel void @test_num_vgpr64_sgpr32() 
[[ATTR_VGPR64_SGPR32:#[0-9]+]]
+// CHECK: define void @test_num_vgpr64_sgpr32() [[ATTR_VGPR64_SGPR32:#[0-9]+]]
 
 }
 
 __attribute__((amdgpu_num_sgpr(20), amdgpu_num_vgpr(40))) // 
expected-no-diagnostics
 kernel void test_num_sgpr20_vgpr40() {
-// CHECK: define amdgpu_kernel void @test_num_sgpr20_vgpr40() 
[[ATTR_SGPR20_VGPR40:#[0-9]+]]
+// CHECK: define void @test_num_sgpr20_vgpr40() [[ATTR_SGPR20_VGPR40:#[0-9]+]]
 }
 
 __attribute__((amdgpu_num_vgpr(0))) // expected-no-diagnostics


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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-07 Thread Vedran Miletić via cfe-commits
rivanvx updated this revision to Diff 56479.
rivanvx added a comment.

Make that int const as well.


http://reviews.llvm.org/D19780

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDecl.cpp
  test/Parser/opencl-cl20.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/storageclass.cl

Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -13,7 +13,7 @@
   constant int L1 = 0;
   local int L2;
 
-  auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+  auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
   global int L4;   // expected-error{{function scope variable cannot be declared in global address space}}
 }
 
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- test/SemaOpenCL/invalid-access-qualifier.cl
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -10,5 +10,5 @@
 #ifdef CL20
 void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
 #else
-void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
+void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL version 2.0}}
 #endif
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -2,10 +2,10 @@
 
 void test_storage_class_specs()
 {
-  static int a;// expected-error {{OpenCL does not support the 'static' storage class specifier}}
-  register int b;  // expected-error {{OpenCL does not support the 'register' storage class specifier}}
-  extern int c;// expected-error {{OpenCL does not support the 'extern' storage class specifier}}
-  auto int d;  // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
+  static int a;// expected-error {{OpenCL version 1.0 does not support the 'static' storage class specifier}}
+  register int b;  // expected-error {{OpenCL version 1.0 does not support the 'register' storage class specifier}}
+  extern int c;// expected-error {{OpenCL version 1.0 does not support the 'extern' storage class specifier}}
+  auto int d;  // expected-error {{OpenCL version 1.0 does not support the 'auto' storage class specifier}}
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
   static int e; // expected-error {{static local variable must reside in constant address space}}
Index: test/Parser/opencl-cl20.cl
===
--- test/Parser/opencl-cl20.cl
+++ test/Parser/opencl-cl20.cl
@@ -10,17 +10,17 @@
   return var;  
 }
 #ifndef CL20
-// expected-error@-5 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the '__generic' type qualifier}}
+// expected-error@-5 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
 #endif
 
 generic int * generic_test(generic int *arg) {
   generic int *var;
   return var;  
 }
 #ifndef CL20
-// expected-error@-5 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error@-6 {{OpenCL does not support the 'generic' type qualifier}}
+// expected-error@-5 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error@-6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
 #endif
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ScopedPrinter.h"
 
 using namespace clang;
 
@@ -3507,9 +3508,13 @@
   if (DiagID == diag::ext_duplicate_declspec)
 Diag(Tok, DiagID)
   << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
-  else if (DiagID == diag::err_opencl_unknown_type_specifier)
-Diag(Tok, DiagID) << PrevSpec << isStorageClass;
-  else
+  else if (DiagID == diag::err_ope

Re: [PATCH] D19957: clang-rename: when renaming a field, rename initializers of that field as well

2016-05-07 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268857: clang-rename: when renaming a field, rename 
initializers of that field as well (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D19957?vs=56241&id=56497#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19957

Files:
  clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
  clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp

Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
 return true;
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (clang::CXXConstructorDecl::init_const_iterator it = 
ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
+  const clang::CXXCtorInitializer* Initializer = *it;
+  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+if (getUSRForDecl(FieldDecl) == USR) {
+  // The initializer refers to a field that is to be renamed.
+  LocationsFound.push_back(Initializer->getSourceLocation());
+}
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.


Index: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
@@ -57,6 +57,19 @@
 return true;
   }
 
+  bool VisitCXXConstructorDecl(clang::CXXConstructorDecl *ConstructorDecl) {
+for (clang::CXXConstructorDecl::init_const_iterator it = ConstructorDecl->init_begin(); it != ConstructorDecl->init_end(); ++it) {
+  const clang::CXXCtorInitializer* Initializer = *it;
+  if (const clang::FieldDecl *FieldDecl = Initializer->getAnyMember()) {
+if (getUSRForDecl(FieldDecl) == USR) {
+  // The initializer refers to a field that is to be renamed.
+  LocationsFound.push_back(Initializer->getSourceLocation());
+}
+  }
+}
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -0,0 +1,17 @@
+class Cla
+{
+  int foo; // CHECK: hector;
+public:
+  Cla();
+};
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+Cla::Cla()
+  : foo(0) // CHECK: hector(0)
+{
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-07 Thread Evangelos Foutras via cfe-commits
foutrelis added a subscriber: foutrelis.


Comment at: test/CodeGenCXX/mangle-abi-tag.cpp:115
@@ +114,3 @@
+C1 f9() { return C1(); }
+// CHECK: @_Z2f9B6Names1v()
+

I'm seeing a test failure on i686 on Arch Linux (all tests pass on x86_64): 
{F1899075}

I'm using this patch and a slightly tweaked version of D17567 on top of clang 
3.8.0; not sure if that's the reason for the failure.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-07 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Thank you for reporting this issue, I'll take a look.
I'm mostly testing on x86_64 so I may not notice the problem.


http://reviews.llvm.org/D18035



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


[PATCH] D20052: Add new ASTMatcher that matches dynamic exception specifications.

2016-05-07 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: alexfh.
hintonda added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Add new ASTMatcher that matches dynamic exception specifications.

http://reviews.llvm.org/D20052

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3212,6 +3212,25 @@
   return Node.isDefaulted();
 }
 
+/// \brief Matches functions that have a dynamic exception specification.
+///
+/// Given:
+/// \code
+///   void f();
+///   void g() noexcept;
+///   void h() throw();
+///   void i() throw(int);
+///   void j() throw(...);
+///   void k() noexcept(false);
+/// \endcode
+/// functionDecl(hasDynamicExceptionSpec())
+///   matches the declarations of h, i, and j, but not f, g or k.
+AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
+  if (const auto *FnTy = Node.getType()->getAs())
+return FnTy->hasDynamicExceptionSpec();
+  return false;
+}
+
 /// \brief Matches functions that have a non-throwing exception specification.
 ///
 /// Given:


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3212,6 +3212,25 @@
   return Node.isDefaulted();
 }
 
+/// \brief Matches functions that have a dynamic exception specification.
+///
+/// Given:
+/// \code
+///   void f();
+///   void g() noexcept;
+///   void h() throw();
+///   void i() throw(int);
+///   void j() throw(...);
+///   void k() noexcept(false);
+/// \endcode
+/// functionDecl(hasDynamicExceptionSpec())
+///   matches the declarations of h, i, and j, but not f, g or k.
+AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) {
+  if (const auto *FnTy = Node.getType()->getAs())
+return FnTy->hasDynamicExceptionSpec();
+  return false;
+}
+
 /// \brief Matches functions that have a non-throwing exception specification.
 ///
 /// Given:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-05-07 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 56511.
hintonda added a comment.

Addressed additional comments.


http://reviews.llvm.org/D18575

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A{};
+class B{};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'foo' uses dynamic exception specification 'throw()'; use 'noexcept' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw(...)'; use 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() noexcept(false);
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: function 'foobar' uses dynamic exception specification 'throw(A, B)'; use 'noexcept(false)' instead [modernize-use-noexcept]
+// CHECK-FIXES: void foobar() noexcept(false)
+
+// Should not trigger a replacement.
+void titi() noexcept {}
+void toto() noexcept(true) {}
Index: test/clang-tidy/modernize-use-noexcept-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept-macro.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
+// RUN:   -- -std=c++11
+
+#define NOEXCEPT noexcept
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bar' uses dynamic exception specification 'throw()'; use 'NOEXCEPT' instead [modernize-use-noexcept]
+// CHECK-FIXES: void bar() NOEXCEPT {}
+
+// Should not trigger a replacement.
+void foo() noexcept(true);
+
Index: docs/clang-tidy/checks/modernize-use-noexcept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-noexcept.rst
@@ -0,0 +1,50 @@
+.. title:: clang-tidy - modernize-use-noexcept
+
+modernize-use-noexcept
+==
+
+The check converts dynamic exception specifications, e.g., throw(),
+throw([,...]), or throw(...) to noexcept, noexcept(false),
+or a user defined macro.
+
+Example
+---
+
+.. code-block:: c++
+
+  void foo() throw();
+	void bar() throw(int) {}
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() noexcept;
+	void bar() noexcept(false) {}
+
+
+User defined macros
+---
+
+By default this check will only replace ``throw()`` with ``noexcept``,
+and ``throw([,...])`` or ``throw(...)`` with
+``throw(false)``.  Additinally, users can also use
+:option:``ReplacementString`` to specify a macro to use instead of
+``noexcept``.  This is useful when maintaining source code that must
+compile on older compilers that don't support the ``noexcept``
+keyword.
+
+Example
+^^^
+
+.. code-block:: c++
+
+  void foo() throw() {}
+
+transforms to:
+
+.. code-block:: c++
+
+  void foo() NOEXCEPT {}
+
+if the ``ReplacementString`` option is set to ``NOEXCEPT``.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -191,6 +191,11 @@
   Selectively replaces string literals containing escaped characters with raw
   string literals.
 
+- New `modernize-use-noexcept
+  `_ check
+
+  Replaces dynamic exception specifications with noexcept.
+
 - New `performance-faster-string-find
   `_ check
 
Index: clang-tidy/utils/LexerUtils.h
===
--- clang-tidy/utils/LexerUtils.h
+++ clang-tidy/utils/LexerUtils.h
@@ -12,6 +12,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallVector.h"
 
 namespace clang {
 namespace tidy {
@@ -23,6 +24,10 @@
 Token getPreviousNonCommentToken(const ASTContext &Context,
  SourceLocation Location);
 
+SmallVector ParseTokens(const ASTContext &Context,
+   const SourceManager &Sources,
+   CharSourceRange Range);
+
 } // namespace lexer
 } // namespac

r268870 - [OpenMP] Check for associated statements with hasAssociatedStmt() when scanning for device code.

2016-05-07 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Sun May  8 01:43:56 2016
New Revision: 268870

URL: http://llvm.org/viewvc/llvm-project?rev=268870&view=rev
Log:
[OpenMP] Check for associated statements with hasAssociatedStmt() when scanning 
for device code.

Summary: `getAssociatedStmt()` contains an assertion that assumes the statement 
always exists. In device code scanning, we need to look into the associated 
statement therefore we check its existence. This patch replaces  
`getAssociatedStmt` by `hasAssociatedStmt` so that we do not trigger the 
assertion for directives that happen not to have an associated statement (e.g 
target enter/exit data).

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: cfe-commits, caomhin

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_enter_data_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=268870&r1=268869&r2=268870&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun May  8 01:43:56 2016
@@ -5719,7 +5719,7 @@ void CGOpenMPRuntime::scanForTargetRegio
   }
 
   if (const OMPExecutableDirective *E = dyn_cast(S)) {
-if (!E->getAssociatedStmt())
+if (!E->hasAssociatedStmt())
   return;
 
 scanForTargetRegionsFunctions(

Modified: cfe/trunk/test/OpenMP/target_enter_data_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_enter_data_codegen.cpp?rev=268870&r1=268869&r2=268870&view=diff
==
--- cfe/trunk/test/OpenMP/target_enter_data_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_enter_data_codegen.cpp Sun May  8 01:43:56 2016
@@ -218,4 +218,32 @@ void no_target_devices(int arg) {
   {++arg;}
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp 
-fomptargets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix 
CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -fopenmp -fomptargets=powerpc64le-ibm-linux-gnu -x 
c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fomptargets=powerpc64le-ibm-linux-gnu -x c++ 
-triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s  --check-prefix CK4 --check-prefix CK4-64
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -fomptargets=i386-pc-linux-gnu -x 
c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  
--check-prefix CK4 --check-prefix CK4-32
+// RUN: %clang_cc1 -DCK4 -fopenmp -fomptargets=i386-pc-linux-gnu -x c++ 
-std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fomptargets=i386-pc-linux-gnu -x c++ -triple 
i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s  --check-prefix CK4 --check-prefix CK4-32
+
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu 
-emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple 
powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu -emit-llvm 
%s -fopenmp-is-device -fomp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck 
%s --check-prefix TCK4 --check-prefix TCK4-64
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fomptargets=powerpc64le-ibm-linux-gnu -emit-pch 
-fopenmp-is-device -fomp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fomptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device 
-fomp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o 
- | FileCheck %s --check-prefix TCK4 --check-prefix TCK4-64
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fomptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fomptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device 
-fomp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCK4 
--check-prefix TCK4-32
+// RUN: %clang_cc1 -DCK4 -fopenmp -x c++ -std=c++11 -triple 
i386-unknown-unknown -fomptargets=i386-pc-linux-gnu -emit-pch 
-fopenmp-is-device -fomp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fomptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device 
-fomp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o 
- | FileCheck %s --check-prefix TCK4 --check-prefix TCK4-3