Re: [PATCH] D17596: [OpenCL] Add ocl and spir version for spir target

2016-03-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264241: [OpenCL] Add ocl and spir version for spir target 
(authored by pxl).

Changed prior to commit:
  http://reviews.llvm.org/D17596?vs=51253=51509#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17596

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenOpenCL/spir_version.cl

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7217,6 +7217,47 @@
   }
 }
 
+//===--===//
+// SPIR ABI Implementation
+//===--===//
+
+namespace {
+class SPIRTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  SPIRTargetCodeGenInfo(CodeGen::CodeGenTypes )
+: TargetCodeGenInfo(new DefaultABIInfo(CGT)) {}
+  void emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
+CodeGen::CodeGenModule ) const override;
+};
+} // End anonymous namespace.
+
+/// Emit SPIR specific metadata: OpenCL and SPIR version.
+void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule ) const {
+  assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL");
+  llvm::LLVMContext  = CGM.getModule().getContext();
+  llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx);
+  llvm::Module  = CGM.getModule();
+  // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
+  // opencl.spir.version named metadata.
+  llvm::Metadata *SPIRVerElts[] = {
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+  llvm::NamedMDNode *SPIRVerMD =
+  M.getOrInsertNamedMetadata("opencl.spir.version");
+  SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));
+  // SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the
+  // opencl.ocl.version named metadata node.
+  llvm::Metadata *OCLVerElts[] = {
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, (CGM.getLangOpts().OpenCLVersion % 100) / 10))};
+  llvm::NamedMDNode *OCLVerMD =
+  M.getOrInsertNamedMetadata("opencl.ocl.version");
+  OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts));
+}
+
 static bool appendType(SmallStringEnc , QualType QType,
const CodeGen::CodeGenModule ,
TypeStringCache );
@@ -7707,5 +7748,8 @@
 return *(TheTargetCodeGenInfo = new SparcV9TargetCodeGenInfo(Types));
   case llvm::Triple::xcore:
 return *(TheTargetCodeGenInfo = new XCoreTargetCodeGenInfo(Types));
+  case llvm::Triple::spir:
+  case llvm::Triple::spir64:
+return *(TheTargetCodeGenInfo = new SPIRTargetCodeGenInfo(Types));
   }
 }
Index: cfe/trunk/test/CodeGenOpenCL/spir_version.cl
===
--- cfe/trunk/test/CodeGenOpenCL/spir_version.cl
+++ cfe/trunk/test/CodeGenOpenCL/spir_version.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CL10
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CL12
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CL20
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CL10
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CL12
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CL20
+kernel void foo() {}
+// CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
+// CL10: [[SPIR]] = !{i32 2, i32 0}
+// CL10: [[OCL]] = !{i32 1, i32 0}
+// CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
+// CL12: [[SPIR]] = !{i32 2, i32 0}
+// CL12: [[OCL]] = !{i32 1, i32 2}
+// CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]}
+// CL20: [[SPIR]] = !{i32 2, i32 0}


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7217,6 +7217,47 @@
   }
 }
 
+//===--===//
+// SPIR ABI Implementation
+//===--===//
+
+namespace {
+class 

r264241 - [OpenCL] Add ocl and spir version for spir target

2016-03-23 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Wed Mar 23 22:57:17 2016
New Revision: 264241

URL: http://llvm.org/viewvc/llvm-project?rev=264241=rev
Log:
[OpenCL] Add ocl and spir version for spir target

Summary: Add opencl.spir.version and opencl.ocl.version metadata for CodeGen to 
identify OpenCL version. 

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits, pekka.jaaskelainen

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

Added:
cfe/trunk/test/CodeGenOpenCL/spir_version.cl
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=264241=264240=264241=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Mar 23 22:57:17 2016
@@ -7217,6 +7217,47 @@ void XCoreTargetCodeGenInfo::emitTargetM
   }
 }
 
+//===--===//
+// SPIR ABI Implementation
+//===--===//
+
+namespace {
+class SPIRTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  SPIRTargetCodeGenInfo(CodeGen::CodeGenTypes )
+: TargetCodeGenInfo(new DefaultABIInfo(CGT)) {}
+  void emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
+CodeGen::CodeGenModule ) const override;
+};
+} // End anonymous namespace.
+
+/// Emit SPIR specific metadata: OpenCL and SPIR version.
+void SPIRTargetCodeGenInfo::emitTargetMD(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule ) const {
+  assert(CGM.getLangOpts().OpenCL && "SPIR is only for OpenCL");
+  llvm::LLVMContext  = CGM.getModule().getContext();
+  llvm::Type *Int32Ty = llvm::Type::getInt32Ty(Ctx);
+  llvm::Module  = CGM.getModule();
+  // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
+  // opencl.spir.version named metadata.
+  llvm::Metadata *SPIRVerElts[] = {
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))};
+  llvm::NamedMDNode *SPIRVerMD =
+  M.getOrInsertNamedMetadata("opencl.spir.version");
+  SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));
+  // SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the
+  // opencl.ocl.version named metadata node.
+  llvm::Metadata *OCLVerElts[] = {
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)),
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+  Int32Ty, (CGM.getLangOpts().OpenCLVersion % 100) / 10))};
+  llvm::NamedMDNode *OCLVerMD =
+  M.getOrInsertNamedMetadata("opencl.ocl.version");
+  OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts));
+}
+
 static bool appendType(SmallStringEnc , QualType QType,
const CodeGen::CodeGenModule ,
TypeStringCache );
@@ -7707,5 +7748,8 @@ const TargetCodeGenInfo ::
 return *(TheTargetCodeGenInfo = new SparcV9TargetCodeGenInfo(Types));
   case llvm::Triple::xcore:
 return *(TheTargetCodeGenInfo = new XCoreTargetCodeGenInfo(Types));
+  case llvm::Triple::spir:
+  case llvm::Triple::spir64:
+return *(TheTargetCodeGenInfo = new SPIRTargetCodeGenInfo(Types));
   }
 }

Added: cfe/trunk/test/CodeGenOpenCL/spir_version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/spir_version.cl?rev=264241=auto
==
--- cfe/trunk/test/CodeGenOpenCL/spir_version.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/spir_version.cl Wed Mar 23 22:57:17 2016
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CL10
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CL12
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CL20
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CL10
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CL12
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CL20
+kernel void foo() {}
+// CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
+// CL10: [[SPIR]] = !{i32 2, i32 0}
+// CL10: [[OCL]] = !{i32 1, i32 0}
+// CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]}
+// CL12: [[SPIR]] = !{i32 2, i32 0}
+// CL12: [[OCL]] = !{i32 1, i32 2}
+// CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]}
+// CL20: !opencl.ocl.version = 

Re: [PATCH] D17981: [clang-tidy] Fix clang-tidy to support parsing of assembly statements.

2016-03-23 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D17981#380350, @alexfh wrote:

> Adding Manuel, who might have better ideas.
>
> In http://reviews.llvm.org/D17981#374904, @rnk wrote:
>
> > In http://reviews.llvm.org/D17981#374553, @etienneb wrote:
> >
> > > This is a huge difference. I didn't expect dependencies to bring so much 
> > > code.
> > >  I'm not a fan of having an empty statement and increasing false 
> > > positives ratio.
> > >  Would it be possible to skip whole declarations with asm-stm, and flag 
> > > them as "ignored / not parsable"?
> >
> >
> > I don't actually think there are that many false positives, but I wanted to 
> > hear from Alex in case I'm wrong. I was hoping he had better ideas on how 
> > to suppress a diagnostic error in clang and run the clang-tidy checks 
> > anyway.
>
>
> I'm not familiar with the capabilities of MS-asm blocks, but if they can 
> contain function calls, for example, we might lose valuable information, if 
> we skip them. The possibility of a false positive depends on a specific 
> check, it's hard to tell in general. There's also a more generic thing that 
> can stop working properly: finding compilation errors inside asm blocks and 
> applying fixes to these errors (if there are any fixes generated from parsing 
> MS-asm blocks). Not sure how frequently this will happen though.
>
> > My best idea is that we make this diagnostic a default-error warning and 
> > then build with -Wno-unparseable-assembly or something. That's not a very 
> > good solution, though. =\
>
>
> Yes, not a very good solution for the reasons outlined above.
>
> > 
>
> > 
>
> > > We could gate this code under a define. I'm not a fan of define, but it 
> > > seems to be a compromise for the size.
>
> > 
>
> > > 
>
> > 
>
> > > Something like: LIBTOOLING_ENABLE_INLINE_ASM_PARSER
>
> > 
>
> > > 
>
> > 
>
> > > If we decide to pursue that direction, then it should probably be for 
> > > every tools.
>
> > 
>
> > 
>
> > I'd really rather not do that.
>
>
> What's your concern? If we want parsing code inside MS asm blocks like the 
> compiler does, we'll need to pay the cost of the asm parser. If the binary 
> size is a large problem here, can we maybe reduce the set of dependencies of 
> the MS asm parser?
>
> In any case, I'm sure many users don't need this functionality, so it should 
> be made compile-time configurable.


The alternative was to plug a dummy asm parser in clang-tidy, to mock the real 
one in the back-end.
I think it's doable, but didn't investigate it.

Or we can add a fake browser to avoid paying the cost of the full one and all 
the dependencies.

Both direction make sense, and I will let you choose:

- Adding the real parser and paying the cost
- Finding a way to parse and ignore any errors related to assembly statement

If we choose to add the expensive dependencies, then we need to choose to gate 
it or not under a "define".

Also, a point to bring here: this is applicable to every tool built with 
libtooling.


http://reviews.llvm.org/D17981



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


[PATCH] D18425: [Sema] Make enable_if act correctly with value dependent conditions/arguments

2016-03-23 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

Test case:

```
int foo(int A) __attribute__((enable_if(A == 0, "")));
template  int bar() { return foo(A); }

int G = bar<1>(); // calls foo(1), which should be a compile-time error, but 
isn't.
```

We get around this by making `CheckEnableIf` fail all value dependent 
`enable_if` conditions, and report whether the condition may have failed due to 
a dependent value. If we fail due for this reason during overload resolution, 
we hand back an unresolved, type-dependent call expression, because the 
following code is perfectly legal:

```
int ThisIsABadIdea(int A) __attribute__((enable_if(A == 1, "")));
double ThisIsABadIdea(int A) __attribute__((enable_if(A == 2, "")));
```

...But if we're not in overload resolution, we can get away with just marking 
the expression as value dependent, because we know our target. :)

http://reviews.llvm.org/D18425

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/enable_if.cpp

Index: test/SemaCXX/enable_if.cpp
===
--- test/SemaCXX/enable_if.cpp
+++ test/SemaCXX/enable_if.cpp
@@ -133,13 +133,18 @@
   int t1 = y.h(1, 2);  // expected-error{{no matching member function for call to 'h'}}
 }
 
-// FIXME: issue an error (without instantiation) because ::h(T()) is not
-// convertible to bool, because return types aren't overloadable.
+void ovlH(int);
+int ovlH(double);
 void h(int);
-template  void outer() {
-  void local_function() __attribute__((enable_if(::h(T()), "")));
+template  int outer() {
+  void local_function() __attribute__((enable_if(::h(T()), ""))); // expected-error{{value of type 'void' is not contextually convertible to 'bool'}}
+  void local_function2() __attribute__((enable_if(::ovlH(T()), ""))); // expected-error{{value of type 'void' is not contextually convertible to 'bool'}}
   local_function();
-};
+  local_function2();
+  return 0;
+}
+
+int runOuter = outer(); // expected-note{{in instantiation of function template specialization 'outer'}}
 
 namespace PR20988 {
   struct Integer {
@@ -191,11 +196,11 @@
   int ovlConflict(int m) __attribute__((enable_if(true, "")));
   int ovlConflict(int m) __attribute__((enable_if(1, "")));
   void test3() {
-int (*p)(int) = ovlConflict; // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
-int (*p2)(int) =  // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+int (*p)(int) = ovlConflict; // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@196{{candidate function}} expected-note@197{{candidate function}}
+int (*p2)(int) =  // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@196{{candidate function}} expected-note@197{{candidate function}}
 int (*a)(int);
-a = ovlConflict; // expected-error{{assigning to 'int (*)(int)' from incompatible type ''}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
-a =  // expected-error{{assigning to 'int (*)(int)' from incompatible type ''}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+a = ovlConflict; // expected-error{{assigning to 'int (*)(int)' from incompatible type ''}} expected-note@196{{candidate function}} expected-note@197{{candidate function}}
+a =  // expected-error{{assigning to 'int (*)(int)' from incompatible type ''}} expected-note@196{{candidate function}} expected-note@197{{candidate function}}
   }
 
   template 
@@ -213,11 +218,11 @@
   template 
   T templatedBar(T m) __attribute__((enable_if(m > 0, ""))) { return T(); }
   void test5() {
-int (*p)(int) = templatedBar; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@214{{candidate function made ineligible by enable_if}}
-int (*p2)(int) = ; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@214{{candidate function made ineligible by enable_if}}
+int (*p)(int) = templatedBar; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@219{{candidate function made ineligible by enable_if}}
+int (*p2)(int) = ; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@219{{candidate function made ineligible by enable_if}}
 int (*a)(int);
-a = templatedBar; // expected-error{{assigning to 'int (*)(int)' from incompatible type ''}} expected-note@214{{candidate function made ineligible by 

r264236 - Add release notes for the removal of the silent include of altivec.h.

2016-03-23 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Mar 23 20:28:25 2016
New Revision: 264236

URL: http://llvm.org/viewvc/llvm-project?rev=264236=rev
Log:
Add release notes for the removal of the silent include of altivec.h.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=264236=264235=264236=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Mar 23 20:28:25 2016
@@ -79,6 +79,7 @@ TLS is enabled for Cygwin defaults to -f
 
 C Language Changes in Clang
 ---
+The -faltivec and -maltivec flags no longer silently include altivec.h on 
Power platforms.
 
 ...
 


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


[PATCH] D18424: [Clang] Fix Clang-tidy modernize-deprecated-headers warnings; other minor fixes

2016-03-23 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: hans, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.
Herald added a subscriber: klimek.

Some Include What You Use suggestions were used too.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Repository:
  rL LLVM

http://reviews.llvm.org/D18424

Files:
  include/clang-c/Index.h
  include/clang/Analysis/Analyses/ThreadSafetyTIL.h
  include/clang/Basic/Linkage.h
  include/clang/Basic/TargetBuiltins.h
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/Driver/Types.cpp
  lib/Frontend/CodeGenOptions.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  lib/Sema/DelayedDiagnostic.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Tooling/Core/QualTypeNames.cpp
  tools/libclang/CIndexDiagnostic.h

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -58,8 +58,10 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 using namespace clang;
@@ -483,6 +485,7 @@
 void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
 }
+
 void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
   Writer.AddSourceLocation(TL.getBuiltinLoc(), Record);
   if (TL.needsExtraLocalData()) {
@@ -492,31 +495,40 @@
 Record.push_back(TL.hasModeAttr());
   }
 }
+
 void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
   Writer.AddSourceLocation(TL.getStarLoc(), Record);
 }
+
 void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
   // nothing to do
 }
+
 void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
   // nothing to do
 }
+
 void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
   Writer.AddSourceLocation(TL.getCaretLoc(), Record);
 }
+
 void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
   Writer.AddSourceLocation(TL.getAmpLoc(), Record);
 }
+
 void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
   Writer.AddSourceLocation(TL.getAmpAmpLoc(), Record);
 }
+
 void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
   Writer.AddSourceLocation(TL.getStarLoc(), Record);
   Writer.AddTypeSourceInfo(TL.getClassTInfo(), Record);
 }
+
 void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
   Writer.AddSourceLocation(TL.getLBracketLoc(), Record);
   Writer.AddSourceLocation(TL.getRBracketLoc(), Record);
@@ -524,29 +536,37 @@
   if (TL.getSizeExpr())
 Writer.AddStmt(TL.getSizeExpr());
 }
+
 void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
   VisitArrayTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
   VisitArrayTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
   VisitArrayTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
 DependentSizedArrayTypeLoc TL) {
   VisitArrayTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
 DependentSizedExtVectorTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
   Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record);
   Writer.AddSourceLocation(TL.getLParenLoc(), Record);
@@ -555,47 +575,59 @@
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Writer.AddDeclRef(TL.getParam(i), Record);
 }
+
 void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
   VisitFunctionTypeLoc(TL);
 }
+
 void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
   Writer.AddSourceLocation(TL.getNameLoc(), Record);
 }
+
 void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
   Writer.AddSourceLocation(TL.getTypeofLoc(), Record);
   Writer.AddSourceLocation(TL.getLParenLoc(), Record);
   Writer.AddSourceLocation(TL.getRParenLoc(), Record);
 }
+
 void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
   Writer.AddSourceLocation(TL.getTypeofLoc(), Record);
   

r264235 - The time when -faltivec (or, on clang only, -maltivec) will magically

2016-03-23 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Mar 23 20:26:08 2016
New Revision: 264235

URL: http://llvm.org/viewvc/llvm-project?rev=264235=rev
Log:
The time when -faltivec (or, on clang only, -maltivec) will magically
include altivec.h has come and gone.

Rationale: This causes modules, rewrite-includes, etc to be sad and
people should just include altivec.h in their source.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c
cfe/trunk/test/CodeGen/builtins-ppc-quadword.c
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
cfe/trunk/test/Parser/cxx-altivec.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=264235=264234=264235=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Mar 23 20:26:08 2016
@@ -2002,10 +2002,6 @@ static void ParsePreprocessorArgs(Prepro
   for (const Arg *A : Args.filtered(OPT_chain_include))
 Opts.ChainedIncludes.emplace_back(A->getValue());
 
-  // Include 'altivec.h' if -faltivec option present
-  if (Args.hasArg(OPT_faltivec))
-Opts.Includes.emplace_back("altivec.h");
-
   for (const Arg *A : Args.filtered(OPT_remap_file)) {
 std::pair Split = 
StringRef(A->getValue()).split(';');
 

Modified: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-altivec.c?rev=264235=264234=264235=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c Wed Mar 23 20:26:08 2016
@@ -6,8 +6,11 @@
 // RUN: %clang_cc1 -faltivec -triple powerpc64le-unknown-unknown -emit-llvm %s 
\
 // RUN:-o - | FileCheck %s -check-prefix=CHECK-LE
 // RUN: not %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
-// RUN:-ferror-limit 0 -o - 2>&1 \
+// RUN:-ferror-limit 0 -DNO_ALTIVEC -o - 2>&1 \
 // RUN:| FileCheck %s -check-prefix=CHECK-NOALTIVEC
+#ifndef NO_ALTIVEC
+#include 
+#endif
 
 vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 };
 vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, 
-14, 15, -16 };

Modified: cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c?rev=264235=264234=264235=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c Wed Mar 23 20:26:08 2016
@@ -6,6 +6,7 @@
 // generate the correct errors for functions that are only overloaded with VSX
 // (vec_cmpge, vec_cmple). Without this option, there is only one overload so
 // it is selected.
+#include 
 
 void dummy() { }
 signed int si;

Modified: cfe/trunk/test/CodeGen/builtins-ppc-quadword.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-quadword.c?rev=264235=264234=264235=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-quadword.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-quadword.c Wed Mar 23 20:26:08 2016
@@ -8,6 +8,7 @@
 
 // RUN: not %clang_cc1 -faltivec -triple powerpc-unknown-unknown \
 // RUN: -emit-llvm %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PPC
+#include 
 
 // CHECK-PPC: error: __int128 is not supported on this target
 vector signed __int128 vlll = { -1 };

Modified: cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-vsx.c?rev=264235=264234=264235=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-vsx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-vsx.c Wed Mar 23 20:26:08 2016
@@ -1,6 +1,7 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple 
powerpc64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -faltivec -target-feature +vsx -triple 
powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s 
-check-prefix=CHECK-LE
+#include 
 
 vector signed char vsc = { -8,  9, -10, 11, -12, 13, -14, 15,
-0,  1,  -2,  3,  -4,  5,  -6,  7};

Modified: cfe/trunk/test/Parser/cxx-altivec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-altivec.cpp?rev=264235=264234=264235=diff
==
--- cfe/trunk/test/Parser/cxx-altivec.cpp (original)
+++ cfe/trunk/test/Parser/cxx-altivec.cpp Wed 

Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

> Depending on how strictly you define "initialized" here, this is either 
> unhelpful or difficult to chpatterneck.


s/chpatterneck/check/


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D18271#382082, @rnk wrote:

> In http://reviews.llvm.org/D18271#381769, @rsmith wrote:
>
> > I think a reasonable approach would be: "do not warn on shadowing if the 
> > idiom of naming a constructor parameter after a class member is used, and 
> > the class member is initialized from that constructor parameter,
>


Depending on how strictly you define "initialized" here, this is either 
unhelpful or difficult to chpatterneck. Consider following examples:

  class C1 {
T field;
  public:
void set_field(T f) {
  field = f;
  // do something else...
}
C1(T field) { set_field(field); }
  };
  
  class C2 {
T1 f1;
T2 f2;
  public:
C2(T1 f1, T2 f2) {
  // Some form of initialization of `this->field` from `field` that is not 
just a copy construction/copy/move,
  // e.g. a method call or an assignment of a single member:
  this->f1.a = f1.a;
  this->f2.CopyFrom(f2);
}
  };

I've seen these patterns being used in the real code, and they don't seem to be 
dangerous or otherwise worth being flagged by this diagnostic.

> > and all uses of the parameter in the constructor body would still be valid 
> > if it were declared `const`".

> 


That might also be overly restrictive. Consider a variant of set_field above 
that takes a `T&` (which is weird, but it doesn't seem like -Wshadow is the 
right warning in this case).

> That sounds like the right check, but I don't have a lot of time to work on 
> this and I don't want to let the perfect be the enemy of the good. Do you 
> think is a reasonable half-way point for us to leave it for the next year or 
> so?

> 

> > In particular, I think we should probably warn if a non-const reference is 
> > bound to the parameter, or if the constructor's member initializer list 
> > does not contain `field(field)`.

> 


See above. There are many cases, when at least the latter pattern is used in a 
reasonable way.


http://reviews.llvm.org/D18271



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


r264229 - Display const/volatile/restrict qualifiers in Visual Studio visualizations

2016-03-23 Thread Mike Spertus via cfe-commits
Author: mps
Date: Wed Mar 23 19:38:54 2016
New Revision: 264229

URL: http://llvm.org/viewvc/llvm-project?rev=264229=rev
Log:
Display const/volatile/restrict qualifiers in Visual Studio visualizations

Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=264229=264228=264229=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Wed Mar 23 19:38:54 2016
@@ -182,11 +182,23 @@ or create a symbolic link so it updates
 typename {*TTPDecl,view(cpp)}
   
   
-
-{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType,view(poly)}
-{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType,view(cpp)}
-{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType}
+
+{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType,view(poly)}{*this,view(fastQuals)}
+{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType,view(cpp)}{*this,view(fastQuals)}
+
+
+{" ",sb}const
+{" ",sb}restrict
+{" ",sb}const restrict
+{" ",sb}volatile
+{" ",sb}const volatile
+{" ",sb}volatile restrict
+{" ",sb}const volatile restrict
+Cannot visualize non-fast 
qualifiers
+{*((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType}{*this,view(fastQuals)}
 
+  *this,view(fastQuals)
   *((clang::ExtQualsTypeCommonBase 
*)(((uintptr_t)Value.Value)  ~(uintptr_t)((1  4) - 
1)))-BaseType
 
   


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


r264227 - Modules builds are necessarily compile actions, but they don't

2016-03-23 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Mar 23 19:34:02 2016
New Revision: 264227

URL: http://llvm.org/viewvc/llvm-project?rev=264227=rev
Log:
Modules builds are necessarily compile actions, but they don't
necessarily produce object files. Turn off split dwarf if we're not
producing a file that the driver believes is an object file.

Added:
cfe/trunk/test/Driver/split-debug.h
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=264227=264226=264227=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Mar 23 19:34:02 2016
@@ -5737,7 +5737,7 @@ void Clang::ConstructJob(Compilation ,
   // Handle the debug info splitting at object creation time if we're
   // creating an object.
   // TODO: Currently only works on linux with newer objcopy.
-  if (SplitDwarf && !isa(JA) && !isa(JA))
+  if (SplitDwarf && Output.getType() == types::TY_Object)
 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut);
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))

Added: cfe/trunk/test/Driver/split-debug.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.h?rev=264227=auto
==
--- cfe/trunk/test/Driver/split-debug.h (added)
+++ cfe/trunk/test/Driver/split-debug.h Wed Mar 23 19:34:02 2016
@@ -0,0 +1,15 @@
+// Check that we aren't splitting debug output for modules builds that don't 
produce object files.
+//
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+//
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-emit-module -fmodules-embed-all-files -fno-implicit-modules 
-fno-implicit-module-maps -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+//
+// FIXME: This should fail using clang, except that the type of the output for
+// an object output with modules is given as clang::driver::types::TY_PCH
+// rather than TY_Object.
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -fmodules 
-fmodule-format=obj -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+//
+// CHECK-NO-ACTIONS-NOT: objcopy


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


r264226 - NFC: clarify comment on lock-free macros

2016-03-23 Thread JF Bastien via cfe-commits
Author: jfb
Date: Wed Mar 23 19:20:44 2016
New Revision: 264226

URL: http://llvm.org/viewvc/llvm-project?rev=264226=rev
Log:
NFC: clarify comment on lock-free macros

Used by both libstdc++ and libc++.

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=264226=264225=264226=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Mar 23 19:20:44 2016
@@ -811,7 +811,7 @@ static void InitializePredefinedMacros(c
 // FIXME: This is target-dependent.
 Builder.defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1");
 
-// Used by libstdc++ to implement ATOMIC__LOCK_FREE.
+// Used by libc++ and libstdc++ to implement ATOMIC__LOCK_FREE.
 unsigned InlineWidthBits = TI.getMaxAtomicInlineWidth();
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
 Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \


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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51495.
jlebar added a comment.

Add check for __global__ constexpr functions.


http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/host-device-constexpr.cu
  test/SemaCUDA/no-host-device-constexpr.cu

Index: test/SemaCUDA/no-host-device-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/no-host-device-constexpr.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+// Check that, with -fno-cuda-host-device-constexpr, constexpr functions are
+// host-only, and __device__ constexpr functions are still device-only.
+
+constexpr int f() { return 0; } // expected-note {{not viable}}
+__device__ constexpr int g() { return 0; } // expected-note {{not viable}}
+
+void __device__ foo() {
+  f(); // expected-error {{no matching function}}
+  g();
+}
+
+void __host__ foo() {
+  f();
+  g(); // expected-error {{no matching function}}
+}
Index: test/SemaCUDA/host-device-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/host-device-constexpr.cu
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-is-device
+
+#include "Inputs/cuda.h"
+
+// Opaque types used to determine which overload we're invoking.
+struct HostReturnTy {};
+struct DeviceReturnTy {};
+struct HostDeviceReturnTy {};
+
+// These shouldn't become host+device because they already have attributes.
+__host__ constexpr int HostOnly() { return 0; }
+// expected-note@-1 0+ {{not viable}}
+__device__ constexpr int DeviceOnly() { return 0; }
+// expected-note@-1 0+ {{not viable}}
+
+__host__ HostReturnTy Overloaded1();
+constexpr HostDeviceReturnTy Overloaded1() { return HostDeviceReturnTy(); }
+
+__device__ DeviceReturnTy Overloaded2();
+constexpr HostDeviceReturnTy Overloaded2() { return HostDeviceReturnTy(); }
+
+__host__ void HostFn() {
+  HostOnly();
+  DeviceOnly(); // expected-error {{no matching function}}
+  HostReturnTy x = Overloaded1();
+  HostDeviceReturnTy y = Overloaded2();
+}
+
+__device__ void DeviceFn() {
+  HostOnly(); // expected-error {{no matching function}}
+  DeviceOnly();
+  HostDeviceReturnTy x = Overloaded1();
+  DeviceReturnTy y = Overloaded2();
+}
+
+__host__ __device__ void HostDeviceFn() {
+#ifdef __CUDA_ARCH__
+  constexpr HostDeviceReturnTy x = Overloaded1();
+  DeviceReturnTy y = Overloaded2();
+#else
+  HostReturnTy x = Overloaded1();
+  constexpr HostDeviceReturnTy y = Overloaded2();
+#endif
+}
+
+// Check that a constexpr function can overload a __device__ function, and
+// that, in particular, we don't get errors if one of them is static and the
+// other isn't.
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -39,22 +39,18 @@
 __host__ HostReturnTy dh() { return HostReturnTy(); }
 __device__ DeviceReturnTy dh() { return DeviceReturnTy(); }
 
-// H/HD and D/HD are not allowed.
-__host__ __device__ int hdh() { return 0; } // expected-note {{previous definition is here}}
-__host__ int hdh() { return 0; }// expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are also OK.
+__host__ __device__ HostDeviceReturnTy hdh() { return HostDeviceReturnTy(); }
+__host__ HostReturnTy hdh() { return HostReturnTy(); }
 
-__host__ int hhd() { return 0; }// expected-note {{previous definition is here}}
-__host__ __device__ int hhd() { return 0; } // expected-error {{redefinition of 'hhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__host__ HostReturnTy hhd() { return HostReturnTy(); }
+__host__ __device__ HostDeviceReturnTy hhd() { return HostDeviceReturnTy(); }
 
-__host__ __device__ int hdd() { return 0; } // expected-note {{previous definition is here}}
-__device__ int hdd() { return 0; }  // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ HostDeviceReturnTy hdd() { return HostDeviceReturnTy(); }
+__device__ DeviceReturnTy hdd() 

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:8011-8013
@@ +8010,5 @@
+  // allowed, so we just treat those as host-only.
+  if (getLangOpts().CUDA && getLangOpts().CUDAHostDeviceConstexpr &&
+  NewFD->isConstexpr() && !NewFD->isVariadic() &&
+  !NewFD->hasAttr() && !NewFD->hasAttr()) {
+NewFD->addAttr(CUDAHostAttr::CreateImplicit(Context));

tra wrote:
> Can we have constexpr `__global__`  ?
Yikes.  We're saved (unless Richard has a tricky counterexample) because 
kernels must be void and constexpr must not be void.  But I'll add a check here 
anyway.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:46
@@ +45,3 @@
+BindArgument B;
+if (const auto * M = dyn_cast(E)) {
+  const auto * TE = M->GetTemporaryExpr();

In LLVM style this should be `const auto *M`.
Please clang-format the file.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:48
@@ +47,3 @@
+  const auto * TE = M->GetTemporaryExpr();
+  if (dyn_cast(TE))
+B.Kind = BK_CallExpr;

Please use `isa` instead of `dyn_cast`, when you don't need the pointer 
returned by `dyn_cast`.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:49
@@ +48,3 @@
+  if (dyn_cast(TE))
+B.Kind = BK_CallExpr;
+  else

I'd prefer to use the conditional operator here: `B.Kind = isa(TE) ? 
BK_CallExpr : BK_Temporary;`.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:116
@@ +115,3 @@
+  Finder->addMatcher(
+  callExpr(callee(namedDecl(isStdBind())),
+   hasArgument(0, declRefExpr(to(functionDecl().bind("f")

You should be able to use `hasName("std::bind")` instead.


Comment at: docs/clang-tidy/checks/readability-avoid-std-bind.rst:6
@@ +5,3 @@
+
+Find uses of ``std::bind``. Replace simple uses of ``std::bind`` with lambdas.
+Lambdas will use value-capture where required.

"The check finds uses of ..."


Comment at: docs/clang-tidy/checks/readability-avoid-std-bind.rst:9
@@ +8,3 @@
+
+Right now it only handles free functions not member functions.
+

Add a comma before "not"?


Comment at: docs/clang-tidy/checks/readability-avoid-std-bind.rst:11
@@ +10,3 @@
+
+Fixits are only generated for simple uses of ``std::bind``.
+

Please add an example or two of what code is flagged and what suggested fixes 
are.


http://reviews.llvm.org/D16962



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


r264216 - clang-cl: Add a FIXME for bumping the default msc version.

2016-03-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar 23 18:26:59 2016
New Revision: 264216

URL: http://llvm.org/viewvc/llvm-project?rev=264216=rev
Log:
clang-cl: Add a FIXME for bumping the default msc version.

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=264216=264215=264216=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Mar 23 18:26:59 2016
@@ -3259,6 +3259,7 @@ VersionTuple visualstudio::getMSVCVersio
 if (Major || Minor || Micro)
   return VersionTuple(Major, Minor, Micro);
 
+// FIXME: Consider bumping this to 19 (MSVC2015) soon.
 return VersionTuple(18);
   }
   return VersionTuple();


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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D18271#381769, @rsmith wrote:

> I think a reasonable approach would be: "do not warn on shadowing if the 
> idiom of naming a constructor parameter after a class member is used, and the 
> class member is initialized from that constructor parameter, and all uses of 
> the parameter in the constructor body would still be valid if it were 
> declared `const`".


That sounds like the right check, but I don't have a lot of time to work on 
this and I don't want to let the perfect be the enemy of the good. Do you think 
is a reasonable half-way point for us to leave it for the next year or so?

> In particular, I think we should probably warn if a non-const reference is 
> bound to the parameter, or if the constructor's member initializer list does 
> not contain `field(field)`.


Would the reference binding check be somewhere in SemaInit.cpp? I don't see an 
obvious spot to do this check at first glance.

> (I agree that catching `A(X x) : x(std::move(x)) { use(x); }` is outside the 
> scope of this change.)


Wouldn't the proposed check for non-const references find this example, though?



Comment at: lib/Sema/SemaDecl.cpp:6400
@@ +6399,3 @@
+if (isa(NewDC) && isa(D))
+  return;
+  }

rsmith wrote:
> Instead of redoing class member lookup every time we check to see if a 
> variable is modifiable, perhaps you could populate a set of 
> shadowed-but-not-diagnosed `VarDecl*`s here? That way, you can also suppress 
> the duplicate diagnostics if the variable is modified multiple times by 
> removing it from the set.
That sounds like a good idea. I could even leave it empty if we're not doing 
-Wshadow.


Comment at: lib/Sema/SemaExpr.cpp:9663
@@ +9662,3 @@
+  if (!S.getLangOpts().CPlusPlus ||
+  S.Diags.isIgnored(diag::warn_decl_shadow, Loc))
+return;

rsmith wrote:
> This query is actually quite expensive (more so than some or all of the other 
> checks below).
This check has to be faster than name lookup, right? Maybe do it before that?


http://reviews.llvm.org/D18271



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


r264211 - Fix typo in test from r264210, sigh.

2016-03-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar 23 18:01:38 2016
New Revision: 264211

URL: http://llvm.org/viewvc/llvm-project?rev=264211=rev
Log:
Fix typo in test from r264210, sigh.

(The test passes both with and without this change, but it's confusing without
it.)

Modified:
cfe/trunk/test/Misc/diag-format.c

Modified: cfe/trunk/test/Misc/diag-format.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-format.c?rev=264211=264210=264211=diff
==
--- cfe/trunk/test/Misc/diag-format.c (original)
+++ cfe/trunk/test/Misc/diag-format.c Wed Mar 23 18:01:38 2016
@@ -17,7 +17,7 @@
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=vi%s 2>&1 | FileCheck %s 
-check-prefix=VI
 //
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column 
-fmsc-version=1500 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015_ORIG
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column 
-fmsc-version=1900 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015_ORIG
 //
 // RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s 
-check-prefix=NO_COLUMN
 //
@@ -40,7 +40,7 @@
 // MSVC: {{.*}}(36,8) : warning: extra tokens at end of #endif directive 
[-Wextra-tokens]
 // MSVC2015: {{.*}}(36,8): warning: extra tokens at end of #endif directive 
[-Wextra-tokens]
 // VI: {{.*}} +36:8: warning: extra tokens at end of #endif directive 
[-Wextra-tokens]
-// MSVC2015_ORIG: {{.*}}(36) : warning: extra tokens at end of #endif 
directive [-Wextra-tokens]
+// MSVC2015_ORIG: {{.*}}(36): warning: extra tokens at end of #endif directive 
[-Wextra-tokens]
 // NO_COLUMN: {{.*}}:36: warning: extra tokens at end of #endif directive 
[-Wextra-tokens]
 // MSVC2010-FALLBACK: {{.*}}(36,7) : error(clang): extra tokens at end of 
#endif directive
 // MSVC2013-FALLBACK: {{.*}}(36,8) : error(clang): extra tokens at end of 
#endif directive


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


r264210 - clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

2016-03-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar 23 17:57:55 2016
New Revision: 264210

URL: http://llvm.org/viewvc/llvm-project?rev=264210=rev
Log:
clang-cl: With -fmsc-version=1900, use MSVS2015 diag formatting.

Remove tests that have neither a triple nor an explicit -fmsc-version flag,
since in the absence of an -fmsc-version flag, the implicit value of the flag
is 17 (MSVC2013) with MSVC triples but 0 (not set) for other triples, and
the default triple is platform dependent.

This relands r263974 with a test fix.

Modified:
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
cfe/trunk/test/Misc/diag-format.c

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=264210=264209=264210=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Wed Mar 23 17:57:55 2016
@@ -819,7 +819,15 @@ void TextDiagnostic::emitDiagnosticLoc(S
   switch (DiagOpts->getFormat()) {
   case DiagnosticOptions::Clang:
   case DiagnosticOptions::Vi:OS << ':';break;
-  case DiagnosticOptions::MSVC:  OS << ") : "; break;
+  case DiagnosticOptions::MSVC:
+// MSVC2013 and before print 'file(4) : error'. MSVC2015 gets rid of the
+// space and prints 'file(4): error'.
+OS << ')';
+if (LangOpts.MSCompatibilityVersion &&
+!LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015))
+  OS << ' ';
+OS << ": ";
+break;
   }
 
   if (DiagOpts->ShowSourceRanges && !Ranges.empty()) {

Modified: cfe/trunk/test/Misc/diag-format.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-format.c?rev=264210=264209=264210=diff
==
--- cfe/trunk/test/Misc/diag-format.c (original)
+++ cfe/trunk/test/Misc/diag-format.c Wed Mar 23 17:57:55 2016
@@ -4,27 +4,27 @@
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300  %s 
2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00  %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc  %s 2>&1 | FileCheck %s 
-check-prefix=MSVC
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
-target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
%s 2>&1 | FileCheck %s -check-prefix=MSVC
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1800 
-target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2013
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
%s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1900 
-target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc 
-fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 2>&1 
| FileCheck %s -check-prefix=MSVC2010
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1800 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2013
 // RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 
-fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1900 
-target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2015
 //
 // RUN: %clang -fsyntax-only -fdiagnostics-format=vi%s 2>&1 | FileCheck %s 
-check-prefix=VI
 //
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column %s 
2>&1 | FileCheck %s -check-prefix=MSVC_ORIG
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column 
-fmsc-version=1500 %s 2>&1 | FileCheck %s -check-prefix=MSVC2015_ORIG
 //
 // RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s 
-check-prefix=NO_COLUMN
 //
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback 
-fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
 // RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback 
-fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s 
-check-prefix=MSVC2010-FALLBACK
-// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 
2>&1 | FileCheck %s -check-prefix=MSVC-FALLBACK
-
-
-
-
+// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback 
-fmsc-version=1800 %s 

Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D18264#381846, @baloghadamsoftware wrote:

> Oh, I was searching in the C++ Core Guidlines, but at the wrong place because 
> I did not find it. So I will change this option to be enabled by default. DSL 
> users who do not follow this rule for the non copy and non move assign 
> operators can disable it.


I'd go without the option until we find a use case for it in real code.



Comment at: clang-tidy/misc/AssignOperatorSignatureCheck.cpp:48
@@ +47,3 @@
+  .bind("method");
+  const auto IsSelfAssign =
+  cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf

Just do whatever `clang-format -style=llvm` does.


http://reviews.llvm.org/D18264



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


Re: [PATCH] D18385: [CUDA] Simplify SemaCUDA/function-overload.cu test.

2016-03-23 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264206: [CUDA] Simplify SemaCUDA/function-overload.cu test. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D18385?vs=51382=51484#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18385

Files:
  cfe/trunk/test/SemaCUDA/function-overload.cu

Index: cfe/trunk/test/SemaCUDA/function-overload.cu
===
--- cfe/trunk/test/SemaCUDA/function-overload.cu
+++ cfe/trunk/test/SemaCUDA/function-overload.cu
@@ -16,187 +16,182 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)(void);
-typedef void (*gp_t)(void);
+typedef int (*fp_t)();
+typedef void (*gp_t)();
 
-// Host and unattributed functions can't be overloaded
-__host__ int hh(void) { return 1; } // expected-note {{previous definition is here}}
-int hh(void) { return 1; } // expected-error {{redefinition of 'hh'}}
+// Host and unattributed functions can't be overloaded.
+__host__ void hh() {} // expected-note {{previous definition is here}}
+void hh() {} // expected-error {{redefinition of 'hh'}}
+
+// H/D overloading is OK.
+__host__ int dh() { return 2; }
+__device__ int dh() { return 2; }
+
+// H/HD and D/HD are not allowed.
+__host__ __device__ int hdh() { return 5; } // expected-note {{previous definition is here}}
+__host__ int hdh() { return 4; } // expected-error {{redefinition of 'hdh'}}
 
-// H/D overloading is OK
-__host__ int dh(void) { return 2; }
-__device__ int dh(void) { return 2; }
-
-// H/HD and D/HD are not allowed
-__host__ __device__ int hdh(void) { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh(void) { return 4; } // expected-error {{redefinition of 'hdh'}}
-
-__host__ int hhd(void) { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd(void) { return 5; } // expected-error {{redefinition of 'hhd'}}
+__host__ int hhd() { return 4; } // expected-note {{previous definition is here}}
+__host__ __device__ int hhd() { return 5; } // expected-error {{redefinition of 'hhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-__host__ __device__ int hdd(void) { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd(void) { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd() { return 7; } // expected-note {{previous definition is here}}
+__device__ int hdd() { return 6; } // expected-error {{redefinition of 'hdd'}}
 
-__device__ int dhd(void) { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd(void) { return 7; } // expected-error {{redefinition of 'dhd'}}
+__device__ int dhd() { return 6; } // expected-note {{previous definition is here}}
+__host__ __device__ int dhd() { return 7; } // expected-error {{redefinition of 'dhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-// Same tests for extern "C" functions
-extern "C" __host__ int chh(void) {return 11;} // expected-note {{previous definition is here}}
-extern "C" int chh(void) {return 11;} // expected-error {{redefinition of 'chh'}}
-
-// H/D overloading is OK
-extern "C" __device__ int cdh(void) {return 10;}
-extern "C" __host__ int cdh(void) {return 11;}
+// Same tests for extern "C" functions.
+extern "C" __host__ int chh() {return 11;} // expected-note {{previous definition is here}}
+extern "C" int chh() {return 11;} // expected-error {{redefinition of 'chh'}}
+
+// H/D overloading is OK.
+extern "C" __device__ int cdh() {return 10;}
+extern "C" __host__ int cdh() {return 11;}
 
 // H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1(void) {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1(void) {return 13;} // expected-error {{redefinition of 'chhd1'}}
+extern "C" __host__ __device__ int chhd1() {return 12;} // expected-note {{previous definition is here}}
+extern "C" __host__ int chhd1() {return 13;} // expected-error {{redefinition of 'chhd1'}}
 
-extern "C" __host__ int chhd2(void) {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2(void) {return 12;} // expected-error {{redefinition of 'chhd2'}}
+extern "C" __host__ int chhd2() {return 13;} // expected-note {{previous definition is here}}
+extern "C" __host__ __device__ int chhd2() {return 12;} // expected-error {{redefinition of 'chhd2'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
 // Helper functions to verify calling restrictions.
-__device__ int d(void) { return 8; }
-__host__ int h(void) { return 9; }
-__global__ void g(void) {}
-extern "C" __device__ int cd(void) {return 10;}
-extern "C" __host__ int ch(void) 

r264207 - [CUDA] Merge most of CodeGenCUDA/function-overload.cu into SemaCUDA/function-overload.cu.

2016-03-23 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Mar 23 17:42:30 2016
New Revision: 264207

URL: http://llvm.org/viewvc/llvm-project?rev=264207=rev
Log:
[CUDA] Merge most of CodeGenCUDA/function-overload.cu into 
SemaCUDA/function-overload.cu.

Summary:
Previously we were using the codegen test to ensure that we choose the
right overload.  But we can do this within sema, with a bit of
cleverness.

I left the constructor/destructor checks in CodeGen, because these
overloads (particularly on the destructors) are hard to check in Sema.

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/CodeGenCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/function-overload.cu

Modified: cfe/trunk/test/CodeGenCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/function-overload.cu?rev=264207=264206=264207=diff
==
--- cfe/trunk/test/CodeGenCUDA/function-overload.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/function-overload.cu Wed Mar 23 17:42:30 2016
@@ -1,7 +1,9 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 
-// Make sure we handle target overloads correctly.
+// Make sure we handle target overloads correctly.  Most of this is checked in
+// sema, but special functions like constructors and destructors are here.
+//
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
 // RUN: -fcuda-target-overloads -emit-llvm -o - %s \
 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
@@ -23,235 +25,8 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)(void);
-typedef void (*gp_t)(void);
-
-// CHECK-HOST: @hp = global i32 ()* @_Z1hv
-// CHECK-HOST: @chp = global i32 ()* @ch
-// CHECK-HOST: @dhp = global i32 ()* @_Z2dhv
-// CHECK-HOST: @cdhp = global i32 ()* @cdh
-// CHECK-HOST: @gp = global void ()* @_Z1gv
-
-// CHECK-BOTH-LABEL: define i32 @_Z2dhv()
-__device__ int dh(void) { return 1; }
-// CHECK-DEVICE: ret i32 1
-__host__ int dh(void) { return 2; }
-// CHECK-HOST:   ret i32 2
-
-// CHECK-BOTH-LABEL: define i32 @_Z2hdv()
-__host__ __device__ int hd(void) { return 3; }
-// CHECK-BOTH:   ret i32 3
-
-// CHECK-DEVICE-LABEL: define i32 @_Z1dv()
-__device__ int d(void) { return 8; }
-// CHECK-DEVICE:   ret i32 8
-
-// CHECK-HOST-LABEL: define i32 @_Z1hv()
-__host__ int h(void) { return 9; }
-// CHECK-HOST:   ret i32 9
-
-// CHECK-BOTH-LABEL: define void @_Z1gv()
-__global__ void g(void) {}
-// CHECK-BOTH:   ret void
-
-// mangled names of extern "C" __host__ __device__ functions clash
-// with those of their __host__/__device__ counterparts, so
-// overloading of extern "C" functions can only happen for __host__
-// and __device__ functions -- we never codegen them in the same
-// compilation and therefore mangled name conflict is not a problem.
-
-// CHECK-BOTH-LABEL: define i32 @cdh()
-extern "C" __device__ int cdh(void) {return 10;}
-// CHECK-DEVICE:   ret i32 10
-extern "C" __host__ int cdh(void) {return 11;}
-// CHECK-HOST: ret i32 11
-
-// CHECK-DEVICE-LABEL: define i32 @cd()
-extern "C" __device__ int cd(void) {return 12;}
-// CHECK-DEVICE:   ret i32 12
-
-// CHECK-HOST-LABEL: define i32 @ch()
-extern "C" __host__ int ch(void) {return 13;}
-// CHECK-HOST: ret i32 13
-
-// CHECK-BOTH-LABEL: define i32 @chd()
-extern "C" __host__ __device__ int chd(void) {return 14;}
-// CHECK-BOTH: ret i32 14
-
-// HD functions are sometimes allowed to call H or D functions -- this
-// is an artifact of the source-to-source splitting performed by nvcc
-// that we need to mimic. During device mode compilation in nvcc, host
-// functions aren't present at all, so don't participate in
-// overloading. But in clang, H and D functions are present in both
-// compilation modes. Clang normally uses the target attribute as a
-// tiebreaker between overloads with otherwise identical priority, but
-// in order to match nvcc's behavior, we sometimes need to wholly
-// discard overloads that would not be present during compilation
-// under nvcc.
-
-template  T template_vs_function(T arg) { return 15; }
-__device__ float template_vs_function(float arg) { return 16; }
-
-// Here we expect to call the templated function during host
-// compilation, even if -fcuda-disable-target-call-checks is passed,
-// and even though C++ overload rules prefer the non-templated
-// function.
-// CHECK-BOTH-LABEL: define void @_Z5hd_tfv()
-__host__ __device__ void hd_tf(void) {
-  template_vs_function(1.0f);
-  // CHECK-HOST: call float @_Z20template_vs_functionIfET_S0_(float
-  // CHECK-DEVICE: call float @_Z20template_vs_functionf(float
-  template_vs_function(2.0);
-  // CHECK-HOST: call double @_Z20template_vs_functionIdET_S0_(double
-  // CHECK-DEVICE: call float @_Z20template_vs_functionf(float
-}
-
-// Calls from __host__ and __device__ functions should always call the
-// overloaded function that matches their mode.
-// 

Re: [PATCH] D18386: [CUDA] Merge most of CodeGenCUDA/function-overload.cu into SemaCUDA/function-overload.cu.

2016-03-23 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264207: [CUDA] Merge most of 
CodeGenCUDA/function-overload.cu into SemaCUDA/function… (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D18386?vs=51383=51485#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18386

Files:
  cfe/trunk/test/CodeGenCUDA/function-overload.cu
  cfe/trunk/test/SemaCUDA/function-overload.cu

Index: cfe/trunk/test/SemaCUDA/function-overload.cu
===
--- cfe/trunk/test/SemaCUDA/function-overload.cu
+++ cfe/trunk/test/SemaCUDA/function-overload.cu
@@ -16,58 +16,80 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)();
-typedef void (*gp_t)();
+// Opaque return types used to check that we pick the right overloads.
+struct HostReturnTy {};
+struct HostReturnTy2 {};
+struct DeviceReturnTy {};
+struct DeviceReturnTy2 {};
+struct HostDeviceReturnTy {};
+struct TemplateReturnTy {};
+
+typedef HostReturnTy (*HostFnPtr)();
+typedef DeviceReturnTy (*DeviceFnPtr)();
+typedef HostDeviceReturnTy (*HostDeviceFnPtr)();
+typedef void (*GlobalFnPtr)();  // __global__ functions must return void.
+
+// CurrentReturnTy is {HostReturnTy,DeviceReturnTy} during {host,device}
+// compilation.
+#ifdef __CUDA_ARCH__
+typedef DeviceReturnTy CurrentReturnTy;
+#else
+typedef HostReturnTy CurrentReturnTy;
+#endif
+
+// CurrentFnPtr is a function pointer to a {host,device} function during
+// {host,device} compilation.
+typedef CurrentReturnTy (*CurrentFnPtr)();
 
 // Host and unattributed functions can't be overloaded.
 __host__ void hh() {} // expected-note {{previous definition is here}}
 void hh() {} // expected-error {{redefinition of 'hh'}}
 
 // H/D overloading is OK.
-__host__ int dh() { return 2; }
-__device__ int dh() { return 2; }
+__host__ HostReturnTy dh() { return HostReturnTy(); }
+__device__ DeviceReturnTy dh() { return DeviceReturnTy(); }
 
 // H/HD and D/HD are not allowed.
-__host__ __device__ int hdh() { return 5; } // expected-note {{previous definition is here}}
-__host__ int hdh() { return 4; } // expected-error {{redefinition of 'hdh'}}
+__host__ __device__ int hdh() { return 0; } // expected-note {{previous definition is here}}
+__host__ int hdh() { return 0; }// expected-error {{redefinition of 'hdh'}}
 
-__host__ int hhd() { return 4; } // expected-note {{previous definition is here}}
-__host__ __device__ int hhd() { return 5; } // expected-error {{redefinition of 'hhd'}}
+__host__ int hhd() { return 0; }// expected-note {{previous definition is here}}
+__host__ __device__ int hhd() { return 0; } // expected-error {{redefinition of 'hhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-__host__ __device__ int hdd() { return 7; } // expected-note {{previous definition is here}}
-__device__ int hdd() { return 6; } // expected-error {{redefinition of 'hdd'}}
+__host__ __device__ int hdd() { return 0; } // expected-note {{previous definition is here}}
+__device__ int hdd() { return 0; }  // expected-error {{redefinition of 'hdd'}}
 
-__device__ int dhd() { return 6; } // expected-note {{previous definition is here}}
-__host__ __device__ int dhd() { return 7; } // expected-error {{redefinition of 'dhd'}}
+__device__ int dhd() { return 0; }  // expected-note {{previous definition is here}}
+__host__ __device__ int dhd() { return 0; } // expected-error {{redefinition of 'dhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
 // Same tests for extern "C" functions.
-extern "C" __host__ int chh() {return 11;} // expected-note {{previous definition is here}}
-extern "C" int chh() {return 11;} // expected-error {{redefinition of 'chh'}}
+extern "C" __host__ int chh() { return 0; } // expected-note {{previous definition is here}}
+extern "C" int chh() { return 0; }  // expected-error {{redefinition of 'chh'}}
 
 // H/D overloading is OK.
-extern "C" __device__ int cdh() {return 10;}
-extern "C" __host__ int cdh() {return 11;}
+extern "C" __device__ DeviceReturnTy cdh() { return DeviceReturnTy(); }
+extern "C" __host__ HostReturnTy cdh() { return HostReturnTy(); }
 
 // H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1() {return 12;} // expected-note {{previous definition is here}}
-extern "C" __host__ int chhd1() {return 13;} // expected-error {{redefinition of 'chhd1'}}
+extern "C" __host__ __device__ int chhd1() { return 0; } // expected-note {{previous definition is here}}
+extern "C" __host__ int chhd1() { return 0; }// expected-error {{redefinition of 'chhd1'}}
 
-extern "C" __host__ int chhd2() {return 13;} // expected-note {{previous definition is here}}
-extern "C" __host__ __device__ int chhd2() {return 12;} // expected-error {{redefinition of 

Re: [PATCH] D18417: [CUDA] Don't define __NVCC__.

2016-03-23 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264205: [CUDA] Don't define __NVCC__. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D18417?vs=51482=51483#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18417

Files:
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -199,7 +199,6 @@
 // Set up compiler macros expected to be seen during compilation.
 #undef __CUDABE__
 #define __CUDACC__
-#define __NVCC__
 
 #if defined(__CUDA_ARCH__)
 // We need to emit IR declaration for non-existing __nvvm_reflect() to


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -199,7 +199,6 @@
 // Set up compiler macros expected to be seen during compilation.
 #undef __CUDABE__
 #define __CUDACC__
-#define __NVCC__
 
 #if defined(__CUDA_ARCH__)
 // We need to emit IR declaration for non-existing __nvvm_reflect() to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r264206 - [CUDA] Simplify SemaCUDA/function-overload.cu test.

2016-03-23 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Mar 23 17:42:28 2016
New Revision: 264206

URL: http://llvm.org/viewvc/llvm-project?rev=264206=rev
Log:
[CUDA] Simplify SemaCUDA/function-overload.cu test.

Summary:
Principally, don't hardcode the line numbers of various notes.  This
lets us make changes to the test without recomputing linenos everywhere.

Instead, just tell -verify that we may get 0 or more notes pointing to
the relevant function definitions.  Checking that we get exactly the
right note isn't so important (and anyway is checked elsewhere).

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/SemaCUDA/function-overload.cu

Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=264206=264205=264206=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload.cu Wed Mar 23 17:42:28 2016
@@ -16,65 +16,85 @@
 
 #include "Inputs/cuda.h"
 
-typedef int (*fp_t)(void);
-typedef void (*gp_t)(void);
+typedef int (*fp_t)();
+typedef void (*gp_t)();
 
-// Host and unattributed functions can't be overloaded
-__host__ int hh(void) { return 1; } // expected-note {{previous definition is 
here}}
-int hh(void) { return 1; } // expected-error {{redefinition of 'hh'}}
-
-// H/D overloading is OK
-__host__ int dh(void) { return 2; }
-__device__ int dh(void) { return 2; }
-
-// H/HD and D/HD are not allowed
-__host__ __device__ int hdh(void) { return 5; } // expected-note {{previous 
definition is here}}
-__host__ int hdh(void) { return 4; } // expected-error {{redefinition of 
'hdh'}}
+// Host and unattributed functions can't be overloaded.
+__host__ void hh() {} // expected-note {{previous definition is here}}
+void hh() {} // expected-error {{redefinition of 'hh'}}
+
+// H/D overloading is OK.
+__host__ int dh() { return 2; }
+__device__ int dh() { return 2; }
+
+// H/HD and D/HD are not allowed.
+__host__ __device__ int hdh() { return 5; } // expected-note {{previous 
definition is here}}
+__host__ int hdh() { return 4; } // expected-error {{redefinition of 'hdh'}}
 
-__host__ int hhd(void) { return 4; } // expected-note {{previous definition is 
here}}
-__host__ __device__ int hhd(void) { return 5; } // expected-error 
{{redefinition of 'hhd'}}
+__host__ int hhd() { return 4; } // expected-note {{previous definition is 
here}}
+__host__ __device__ int hhd() { return 5; } // expected-error {{redefinition 
of 'hhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-__host__ __device__ int hdd(void) { return 7; } // expected-note {{previous 
definition is here}}
-__device__ int hdd(void) { return 6; } // expected-error {{redefinition of 
'hdd'}}
+__host__ __device__ int hdd() { return 7; } // expected-note {{previous 
definition is here}}
+__device__ int hdd() { return 6; } // expected-error {{redefinition of 'hdd'}}
 
-__device__ int dhd(void) { return 6; } // expected-note {{previous definition 
is here}}
-__host__ __device__ int dhd(void) { return 7; } // expected-error 
{{redefinition of 'dhd'}}
+__device__ int dhd() { return 6; } // expected-note {{previous definition is 
here}}
+__host__ __device__ int dhd() { return 7; } // expected-error {{redefinition 
of 'dhd'}}
 // expected-warning@-1 {{attribute declaration must precede definition}}
 // expected-note@-3 {{previous definition is here}}
 
-// Same tests for extern "C" functions
-extern "C" __host__ int chh(void) {return 11;} // expected-note {{previous 
definition is here}}
-extern "C" int chh(void) {return 11;} // expected-error {{redefinition of 
'chh'}}
-
-// H/D overloading is OK
-extern "C" __device__ int cdh(void) {return 10;}
-extern "C" __host__ int cdh(void) {return 11;}
+// Same tests for extern "C" functions.
+extern "C" __host__ int chh() {return 11;} // expected-note {{previous 
definition is here}}
+extern "C" int chh() {return 11;} // expected-error {{redefinition of 'chh'}}
+
+// H/D overloading is OK.
+extern "C" __device__ int cdh() {return 10;}
+extern "C" __host__ int cdh() {return 11;}
 
 // H/HD and D/HD overloading is not allowed.
-extern "C" __host__ __device__ int chhd1(void) {return 12;} // expected-note 
{{previous definition is here}}
-extern "C" __host__ int chhd1(void) {return 13;} // expected-error 
{{redefinition of 'chhd1'}}
+extern "C" __host__ __device__ int chhd1() {return 12;} // expected-note 
{{previous definition is here}}
+extern "C" __host__ int chhd1() {return 13;} // expected-error {{redefinition 
of 'chhd1'}}
 
-extern "C" __host__ int chhd2(void) {return 13;} // expected-note {{previous 
definition is here}}
-extern "C" __host__ __device__ int chhd2(void) {return 12;} // expected-error 
{{redefinition of 'chhd2'}}
+extern "C" __host__ int chhd2() {return 13;} 

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:8011-8013
@@ +8010,5 @@
+  // allowed, so we just treat those as host-only.
+  if (getLangOpts().CUDA && getLangOpts().CUDAHostDeviceConstexpr &&
+  NewFD->isConstexpr() && !NewFD->isVariadic() &&
+  !NewFD->hasAttr() && !NewFD->hasAttr()) {
+NewFD->addAttr(CUDAHostAttr::CreateImplicit(Context));

Can we have constexpr `__global__`  ?


http://reviews.llvm.org/D18380



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


[PATCH] D18417: [CUDA] Don't define __NVCC__.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

We decided this makes life too difficult for code authors.  For example,
people may want to detect NVCC and disable variadic templates, which
NVCC does not support, but which we do.

Since people are going to have to change compiler flags *anyway* in
order to compile with clang, if they really want the old behavior, they
can pass -D__NVCC__.

Tested with tensorflow and thrust, no apparent problems.

http://reviews.llvm.org/D18417

Files:
  lib/Headers/__clang_cuda_runtime_wrapper.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -199,7 +199,6 @@
 // Set up compiler macros expected to be seen during compilation.
 #undef __CUDABE__
 #define __CUDACC__
-#define __NVCC__
 
 #if defined(__CUDA_ARCH__)
 // We need to emit IR declaration for non-existing __nvvm_reflect() to


Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -199,7 +199,6 @@
 // Set up compiler macros expected to be seen during compilation.
 #undef __CUDABE__
 #define __CUDACC__
-#define __NVCC__
 
 #if defined(__CUDA_ARCH__)
 // We need to emit IR declaration for non-existing __nvvm_reflect() to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18416: [CUDA] Remove three obsolete CUDA cc1 flags.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, rsmith.

* -fcuda-target-overloads

  Previously unconditionally set to true by the driver.  Necessary for
  correct functioning of the compiler -- our CUDA headers wrapper won't
  compile without this.

* -fcuda-disable-target-call-checks

  Previously unconditionally set to true by the driver.  Necessary to
  compile almost any external CUDA code -- almost all libraries assume
  that host+device code can call host or device functions.

* -fcuda-allow-host-calls-from-host-device

  No effect when target overloading is enabled.

http://reviews.llvm.org/D18416

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Sema.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGenCUDA/function-overload.cu
  test/CodeGenCUDA/host-device-calls-host.cu
  test/SemaCUDA/builtins.cu
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/function-target-disabled-check.cu
  test/SemaCUDA/function-target-hd.cu
  test/SemaCUDA/implicit-intrinsic.cu
  test/SemaCUDA/implicit-member-target-collision-cxx11.cu
  test/SemaCUDA/method-target.cu

Index: test/SemaCUDA/method-target.cu
===
--- test/SemaCUDA/method-target.cu
+++ test/SemaCUDA/method-target.cu
@@ -44,7 +44,7 @@
 };
 
 __host__ __device__ void foo4(S4& s) {
-  s.method(); // expected-error {{reference to __device__ function 'method' in __host__ __device__ function}}
+  s.method();
 }
 
 //--
Index: test/SemaCUDA/implicit-member-target-collision-cxx11.cu
===
--- test/SemaCUDA/implicit-member-target-collision-cxx11.cu
+++ test/SemaCUDA/implicit-member-target-collision-cxx11.cu
@@ -74,13 +74,11 @@
 struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor {
 };
 
-// expected-note@-3 {{candidate constructor (the implicit default constructor}} not viable
-// expected-note@-4 {{implicit copy constructor inferred target collision}}
-// expected-note@-5 {{candidate constructor (the implicit copy constructor}} not viable
+// expected-note@-3 {{copy constructor of 'C4_with_collision' is implicitly deleted because base class 'B4_with_device_copy_ctor' has no copy constructor}}
 
 void hostfoo4() {
   C4_with_collision c;
-  C4_with_collision c2 = c; // expected-error {{no matching constructor}}
+  C4_with_collision c2 = c; // expected-error {{call to implicitly-deleted copy constructor of 'C4_with_collision'}}
 }
 
 //--
Index: test/SemaCUDA/implicit-intrinsic.cu
===
--- test/SemaCUDA/implicit-intrinsic.cu
+++ test/SemaCUDA/implicit-intrinsic.cu
@@ -1,7 +1,5 @@
 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device \
 // RUN: -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device \
-// RUN: -fcuda-target-overloads -fsyntax-only -verify %s
 
 #include "Inputs/cuda.h"
 
Index: test/SemaCUDA/function-target-hd.cu
===
--- test/SemaCUDA/function-target-hd.cu
+++ /dev/null
@@ -1,71 +0,0 @@
-// Test the Sema analysis of caller-callee relationships of host device
-// functions when compiling CUDA code. There are 4 permutations of this test as
-// host and device compilation are separate compilation passes, and clang has
-// an option to allow host calls from host device functions. __CUDA_ARCH__ is
-// defined when compiling for the device and TEST_WARN_HD when host calls are
-// allowed from host device functions. So for example, if __CUDA_ARCH__ is
-// defined and TEST_WARN_HD is not then device compilation is happening but
-// host device functions are not allowed to call device functions.
-
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -triple nvptx-unknown-cuda -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-allow-host-calls-from-host-device -verify %s -DTEST_WARN_HD
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -triple nvptx-unknown-cuda -fcuda-allow-host-calls-from-host-device -verify %s -DTEST_WARN_HD
-
-#include "Inputs/cuda.h"
-
-__host__ void hd1h(void);
-#if defined(__CUDA_ARCH__) && !defined(TEST_WARN_HD)
-// expected-note@-2 {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
-#endif
-__device__ void hd1d(void);
-#ifndef __CUDA_ARCH__
-// expected-note@-2 {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
-#endif
-__host__ void hd1hg(void);
-__device__ void hd1dg(void);
-#ifdef 

Re: [PATCH] D16993: Add missing __builtin_bitreverse8

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

r264203


http://reviews.llvm.org/D16993



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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Changed as discussed.  Please have another look.  Thank you for your continued 
patience here.


http://reviews.llvm.org/D18380



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


r264203 - Add missing __builtin_bitreverse8

2016-03-23 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Wed Mar 23 17:14:43 2016
New Revision: 264203

URL: http://llvm.org/viewvc/llvm-project?rev=264203=rev
Log:
Add missing __builtin_bitreverse8

Also add documentation for bitreverse builtins

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=264203=264202=264203=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Wed Mar 23 17:14:43 2016
@@ -1505,6 +1505,33 @@ C-style cast applied to each element of
 
 Query for this feature with ``__has_builtin(__builtin_convertvector)``.
 
+``__builtin_bitreverse``
+-
+
+* ``__builtin_bitreverse8``
+* ``__builtin_bitreverse16``
+* ``__builtin_bitreverse32``
+* ``__builtin_bitreverse64``
+
+**Syntax**:
+
+.. code-block:: c++
+ __builtin_bitreverse32(x)
+
+**Examples**:
+
+.. code-block:: c++
+  uint8_t rev_x = __builtin_bitreverse8(x);
+  uint16_t rev_x = __builtin_bitreverse16(x);
+  uint32_t rev_y = __builtin_bitreverse32(y);
+  uint64_t rev_z = __builtin_bitreverse64(z);
+
+**Description**:
+
+The '``__builtin_bitreverse``' family of builtins is used to reverse
+the bitpattern of an integer value; for example ``0b10110110`` becomes
+``0b01101101``.
+
 ``__builtin_unreachable``
 -
 

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=264203=264202=264203=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Mar 23 17:14:43 2016
@@ -409,6 +409,7 @@ BUILTIN(__builtin_bswap16, "UsUs", "nc")
 BUILTIN(__builtin_bswap32, "UiUi", "nc")
 BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
 
+BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
 BUILTIN(__builtin_bitreverse32, "UiUi", "nc")
 BUILTIN(__builtin_bitreverse64, "ULLiULLi", "nc")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=264203=264202=264203=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Mar 23 17:14:43 2016
@@ -681,6 +681,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_bswap64: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
+  case Builtin::BI__builtin_bitreverse8:
   case Builtin::BI__builtin_bitreverse16:
   case Builtin::BI__builtin_bitreverse32:
   case Builtin::BI__builtin_bitreverse64: {

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=264203=264202=264203=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Wed Mar 23 17:14:43 2016
@@ -117,9 +117,11 @@ int main() {
   P(bswap32, (N));
   P(bswap64, (N));
 
+  // CHECK: @llvm.bitreverse.i8
   // CHECK: @llvm.bitreverse.i16
   // CHECK: @llvm.bitreverse.i32
   // CHECK: @llvm.bitreverse.i64
+  P(bitreverse8, (N));
   P(bitreverse16, (N));
   P(bitreverse32, (N));
   P(bitreverse64, (N));


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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 51479.
jlebar added a comment.

Switch to -fno-cuda-host-device-constexpr.  Only implicitly add the attributes
on functions which themselves lack host/device attributes.  Add more tests.


http://reviews.llvm.org/D18380

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/host-device-constexpr.cu
  test/SemaCUDA/no-host-device-constexpr.cu

Index: test/SemaCUDA/no-host-device-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/no-host-device-constexpr.cu
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fno-cuda-host-device-constexpr -fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+// Check that, with -fno-cuda-host-device-constexpr, constexpr functions are
+// host-only, and __device__ constexpr functions are still device-only.
+
+constexpr int f() { return 0; } // expected-note {{not viable}}
+__device__ constexpr int g() { return 0; } // expected-note {{not viable}}
+
+void __device__ foo() {
+  f(); // expected-error {{no matching function}}
+  g();
+}
+
+void __host__ foo() {
+  f();
+  g(); // expected-error {{no matching function}}
+}
Index: test/SemaCUDA/host-device-constexpr.cu
===
--- /dev/null
+++ test/SemaCUDA/host-device-constexpr.cu
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcuda-is-device
+
+#include "Inputs/cuda.h"
+
+// Opaque types used to determine which overload we're invoking.
+struct HostReturnTy {};
+struct DeviceReturnTy {};
+struct HostDeviceReturnTy {};
+
+// These shouldn't become host+device because they already have attributes.
+__host__ constexpr int HostOnly() { return 0; }
+// expected-note@-1 0+ {{not viable}}
+__device__ constexpr int DeviceOnly() { return 0; }
+// expected-note@-1 0+ {{not viable}}
+
+__host__ HostReturnTy Overloaded1();
+constexpr HostDeviceReturnTy Overloaded1() { return HostDeviceReturnTy(); }
+
+__device__ DeviceReturnTy Overloaded2();
+constexpr HostDeviceReturnTy Overloaded2() { return HostDeviceReturnTy(); }
+
+__host__ void HostFn() {
+  HostOnly();
+  DeviceOnly(); // expected-error {{no matching function}}
+  HostReturnTy x = Overloaded1();
+  HostDeviceReturnTy y = Overloaded2();
+}
+
+__device__ void DeviceFn() {
+  HostOnly(); // expected-error {{no matching function}}
+  DeviceOnly();
+  HostDeviceReturnTy x = Overloaded1();
+  DeviceReturnTy y = Overloaded2();
+}
+
+__host__ __device__ void HostDeviceFn() {
+#ifdef __CUDA_ARCH__
+  constexpr HostDeviceReturnTy x = Overloaded1();
+  DeviceReturnTy y = Overloaded2();
+#else
+  HostReturnTy x = Overloaded1();
+  constexpr HostDeviceReturnTy y = Overloaded2();
+#endif
+}
+
+// Check that a constexpr function can overload a __device__ function, and
+// that, in particular, we don't get errors if one of them is static and the
+// other isn't.
+static __device__ void f1();
+constexpr void f1();
+
+__device__ void f2();
+static constexpr void f2();
+
+// Different potential error depending on the order of declaration.
+constexpr void f3();
+static __device__ void f3();
+
+static constexpr void f4();
+__device__ void f4();
+
+// Variadic device functions are not allowed, so this is just treated as
+// host-only.
+constexpr void variadic(const char*, ...);
Index: test/SemaCUDA/function-overload.cu
===
--- test/SemaCUDA/function-overload.cu
+++ test/SemaCUDA/function-overload.cu
@@ -39,22 +39,18 @@
 __host__ HostReturnTy dh() { return HostReturnTy(); }
 __device__ DeviceReturnTy dh() { return DeviceReturnTy(); }
 
-// H/HD and D/HD are not allowed.
-__host__ __device__ int hdh() { return 0; } // expected-note {{previous definition is here}}
-__host__ int hdh() { return 0; }// expected-error {{redefinition of 'hdh'}}
+// H/HD and D/HD are also OK.
+__host__ __device__ HostDeviceReturnTy hdh() { return HostDeviceReturnTy(); }
+__host__ HostReturnTy hdh() { return HostReturnTy(); }
 
-__host__ int hhd() { return 0; }// expected-note {{previous definition is here}}
-__host__ __device__ int hhd() { return 0; } // expected-error {{redefinition of 'hhd'}}
-// expected-warning@-1 {{attribute declaration must precede definition}}
-// expected-note@-3 {{previous definition is here}}
+__host__ HostReturnTy hhd() { return HostReturnTy(); }
+__host__ __device__ HostDeviceReturnTy hhd() { return HostDeviceReturnTy(); }
 
-__host__ __device__ int hdd() { return 0; } // expected-note {{previous definition is here}}
-__device__ int hdd() { return 0; }  // expected-error {{redefinition of 'hdd'}}

Re: [PATCH] D18385: [CUDA] Simplify SemaCUDA/function-overload.cu test.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar marked an inline comment as done.
jlebar added a comment.

One comment is done, will be reflected when I submit.  Thank you!


http://reviews.llvm.org/D18385



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


Re: [PATCH] D16993: Add missing __builtin_bitreverse8

2016-03-23 Thread Matt Arsenault via cfe-commits
arsenm added inline comments.


Comment at: docs/LanguageExtensions.rst:1533
@@ +1532,3 @@
+the bitpattern of an integer value; for example ``0b1234567`` becomes
+``0b7654321``.
+

rsmith wrote:
> This example doesn't make much sense: it looks like it's bit reversing a 7 
> bit number containing non-binary digits? Can you provide a real example 
> instead?
This was copied from the IR description. I fixed it there, I'll fix it again 
here


http://reviews.llvm.org/D16993



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


r264196 - ObjC: add getter/setter for class properties to global pool.

2016-03-23 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Mar 23 16:39:31 2016
New Revision: 264196

URL: http://llvm.org/viewvc/llvm-project?rev=264196=rev
Log:
ObjC: add getter/setter for class properties to global pool.

rdar://problem/25323072

Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/objc-class-property.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=264196=264195=264196=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Wed Mar 23 16:39:31 2016
@@ -2308,6 +2308,11 @@ void Sema::ProcessPropertyDecl(ObjCPrope
   AddInstanceMethodToGlobalPool(GetterMethod);
 if (SetterMethod)
   AddInstanceMethodToGlobalPool(SetterMethod);
+  } else {
+if (GetterMethod)
+  AddFactoryMethodToGlobalPool(GetterMethod);
+if (SetterMethod)
+  AddFactoryMethodToGlobalPool(SetterMethod);
   }
 
   ObjCInterfaceDecl *CurrentClass = dyn_cast(CD);

Modified: cfe/trunk/test/SemaObjC/objc-class-property.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-class-property.m?rev=264196=264195=264196=diff
==
--- cfe/trunk/test/SemaObjC/objc-class-property.m (original)
+++ cfe/trunk/test/SemaObjC/objc-class-property.m Wed Mar 23 16:39:31 2016
@@ -33,3 +33,11 @@ int test() {
   A *a = [[A alloc] init];
   return a.x + A.c;
 }
+
+void message_id(id me) {
+  [me y];
+}
+
+void message_class(Class me) {
+  [me c2];
+}


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


Re: [PATCH] D18171: [CUDA][OpenMP] Create generic offload action

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar added a comment.

> @jlebar: Justin, any suggestions on what we can/should do regarding [const 
> correctness issues]?


Using "mutable" to work around const-incorrectness should be a last resort.  
I've been frustrated by the const-incorrectness of Action as well, but if it's 
an issue here, I think it needs to be fixed, not hacked around.


http://reviews.llvm.org/D18171



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


Re: [PATCH] D18171: [CUDA][OpenMP] Create generic offload action

2016-03-23 Thread Artem Belevich via cfe-commits
tra added a comment.

Thank you for making these changes. They don't solve all the shortcomings, but 
they improve things quite a bit, IMO.

Overall I'm happy with the changes, though use of mutable and changing action 
state from const functions may need a look from someone with better C++-fu 
skills than myself.
@jlebar: Justin, any suggestions on what we can/should do regarding that?



Comment at: include/clang/Driver/Action.h:95
@@ +94,3 @@
+  /// same host. Therefore, the host offloading kind is a combination of kinds.
+  mutable unsigned OffloadingHostKind;
+  /// \brief Offloading kind of the device.

I assume that by combination you imply that this is a mask of all offloading 
kinds we intend to use.
Perhaps it should be renamed to reflect it better. ActiveOffloadKindMask?


Comment at: include/clang/Driver/Action.h:95
@@ +94,3 @@
+  /// same host. Therefore, the host offloading kind is a combination of kinds.
+  mutable unsigned OffloadingHostKind;
+  /// \brief Offloading kind of the device.

tra wrote:
> I assume that by combination you imply that this is a mask of all offloading 
> kinds we intend to use.
> Perhaps it should be renamed to reflect it better. ActiveOffloadKindMask?
These fields appears to be part of the Action state yet you want to modify them 
from const functions which seems wrong to me. Perhaps functions that set these 
fields should not be const.


Comment at: include/clang/Driver/Action.h:137
@@ +136,3 @@
+  /// dependences.
+  void propagateDeviceOffloadInfo(OffloadKind OKind, const char *OArch) const;
+  /// \brief Append the host offload info of this action and propagate it to 
its

propagateXXX implies modification which contradicts 'const' which implies that 
there will be no state change. Which one is telling the truth?


Comment at: include/clang/Driver/Action.h:208-215
@@ +207,10 @@
+  private:
+/// \brief The dependence action.
+ActionList AL;
+/// \brief The offloading toolchains that should be used with the action.
+SmallVector TCL;
+/// \brief The architectures that should be used with this action.
+SmallVector BAL;
+/// \brief The offload kind of each dependence.
+SmallVector KL;
+

Are these independent or is it expected that all four are populated/modified in 
sync? If they all need to be updated at the same time (which is what the code 
below does), it should be documented. Perhaps these arrays could be converted 
into vector of structs.


Comment at: include/clang/Driver/Action.h:220
@@ +219,3 @@
+/// offload kind.
+void add(Action *A, const ToolChain *TC, const char *BoundArch,
+ OffloadKind OKind);

Can any of parameters be nullptr?


Comment at: include/clang/Driver/Action.h:234-240
@@ +233,9 @@
+/// \brief The dependence action.
+Action *A;
+/// \brief The offloading toolchain that should be used with the action.
+const ToolChain *TC;
+/// \brief The architectures that should be used with this action.
+const char *BoundArch;
+/// \brief The offload kind of each dependence.
+unsigned OffloadKinds;
+

Cosmetic nit: Naming is somewhat inconsistent. Device dependencies use 
acronyms, but HostDependence uses mix of acronyms and words. I'd use camelcase 
words in both.


Comment at: include/clang/Driver/Driver.h:422
@@ -424,1 +421,3 @@
+ bool AtTopLevel, bool MultipleArchs,
+ const ToolChain *TC) const;
 

TC is only used to get triple to construct file name prefix. Perhaps just pass 
that string explicitly.


Comment at: lib/Driver/Action.cpp:44
@@ +43,3 @@
+void Action::propagateDeviceOffloadInfo(OffloadKind OKind,
+const char *OArch) const {
+  // Offload action set its own kinds on their dependences.

Given that these functions change state they probably should not be const.


Comment at: lib/Driver/Action.cpp:103
@@ +102,3 @@
+
+std::string Action::getOffloadingFileNamePrefix(const ToolChain *TC) const {
+  // A file prefix is only generated for device actions and consists of the

There's no need for ToolChain here. A string is all it needs as an input.


Comment at: lib/Driver/Action.cpp:208
@@ +207,3 @@
+Action *OffloadAction::getSingleDeviceDependence() const {
+  return (!HostTC && getInputs().size() == 1) ? getInputs().front() : nullptr;
+}

returning nullptr if .size() != 1 looks strange. Perhaps there should be an 
assert.


Comment at: lib/Driver/Driver.cpp:1391-1395
@@ -1357,5 +1390,7 @@
 
+  const ToolChain *CudaTC =
+  C.getSingleOffloadDeviceToolChain();
+
   // Build actions for all device inputs.
-  

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

2016-03-23 Thread Richard Barton via cfe-commits
richard.barton.arm added a comment.

Hi Eric - no problem at all, you practically wrote it for me after all ;-)


http://reviews.llvm.org/D18347



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


[libcxx] r264191 - Guard a number of tests relying on threads support when built in

2016-03-23 Thread Richard Barton via cfe-commits
Author: rbarton
Date: Wed Mar 23 16:04:11 2016
New Revision: 264191

URL: http://llvm.org/viewvc/llvm-project?rev=264191=rev
Log:
Guard a number of tests relying on threads support when built in
single-threaded mode.

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


Modified:

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/copy_assign.fail.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp?rev=264191=264190=264191=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_annotations_not_enabled.pass.cpp
 Wed Mar 23 16:04:11 2016
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcpp-has-no-threads
+
 // 
 
 // This test does not define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS so it

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp?rev=264191=264190=264191=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp 
(original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp 
Wed Mar 23 16:04:11 2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcpp-has-no-threads
 // REQUIRES: thread-safety
 
 // 

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp?rev=264191=264190=264191=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp 
(original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_lock_unlock.pass.cpp 
Wed Mar 23 16:04:11 2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcpp-has-no-threads
 // REQUIRES: thread-safety
 
 // 

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp?rev=264191=264190=264191=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_missing_unlock.fail.cpp
 Wed Mar 23 16:04:11 2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// UNSUPPORTED: libcpp-has-no-threads
 // REQUIRES: thread-safety
 
 // 

Modified: 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.mutex/thread_safety_requires_capability.pass.cpp?rev=264191=264190=264191=diff

Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-23 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:859
@@ +858,3 @@
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = 
__atomic_always_lock_free(sizeof(__a_), 0);
+#endif

EricWF wrote:
> jfb wrote:
> > I don't think so: it's similar to `std::integral_constant<_Tp, __v>::value`.
> integral_constant::value has a definition on line 481 of type_traits.
Ha! I'd totally missed that. That explains why I was confused :-)

Added, thanks!


http://reviews.llvm.org/D17951



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-23 Thread JF Bastien via cfe-commits
jfb updated this revision to Diff 51473.
jfb added a comment.

- Add definition.


http://reviews.llvm.org/D17951

Files:
  include/atomic
  test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp

Index: test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
===
--- /dev/null
+++ test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03, c++11, c++14
+
+// 
+
+// static constexpr bool is_always_lock_free;
+
+#include 
+#include 
+
+template  void checkAlwaysLockFree() {
+  if (std::atomic::is_always_lock_free)
+assert(std::atomic().is_lock_free());
+}
+
+int main()
+{
+// structs and unions can't be defined in the template invocation.
+// Work around this with a typedef.
+#define CHECK_ALWAYS_LOCK_FREE(T)  \
+  do { \
+typedef T type;\
+checkAlwaysLockFree();   \
+  } while (0)
+
+CHECK_ALWAYS_LOCK_FREE(bool);
+CHECK_ALWAYS_LOCK_FREE(char);
+CHECK_ALWAYS_LOCK_FREE(signed char);
+CHECK_ALWAYS_LOCK_FREE(unsigned char);
+CHECK_ALWAYS_LOCK_FREE(char16_t);
+CHECK_ALWAYS_LOCK_FREE(char32_t);
+CHECK_ALWAYS_LOCK_FREE(wchar_t);
+CHECK_ALWAYS_LOCK_FREE(short);
+CHECK_ALWAYS_LOCK_FREE(unsigned short);
+CHECK_ALWAYS_LOCK_FREE(int);
+CHECK_ALWAYS_LOCK_FREE(unsigned int);
+CHECK_ALWAYS_LOCK_FREE(long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long);
+CHECK_ALWAYS_LOCK_FREE(long long);
+CHECK_ALWAYS_LOCK_FREE(unsigned long long);
+CHECK_ALWAYS_LOCK_FREE(std::nullptr_t);
+CHECK_ALWAYS_LOCK_FREE(void*);
+CHECK_ALWAYS_LOCK_FREE(float);
+CHECK_ALWAYS_LOCK_FREE(double);
+CHECK_ALWAYS_LOCK_FREE(long double);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(1 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(2 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(4 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(16 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(int __attribute__((vector_size(32 * sizeof(int);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(1 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(2 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(4 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(16 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(float __attribute__((vector_size(32 * sizeof(float);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(1 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(2 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(4 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(16 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(double __attribute__((vector_size(32 * sizeof(double);
+CHECK_ALWAYS_LOCK_FREE(struct{});
+CHECK_ALWAYS_LOCK_FREE(struct{ int i; });
+CHECK_ALWAYS_LOCK_FREE(struct{ int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[2]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[4]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[8]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ long long int i[16]; });
+CHECK_ALWAYS_LOCK_FREE(struct{ char c; /* padding */ long long int i; });
+CHECK_ALWAYS_LOCK_FREE(union{ int i; float f; });
+
+// C macro and static constexpr must be consistent.
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_BOOL_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR16_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_CHAR32_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_WCHAR_T_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_SHORT_LOCK_FREE));
+static_assert(std::atomic::is_always_lock_free == 

Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-23 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: include/atomic:859
@@ +858,3 @@
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = 
__atomic_always_lock_free(sizeof(__a_), 0);
+#endif

jfb wrote:
> I don't think so: it's similar to `std::integral_constant<_Tp, __v>::value`.
integral_constant::value has a definition on line 481 of type_traits.


http://reviews.llvm.org/D17951



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


Re: [PATCH] D17951: Implement is_always_lock_free

2016-03-23 Thread JF Bastien via cfe-commits
jfb added inline comments.


Comment at: include/atomic:859
@@ +858,3 @@
+#if defined(__cpp_lib_atomic_is_always_lock_free)
+  static _LIBCPP_CONSTEXPR bool is_always_lock_free = 
__atomic_always_lock_free(sizeof(__a_), 0);
+#endif

I don't think so: it's similar to `std::integral_constant<_Tp, __v>::value`.


http://reviews.llvm.org/D17951



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


r264189 - Make SemaAccess smarter about determining when a dependent class might

2016-03-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Mar 23 15:39:06 2016
New Revision: 264189

URL: http://llvm.org/viewvc/llvm-project?rev=264189=rev
Log:
Make SemaAccess smarter about determining when a dependent class might
instantiate to match a friend class declaration. It's still pretty dumb,
though.

Modified:
cfe/trunk/lib/Sema/SemaAccess.cpp
cfe/trunk/test/CXX/drs/dr5xx.cpp
cfe/trunk/test/SemaCXX/access.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/Sema/SemaAccess.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=264189=264188=264189=diff
==
--- cfe/trunk/lib/Sema/SemaAccess.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAccess.cpp Wed Mar 23 15:39:06 2016
@@ -291,9 +291,10 @@ static AccessResult IsDerivedFromInclusi
   SmallVector Queue; // actually a stack
 
   while (true) {
-if (Derived->isDependentContext() && !Derived->hasDefinition())
+if (Derived->isDependentContext() && !Derived->hasDefinition() &&
+!Derived->isLambda())
   return AR_dependent;
-
+
 for (const auto  : Derived->bases()) {
   const CXXRecordDecl *RD;
 
@@ -410,14 +411,8 @@ static AccessResult MatchesFriend(Sema &
 return AR_accessible;
 
   if (EC.isDependent()) {
-CanQualType FriendTy
-  = S.Context.getCanonicalType(S.Context.getTypeDeclType(Friend));
-
-for (EffectiveContext::record_iterator
-   I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
-  CanQualType ContextTy
-= S.Context.getCanonicalType(S.Context.getTypeDeclType(*I));
-  if (MightInstantiateTo(S, ContextTy, FriendTy))
+for (const CXXRecordDecl *Context : EC.Records) {
+  if (MightInstantiateTo(Context, Friend))
 return AR_dependent;
 }
   }

Modified: cfe/trunk/test/CXX/drs/dr5xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr5xx.cpp?rev=264189=264188=264189=diff
==
--- cfe/trunk/test/CXX/drs/dr5xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr5xx.cpp Wed Mar 23 15:39:06 2016
@@ -814,7 +814,7 @@ namespace dr577 { // dr577: yes
   }
 }
 
-namespace dr580 { // dr580: no
+namespace dr580 { // dr580: partial
   class C;
   struct A { static C c; };
   struct B { static C c; };
@@ -822,7 +822,7 @@ namespace dr580 { // dr580: no
 C(); // expected-note {{here}}
 ~C(); // expected-note {{here}}
 
-typedef int I; // expected-note {{here}}
+typedef int I; // expected-note 2{{here}}
 template struct X;
 template friend struct Y;
 template void f();
@@ -832,7 +832,20 @@ namespace dr580 { // dr580: no
 
   template struct C::X {};
   template struct Y {};
-  template struct Z {}; // FIXME: should reject, accepted because C 
befriends A!
+  template struct Z {}; // expected-error {{private}}
+
+  struct C2 {
+class X {
+  struct A;
+  typedef int I;
+  friend struct A;
+};
+class Y {
+  template struct A {}; // FIXME: We incorrectly accept this
+  // because we think C2::Y::A<...> might
+  // instantiate to C2::X::A
+};
+  };
 
   template void C::f() {}
   template void g() {}

Modified: cfe/trunk/test/SemaCXX/access.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access.cpp?rev=264189=264188=264189=diff
==
--- cfe/trunk/test/SemaCXX/access.cpp (original)
+++ cfe/trunk/test/SemaCXX/access.cpp Wed Mar 23 15:39:06 2016
@@ -167,5 +167,5 @@ namespace ThisLambdaIsNotMyFriend {
   template  void foo() {
 []() { A::foo(); }(); // expected-error {{private}}
   }
-  void bar() { foo(); } // expected-note {{instantiation}}
+  void bar() { foo(); }
 }

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=264189=264188=264189=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Wed Mar 23 15:39:06 2016
@@ -3523,7 +3523,7 @@ and POD class
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580;>580
 C++11
 Access in template-parameters of member and friend 
definitions
-No
+Partial
   
   
 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#581;>581


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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/CC1Options.td:702-703
@@ -701,2 +701,4 @@
   HelpText<"Allow variadic functions in CUDA device code.">;
+def fcuda_relaxed_constexpr : Flag<["-"], "fcuda-relaxed-constexpr">,
+  HelpText<"Treat constexpr functions as __host__ __device__.">;
 

rsmith wrote:
> jlebar wrote:
> > rsmith wrote:
> > > Is there a better name we can use for this? I don't think this is 
> > > "relaxed" in any obvious sense. `-fcuda-host-device-constexpr` or 
> > > `-fcuda-constexpr-on-device` might be clearer?
> > "relaxed constexpr" is nvidia's term -- do you think it might be helpful to 
> > use the same terminology?  I understand there's some prior art here, with 
> > respect to clang accepting gcc's flags, although the situation here is of 
> > course different.
> I think it's problematic to use that terminology, as "relaxed constexpr" is 
> also used to describe the C++14 `constexpr` rules (see 
> [n3652](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html)).
Heh, I can't argue with that.


Comment at: lib/Driver/Tools.cpp:3597
@@ -3596,2 +3596,3 @@
 CmdArgs.push_back("-fcuda-disable-target-call-checks");
+CmdArgs.push_back("-fcuda-relaxed-constexpr");
   }

rsmith wrote:
> jlebar wrote:
> > rsmith wrote:
> > > For flags that are enabled by default, we usually have the -cc1 flag be a 
> > > `-fno-*` flag. This allows people to use (for instance) `clang blah.cu 
> > > -Xclang -fno-cuda-relaxed-constexpr` if necessary.
> > Yeah, Artem and I had a discussion about this yesterday.  As you can see, 
> > there are two other flags above which are turned on by default -- these 
> > also lack -fno variants.
> > 
> > I think it would be good to be consistent here.  I'm tempted to add another 
> > patch below this one which makes the other two -fno, then we can make this 
> > one -fno as well.  It seems that convention is to just get rid of the 
> > existing non-fno flags, rather than leave both positive and negative 
> > versions.
> > 
> > Does that sound OK to you?
> Yes, that sounds fine.
Okay, thank you.  After talking to Artem, we're just going to remove those two 
flags entirely.  So after we convert relaxed-constexpr to an fno flag, there 
should be no changes to this file in this patch.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

2016-03-23 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D18412#381843, @dblaikie wrote:

> can you just match on the name of the template instead?


I'm not sure to get your point?

Are you proposing to match "basic_string" instead of the whole regexp?
I'm in favor of that change as I don't see any counter example or any false 
positive.

In fact, many checkers are using hasName("basic_string").
I just kept the change as minimal as possible to keep the same semantic and 
allow matching more cases.

Example from RedundantStringInitCheck.cpp:

  // Match string constructor.
  const auto StringConstructorExpr = expr(anyOf(
  cxxConstructExpr(argumentCountIs(1),
   hasDeclaration(cxxMethodDecl(hasName("basic_string",



Comment at: test/clang-tidy/readability-redundant-string-cstr.cpp:54
@@ +53,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+}

mamai wrote:
> Isn't this a copy-paste error to reference f1 ? Same question for line 62 and 
> 70...
Good catch.


http://reviews.llvm.org/D18412



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


Re: [PATCH] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

2016-03-23 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai added a subscriber: mamai.
mamai added a comment.

nit: in summary, consiring -> considering ?



Comment at: test/clang-tidy/readability-redundant-string-cstr.cpp:54
@@ +53,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+}

Isn't this a copy-paste error to reference f1 ? Same question for line 62 and 
70...


http://reviews.llvm.org/D18412



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


Re: [PATCH] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

2016-03-23 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 51464.
etienneb marked an inline comment as done.
etienneb added a comment.

Fix unittests.


http://reviews.llvm.org/D18412

Files:
  clang-tidy/readability/RedundantStringCStrCheck.cpp
  test/clang-tidy/readability-redundant-string-cstr.cpp

Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -12,14 +12,20 @@
   const C *c_str() const;
 };
 typedef basic_string 
string;
+typedef basic_string wstring;
+typedef basic_string u16string;
+typedef basic_string u32string;
 }
+
 namespace llvm {
 struct StringRef {
   StringRef(const char *p);
   StringRef(const std::string &);
 };
 }
 
+// Tests for std::string.
+
 void f1(const std::string ) {
   f1(s.c_str());
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
@@ -39,3 +45,27 @@
   // CHECK-FIXES: {{^  }}std::string s;{{$}}
   // CHECK-FIXES-NEXT: {{^  }}f3(s);{{$}}
 }
+
+// Tests for std::wstring.
+
+void g1(const std::wstring ) {
+  g1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}g1(s);{{$}}
+}
+
+// Tests for std::u16string.
+
+void h1(const std::u16string ) {
+  h1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}h1(s);{{$}}
+}
+
+// Tests for std::u32string.
+
+void k1(const std::u32string ) {
+  k1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}k1(s);{{$}}
+}
Index: clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -66,11 +66,11 @@
 }
 
 const char StringConstructor[] =
-"::std::basic_string"
+"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
 "::basic_string";
 
 const char StringCStrMethod[] =
-"::std::basic_string"
+"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
 "::c_str";
 
 } // end namespace
@@ -89,18 +89,18 @@
   const auto StringConstructorExpr = expr(anyOf(
   cxxConstructExpr(
   argumentCountIs(1),
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor,
+  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor,
   cxxConstructExpr(
   argumentCountIs(2),
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
+  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor))),
   // If present, the second argument is the alloc object which must not
   // be present explicitly.
   hasArgument(1, cxxDefaultArgExpr();
 
   // Match a call to the string 'c_str()' method.
-  const auto StringCStrCallExpr = cxxMemberCallExpr(
-callee(memberExpr().bind("member")),
-callee(cxxMethodDecl(hasName(StringCStrMethod))),
+  const auto StringCStrCallExpr =
+  cxxMemberCallExpr(callee(memberExpr().bind("member")),
+callee(cxxMethodDecl(matchesName(StringCStrMethod))),
 on(expr().bind("arg"))).bind("call");
 
   Finder->addMatcher(


Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -12,14 +12,20 @@
   const C *c_str() const;
 };
 typedef basic_string string;
+typedef basic_string wstring;
+typedef basic_string u16string;
+typedef basic_string u32string;
 }
+
 namespace llvm {
 struct StringRef {
   StringRef(const char *p);
   StringRef(const std::string &);
 };
 }
 
+// Tests for std::string.
+
 void f1(const std::string ) {
   f1(s.c_str());
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
@@ -39,3 +45,27 @@
   // CHECK-FIXES: {{^  }}std::string s;{{$}}
   // CHECK-FIXES-NEXT: {{^  }}f3(s);{{$}}
 }
+
+// Tests for std::wstring.
+
+void g1(const std::wstring ) {
+  g1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: 

Re: [PATCH] D18347: [PATCH] Fix thread_annotation negtest for thread safety.

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

LGTM! Thanks for the complete patch! The "no-threads" bot should now be green 
so future breakage will be detected immediately!


http://reviews.llvm.org/D18347



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


r264184 - Make sure to perform dependent access checks when instantiating a

2016-03-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Mar 23 15:07:07 2016
New Revision: 264184

URL: http://llvm.org/viewvc/llvm-project?rev=264184=rev
Log:
Make sure to perform dependent access checks when instantiating a
lambda-expression. We don't actually instantiate the closure type / operator()
in the template in order to produce the closure type / operator() in the
instantiation, so this isn't caught by the normal path.

Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaCXX/access.cpp

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=264184=264183=264184=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Wed Mar 23 15:07:07 2016
@@ -809,19 +809,14 @@ void Sema::ActOnStartOfLambdaDefinition(
   bool KnownDependent = false;
   LambdaScopeInfo *const LSI = getCurLambda();
   assert(LSI && "LambdaScopeInfo should be on stack!");
-  TemplateParameterList *TemplateParams = 
-getGenericLambdaTemplateParameterList(LSI, *this);
 
-  if (Scope *TmplScope = CurScope->getTemplateParamParent()) {
-// Since we have our own TemplateParams, so check if an outer scope
-// has template params, only then are we in a dependent scope.
-if (TemplateParams)  {
-  TmplScope = TmplScope->getParent();
-  TmplScope = TmplScope ? TmplScope->getTemplateParamParent() : nullptr;
-}
-if (TmplScope && !TmplScope->decl_empty())
+  // The lambda-expression's closure type might be dependent even if its
+  // semantic context isn't, if it appears within a default argument of a
+  // function template.
+  if (Scope *TmplScope = CurScope->getTemplateParamParent())
+if (!TmplScope->decl_empty())
   KnownDependent = true;
-  }
+
   // Determine the signature of the call operator.
   TypeSourceInfo *MethodTyInfo;
   bool ExplicitParams = true;

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=264184=264183=264184=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Wed Mar 23 15:07:07 2016
@@ -729,6 +729,11 @@ namespace {
   }
   
   SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
+
+  // We recreated a local declaration, but not by instantiating it. There
+  // may be pending dependent diagnostics to produce.
+  if (auto *DC = dyn_cast(Old))
+SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
 }
 
 /// \brief Transform the definition of the given declaration by

Modified: cfe/trunk/test/SemaCXX/access.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/access.cpp?rev=264184=264183=264184=diff
==
--- cfe/trunk/test/SemaCXX/access.cpp (original)
+++ cfe/trunk/test/SemaCXX/access.cpp Wed Mar 23 15:07:07 2016
@@ -158,3 +158,14 @@ namespace LocalExternVar {
 
   int array[sizeof(test::private_struct)]; // expected-error {{private}}
 }
+
+namespace ThisLambdaIsNotMyFriend {
+  class A {
+friend class D;
+static void foo(); // expected-note {{here}}
+  };
+  template  void foo() {
+[]() { A::foo(); }(); // expected-error {{private}}
+  }
+  void bar() { foo(); } // expected-note {{instantiation}}
+}


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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-23 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

Oh, I was searching in the C++ Core Guidlines, but at the wrong place because I 
did not find it. So I will change this option to be enabled by default. DSL 
users who do not follow this rule for the non copy and non move assign 
operators can disable it.


http://reviews.llvm.org/D18264



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


Re: [PATCH] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

2016-03-23 Thread David Blaikie via cfe-commits
can you just match on the name of the template instead?

On Wed, Mar 23, 2016 at 12:46 PM, Etienne Bergeron via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> etienneb created this revision.
> etienneb added a reviewer: alexfh.
> etienneb added a subscriber: cfe-commits.
>
> The current checker is able to recognize std::string but do not recognize
> other string variants.
> This path is adding the support for any string define with basic_string
> without consiring the
> the char type.
>
> The most common variant is: std::wstring based on wchar_t.
>
> There are also other string variants added to the standard: u16string,
> u32string, etc...
>
> http://reviews.llvm.org/D18412
>
> Files:
>   clang-tidy/readability/RedundantStringCStrCheck.cpp
>   test/clang-tidy/readability-redundant-string-cstr.cpp
>
> Index: test/clang-tidy/readability-redundant-string-cstr.cpp
> ===
> --- test/clang-tidy/readability-redundant-string-cstr.cpp
> +++ test/clang-tidy/readability-redundant-string-cstr.cpp
> @@ -12,14 +12,20 @@
>const C *c_str() const;
>  };
>  typedef basic_string
> string;
> +typedef basic_string std::allocator> wstring;
> +typedef basic_string std::allocator> u16string;
> +typedef basic_string std::allocator> u32string;
>  }
> +
>  namespace llvm {
>  struct StringRef {
>StringRef(const char *p);
>StringRef(const std::string &);
>  };
>  }
>
> +// Tests for std::string.
> +
>  void f1(const std::string ) {
>f1(s.c_str());
>// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()`
> [readability-redundant-string-cstr]
> @@ -39,3 +45,27 @@
>// CHECK-FIXES: {{^  }}std::string s;{{$}}
>// CHECK-FIXES-NEXT: {{^  }}f3(s);{{$}}
>  }
> +
> +// Tests for std::wstring.
> +
> +void g1(const std::wstring ) {
> +  g1(s.c_str());
> +  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()`
> [readability-redundant-string-cstr]
> +  // CHECK-FIXES: {{^  }}f1(s);{{$}}
> +}
> +
> +// Tests for std::u16string.
> +
> +void h1(const std::u16string ) {
> +  h1(s.c_str());
> +  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()`
> [readability-redundant-string-cstr]
> +  // CHECK-FIXES: {{^  }}f1(s);{{$}}
> +}
> +
> +// Tests for std::u32string.
> +
> +void k1(const std::u32string ) {
> +  k1(s.c_str());
> +  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()`
> [readability-redundant-string-cstr]
> +  // CHECK-FIXES: {{^  }}f1(s);{{$}}
> +}
> Index: clang-tidy/readability/RedundantStringCStrCheck.cpp
> ===
> --- clang-tidy/readability/RedundantStringCStrCheck.cpp
> +++ clang-tidy/readability/RedundantStringCStrCheck.cpp
> @@ -66,11 +66,11 @@
>  }
>
>  const char StringConstructor[] =
> -"::std::basic_string std::allocator >"
> +"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
>  "::basic_string";
>
>  const char StringCStrMethod[] =
> -"::std::basic_string std::allocator >"
> +"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
>  "::c_str";
>
>  } // end namespace
> @@ -89,18 +89,18 @@
>const auto StringConstructorExpr = expr(anyOf(
>cxxConstructExpr(
>argumentCountIs(1),
> -  hasDeclaration(cxxMethodDecl(hasName(StringConstructor,
> +  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor,
>cxxConstructExpr(
>argumentCountIs(2),
> -  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
> +  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor))),
>// If present, the second argument is the alloc object which
> must not
>// be present explicitly.
>hasArgument(1, cxxDefaultArgExpr();
>
>// Match a call to the string 'c_str()' method.
> -  const auto StringCStrCallExpr = cxxMemberCallExpr(
> -callee(memberExpr().bind("member")),
> -
> callee(cxxMethodDecl(hasName(StringCStrMethod))),
> +  const auto StringCStrCallExpr =
> +  cxxMemberCallExpr(callee(memberExpr().bind("member")),
> +
> callee(cxxMethodDecl(matchesName(StringCStrMethod))),
>  on(expr().bind("arg"))).bind("call");
>
>Finder->addMatcher(
>
>
>
> ___
> 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] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

2016-03-23 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

The current checker is able to recognize std::string but do not recognize other 
string variants.
This path is adding the support for any string define with basic_string without 
consiring the
the char type.

The most common variant is: std::wstring based on wchar_t.

There are also other string variants added to the standard: u16string, 
u32string, etc...

http://reviews.llvm.org/D18412

Files:
  clang-tidy/readability/RedundantStringCStrCheck.cpp
  test/clang-tidy/readability-redundant-string-cstr.cpp

Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -12,14 +12,20 @@
   const C *c_str() const;
 };
 typedef basic_string 
string;
+typedef basic_string wstring;
+typedef basic_string u16string;
+typedef basic_string u32string;
 }
+
 namespace llvm {
 struct StringRef {
   StringRef(const char *p);
   StringRef(const std::string &);
 };
 }
 
+// Tests for std::string.
+
 void f1(const std::string ) {
   f1(s.c_str());
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
@@ -39,3 +45,27 @@
   // CHECK-FIXES: {{^  }}std::string s;{{$}}
   // CHECK-FIXES-NEXT: {{^  }}f3(s);{{$}}
 }
+
+// Tests for std::wstring.
+
+void g1(const std::wstring ) {
+  g1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+}
+
+// Tests for std::u16string.
+
+void h1(const std::u16string ) {
+  h1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+}
+
+// Tests for std::u32string.
+
+void k1(const std::u32string ) {
+  k1(s.c_str());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` 
[readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+}
Index: clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -66,11 +66,11 @@
 }
 
 const char StringConstructor[] =
-"::std::basic_string"
+"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
 "::basic_string";
 
 const char StringCStrMethod[] =
-"::std::basic_string"
+"::std::basic_string<.*, std::char_traits<.*>, std::allocator<.*> >"
 "::c_str";
 
 } // end namespace
@@ -89,18 +89,18 @@
   const auto StringConstructorExpr = expr(anyOf(
   cxxConstructExpr(
   argumentCountIs(1),
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor,
+  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor,
   cxxConstructExpr(
   argumentCountIs(2),
-  hasDeclaration(cxxMethodDecl(hasName(StringConstructor))),
+  hasDeclaration(cxxMethodDecl(matchesName(StringConstructor))),
   // If present, the second argument is the alloc object which must not
   // be present explicitly.
   hasArgument(1, cxxDefaultArgExpr();
 
   // Match a call to the string 'c_str()' method.
-  const auto StringCStrCallExpr = cxxMemberCallExpr(
-callee(memberExpr().bind("member")),
-callee(cxxMethodDecl(hasName(StringCStrMethod))),
+  const auto StringCStrCallExpr =
+  cxxMemberCallExpr(callee(memberExpr().bind("member")),
+callee(cxxMethodDecl(matchesName(StringCStrMethod))),
 on(expr().bind("arg"))).bind("call");
 
   Finder->addMatcher(


Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -12,14 +12,20 @@
   const C *c_str() const;
 };
 typedef basic_string string;
+typedef basic_string wstring;
+typedef basic_string u16string;
+typedef basic_string u32string;
 }
+
 namespace llvm {
 struct StringRef {
   StringRef(const char *p);
   StringRef(const std::string &);
 };
 }
 
+// Tests for std::string.
+
 void f1(const std::string ) {
   f1(s.c_str());
   // CHECK-MESSAGES: 

Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Ben Craig via cfe-commits
bcraig added a subscriber: mclow.lists.
bcraig added a comment.

> > Not dblaikie, but I've used the GCC version of -Wshadow on reasonably large 
> > code bases before.  The ctor pattern that this is trying to squelch was 
> > certainly a significant portion of the warnings, particularly when (old) 
> > boost headers got involved.

> 

> > 

> 

> > I believe that newer versions of boost (~1.50 and newer?) attempt to be 
> > -Wshadow clean in the headers.

> 

> 

> Did squelching this ctor pattern find any bugs? Do you know if boost would 
> miss the warning firing in this case?


I don't recall fixing any bugs with the ctor pattern.  I can only recall two 
different classes of things that I have fixed that were flagged with -Wshadow.

1. Long, horrible, deeply nested method, with a local that was trivially 
shadowing a different local in a larger scope.
2. Mutex lock guards and similar "sentry" objects.  
"std::unique_lock(name_of_a_member);"  The user wanted that to lock 
'name_of_member' and release it at end of scope, but instead it declared a 
default constructed unique_lock called 'name_of_a_member' that shadows the 
member variable.  I've had to fix this kind of bug a number of times, and it is 
my main justification for turning on -Wshadow in the first place.  On that 
note, I'm really looking forward to the day I can say "auto guard = 
std::unique_lock(name_of_member);" to effectively get rid of this problem.

I doubt boost would miss the warning, and probably wouldn't even notice 
(barring overlapping list membership).  If you're really wondering if boost 
would care / notice, @mclow.lists would have a better idea.


http://reviews.llvm.org/D18271



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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-03-23 Thread Yaxun Liu via cfe-commits
yaxunl removed rL LLVM as the repository for this revision.
yaxunl updated this revision to Diff 51460.
yaxunl marked 13 inline comments as done.
yaxunl added a comment.

Added comments. Revised test.


http://reviews.llvm.org/D17412

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/address-spaces-conversions.cl
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl

Index: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -225,3 +225,69 @@
 // expected-error@-2{{passing '__constant int *' to parameter of type '__generic int *' changes address space of pointer}}
 #endif
 }
+
+void test_ternary() {
+  AS int *var_cond;
+  generic int *arg_gen;
+  global int *arg_glob;
+  arg_gen = 0 ? var_cond : arg_glob;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  local int *arg_loc;
+  arg_gen = 0 ? var_cond : arg_loc;
+#ifndef GENERIC
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  constant int *arg_const;
+  var_cond = 0 ? var_cond : arg_const;
+#ifndef CONSTANT
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  private int *arg_priv;
+  arg_gen = 0 ? var_cond : arg_priv;
+#ifndef GENERIC
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|constant}} int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_gen;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  void *var_void_gen;
+  global char *arg_glob_ch;
+  var_void_gen = 0 ? var_cond : arg_glob_ch;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  local char *arg_loc_ch;
+  var_void_gen = 0 ? var_cond : arg_loc_ch;
+#ifndef GENERIC
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|constant}} int *' and '__local char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  constant void *var_void_const;
+  constant char *arg_const_ch;
+  var_void_const = 0 ? var_cond : arg_const_ch;
+#ifndef CONSTANT
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|generic}} int *' and '__constant char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  private char *arg_priv_ch;
+  var_void_gen = 0 ? var_cond : arg_priv_ch;
+#ifndef GENERIC
+// expected-error-re@-2{{conditional operator with the second and third operands of type  ('__{{global|constant}} int *' and 'char *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  generic char *arg_gen_ch;
+  var_void_gen = 0 ? var_cond : arg_gen_ch;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__generic char *') which are pointers to non-overlapping address spaces}}
+#endif
+}
+
Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -3,20 +3,35 @@
 // test that we generate address space casts everywhere we need conversions of
 // pointers to different address spaces
 
-void test(global int *arg_glob, generic int *arg_gen) {
+void test(global int *arg_glob, generic int *arg_gen, global float *arg_glob_f,
+  generic void *arg_gen_v) {
   int var_priv;
+  
   arg_gen = arg_glob; // implicit cast global -> generic
   // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)*
+  
   arg_gen = _priv; // implicit cast with obtaining adr, private -> generic
   // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  
   arg_glob = (global int *)arg_gen; // explicit cast
   // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(4)* %{{[0-9]+}} to i32 addrspace(1)*
+  
   global int *var_glob =
   (global int *)arg_glob; // explicit cast in the same address space
   // CHECK-NOT: %{{[0-9]+}} = 

Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-03-23 Thread Mandeep Singh Grang via cfe-commits
mgrang added a subscriber: mgrang.


Comment at: include/clang/AST/ASTContext.h:903
@@ +902,3 @@
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   
\
+  CanQualType SingletonId;
+#include "clang/AST/OpenCLImageTypes.def"

remove extra spacing in front of the \


http://reviews.llvm.org/D17821



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


r264182 - clang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.

2016-03-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar 23 13:46:57 2016
New Revision: 264182

URL: http://llvm.org/viewvc/llvm-project?rev=264182=rev
Log:
clang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.

Instead of putting the /Yc header into ExtraDeps, give DependencyOutputOptions
a dedicated field for /Yc mode, and let HeaderIncludesCallback hang on to the
full DependencyOutputOptions object, not just ExtraDeps.

Reverts parts of r263352 that are now no longer needed.

Modified:
cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp
cfe/trunk/test/Driver/cl-pch-showincludes.cpp

Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=264182=264181=264182=diff
==
--- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Wed Mar 23 
13:46:57 2016
@@ -50,6 +50,9 @@ public:
   /// A list of filenames to be used as extra dependencies for every target.
   std::vector ExtraDeps;
 
+  /// In /showIncludes mode, pretend the main TU is a header with this name.
+  std::string ShowIncludesPretendHeader;
+
   /// \brief The file to write GraphViz-formatted header dependencies to.
   std::string DOTOutputFile;
 

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=264182=264181=264182=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Mar 23 13:46:57 2016
@@ -142,15 +142,13 @@ public:
 
 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach
 /// it to the given preprocessor.
-  void AttachDependencyGraphGen(Preprocessor , StringRef OutputFile,
-StringRef SysRoot);
+void AttachDependencyGraphGen(Preprocessor , StringRef OutputFile,
+  StringRef SysRoot);
 
 /// AttachHeaderIncludeGen - Create a header include list generator, and attach
 /// it to the given preprocessor.
 ///
-/// \param ExtraHeaders - If not empty, will write the header filenames, just
-/// like they were included during a regular preprocessing. Useful for
-/// implicit include dependencies, like sanitizer blacklists.
+/// \param DepOpts - Options controlling the output.
 /// \param ShowAllHeaders - If true, show all header information instead of 
just
 /// headers following the predefines buffer. This is useful for making sure
 /// includes mentioned on the command line are also reported, but differs from
@@ -160,7 +158,7 @@ public:
 /// \param ShowDepth - Whether to indent to show the nesting of the includes.
 /// \param MSStyle - Whether to print in cl.exe /showIncludes style.
 void AttachHeaderIncludeGen(Preprocessor ,
-const std::vector ,
+const DependencyOutputOptions ,
 bool ShowAllHeaders = false,
 StringRef OutputPath = "",
 bool ShowDepth = true, bool MSStyle = false);

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=264182=264181=264182=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Mar 23 13:46:57 2016
@@ -360,18 +360,18 @@ void CompilerInstance::createPreprocesso
 
   // Handle generating header include information, if requested.
   if (DepOpts.ShowHeaderIncludes)
-AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps);
+AttachHeaderIncludeGen(*PP, DepOpts);
   if (!DepOpts.HeaderIncludeOutputFile.empty()) {
 StringRef OutputPath = DepOpts.HeaderIncludeOutputFile;
 if (OutputPath == "-")
   OutputPath = "";
-AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps,
+AttachHeaderIncludeGen(*PP, DepOpts,
/*ShowAllHeaders=*/true, OutputPath,
/*ShowDepth=*/false);
   }
 
   if (DepOpts.PrintShowIncludes) {
-AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps,
+AttachHeaderIncludeGen(*PP, DepOpts,
/*ShowAllHeaders=*/true, /*OutputPath=*/"",
/*ShowDepth=*/true, /*MSStyle=*/true);
   }
@@ -765,7 +765,7 @@ bool CompilerInstance::InitializeSourceM
 /*SuggestedModule=*/nullptr, /*SkipCache=*/true);
   // Also add the header to /showIncludes output.
   if (File)
-

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Driver/CC1Options.td:702-703
@@ -701,2 +701,4 @@
   HelpText<"Allow variadic functions in CUDA device code.">;
+def fcuda_relaxed_constexpr : Flag<["-"], "fcuda-relaxed-constexpr">,
+  HelpText<"Treat constexpr functions as __host__ __device__.">;
 

jlebar wrote:
> rsmith wrote:
> > Is there a better name we can use for this? I don't think this is "relaxed" 
> > in any obvious sense. `-fcuda-host-device-constexpr` or 
> > `-fcuda-constexpr-on-device` might be clearer?
> "relaxed constexpr" is nvidia's term -- do you think it might be helpful to 
> use the same terminology?  I understand there's some prior art here, with 
> respect to clang accepting gcc's flags, although the situation here is of 
> course different.
I think it's problematic to use that terminology, as "relaxed constexpr" is 
also used to describe the C++14 `constexpr` rules (see 
[n3652](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html)).


Comment at: lib/Driver/Tools.cpp:3597
@@ -3596,2 +3596,3 @@
 CmdArgs.push_back("-fcuda-disable-target-call-checks");
+CmdArgs.push_back("-fcuda-relaxed-constexpr");
   }

jlebar wrote:
> rsmith wrote:
> > For flags that are enabled by default, we usually have the -cc1 flag be a 
> > `-fno-*` flag. This allows people to use (for instance) `clang blah.cu 
> > -Xclang -fno-cuda-relaxed-constexpr` if necessary.
> Yeah, Artem and I had a discussion about this yesterday.  As you can see, 
> there are two other flags above which are turned on by default -- these also 
> lack -fno variants.
> 
> I think it would be good to be consistent here.  I'm tempted to add another 
> patch below this one which makes the other two -fno, then we can make this 
> one -fno as well.  It seems that convention is to just get rid of the 
> existing non-fno flags, rather than leave both positive and negative versions.
> 
> Does that sound OK to you?
Yes, that sounds fine.


http://reviews.llvm.org/D18380



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-03-23 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Could you add the reduced false positives to the tests file?

> As far as I see the diagnostics are showing the proper path now..


What do you mean? Does this refer to supplying more information the the path 
about why the error occurs?



Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:12
@@ +11,3 @@
+//
+// ConversionChecker generates a subset of the warnings that are reported by
+// Wconversion. It is designed to be an alternative to Wconversion.

danielmarjamaki wrote:
> Thanks! I have tried to do that.
Can you describe what it does without referencing Wconversion? A reader might 
not know what that warning does.


Comment at: lib/StaticAnalyzer/Checkers/ConversionChecker.cpp:85
@@ +84,3 @@
+  if (!N)
+return;
+

danielmarjamaki wrote:
> I renamed and changed these functions. Hope we all like it better now. The 
> name is now "greaterEqualState" and it returns the state when the value is 
> greater or equal. If there is no such state it returns nullptr.
> 
> As far as I see the diagnostics are showing the proper path now..
Cppcheck is probably performing control-flow sensitive analysis, which is 
completely different than the algorithm that is used by the Clang Static 
Analyzer, which performs path-sensitive analysis. The meaning of may and must 
are different. It is very important to understand the fundamentals behind how 
the analyzer works. Please, watch the video and let me know if you are 
interested in more information on symbolic execution.

When we talk about possible values for a variable(or a symbol) along one path 
in the static analyzer we can have both may and must:
 - may be greater than: StGE != nullptr
 - is greater than: StGE && !StLT

The whole point behind "assumeDual" is to allow us to differentiate between 
them. Your function specifically only cares about the "must" case. It would be 
a bug if it checked that the state is a "may" state.


http://reviews.llvm.org/D13126



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


Re: [PATCH] D18275: [ASTMatchers] Add own version of VariadicFunction.

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Still LG.



Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:82
@@ +81,3 @@
+  ResultT operator()(ArrayRef Args) const {
+SmallVector InnerArgs;
+for (const ArgT  : Args)

> On the other hand, constructing the matchers has never been the performance 
> bottleneck of the framework.

I was confused then. I thought, the operator() in question gets called when 
traversing the AST, not when constructing the matcher.


http://reviews.llvm.org/D18275



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Richard Smith via cfe-commits
rsmith added a comment.

I think a reasonable approach would be: "do not warn on shadowing if the idiom 
of naming a constructor parameter after a class member is used, and the class 
member is initialized from that constructor parameter, and all uses of the 
parameter in the constructor body would still be valid if it were declared 
`const`".

In particular, I think we should probably warn if a non-const reference is 
bound to the parameter, or if the constructor's member initializer list does 
not contain `field(field)`.

(I agree that catching `A(X x) : x(std::move(x)) { use(x); }` is outside the 
scope of this change.)



Comment at: lib/Sema/SemaDecl.cpp:6400
@@ +6399,3 @@
+if (isa(NewDC) && isa(D))
+  return;
+  }

Instead of redoing class member lookup every time we check to see if a variable 
is modifiable, perhaps you could populate a set of shadowed-but-not-diagnosed 
`VarDecl*`s here? That way, you can also suppress the duplicate diagnostics if 
the variable is modified multiple times by removing it from the set.


Comment at: lib/Sema/SemaExpr.cpp:9663
@@ +9662,3 @@
+  if (!S.getLangOpts().CPlusPlus ||
+  S.Diags.isIgnored(diag::warn_decl_shadow, Loc))
+return;

This query is actually quite expensive (more so than some or all of the other 
checks below).


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/CC1Options.td:702-703
@@ -701,2 +701,4 @@
   HelpText<"Allow variadic functions in CUDA device code.">;
+def fcuda_relaxed_constexpr : Flag<["-"], "fcuda-relaxed-constexpr">,
+  HelpText<"Treat constexpr functions as __host__ __device__.">;
 

rsmith wrote:
> Is there a better name we can use for this? I don't think this is "relaxed" 
> in any obvious sense. `-fcuda-host-device-constexpr` or 
> `-fcuda-constexpr-on-device` might be clearer?
"relaxed constexpr" is nvidia's term -- do you think it might be helpful to use 
the same terminology?  I understand there's some prior art here, with respect 
to clang accepting gcc's flags, although the situation here is of course 
different.


Comment at: lib/Driver/Tools.cpp:3597
@@ -3596,2 +3596,3 @@
 CmdArgs.push_back("-fcuda-disable-target-call-checks");
+CmdArgs.push_back("-fcuda-relaxed-constexpr");
   }

rsmith wrote:
> For flags that are enabled by default, we usually have the -cc1 flag be a 
> `-fno-*` flag. This allows people to use (for instance) `clang blah.cu 
> -Xclang -fno-cuda-relaxed-constexpr` if necessary.
Yeah, Artem and I had a discussion about this yesterday.  As you can see, there 
are two other flags above which are turned on by default -- these also lack 
-fno variants.

I think it would be good to be consistent here.  I'm tempted to add another 
patch below this one which makes the other two -fno, then we can make this one 
-fno as well.  It seems that convention is to just get rid of the existing 
non-fno flags, rather than leave both positive and negative versions.

Does that sound OK to you?


http://reviews.llvm.org/D18380



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Nico Weber via cfe-commits
thakis added a comment.

In http://reviews.llvm.org/D18271#381758, @bcraig wrote:

> In http://reviews.llvm.org/D18271#381744, @thakis wrote:
>
> > FWIW we don't currently use this warning on Chromium because it's way to 
> > noisy. So something like this looks like a great change to me.
> >
> > dblaikie, are you aware of any codebases that use this warning in its 
> > current form?
>
>
> Not dblaikie, but I've used the GCC version of -Wshadow on reasonably large 
> code bases before.  The ctor pattern that this is trying to squelch was 
> certainly a significant portion of the warnings, particularly when (old) 
> boost headers got involved.
>
> I believe that newer versions of boost (~1.50 and newer?) attempt to be 
> -Wshadow clean in the headers.


Did squelching this ctor pattern find any bugs? Do you know if boost would miss 
the warning firing in this case?


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Ben Craig via cfe-commits
bcraig added a subscriber: bcraig.
bcraig added a comment.

In http://reviews.llvm.org/D18271#381744, @thakis wrote:

> FWIW we don't currently use this warning on Chromium because it's way to 
> noisy. So something like this looks like a great change to me.
>
> dblaikie, are you aware of any codebases that use this warning in its current 
> form?


Not dblaikie, but I've used the GCC version of -Wshadow on reasonably large 
code bases before.  The ctor pattern that this is trying to squelch was 
certainly a significant portion of the warnings, particularly when (old) boost 
headers got involved.

I believe that newer versions of boost (~1.50 and newer?) attempt to be 
-Wshadow clean in the headers.


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Nico Weber via cfe-commits
thakis added a subscriber: thakis.
thakis added a comment.

FWIW we don't currently use this warning on Chromium because it's way to noisy. 
So something like this looks like a great change to me.

dblaikie, are you aware of any codebases that use this warning in its current 
form?


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D18271#378196, @dblaikie wrote:

> It's not just modifications of shadowed variables that are a problem - one of 
> the one's I'm concerned we should catch is:
>
>   struct foo {
> std::unique_ptr p;
> foo(std::unique_ptr p) : p(std::move(p)) {
>   f(*p);
> }
>   };


This seems totally out of scope for -Wshadow, and seeing a -Wshadow warning on 
this wouldn't help (imagine a few tens of lines before the `*p` is used).


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread David Blaikie via cfe-commits
On Wed, Mar 23, 2016 at 11:03 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> alexfh added a subscriber: alexfh.
> alexfh added a comment.
>
> As a data point: I ran -Wshadow on our code base with a similar, but
> simpler patch (http://reviews.llvm.org/D18395, just disables the warning
> on ctor parameters named after fields). It removes more than half of the
> hits (from ~100k initially) and a random sample of ~100 removed removed
> hits didn't contain any issues that we'd like to still be warning about.
>
> Ultimately, I think, this diagnostic should be made much less noisy to be
> actually useful. So maybe even starting with a removal of a larger subset
> of warnings (and then gradually adding back the cases that seem to be
> important to flag) would be better.
>

Right - my concern is that for people who are already using the warning,
that might be a loss of functionality for them (if they've gone to the
hassle/code convention of not naming members the same as ctor parameters,
etc) & so they'll start missing mistakes they thought they were guarded
against.


>
>
> 
> Comment at: lib/Sema/SemaExpr.cpp:9887
> @@ -9854,1 +9886,3 @@
>  if (ConvTy == Compatible) {
> +  const Expr *InnerLHS = LHSExpr->IgnoreParenCasts();
> +  const DeclRefExpr *DRE = dyn_cast(InnerLHS);
> 
> Why this change?
>
>
> http://reviews.llvm.org/D18271
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

…and landed in r264174.


http://reviews.llvm.org/D18401



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


r264174 - clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Mar 23 13:00:22 2016
New Revision: 264174

URL: http://llvm.org/viewvc/llvm-project?rev=264174=rev
Log:
clang-cl: Include /FI headers in /showIncludes output.

-H in gcc mode doesn't print -include headers, but they are included in
depfiles written by MMD and friends. Since /showIncludes is what's used instead
of depfiles, printing /FI there seems important (and matches cl.exe).

Instead of giving HeaderIncludeGen more options, just switch on ShowAllHeaders
in clang-cl mode and let clang::InitializePreprocessor() not put -include flags
in the  block. This changes the behavior of -E slightly, and it
removes the  flag from the output triggered by setting the
obscure CC_PRINT_HEADERS=1 env var to true while running clang. Both of these
seem ok to change.

http://reviews.llvm.org/D18401

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/cl-pch-showincludes.cpp
cfe/trunk/test/Frontend/print-header-includes.c

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=264174=264173=264174=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Mar 23 13:00:22 2016
@@ -372,7 +372,7 @@ void CompilerInstance::createPreprocesso
 
   if (DepOpts.PrintShowIncludes) {
 AttachHeaderIncludeGen(*PP, DepOpts.ExtraDeps,
-   /*ShowAllHeaders=*/false, /*OutputPath=*/"",
+   /*ShowAllHeaders=*/true, /*OutputPath=*/"",
/*ShowDepth=*/true, /*MSStyle=*/true);
   }
 }

Modified: cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp?rev=264174=264173=264174=diff
==
--- cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp (original)
+++ cfe/trunk/lib/Frontend/HeaderIncludeGen.cpp Wed Mar 23 13:00:22 2016
@@ -148,11 +148,18 @@ void HeaderIncludesCallback::FileChanged
   // line buffers.
   bool ShowHeader = (HasProcessedPredefines ||
  (ShowAllHeaders && CurrentIncludeDepth > 2));
+  unsigned IncludeDepth = CurrentIncludeDepth;
+  if (!HasProcessedPredefines)
+--IncludeDepth;  // Ignore indent from .
 
   // Dump the header include information we are past the predefines buffer or
-  // are showing all headers.
-  if (ShowHeader && Reason == PPCallbacks::EnterFile) {
-PrintHeaderInfo(OutputFile, UserLoc.getFilename(),
-ShowDepth, CurrentIncludeDepth, MSStyle);
+  // are showing all headers and this isn't the magic implicit 
+  // header.
+  // FIXME: Identify headers in a more robust way than comparing their name to
+  // "" and "" in a bunch of places.
+  if (ShowHeader && Reason == PPCallbacks::EnterFile &&
+  UserLoc.getFilename() != StringRef("")) {
+PrintHeaderInfo(OutputFile, UserLoc.getFilename(), ShowDepth, IncludeDepth,
+MSStyle);
   }
 }

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=264174=264173=264174=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Mar 23 13:00:22 2016
@@ -972,6 +972,10 @@ void clang::InitializePreprocessor(
  PP.getDiagnostics());
   }
 
+  // Exit the command line and go back to  (2 is LC_LEAVE).
+  if (!PP.getLangOpts().AsmPreprocessor)
+Builder.append("# 1 \"\" 2");
+
   // If -imacros are specified, include them now.  These are processed before
   // any -include directives.
   for (unsigned i = 0, e = InitOpts.MacroIncludes.size(); i != e; ++i)
@@ -990,10 +994,6 @@ void clang::InitializePreprocessor(
 AddImplicitInclude(Builder, Path);
   }
 
-  // Exit the command line and go back to  (2 is LC_LEAVE).
-  if (!PP.getLangOpts().AsmPreprocessor)
-Builder.append("# 1 \"\" 2");
-
   // Instruct the preprocessor to skip the preamble.
   PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first,
  InitOpts.PrecompiledPreambleBytes.second);

Modified: cfe/trunk/test/Driver/cl-pch-showincludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-showincludes.cpp?rev=264174=264173=264174=diff
==
--- cfe/trunk/test/Driver/cl-pch-showincludes.cpp (original)
+++ cfe/trunk/test/Driver/cl-pch-showincludes.cpp Wed Mar 23 13:00:22 2016
@@ -8,16 +8,17 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // 

Re: [PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 51448.
thakis marked 2 inline comments as done.
thakis added a comment.

Thanks! All done.


http://reviews.llvm.org/D18401

Files:
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/HeaderIncludeGen.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/cl-pch-showincludes.cpp
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -1,24 +1,24 @@
-// RUN: cd %S
-// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.stderr
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E -H -o /dev/null %s 2> %t.stderr
 // RUN: FileCheck < %t.stderr %s
 
 // CHECK-NOT: test3.h
 // CHECK: . {{.*test.h}}
 // CHECK: .. {{.*test2.h}}
 
-// RUN: %clang_cc1 -include Inputs/test3.h -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS < %t.stdout %s
-// MS-NOT: test3.h
-// MS: Note: including file: {{.*test.h}}
-// MS: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS %s
+// MS-NOT: 
+// MS: Note: including file: {{[^ ]*test3.h}}
+// MS: Note: including file: {{[^ ]*test.h}}
+// MS: Note: including file:  {{[^ ]*test2.h}}
 // MS-NOT: Note
 
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s
-// MS-BLACKLIST: Note: including file: {{.*\.blacklist}}
-// MS-BLACKLIST: Note: including file: {{.*test.h}}
-// MS-BLACKLIST: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS-BLACKLIST %s
+// MS-BLACKLIST: Note: including file: {{[^ ]*\.blacklist}}
+// MS-BLACKLIST: Note: including file: {{[^ ]*test.h}}
+// MS-BLACKLIST: Note: including file:  {{[^ ]*test2.h}}
 // MS-BLACKLIST-NOT: Note
 
 #include "Inputs/test.h"
Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,16 +8,17 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YC %s
-// CHECK-YC: Note: including file: {{.+header2.h}}
-// CHECK-YC: Note: including file: {{.+header1.h}}
-// CHECK-YC: Note: including file: {{.+header3.h}}
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
+// CHECK-YC: Note: including file: {{[^ ]*header2.h}}
+// FIXME: header1.h should be indented one more:
+// CHECK-YC: Note: including file: {{[^ ]*header1.h}}
+// CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YU %s
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
-// CHECK-YU: Note: including file: {{.+header3.h}}
+// CHECK-YU: Note: including file: {{[^ ]*header3.h}}
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -972,6 +972,10 @@
  PP.getDiagnostics());
   }
 
+  // Exit the command line and go back to  (2 is LC_LEAVE).
+  if (!PP.getLangOpts().AsmPreprocessor)
+Builder.append("# 1 \"\" 2");
+
   // If -imacros are specified, include them now.  These are processed before
   // any -include directives.
   for (unsigned i = 0, e = InitOpts.MacroIncludes.size(); i != e; ++i)
@@ -990,10 +994,6 @@
 AddImplicitInclude(Builder, Path);
   }
 
-  // Exit the command line and go back to  (2 is LC_LEAVE).
-  if (!PP.getLangOpts().AsmPreprocessor)
-Builder.append("# 1 \"\" 2");
-
   // Instruct the preprocessor to skip the preamble.
   PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first,
  InitOpts.PrecompiledPreambleBytes.second);
Index: 

Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D18271#381728, @alexfh wrote:

> ... and then gradually adding back the cases that seem to be important to 
> flag ...


Maybe as separate warnings.


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a subscriber: alexfh.
alexfh added a comment.

As a data point: I ran -Wshadow on our code base with a similar, but simpler 
patch (http://reviews.llvm.org/D18395, just disables the warning on ctor 
parameters named after fields). It removes more than half of the hits (from 
~100k initially) and a random sample of ~100 removed removed hits didn't 
contain any issues that we'd like to still be warning about.

Ultimately, I think, this diagnostic should be made much less noisy to be 
actually useful. So maybe even starting with a removal of a larger subset of 
warnings (and then gradually adding back the cases that seem to be important to 
flag) would be better.



Comment at: lib/Sema/SemaExpr.cpp:9887
@@ -9854,1 +9886,3 @@
 if (ConvTy == Compatible) {
+  const Expr *InnerLHS = LHSExpr->IgnoreParenCasts();
+  const DeclRefExpr *DRE = dyn_cast(InnerLHS);

Why this change?


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18275: [ASTMatchers] Add own version of VariadicFunction.

2016-03-23 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:80
@@ +79,3 @@
+  ResultT operator()(ArrayRef Args) const {
+std::vector InnerArgs;
+for (const ArgT  : Args)

alexfh wrote:
> It's unfortunate that we need to create an array of the argument pointers 
> here, but it seems there's no larger common denominator of the two ways this 
> functions can be called.
> 
> One nit though: SmallVector will be a better container here.
> It's unfortunate that we need to create an array of the argument pointers 
> here, but it seems there's no larger  common denominator of the two ways this 
> functions can be called.

Now that we control it, we can change it to be something different.
For example, instead of passing a function pointer as template parameter we 
could pass a class that contains overloaded operator() for both ArrayRef and 
ArrayRef.

On the other hand, constructing the matchers has never been the performance 
bottleneck of the framework.
They are usually created once and used thousands/millions of times.
Might not be worth it to optimize this too much.

> One nit though: SmallVector will be a better container here.

Done.


http://reviews.llvm.org/D18275



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


Re: [PATCH] D18275: [ASTMatchers] Add own version of VariadicFunction.

2016-03-23 Thread Samuel Benzaquen via cfe-commits
sbenza updated this revision to Diff 51447.
sbenza added a comment.

Minor fix


http://reviews.llvm.org/D18275

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/Dynamic/Marshallers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3000,6 +3000,9 @@
   EXPECT_TRUE(notMatches(Code, recordDecl(hasAnyName("::C", "::b::C";
   EXPECT_TRUE(
   matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C";
+
+  std::vector Names = {"::C", "::b::C", "::a::b::C"};
+  EXPECT_TRUE(matches(Code, recordDecl(hasAnyName(Names;
 }
 
 TEST(Matcher, IsDefinition) {
Index: lib/ASTMatchers/Dynamic/Marshallers.h
===
--- lib/ASTMatchers/Dynamic/Marshallers.h
+++ lib/ASTMatchers/Dynamic/Marshallers.h
@@ -325,8 +325,9 @@
 
   template )>
-  VariadicFuncMatcherDescriptor(llvm::VariadicFunction Func,
-  StringRef MatcherName)
+  VariadicFuncMatcherDescriptor(
+  ast_matchers::internal::VariadicFunction Func,
+  StringRef MatcherName)
   : Func(),
 MatcherName(MatcherName.str()),
 ArgsKind(ArgTypeTraits::getKind()) {
@@ -655,9 +656,9 @@
 /// \brief Variadic overload.
 template )>
-MatcherDescriptor *
-makeMatcherAutoMarshall(llvm::VariadicFunction VarFunc,
-StringRef MatcherName) {
+MatcherDescriptor *makeMatcherAutoMarshall(
+ast_matchers::internal::VariadicFunction VarFunc,
+StringRef MatcherName) {
   return new VariadicFuncMatcherDescriptor(VarFunc, MatcherName);
 }
 
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -46,8 +46,9 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/Type.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
-#include "llvm/ADT/VariadicFunction.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ManagedStatic.h"
 #include 
 #include 
@@ -60,6 +61,39 @@
 
 namespace internal {
 
+/// \brief Variadic function object.
+///
+/// Most of the functions below that use VariadicFunction could be implemented
+/// using plain C++11 variadic functions, but the function object allows us to
+/// capture it on the dynamic matcher registry.
+template )>
+struct VariadicFunction {
+  ResultT operator()() const { return Func({}); }
+
+  template 
+  ResultT operator()(const ArgT , const ArgsT &... Args) const {
+return Execute(Arg1, static_cast(Args)...);
+  }
+
+  // We also allow calls with an already created array, in case the caller
+  // already had it.
+  ResultT operator()(ArrayRef Args) const {
+SmallVector InnerArgs;
+for (const ArgT  : Args)
+  InnerArgs.push_back();
+return Func(InnerArgs);
+  }
+
+private:
+  // Trampoline function to allow for implicit conversions to take place
+  // before we make the array.
+  template  ResultT Execute(const ArgsT &... Args) const {
+const ArgT *const ArgsArray[] = {};
+return Func(ArgsArray);
+  }
+};
+
 /// \brief Unifies obtaining the underlying type of a regular node through
 /// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
 template 
@@ -1405,9 +1439,8 @@
 /// casted to CXXRecordDecl and all given matchers match.
 template 
 class VariadicDynCastAllOfMatcher
-: public llvm::VariadicFunction<
-BindableMatcher, Matcher,
-makeDynCastAllOfComposite > {
+: public VariadicFunction> {
 public:
   VariadicDynCastAllOfMatcher() {}
 };
@@ -1423,9 +1456,9 @@
 /// \c Matcher.
 /// The returned matcher matches if all given matchers match.
 template 
-class VariadicAllOfMatcher : public llvm::VariadicFunction<
-   BindableMatcher, Matcher,
-   makeAllOfComposite > {
+class VariadicAllOfMatcher
+: public VariadicFunction {
 public:
   VariadicAllOfMatcher() {}
 };
@@ -1546,8 +1579,8 @@
 new MatcherImpl(InnerMatcher, Getter::value()));
   }
 
-  struct Func : public llvm::VariadicFunction {
+  struct Func
+  : public VariadicFunction {
 Func() {}
   };
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- 

Re: [PATCH] D18380: [CUDA] Implement -fcuda-relaxed-constexpr, and enable it by default.

2016-03-23 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Driver/CC1Options.td:702-703
@@ -701,2 +701,4 @@
   HelpText<"Allow variadic functions in CUDA device code.">;
+def fcuda_relaxed_constexpr : Flag<["-"], "fcuda-relaxed-constexpr">,
+  HelpText<"Treat constexpr functions as __host__ __device__.">;
 

Is there a better name we can use for this? I don't think this is "relaxed" in 
any obvious sense. `-fcuda-host-device-constexpr` or 
`-fcuda-constexpr-on-device` might be clearer?


Comment at: lib/Driver/Tools.cpp:3597
@@ -3596,2 +3596,3 @@
 CmdArgs.push_back("-fcuda-disable-target-call-checks");
+CmdArgs.push_back("-fcuda-relaxed-constexpr");
   }

For flags that are enabled by default, we usually have the -cc1 flag be a 
`-fno-*` flag. This allows people to use (for instance) `clang blah.cu -Xclang 
-fno-cuda-relaxed-constexpr` if necessary.


Comment at: lib/Sema/SemaOverload.cpp:1132
@@ -1136,1 +1131,3 @@
+// one viable function with this signature on any side of CUDA compilation.
+if ((NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;

No parens around `==` comparisons.


http://reviews.llvm.org/D18380



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


[PATCH] D18408: readability check for const params in declarations

2016-03-23 Thread Matt Kulukundis via cfe-commits
fowles created this revision.
fowles added a reviewer: alexfh.
fowles added a subscriber: cfe-commits.

Adds a clang-tidy warning for top-level consts in function declarations.

http://reviews.llvm.org/D18408

Files:
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tidy/readability/AvoidConstParamsInDecls.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
  test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s readability-avoid-const-params-in-decls %t
+
+using alias_type = bool;
+using alias_const_type = const bool;
+
+
+void F1(const int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
+// CHECK-FIXES: void F1(int i);
+
+void F2(const int *const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F2(const int * i);
+
+void F3(int const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F3(int i);
+
+void F4(alias_type const i);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
+// CHECK-FIXES: void F4(alias_type i);
+
+void F5(const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// CHECK-FIXES: void F5(int);
+
+void F6(const int *const);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// BUG(b/27584482): void F6(const int *);  should be produced
+
+void F7(int, const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: parameter 2 is const-qualified
+// CHECK-FIXES: void F7(int, int);
+
+void F8(const int, const int);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
+// CHECK-MESSAGES: :[[@LINE-2]]:20: warning: parameter 2 is const-qualified
+// CHECK-FIXES: void F8(int, int);
+
+void F9(const int long_name);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'long_name'
+// CHECK-FIXES: void F9(int long_name);
+
+void F10(const int *const *const long_name);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'long_name'
+// CHECK-FIXES: void F10(const int *const * long_name);
+
+
+struct Foo {
+  Foo(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i'
+  // CHECK-FIXES: Foo(int i);
+
+  void operator()(const int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(int i);
+};
+
+// Do not match on definitions
+void NF1(const int i) {}
+void NF2(const int *const i) {}
+void NF3(int const i) {}
+void NF4(alias_type const i) {}
+void NF5(const int) {}
+void NF6(const int *const) {}
+void NF7(int, const int) {}
+void NF8(const int, const int) {}
+
+// Do not match on other stuff
+void NF(const alias_type& i);
+void NF(const int );
+void NF(const int *i);
+void NF(alias_const_type i);
+void NF(const alias_type&);
+void NF(const int&);
+void NF(const int*);
+void NF(const int* const*);
+void NF(alias_const_type);
Index: docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-avoid-const-params-in-decls.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - readability-avoid-const-params-in-decls
+
+readability-avoid-const-params-in-decls
+==
+
+Checks whether a function declaration has parameters that are top level const.
+
+`const` values in declarations do not have any affect on the signature of a
+function, so they should not be put there.  For example:
+
+Examples:
+
+.. code:: c++
+
+  void f(const string);   // bad. const is top level
+  void f(const string&);  // ok. const is not top level
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -88,6 +88,7 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
+   readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
readability-else-after-return
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 

Re: [PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
This revision is now accepted and ready to land.


Comment at: lib/Frontend/HeaderIncludeGen.cpp:155-156
@@ -151,3 +154,4 @@
 
   // Dump the header include information we are past the predefines buffer or
   // are showing all headers.
+  if (ShowHeader && Reason == PPCallbacks::EnterFile &&

Missing "if" or similar in this comment?


Comment at: lib/Frontend/HeaderIncludeGen.cpp:158
@@ +157,3 @@
+  if (ShowHeader && Reason == PPCallbacks::EnterFile &&
+  strcmp(UserLoc.getFilename(), "")) {
+PrintHeaderInfo(OutputFile, UserLoc.getFilename(), ShowDepth, IncludeDepth,

I'm not a fan of using `strcmp` like this (implicitly converting the result to 
`bool` to mean "check strings are different"). I'd prefer you used

UserLoc.getFilename() != StringRef("")

(Of course, ideally we'd use something more principled than a check against the 
filename string... please add a FIXME for that.)


http://reviews.llvm.org/D18401



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


r264170 - [NFC] Delete an unused function parameter from a static function

2016-03-23 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Mar 23 12:39:51 2016
New Revision: 264170

URL: http://llvm.org/viewvc/llvm-project?rev=264170=rev
Log:
[NFC] Delete an unused function parameter from a static function 

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=264170=264169=264170=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Mar 23 12:39:51 2016
@@ -13249,8 +13249,7 @@ static bool captureInCapturedRegion(Capt
 
 /// \brief Create a field within the lambda class for the variable
 /// being captured.
-// FIXME: Delete VarDecl *Var below, it is not used in the function.
-static void addAsFieldToClosureType(Sema , LambdaScopeInfo *LSI, VarDecl 
*Var,
+static void addAsFieldToClosureType(Sema , LambdaScopeInfo *LSI, 
 QualType FieldType, QualType DeclRefType,
 SourceLocation Loc,
 bool RefersToCapturedVariable) {
@@ -13344,7 +13343,7 @@ static bool captureInLambda(LambdaScopeI
 
   // Capture this variable in the lambda.
   if (BuildAndDiagnose)
-addAsFieldToClosureType(S, LSI, Var, CaptureType, DeclRefType, Loc,
+addAsFieldToClosureType(S, LSI, CaptureType, DeclRefType, Loc,
 RefersToCapturedVariable);
 
   // Compute the type of a reference to this captured variable.


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


Re: [PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
thakis updated the summary for this revision.
thakis updated this revision to Diff 51442.

http://reviews.llvm.org/D18401

Files:
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/HeaderIncludeGen.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/cl-pch-showincludes.cpp
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -1,24 +1,24 @@
-// RUN: cd %S
-// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.stderr
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E -H -o /dev/null %s 2> %t.stderr
 // RUN: FileCheck < %t.stderr %s
 
 // CHECK-NOT: test3.h
 // CHECK: . {{.*test.h}}
 // CHECK: .. {{.*test2.h}}
 
-// RUN: %clang_cc1 -include Inputs/test3.h -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS < %t.stdout %s
-// MS-NOT: test3.h
-// MS: Note: including file: {{.*test.h}}
-// MS: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS %s
+// MS-NOT: 
+// MS: Note: including file: {{[^ ]*test3.h}}
+// MS: Note: including file: {{[^ ]*test.h}}
+// MS: Note: including file:  {{[^ ]*test2.h}}
 // MS-NOT: Note
 
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s
-// MS-BLACKLIST: Note: including file: {{.*\.blacklist}}
-// MS-BLACKLIST: Note: including file: {{.*test.h}}
-// MS-BLACKLIST: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS-BLACKLIST %s
+// MS-BLACKLIST: Note: including file: {{[^ ]*\.blacklist}}
+// MS-BLACKLIST: Note: including file: {{[^ ]*test.h}}
+// MS-BLACKLIST: Note: including file:  {{[^ ]*test2.h}}
 // MS-BLACKLIST-NOT: Note
 
 #include "Inputs/test.h"
Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,16 +8,17 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YC %s
-// CHECK-YC: Note: including file: {{.+header2.h}}
-// CHECK-YC: Note: including file: {{.+header1.h}}
-// CHECK-YC: Note: including file: {{.+header3.h}}
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
+// CHECK-YC: Note: including file: {{[^ ]*header2.h}}
+// FIXME: header1.h should be indented one more:
+// CHECK-YC: Note: including file: {{[^ ]*header1.h}}
+// CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YU %s
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
-// CHECK-YU: Note: including file: {{.+header3.h}}
+// CHECK-YU: Note: including file: {{[^ ]*header3.h}}
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -972,6 +972,10 @@
  PP.getDiagnostics());
   }
 
+  // Exit the command line and go back to  (2 is LC_LEAVE).
+  if (!PP.getLangOpts().AsmPreprocessor)
+Builder.append("# 1 \"\" 2");
+
   // If -imacros are specified, include them now.  These are processed before
   // any -include directives.
   for (unsigned i = 0, e = InitOpts.MacroIncludes.size(); i != e; ++i)
@@ -990,10 +994,6 @@
 AddImplicitInclude(Builder, Path);
   }
 
-  // Exit the command line and go back to  (2 is LC_LEAVE).
-  if (!PP.getLangOpts().AsmPreprocessor)
-Builder.append("# 1 \"\" 2");
-
   // Instruct the preprocessor to skip the preamble.
   PP.setSkipMainFilePreamble(InitOpts.PrecompiledPreambleBytes.first,
  InitOpts.PrecompiledPreambleBytes.second);
Index: lib/Frontend/HeaderIncludeGen.cpp

r264169 - Visualize fields of records as they were declared in Visual Studio debugger

2016-03-23 Thread Mike Spertus via cfe-commits
Author: mps
Date: Wed Mar 23 12:29:42 2016
New Revision: 264169

URL: http://llvm.org/viewvc/llvm-project?rev=264169=rev
Log:
Visualize fields of records as they were declared in Visual Studio debugger

Modified:
cfe/trunk/utils/clang.natvis

Modified: cfe/trunk/utils/clang.natvis
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang.natvis?rev=264169=264168=264169=diff
==
--- cfe/trunk/utils/clang.natvis (original)
+++ cfe/trunk/utils/clang.natvis Wed Mar 23 12:29:42 2016
@@ -95,7 +95,7 @@ or create a symbolic link so it updates
 
   
   
-Field {{{*(clang::NamedDecl 
*)this,view(cpp)nd}}}
+Field {{{*(clang::DeclaratorDecl 
*)this,view(cpp)nd}}}
   
   
 {*(clang::FunctionDecl 
*)this,nd}


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


Re: [PATCH] D17762: Fix an assertion failure in setPointOfInstantiation.

2016-03-23 Thread Richard Smith via cfe-commits
rsmith added a comment.

It seems to me that the bug is that we're producing an invalid source location, 
not how we handle that downstream. Typo correction should be able to preserve 
the source location of whatever expression it was correcting.



Comment at: lib/Sema/SemaExpr.cpp:14047-14048
@@ -14046,1 +14046,4 @@
 
+  if (Loc.isInvalid())
+return true;
+

General rule: for a function that returns `true` to say "an error occurred", it 
is not acceptable to return `true` without either (a) producing an error or (b) 
observing some state that proves someone else emitted an error (such as a decl 
that has been set as invalid).


http://reviews.llvm.org/D17762



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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

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

According to cpp core guidelines any assignment operator should return *this.
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-assignment-op

So in case this check is activated by using an alias it should not be a special 
case.


http://reviews.llvm.org/D18264



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


Re: [PATCH] D18399: Added support for different VFSs in format::getStyle.

2016-03-23 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D18399



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


Re: [PATCH] D18399: Added support for different VFSs in format::getStyle.

2016-03-23 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51440.
ioeric added a comment.

- changed c_str() to str()


http://reviews.llvm.org/D18399

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 #define DEBUG_TYPE "format-test"
@@ -11199,6 +11200,33 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST(FormatStyle, GetStyleOfFile) {
+  vfs::InMemoryFileSystem FS;
+  // Test 1: format file in the same directory.
+  ASSERT_TRUE(
+  FS.addFile("/a/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style1 = getStyle("file", "/a/.clang-format", "Google", );
+  ASSERT_EQ(Style1, getLLVMStyle());
+
+  // Test 2: fallback to default.
+  ASSERT_TRUE(
+  FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", );
+  ASSERT_EQ(Style2, getMozillaStyle());
+
+  // Test 3: format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/c/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", );
+  ASSERT_EQ(Style3, getGoogleStyle());
+}
+
 class ReplacementTest : public ::testing::Test {
 protected:
   tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2098,7 +2098,10 @@
 }
 
 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle) {
+ StringRef FallbackStyle, vfs::FileSystem *FS) {
+  if (!FS) {
+FS = vfs::getRealFileSystem().get();
+  }
   FormatStyle Style = getLLVMStyle();
   Style.Language = getLanguageByFileName(FileName);
   if (!getPredefinedStyle(FallbackStyle, Style.Language, )) {
@@ -2129,28 +2132,35 @@
   llvm::sys::fs::make_absolute(Path);
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
-if (!llvm::sys::fs::is_directory(Directory))
+
+auto Status = FS->status(Directory);
+if (!Status ||
+Status->getType() != llvm::sys::fs::file_type::directory_file) {
   continue;
+}
+
 SmallString<128> ConfigFile(Directory);
 
 llvm::sys::path::append(ConfigFile, ".clang-format");
 DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
-bool IsFile = false;
 // Ignore errors from is_regular_file: we only need to know if we can read
 // the file or not.
-llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
-
+Status = FS->status(ConfigFile.str());
+bool IsFile =
+Status && (Status->getType() == llvm::sys::fs::file_type::regular_file);
 if (!IsFile) {
   // Try _clang-format too, since dotfiles are not commonly used on Windows.
   ConfigFile = Directory;
   llvm::sys::path::append(ConfigFile, "_clang-format");
   DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
-  llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
+  Status = FS->status(ConfigFile.str());
+  IsFile = Status &&
+   (Status->getType() == llvm::sys::fs::file_type::regular_file);
 }
 
 if (IsFile) {
   llvm::ErrorOr Text =
-  llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+  FS->getBufferForFile(ConfigFile.str());
   if (std::error_code EC = Text.getError()) {
 llvm::errs() << EC.message() << "\n";
 break;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -832,11 +833,13 @@
 /// == "file".
 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
 /// in case the style can't be determined from \p StyleName.
+/// \param[in] FS The underlying file system, in which the file resides. By
+/// default, the file system is the real file system.
 ///
 /// \returns FormatStyle as specified by 

Re: [PATCH] D18385: [CUDA] Simplify SemaCUDA/function-overload.cu test.

2016-03-23 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Small nit, LGTM otherwise.



Comment at: test/SemaCUDA/function-overload.cu:66
@@ +65,3 @@
+__device__ int d() { return 8; }
+// expected-note@-1 0+ {{'d' declared here}}
+// expected-note@-2 0+ {{candidate function not viable: call to __device__ 
function from __host__ function}}

Minor nit: Notes that are common to all test runs should probably be 1+.


http://reviews.llvm.org/D18385



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


Re: [PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
thakis added a comment.

On second thought, and after looking at -E output with -include and gch files, 
and at CC_PRINT_HEADERS behavior (it prints  but doesn't indent), 
I think I like the alternative implementation I'm mentioning better. Let me 
make that change.


http://reviews.llvm.org/D18401



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


Re: [PATCH] D18399: Added support for different VFSs in format::getStyle.

2016-03-23 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Format/Format.cpp:2148
@@ -2140,3 +2147,3 @@
 // the file or not.
-llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
-
+Status = FS->status(ConfigFile.c_str());
+bool IsFile =

Prefer .str to .c_str, the former is nicely typed. (here and below)


http://reviews.llvm.org/D18399



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


Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-23 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51437.
baloghadamsoftware added a comment.

Release notes fixed.


http://reviews.llvm.org/D18243

Files:
  docs/LibASTMatchersReference.html
  docs/ReleaseNotes.rst
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", 
ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with hasAnyArgument(...)
 ///   matching y
-///
-/// FIXME: Currently this will ignore parentheses and implicit casts on
-/// the argument before applying the inner matcher. We'll want to remove
-/// this to allow for greater control by the user once \c ignoreImplicit()
-/// has been implemented.
 AST_POLYMORPHIC_MATCHER_P(hasAnyArgument,
   AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr,
   CXXConstructExpr),
   internal::Matcher, InnerMatcher) {
   for (const Expr *Arg : Node.arguments()) {
 BoundNodesTreeBuilder Result(*Builder);
-if (InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, )) {
+if (InnerMatcher.matches(*Arg, Finder, )) {
   *Builder = std::move(Result);
   return true;
 }
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -119,6 +119,12 @@
 AST Matchers
 
 
+- hasAnyArgument: Matcher no longer ignores parentheses and implicit casts on
+  the argument before applying the inner matcher. The fix was done to allow for
+  greater control by the user. In all existing checkers that use this matcher
+  all instances of code ``hasAnyArgument()`` must be changed to
+  ``hasAnyArgument(ignoringParenImpCasts())``.
+
 ...
 
 libclang
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3636,11 +3636,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 
@@ -3907,11 +3902,6 @@
   matches x(1, y, 42)
 with hasAnyArgument(...)
   matching y
-
-FIXME: Currently this will ignore parentheses and implicit casts on
-the argument before applying the inner matcher. We'll want to remove
-this to allow for greater control by the user once ignoreImplicit()
-has been implemented.
 
 
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1633,10 +1633,15 @@
 
 TEST(Matcher, AnyArgument) {
   StatementMatcher CallArgumentY = callExpr(
-  hasAnyArgument(declRefExpr(to(varDecl(hasName("y"));
+  hasAnyArgument(
+  ignoringParenImpCasts(declRefExpr(to(varDecl(hasName("y")));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(1, y); }", CallArgumentY));
   EXPECT_TRUE(matches("void x(int, int) { int y; x(y, 42); }", CallArgumentY));
   EXPECT_TRUE(notMatches("void x(int, int) { x(1, 2); }", CallArgumentY));
+  
+  StatementMatcher ImplicitCastedArgument = callExpr(
+  hasAnyArgument(implicitCastExpr()));
+  EXPECT_TRUE(matches("void x(long) { int y; x(y); }", ImplicitCastedArgument));
 }
 
 TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -2989,18 +2989,13 @@
 ///   matches x(1, y, 42)
 /// with 

AUTO: Jacob Hansen is out of the office (returning 05/04/2016)

2016-03-23 Thread via cfe-commits

I am out of the office until 05/04/2016.




Note: This is an automated response to your message  "cfe-commits Digest, Vol
105, Issue 505" sent on 3/23/2016 4:59:28 PM.

This is the only notification you will receive while this person is away.


This message and any attachments are intended for the use of the addressee or 
addressees only.
The unauthorised disclosure, use, dissemination or copying (either in whole or 
in part) of its
content is not permitted.
If you received this message in error, please notify the sender and delete it 
from your system.
Emails can be altered and their integrity cannot be guaranteed by the sender.

Please consider the environment before printing this email.

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


Re: [PATCH] D18264: [clang-tidy] misc-assign-operator-signature checker checks return value of all assign operators

2016-03-23 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware updated this revision to Diff 51435.
baloghadamsoftware added a comment.

Check for non copy and move assign operators made optional.


http://reviews.llvm.org/D18264

Files:
  clang-tidy/misc/AssignOperatorSignatureCheck.cpp
  clang-tidy/misc/AssignOperatorSignatureCheck.h
  test/clang-tidy/misc-assign-operator-signature.cpp

Index: test/clang-tidy/misc-assign-operator-signature.cpp
===
--- test/clang-tidy/misc-assign-operator-signature.cpp
+++ test/clang-tidy/misc-assign-operator-signature.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-assign-operator-signature %t
+// RUN: %check_clang_tidy %s misc-assign-operator-signature %t -- -config="{CheckOptions: [{key: misc-assign-operator-signature.CheckAllAssignOperators, value: 1}]}" --
 
 struct Good {
   Good& operator=(const Good&);
@@ -18,6 +18,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturn&' [misc-assign-operator-signature]
   const BadReturn& operator=(BadReturn&&);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
+  void operator=(int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
 };
 struct BadReturn2 {
   BadReturn2&& operator=(const BadReturn2&);
Index: clang-tidy/misc/AssignOperatorSignatureCheck.h
===
--- clang-tidy/misc/AssignOperatorSignatureCheck.h
+++ clang-tidy/misc/AssignOperatorSignatureCheck.h
@@ -24,10 +24,13 @@
 ///   * Private and deleted operators are ignored.
 class AssignOperatorSignatureCheck : public ClangTidyCheck {
 public:
-  AssignOperatorSignatureCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  AssignOperatorSignatureCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  const bool CheckAllAssignOperators;
 };
 
 } // namespace misc
Index: clang-tidy/misc/AssignOperatorSignatureCheck.cpp
===
--- clang-tidy/misc/AssignOperatorSignatureCheck.cpp
+++ clang-tidy/misc/AssignOperatorSignatureCheck.cpp
@@ -17,6 +17,16 @@
 namespace tidy {
 namespace misc {
 
+AssignOperatorSignatureCheck::AssignOperatorSignatureCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  CheckAllAssignOperators(Options.get("CheckAllAssignOperators", false)) {}
+
+void AssignOperatorSignatureCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "CheckAllAssignOperators", CheckAllAssignOperators);
+}
+
 void AssignOperatorSignatureCheck::registerMatchers(
 ast_matchers::MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
@@ -31,16 +41,19 @@
   const auto IsSelf = qualType(
   anyOf(hasDeclaration(equalsBoundNode("class")),
 referenceType(pointee(hasDeclaration(equalsBoundNode("class"));
-  const auto IsSelfAssign =
+  const auto IsAssign =
   cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
-hasName("operator="), ofClass(recordDecl().bind("class")),
-hasParameter(0, parmVarDecl(hasType(IsSelf
+hasName("operator="), ofClass(recordDecl().bind("class")))
+  .bind("method");
+  const auto IsSelfAssign =
+  cxxMethodDecl(IsAssign, hasParameter(0, parmVarDecl(hasType(IsSelf
   .bind("method");
 
   Finder->addMatcher(
-  cxxMethodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
+  cxxMethodDecl(CheckAllAssignOperators ? IsAssign : IsSelfAssign,
+unless(HasGoodReturnType))
+  .bind("ReturnType"),
   this);
-
   const auto BadSelf = referenceType(
   anyOf(lValueReferenceType(pointee(unless(isConstQualified(,
 rValueReferenceType(pointee(isConstQualified();
@@ -58,14 +71,13 @@
 
 void AssignOperatorSignatureCheck::check(
 const MatchFinder::MatchResult ) {
-  const auto* Method = Result.Nodes.getNodeAs("method");
+  const auto *Method = Result.Nodes.getNodeAs("method");
   std::string Name = Method->getParent()->getName();
 
   static const char *const Messages[][2] = {
   {"ReturnType", "operator=() should return '%0&'"},
   {"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
-  {"cv", "operator=() should not be marked '%1'"}
-  };
+  {"cv", "operator=() should not be marked '%1'"}};
 
   for (const auto  : Messages) {
 if (Result.Nodes.getNodeAs(Message[0]))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18243: [ASTMatchers] Existing matcher hasAnyArgument fixed

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: docs/ReleaseNotes.rst:123
@@ +122,3 @@
+- hasAnyArgument: Matcher no longer ignores parentheses and implicit casts on
+  the argument before applying the inner matcher. The fix was done allow for
+  greater control by the user. In all existing checkers that use this matcher

nit: The sentence doesn't parse. Did you mean "The fix allows" or "The fix was 
done to allow"?


Comment at: docs/ReleaseNotes.rst:125
@@ +124,3 @@
+  greater control by the user. In all existing checkers that use this matcher
+  all instances of code hasAnyArgument() must be changed to
+  hasAnyArgument(ignoringParenImpCasts()).

nit: Please enclose inline code snippets in double backquotes.


http://reviews.llvm.org/D18243



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


Re: [PATCH] D18396: Clang-tidy:modernize-use-override. Fix for __declspec attributes and const=0 without spacse

2016-03-23 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for the patch!

Looks good in general. A few nits.



Comment at: clang-tidy/modernize/UseOverrideCheck.cpp:125
@@ -124,1 +124,3 @@
+  if (T.is(tok::kw___attribute) && 
+  !(Sources.isBeforeInTranslationUnit(T.getLocation(), MethodLoc))) {
 InsertLoc = T.getLocation();

nit: no need for the parentheses around the function call.


Comment at: clang-tidy/modernize/UseOverrideCheck.cpp:136
@@ -133,3 +135,3 @@
   Sources.getExpansionLoc(A->getRange().getBegin());
-  if (!InsertLoc.isValid() ||
-  Sources.isBeforeInTranslationUnit(Loc, InsertLoc))
+  if ((!InsertLoc.isValid() ||
+  Sources.isBeforeInTranslationUnit(Loc, InsertLoc)) &&

Please clang-format this change.


Comment at: test/clang-tidy/modernize-use-override-ms.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s modernize-use-override %t
+

Does this test pass on linux? If no additional compiler arguments needed and it 
just works, maybe just merge this test code to the main test file?


http://reviews.llvm.org/D18396



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


r264167 - ObjC: Handle boolean fixed type for enum.

2016-03-23 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Mar 23 11:28:28 2016
New Revision: 264167

URL: http://llvm.org/viewvc/llvm-project?rev=264167=rev
Log:
ObjC: Handle boolean fixed type for enum.

Before this commit, we assert failure in ImplicitCastExpr
"unheralded conversion to bool". This commit fixes the assertion by using
the correct cast type when the fixed type is boolean.

This commit also fixes the behavior for Microsoft mode as well, since
Obj-C and Microsoft mode share the same code path.

rdar://24999533

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/enum-fixed-type.m

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=264167=264166=264167=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Mar 23 11:28:28 2016
@@ -14146,7 +14146,10 @@ EnumConstantDecl *Sema::CheckEnumConstan
 } else
   Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
   } else
-Val = ImpCastExprToType(Val, EltTy, CK_IntegralCast).get();
+Val = ImpCastExprToType(Val, EltTy,
+EltTy->isBooleanType() ?
+CK_IntegralToBoolean : CK_IntegralCast)
+.get();
 } else if (getLangOpts().CPlusPlus) {
   // C++11 [dcl.enum]p5:
   //   If the underlying type is not fixed, the type of each enumerator

Modified: cfe/trunk/test/SemaObjC/enum-fixed-type.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/enum-fixed-type.m?rev=264167=264166=264167=diff
==
--- cfe/trunk/test/SemaObjC/enum-fixed-type.m (original)
+++ cfe/trunk/test/SemaObjC/enum-fixed-type.m Wed Mar 23 11:28:28 2016
@@ -38,3 +38,8 @@ int arr3[(long long)Bar == (long long)-1
 
 typedef enum : Integer { BaseElem } BaseEnum;
 typedef enum : BaseEnum { DerivedElem } DerivedEnum; // expected-error 
{{non-integral type 'BaseEnum' is an invalid underlying type}}
+
+// 
+enum MyEnum : _Bool {
+  MyThing = 0
+};


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


Re: [PATCH] D18395: -Wshadow: don't warn on ctor parameters with the same name as a field name

2016-03-23 Thread David Blaikie via cfe-commits
Ah, now I see your follow-up email. Soryr I missed it...

On Wed, Mar 23, 2016 at 9:30 AM, David Blaikie  wrote:

> Reid sent out a different patch for this warning improvement. Have you
> checked that one out? Is it abandoned?
>
> I'm still a bit concerned about whitelisting all these cases & not
> catching cases where the parameter is then used inside the function in some
> problematic way (the classic being a unique_ptr parameter, moved into a
> member, then the parameter (instead of the member) is referenced in the
> body of the function).
>
> On Wed, Mar 23, 2016 at 7:43 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> alexfh created this revision.
>> alexfh added reviewers: rsmith, rnk.
>> alexfh added a subscriber: cfe-commits.
>>
>> -Wshadow: don't warn on ctor parameters with the same name as a field
>> name. This fixes a broad class of false positives resulting from a widely
>> used
>> pattern:
>>
>>   struct A {
>> int q;
>> A(int q) : q(q) {}
>>   };
>>
>> Fixes http://llvm.org/PR16088.
>>
>> http://reviews.llvm.org/D18395
>>
>> Files:
>>   lib/Sema/SemaDecl.cpp
>>   test/SemaCXX/warn-shadow.cpp
>>
>> Index: test/SemaCXX/warn-shadow.cpp
>> ===
>> --- test/SemaCXX/warn-shadow.cpp
>> +++ test/SemaCXX/warn-shadow.cpp
>> @@ -71,6 +71,14 @@
>>  };
>>  }
>>
>> +// http://llvm.org/PR16088
>> +namespace PR16088 {
>> +struct S {
>> +  int i;
>> +  S(int i) : i(i) {}
>> +};
>> +}
>> +
>>  extern int bob; // expected-note {{previous declaration is here}}
>>
>>  // rdar://8883302
>> Index: lib/Sema/SemaDecl.cpp
>> ===
>> --- lib/Sema/SemaDecl.cpp
>> +++ lib/Sema/SemaDecl.cpp
>> @@ -6406,6 +6406,11 @@
>>  }
>>  }
>>
>> +  // Don't warn on constructor parameters with the same name as a field
>> name.
>> +  if (isa(ShadowedDecl) && isa(NewDC) &&
>> +  isa(D))
>> +return;
>> +
>>DeclContext *OldDC = ShadowedDecl->getDeclContext();
>>
>>// Only warn about certain kinds of shadowing for class members.
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18395: -Wshadow: don't warn on ctor parameters with the same name as a field name

2016-03-23 Thread David Blaikie via cfe-commits
Reid sent out a different patch for this warning improvement. Have you
checked that one out? Is it abandoned?

I'm still a bit concerned about whitelisting all these cases & not catching
cases where the parameter is then used inside the function in some
problematic way (the classic being a unique_ptr parameter, moved into a
member, then the parameter (instead of the member) is referenced in the
body of the function).

On Wed, Mar 23, 2016 at 7:43 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> alexfh created this revision.
> alexfh added reviewers: rsmith, rnk.
> alexfh added a subscriber: cfe-commits.
>
> -Wshadow: don't warn on ctor parameters with the same name as a field
> name. This fixes a broad class of false positives resulting from a widely
> used
> pattern:
>
>   struct A {
> int q;
> A(int q) : q(q) {}
>   };
>
> Fixes http://llvm.org/PR16088.
>
> http://reviews.llvm.org/D18395
>
> Files:
>   lib/Sema/SemaDecl.cpp
>   test/SemaCXX/warn-shadow.cpp
>
> Index: test/SemaCXX/warn-shadow.cpp
> ===
> --- test/SemaCXX/warn-shadow.cpp
> +++ test/SemaCXX/warn-shadow.cpp
> @@ -71,6 +71,14 @@
>  };
>  }
>
> +// http://llvm.org/PR16088
> +namespace PR16088 {
> +struct S {
> +  int i;
> +  S(int i) : i(i) {}
> +};
> +}
> +
>  extern int bob; // expected-note {{previous declaration is here}}
>
>  // rdar://8883302
> Index: lib/Sema/SemaDecl.cpp
> ===
> --- lib/Sema/SemaDecl.cpp
> +++ lib/Sema/SemaDecl.cpp
> @@ -6406,6 +6406,11 @@
>  }
>  }
>
> +  // Don't warn on constructor parameters with the same name as a field
> name.
> +  if (isa(ShadowedDecl) && isa(NewDC) &&
> +  isa(D))
> +return;
> +
>DeclContext *OldDC = ShadowedDecl->getDeclContext();
>
>// Only warn about certain kinds of shadowing for class members.
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17852: Added formatAndApplyAllReplacements that works on multiple files in libTooling.

2016-03-23 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51433.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- removed format::getStyle test case from ToolingTests;


http://reviews.llvm.org/D17852

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/Refactoring.h
  lib/Format/Format.cpp
  lib/Tooling/CMakeLists.txt
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Format/FormatTest.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
@@ -166,6 +167,41 @@
   EXPECT_EQ("z", Context.getRewrittenText(IDz));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(formatAndApplyAllReplacements(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 TEST(ShiftedCodePositionTest, FindsNewCodePosition) {
   Replacements Replaces;
   Replaces.insert(Replacement("", 0, 1, ""));
@@ -426,7 +462,7 @@
   Replaces.insert(Replacement("foo", 10, 1, "zz"));
   Replaces.insert(Replacement("foo", 11, 0, ""));
 
-  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+  std::vector Ranges = calculateChangedRanges(Replaces);
 
   EXPECT_EQ(3ul, Ranges.size());
   EXPECT_TRUE(Ranges[0].getOffset() == 0);
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -30,6 +30,7 @@
   clangAST
   clangASTMatchers
   clangBasic
+  clangFormat
   clangFrontend
   clangLex
   clangRewrite
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11234,7 +11234,8 @@
 
   format::FormatStyle Style = format::getLLVMStyle();
   Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
-  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+  EXPECT_EQ(Expected, applyAllReplacements(
+  Code, formatReplacements(Code, Replaces, Style)));
 }
 
 } // end namespace
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Format/Format.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -61,5 +62,41 @@
   return Rewrite.overwriteChangedFiles() ? 1 : 0;
 }
 
+static bool formatAndApply(const Replacements , Rewriter ,
+   const format::FormatStyle *Style) {
+  SourceManager  = Rewrite.getSourceMgr();
+  FileManager  = SM.getFileManager();
+
+  auto FileToReplaces = groupReplacementsByFile(Replaces);
+
+  bool Result = true;
+  for (auto  : FileToReplaces) {
+const std::string FilePath = FileAndReplaces.first;
+

[PATCH] D18401: clang-cl: Include /FI headers in /showIncludes output.

2016-03-23 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis added a subscriber: cfe-commits.

`-H` in gcc mode doesn't print `-include` headers, but they are included in 
depfiles written by MMD and friends. Since `/showIncludes` is what's used 
instead of depfiles, printing `/FI` there seems important (and matches cl.exe).

There's more work to do for the interaction of `/FI`, `/showIncludes`, and PCH 
flags, but this is a strict improvement over what we have today.

Instead of giving HeaderIncludeGen more options, another approach would be to 
just switch on ShowAllHeaders in clang-cl mode and let 
clang::InitializePreprocessor() not put `-include` flags in the `` block. This would change the behavior of `-E` slightly, and it would 
remove the `` flag from the output triggered by setting the 
obscure `CC_PRINT_HEADERS=1` env var to true while running clang. So don't do 
that as it would change behavior. (But if someone reading this thinks that's ok 
to change, I'd prefer doing that, as it makes things simpler.)

http://reviews.llvm.org/D18401

Files:
  include/clang/Frontend/Utils.h
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/HeaderIncludeGen.cpp
  test/Driver/cl-pch-showincludes.cpp
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -1,24 +1,24 @@
-// RUN: cd %S
-// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.stderr
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E -H -o /dev/null %s 2> %t.stderr
 // RUN: FileCheck < %t.stderr %s
 
 // CHECK-NOT: test3.h
 // CHECK: . {{.*test.h}}
 // CHECK: .. {{.*test2.h}}
 
-// RUN: %clang_cc1 -include Inputs/test3.h -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS < %t.stdout %s
-// MS-NOT: test3.h
-// MS: Note: including file: {{.*test.h}}
-// MS: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -include Inputs/test3.h -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS %s
+// MS-NOT: 
+// MS: Note: including file: {{[^ ]*test3.h}}
+// MS: Note: including file: {{[^ ]*test.h}}
+// MS: Note: including file:  {{[^ ]*test2.h}}
 // MS-NOT: Note
 
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
-// RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s
-// MS-BLACKLIST: Note: including file: {{.*\.blacklist}}
-// MS-BLACKLIST: Note: including file: {{.*test.h}}
-// MS-BLACKLIST: Note: including file:  {{.*test2.h}}
+// RUN: %clang_cc1 -I%S -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o /dev/null %s | \
+// RUN: FileCheck --strict-whitespace --check-prefix=MS-BLACKLIST %s
+// MS-BLACKLIST: Note: including file: {{[^ ]*\.blacklist}}
+// MS-BLACKLIST: Note: including file: {{[^ ]*test.h}}
+// MS-BLACKLIST: Note: including file:  {{[^ ]*test2.h}}
 // MS-BLACKLIST-NOT: Note
 
 #include "Inputs/test.h"
Index: test/Driver/cl-pch-showincludes.cpp
===
--- test/Driver/cl-pch-showincludes.cpp
+++ test/Driver/cl-pch-showincludes.cpp
@@ -8,16 +8,17 @@
 
 // When building the pch, header1.h (included by header2.h), header2.h (the pch
 // input itself) and header3.h (included directly, above) should be printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YC %s
-// CHECK-YC: Note: including file: {{.+header2.h}}
-// CHECK-YC: Note: including file: {{.+header1.h}}
-// CHECK-YC: Note: including file: {{.+header3.h}}
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Ycheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YC %s
+// CHECK-YC: Note: including file: {{[^ ]*header2.h}}
+// FIXME: header1.h should be indented one more:
+// CHECK-YC: Note: including file: {{[^ ]*header1.h}}
+// CHECK-YC: Note: including file: {{[^ ]*header3.h}}
 
 // When using the pch, only the direct include is printed.
-// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-YU %s
+// RUN: %clang_cl -Werror /showIncludes /I%S/Inputs /Yuheader2.h /FIheader2.h /Fp%t.pch /c /Fo%t -- %s \
+// RUN:   | FileCheck --strict-whitespace -check-prefix=CHECK-YU %s
 // CHECK-YU-NOT: Note: including file: {{.*pch}}
 // CHECK-YU-NOT: Note: including file: {{.*header1.h}}
 // CHECK-YU-NOT: Note: including file: {{.*header2.h}}
-// CHECK-YU: Note: including file: {{.+header3.h}}
+// CHECK-YU: Note: including file: {{[^ ]*header3.h}}
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- 

Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-03-23 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

ping!


http://reviews.llvm.org/D17451



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


Re: [PATCH] D18399: Added support for different VFSs in format::getStyle.

2016-03-23 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 51431.
ioeric marked 3 inline comments as done.
ioeric added a comment.

- some more redundancy removed


http://reviews.llvm.org/D18399

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 #define DEBUG_TYPE "format-test"
@@ -11199,6 +11200,33 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+TEST(FormatStyle, GetStyleOfFile) {
+  vfs::InMemoryFileSystem FS;
+  // Test 1: format file in the same directory.
+  ASSERT_TRUE(
+  FS.addFile("/a/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: LLVM")));
+  ASSERT_TRUE(
+  FS.addFile("/a/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style1 = getStyle("file", "/a/.clang-format", "Google", );
+  ASSERT_EQ(Style1, getLLVMStyle());
+
+  // Test 2: fallback to default.
+  ASSERT_TRUE(
+  FS.addFile("/b/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style2 = getStyle("file", "/b/test.cpp", "Mozilla", );
+  ASSERT_EQ(Style2, getMozillaStyle());
+
+  // Test 3: format file in parent directory.
+  ASSERT_TRUE(
+  FS.addFile("/c/.clang-format", 0,
+ llvm::MemoryBuffer::getMemBuffer("BasedOnStyle: Google")));
+  ASSERT_TRUE(FS.addFile("/c/sub/sub/sub/test.cpp", 0,
+ llvm::MemoryBuffer::getMemBuffer("int i;")));
+  auto Style3 = getStyle("file", "/c/sub/sub/sub/test.cpp", "LLVM", );
+  ASSERT_EQ(Style3, getGoogleStyle());
+}
+
 class ReplacementTest : public ::testing::Test {
 protected:
   tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -2098,7 +2098,10 @@
 }
 
 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
- StringRef FallbackStyle) {
+ StringRef FallbackStyle, vfs::FileSystem *FS) {
+  if (!FS) {
+FS = vfs::getRealFileSystem().get();
+  }
   FormatStyle Style = getLLVMStyle();
   Style.Language = getLanguageByFileName(FileName);
   if (!getPredefinedStyle(FallbackStyle, Style.Language, )) {
@@ -2129,28 +2132,35 @@
   llvm::sys::fs::make_absolute(Path);
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
-if (!llvm::sys::fs::is_directory(Directory))
+
+auto Status = FS->status(Directory);
+if (!Status ||
+Status->getType() != llvm::sys::fs::file_type::directory_file) {
   continue;
+}
+
 SmallString<128> ConfigFile(Directory);
 
 llvm::sys::path::append(ConfigFile, ".clang-format");
 DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
-bool IsFile = false;
 // Ignore errors from is_regular_file: we only need to know if we can read
 // the file or not.
-llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
-
+Status = FS->status(ConfigFile.c_str());
+bool IsFile =
+Status && (Status->getType() == llvm::sys::fs::file_type::regular_file);
 if (!IsFile) {
   // Try _clang-format too, since dotfiles are not commonly used on Windows.
   ConfigFile = Directory;
   llvm::sys::path::append(ConfigFile, "_clang-format");
   DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
-  llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
+  Status = FS->status(ConfigFile.c_str());
+  IsFile = Status &&
+   (Status->getType() == llvm::sys::fs::file_type::regular_file);
 }
 
 if (IsFile) {
   llvm::ErrorOr Text =
-  llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+  FS->getBufferForFile(ConfigFile.c_str());
   if (std::error_code EC = Text.getError()) {
 llvm::errs() << EC.message() << "\n";
 break;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,6 +16,7 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -832,11 +833,13 @@
 /// == "file".
 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
 /// in case the style can't be determined from \p StyleName.
+/// \param[in] FS The underlying file system, in which the file resides. By
+/// default, the file system is the real file system.
 ///
 

Re: [PATCH] D18363: Fix typo s/initalize/initialize/

2016-03-23 Thread Chih-Hung Hsieh via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL264164: [analyzer] Fix typo s/initalize/initialize/ 
(authored by chh).

Changed prior to commit:
  http://reviews.llvm.org/D18363?vs=51307=51429#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18363

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -313,7 +313,7 @@
   if (L.isUndef()) {
 if (!BT_call_undef)
   BT_call_undef.reset(new BuiltinBug(
-  this, "Called function pointer is an uninitalized pointer value"));
+  this, "Called function pointer is an uninitialized pointer value"));
 emitBadCall(BT_call_undef.get(), C, Callee);
 return;
   }


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -313,7 +313,7 @@
   if (L.isUndef()) {
 if (!BT_call_undef)
   BT_call_undef.reset(new BuiltinBug(
-  this, "Called function pointer is an uninitalized pointer value"));
+  this, "Called function pointer is an uninitialized pointer value"));
 emitBadCall(BT_call_undef.get(), C, Callee);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >