r258495 - [OPENMP] Generalize codegen for 'sections'-based directive.

2016-01-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Jan 22 02:56:50 2016
New Revision: 258495

URL: http://llvm.org/viewvc/llvm-project?rev=258495&view=rev
Log:
[OPENMP] Generalize codegen for 'sections'-based directive.
If 'sections' directive has only one sub-section, the code for 'single'-based 
directive was emitted. Removed this codegen, because it causes crashes in 
different cases.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp
cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
cfe/trunk/test/OpenMP/parallel_sections_codegen.cpp
cfe/trunk/test/OpenMP/sections_codegen.cpp
cfe/trunk/test/OpenMP/sections_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/sections_private_codegen.cpp
cfe/trunk/test/OpenMP/sections_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=258495&r1=258494&r2=258495&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Jan 22 02:56:50 2016
@@ -483,7 +483,7 @@ llvm::Value *CGOpenMPRuntime::getThreadI
 if (ThreadID != nullptr)
   return ThreadID;
   }
-  if (auto OMPRegionInfo =
+  if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
 if (OMPRegionInfo->getThreadIDVariable()) {
   // Check if this an outlined function with thread id passed as argument.
@@ -1356,7 +1356,7 @@ void CGOpenMPRuntime::emitParallelCall(C
 // return the address of that temp.
 Address CGOpenMPRuntime::emitThreadIDAddress(CodeGenFunction &CGF,
  SourceLocation Loc) {
-  if (auto OMPRegionInfo =
+  if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo))
 if (OMPRegionInfo->getThreadIDVariable())
   return OMPRegionInfo->getThreadIDVariableLValue(CGF).getAddress();
@@ -1717,15 +1717,10 @@ void CGOpenMPRuntime::emitBarrierCall(Co
   }
   // Build call __kmpc_cancel_barrier(loc, thread_id) or __kmpc_barrier(loc,
   // thread_id);
-  auto *OMPRegionInfo =
-  dyn_cast_or_null(CGF.CapturedStmtInfo);
-  // Do not emit barrier call in the single directive emitted in some rare 
cases
-  // for sections directives.
-  if (OMPRegionInfo && OMPRegionInfo->getDirectiveKind() == OMPD_single)
-return;
   llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc, Flags),
  getThreadID(CGF, Loc)};
-  if (OMPRegionInfo) {
+  if (auto *OMPRegionInfo =
+  dyn_cast_or_null(CGF.CapturedStmtInfo)) {
 if (!ForceSimpleCall && OMPRegionInfo->hasCancel()) {
   auto *Result = CGF.EmitRuntimeCall(
   createRuntimeFunction(OMPRTL__kmpc_cancel_barrier), Args);
@@ -3649,8 +3644,6 @@ void CGOpenMPRuntime::emitCancellationPo
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->getDirectiveKind() == OMPD_single)
-  return;
 if (OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=258495&r1=258494&r2=258495&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Fri Jan 22 02:56:50 2016
@@ -1657,50 +1657,51 @@ OpenMPDirectiveKind
 CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
   auto *Stmt = cast(S.getAssociatedStmt())->getCapturedStmt();
   auto *CS = dyn_cast(Stmt);
-  if (CS && CS->size() > 1) {
-bool HasLastprivates = false;
-auto &&CodeGen = [&S, CS, &HasLastprivates](CodeGenFunction &CGF) {
-  auto &C = CGF.CGM.getContext();
-  auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, 
/*Signed=*/1);
-  // Emit helper vars inits.
-  LValue LB = createSectionLVal(CGF, KmpInt32Ty, ".omp.sections.lb.",
-CGF.Builder.getInt32(0));
-  auto *GlobalUBVal = CGF.Builder.getInt32(CS->size() - 1);
-  LValue UB =
-  createSectionLVal(CGF, KmpInt32Ty, ".omp.sections.ub.", GlobalUBVal);
-  LValue ST = createSectionLVal(CGF, KmpInt32Ty, ".omp.sections.st.",
-CGF.Builder.getInt32(1));
-  LValue IL = createSectionLVal(CGF, KmpInt32Ty, ".omp.sections.il.",
-CGF.Builder.getInt32(0));
-  // Loop counter.
-  LValue IV = createSectionLVal(CGF, KmpInt32Ty, ".omp.sections.iv.");
-  OpaqueValueExpr IVRefExpr(S.getLocStart(), KmpInt32Ty, VK_LValue);
-  CodeGenFunction::OpaqueValueMappi

Re: [PATCH] D16438: Fix printing of types in initializers with suppressed tags.

2016-01-22 Thread Nick Sumner via cfe-commits
nick.sumner retitled this revision from "Fix printing of nested variable 
declarations with suppressed tags" to "Fix printing of types in initializers 
with suppressed tags.".
nick.sumner updated the summary for this revision.
nick.sumner updated this revision to Diff 45658.
nick.sumner added a comment.

Updated to reset tag and specifier suppression precisely when printing 
initializers.


http://reviews.llvm.org/D16438

Files:
  lib/AST/DeclPrinter.cpp
  test/Sema/ast-print.c

Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -53,3 +53,13 @@
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
 struct pair_t p = {a: 3, .b = 4};
+
+void initializers() {
+  // CHECK: int *x = ((void *)0), *y = ((void *)0);
+  int *x = ((void *)0), *y = ((void *)0);
+  struct Z{};
+  struct {
+struct Z z;
+  // CHECK: } z = {(struct Z){}};
+  } z = {(struct Z){}};
+}
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -751,7 +751,10 @@
   else if (D->getInitStyle() == VarDecl::CInit) {
 Out << " = ";
   }
-  Init->printPretty(Out, nullptr, Policy, Indentation);
+  PrintingPolicy SubPolicy(Policy);
+  SubPolicy.SuppressSpecifiers = false;
+  SubPolicy.SuppressTag = false;
+  Init->printPretty(Out, nullptr, SubPolicy, Indentation);
   if ((D->getInitStyle() == VarDecl::CallInit) && 
!isa(Init))
 Out << ")";
 }


Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -53,3 +53,13 @@
 
 // CHECK: struct pair_t p = {a: 3, .b = 4};
 struct pair_t p = {a: 3, .b = 4};
+
+void initializers() {
+  // CHECK: int *x = ((void *)0), *y = ((void *)0);
+  int *x = ((void *)0), *y = ((void *)0);
+  struct Z{};
+  struct {
+struct Z z;
+  // CHECK: } z = {(struct Z){}};
+  } z = {(struct Z){}};
+}
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -751,7 +751,10 @@
   else if (D->getInitStyle() == VarDecl::CInit) {
 Out << " = ";
   }
-  Init->printPretty(Out, nullptr, Policy, Indentation);
+  PrintingPolicy SubPolicy(Policy);
+  SubPolicy.SuppressSpecifiers = false;
+  SubPolicy.SuppressTag = false;
+  Init->printPretty(Out, nullptr, SubPolicy, Indentation);
   if ((D->getInitStyle() == VarDecl::CallInit) && !isa(Init))
 Out << ")";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16413: Let RecursiveASTVisitor visit array index VarDecls

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

LG.
I'd probably add a test to unittests/Tooling/RecursiveASTVisitorTest.cpp.


http://reviews.llvm.org/D16413



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-22 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added a comment.

In http://reviews.llvm.org/D16310#331538, @LegalizeAdulthood wrote:

> If you state what the check does, then
>
> In http://reviews.llvm.org/D16310#331054, @danielmarjamaki wrote:
>
> > In http://reviews.llvm.org/D16310#330367, @LegalizeAdulthood wrote:
> >
> > > Why not supply a fixit that removes the cast?
> >
> >
> > I am skeptic. There are different valid fixes.
> >
> > Example code:
> >
> >   l = (long)(a*1000);
> >   
> >
> > Fix1:
> >
> >   l = ((long)a * 1000);
> >   
> >
> > Fix2:
> >
> >   l = (a * (long)1000);
> >   
> >
> > Fix3:
> >
> >   l = (a * 1000L);
>
>
> The way I see it, the check is complaining about the pointless cast and 
> pointing the finger at the beginning of the cast.  To me, my expectation is 
> that the suggested fix is none of the options you gave but instead:
>
>   l = (a*1000);
>


I expect that this warning will in most cases be fixed by moving the cast.

I believe there is often a bug in such code.

If you want that we hide these bugs by removing the casts I can do it.. but I 
personally think that is wrong.

And yes clang-tidy does not have static analysis. that would not help much to 
determine proper fix anyway - if we can see there is overflow then should it be 
fixed with fix 1,2,3 or is the overflow intentional.


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


Re: [PATCH] D16401: [OpenMP] Sema for depend clause on target exit data directive.

2016-01-22 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D16401



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


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-01-22 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 45681.
pxli168 marked 4 inline comments as done.
pxli168 added a comment.

Rewrite some comments and add missing invalid test case.


http://reviews.llvm.org/D16040

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/Parser/opencl-image-access.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-kernel-attrs.cl

Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -28,8 +28,8 @@
 
 void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
   int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only applies to parameters}}
 }
 
 kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 -DCL20 %s 
+
+void test1(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}} 
+
+void test2(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+#ifdef CL20
+void test4(read_write image1d_t i){} 
+
+void test5(read_write pipe int i){} // expected-error{{access qualifier read_write can not be used for 'pipe'}}
+#else
+void test4(read_write image1d_t i){} // expected-error{{access qualifier read_write can not be used for 'image1d_t' earlier than OpenCL2.0 version}}
+#endif
Index: test/Parser/opencl-image-access.cl
===
--- test/Parser/opencl-image-access.cl
+++ test/Parser/opencl-image-access.cl
@@ -1,14 +1,18 @@
 // RUN: %clang_cc1 %s -fsyntax-only
+// RUN: %clang_cc1 %s -fsyntax-only -cl-std=CL2.0 -DCL20
 
 __kernel void f__ro(__read_only image2d_t a) { }
 
 __kernel void f__wo(__write_only image2d_t a) { }
 
+#if CL20
 __kernel void f__rw(__read_write image2d_t a) { }
-
+#endif
 
 __kernel void fro(read_only image2d_t a) { }
 
 __kernel void fwo(write_only image2d_t a) { }
 
+#if CL20
 __kernel void frw(read_write image2d_t a) { }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6217,6 +6217,17 @@
   CurType = S.Context.getVectorType(CurType, numElts, VecKind);
 }
 
+/// Handle OpenCL Access Qualifier Attribute
+static void HandleOpenCLAccessAttr(QualType &CurType, const AttributeList &Attr,
+   Sema &S) {
+  // OpenCL v2.0 s6.6: Access Qualifier can used only for image and pipe type
+  if (!(CurType->isImageType() || CurType->isPipeType())) {
+S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier);
+Attr.setInvalid();
+return;
+  }
+}
+
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
  TypeAttrLocation TAL, AttributeList *attrs) {
   // Scan through and apply attributes to this type where it makes sense.  Some
@@ -6312,9 +6323,8 @@
VectorType::NeonPolyVector);
   attr.setUsedAsTypeAttr();
   break;
-case AttributeList::AT_OpenCLImageAccess:
-  // FIXME: there should be some type checking happening here, I would
-  // imagine, but the original handler's checking was entirely superfluous.
+case AttributeList::AT_OpenCLAccess:
+  HandleOpenCLAccessAttr(type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
   break;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4923,6 +4923,41 @@
   return false;
 }
 
+static void handleOpenCLAccessAttr(Sema &S, Decl *D,
+   const AttributeList &Attr) {
+  if (D->isInvalidDecl())
+return;
+
+  // Check if there only one access qualifier
+  if (D->hasAttr()) {
+S.Diag(D->getLocation(), diag::err_opencl_multiple_access_qualifiers)
+<< D->getSourceRange(

r258500 - Replace some tabs with spaces.

2016-01-22 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan 22 08:12:44 2016
New Revision: 258500

URL: http://llvm.org/viewvc/llvm-project?rev=258500&view=rev
Log:
Replace some tabs with spaces.

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

Modified: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=258500&r1=258499&r2=258500&view=diff
==
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp Fri Jan 22 08:12:44 
2016
@@ -42,13 +42,13 @@ TEST(RecursiveASTVisitor, VisitsLambdaEx
   LambdaExprVisitor Visitor;
   Visitor.ExpectMatch("", 1, 12);
   EXPECT_TRUE(Visitor.runOver("void f() { []{ return; }(); }",
- LambdaExprVisitor::Lang_CXX11));
+  LambdaExprVisitor::Lang_CXX11));
 }
 
 TEST(RecursiveASTVisitor, TraverseLambdaBodyCanBeOverridden) {
   LambdaExprVisitor Visitor;
   EXPECT_TRUE(Visitor.runOver("void f() { []{ return; }(); }",
- LambdaExprVisitor::Lang_CXX11));
+  LambdaExprVisitor::Lang_CXX11));
   EXPECT_TRUE(Visitor.allBodiesHaveBeenTraversed());
 }
 
@@ -92,8 +92,7 @@ private:
 
 TEST(RecursiveASTVisitor, LambdaClosureTypesAreImplicit) {
   ClassVisitor Visitor;
-  EXPECT_TRUE(Visitor.runOver("auto lambda = []{};",
- ClassVisitor::Lang_CXX11));
+  EXPECT_TRUE(Visitor.runOver("auto lambda = []{};", 
ClassVisitor::Lang_CXX11));
   EXPECT_TRUE(Visitor.sawOnlyImplicitLambdaClasses());
 }
 


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


Re: [PATCH] D16376: clang-tidy check: User-defined copy without assignment

2016-01-22 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/misc/UserDefinedCopyWithoutAssignmentCheck.h:25
@@ +24,3 @@
+/// assignment operator to be `= delete`.
+///
+/// For the user-facing documentation see:

jbcoe wrote:
> The standard says that compiler generation of the assignment operator is 
> deprecated if there is a user-defined copy constructor 12.8.18 . 
> 
> '= default' still counts as user-defined to the best of my understanding.
> 
> MSVC, clang and gcc all generate assignment operators in the face of deleted 
> copy constructors. None of them seem to follow the deprecation rule.
> 
> I agree entirely with your point in principle, but it seems to be at odds 
> with the standard. I think requiring the user to explicitly default the 
> assignment operator by generating a deleted assignment operator is the right 
> thing to do.
On reflection this is pedantic. As you say if a user defaults one, they will 
want to default the other. 


http://reviews.llvm.org/D16376



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


r258502 - [OpenMP] Sema for depend clause on target exit data directive.

2016-01-22 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Fri Jan 22 08:58:21 2016
New Revision: 258502

URL: http://llvm.org/viewvc/llvm-project?rev=258502&view=rev
Log:
[OpenMP] Sema for depend clause on target exit data directive.

Summary:
Accept depend clause on target exit data directive in sema and add test cases.

Reviewers: ABataev

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


Added:
cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=258502&r1=258501&r2=258502&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Fri Jan 22 08:58:21 2016
@@ -372,11 +372,11 @@ OPENMP_TARGET_ENTER_DATA_CLAUSE(nowait)
 OPENMP_TARGET_ENTER_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'target exit data'.
-// TODO More clauses for 'target exit data' directive.
 OPENMP_TARGET_EXIT_DATA_CLAUSE(if)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(device)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(map)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(nowait)
+OPENMP_TARGET_EXIT_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'teams'.
 // TODO More clauses for 'teams' directive.

Modified: cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp?rev=258502&r1=258501&r2=258502&view=diff
==
--- cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp Fri Jan 22 08:58:21 
2016
@@ -43,6 +43,22 @@ T tmain(T argc, T *argv) {
 
 #pragma omp target exit data nowait map(always,release: e)
 
+#pragma omp target exit data depend(in : argc, argv[i:argc], x[:]) nowait 
map(from: i)
+
+#pragma omp target exit data nowait depend(in : argc, argv[i:argc], x[:]) 
map(from: i) if (target exit data: j > 0)
+
+#pragma omp target exit data map(from: i) depend(in : argc, argv[i:argc], 
x[:]) if (b) nowait
+
+#pragma omp target exit data map(from: c) depend(in : argc, argv[i:argc], 
x[:]) nowait
+
+#pragma omp target exit data map(from: c) depend(in : argc, argv[i:argc], 
x[:]) nowait if(b>e)
+
+#pragma omp target exit data nowait map(release: x[0:10], c) depend(in : argc, 
argv[i:argc], x[:])
+
+#pragma omp target exit data nowait map(from: c) depend(in : argc, 
argv[i:argc], x[:]) map(release: d)
+
+#pragma omp target exit data depend(in : argc, argv[i:argc], x[:]) nowait 
map(always,release: e)
+
   return 0;
 }
 
@@ -65,6 +81,14 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c)
 // CHECK-NEXT: #pragma omp target exit data nowait map(from: c) map(release: d)
 // CHECK-NEXT: #pragma omp target exit data nowait map(always,release: e)
+// CHECK-NEXT: #pragma omp target exit data depend(in : 
argc,argv[i:argc],x[:]) nowait map(from: i)
+// CHECK-NEXT: #pragma omp target exit data nowait depend(in : 
argc,argv[i:argc],x[:]) map(from: i) if(target exit data: j > 0)
+// CHECK-NEXT: #pragma omp target exit data map(from: i) depend(in : 
argc,argv[i:argc],x[:]) if(b) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) depend(in : 
argc,argv[i:argc],x[:]) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) depend(in : 
argc,argv[i:argc],x[:]) nowait if(b > e)
+// CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c) 
depend(in : argc,argv[i:argc],x[:])
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: c) depend(in : 
argc,argv[i:argc],x[:]) map(release: d)
+// CHECK-NEXT: #pragma omp target exit data depend(in : 
argc,argv[i:argc],x[:]) nowait map(always,release: e)
 // CHECK: template  char tmain(char argc, char 
*argv) {
 // CHECK-NEXT: char i, j, b, c, d, e, x[20];
 // CHECK-NEXT: i = argc;
@@ -84,6 +108,14 @@ T tmain(T argc, T *argv) {
 // CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c)
 // CHECK-NEXT: #pragma omp target exit data nowait map(from: c) map(release: d)
 // CHECK-NEXT: #pragma omp target exit data nowait map(always,release: e)
+// CHECK-NEXT: #pragma omp target exit data depend(in : 
argc,argv[i:argc],x[:]) nowait map(from: i)
+// CHECK-NEXT: #pragma omp target exit data nowait depend(in : 
argc,argv[i:argc],x[:]) map(from: i) if(target exit data: j > 0)
+// CHECK-NEXT: #pragma omp target exit data map(from: i) depend(in : 
argc,argv[i:argc],x[:]) if(b) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) depend(in : 
argc,argv[i:argc],x[:]) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) depend(in : 
argc,argv[i:argc],x[:]) nowait if(b > e)
+// CHECK-NEXT: #pragma omp ta

Re: [PATCH] D16401: [OpenMP] Sema for depend clause on target exit data directive.

2016-01-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258502: [OpenMP] Sema for depend clause on target exit data 
directive. (authored by arpith).

Changed prior to commit:
  http://reviews.llvm.org/D16401?vs=45532&id=45684#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16401

Files:
  cfe/trunk/include/clang/Basic/OpenMPKinds.def
  cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
  cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp

Index: cfe/trunk/include/clang/Basic/OpenMPKinds.def
===
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def
@@ -372,11 +372,11 @@
 OPENMP_TARGET_ENTER_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'target exit data'.
-// TODO More clauses for 'target exit data' directive.
 OPENMP_TARGET_EXIT_DATA_CLAUSE(if)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(device)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(map)
 OPENMP_TARGET_EXIT_DATA_CLAUSE(nowait)
+OPENMP_TARGET_EXIT_DATA_CLAUSE(depend)
 
 // Clauses allowed for OpenMP directive 'teams'.
 // TODO More clauses for 'teams' directive.
Index: cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
===
--- cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
+++ cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+template 
+int tmain(T argc, S **argv, R *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  char *arr;
+
+  int i;
+  #pragma omp target exit data map(from: i) depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[0])
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : tmain) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to 

[PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan created this revision.
ehsan added a reviewer: rnk.
ehsan added a subscriber: cfe-commits.

In the Microsoft ABI, some expressions containing references to variables
cannot be evaluated as a constant.  These are expressions containing a
conditional, logical and/or, or comma operator with an operand that is a
variable name.

This is observable at the ABI level by whether the compiler would emit a
static initializer for such expressions where normally it would emit a
readonly constant data.  See PR26210 for more details.

http://reviews.llvm.org/D16465

Files:
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp
  test/CodeGenCXX/static-init-msvc.cpp

Index: test/CodeGenCXX/static-init-msvc.cpp
===
--- /dev/null
+++ test/CodeGenCXX/static-init-msvc.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -fms-extensions -emit-llvm -O0 -w -o - %s | FileCheck %s --check-prefix GNU
+
+void fun_and() {
+// CHECK-LABEL: @"\01?fun_and@@YAXXZ"()
+// GNU-LABEL: @_Z7fun_andv()
+  static int k;
+  static const int foo = 0 && k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_and@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_or() {
+// CHECK-LABEL: @"\01?fun_or@@YAXXZ"()
+// GNU-LABEL: @_Z6fun_orv()
+  static int k;
+  static const int foo = 1 || k;
+// CHECK: init:
+// CHECK-NEXT: store i32 1, i32* @"\01?foo@?1??fun_or@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_comma() {
+// CHECK-LABEL: @"\01?fun_comma@@YAXXZ"()
+// GNU-LABEL: @_Z9fun_commav()
+  static int k;
+  static const int foo = (k, 0);
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_comma@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
+
+void fun_cond() {
+// CHECK-LABEL: @"\01?fun_cond@@YAXXZ"()
+// GNU-LABEL: @_Z8fun_condv()
+  static int k;
+  static const int foo = true ? 0 : k;
+// CHECK: init:
+// CHECK-NEXT: store i32 0, i32* @"\01?foo@?1??fun_cond@@YAXXZ@4HB", align 4
+// GNU: entry:
+// GNU-NEXT: ret void
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -477,6 +477,19 @@
 /// fold (not just why it's not strictly a constant expression)?
 bool HasFoldFailureDiagnostic;
 
+/// \brief True if we need to obey the Microsoft ABI.  This affects whether
+/// some expressions can be evaluated as a constant if they refer to
+/// variables in some cases.  See PR26210 for the discussion.
+bool IsMicrosoftABI;
+
+/// \brief True if we are looking for a DeclRefExpr.
+bool LookingForDeclRefExpr;
+
+/// \brief True if we have observed a DeclRefExpr since the last time that
+/// awaitDeclRefExpr() was called.  This is used in order to handle Microsoft
+/// ABI requirements.
+bool HaveSeenDeclRefExpr;
+
 enum EvaluationMode {
   /// Evaluate as a constant expression. Stop if we find that the expression
   /// is not a constant expression.
@@ -541,7 +554,9 @@
 BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
 EvaluatingDecl((const ValueDecl *)nullptr),
 EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
-HasFoldFailureDiagnostic(false), EvalMode(Mode) {}
+HasFoldFailureDiagnostic(false), IsMicrosoftABI(false),
+LookingForDeclRefExpr(false), HaveSeenDeclRefExpr(false),
+EvalMode(Mode) {}
 
 void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value) {
   EvaluatingDecl = Base;
@@ -766,6 +781,22 @@
 bool allowInvalidBaseExpr() const {
   return EvalMode == EM_DesignatorFold;
 }
+
+/// Use the Microsoft ABI during evaluation.
+void useMicrosoftABI() {
+  IsMicrosoftABI = true;
+}
+
+/// Start watching for a DeclRefExpr.
+void awaitDeclRefExpr() {
+  LookingForDeclRefExpr = true;
+  HaveSeenDeclRefExpr = false;
+}
+
+/// Remember that we have observed a DeclRefExpr.
+void noteDeclRefExpr() {
+  HaveSeenDeclRefExpr = true;
+}
   };
 
   /// Object used to treat all foldable expressions as constant expressions.
@@ -814,13 +845,14 @@
   /// RAII object used to suppress diagnostics and side-effects from a
   /// speculative evaluation.
   class SpeculativeEvaluationRAII {
-EvalInfo &Info;
 Expr::EvalStatus Old;
+  protected:
+EvalInfo &Info;
 
   public:
 SpeculativeEvaluationRAII(EvalInfo &Info,
 SmallVectorImpl *NewDiag = nullptr)
-  : Info(Info), Old(Info.EvalStatus) {
+

Re: [PATCH] D16413: Let RecursiveASTVisitor visit array index VarDecls

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

r258503, thanks! (with the extra test)


http://reviews.llvm.org/D16413



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


Re: [PATCH] D16344: [libcxx] Fix PR26103 - Error calling is_convertible with incomplete type

2016-01-22 Thread Michael Daniels via cfe-commits
mdaniels updated this revision to Diff 45685.

http://reviews.llvm.org/D16344

Files:
  include/type_traits
  test/std/utilities/meta/meta.rel/is_convertible.pass.cpp

Index: test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
===
--- test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
+++ test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -52,6 +52,11 @@
   NonCopyable(NonCopyable&);
 };
 
+template 
+class CannotInstantiate {
+  enum { X = T::ThisExpressionWillBlowUp };
+};
+
 int main()
 {
 // void
@@ -206,4 +211,7 @@
 test_is_not_convertible();
 #endif
 
+// Ensure that CannotInstantiate is not instantiated by is_convertible 
when it is not needed.
+// For example CannotInstantiate is instatiated as a part of ADL lookup 
for arguments of type CannotInstantiate*.
+static_assert((std::is_convertible*, 
CannotInstantiate*>::value), "");
 }
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -1347,10 +1347,9 @@
 
 template 
 struct __is_convertible_test<_From, _To,
-decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
+
decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))>
 : public true_type
 {};
 
-template  __two __test(...);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template  _Tp&& __source();
 #else


Index: test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
===
--- test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
+++ test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -52,6 +52,11 @@
   NonCopyable(NonCopyable&);
 };
 
+template 
+class CannotInstantiate {
+  enum { X = T::ThisExpressionWillBlowUp };
+};
+
 int main()
 {
 // void
@@ -206,4 +211,7 @@
 test_is_not_convertible();
 #endif
 
+// Ensure that CannotInstantiate is not instantiated by is_convertible when it is not needed.
+// For example CannotInstantiate is instatiated as a part of ADL lookup for arguments of type CannotInstantiate*.
+static_assert((std::is_convertible*, CannotInstantiate*>::value), "");
 }
Index: include/type_traits
===
--- include/type_traits
+++ include/type_traits
@@ -1347,10 +1347,9 @@
 
 template 
 struct __is_convertible_test<_From, _To,
-decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
+decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
 {};
 
-template  __two __test(...);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template  _Tp&& __source();
 #else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan added inline comments.


Comment at: lib/AST/ExprConstant.cpp:4113
@@ +4112,3 @@
+  if (!CheckPotentialExpressionContainingDeclRefExpr(E->getTrueExpr(),
+  E->getFalseExpr()))
+return false;

Oops, sorry, just noticed this whitespace issue, will fix when landing!


http://reviews.llvm.org/D16465



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


r258503 - Let RecursiveASTVisitor visit array index VarDecls

2016-01-22 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan 22 09:11:54 2016
New Revision: 258503

URL: http://llvm.org/viewvc/llvm-project?rev=258503&view=rev
Log:
Let RecursiveASTVisitor visit array index VarDecls

An implicit copy ctor creates loop VarDecls that hang off CXXCtorInitializer.
RecursiveASTVisitor used to not visit them, so that they didn't show up in the
parent map used by ASTMatchers, causing asserts() when the implicit
DeclRefExpr() in a CXXCtorInitializer referred to one of these VarDecls.

Fixes PR26227.
http://reviews.llvm.org/D16413

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258503&r1=258502&r2=258503&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jan 22 09:11:54 2016
@@ -809,6 +809,10 @@ bool RecursiveASTVisitor::Trave
 
   if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
 TRY_TO(TraverseStmt(Init->getInit()));
+
+  if (Init->getNumArrayIndices() && getDerived().shouldVisitImplicitCode())
+for (VarDecl *VD : Init->getArrayIndexes())
+  TRY_TO(TraverseDecl(VD));
   return true;
 }
 

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=258503&r1=258502&r2=258503&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Fri Jan 22 09:11:54 2016
@@ -4217,6 +4217,14 @@ TEST(HasAncestor, MatchesAllAncestors) {
   
hasAncestor(cxxRecordDecl(unless(isTemplateInstantiation(;
 }
 
+TEST(HasAncestor, ImplicitArrayCopyCtorDeclRefExpr) {
+  EXPECT_TRUE(matches("struct MyClass {\n"
+  "  int c[1];\n"
+  "  static MyClass Create() { return MyClass(); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"

Modified: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=258503&r1=258502&r2=258503&view=diff
==
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp Fri Jan 22 09:11:54 
2016
@@ -133,4 +133,23 @@ TEST(RecursiveASTVisitor, AttributesAreV
 "};\n"));
 }
 
+// Check to ensure that VarDecls are visited.
+class VarDeclVisitor : public ExpectedLocationVisitor {
+public:
+  bool VisitVarDecl(VarDecl *VD) {
+Match(VD->getNameAsString(), VD->getLocStart());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, ArrayInitializersAreVisited) {
+  VarDeclVisitor Visitor;
+  Visitor.ExpectMatch("__i0", 1, 8);
+  EXPECT_TRUE(
+  Visitor.runOver("struct MyClass {\n"
+  "  int c[1];\n"
+  "  static MyClass Create() { return MyClass(); }\n"
+  "};\n"));
+}
+
 } // end anonymous namespace


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


r258504 - Change of UserLabelPrefix default value from "_" to ""

2016-01-22 Thread Andrey Bokhanko via cfe-commits
Author: asbokhan
Date: Fri Jan 22 09:24:34 2016
New Revision: 258504

URL: http://llvm.org/viewvc/llvm-project?rev=258504&view=rev
Log:
Change of UserLabelPrefix default value from "_" to ""

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

Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=258504&r1=258503&r2=258504&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Jan 22 09:24:34 2016
@@ -72,7 +72,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   DoubleFormat = &llvm::APFloat::IEEEdouble;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble;
   DataLayoutString = nullptr;
-  UserLabelPrefix = "_";
+  UserLabelPrefix = "";
   MCountName = "mcount";
   RegParmMax = 0;
   SSERegParmMax = 0;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=258504&r1=258503&r2=258504&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Jan 22 09:24:34 2016
@@ -102,9 +102,7 @@ protected:
 
 public:
   CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
@@ -242,6 +240,7 @@ public:
   this->TLSSupported = !Triple.isOSVersionLT(2);
 
 this->MCountName = "\01mcount";
+this->UserLabelPrefix = "_";
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {
@@ -284,8 +283,6 @@ protected:
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +324,6 @@ protected:
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) 
{
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +363,7 @@ protected:
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +385,7 @@ protected:
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -467,7 +458,6 @@ protected:
   }
 public:
   NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +478,6 @@ protected:
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) 
{
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +525,6 @@ protected:
   }
 public:
   BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +542,7 @@ protected:
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,7 +562,6 @@ protected:
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
@@ -604,7 +589,6 @@ public:
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 switch (Triple.getArch()) {
 default:
@@ -724,7 +708,6 @@ protected:
 
 public:
   NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongAlign = 32;
 this->LongWidth = 32;
 this->PointerAlign = 32;
@@ -778,7 +761,6 @@ public:
   explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
 this->MCountName = "__mcount";
-this->UserLabelPrefix = "";
 this->TheCXXABI.set(TargetCXXABI::WebAssembly);
   }
 };
@@ -816,6 +798,7 @@ public:
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }
 
   /// \brief Flags for architecture specific defines.
@@ -1631,6 +16

Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258504: Change of UserLabelPrefix default value from "_" to 
"" (authored by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D16295?vs=45177&id=45687#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16295

Files:
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets.cpp

Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -72,7 +72,7 @@
   DoubleFormat = &llvm::APFloat::IEEEdouble;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble;
   DataLayoutString = nullptr;
-  UserLabelPrefix = "_";
+  UserLabelPrefix = "";
   MCountName = "mcount";
   RegParmMax = 0;
   SSERegParmMax = 0;
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -102,9 +102,7 @@
 
 public:
   CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
@@ -242,6 +240,7 @@
   this->TLSSupported = !Triple.isOSVersionLT(2);
 
 this->MCountName = "\01mcount";
+this->UserLabelPrefix = "_";
   }
 
   std::string isValidSectionSpecifier(StringRef SR) const override {
@@ -284,8 +283,6 @@
 public:
   DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -327,8 +324,6 @@
   }
 public:
   FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-
 switch (Triple.getArch()) {
 default:
 case llvm::Triple::x86:
@@ -368,9 +363,7 @@
   }
 public:
   KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  : OSTargetInfo(Triple) {}
 };
 
 // Minix Target
@@ -392,9 +385,7 @@
 DefineStd(Builder, "unix", Opts);
   }
 public:
-  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  MinixTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // Linux target
@@ -467,7 +458,6 @@
   }
 public:
   NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "_mcount";
   }
 };
@@ -488,7 +478,6 @@
   }
 public:
   OpenBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->TLSSupported = false;
 
   switch (Triple.getArch()) {
@@ -536,7 +525,6 @@
   }
 public:
   BitrigTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->MCountName = "__mcount";
   }
 };
@@ -554,9 +542,7 @@
 Builder.defineMacro("__ELF__");
   }
 public:
-  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
-  }
+  PSPTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {}
 };
 
 // PS3 PPU Target
@@ -576,7 +562,6 @@
   }
 public:
   PS3PPUTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongWidth = this->LongAlign = 32;
 this->PointerWidth = this->PointerAlign = 32;
 this->IntMaxType = TargetInfo::SignedLongLong;
@@ -604,7 +589,6 @@
 
 // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
 this->MaxTLSAlign = 256;
-this->UserLabelPrefix = "";
 
 switch (Triple.getArch()) {
 default:
@@ -724,7 +708,6 @@
 
 public:
   NaClTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
-this->UserLabelPrefix = "";
 this->LongAlign = 32;
 this->LongWidth = 32;
 this->PointerAlign = 32;
@@ -778,7 +761,6 @@
   explicit WebAssemblyOSTargetInfo(const llvm::Triple &Triple)
   : OSTargetInfo(Triple) {
 this->MCountName = "__mcount";
-this->UserLabelPrefix = "";
 this->TheCXXABI.set(TargetCXXABI::WebAssembly);
   }
 };
@@ -816,6 +798,7 @@
 SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble;
+UserLabelPrefix = "_";
   }
 
   /// \brief Flags for architecture specific defines.
@@ -1631,6 +1614,7 @@
 NoAsmVariants = true;
 // Set the default GPU to sm20
 GPU = GK_SM20;
+UserLabelPrefix = "_";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3671,6 +3655,8 @@
 // FIXME: Check that we actually have cmpxchg8b before setting
 // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+
+UserLabe

Re: [PATCH] D16444: AMDGPU: Rename builtins to use amdgcn prefix

2016-01-22 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
tstellarAMD added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D16444



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


Re: [PATCH] D16295: Change of UserLabelPrefix default value from "_" to ""

2016-01-22 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Rafael, thanks for the review!

In http://reviews.llvm.org/D16295#329929, @rafael wrote:

> I am pretty sure the cases in init.c are wrong as the assembly itself
>  doesn't use a '_'.
>
> Having said that, it is probably a good thing to do this in two steps.
>  So this patch LGTM on the condition that you also open a bug to audit
>  the cases where we define __USER_LABEL_PREFIX__ to _ in init.c and CC
>  whoever added those.


Done. https://llvm.org/bugs/show_bug.cgi?id=26255

Yours,
Andrey


Repository:
  rL LLVM

http://reviews.llvm.org/D16295



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


r258505 - Try to pacify MSVC.

2016-01-22 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Jan 22 09:49:53 2016
New Revision: 258505

URL: http://llvm.org/viewvc/llvm-project?rev=258505&view=rev
Log:
Try to pacify MSVC.

I'm not sure why it needs these braces, but they help locally.

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

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258505&r1=258504&r2=258505&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jan 22 09:49:53 2016
@@ -811,8 +811,9 @@ bool RecursiveASTVisitor::Trave
 TRY_TO(TraverseStmt(Init->getInit()));
 
   if (Init->getNumArrayIndices() && getDerived().shouldVisitImplicitCode())
-for (VarDecl *VD : Init->getArrayIndexes())
+for (VarDecl *VD : Init->getArrayIndexes()) {
   TRY_TO(TraverseDecl(VD));
+}
   return true;
 }
 


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


Re: r258505 - Try to pacify MSVC.

2016-01-22 Thread Nico Weber via cfe-commits
Fun fact: cl.exe refuses to compile this program:

#include 
void f(std::vector v) {
  for (int i : v)
do {} while(false);
}

¯\_(ツ)_/¯

On Fri, Jan 22, 2016 at 10:49 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Fri Jan 22 09:49:53 2016
> New Revision: 258505
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258505&view=rev
> Log:
> Try to pacify MSVC.
>
> I'm not sure why it needs these braces, but they help locally.
>
> Modified:
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=258505&r1=258504&r2=258505&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Jan 22 09:49:53
> 2016
> @@ -811,8 +811,9 @@ bool RecursiveASTVisitor::Trave
>  TRY_TO(TraverseStmt(Init->getInit()));
>
>if (Init->getNumArrayIndices() &&
> getDerived().shouldVisitImplicitCode())
> -for (VarDecl *VD : Init->getArrayIndexes())
> +for (VarDecl *VD : Init->getArrayIndexes()) {
>TRY_TO(TraverseDecl(VD));
> +}
>return true;
>  }
>
>
>
> ___
> 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


r258506 - [MSVC Compat] Don't provide /volatile:ms semantics to types > pointer

2016-01-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Jan 22 10:36:44 2016
New Revision: 258506

URL: http://llvm.org/viewvc/llvm-project?rev=258506&view=rev
Log:
[MSVC Compat] Don't provide /volatile:ms semantics to types > pointer

Volatile loads of type wider than a pointer get split by MSVC because
the base x86 ISA doesn't provide loads which are wider than pointer
width.  LLVM assumes that it can emit an cmpxchg8b but this is
problematic if the memory is in a CONST memory segment.

Instead, provide behavior compatible with MSVC: split loads wider than a
pointer.

Modified:
cfe/trunk/lib/CodeGen/CGAtomic.cpp
cfe/trunk/test/CodeGen/ms-volatile.c

Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=258506&r1=258505&r2=258506&view=diff
==
--- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Jan 22 10:36:44 2016
@@ -1295,10 +1295,23 @@ bool CodeGenFunction::LValueIsSuitableFo
 /// performing such an operation can be performed without a libcall.
 bool CodeGenFunction::typeIsSuitableForInlineAtomic(QualType Ty,
 bool IsVolatile) const {
+  // The operation must be volatile for us to make it atomic.
+  if (!IsVolatile)
+return false;
+  // The -fms-volatile flag must be passed for us to adopt this behavior.
+  if (!CGM.getCodeGenOpts().MSVolatile)
+return false;
+
   // An atomic is inline if we don't need to use a libcall (e.g. it is 
builtin).
-  bool AtomicIsInline = getContext().getTargetInfo().hasBuiltinAtomic(
-  getContext().getTypeSize(Ty), getContext().getTypeAlign(Ty));
-  return CGM.getCodeGenOpts().MSVolatile && IsVolatile && AtomicIsInline;
+  if (!getContext().getTargetInfo().hasBuiltinAtomic(
+  getContext().getTypeSize(Ty), getContext().getTypeAlign(Ty)))
+return false;
+
+  // MSVC doesn't seem to do this for types wider than a pointer.
+  if (getContext().getTypeSize(Ty) >
+  getContext().getTypeSize(getContext().getIntPtrType()))
+return false;
+  return true;
 }
 
 RValue CodeGenFunction::EmitAtomicLoad(LValue LV, SourceLocation SL,

Modified: cfe/trunk/test/CodeGen/ms-volatile.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-volatile.c?rev=258506&r1=258505&r2=258506&view=diff
==
--- cfe/trunk/test/CodeGen/ms-volatile.c (original)
+++ cfe/trunk/test/CodeGen/ms-volatile.c Fri Jan 22 10:36:44 2016
@@ -52,11 +52,23 @@ void test7(volatile struct bar *p, volat
 void test8(volatile double *p, volatile double *q) {
   *p = *q;
   // CHECK-LABEL: @test8
-  // CHECK: load atomic volatile {{.*}} acquire
-  // CHECK: store atomic volatile {{.*}}, {{.*}} release
+  // CHECK: load volatile {{.*}}
+  // CHECK: store volatile {{.*}}, {{.*}}
 }
 void test9(volatile baz *p, baz *q) {
   *p = *q;
   // CHECK-LABEL: @test9
   // CHECK: store atomic volatile {{.*}}, {{.*}} release
 }
+void test10(volatile long long *p, volatile long long *q) {
+  *p = *q;
+  // CHECK-LABEL: @test10
+  // CHECK: load volatile {{.*}}
+  // CHECK: store volatile {{.*}}, {{.*}}
+}
+void test11(volatile float *p, volatile float *q) {
+  *p = *q;
+  // CHECK-LABEL: @test11
+  // CHECK: load atomic volatile {{.*}} acquire
+  // CHECK: store atomic volatile {{.*}}, {{.*}} release
+}


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


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread David Majnemer via cfe-commits
majnemer added a subscriber: majnemer.
majnemer added a comment.

Adding @rsmith as a reviewer.


http://reviews.llvm.org/D16465



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


[PATCH] D16467: [libcxx] re.results.form: Format out-of-range subexpression references as null

2016-01-22 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: EricWF, mclow.lists.
dexonsmith added a subscriber: cfe-commits.

Rather than crashing in match_results::format() when a reference to a
marked subexpression is out of range, format the subexpression as
empty (i.e., replace it with an empty string).

The standard doesn't require that marked subexpression references are
valid (the only preconditions are that ready() == true and that Out is
an output iterator), so the implementation shouldn't segfault on
out-of-range marked subexpressions.  The most user-friendly behaviour
(and the easiest to implement) is to treat them as "null" sub-matches.
Another option that I rejected is to leave them un-substituted.

I'm not sure about my choice of where to put the tests.  I considered
duplicating them across all four form*.pass.cpp, but thought I'd get
some feedback first.

http://reviews.llvm.org/D16467

Files:
  include/regex
  test/std/re/re.results/re.results.form/form1.pass.cpp

Index: test/std/re/re.results/re.results.form/form1.pass.cpp
===
--- test/std/re/re.results/re.results.form/form1.pass.cpp
+++ test/std/re/re.results/re.results.form/form1.pass.cpp
@@ -38,6 +38,31 @@
 {
 std::match_results m;
 const char s[] = "abcdefghijk";
+assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+  
std::regex_constants::nosubs)));
+
+char out[100] = {0};
+const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: 
$2";
+char* r = m.format(output_iterator(out),
+fmt, fmt + std::char_traits::length(fmt)).base();
+assert(r == out + 54);
+assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
m[1]: , m[2]: ");
+}
+{
+std::match_results m;
+const char s[] = "abcdefghijk";
+assert(std::regex_search(s, m, std::regex("cdefghi")));
+
+char out[100] = {0};
+const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: 
$2";
+char* r = m.format(output_iterator(out),
+fmt, fmt + std::char_traits::length(fmt)).base();
+assert(r == out + 54);
+assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, 
m[1]: , m[2]: ");
+}
+{
+std::match_results m;
+const char s[] = "abcdefghijk";
 assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
 
 char out[100] = {0};
@@ -61,6 +86,33 @@
 assert(r == out + 34);
 assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
 }
+{
+std::match_results m;
+const char s[] = "abcdefghijk";
+assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+  
std::regex_constants::nosubs)));
+
+char out[100] = {0};
+const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+char* r = m.format(output_iterator(out),
+fmt, fmt + std::char_traits::length(fmt),
+std::regex_constants::format_sed).base();
+assert(r == out + 30);
+assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
+}
+{
+std::match_results m;
+const char s[] = "abcdefghijk";
+assert(std::regex_search(s, m, std::regex("cdefghi")));
+
+char out[100] = {0};
+const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+char* r = m.format(output_iterator(out),
+fmt, fmt + std::char_traits::length(fmt),
+std::regex_constants::format_sed).base();
+assert(r == out + 30);
+assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
+}
 
 {
 std::match_results m;
Index: include/regex
===
--- include/regex
+++ include/regex
@@ -5387,8 +5387,10 @@
 if ('0' <= *__fmt_first && *__fmt_first <= '9')
 {
 size_t __i = *__fmt_first - '0';
-__out = _VSTD::copy(__matches_[__i].first,
-   __matches_[__i].second, __out);
+if (__i < __matches_.size()) {
+__out = _VSTD::copy(__matches_[__i].first,
+__matches_[__i].second, __out);
+}
 }
 else
 {
@@ -5439,8 +5441,10 @@
 ++__fmt_first;
 __i = 10 * __i + *__fmt_first - '0';
 }
-__out = _VSTD::copy(__matches_[__i].first,
-   __matches_[__i].second, __out);
+if (__i < __matches_.size()) {
+__out = _VSTD::copy(__matches_[__i].fi

Re: [PATCH] D8940: Clang changes for indirect call target profiling

2016-01-22 Thread David Li via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

LGTM.

I think we also need a user level option to turn value profiling on/off (in 
followups).


http://reviews.llvm.org/D8940



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-01-22 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

I find this an interesting discussion.  I do not mean to imply that my remarks 
constitute any sort of demand that this check produce my suggestion for a fixit.

In http://reviews.llvm.org/D16310#333416, @danielmarjamaki wrote:

> I expect that this warning will in most cases be fixed by moving the cast.


For a seasoned C++ developer having authored the offending code, I agree.  
However, I have seen lots of code where things were done that were just 
unnecessary.

> I believe there is often a bug in such code.


I think it depends on who was writing it.

> If you want that we hide these bugs by removing the casts I can do it.. but I 
> personally think that is wrong.


I'm simply saying that **if** it is going to suggest a fixit, then the fixit 
suggested should be one that doesn't change the meaning of the code as written.

I agree that such a suggested fixit would not be the correct change in all 
cases, since clang-tidy can't know the original intent of the author.

However, suppose we had code like this:

  long f(int a) {
return a*1000;
  }

This code is not going to issue any warnings about potential loss of precision, 
but by simply adding the cast on the result expression, suddenly I'm getting 
warnings about possible loss of precision.

In both cases, the precision loss is a potentiality.

The check assumes that placing the cast there is an indicator of a bug.

When I look at such code with a redundant cast, I would infer the opposite: the 
programmer is adding stuff that isn't necessary.

Maybe our differing attitude on what the cast implies is a reflection of the 
difference in our experiences in working on different code bases.  Am I just so 
unlucky as to have been exposed to so much **badly written** C++ over the 
years?  The checks that I have added and would like to continue to add are 
primarily focused on "cleaning up the mess" that I've seen in so many C++ code 
bases over the years.  I have seen many uses of unnecessary casting over the 
years, as opposed to misplaced casts that were intended to prevent loss of 
precision.

Without access to the original intent (locked up in someone's brain somewhere), 
whether or not a loss of precision is a problem can only be determined by 
dynamic analysis or some other form of runtime testing.

Perhaps because both of our interpretations are valid but different points of 
view, it is best that this check not offer any fixit at all.  If it does offer 
a fixit, then there should be a configuration option to say which kind of fixit 
to prefer.  A developer can then use a workflow like this:

1. Run the tool with no fixits to see if there are any potential problems.
2. Examine each instance and decide if the cast is redundant or misplaced.
3. For redundant casts, run the tool again configured to drop the redundant 
cast and selectively apply the fixits on the appropriate instances.
4. For misplaced casts, run the tool again configured to move the cast and 
selectively apply the fixits on the appropriate instances.

This leaves the tool operating conservatively by default, yet still providing 
the developer with the means of deciding the intent on each flagged instance 
and applying the appropriate fix for each case.


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


Re: [PATCH] D12354: [libcxx] Add global assertion handler for debug mode.

2016-01-22 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jan-21, at 22:22, Eric Fiselier  wrote:
> 
> 
> 
> On Thu, Jan 21, 2016 at 10:35 PM, Duncan P. N. Exon Smith 
>  wrote:
> 
> > On 2016-Jan-21, at 17:59, Eric Fiselier  wrote:
> >
> > EricWF added a comment.
> >
> > In http://reviews.llvm.org/D12354#331776, @dexonsmith wrote:
> >
> >> This patch looks correct to me.  Is there any reason it wasn't committed?
> >
> >
> > I was concerned about using a function-local static in the library headers, 
> > I don't think libc++ does that anywhere else and I wanted to make sure it 
> > was safe to do.
> >
> >
> > http://reviews.llvm.org/D12354
> 
> Ah, in the testing hook.  I feel like it's better than the current
> situation, anyway.  Unless we have ABI guarantees for _LIBCPP_DEBUG
> since this could lock us in somehow.  (Do we?  Should we?)
> 
> The _LIBCPP_DEBUG mode should produce the same ABI as non-debug builds.
> However I don't see how this patch would "lock us in" or change our ABI 
> guarantees.
> The function local static should have vague linkage and be emitted in every 
> TU where it is ODR used.
> TU's compiled with debug mode off will not contain or depend on the symbol.
> 
> The libc++.dylib will contain it's own copy of the function local static 
> since _LIBCPP_ASSERT 

If so, then the hook (as intended) doesn't actually allow testing
the _LIBCPP_ASSERT()s in src/debug.cpp, unless I'm missing something?

In that case, why not just do (2) and not worry about a global variable
at all?  I.e., in test/support/debug.hpp, something like:
--
#define _LIBCPP_ASSERT(c, m) (c ? (void)0 : handleAssertion(m, __FILE__, ...))
#include <__debug>
--

> Do you disagree? Do you have any concerns about this?

As written, shouldn't the runtime linker coalesce these ODR functions
(and the function-local static) with the version in the headers?  This
isn't going to have hidden visibility AFAICT (maybe I missed something).

> I want to be 100% sure about the ABI implications.

Because these functions are inline (and not always_inline, or
internal_linkage, or whatever the new thing is), ODR requires that every
source file is compiled with the exact same version of them.  I think
this affects the ABI.

> Thinking through a couple of other options:
> 
>  2. The test could provide its own version of _LIBCPP_ASSERT.  It's
> not obvious how to hook into the assertions in src/debug.cpp
> though.
> 
> 
> This could work, but it feels more like a hack than a fix.

IMO, it's no more hacky than adding function-locals.  The point of
this part of the patch is to test calls to _LIBCPP_ASSERT, but
approach (1) affects uses in non-trivial ways (adding global variables
that need to be coalesced between all the affected TUs).  At least (2)
limits the hook to the testing framework itself.

>  
>  3. We could move __debug_assert() and __debug_assertion_handler()
> to the dylib (and use a static global variable there).
> 
> This would be the *cleanest* solution but is actually the worst option IMHO.
> We can't safely use the new dylib symbol in the headers without breaking ABI 
> compatibility for older/system dylibs.
> I think I'll try and move the symbol into the dylib for ABI v2 though. 
> 
> Maybe (3) is the best.  Is it important for these functions to be
> inline, given that they're in the slow path anyway?
> 
> The "inline" has more to do with linkage and ABI concerns. _LIBCPP_DEBUG 
> isn't meant to be a "fast" path.

I don't think making it inline really simplifies the ABI story
though.

> 
> I have a 4th possible option:
> 
> 4. Make __debug_assertion_handler a weak symbol. By default it would not be 
> defined, but users and tests could override it.
> __debug_assert will use "__debug_assertion_handler" if it's defined, 
> otherwise it will just abort.
> However weak symbols are not a part of the language while function local 
> statics are. I'm also concerned that weak symbols are not portable.

Yeah, I had a similar thought and rejected it for the same reason.
Portability probably matters here.

> I've reached out to the libstdc++ maintainer about the ABI considerations of 
> using function local statics. If I get a positive response from him I'm going 
> to move ahead with plan #1.
> 
> /Eric
> 

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


r258507 - Module Debugging: Use a nonzero DWO id for precompiled headers.

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 11:43:43 2016
New Revision: 258507

URL: http://llvm.org/viewvc/llvm-project?rev=258507&view=rev
Log:
Module Debugging: Use a nonzero DWO id for precompiled headers.
PCH files don't have a module signature and LLVM uses a nonzero DWO id as
an indicator for skeleton / module CUs. This change pins the DWO id for PCH
files to a known constant value.
The correct long-term solution here is to implement a module signature
that is an actual dterministic hash (at the moment module signatures are
just random nonzero numbers) and then enable this for PCH files as well.



Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 11:43:43 2016
@@ -1740,11 +1740,14 @@ CGDebugInfo::getOrCreateModuleRef(Extern
 
   bool IsRootModule = M ? !M->Parent : true;
   if (CreateSkeletonCU && IsRootModule) {
+// PCH files don't have a signature field in the control block,
+// but LLVM detects skeleton CUs by looking for a non-zero DWO id.
+uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1U;
 llvm::DIBuilder DIB(CGM.getModule());
 DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
   Mod.getPath(), TheCU->getProducer(), true,
   StringRef(), 0, Mod.getASTFile(),
-  llvm::DIBuilder::FullDebug, Mod.getSignature());
+  llvm::DIBuilder::FullDebug, Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258507&r1=258506&r2=258507&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22 
11:43:43 2016
@@ -219,7 +219,11 @@ public:
 
 M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
 M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
-Builder->getModuleDebugInfo()->setDwoId(Buffer->Signature);
+
+// PCH files don't have a signature field in the control block,
+// but LLVM detects DWO CUs by looking for a non-zero DWO id.
+uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1U;
+Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.
 if (Builder)

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 11:43:43 2016
@@ -102,3 +102,7 @@ void foo() {
 
 
 // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 24)
+
+// CHECK: !DICompileUnit(
+// CHECK-SAME:   splitDebugFilename:
+// CHECK-SAME:   dwoId:

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Fri Jan 22 11:43:43 2016
@@ -8,7 +8,6 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps 
-DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll 
-mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
-// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
@@ -22,7 +21,7 @@
 // CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-SAME:isOptimized: false,
 // CHECK-SAME-NOT:splitDebugFilename:
-// CHECK-DWO: dwoId:
+// CHECK: dwoId:
 
 // CHECK: !DICompositeType(tag: 

Re: r258507 - Module Debugging: Use a nonzero DWO id for precompiled headers.

2016-01-22 Thread David Blaikie via cfe-commits
On Fri, Jan 22, 2016 at 9:43 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Jan 22 11:43:43 2016
> New Revision: 258507
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258507&view=rev
> Log:
> Module Debugging: Use a nonzero DWO id for precompiled headers.
> PCH files don't have a module signature and LLVM uses a nonzero DWO id as
> an indicator for skeleton / module CUs. This change pins the DWO id for PCH
> files to a known constant value.
> The correct long-term solution here is to implement a module signature
> that is an actual dterministic hash (at the moment module signatures are
> just random nonzero numbers) and then enable this for PCH files as well.
>

^ is this on the books/planned at all?


>
> 
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 11:43:43 2016
> @@ -1740,11 +1740,14 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>
>bool IsRootModule = M ? !M->Parent : true;
>if (CreateSkeletonCU && IsRootModule) {
> +// PCH files don't have a signature field in the control block,
> +// but LLVM detects skeleton CUs by looking for a non-zero DWO id.
> +uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1U;
>  llvm::DIBuilder DIB(CGM.getModule());
>  DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
>Mod.getPath(), TheCU->getProducer(), true,
>StringRef(), 0, Mod.getASTFile(),
> -  llvm::DIBuilder::FullDebug, Mod.getSignature());
> +  llvm::DIBuilder::FullDebug, Signature);
>  DIB.finalize();
>}
>llvm::DIModule *Parent =
>
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258507&r1=258506&r2=258507&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22
> 11:43:43 2016
> @@ -219,7 +219,11 @@ public:
>
>  M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
>  M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
> -Builder->getModuleDebugInfo()->setDwoId(Buffer->Signature);
> +
> +// PCH files don't have a signature field in the control block,
> +// but LLVM detects DWO CUs by looking for a non-zero DWO id.
> +uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1U;
> +Builder->getModuleDebugInfo()->setDwoId(Signature);
>
>  // Finalize the Builder.
>  if (Builder)
>
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
>
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 11:43:43 2016
> @@ -102,3 +102,7 @@ void foo() {
>
>
>  // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0,
> entity: !"_ZTSN8DebugCXX6StructE", line: 24)
> +
> +// CHECK: !DICompileUnit(
> +// CHECK-SAME:   splitDebugFilename:
> +// CHECK-SAME:   dwoId:
>
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
>
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Fri Jan 22 11:43:43 2016
> @@ -8,7 +8,6 @@
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
> -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj
> -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I
> %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
>  // RUN: cat %t-mod.ll | FileCheck %s
>  // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
> -// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
>
>  // PCH:
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11
> -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h
> -mllvm -debug-only=pchcontainer &>%t-p

Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-01-22 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: clang-tidy/utils/HeaderFileExtensionsUtils.cpp:49
@@ +48,3 @@
+  AllHeaderFileExtensions.split(Suffixes, ',');
+  HeaderFileExtensions.clear();
+  for (llvm::StringRef Suffix : Suffixes) {

I'm +1 on keeping the consistence of `list` option. 

I also check the option in clang-tidy checks, seems that this is the first time 
to introduce list option into clang-tidy. So `;` is fine to me. 




http://reviews.llvm.org/D16113



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


Re: [PATCH] D16152: [clang-tidy] Add check performance-faster-string-find

2016-01-22 Thread Haojian Wu via cfe-commits
hokein added a subscriber: hokein.


Comment at: clang-tidy/performance/FasterStringFindCheck.h:25
@@ +24,3 @@
+/// The character literal overload is more efficient.
+///
+/// For the user-facing documentation see:

I think you need to add document about `StringLikeClasses` option here.


http://reviews.llvm.org/D16152



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


Re: r258507 - Module Debugging: Use a nonzero DWO id for precompiled headers.

2016-01-22 Thread Adrian Prantl via cfe-commits

> On Jan 22, 2016, at 9:50 AM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Jan 22, 2016 at 9:43 AM, Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Fri Jan 22 11:43:43 2016
> New Revision: 258507
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=258507&view=rev 
> 
> Log:
> Module Debugging: Use a nonzero DWO id for precompiled headers.
> PCH files don't have a module signature and LLVM uses a nonzero DWO id as
> an indicator for skeleton / module CUs. This change pins the DWO id for PCH
> files to a known constant value.
> The correct long-term solution here is to implement a module signature
> that is an actual dterministic hash (at the moment module signatures are
> just random nonzero numbers) and then enable this for PCH files as well.
> 
> ^ is this on the books/planned at all?
>  

IIRC there was some consensus on the list that this would be the way forward. 
Back then (~1 year ago) we still had massive problems with PCM files being 
nondeterministic (Chandler later fixed at least some of that) so it was not 
immediately possible at the time. But the random ID that we use currently is 
causing me headaches in dsymutil because it will, e.g., warn about dwoid 
mismatches for modules that have been rebuilt but haven’t actually changed, so 
I definitely want to do this.

-- adrian

> 
> 
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/ExtDebugInfo.cpp
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 11:43:43 2016
> @@ -1740,11 +1740,14 @@ CGDebugInfo::getOrCreateModuleRef(Extern
> 
>bool IsRootModule = M ? !M->Parent : true;
>if (CreateSkeletonCU && IsRootModule) {
> +// PCH files don't have a signature field in the control block,
> +// but LLVM detects skeleton CUs by looking for a non-zero DWO id.
> +uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1U;
>  llvm::DIBuilder DIB(CGM.getModule());
>  DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
>Mod.getPath(), TheCU->getProducer(), true,
>StringRef(), 0, Mod.getASTFile(),
> -  llvm::DIBuilder::FullDebug, Mod.getSignature());
> +  llvm::DIBuilder::FullDebug, Signature);
>  DIB.finalize();
>}
>llvm::DIModule *Parent =
> 
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258507&r1=258506&r2=258507&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22 
> 11:43:43 2016
> @@ -219,7 +219,11 @@ public:
> 
>  M->setTargetTriple(Ctx.getTargetInfo().getTriple().getTriple());
>  M->setDataLayout(Ctx.getTargetInfo().getDataLayoutString());
> -Builder->getModuleDebugInfo()->setDwoId(Buffer->Signature);
> +
> +// PCH files don't have a signature field in the control block,
> +// but LLVM detects DWO CUs by looking for a non-zero DWO id.
> +uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1U;
> +Builder->getModuleDebugInfo()->setDwoId(Signature);
> 
>  // Finalize the Builder.
>  if (Builder)
> 
> Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258507&r1=258506&r2=258507&view=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 11:43:43 2016
> @@ -102,3 +102,7 @@ void foo() {
> 
> 
>  // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
> entity: !"_ZTSN8DebugCXX6StructE", line: 24)
> +
> +// CHECK: !DICompileUnit(
> +// CHECK-SAME:   splitDebugFilename:
> +// CHECK-SAME:   dwoId:
> 
> Modified: cfe/trun

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Rong Xu via cfe-commits
On Thu, Jan 21, 2016 at 7:32 PM, Sean Silva  wrote:
> silvas added a comment.
>
> @slingn and I had a discussion offline about the potential names and came up 
> with some ideas, but none is a clear winner.
>
> Overall, my feeling is that from a user's perspective, the frontend stuff is 
> probably best referred to as "coverage-based". It's not as clear for the 
> IR-level stuff, but referring to it as the "pgo focused" or "optimization 
> focused" instrumentation might be a way to describe it. E.g. perhaps 
> `-fprofile-instr-method={coverage,optimization}`.
>

Agreed. Frontend instrumentation has a less chance of the mismatch
caused by compiler change. IR-level instrumentation is more for the
PGO optimization. Speed and simplicity are the focus -- that is also
the main reason that we don't split the BB for no-return-calls.

> For now, can we make this a CC1-only option? Then we don't have to hold up 
> the patch review on the driver stuff. Once we have fully integrated the 
> IR-level instrumentation, we can revisit exposing the user-visible name. (as 
> compiler developers, we can of course use the flag freely for 
> integration/testing).

I can do this. I just need to move the option define from Opertion.td
to CC1Options.td. The user would need to use '-Xclang
-fprofile-ir-instr' to invoke.

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


[libcxx] r258511 - unordered: Rename __construct_node_hash() to allow forwarding, NFC

2016-01-22 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Jan 22 12:27:26 2016
New Revision: 258511

URL: http://llvm.org/viewvc/llvm-project?rev=258511&view=rev
Log:
unordered: Rename __construct_node_hash() to allow forwarding, NFC

Rename the version of __construct_node() that takes a hash as an
argument to __construct_node_hash(), and use perfect-forwarding when
Rvalue references are available.  The primary motivation is to allow
other types through, since unordered_map's value_type is different from
__hash_table's value_type -- a follow-up will take advantage of this --
but the rename is general "goodness".

There should be no functionality change here (aside from enabling the
follow-up).

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=258511&r1=258510&r2=258511&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Fri Jan 22 12:27:26 2016
@@ -1047,11 +1047,12 @@ private:
 template 
 __node_holder __construct_node(_Args&& ...__args);
 #endif  // _LIBCPP_HAS_NO_VARIADICS
-__node_holder __construct_node(value_type&& __v, size_t __hash);
+template 
+__node_holder __construct_node_hash(_ValueTp&& __v, size_t __hash);
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 __node_holder __construct_node(const value_type& __v);
 #endif
-__node_holder __construct_node(const value_type& __v, size_t __hash);
+__node_holder __construct_node_hash(const value_type& __v, size_t __hash);
 
 _LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const __hash_table& __u)
@@ -1730,7 +1731,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 }
 }
 {
-__node_holder __h = __construct_node(_VSTD::forward<_ValueTp>(__x), 
__hash);
+__node_holder __h = 
__construct_node_hash(_VSTD::forward<_ValueTp>(__x), __hash);
 if (size()+1 > __bc * max_load_factor() || __bc == 0)
 {
 rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc),
@@ -2051,13 +2052,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 template 
+template 
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v,
-   size_t __hash)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(_ValueTp&& __v,
+size_t __hash)
 {
 __node_allocator& __na = __node_alloc();
 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
-__node_traits::construct(__na, _VSTD::addressof(__h->__value_), 
_VSTD::move(__v));
+__node_traits::construct(__na, _VSTD::addressof(__h->__value_), 
_VSTD::forward<_ValueTp>(__v));
 __h.get_deleter().__value_constructed = true;
 __h->__hash_ = __hash;
 __h->__next_ = nullptr;
@@ -2083,8 +2085,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>
 
 template 
 typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
-__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& 
__v,
-   size_t __hash)
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(const 
value_type& __v,
+size_t __hash)
 {
 __node_allocator& __na = __node_alloc();
 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));


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


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-01-22 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jan-21, at 23:14, Eric Fiselier  wrote:
> 
> EricWF added a comment.
> 
>> - Did I successfully match the coding style? (I'm kind of lost without 
>> clang-format TBH.)
> 
> 
> The style looks pretty good. I'll comment on any nits I have.
> 
>> - Should I separate the change to __construct_node_hash() into a separate 
>> prep commit? (I would if this were LLVM, but I'm not sure if the common 
>> practice is different for libc++.)
> 
> 
> Yes please!
> 

r258511

> 
> http://reviews.llvm.org/D16360
> 
> 
> 

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


[PATCH] D16469: Pass --wrap=pthread_create to linker for -fsplit-stack

2016-01-22 Thread H.J Lu via cfe-commits
hjl.tools created this revision.
hjl.tools added a reviewer: rsmith.
hjl.tools added a subscriber: cfe-commits.

From

https://gcc.gnu.org/ml/gcc-patches/2010-09/msg01807.html

-fsplit-stack should pass --wrap=pthread_create to linker for -fsplit-stack
It is needed to initialize the stack guard.  This fixes PR 20148.

http://reviews.llvm.org/D16469

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9001,6 +9001,9 @@
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");
 
+  if (Args.hasArg(options::OPT_fsplit_stack))
+CmdArgs.push_back("--wrap=pthread_create");
+
   CmdArgs.push_back("-lc");
 
   if (Args.hasArg(options::OPT_static))


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9001,6 +9001,9 @@
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");
 
+  if (Args.hasArg(options::OPT_fsplit_stack))
+CmdArgs.push_back("--wrap=pthread_create");
+
   CmdArgs.push_back("-lc");
 
   if (Args.hasArg(options::OPT_static))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Your code won't catch this test case:

  static int x;
  extern inline const bool *f() {
static const bool p = !&x;
return &p;
  }

Getting this exactly right is going to be a challenge. =/



Comment at: include/clang/Basic/DiagnosticASTKinds.td:151
@@ -150,1 +150,3 @@
   "%plural{1:byte|:bytes}1">;
+def note_constexpr_microsoft_abi_declrefexpr : Note<
+  "the constant expression cannot contain a reference to a variable as a 
Microsoft "

We should add this test case and decide what to do with it:
  static int x;
  inline int **f() {
static constexpr int *p = true ? 0 : &x;
return &p;
  }
Currently, in your patch, this diagnostic will come out. MSVC compiles this to 
guarded, dynamic initialization, despite the constexpr. ;_;

David thinks we should just give the user the real deal constexpr behavior, 
even though it's ABI incompatible.


Comment at: include/clang/Basic/DiagnosticASTKinds.td:152-153
@@ -151,1 +151,4 @@
+def note_constexpr_microsoft_abi_declrefexpr : Note<
+  "the constant expression cannot contain a reference to a variable as a 
Microsoft "
+  "ABI extension">;
 

This isn't an extension, so we should say something else. Maybe:
  "in the Microsoft ABI static local variables cannot contain references to 
variables"


Comment at: lib/AST/ExprConstant.cpp:9008
@@ -8917,1 +9007,3 @@
 
+  if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
+InitInfo.useMicrosoftABI();

This should be limited in scope to only apply to static locals. We should be 
able to statically initialize globals.


http://reviews.llvm.org/D16465



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread David Li via cfe-commits
davidxl added a comment.

This option is not needed for -fprofile-instr-use compilation as the compiler 
can detect the flavor of the profile (patch pending review), and decide what to 
do.

The question here is what the option should look like  to tell the compiler 
which phase to do the instrumentation (fprofile-instr-generate).


http://reviews.llvm.org/D15829



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Rong Xu via cfe-commits
xur updated this revision to Diff 45708.
xur added a comment.

This new patches integrates Sean review comments:
(1) make -fprofile-ir-instr a cc1 option instead of driver option.
(2) add one cc1 option test, and test the pass is indeed invoked.
(3) remove the driver test (runtime library).
(4) fix a comment.

Thanks,

-Rong


http://reviews.llvm.org/D15829

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/pgo-instrumentation.c

Index: test/CodeGen/pgo-instrumentation.c
===
--- /dev/null
+++ test/CodeGen/pgo-instrumentation.c
@@ -0,0 +1,9 @@
+// Test PGO instrumentation.
+//
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang -O2 -c -Xclang -fprofile-ir-instr -fprofile-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PASS
+// CHECK-PASS: PGOInstrumentationGenPass
+//
+// Ensure cc1 option -fprofile-ir-instr is null operation without existing pgo options.
+// RUN: %clang -O2 -c -Xclang -fprofile-ir-instr %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PASS2
+// CHECK-PASS2-NOT: PGOInstrumentationGenPass
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -477,8 +477,16 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
-  Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
-  Args.hasArg(OPT_fprofile_instr_generate_EQ);
+  // Only set ProfileIRInstr when there are profile generate or use options.
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr) &&
+(Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ) ||
+ Args.hasArg(OPT_fprofile_instr_use_EQ));
+  // Set Opts.ProfileInstrGenerate when Opts.ProfileIRInstr is false.
+  // Opts.ProfileInstrGenerate will be used for Clang instrumentation only.
+  if (!Opts.ProfileIRInstr)
+Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||
+Args.hasArg(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileOutput = Args.getLastArgValue(OPT_fprofile_instr_generate_EQ);
   Opts.InstrProfileInput = Args.getLastArgValue(OPT_fprofile_instr_use_EQ);
   Opts.CoverageMapping =
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3275,6 +3275,8 @@
   CmdArgs.push_back(Args.MakeArgString(CoverageFilename));
 }
   }
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }
 
 static void addPS4ProfileRTArgs(const ToolChain &TC, const ArgList &Args,
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -147,7 +147,7 @@
   if (C.getLangOpts().ObjC1)
 ObjCData = new ObjCEntrypoints();
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.ProfileIRInstr && !CodeGenOpts.InstrProfileInput.empty()) {
 auto ReaderOrErr =
 llvm::IndexedInstrProfReader::create(CodeGenOpts.InstrProfileInput);
 if (std::error_code EC = ReaderOrErr.getError()) {
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -436,6 +436,18 @@
 MPM->add(createInstrProfilingPass(Options));
   }
 
+  if (CodeGenOpts.ProfileIRInstr) {
+// Should not have ProfileInstrGenerate set -- it is for clang
+// instrumentation only.
+assert (!CodeGenOpts.ProfileInstrGenerate);
+if (!CodeGenOpts.InstrProfileInput.empty())
+  PMBuilder.PGOInstrUse = CodeGenOpts.InstrProfileInput;
+else if (!CodeGenOpts.InstrProfileOutput.empty())
+  PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
+else
+  PMBuilder.PGOInstrGen = "default.profraw";
+  }
+
   if (!CodeGenOpts.SampleProfileFile.empty())
 MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile));
 
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -105,6 +105,7 @@
 
 CODEGENOPT(ProfileInstrGenerate , 1, 0) ///< Instrument code to generate
 ///< execution counts to use with PGO.
+CODEGENOPT(ProfileIRInstr, 1, 0) ///< IR level PGO instrumentation and use.
 CODEGENOPT(

r258517 - [analyzer] SATestBuild.py: Handle spaces in path passed to --use-analyzer.

2016-01-22 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Jan 22 12:45:22 2016
New Revision: 258517

URL: http://llvm.org/viewvc/llvm-project?rev=258517&view=rev
Log:
[analyzer] SATestBuild.py: Handle spaces in path passed to --use-analyzer.

I missed this one in r258493.

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=258517&r1=258516&r2=258517&view=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Fri Jan 22 12:45:22 2016
@@ -285,8 +285,8 @@ def runScanBuild(Dir, SBOutputDir, PBuil
 # Run scan-build from within the patched source directory.
 SBCwd = os.path.join(Dir, PatchedSourceDirName)
 
-SBOptions = "--use-analyzer " + Clang + " "
-SBOptions += "-plist-html -o '" + SBOutputDir + "' "
+SBOptions = "--use-analyzer '%s' " %  Clang
+SBOptions += "-plist-html -o '%s' " % SBOutputDir
 SBOptions += "-enable-checker " + AllCheckers + " "
 SBOptions += "--keep-empty "
 # Always use ccc-analyze to ensure that we can locate the failures


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


r258519 - Fix a typo in r258507 and change the PCH dwoid constant to ~1UL.

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 12:46:45 2016
New Revision: 258519

URL: http://llvm.org/viewvc/llvm-project?rev=258519&view=rev
Log:
Fix a typo in r258507 and change the PCH dwoid constant to ~1UL.

rdar://problem/24290667

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258519&r1=258518&r2=258519&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 12:46:45 2016
@@ -1742,7 +1742,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   if (CreateSkeletonCU && IsRootModule) {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
-uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1U;
+uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1UL;
 llvm::DIBuilder DIB(CGM.getModule());
 DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
   Mod.getPath(), TheCU->getProducer(), true,

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258519&r1=258518&r2=258519&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22 
12:46:45 2016
@@ -222,7 +222,7 @@ public:
 
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
-uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1U;
+uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1UL;
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258519&r1=258518&r2=258519&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 12:46:45 2016
@@ -18,7 +18,7 @@
 // RUN: -triple %itanium_abi_triple \
 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
 // RUN: cat %t-pch.ll |  FileCheck %s
-
+// RUN: cat %t-pch.ll |  FileCheck %s --check-prefix=CHECK-PCH
 
 #ifdef MODULES
 @import DebugCXX;
@@ -109,3 +109,4 @@ void foo() {
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:
 // CHECK-SAME:   dwoId:
+// CHECK-PCH:dwoId: 18446744073709551614


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


r258518 - Fix 80-column violations.

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 12:46:40 2016
New Revision: 258518

URL: http://llvm.org/viewvc/llvm-project?rev=258518&view=rev
Log:
Fix 80-column violations.

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

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258518&r1=258517&r2=258518&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 12:46:40 2016
@@ -2,7 +2,8 @@
 // Test that only forward declarations are emitted for types dfined in modules.
 
 // Modules:
-// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited 
-dwarf-ext-refs -fmodules \
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=limited \
+// RUN: -dwarf-ext-refs -fmodules   \
 // RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
 // RUN: -triple %itanium_abi_triple \
 // RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o 
%t-mod.ll
@@ -12,11 +13,13 @@
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodule-format=obj -emit-pch -I%S/Inputs 
\
 // RUN: -triple %itanium_abi_triple \
 // RUN: -o %t.pch %S/Inputs/DebugCXX.h
-// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited -dwarf-ext-refs 
-fmodule-format=obj \
+// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited \
+// RUN: -dwarf-ext-refs -fmodule-format=obj \
 // RUN: -triple %itanium_abi_triple \
 // RUN: -include-pch %t.pch %s -emit-llvm -o %t-pch.ll %s
 // RUN: cat %t-pch.ll |  FileCheck %s
 
+
 #ifdef MODULES
 @import DebugCXX;
 #endif
@@ -101,7 +104,7 @@ void foo() {
 // CHECK-SAME:  name: "InAnonymousNamespace", {{.*}}DIFlagFwdDecl)
 
 
-// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 24)
+// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, 
entity: !"_ZTSN8DebugCXX6StructE", line: 27)
 
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:


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


[PATCH] D16475: Remove autoconf support

2016-01-22 Thread Chris Bieneman via cfe-commits
beanz created this revision.
beanz added reviewers: echristo, chandlerc, grosbach, bob.wilson.
beanz added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch is provided in preparation for removing autoconf on 1/26. The 
proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: 
http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"Now I am become Death, the destroyer of worlds."
-J. Robert Oppenheimer

http://reviews.llvm.org/D16475

Files:
  Makefile
  clang-apply-replacements/Makefile
  clang-apply-replacements/lib/Tooling/Makefile
  clang-apply-replacements/tool/Makefile
  clang-query/Makefile
  clang-query/tool/Makefile
  clang-rename/Makefile
  clang-rename/tool/Makefile
  clang-tidy/Makefile
  clang-tidy/cert/Makefile
  clang-tidy/cppcoreguidelines/Makefile
  clang-tidy/google/Makefile
  clang-tidy/llvm/Makefile
  clang-tidy/misc/Makefile
  clang-tidy/modernize/Makefile
  clang-tidy/performance/Makefile
  clang-tidy/readability/Makefile
  clang-tidy/tool/Makefile
  clang-tidy/utils/Makefile
  docs/Makefile
  modularize/Makefile
  pp-trace/Makefile
  test/Makefile
  tool-template/Makefile
  unittests/Makefile
  unittests/clang-apply-replacements/Makefile
  unittests/clang-query/Makefile
  unittests/clang-rename/Makefile
  unittests/clang-tidy/Makefile

Index: unittests/clang-tidy/Makefile
===
--- unittests/clang-tidy/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-##===- unittests/clang-tidy/Makefile ---*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===--===##
-
-CLANG_LEVEL = ../../../..
-include $(CLANG_LEVEL)/../../Makefile.config
-
-TESTNAME = ClangTidy
-LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
-		 TransformUtils
-USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
-	   clangTidyMiscModule.a clangTidyReadability.a clangTidy.a \
-	   clangTidyUtils.a \
-	   clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
-	   clangStaticAnalyzerCore.a \
-	   clangFormat.a clangTooling.a clangToolingCore.a \
-	   clangFrontend.a clangSerialization.a \
-	   clangDriver.a clangRewriteFrontend.a clangRewrite.a \
-	   clangParse.a clangSema.a clangAnalysis.a clangAST.a \
-	   clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
-
-include $(CLANG_LEVEL)/Makefile
-MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
-CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-tidy
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
Index: unittests/clang-rename/Makefile
===
--- unittests/clang-rename/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-##===- unittests/clang-rename/Makefile -*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===--===##
-
-CLANG_LEVEL = ../../../..
-include $(CLANG_LEVEL)/../../Makefile.config
-
-TESTNAME = ClangRenameTests
-LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
-		 TransformUtils
-USEDLIBS = clangRename.a clangFrontend.a clangSerialization.a clangDriver.a \
-   clangTooling.a clangParse.a clangSema.a clangIndex.a \
-   clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \
-   clangStaticAnalyzerCore.a clangAnalysis.a clangRewriteFrontend.a \
-   clangRewrite.a clangEdit.a clangAST.a clangLex.a clangBasic.a
-
-include $(CLANG_LEVEL)/Makefile
-MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
-CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-rename
-include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
Index: unittests/clang-query/Makefile
===
--- unittests/clang-query/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-##===- unittests/clang-query/Makefile --*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===--===##
-
-CLANG_LEVEL = ../../../..
-include $(CLANG_LEVEL)/../../Makefile.config
-
-TESTNAME = ClangQuery
-LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
-		 TransformUtils
-USEDLIBS = clangQuery.a clangTooling.a clangFrontend.a clangSerialization.a \
-	   clangDriver.a clangParse.a clangSema.a clangEdit.a clangAnalysis.a \
-	   clangAST.a clangASTMatchers.a clangDynamicASTMatchers.a clangLex.a \
-	   clangBasic.a
-
-include $(CLANG_LEVEL)/Makef

[PATCH] D16478: Always build a new TypeSourceInfo for function templates with parameters

2016-01-22 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added reviewers: rsmith, rnk.
thakis added a subscriber: cfe-commits.
Herald added subscribers: aemerson, klimek.

RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's 
ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and `
DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's 
ParmVarDecls.

For a function template that doesn't have parameters that explicitly depend on 
the template parameter, we used to be clever and not build a new 
TypeSourceInfo. That meant that when an instantiation of such a template is 
visited, its TypeSourceInfo would point to the ParmVarDecls of the template, 
not of the instantiation, which then confused clients of RecursiveASTVisitor.

So don't be clever for function templates that have parameters, even if none of 
the parameters depend on the type.

Fixes PR26257.

http://reviews.llvm.org/D16478

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,20 +1512,22 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 
   FunctionProtoTypeLoc FP = TL.castAs();
+  bool AllParmsNull = true;
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
 ParmVarDecl *P = FP.getParam(I);
 
 // This must be synthesized from a typedef.
 if (!P) continue;
+AllParmsNull = false;
 
 // The parameter's type as written might be dependent even if the
 // decayed type was not dependent.
@@ -1540,7 +1542,9 @@
   return true;
   }
 
-  return false;
+  // If there are any parameters, a new TypeSourceInfo that refers to the
+  // instantiated parameters must be built.
+  return !AllParmsNull && FP.getNumParams() > 0;
 }
 
 /// A form of SubstType intended specifically for instantiating the
@@ -1556,7 +1560,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4225,6 +4225,17 @@
   declRefExpr(to(decl(hasAncestor(decl()));
 }
 
+TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
+  EXPECT_TRUE(matches("struct PartitionAllocator {\n"
+  "  template\n"
+  "  static int quantizedSize(int count) {\n"
+  "return count;\n"
+  "  }\n"
+  "  void f() { quantizedSize(10); }\n"
+  "};",
+  declRefExpr(to(decl(hasAncestor(decl()));
+}
+
 TEST(HasParent, MatchesAllParents) {
   EXPECT_TRUE(matches(
   "template  struct C { static void f() { 42; } };"


Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1512,20 +1512,22 @@
 }
 
 static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
-  if (T->getType()->isInstantiationDependentType() || 
+  if (T->getType()->isInstantiationDependentType() ||
   T->getType()->isVariablyModifiedType())
 return true;
 
   TypeLoc TL = T->getTypeLoc().IgnoreParens();
   if (!TL.getAs())
 return false;
 
   FunctionProtoTypeLoc FP = TL.castAs();
+  bool AllParmsNull = true;
   for (unsigned I = 0, E = FP.getNumParams(); I != E; ++I) {
 ParmVarDecl *P = FP.getParam(I);
 
 // This must be synthesized from a typedef.
 if (!P) continue;
+AllParmsNull = false;
 
 // The parameter's type as written might be dependent even if the
 // decayed type was not dependent.
@@ -1540,7 +1542,9 @@
   return true;
   }
 
-  return false;
+  // If there are any parameters, a new TypeSourceInfo that refers to the
+  // instantiated parameters must be built.
+  return !AllParmsNull && FP.getNumParams() > 0;
 }
 
 /// A form of SubstType intended specifically for instantiating the
@@ -1556,7 +1560,7 @@
   assert(!ActiveTemplateInstantiations.empty() &&
  "Cannot perform an instantiation without some context on the "
  "instantiation stack");
-  
+
   if (!NeedsInstantiationAsFunctionType(T))
 return T;
 
Index: unittests/ASTMatchers/ASTMatchersTest.cpp
==

r258524 - Merge templated static member variables, fixes http://llvm.org/pr26179.

2016-01-22 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Fri Jan 22 13:03:27 2016
New Revision: 258524

URL: http://llvm.org/viewvc/llvm-project?rev=258524&view=rev
Log:
Merge templated static member variables, fixes http://llvm.org/pr26179.

Patch by Vassil Vassilev!
Reviewed by Richard Smith.


Added:
cfe/trunk/test/Modules/Inputs/PR26179/
cfe/trunk/test/Modules/Inputs/PR26179/A.h
cfe/trunk/test/Modules/Inputs/PR26179/B.h
cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
cfe/trunk/test/Modules/pr26179.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=258524&r1=258523&r2=258524&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Jan 22 13:03:27 2016
@@ -2595,8 +2595,24 @@ static bool isSameEntity(NamedDecl *X, N
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast(X)) {
 VarDecl *VarY = cast(Y);
-return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
-  VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
+  ASTContext &C = VarX->getASTContext();
+  if (C.hasSameType(VarX->getType(), VarY->getType()))
+return true;
+
+  // We can get decls with different types on the redecl chain. Eg.
+  // template  struct S { static T Var[]; }; // #1
+  // template  T S::Var[sizeof(T)]; // #2
+  // Only? happens when completing an incomplete array type. In this case
+  // when comparing #1 and #2 we should go through their elements types.
+  const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
+  const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
+  if (!VarXTy || !VarYTy)
+return false;
+  if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType())
+return C.hasSameType(VarXTy->getElementType(), 
VarYTy->getElementType());
+}
+return false;
   }
 
   // Namespaces with the same name and inlinedness match.

Added: cfe/trunk/test/Modules/Inputs/PR26179/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/A.h?rev=258524&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR26179/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/A.h Fri Jan 22 13:03:27 2016
@@ -0,0 +1,4 @@
+#include "basic_string.h"
+#include "B.h"
+
+int *p = a;

Added: cfe/trunk/test/Modules/Inputs/PR26179/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/B.h?rev=258524&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR26179/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/B.h Fri Jan 22 13:03:27 2016
@@ -0,0 +1,2 @@
+#include "basic_string.h"
+extern int a[5];

Added: cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h?rev=258524&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/basic_string.h Fri Jan 22 13:03:27 
2016
@@ -0,0 +1,14 @@
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING 1
+
+template
+struct basic_string {
+  static T _S_empty_rep_storage[];
+};
+
+template
+T basic_string::_S_empty_rep_storage[sizeof(T)];
+
+extern int a[];
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap?rev=258524&view=auto
==
--- cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR26179/module.modulemap Fri Jan 22 13:03:27 
2016
@@ -0,0 +1,9 @@
+module A {
+  header "A.h"
+  export *
+}
+
+module B {
+  header "B.h"
+  export *
+}

Added: cfe/trunk/test/Modules/pr26179.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr26179.cpp?rev=258524&view=auto
==
--- cfe/trunk/test/Modules/pr26179.cpp (added)
+++ cfe/trunk/test/Modules/pr26179.cpp Fri Jan 22 13:03:27 2016
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -I%S/Inputs/PR26179 -verify %s
+// RUN: %clang_cc1 -fmodules 
-fmodule-map-file=%S/Inputs/PR26179/module.modulemap -fmodules-cache-path=%t 
-I%S/Inputs/PR26179 -verify %s
+
+#include "A.h"
+
+// expected-no-diagnostics


___
cfe

Re: [PATCH][Modules][PR26179]

2016-01-22 Thread Yaron Keren via cfe-commits
Committed revision 258524.


2016-01-21 19:33 GMT+02:00 Vassil Vassilev via cfe-commits <
cfe-commits@lists.llvm.org>:

> ping... (perhaps someone else with commit rights can check it it...)
> --Vassil
>
> On 18/01/16 22:07, Vassil Vassilev wrote:
>
> Thanks! Could you check it in?
> -- Vassil
> On 18/01/16 21:38, Richard Smith via cfe-commits wrote:
>
> LGTM
> On Jan 18, 2016 12:06 PM, "Vassil Vassilev"  wrote:
>
>> Attaching v3 of the patch. Added your case to the current test and fixed
>> my silly non-array mistake.
>> -- Vassil
>> On 18/01/16 20:38, Richard Smith wrote:
>>
>> Please also add a test case that your old patch would have failed on,
>> such as:
>>
>> m1.h:
>> extern int a[];
>>
>> m2.h:
>> extern int a[5];
>>
>> x.cc:
>> #include "m1.h"
>> #include "m2.h"
>> int *p = a;
>> On Jan 18, 2016 9:28 AM, "Vassil Vassilev"  wrote:
>>
>>> On 17/01/16 06:34, Douglas Gregor wrote:
>>>
 On Jan 16, 2016, at 3:41 PM, Vassil Vassilev < 
> vvasi...@cern.ch> wrote:
>
> Hi,
>   Could somebody review the attached patch. It fixes
> https://llvm.org/bugs/show_bug.cgi?id=26179
> Many thanks!
> Vassil
> <0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>
>

 +  // We can get decls with different types on the redecl chain. Eg.
 +  // template  struct S { static T Var[]; }; // #1
 +  // template  T S::Var[sizeof(T)]; // #2
 +  // Trying to compare #1 and #2 should go through their canonical
 decls.
 +  QualType VarXTy = VarX->getCanonicalDecl()->getType();
 +  QualType VarYTy = VarY->getCanonicalDecl()->getType();
 +  if (Context.hasSameType(VarXTy, VarYTy))
 +return true;

 Completing an incomplete array is (I think) the only case in which this
 can happen. How about checking for that case specifically (i.e., it’s okay
 to have one be an incomplete array and the other to be any other kind of
 array with the same element type), rather than a blanket check on the
 canonical declaration types?

 - Doug

 Thanks for the comments. Patch v2 attached.
>>> -- Vassil
>>>
>>
>>
>
> ___
> cfe-commits mailing 
> listcfe-comm...@lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Chad Rosier via cfe-commits
mcrosier added a subscriber: mcrosier.
mcrosier added a comment.

Would it make sense to include an additional test (in test/Driver) that shows 
the -fprofile-ir-instr option being passed from the driver to the frontend? 
Such a test case would land in clang_f_opt.c, which has many examples.



Comment at: lib/Driver/Tools.cpp:3279
@@ -3278,1 +3278,3 @@
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }

I don't think AddAllArgs is what you really want.  What if the user specifies 
the option twice?  Do we really want to pass the flag from the driver to the 
front-end twice?  Also, should we warn if the option is passed twice?

I also think some of the logic in CompilerInvocation should land here...  see 
comments below.


Comment at: lib/Frontend/CompilerInvocation.cpp:482
@@ +481,3 @@
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr) &&
+(Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ) ||

IIRC, the general practice is to put this type of logic in the driver.  
Specifically, in Driver.cpp include something like

if (Args.hasArg(OPT_fprofile_ir_instr) &&
(Args.hasArg(OPT_fprofile_instr_generate) ||
 Args.hasArg(OPT_fprofile_instr_generate_EQ) ||
 Args.hasArg(OPT_fprofile_instr_use_EQ)))
  // Add -fprofile_ir_instr flag




http://reviews.llvm.org/D15829



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


Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Let's go ahead and land this. It doesn't seem high risk. Richard will be back 
on Monday, he's been skiing.


http://reviews.llvm.org/D15670



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


Re: [PATCH] D16465: [MS ABI] Prevent some expressions from evaluating to a constant

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan added a comment.

In http://reviews.llvm.org/D16465#333688, @rnk wrote:

> Your code won't catch this test case:
>
>   static int x;
>   extern inline const bool *f() {
> static const bool p = !&x;
> return &p;
>   }
>
> Getting this exactly right is going to be a challenge. =/


Oh you're right.  I need to spend some more time comparing our behavior with 
cl's, it seems...



Comment at: include/clang/Basic/DiagnosticASTKinds.td:151
@@ -150,1 +150,3 @@
   "%plural{1:byte|:bytes}1">;
+def note_constexpr_microsoft_abi_declrefexpr : Note<
+  "the constant expression cannot contain a reference to a variable as a 
Microsoft "

rnk wrote:
> We should add this test case and decide what to do with it:
>   static int x;
>   inline int **f() {
> static constexpr int *p = true ? 0 : &x;
> return &p;
>   }
> Currently, in your patch, this diagnostic will come out. MSVC compiles this 
> to guarded, dynamic initialization, despite the constexpr. ;_;
> 
> David thinks we should just give the user the real deal constexpr behavior, 
> even though it's ABI incompatible.
One solution to this would be to create a variation of `evaluateValue()` which 
activates this new behavior and only use it from 
`CodeGenModule::EmitConstantInit()`, so that the behavior of `evaluateValue()` 
in this context doesn't change.  How does that sound?

By the way, I just realized that 
`CheckPotentialExpressionContainingDeclRefExpr()` eats this diagnostic because 
of the `SpeculativeLookForDeclRefExprRAII` object.  Should I propagate it up 
from `CheckPotentialExpressionContainingDeclRefExpr()` to make it user visible? 
 Right now the test case above only emits "constexpr variable 'p' must be 
initialized by a constant expression" without any notes.


Comment at: lib/AST/ExprConstant.cpp:9008
@@ -8917,1 +9007,3 @@
 
+  if (Ctx.getTargetInfo().getCXXABI().isMicrosoft())
+InitInfo.useMicrosoftABI();

rnk wrote:
> This should be limited in scope to only apply to static locals. We should be 
> able to statically initialize globals.
Right, my bad!


http://reviews.llvm.org/D16465



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


r258526 - Rephrase this test to help debug a buildbot issue

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 13:14:24 2016
New Revision: 258526

URL: http://llvm.org/viewvc/llvm-project?rev=258526&view=rev
Log:
Rephrase this test to help debug a buildbot issue

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

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=258526&r1=258525&r2=258526&view=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Fri Jan 22 13:14:24 2016
@@ -109,4 +109,5 @@ void foo() {
 // CHECK: !DICompileUnit(
 // CHECK-SAME:   splitDebugFilename:
 // CHECK-SAME:   dwoId:
-// CHECK-PCH:dwoId: 18446744073709551614
+// CHECK-PCH: !DICompileUnit({{.*}}splitDebugFilename:
+// CHECK-PCH:dwoId: 18446744073709551614


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


Re: [PATCH][Modules][PR26179]

2016-01-22 Thread Vassil Vassilev via cfe-commits

Thanks!
--Vassil
On 22/01/16 20:07, Yaron Keren wrote:

Committed revision 258524.


2016-01-21 19:33 GMT+02:00 Vassil Vassilev via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>:


ping... (perhaps someone else with commit rights can check it it...)
--Vassil

On 18/01/16 22:07, Vassil Vassilev wrote:

Thanks! Could you check it in?
-- Vassil
On 18/01/16 21:38, Richard Smith via cfe-commits wrote:


LGTM

On Jan 18, 2016 12:06 PM, "Vassil Vassilev" mailto:vvasi...@cern.ch>> wrote:

Attaching v3 of the patch. Added your case to the current
test and fixed my silly non-array mistake.
-- Vassil
On 18/01/16 20:38, Richard Smith wrote:


Please also add a test case that your old patch would have
failed on, such as:

m1.h:
extern int a[];

m2.h:
extern int a[5];

x.cc:
#include "m1.h"
#include "m2.h"
int *p = a;

On Jan 18, 2016 9:28 AM, "Vassil Vassilev"
mailto:vvasi...@cern.ch>> wrote:

On 17/01/16 06:34, Douglas Gregor wrote:

On Jan 16, 2016, at 3:41 PM, Vassil Vassilev
mailto:vvasi...@cern.ch>> wrote:

Hi,
  Could somebody review the attached patch. It
fixes https://llvm.org/bugs/show_bug.cgi?id=26179
Many thanks!
Vassil

<0001-modules-Teach-clang-to-how-to-merge-variable-redecls.patch>


+  // We can get decls with different types on
the redecl chain. Eg.
+  // template  struct S { static T
Var[]; }; // #1
+  // template  T
S::Var[sizeof(T)]; // #2
+  // Trying to compare #1 and #2 should go
through their canonical decls.
+  QualType VarXTy =
VarX->getCanonicalDecl()->getType();
+  QualType VarYTy =
VarY->getCanonicalDecl()->getType();
+  if (Context.hasSameType(VarXTy, VarYTy))
+return true;

Completing an incomplete array is (I think) the
only case in which this can happen. How about
checking for that case specifically (i.e., it’s
okay to have one be an incomplete array and the
other to be any other kind of array with the same
element type), rather than a blanket check on the
canonical declaration types?

- Doug

Thanks for the comments. Patch v2 attached.
-- Vassil





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





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




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


Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Ehsan Akhgari via cfe-commits
Sure.  I'd be happy to address any comments post-landing.

Thanks!

On Fri, Jan 22, 2016 at 2:13 PM, Reid Kleckner  wrote:

> rnk added a comment.
>
> Let's go ahead and land this. It doesn't seem high risk. Richard will be
> back on Monday, he's been skiing.
>
>
> http://reviews.llvm.org/D15670
>
>
>
>


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


Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Ehsan Akhgari via cfe-commits
ehsan added a comment.

Sure.  I'd be happy to address any comments post-landing.

Thanks!


http://reviews.llvm.org/D15670



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


r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Fri Jan 22 13:26:44 2016
New Revision: 258530

URL: http://llvm.org/viewvc/llvm-project?rev=258530&view=rev
Log:
[MSVC Compat] Accept elided commas in macro function arguments

Summary:
This fixes PR25875.  When the trailing comma in a macro argument list is
elided, we need to treat it similarly to the case where a variadic macro
misses one actual argument.

Reviewers: rnk, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Lex/Token.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/microsoft-ext.c

Modified: cfe/trunk/include/clang/Lex/Token.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=258530&r1=258529&r2=258530&view=diff
==
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Fri Jan 22 13:26:44 2016
@@ -85,6 +85,7 @@ public:
 IgnoredComma = 0x80,   // This comma is not a macro argument separator 
(MS).
 StringifiedInMacro = 0x100, // This string or character literal is formed 
by
 // macro stringizing or charizing operator.
+CommaAfterElided = 0x200, // The comma following this token was elided 
(MS).
   };
 
   tok::TokenKind getKind() const { return Kind; }
@@ -297,6 +298,11 @@ public:
   bool stringifiedInMacro() const {
 return (Flags & StringifiedInMacro) ? true : false;
   }
+
+  /// Returns true if the comma after this token was elided.
+  bool commaAfterElided() const {
+return (Flags & CommaAfterElided) ? true : false;
+  }
 };
 
 /// \brief Information about the conditional stack (\#if directives)

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=258530&r1=258529&r2=258530&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jan 22 13:26:44 2016
@@ -723,6 +723,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
   // heap allocations in the common case.
   SmallVector ArgTokens;
   bool ContainsCodeCompletionTok = false;
+  bool FoundElidedComma = false;
 
   SourceLocation TooManyArgsLoc;
 
@@ -765,6 +766,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
 // If we found the ) token, the macro arg list is done.
 if (NumParens-- == 0) {
   MacroEnd = Tok.getLocation();
+  if (!ArgTokens.empty() &&
+  ArgTokens.back().commaAfterElided()) {
+FoundElidedComma = true;
+  }
   break;
 }
   } else if (Tok.is(tok::l_paren)) {
@@ -909,7 +914,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
   // then we have an empty "()" argument empty list.  This is fine, even if
   // the macro expects one argument (the argument is just empty).
   isVarargsElided = MI->isVariadic();
-} else if (MI->isVariadic() &&
+} else if ((FoundElidedComma || MI->isVariadic()) &&
(NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
 (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
   // Varargs where the named vararg parameter is missing: OK as extension.

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=258530&r1=258529&r2=258530&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Fri Jan 22 13:26:44 2016
@@ -154,12 +154,17 @@ bool TokenLexer::MaybeRemoveCommaBeforeV
   // Remove the comma.
   ResultToks.pop_back();
 
-  // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
-  // then removal of the comma should produce a placemarker token (in C99
-  // terms) which we model by popping off the previous ##, giving us a plain
-  // "X" when __VA_ARGS__ is empty.
-  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
-ResultToks.pop_back();
+  if (!ResultToks.empty()) {
+// If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
+// then removal of the comma should produce a placemarker token (in C99
+// terms) which we model by popping off the previous ##, giving us a plain
+// "X" when __VA_ARGS__ is empty.
+if (ResultToks.back().is(tok::hashhash))
+  ResultToks.pop_back();
+
+// Remember that this comma was elided.
+ResultToks.back().setFlag(Token::CommaAfterElided);
+  }
 
   // Never add a space, even if the comma, ##, or arg had a space.
   NextTokGetsSpace = false;

Modified: cfe/trunk/test/Preprocessor/microsoft-ext.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/microsoft-ext.c?rev=258530&r1=258529&r2=258

Re: [PATCH] D15670: Accept elided commas in macro function arguments for MS compatibility

2016-01-22 Thread Ehsan Akhgari via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258530: [MSVC Compat] Accept elided commas in macro function 
arguments (authored by ehsan).

Changed prior to commit:
  http://reviews.llvm.org/D15670?vs=43310&id=45718#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15670

Files:
  cfe/trunk/include/clang/Lex/Token.h
  cfe/trunk/lib/Lex/PPMacroExpansion.cpp
  cfe/trunk/lib/Lex/TokenLexer.cpp
  cfe/trunk/test/Preprocessor/microsoft-ext.c

Index: cfe/trunk/include/clang/Lex/Token.h
===
--- cfe/trunk/include/clang/Lex/Token.h
+++ cfe/trunk/include/clang/Lex/Token.h
@@ -85,6 +85,7 @@
 IgnoredComma = 0x80,   // This comma is not a macro argument separator (MS).
 StringifiedInMacro = 0x100, // This string or character literal is formed by
 // macro stringizing or charizing operator.
+CommaAfterElided = 0x200, // The comma following this token was elided (MS).
   };
 
   tok::TokenKind getKind() const { return Kind; }
@@ -297,6 +298,11 @@
   bool stringifiedInMacro() const {
 return (Flags & StringifiedInMacro) ? true : false;
   }
+
+  /// Returns true if the comma after this token was elided.
+  bool commaAfterElided() const {
+return (Flags & CommaAfterElided) ? true : false;
+  }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
Index: cfe/trunk/test/Preprocessor/microsoft-ext.c
===
--- cfe/trunk/test/Preprocessor/microsoft-ext.c
+++ cfe/trunk/test/Preprocessor/microsoft-ext.c
@@ -34,3 +34,12 @@
 
 MAKE_FUNC(MAK, ER, int a, _COMMA, int b);
 // CHECK: void func(int a , int b) {}
+
+#define macro(a, b) (a - b)
+void function(int a);
+#define COMMA_ELIDER(...) \
+  macro(x, __VA_ARGS__); \
+  function(x, __VA_ARGS__);
+COMMA_ELIDER();
+// CHECK: (x - );
+// CHECK: function(x);
Index: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
===
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp
@@ -723,6 +723,7 @@
   // heap allocations in the common case.
   SmallVector ArgTokens;
   bool ContainsCodeCompletionTok = false;
+  bool FoundElidedComma = false;
 
   SourceLocation TooManyArgsLoc;
 
@@ -765,6 +766,10 @@
 // If we found the ) token, the macro arg list is done.
 if (NumParens-- == 0) {
   MacroEnd = Tok.getLocation();
+  if (!ArgTokens.empty() &&
+  ArgTokens.back().commaAfterElided()) {
+FoundElidedComma = true;
+  }
   break;
 }
   } else if (Tok.is(tok::l_paren)) {
@@ -909,7 +914,7 @@
   // then we have an empty "()" argument empty list.  This is fine, even if
   // the macro expects one argument (the argument is just empty).
   isVarargsElided = MI->isVariadic();
-} else if (MI->isVariadic() &&
+} else if ((FoundElidedComma || MI->isVariadic()) &&
(NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
 (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...) -> A()
   // Varargs where the named vararg parameter is missing: OK as extension.
Index: cfe/trunk/lib/Lex/TokenLexer.cpp
===
--- cfe/trunk/lib/Lex/TokenLexer.cpp
+++ cfe/trunk/lib/Lex/TokenLexer.cpp
@@ -154,12 +154,17 @@
   // Remove the comma.
   ResultToks.pop_back();
 
-  // If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
-  // then removal of the comma should produce a placemarker token (in C99
-  // terms) which we model by popping off the previous ##, giving us a plain
-  // "X" when __VA_ARGS__ is empty.
-  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
-ResultToks.pop_back();
+  if (!ResultToks.empty()) {
+// If the comma was right after another paste (e.g. "X##,##__VA_ARGS__"),
+// then removal of the comma should produce a placemarker token (in C99
+// terms) which we model by popping off the previous ##, giving us a plain
+// "X" when __VA_ARGS__ is empty.
+if (ResultToks.back().is(tok::hashhash))
+  ResultToks.pop_back();
+
+// Remember that this comma was elided.
+ResultToks.back().setFlag(Token::CommaAfterElided);
+  }
 
   // Never add a space, even if the comma, ##, or arg had a space.
   NextTokGetsSpace = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258531 - Fix the build by using the correct suffix for 64 bit literals

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 13:29:41 2016
New Revision: 258531

URL: http://llvm.org/viewvc/llvm-project?rev=258531&view=rev
Log:
Fix the build by using the correct suffix for 64 bit literals

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258531&r1=258530&r2=258531&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 13:29:41 2016
@@ -1742,7 +1742,7 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   if (CreateSkeletonCU && IsRootModule) {
 // PCH files don't have a signature field in the control block,
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
-uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1UL;
+uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
 DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
   Mod.getPath(), TheCU->getProducer(), true,

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258531&r1=258530&r2=258531&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22 
13:29:41 2016
@@ -222,7 +222,7 @@ public:
 
 // PCH files don't have a signature field in the control block,
 // but LLVM detects DWO CUs by looking for a non-zero DWO id.
-uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1UL;
+uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1ULL;
 Builder->getModuleDebugInfo()->setDwoId(Signature);
 
 // Finalize the Builder.


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


Re: [PATCH] D16376: clang-tidy check: User-defined copy without assignment

2016-01-22 Thread Jonathan B Coe via cfe-commits
jbcoe planned changes to this revision.
jbcoe added a comment.

i need the matcher from http://reviews.llvm.org/D16470 to add a corresponding 
pair of checks and fixes for move-constructors and move-assignment.


http://reviews.llvm.org/D16376



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


Re: [PATCH] D16469: Pass --wrap=pthread_create to linker for -fsplit-stack

2016-01-22 Thread Rafael Ávila de Espíndola via cfe-commits
rafael added a subscriber: rafael.
rafael added a comment.

Needs a testcase.


http://reviews.llvm.org/D16469



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


Re: [PATCH] D15624: Add iOS/watchOS/tvOS support for ASan (clang part)

2016-01-22 Thread Anna Zaks via cfe-commits
zaks.anna updated this revision to Diff 45720.
zaks.anna added a comment.

Thanks for spotting the bug! The bug is fixed and the tests are added in this 
revision.


http://reviews.llvm.org/D15624

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/darwin-sanitizer-ld.c
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -230,7 +230,7 @@
 // CHECK-VPTR-DARWIN-NEW: -fsanitize=alignment,vptr
 
 // RUN: %clang -target armv7-apple-ios7 -miphoneos-version-min=7.0 -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IOS
-// CHECK-ASAN-IOS: unsupported option '-fsanitize=address' for target 'arm-apple-ios7'
+// CHECK-ASAN-IOS: -fsanitize=address
 
 // RUN: %clang -target i386-pc-openbsd -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-OPENBSD
 // CHECK-ASAN-OPENBSD: unsupported option '-fsanitize=address' for target 'i386-pc-openbsd'
Index: test/Driver/darwin-sanitizer-ld.c
===
--- test/Driver/darwin-sanitizer-ld.c
+++ test/Driver/darwin-sanitizer-ld.c
@@ -11,16 +11,6 @@
 // CHECK-ASAN: "-rpath" "{{.*}}lib{{.*}}darwin"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
-// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
-
-// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ASAN-IOSSIM: lc++
-// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
-// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
-// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
-
-// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DYN-ASAN %s
 
@@ -65,3 +55,63 @@
 
 // CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
 // CHECK-DYN-BOUNDS-NOT: ubsan_osx
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mios-simulator-version-min=7.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOSSIM %s
+
+// CHECK-ASAN-IOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-IOSSIM: lc++
+// CHECK-ASAN-IOSSIM: libclang_rt.asan_iossim_dynamic.dylib"
+// CHECK-ASAN-IOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-IOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mtvos-simulator-version-min=8.3.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOSSIM %s
+
+// CHECK-ASAN-TVOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-TVOSSIM: lc++
+// CHECK-ASAN-TVOSSIM: libclang_rt.asan_tvossim_dynamic.dylib"
+// CHECK-ASAN-TVOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-TVOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN:   -fsanitize=address -mwatchos-simulator-version-min=2.0.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-WATCHOSSIM %s
+
+// CHECK-ASAN-WATCHOSSIM: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-WATCHOSSIM: lc++
+// CHECK-ASAN-WATCHOSSIM: libclang_rt.asan_watchossim_dynamic.dylib"
+// CHECK-ASAN-WATCHOSSIM: "-rpath" "@executable_path"
+// CHECK-ASAN-WATCHOSSIM: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target armv7-apple-ios  \
+// RUN:   -fsanitize=address -miphoneos-version-min=7 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-IOS %s
+
+// CHECK-ASAN-IOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-IOS: lc++
+// CHECK-ASAN-IOS: libclang_rt.asan_ios_dynamic.dylib"
+// CHECK-ASAN-IOS: "-rpath" "@executable_path"
+// CHECK-ASAN-IOS: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target arm64-apple-tvos \
+// RUN:   -fsanitize=address -mtvos-version-min=8.3 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-TVOS %s
+
+// CHECK-ASAN-TVOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-TVOS: lc++
+// CHECK-ASAN-TVOS: libclang_rt.asan_tvos_dynamic.dylib"
+// CHECK-ASAN-TVOS: "-rpath" "@executable_path"
+// CHECK-ASAN-TVOS: "-rpath" "{{.*}}lib{{.*}}darwin"
+
+// RUN: %clang -no-canonical-prefixes -### -target armv7k-apple-watchos \
+// RUN:   -fsanitize=address -mwatchos-version-min=2.0 %s -o %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ASAN-WATCHOS %s
+
+// CHECK-ASAN-WATCHOS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-WATCHOS: lc++
+// CHECK-ASAN-WATCHOS: libclang_rt.asan_watchos_dynamic.dylib"
+// CHECK-ASAN-WATCHOS: "-rpath" "@executable_path"
+// CHECK-ASAN-WATCHOS: "-rpath" "{{.*}}lib{{.*}}darwin"
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -496,6 +496,8 @@
 return TargetVersion < VersionTuple(V0, V1, V2);
   }
 

Re: r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Nico Weber via cfe-commits
Is it possible to emit some -Wmicrosoft warning in cases where this is
necessary?

On Fri, Jan 22, 2016 at 2:26 PM, Ehsan Akhgari via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ehsan
> Date: Fri Jan 22 13:26:44 2016
> New Revision: 258530
>
> URL: http://llvm.org/viewvc/llvm-project?rev=258530&view=rev
> Log:
> [MSVC Compat] Accept elided commas in macro function arguments
>
> Summary:
> This fixes PR25875.  When the trailing comma in a macro argument list is
> elided, we need to treat it similarly to the case where a variadic macro
> misses one actual argument.
>
> Reviewers: rnk, rsmith
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D15670
>
> Modified:
> cfe/trunk/include/clang/Lex/Token.h
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/lib/Lex/TokenLexer.cpp
> cfe/trunk/test/Preprocessor/microsoft-ext.c
>
> Modified: cfe/trunk/include/clang/Lex/Token.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=258530&r1=258529&r2=258530&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/Token.h (original)
> +++ cfe/trunk/include/clang/Lex/Token.h Fri Jan 22 13:26:44 2016
> @@ -85,6 +85,7 @@ public:
>  IgnoredComma = 0x80,   // This comma is not a macro argument
> separator (MS).
>  StringifiedInMacro = 0x100, // This string or character literal is
> formed by
>  // macro stringizing or charizing
> operator.
> +CommaAfterElided = 0x200, // The comma following this token was
> elided (MS).
>};
>
>tok::TokenKind getKind() const { return Kind; }
> @@ -297,6 +298,11 @@ public:
>bool stringifiedInMacro() const {
>  return (Flags & StringifiedInMacro) ? true : false;
>}
> +
> +  /// Returns true if the comma after this token was elided.
> +  bool commaAfterElided() const {
> +return (Flags & CommaAfterElided) ? true : false;
> +  }
>  };
>
>  /// \brief Information about the conditional stack (\#if directives)
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=258530&r1=258529&r2=258530&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jan 22 13:26:44 2016
> @@ -723,6 +723,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>// heap allocations in the common case.
>SmallVector ArgTokens;
>bool ContainsCodeCompletionTok = false;
> +  bool FoundElidedComma = false;
>
>SourceLocation TooManyArgsLoc;
>
> @@ -765,6 +766,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
>  // If we found the ) token, the macro arg list is done.
>  if (NumParens-- == 0) {
>MacroEnd = Tok.getLocation();
> +  if (!ArgTokens.empty() &&
> +  ArgTokens.back().commaAfterElided()) {
> +FoundElidedComma = true;
> +  }
>break;
>  }
>} else if (Tok.is(tok::l_paren)) {
> @@ -909,7 +914,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>// then we have an empty "()" argument empty list.  This is fine,
> even if
>// the macro expects one argument (the argument is just empty).
>isVarargsElided = MI->isVariadic();
> -} else if (MI->isVariadic() &&
> +} else if ((FoundElidedComma || MI->isVariadic()) &&
> (NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
>  (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...)
> -> A()
>// Varargs where the named vararg parameter is missing: OK as
> extension.
>
> Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=258530&r1=258529&r2=258530&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
> +++ cfe/trunk/lib/Lex/TokenLexer.cpp Fri Jan 22 13:26:44 2016
> @@ -154,12 +154,17 @@ bool TokenLexer::MaybeRemoveCommaBeforeV
>// Remove the comma.
>ResultToks.pop_back();
>
> -  // If the comma was right after another paste (e.g.
> "X##,##__VA_ARGS__"),
> -  // then removal of the comma should produce a placemarker token (in C99
> -  // terms) which we model by popping off the previous ##, giving us a
> plain
> -  // "X" when __VA_ARGS__ is empty.
> -  if (!ResultToks.empty() && ResultToks.back().is(tok::hashhash))
> -ResultToks.pop_back();
> +  if (!ResultToks.empty()) {
> +// If the comma was right after another paste (e.g.
> "X##,##__VA_ARGS__"),
> +// then removal of the comma should produce a placemarker token (in
> C99
> +// terms) which we model by popping off the previous ##, giving us a
> plain
> +// "X" when __VA_ARGS__ is empty.
> +if (ResultToks.back().is(tok::hashhash))

Re: r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Ehsan Akhgari via cfe-commits
Do you mean only a warning for the case this patch is handling, or also for
cases such as the second test case in
https://llvm.org/bugs/show_bug.cgi?id=25875#c1 too?

(I think it would probably be a good idea to warn in both cases.)

On Fri, Jan 22, 2016 at 2:39 PM, Nico Weber  wrote:

> Is it possible to emit some -Wmicrosoft warning in cases where this is
> necessary?
>
> On Fri, Jan 22, 2016 at 2:26 PM, Ehsan Akhgari via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ehsan
>> Date: Fri Jan 22 13:26:44 2016
>> New Revision: 258530
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=258530&view=rev
>> Log:
>> [MSVC Compat] Accept elided commas in macro function arguments
>>
>> Summary:
>> This fixes PR25875.  When the trailing comma in a macro argument list is
>> elided, we need to treat it similarly to the case where a variadic macro
>> misses one actual argument.
>>
>> Reviewers: rnk, rsmith
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D15670
>>
>> Modified:
>> cfe/trunk/include/clang/Lex/Token.h
>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> cfe/trunk/lib/Lex/TokenLexer.cpp
>> cfe/trunk/test/Preprocessor/microsoft-ext.c
>>
>> Modified: cfe/trunk/include/clang/Lex/Token.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=258530&r1=258529&r2=258530&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Lex/Token.h (original)
>> +++ cfe/trunk/include/clang/Lex/Token.h Fri Jan 22 13:26:44 2016
>> @@ -85,6 +85,7 @@ public:
>>  IgnoredComma = 0x80,   // This comma is not a macro argument
>> separator (MS).
>>  StringifiedInMacro = 0x100, // This string or character literal is
>> formed by
>>  // macro stringizing or charizing
>> operator.
>> +CommaAfterElided = 0x200, // The comma following this token was
>> elided (MS).
>>};
>>
>>tok::TokenKind getKind() const { return Kind; }
>> @@ -297,6 +298,11 @@ public:
>>bool stringifiedInMacro() const {
>>  return (Flags & StringifiedInMacro) ? true : false;
>>}
>> +
>> +  /// Returns true if the comma after this token was elided.
>> +  bool commaAfterElided() const {
>> +return (Flags & CommaAfterElided) ? true : false;
>> +  }
>>  };
>>
>>  /// \brief Information about the conditional stack (\#if directives)
>>
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=258530&r1=258529&r2=258530&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jan 22 13:26:44 2016
>> @@ -723,6 +723,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>// heap allocations in the common case.
>>SmallVector ArgTokens;
>>bool ContainsCodeCompletionTok = false;
>> +  bool FoundElidedComma = false;
>>
>>SourceLocation TooManyArgsLoc;
>>
>> @@ -765,6 +766,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>  // If we found the ) token, the macro arg list is done.
>>  if (NumParens-- == 0) {
>>MacroEnd = Tok.getLocation();
>> +  if (!ArgTokens.empty() &&
>> +  ArgTokens.back().commaAfterElided()) {
>> +FoundElidedComma = true;
>> +  }
>>break;
>>  }
>>} else if (Tok.is(tok::l_paren)) {
>> @@ -909,7 +914,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>// then we have an empty "()" argument empty list.  This is fine,
>> even if
>>// the macro expects one argument (the argument is just empty).
>>isVarargsElided = MI->isVariadic();
>> -} else if (MI->isVariadic() &&
>> +} else if ((FoundElidedComma || MI->isVariadic()) &&
>> (NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
>>  (NumActuals == 0 && MinArgsExpected == 2))) {// A(x,...)
>> -> A()
>>// Varargs where the named vararg parameter is missing: OK as
>> extension.
>>
>> Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=258530&r1=258529&r2=258530&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
>> +++ cfe/trunk/lib/Lex/TokenLexer.cpp Fri Jan 22 13:26:44 2016
>> @@ -154,12 +154,17 @@ bool TokenLexer::MaybeRemoveCommaBeforeV
>>// Remove the comma.
>>ResultToks.pop_back();
>>
>> -  // If the comma was right after another paste (e.g.
>> "X##,##__VA_ARGS__"),
>> -  // then removal of the comma should produce a placemarker token (in C99
>> -  // terms) which we model by popping off the previous ##, giving us a
>> plain
>> -  // "X" when __VA_ARGS__ is empty.
>> -  if (!ResultToks.empty() && ResultToks.back().is(tok

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Rong Xu via cfe-commits
xur added inline comments.


Comment at: lib/Driver/Tools.cpp:3279
@@ -3278,1 +3278,3 @@
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }

mcrosier wrote:
> I don't think AddAllArgs is what you really want.  What if the user specifies 
> the option twice?  Do we really want to pass the flag from the driver to the 
> front-end twice?  Also, should we warn if the option is passed twice?
> 
> I also think some of the logic in CompilerInvocation should land here...  see 
> comments below.
Thanks for pointing thi out. What about add a guard, like:
-  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
+  if (Args.hasArg(options::OPT_fprofile_ir_instr))
+Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);

But looking at it again, I think i need to remove this stmt in the most 
recently patch as OPT_profile_ir_instr is now a CC1 option. it will not be seen 
here, right?




Comment at: lib/Frontend/CompilerInvocation.cpp:482
@@ +481,3 @@
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr) &&
+(Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ) ||

mcrosier wrote:
> IIRC, the general practice is to put this type of logic in the driver.  
> Specifically, in Driver.cpp include something like
> 
> if (Args.hasArg(OPT_fprofile_ir_instr) &&
> (Args.hasArg(OPT_fprofile_instr_generate) ||
>  Args.hasArg(OPT_fprofile_instr_generate_EQ) ||
>  Args.hasArg(OPT_fprofile_instr_use_EQ)))
>   // Add -fprofile_ir_instr flag
> 
> 
In the most recent patch (Suggested by Sean as a temporary measure to speed up 
the code review)  where -fprofiel-ir-instr becomes a CC1 only option, I have to 
do it here. Driver won't see the OPT_fprofile_ir_instr. 

But I'll remember you point when this becomes a Driver option in the next step. 
Also note that the driver could convert "-fprofile-genearte" to 
"-fprofiel-instr-generate" and also for "-fprofile-use".  So the condition will 
be longer if we move to driver.


http://reviews.llvm.org/D15829



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


[PATCH] D16480: [libcxx] NFC: suppress warning on systems where sizeof(int) == sizeof(long)

2016-01-22 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added a reviewer: mclow.lists.
bcraig added a subscriber: cfe-commits.

The old code produced a couple of these warnings...

src/string.cpp:95:11: warning: comparison of constant -2147483648 with 
expression of type 'long' (range [-2147483648, 2147483647]) is always false 
[-Wtautological-constant-out-of-range-compare]
if (r < numeric_limits::min() || numeric_limits::max() < r)
~ ^ ~~
src/string.cpp:95:11: note: place two sets of parentheses around the constant 
to silence this warning
if (r < numeric_limits::min() || numeric_limits::max() < r)


This patch follows the advice of the note, as the comparison is reasonable on 
many 64-bit systems.

http://reviews.llvm.org/D16480

Files:
  src/string.cpp

Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -91,7 +91,7 @@
 {
 // Use long as no Standard string to integer exists.
 long r = as_integer_helper( func, s, idx, base, strtol );
-if (r < numeric_limits::min() || numeric_limits::max() < r)
+if (r < ((numeric_limits::min())) || ((numeric_limits::max())) < 
r)
 throw_from_string_out_of_range(func);
 return static_cast(r);
 }
@@ -136,7 +136,7 @@
 {
 // Use long as no Stantard string to integer exists.
 long r = as_integer_helper( func, s, idx, base, wcstol );
-if (r < numeric_limits::min() || numeric_limits::max() < r)
+if (r < ((numeric_limits::min())) || ((numeric_limits::max())) < 
r)
 throw_from_string_out_of_range(func);
 return static_cast(r);
 }


Index: src/string.cpp
===
--- src/string.cpp
+++ src/string.cpp
@@ -91,7 +91,7 @@
 {
 // Use long as no Standard string to integer exists.
 long r = as_integer_helper( func, s, idx, base, strtol );
-if (r < numeric_limits::min() || numeric_limits::max() < r)
+if (r < ((numeric_limits::min())) || ((numeric_limits::max())) < r)
 throw_from_string_out_of_range(func);
 return static_cast(r);
 }
@@ -136,7 +136,7 @@
 {
 // Use long as no Stantard string to integer exists.
 long r = as_integer_helper( func, s, idx, base, wcstol );
-if (r < numeric_limits::min() || numeric_limits::max() < r)
+if (r < ((numeric_limits::min())) || ((numeric_limits::max())) < r)
 throw_from_string_out_of_range(func);
 return static_cast(r);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16482: Add builtins for bitreverse intrinsic

2016-01-22 Thread Matt Arsenault via cfe-commits
arsenm created this revision.
arsenm added a reviewer: jmolloy.
arsenm added a subscriber: cfe-commits.

Follow the naming convention that bswap uses since it's a
similar sort of operation.

http://reviews.llvm.org/D16482

Files:
  include/clang/Basic/Builtins.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins.c

Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -116,6 +116,14 @@
   P(bswap16, (N));
   P(bswap32, (N));
   P(bswap64, (N));
+
+  // CHECK: @llvm.bitreverse.i16
+  // CHECK: @llvm.bitreverse.i32
+  // CHECK: @llvm.bitreverse.i64
+  P(bitreverse16, (N));
+  P(bitreverse32, (N));
+  P(bitreverse64, (N));
+
   // FIXME
   // V(clear_cache, (&N, &N+1));
   V(trap, ());
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -288,6 +288,40 @@
   return CGF.Builder.CreateExtractValue(Tmp, 0);
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type.
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, Src0);
+}
+
+// Emit an intrinsic that has 3 float or double operands.
+static Value *emitTernaryFPBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, {Src0, Src1, Src2});
+}
+
+// Emit an intrinsic that has 1 float or double operand, and 1 integer.
+static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
+   const CallExpr *E,
+   unsigned IntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  return CGF.Builder.CreateCall(F, {Src0, Src1});
+}
+
 namespace {
   struct WidthAndSignedness {
 unsigned Width;
@@ -645,10 +679,12 @@
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
   case Builtin::BI__builtin_bswap64: {
-Value *ArgValue = EmitScalarExpr(E->getArg(0));
-llvm::Type *ArgType = ArgValue->getType();
-Value *F = CGM.getIntrinsic(Intrinsic::bswap, ArgType);
-return RValue::get(Builder.CreateCall(F, ArgValue));
+return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
+  }
+  case Builtin::BI__builtin_bitreverse16:
+  case Builtin::BI__builtin_bitreverse32:
+  case Builtin::BI__builtin_bitreverse64: {
+return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bitreverse));
   }
   case Builtin::BI__builtin_object_size: {
 unsigned Type =
@@ -6851,39 +6887,6 @@
   }
 }
 
-// Emit an intrinsic that has 1 float or double.
-static Value *emitUnaryFPBuiltin(CodeGenFunction &CGF,
- const CallExpr *E,
- unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, Src0);
-}
-
-// Emit an intrinsic that has 3 float or double operands.
-static Value *emitTernaryFPBuiltin(CodeGenFunction &CGF,
-   const CallExpr *E,
-   unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
-  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, {Src0, Src1, Src2});
-}
-
-// Emit an intrinsic that has 1 float or double operand, and 1 integer.
-static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
-   const CallExpr *E,
-   unsigned IntrinsicID) {
-  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
-  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
-
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
-  return CGF.Builder.CreateCall(F, {Src0, Src1});
-}
-
 Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E) {
   switch (BuiltinID) {
@@ -6933,13 +6936,13 @@
 return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_trig_preop);
   case AMDGPU::BI__builtin_amdgcn_rcp:
   case AMDGPU::BI__b

Re: r258530 - [MSVC Compat] Accept elided commas in macro function arguments

2016-01-22 Thread Nico Weber via cfe-commits
Every time we accept something in MS mode that isn't standards compliant,
we should accept it with a warning (for stuff that's harmless, an Extension
warning, for stuff that can lead to bugs a Warning warning), unless it's
really hard to implement.

(See also
https://docs.google.com/presentation/d/1oxNHaVjA9Gn_rTzX6HIpJHP7nXRua_0URXxxJ3oYRq0/edit#slide=id.g71ecd450e_2_812
slide 27.)

On Fri, Jan 22, 2016 at 2:44 PM, Ehsan Akhgari 
wrote:

> Do you mean only a warning for the case this patch is handling, or also
> for cases such as the second test case in
> https://llvm.org/bugs/show_bug.cgi?id=25875#c1 too?
>
> (I think it would probably be a good idea to warn in both cases.)
>
> On Fri, Jan 22, 2016 at 2:39 PM, Nico Weber  wrote:
>
>> Is it possible to emit some -Wmicrosoft warning in cases where this is
>> necessary?
>>
>> On Fri, Jan 22, 2016 at 2:26 PM, Ehsan Akhgari via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ehsan
>>> Date: Fri Jan 22 13:26:44 2016
>>> New Revision: 258530
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258530&view=rev
>>> Log:
>>> [MSVC Compat] Accept elided commas in macro function arguments
>>>
>>> Summary:
>>> This fixes PR25875.  When the trailing comma in a macro argument list is
>>> elided, we need to treat it similarly to the case where a variadic macro
>>> misses one actual argument.
>>>
>>> Reviewers: rnk, rsmith
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: http://reviews.llvm.org/D15670
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Lex/Token.h
>>> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>> cfe/trunk/lib/Lex/TokenLexer.cpp
>>> cfe/trunk/test/Preprocessor/microsoft-ext.c
>>>
>>> Modified: cfe/trunk/include/clang/Lex/Token.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=258530&r1=258529&r2=258530&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Lex/Token.h (original)
>>> +++ cfe/trunk/include/clang/Lex/Token.h Fri Jan 22 13:26:44 2016
>>> @@ -85,6 +85,7 @@ public:
>>>  IgnoredComma = 0x80,   // This comma is not a macro argument
>>> separator (MS).
>>>  StringifiedInMacro = 0x100, // This string or character literal is
>>> formed by
>>>  // macro stringizing or charizing
>>> operator.
>>> +CommaAfterElided = 0x200, // The comma following this token was
>>> elided (MS).
>>>};
>>>
>>>tok::TokenKind getKind() const { return Kind; }
>>> @@ -297,6 +298,11 @@ public:
>>>bool stringifiedInMacro() const {
>>>  return (Flags & StringifiedInMacro) ? true : false;
>>>}
>>> +
>>> +  /// Returns true if the comma after this token was elided.
>>> +  bool commaAfterElided() const {
>>> +return (Flags & CommaAfterElided) ? true : false;
>>> +  }
>>>  };
>>>
>>>  /// \brief Information about the conditional stack (\#if directives)
>>>
>>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=258530&r1=258529&r2=258530&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Jan 22 13:26:44 2016
>>> @@ -723,6 +723,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>>// heap allocations in the common case.
>>>SmallVector ArgTokens;
>>>bool ContainsCodeCompletionTok = false;
>>> +  bool FoundElidedComma = false;
>>>
>>>SourceLocation TooManyArgsLoc;
>>>
>>> @@ -765,6 +766,10 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>>  // If we found the ) token, the macro arg list is done.
>>>  if (NumParens-- == 0) {
>>>MacroEnd = Tok.getLocation();
>>> +  if (!ArgTokens.empty() &&
>>> +  ArgTokens.back().commaAfterElided()) {
>>> +FoundElidedComma = true;
>>> +  }
>>>break;
>>>  }
>>>} else if (Tok.is(tok::l_paren)) {
>>> @@ -909,7 +914,7 @@ MacroArgs *Preprocessor::ReadFunctionLik
>>>// then we have an empty "()" argument empty list.  This is fine,
>>> even if
>>>// the macro expects one argument (the argument is just empty).
>>>isVarargsElided = MI->isVariadic();
>>> -} else if (MI->isVariadic() &&
>>> +} else if ((FoundElidedComma || MI->isVariadic()) &&
>>> (NumActuals+1 == MinArgsExpected ||  // A(x, ...) -> A(X)
>>>  (NumActuals == 0 && MinArgsExpected == 2))) {//
>>> A(x,...) -> A()
>>>// Varargs where the named vararg parameter is missing: OK as
>>> extension.
>>>
>>> Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=258530&r1=258529&r2=258530&view=diff
>>>
>>> ==
>>> --- cfe/trunk/li

r258543 - [OpenMP] Update map clause SEMA to support OpenMP 4.5 possible list items.

2016-01-22 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Jan 22 14:21:36 2016
New Revision: 258543

URL: http://llvm.org/viewvc/llvm-project?rev=258543&view=rev
Log:
[OpenMP] Update map clause SEMA to support OpenMP 4.5 possible list items.

Summary:
Extend support in the map clause SEMA for the expressions supported in the 
OpenMP 4.5 specification, namely member expressions.  

Fix some bugs in the previous implementation of SEMA related with expressions 
that do not consist of single variable references.

Fix bug in parsing when the expression in the map clause do not start with an 
identifier: accept any expression in the map clause and check for validity in 
SEMA instead of just ignoring it.

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

Subscribers: cfe-commits, fraggamuffin, caomhin

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_map_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258543&r1=258542&r2=258543&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 22 14:21:36 
2016
@@ -7714,6 +7714,24 @@ def err_omp_expected_var_name_member_exp
   "expected variable name%select{| or data member of current class}0">;
 def err_omp_expected_var_name_member_expr_or_array_item : Error<
   "expected variable name%select{|, data member of current class}0, array 
element or array section">;
+def err_omp_expected_named_var_member_or_array_expression: Error<
+  "expected expression containing only member accesses and/or array sections 
based on named variables">;
+def err_omp_bit_fields_forbidden_in_map_clause : Error<
+  "bit fields cannot be used to specify storage in a map clause">;
+def err_omp_array_section_in_rightmost_expression : Error<
+  "array section can only be associated with the rightmost variable in a map 
clause expression">;
+def err_omp_union_type_not_allowed : Error<
+  "mapped storage cannot be derived from a union">;
+def err_omp_expected_access_to_data_field : Error<
+  "expected access to data field">;
+def err_omp_multiple_array_items_in_map_clause : Error<
+  "multiple array elements associated with the same variable are not allowed 
in map clauses of the same construct">;
+def err_omp_pointer_mapped_along_with_derived_section : Error<
+  "pointer cannot be mapped along with a section derived from itself">;
+def err_omp_original_storage_is_shared_and_does_not_contain : Error<
+  "original storage of expression in data environment is shared but data 
environment do not fully contain mapped expression storage">;
+def err_omp_same_pointer_derreferenced : Error<
+  "same pointer derreferenced in multiple different ways in map clause 
expressions">;
 def note_omp_task_predetermined_firstprivate_here : Note<
   "predetermined as a firstprivate in a task construct here">;
 def err_omp_threadprivate_incomplete_type : Error<

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=258543&r1=258542&r2=258543&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Fri Jan 22 14:21:36 2016
@@ -900,7 +900,6 @@ OMPClause *Parser::ParseOpenMPVarListCla
   OpenMPMapClauseKind MapTypeModifier = OMPC_MAP_unknown;
   bool MapTypeIsImplicit = false;
   bool MapTypeModifierSpecified = false;
-  bool UnexpectedId = false;
   SourceLocation DepLinMapLoc;
 
   // Parse '('.
@@ -1021,7 +1020,8 @@ OMPClause *Parser::ParseOpenMPVarListCla
 MapTypeIsImplicit = true;
   }
 } else {
-  UnexpectedId = true;
+  MapType = OMPC_MAP_tofrom;
+  MapTypeIsImplicit = true;
 }
 
 if (Tok.is(tok::colon)) {
@@ -1036,7 +1036,7 @@ OMPClause *Parser::ParseOpenMPVarListCla
   ((Kind != OMPC_reduction) && (Kind != OMPC_depend) &&
(Kind != OMPC_map)) ||
   ((Kind == OMPC_reduction) && !InvalidReductionId) ||
-  ((Kind == OMPC_map) && (UnexpectedId || MapType != OMPC_MAP_unknown) &&
+  ((Kind == OMPC_map) && (MapType != OMPC_MAP_unknown) &&
(!MapTypeModifierSpecified ||
 (MapTypeModifierSpecified && MapTypeModifier == OMPC_MAP_always))) ||
   ((Kind == OMPC_depend) && DepKind != OMPC_DEPEND_unknown);
@@ -1088,9 +1088,8 @@ OMPClause *Parser::ParseOpenMPVarListCla
   // Parse ')'.
   T.consumeClose();
   if ((Kind == OMPC_depend && DepKind != OMPC_DEPEND_unknown && Vars.empty()) 
||
-  (Kind != OMPC_depend && Vars.empty()) || (MustHaveTail && !TailExpr) ||
-  (Kind == OMPC_map && MapType == OMPC_

Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-22 Thread Nico Weber via cfe-commits
I implemented Reid's suggestion in 258545. I tested that the test runs and
passes when the DIA SDK is around (this is usually the case), and doesn't
run when it isn't.

On Thu, Jan 21, 2016 at 2:09 PM, Alexey Samsonov  wrote:

> On Thu, Jan 21, 2016 at 10:58 AM, Reid Kleckner  wrote:
>
>> On Thu, Jan 21, 2016 at 10:47 AM, Nico Weber  wrote:
>>
>>> Oh, ok, let's not depend on lld then. So, we need to either determine if
 DIA SDK is available at compiler-rt configure time, or teach
 llvm-symbolizer.exe to tell us that (as we support standalone compiler-rt
 build)...

>>>
>>> Maybe the lit config file could compile a small program with clang-cl
>>> and then run it through llvm-symbolizer and see if a symbol is returned?
>>>
>>
>> I'd rather duplicate this check in compiler-rt than add auto-conf style
>> tests to check-asan startup:
>>   # See if the DIA SDK is available and usable.
>>   set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
>>   if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
>> set(HAVE_DIA_SDK 1)
>>   else()
>> set(HAVE_DIA_SDK 0)
>>   endif()
>>
>
> Yes. It's not 100% correct, but probably fine to assume that if we failed
> to find DIA SDK at configure time, so did llvm-symbolizer when it was built.
>
>
>>
>> It is also possible to change LLVMSymbolizer::SymbolizePC to return false
>> when llvm-symbolizer returns no useful information.
>>
>
> Do we want LLVMSymbolizer::SymbolizePC to succeed if we fetched file/line
> info, but not function name?
> Also, there may well be another issue that will be hard to debug. It makes
> sense to store information about what features of llvm-symbolizer we expect
> to work explicitly.
>
>
>> This will cause the sanitizers to try calling into dbghelp, which will
>> probably work. It doesn't return PDB column info or work with dwarf, which
>> is why we try llvm-symbolizer first. I think I made this change at one
>> point, but I was asked to revert it or there were minor issues that didn't
>> seem worth fixing.
>>
>
>
> --
> Alexey Samsonov
> vonos...@gmail.com
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r258110 - Fix PR26134: When substituting into default template arguments, keep CurContext unchanged.

2016-01-22 Thread Dimitry Andric via cfe-commits
Hans,

This change looks pretty trivial, and is required to not crash for the test 
cases in PR26134.  Can we merge it to release_38, please?

-Dimitry

> On 19 Jan 2016, at 19:28, Dimitry Andric via cfe-commits 
>  wrote:
> 
> Hi Richard,
> 
> I am unsure if you are specifically the code owner of Sema, but can you 
> please approve this change for the 3.8 branch?
> 
> -Dimitry
> 
>> On 19 Jan 2016, at 04:58, Faisal Vali via cfe-commits 
>>  wrote:
>> 
>> Author: faisalv
>> Date: Mon Jan 18 21:58:55 2016
>> New Revision: 258110
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=258110&view=rev
>> Log:
>> Fix PR26134: When substituting into default template arguments, keep 
>> CurContext unchanged.
>> 
>> Or, do not set Sema's CurContext to the template declaration's when 
>> substituting into default template arguments of said template declaration.
>> If we do push the template declaration context on to Sema, and the template 
>> declaration is at namespace scope, Sema can get confused and try and do odr 
>> analysis when substituting into default template arguments, even though the 
>> substitution could be occurring within a dependent context.
>> I'm not sure why this was being done, perhaps there was concern that if a 
>> default template argument referred to a previous template parameter, it 
>> might not be found during substitution - but all regression tests pass, and 
>> I can't craft a test that would cause it to fails (if some one does, please 
>> inform me, and i'll craft a different fix for the PR).
>> 
>> 
>> This patch removes a single line of code, but unfortunately adds more than 
>> it removes, because of the tests.  Some day I still hope to commit a patch 
>> that removes far more lines than it adds, while leaving clang better for it 
>> ;)
>> 
>> Sorry that r253590 ("Change the expression evaluation context from 
>> Unevaluated to ConstantEvaluated while substituting into non-type template 
>> argument defaults") caused the PR!
>> 
>> 
>> 
>> 
>> 
>> Modified:
>>   cfe/trunk/lib/Sema/SemaTemplate.cpp
>>   cfe/trunk/test/SemaTemplate/default-arguments.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=258110&r1=258109&r2=258110&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 18 21:58:55 2016
>> @@ -3281,7 +3281,6 @@ SubstDefaultTemplateArgument(Sema &SemaR
>>  for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
>>TemplateArgLists.addOuterTemplateArguments(None);
>> 
>> -  Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
>>  EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
>> Sema::ConstantEvaluated);
>>  return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
>> 
>> Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=258110&r1=258109&r2=258110&view=diff
>> ==
>> --- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Mon Jan 18 21:58:55 
>> 2016
>> @@ -179,3 +179,31 @@ struct C {
>>  C(T t = ); // expected-error {{expected expression}}
>> };
>> C obj;
>> +
>> +namespace PR26134 {
>> +// Make sure when substituting default template arguments we do it in the 
>> current context.
>> +template
>> +struct X {};
>> +
>> +template struct Y {
>> +  void f() { X xy; }
>> +  static const bool value = B;
>> +};
>> +
>> +namespace ns1 {
>> +template
>> +struct X {
>> +  template struct XInner { static const bool value = B; 
>> };
>> +};
>> +template struct S { static const bool value = B; };
>> +#if __cplusplus > 199711L
>> +template struct Y {
>> +  static constexpr bool f() { return typename X>::template 
>> XInner<>{}.value; }
>> +  static_assert(f() == B, "");
>> +};
>> +Y y;
>> +Y y2;
>> +#endif
>> +
>> +} // end ns1
>> +} // end ns PR26134
>> 
>> 
>> ___
>> 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



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


Re: r258110 - Fix PR26134: When substituting into default template arguments, keep CurContext unchanged.

2016-01-22 Thread Hans Wennborg via cfe-commits
It seems Richard is out of office, but perhaps he can verify this later.

Dimitry: go ahead and merge it (or let me know if you'd like me to).

On Fri, Jan 22, 2016 at 12:38 PM, Dimitry Andric  wrote:
> Hans,
>
> This change looks pretty trivial, and is required to not crash for the test 
> cases in PR26134.  Can we merge it to release_38, please?
>
> -Dimitry
>
>> On 19 Jan 2016, at 19:28, Dimitry Andric via cfe-commits 
>>  wrote:
>>
>> Hi Richard,
>>
>> I am unsure if you are specifically the code owner of Sema, but can you 
>> please approve this change for the 3.8 branch?
>>
>> -Dimitry
>>
>>> On 19 Jan 2016, at 04:58, Faisal Vali via cfe-commits 
>>>  wrote:
>>>
>>> Author: faisalv
>>> Date: Mon Jan 18 21:58:55 2016
>>> New Revision: 258110
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=258110&view=rev
>>> Log:
>>> Fix PR26134: When substituting into default template arguments, keep 
>>> CurContext unchanged.
>>>
>>> Or, do not set Sema's CurContext to the template declaration's when 
>>> substituting into default template arguments of said template declaration.
>>> If we do push the template declaration context on to Sema, and the template 
>>> declaration is at namespace scope, Sema can get confused and try and do odr 
>>> analysis when substituting into default template arguments, even though the 
>>> substitution could be occurring within a dependent context.
>>> I'm not sure why this was being done, perhaps there was concern that if a 
>>> default template argument referred to a previous template parameter, it 
>>> might not be found during substitution - but all regression tests pass, and 
>>> I can't craft a test that would cause it to fails (if some one does, please 
>>> inform me, and i'll craft a different fix for the PR).
>>>
>>>
>>> This patch removes a single line of code, but unfortunately adds more than 
>>> it removes, because of the tests.  Some day I still hope to commit a patch 
>>> that removes far more lines than it adds, while leaving clang better for it 
>>> ;)
>>>
>>> Sorry that r253590 ("Change the expression evaluation context from 
>>> Unevaluated to ConstantEvaluated while substituting into non-type template 
>>> argument defaults") caused the PR!
>>>
>>>
>>>
>>>
>>>
>>> Modified:
>>>   cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>   cfe/trunk/test/SemaTemplate/default-arguments.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=258110&r1=258109&r2=258110&view=diff
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 18 21:58:55 2016
>>> @@ -3281,7 +3281,6 @@ SubstDefaultTemplateArgument(Sema &SemaR
>>>  for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
>>>TemplateArgLists.addOuterTemplateArguments(None);
>>>
>>> -  Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
>>>  EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
>>> 
>>> Sema::ConstantEvaluated);
>>>  return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
>>>
>>> Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=258110&r1=258109&r2=258110&view=diff
>>> ==
>>> --- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
>>> +++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Mon Jan 18 21:58:55 
>>> 2016
>>> @@ -179,3 +179,31 @@ struct C {
>>>  C(T t = ); // expected-error {{expected expression}}
>>> };
>>> C obj;
>>> +
>>> +namespace PR26134 {
>>> +// Make sure when substituting default template arguments we do it in the 
>>> current context.
>>> +template
>>> +struct X {};
>>> +
>>> +template struct Y {
>>> +  void f() { X xy; }
>>> +  static const bool value = B;
>>> +};
>>> +
>>> +namespace ns1 {
>>> +template
>>> +struct X {
>>> +  template struct XInner { static const bool value = 
>>> B; };
>>> +};
>>> +template struct S { static const bool value = B; };
>>> +#if __cplusplus > 199711L
>>> +template struct Y {
>>> +  static constexpr bool f() { return typename X>::template 
>>> XInner<>{}.value; }
>>> +  static_assert(f() == B, "");
>>> +};
>>> +Y y;
>>> +Y y2;
>>> +#endif
>>> +
>>> +} // end ns1
>>> +} // end ns PR26134
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lis

Re: [PATCH] D16376: clang-tidy check: User-defined copy without assignment

2016-01-22 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 45729.
jbcoe added a comment.

Added handling for move-constructor/move-assignment pairs.


http://reviews.llvm.org/D16376

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UserDefinedCopyWithoutAssignmentCheck.cpp
  clang-tidy/misc/UserDefinedCopyWithoutAssignmentCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-user-defined-copy-without-assignment.rst
  test/clang-tidy/misc-user-defined-copy-without-assignment.cpp

Index: test/clang-tidy/misc-user-defined-copy-without-assignment.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-user-defined-copy-without-assignment.cpp
@@ -0,0 +1,161 @@
+// RUN: %check_clang_tidy %s misc-user-defined-copy-without-assignment %t
+
+//
+// User defined copy-constructors
+//
+class A {
+  A(const A &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'A' defines a copy-constructor but not a copy-assignment operator [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class A {
+// CHECK-FIXES-NEXT: A(const A &);
+// CHECK-FIXES-NEXT: A &operator=(const A &) = delete;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class B {
+  B(const B &);
+  B &operator=(const B &);
+};
+
+class C {
+  C(const C &) = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'C' defines a copy-constructor but not a copy-assignment operator [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class C {
+// CHECK-FIXES-NEXT: C(const C &) = default;
+// CHECK-FIXES-NEXT: C &operator=(const C &) = default;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class D {
+  D(const D &);
+  D &operator=(const D &) = default;
+};
+
+class E {
+  E(const E &);
+  E &operator=(const E &) = delete;
+};
+
+//
+// User defined copy-assignment
+//
+class A2 {
+  A2 &operator=(const A2 &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class 'A2' defines a copy-assignment operator but not a copy-constructor [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class A2 {
+// CHECK-FIXES-NEXT: A2(const A2 &) = delete;
+// CHECK-FIXES-NEXT: A2 &operator=(const A2 &);
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class B2 {
+  B2(const B2 &);
+  B2 &operator=(const B2 &);
+};
+
+class C2 {
+  C2 &operator=(const C2 &) = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class 'C2' defines a copy-assignment operator but not a copy-constructor [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class C2 {
+// CHECK-FIXES-NEXT: C2(const C2 &) = default;
+// CHECK-FIXES-NEXT: C2 &operator=(const C2 &) = default;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class D2 {
+  D2(const D2 &) = default;
+  D2 &operator=(const D2 &);
+};
+
+class E2 {
+  E2(const E2 &) = delete;
+  E2 &operator=(const E2 &);
+};
+
+//
+// User defined move-constructors
+//
+class A3 {
+  A3(A3 &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'A3' defines a move-constructor but not a move-assignment operator [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class A3 {
+// CHECK-FIXES-NEXT: A3(A3 &&);
+// CHECK-FIXES-NEXT: A3 &operator=(A3 &&) = delete;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class B3 {
+  B3(B3 &&);
+  B3 &operator=(B3 &&);
+};
+
+class C3 {
+  C3(C3 &&) = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'C3' defines a move-constructor but not a move-assignment operator [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class C3 {
+// CHECK-FIXES-NEXT: C3(C3 &&) = default;
+// CHECK-FIXES-NEXT: C3 &operator=(C3 &&) = default;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class D3 {
+  D3(D3 &&);
+  D3 &operator=(D3 &&) = default;
+};
+
+class E3 {
+  E3(E3 &&);
+  E3 &operator=(E3 &&) = delete;
+};
+
+//
+// User defined move-assignment
+//
+class A4 {
+  A4 &operator=(A4 &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class 'A4' defines a move-assignment operator but not a move-constructor [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class A4 {
+// CHECK-FIXES-NEXT: A4(A4 &&) = delete;
+// CHECK-FIXES-NEXT: A4 &operator=(A4 &&);
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class B4 {
+  B4(B4 &&);
+  B4 &operator=(B4 &&);
+};
+
+class C4 {
+  C4 &operator=(C4 &&) = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: class 'C4' defines a move-assignment operator but not a move-constructor [misc-user-defined-copy-without-assignment]
+};
+
+// CHECK-FIXES: class C4 {
+// CHECK-FIXES-NEXT: C4(C4 &&) = default;
+// CHECK-FIXES-NEXT: C4 &operator=(C4 &&) = default;
+// CHECK-FIXES-NEXT: //
+// CHECK-FIXES-NEXT: };
+
+class D4 {
+  D4(D4 &&) = default;
+  D4 &operator=(D4 &&);
+};
+
+class E4 {
+  E4(E4 &&) = delete;
+  E4 &operator=(E4 &&);
+};
Index: docs/clang-tidy/checks/misc-user-defined-copy-without-assignment.rst
=

Re: r258110 - Fix PR26134: When substituting into default template arguments, keep CurContext unchanged.

2016-01-22 Thread Dimitry Andric via cfe-commits
Thanks, I merged it in r258549.

-Dimitry

> On 22 Jan 2016, at 21:43, Hans Wennborg  wrote:
> 
> It seems Richard is out of office, but perhaps he can verify this later.
> 
> Dimitry: go ahead and merge it (or let me know if you'd like me to).
> 
> On Fri, Jan 22, 2016 at 12:38 PM, Dimitry Andric  wrote:
>> Hans,
>> 
>> This change looks pretty trivial, and is required to not crash for the test 
>> cases in PR26134.  Can we merge it to release_38, please?
>> 
>> -Dimitry
>> 
>>> On 19 Jan 2016, at 19:28, Dimitry Andric via cfe-commits 
>>>  wrote:
>>> 
>>> Hi Richard,
>>> 
>>> I am unsure if you are specifically the code owner of Sema, but can you 
>>> please approve this change for the 3.8 branch?
>>> 
>>> -Dimitry
>>> 
 On 19 Jan 2016, at 04:58, Faisal Vali via cfe-commits 
  wrote:
 
 Author: faisalv
 Date: Mon Jan 18 21:58:55 2016
 New Revision: 258110
 
 URL: http://llvm.org/viewvc/llvm-project?rev=258110&view=rev
 Log:
 Fix PR26134: When substituting into default template arguments, keep 
 CurContext unchanged.
 
 Or, do not set Sema's CurContext to the template declaration's when 
 substituting into default template arguments of said template declaration.
 If we do push the template declaration context on to Sema, and the 
 template declaration is at namespace scope, Sema can get confused and try 
 and do odr analysis when substituting into default template arguments, 
 even though the substitution could be occurring within a dependent context.
 I'm not sure why this was being done, perhaps there was concern that if a 
 default template argument referred to a previous template parameter, it 
 might not be found during substitution - but all regression tests pass, 
 and I can't craft a test that would cause it to fails (if some one does, 
 please inform me, and i'll craft a different fix for the PR).
 
 
 This patch removes a single line of code, but unfortunately adds more than 
 it removes, because of the tests.  Some day I still hope to commit a patch 
 that removes far more lines than it adds, while leaving clang better for 
 it ;)
 
 Sorry that r253590 ("Change the expression evaluation context from 
 Unevaluated to ConstantEvaluated while substituting into non-type template 
 argument defaults") caused the PR!
 
 
 
 
 
 Modified:
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/SemaTemplate/default-arguments.cpp
 
 Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=258110&r1=258109&r2=258110&view=diff
 ==
 --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
 +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Jan 18 21:58:55 2016
 @@ -3281,7 +3281,6 @@ SubstDefaultTemplateArgument(Sema &SemaR
 for (unsigned i = 0, e = Param->getDepth(); i != e; ++i)
   TemplateArgLists.addOuterTemplateArguments(None);
 
 -  Sema::ContextRAII SavedContext(SemaRef, Template->getDeclContext());
 EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,

 Sema::ConstantEvaluated);
 return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 
 Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=258110&r1=258109&r2=258110&view=diff
 ==
 --- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
 +++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Mon Jan 18 21:58:55 
 2016
 @@ -179,3 +179,31 @@ struct C {
 C(T t = ); // expected-error {{expected expression}}
 };
 C obj;
 +
 +namespace PR26134 {
 +// Make sure when substituting default template arguments we do it in the 
 current context.
 +template
 +struct X {};
 +
 +template struct Y {
 +  void f() { X xy; }
 +  static const bool value = B;
 +};
 +
 +namespace ns1 {
 +template
 +struct X {
 +  template struct XInner { static const bool value = 
 B; };
 +};
 +template struct S { static const bool value = B; };
 +#if __cplusplus > 199711L
 +template struct Y {
 +  static constexpr bool f() { return typename X>::template 
 XInner<>{}.value; }
 +  static_assert(f() == B, "");
 +};
 +Y y;
 +Y y2;
 +#endif
 +
 +} // end ns1
 +} // end ns PR26134
 
 
 ___
 cfe-commits mailing list
 cfe-commits@lists.llvm.org
 http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>> 
>>> _

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Xinliang David Li via cfe-commits
For the longer term, one possible solution is to make FE based
instrumentation only used for coverage testing which can be turned on
with -fcoverage-mapping option (currently, -fcoverage-mapping can not
be used alone and must be used together with
-fprofile-instr-generate). To summarize:

A. Current behavior:
---
1) -fprofile-instr-generate turns on FE based instrumentation
2) -fprofile-instr-generate -fcoverage-mapping turns on FE based
instrumentation and coverage mapping data generation.
3) -fprofile-instr-use=<..> assumes profile data from FE instrumentation.


B. Proposed new behavior:

1) -fprofile-instr-generate turns on IR late instrumentation
2) -fcoverage-mapping turns on FE instrumentation and coverage-mapping
3) -fprofile-instr-generate -fcoverage-mapping result in compiler warning
4) -fprofile-instr-use=<> will automatically determine how to use the
profile data.

B.2) above can be done today for improved usability. B.1) needs a
transition period before  the IR based instrumentation becomes
stablized (and can be flipped to the default).  During the transition
period, the behavior of 1) does not change, but a cc1 option can be
used to turn on IR instrumentation (as proposed by Sean).


In the real longer term, I think IR based instrumentation can also be
used for coverage testing too (by disabling some pre-optimizations and
pre-inlining needed for PGO purpose) -- but this is a different topic
to be discussed.

thanks,

David









On Thu, Jan 21, 2016 at 7:40 PM, Sean Silva  wrote:
> silvas added a comment.
>
> @bogner btw, did you say that at Apple you guys have a requirement of 
> supporting existing profdata? I.e. users can pass older profdata to a newer 
> compiler?
>
> Realistically, it would be nice if our PGO offering defaulted to the IR stuff 
> (since it seems like it is going to be the focus of optimization work and so 
> is likely to be our best-performing offering). But if we need to support 
> profdata across versions of clang, that puts us in a thorny situation because 
> suddenly `clang -c foo.c 
> -fprofile-instr-use=old-profdata-from-frontend-instrumentation.profdata` has 
> a default meaning equivalent to `clang -c foo.c -fir-level-instrumentation 
> -fprofile-instr-use=old-profdata-from-frontend-instrumentation.profdata` 
> (setting aside the flag name issue), which is a case we want to error on due 
> to mismatch between frontend and IR-level instrumentation.
>
>
> http://reviews.llvm.org/D15829
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16376: clang-tidy check: User-defined copy without assignment

2016-01-22 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/misc/UserDefinedCopyWithoutAssignmentCheck.cpp:52
@@ +51,3 @@
+  hasDescendant(
+  cxxMethodDecl(isMoveAssignmentOperator(), unless(isImplicit()))
+  .bind("move-assignment")),

I've moved the C++11 check to just before creating the fixit.


http://reviews.llvm.org/D16376



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread David Li via cfe-commits
davidxl added a comment.

For the longer term, one possible solution is to make FE based
instrumentation only used for coverage testing which can be turned on
with -fcoverage-mapping option (currently, -fcoverage-mapping can not
be used alone and must be used together with
-fprofile-instr-generate). To summarize:

A. Current behavior:


1. -fprofile-instr-generate turns on FE based instrumentation
2. -fprofile-instr-generate -fcoverage-mapping turns on FE based

instrumentation and coverage mapping data generation.

3. -fprofile-instr-use=<..> assumes profile data from FE instrumentation.



B. Proposed new behavior:
-

1. -fprofile-instr-generate turns on IR late instrumentation
2. -fcoverage-mapping turns on FE instrumentation and coverage-mapping
3. -fprofile-instr-generate -fcoverage-mapping result in compiler warning
4. -fprofile-instr-use=<> will automatically determine how to use the

profile data.

B.2) above can be done today for improved usability. B.1) needs a
transition period before  the IR based instrumentation becomes
stablized (and can be flipped to the default).  During the transition
period, the behavior of 1) does not change, but a cc1 option can be
used to turn on IR instrumentation (as proposed by Sean).

In the real longer term, I think IR based instrumentation can also be
used for coverage testing too (by disabling some pre-optimizations and
pre-inlining needed for PGO purpose) -- but this is a different topic
to be discussed.

thanks,

David


http://reviews.llvm.org/D15829



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


Re: [PATCH] D16094: Debugger tuning via gold plugin

2016-01-22 Thread Paul Robinson via cfe-commits
probinson added a comment.

Ping.


http://reviews.llvm.org/D16094



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


Re: [PATCH] D15881: [DWARF] Omitting the explicit import of an anonymous namespace is a debugger-tuning decision, not a target decision.

2016-01-22 Thread Paul Robinson via cfe-commits
probinson added a comment.

Ping.


http://reviews.llvm.org/D15881



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


r258550 - [OpenMP] Remove '#if 1' hanging in target_map_messages.cpp.

2016-01-22 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Fri Jan 22 14:52:54 2016
New Revision: 258550

URL: http://llvm.org/viewvc/llvm-project?rev=258550&view=rev
Log:
[OpenMP] Remove '#if 1' hanging in target_map_messages.cpp.   

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

Modified: cfe/trunk/test/OpenMP/target_map_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_messages.cpp?rev=258550&r1=258549&r2=258550&view=diff
==
--- cfe/trunk/test/OpenMP/target_map_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_map_messages.cpp Fri Jan 22 14:52:54 2016
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
-#if 1
 template 
 struct SA {
   static int ss;
@@ -175,7 +174,6 @@ void SAclient(int arg) {
   }
   }
 }
-#endif
 void foo() {
 }
 
@@ -238,7 +236,6 @@ T tmain(T argc) {
   T y;
   T to, tofrom, always;
   const T (&l)[5] = da;
-#if 1
 #pragma omp target map // expected-error {{expected '(' after 'map'}}
   {}
 #pragma omp target map( // expected-error {{expected ')'}} expected-note {{to 
match this '('}} expected-error {{expected expression}}
@@ -279,7 +276,6 @@ T tmain(T argc) {
   foo();
 #pragma omp target map(to, x)
   foo();
-#endif
 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 
'map' clause}}
 #pragma omp target data map(tofrom: argc > 0 ? x : y) // expected-error 2 
{{expected expression containing only member accesses and/or array sections 
based on named variables}}
 #pragma omp target data map(argc)
@@ -295,7 +291,6 @@ T tmain(T argc) {
 #pragma omp target data map(k) map(k) // expected-error 2 {{variable already 
marked as mapped in current construct}} expected-note 2 {{used here}}
 #pragma omp target map(k), map(k[:5]) // expected-error 2 {{pointer cannot be 
mapped along with a section derived from itself}} expected-note 2 {{used here}}
   foo();
-#if 1
 #pragma omp target data map(da)
 #pragma omp target map(da[:4])
   foo();
@@ -316,7 +311,6 @@ T tmain(T argc) {
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 
'map' clause}}
   foo();
-#endif
   return 0;
 }
 
@@ -332,7 +326,6 @@ int main(int argc, char **argv) {
   int y;
   int to, tofrom, always;
   const int (&l)[5] = da;
-#if 1
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} 
expected-error {{expected at least one map clause for '#pragma omp target 
data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note 
{{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -387,7 +380,6 @@ int main(int argc, char **argv) {
 #pragma omp target data map(always, tofrom: always, tofrom, x)
 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 
'map' clause}}
   foo();
-#endif
   return tmain(argc)+tmain(argc); // expected-note {{in 
instantiation of function template specialization 'tmain' requested 
here}} expected-note {{in instantiation of function template specialization 
'tmain' requested here}}
 }
 


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


[PATCH] D16484: [CUDA] Disallow variadic functions other than printf in device code.

2016-01-22 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, echristo, cfe-commits.

http://reviews.llvm.org/D16484

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/va-arg.cu
  test/SemaCUDA/vararg.cu

Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
 // RUN:   -verify -DEXPECT_ERR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
 
 #include 
 #include "Inputs/cuda.h"
@@ -26,3 +26,12 @@
   va_arg(list, int);  // OK: only seen when compiling for host
 #endif
 }
+
+__device__ void vararg(const char* x, ...) {}
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+__device__ int printf(const char* fmt, ...);  // OK, special case.
+
+// Definition of printf not allowed.
+__device__ int printf(const char* fmt, ...) { return 0; }
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8276,18 +8276,25 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA)
-if (IdentifierInfo *II = NewFD->getIdentifier())
-  if (!NewFD->isInvalidDecl() &&
-  NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-if (II->isStr("cudaConfigureCall")) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code.
+if (NewFD->isVariadic() && (NewFD->hasAttr() ||
+NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
 
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-  }
-  
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6423,6 +6423,8 @@
 def warn_kern_is_inline : Warning<
   "ignored 'inline' attribute on kernel function %0">,
   InGroup;
+def err_variadic_device_fn : Error<
+  "CUDA device code does not support variadic functions">;
 def err_va_arg_in_device : Error<
   "CUDA device code does not support va_arg">;
 


Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
 // RUN:   -verify -DEXPECT_ERR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
 
 #include 
 #include "Inputs/cuda.h"
@@ -26,3 +26,12 @@
   va_arg(list, int);  // OK: only seen when compiling for host
 #endif
 }
+
+__device__ void vararg(const char* x, ...) {}
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+__device__ int printf(const char* fmt, ...);  // OK, special case.
+
+// Definition of printf not allowed.
+__device__ int printf(const char* fmt, ...) { return 0; }
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8276,18 +8276,25 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA)
-if (IdentifierInfo *II = NewFD->getIdentifier())
-  if (!NewFD->isInvalidDecl() &&
-  NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-if (II->isStr("cudaConfigureCall")) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), 

Re: [PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2016-01-22 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

As a general comment, I am continually fascinated by the **huge** variety of 
opinion as to matters of readability within the C++ community.  I don't know 
why we have so many differing opinions compared to the communities built around 
other programming languages, but I enjoy hearing all of them.  I enjoy having 
my opinions on readability challenged because it forces me to think **why** I 
find one form preferable over another and that is a good thing.

In http://reviews.llvm.org/D16286#330390, @aaron.ballman wrote:

> In http://reviews.llvm.org/D16286#330360, @LegalizeAdulthood wrote:
>
> > One could argue that this check should be part of the google module.  The 
> > google style guide specifically forbids writing return with extra 
> > parenthesis.
>
>
> If it is meant to work for a particular style guide, then it should 
> absolutely go under that style guide. But for something more generally under 
> the readability-* umbrella, I think it doesn't hurt to discuss where to draw 
> the line, or what options may be valuable.


I think that is the correct conclusion here; according to the bug report this 
check is motivated by the Google style guide which explicitly prohibits the 
parens for return expressions.


http://reviews.llvm.org/D16286



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Sean Silva via cfe-commits
silvas added inline comments.


Comment at: lib/Driver/Tools.cpp:3279
@@ -3278,1 +3278,3 @@
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }

xur wrote:
> mcrosier wrote:
> > I don't think AddAllArgs is what you really want.  What if the user 
> > specifies the option twice?  Do we really want to pass the flag from the 
> > driver to the front-end twice?  Also, should we warn if the option is 
> > passed twice?
> > 
> > I also think some of the logic in CompilerInvocation should land here...  
> > see comments below.
> Thanks for pointing thi out. What about add a guard, like:
> -  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
> +  if (Args.hasArg(options::OPT_fprofile_ir_instr))
> +Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
> 
> But looking at it again, I think i need to remove this stmt in the most 
> recently patch as OPT_profile_ir_instr is now a CC1 option. it will not be 
> seen here, right?
> 
> 
> But looking at it again, I think i need to remove this stmt in the most 
> recently patch as OPT_profile_ir_instr is now a CC1 option. it will not be 
> seen here, right?

Yes. The patch should make no changes to lib/Driver and should require no tests 
in test/Driver


http://reviews.llvm.org/D15829



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


Re: [PATCH] D15599: [CodeGen] Fix a crash that occurs when attribute "naked" is attached to a c++ member function

2016-01-22 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


Comment at: lib/CodeGen/CodeGenFunction.cpp:1962
@@ +1961,3 @@
+for (auto *U : I->users())
+  InstrsToRemove.push_back(cast(U));
+

manmanren wrote:
> Do we need to check if the user has been erased? I am not sure if the same 
> instruction can be pushed multiple times into InstrsToRemove.
I think you are right: it's incorrect to assume an instruction cannot be pushed 
twice. I'll change the type of InstrsToRemove to a set to prevent that from 
happenning.


Comment at: lib/CodeGen/CodeGenFunction.cpp:1979
@@ +1978,3 @@
+  if (auto *T = EntryBB->getTerminator())
+T->eraseFromParent();
+

manmanren wrote:
> Is it possible that T has been erased in the above?
I'm not sure I understand. getTerminator will return null if there is no 
terminator or the basic block is empty, so I think this code is safe?


http://reviews.llvm.org/D15599



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


Re: [PATCH] D16484: [CUDA] Disallow variadic functions other than printf in device code.

2016-01-22 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: lib/Sema/SemaDecl.cpp:8291-8293
@@ +8290,5 @@
+// in device-side CUDA code.
+if (NewFD->isVariadic() && (NewFD->hasAttr() ||
+NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);

It would be nice to emit this diagnostics on one side of compilation only.

Nit - unneeded {}


http://reviews.llvm.org/D16484



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


Re: [PATCH] D15624: Add iOS/watchOS/tvOS support for ASan (clang part)

2016-01-22 Thread Alexey Samsonov via cfe-commits
samsonov accepted this revision.
samsonov added a reviewer: samsonov.
samsonov added a comment.

LGTM



Comment at: lib/Driver/ToolChains.cpp:339
@@ +338,3 @@
+  }
+}
+

You might need `llvm_unreachable` at the very end to suppress GCC warnings 
(http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations)


http://reviews.llvm.org/D15624



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


Re: [PATCH] D15363: [UBSan] Implement runtime suppressions (PR25066).

2016-01-22 Thread Alexey Samsonov via cfe-commits
Thank you for fixing this!

On Fri, Jan 22, 2016 at 12:30 PM, Nico Weber  wrote:

> I implemented Reid's suggestion in 258545. I tested that the test runs and
> passes when the DIA SDK is around (this is usually the case), and doesn't
> run when it isn't.
>
> On Thu, Jan 21, 2016 at 2:09 PM, Alexey Samsonov 
> wrote:
>
>> On Thu, Jan 21, 2016 at 10:58 AM, Reid Kleckner  wrote:
>>
>>> On Thu, Jan 21, 2016 at 10:47 AM, Nico Weber 
>>> wrote:
>>>
 Oh, ok, let's not depend on lld then. So, we need to either determine
> if DIA SDK is available at compiler-rt configure time, or teach
> llvm-symbolizer.exe to tell us that (as we support standalone compiler-rt
> build)...
>

 Maybe the lit config file could compile a small program with clang-cl
 and then run it through llvm-symbolizer and see if a symbol is returned?

>>>
>>> I'd rather duplicate this check in compiler-rt than add auto-conf style
>>> tests to check-asan startup:
>>>   # See if the DIA SDK is available and usable.
>>>   set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
>>>   if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
>>> set(HAVE_DIA_SDK 1)
>>>   else()
>>> set(HAVE_DIA_SDK 0)
>>>   endif()
>>>
>>
>> Yes. It's not 100% correct, but probably fine to assume that if we failed
>> to find DIA SDK at configure time, so did llvm-symbolizer when it was built.
>>
>>
>>>
>>> It is also possible to change LLVMSymbolizer::SymbolizePC to return
>>> false when llvm-symbolizer returns no useful information.
>>>
>>
>> Do we want LLVMSymbolizer::SymbolizePC to succeed if we fetched file/line
>> info, but not function name?
>> Also, there may well be another issue that will be hard to debug. It
>> makes sense to store information about what features of llvm-symbolizer we
>> expect to work explicitly.
>>
>>
>>> This will cause the sanitizers to try calling into dbghelp, which will
>>> probably work. It doesn't return PDB column info or work with dwarf, which
>>> is why we try llvm-symbolizer first. I think I made this change at one
>>> point, but I was asked to revert it or there were minor issues that didn't
>>> seem worth fixing.
>>>
>>
>>
>> --
>> Alexey Samsonov
>> vonos...@gmail.com
>>
>
>


-- 
Alexey Samsonov
vonos...@gmail.com
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r258555 - Module debugging: Create a parent DIModule with the PCH name for types

2016-01-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan 22 15:14:41 2016
New Revision: 258555

URL: http://llvm.org/viewvc/llvm-project?rev=258555&view=rev
Log:
Module debugging: Create a parent DIModule with the PCH name for types
emitted into a precompiled header to mirror the debug info emitted for
object files importing the PCH.

rdar://problem/24290667

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/ModuleDebugInfo.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=258555&r1=258554&r2=258555&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Jan 22 15:14:41 2016
@@ -2224,8 +2224,12 @@ llvm::DIModule *CGDebugInfo::getParentMo
 // option.
 FullSourceLoc Loc(D->getLocation(), CGM.getContext().getSourceManager());
 if (Module *M = ClangModuleMap->inferModuleFromLocation(Loc)) {
+  // This is a (sub-)module.
   auto Info = ExternalASTSource::ASTSourceDescriptor(*M);
   return getOrCreateModuleRef(Info, /*SkeletonCU=*/false);
+} else {
+  // This the precompiled header being built.
+  return getOrCreateModuleRef(PCHDescriptor, /*SkeletonCU=*/false);
 }
   }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=258555&r1=258554&r2=258555&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Jan 22 15:14:41 2016
@@ -16,6 +16,7 @@
 
 #include "CGBuilder.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
@@ -57,6 +58,7 @@ class CGDebugInfo {
   llvm::DIBuilder DBuilder;
   llvm::DICompileUnit *TheCU = nullptr;
   ModuleMap *ClangModuleMap = nullptr;
+  ExternalASTSource::ASTSourceDescriptor PCHDescriptor;
   SourceLocation CurLoc;
   llvm::DIType *VTablePtrType = nullptr;
   llvm::DIType *ClassTy = nullptr;
@@ -275,6 +277,8 @@ public:
 
   void finalize();
 
+  /// Module debugging: Support for building PCMs.
+  /// @{
   /// Set the main CU's DwoId field to \p Signature.
   void setDwoId(uint64_t Signature);
 
@@ -283,6 +287,14 @@ public:
   /// the module of origin of each Decl.
   void setModuleMap(ModuleMap &MMap) { ClangModuleMap = &MMap; }
 
+  /// When generating debug information for a clang module or
+  /// precompiled header, this module map will be used to determine
+  /// the module of origin of each Decl.
+  void setPCHDescriptor(ExternalASTSource::ASTSourceDescriptor PCH) {
+PCHDescriptor = PCH;
+  }
+  /// @}
+
   /// Update the current source location. If \arg loc is invalid it is
   /// ignored.
   void setLocation(SourceLocation Loc);

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=258555&r1=258554&r2=258555&view=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Jan 22 
15:14:41 2016
@@ -42,6 +42,7 @@ namespace {
 class PCHContainerGenerator : public ASTConsumer {
   DiagnosticsEngine &Diags;
   const std::string MainFileName;
+  const std::string OutputFileName;
   ASTContext *Ctx;
   ModuleMap &MMap;
   const HeaderSearchOptions &HeaderSearchOpts;
@@ -137,7 +138,8 @@ public:
 const std::string &OutputFileName,
 raw_pwrite_stream *OS,
 std::shared_ptr Buffer)
-  : Diags(CI.getDiagnostics()), Ctx(nullptr),
+  : Diags(CI.getDiagnostics()), MainFileName(MainFileName),
+OutputFileName(OutputFileName), Ctx(nullptr),
 MMap(CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()),
 HeaderSearchOpts(CI.getHeaderSearchOpts()),
 PreprocessorOpts(CI.getPreprocessorOpts()),
@@ -163,6 +165,8 @@ public:
 Builder.reset(new CodeGen::CodeGenModule(
 *Ctx, HeaderSearchOpts, PreprocessorOpts, CodeGenOpts, *M, Diags));
 Builder->getModuleDebugInfo()->setModuleMap(MMap);
+Builder->getModuleDebugInfo()->setPCHDescriptor(
+{MainFileName, "", OutputFileName, ~1ULL});
   }
 
   bool HandleTopLevelDecl(DeclGroupRef D) override {

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.m?rev=258555&r1=258554&r2=258555&view=diff
==

Re: [PATCH] D16469: Pass --wrap=pthread_create to linker for -fsplit-stack

2016-01-22 Thread H.J Lu via cfe-commits
hjl.tools updated this revision to Diff 45735.
hjl.tools added a comment.

Add a testcase.


http://reviews.llvm.org/D16469

Files:
  lib/Driver/Tools.cpp
  test/Driver/split-stack-ld.c

Index: test/Driver/split-stack-ld.c
===
--- /dev/null
+++ test/Driver/split-stack-ld.c
@@ -0,0 +1,17 @@
+// Test split stack ld flags.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386 %s
+//
+// CHECK-LINUX-I386: "--wrap=pthread_create"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
+//
+// CHECK-LINUX-X86-64: "--wrap=pthread_create"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9001,6 +9001,9 @@
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");
 
+  if (Args.hasArg(options::OPT_fsplit_stack))
+CmdArgs.push_back("--wrap=pthread_create");
+
   CmdArgs.push_back("-lc");
 
   if (Args.hasArg(options::OPT_static))


Index: test/Driver/split-stack-ld.c
===
--- /dev/null
+++ test/Driver/split-stack-ld.c
@@ -0,0 +1,17 @@
+// Test split stack ld flags.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386 %s
+//
+// CHECK-LINUX-I386: "--wrap=pthread_create"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fsplit-stack \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
+//
+// CHECK-LINUX-X86-64: "--wrap=pthread_create"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9001,6 +9001,9 @@
   if (WantPthread && !isAndroid)
 CmdArgs.push_back("-lpthread");
 
+  if (Args.hasArg(options::OPT_fsplit_stack))
+CmdArgs.push_back("--wrap=pthread_create");
+
   CmdArgs.push_back("-lc");
 
   if (Args.hasArg(options::OPT_static))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16444: AMDGPU: Rename builtins to use amdgcn prefix

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

r258560


http://reviews.llvm.org/D16444



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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Chad Rosier via cfe-commits
mcrosier added inline comments.


Comment at: lib/Driver/Tools.cpp:3279
@@ -3278,1 +3278,3 @@
+
+  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
 }

silvas wrote:
> xur wrote:
> > mcrosier wrote:
> > > I don't think AddAllArgs is what you really want.  What if the user 
> > > specifies the option twice?  Do we really want to pass the flag from the 
> > > driver to the front-end twice?  Also, should we warn if the option is 
> > > passed twice?
> > > 
> > > I also think some of the logic in CompilerInvocation should land here...  
> > > see comments below.
> > Thanks for pointing thi out. What about add a guard, like:
> > -  Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
> > +  if (Args.hasArg(options::OPT_fprofile_ir_instr))
> > +Args.AddAllArgs(CmdArgs, options::OPT_fprofile_ir_instr);
> > 
> > But looking at it again, I think i need to remove this stmt in the most 
> > recently patch as OPT_profile_ir_instr is now a CC1 option. it will not be 
> > seen here, right?
> > 
> > 
> > But looking at it again, I think i need to remove this stmt in the most 
> > recently patch as OPT_profile_ir_instr is now a CC1 option. it will not be 
> > seen here, right?
> 
> Yes. The patch should make no changes to lib/Driver and should require no 
> tests in test/Driver
Ah, okay.  I still think this type of complexity should land in the driver, but 
if this is a special case then just ignore my comments.


http://reviews.llvm.org/D15829



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


r258560 - AMDGPU: Rename builtins to use amdgcn prefix

2016-01-22 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jan 22 15:30:53 2016
New Revision: 258560

URL: http://llvm.org/viewvc/llvm-project?rev=258560&view=rev
Log:
AMDGPU: Rename builtins to use amdgcn prefix

Keep the ones still used by libclc around for now.

Emit the new amdgcn intrinsic name if not targeting r600,
in which case the old AMDGPU name is still used.

Added:
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
  - copied, changed from r258543, 
cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=258560&r1=258559&r2=258560&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jan 22 15:30:53 2016
@@ -7,30 +7,36 @@
 //
 
//===--===//
 //
-// This file defines the R600-specific builtin function database. Users of this
-// file must define the BUILTIN macro to make use of this information.
+// This file defines the AMDGPU-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
 //
 
//===--===//
 
 // The format of this database matches clang/Basic/Builtins.def.
 
-BUILTIN(__builtin_amdgpu_div_scale, "dddbb*", "n")
-BUILTIN(__builtin_amdgpu_div_scalef, "fffbb*", "n")
-BUILTIN(__builtin_amdgpu_div_fmas, "b", "nc")
-BUILTIN(__builtin_amdgpu_div_fmasf, "b", "nc")
-BUILTIN(__builtin_amdgpu_div_fixup, "", "nc")
-BUILTIN(__builtin_amdgpu_div_fixupf, "", "nc")
-BUILTIN(__builtin_amdgpu_trig_preop, "ddi", "nc")
-BUILTIN(__builtin_amdgpu_trig_preopf, "ffi", "nc")
-BUILTIN(__builtin_amdgpu_rcp, "dd", "nc")
-BUILTIN(__builtin_amdgpu_rcpf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
+BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
+BUILTIN(__builtin_amdgcn_div_fmas, "b", "nc")
+BUILTIN(__builtin_amdgcn_div_fmasf, "b", "nc")
+BUILTIN(__builtin_amdgcn_div_fixup, "", "nc")
+BUILTIN(__builtin_amdgcn_div_fixupf, "", "nc")
+BUILTIN(__builtin_amdgcn_trig_preop, "ddi", "nc")
+BUILTIN(__builtin_amdgcn_trig_preopf, "ffi", "nc")
+BUILTIN(__builtin_amdgcn_rcp, "dd", "nc")
+BUILTIN(__builtin_amdgcn_rcpf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_rsq, "dd", "nc")
+BUILTIN(__builtin_amdgcn_rsqf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_rsq_clamped, "dd", "nc")
+BUILTIN(__builtin_amdgcn_rsq_clampedf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_ldexp, "ddi", "nc")
+BUILTIN(__builtin_amdgcn_ldexpf, "ffi", "nc")
+BUILTIN(__builtin_amdgcn_class, "bdi", "nc")
+BUILTIN(__builtin_amdgcn_classf, "bfi", "nc")
+
+// Legacy names with amdgpu prefix
 BUILTIN(__builtin_amdgpu_rsq, "dd", "nc")
 BUILTIN(__builtin_amdgpu_rsqf, "ff", "nc")
-BUILTIN(__builtin_amdgpu_rsq_clamped, "dd", "nc")
-BUILTIN(__builtin_amdgpu_rsq_clampedf, "ff", "nc")
 BUILTIN(__builtin_amdgpu_ldexp, "ddi", "nc")
 BUILTIN(__builtin_amdgpu_ldexpf, "ffi", "nc")
-BUILTIN(__builtin_amdgpu_class, "bdi", "nc")
-BUILTIN(__builtin_amdgpu_classf, "bfi", "nc")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=258560&r1=258559&r2=258560&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jan 22 15:30:53 2016
@@ -6887,8 +6887,8 @@ static Value *emitFPIntBuiltin(CodeGenFu
 Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
   const CallExpr *E) {
   switch (BuiltinID) {
-  case AMDGPU::BI__builtin_amdgpu_div_scale:
-  case AMDGPU::BI__builtin_amdgpu_div_scalef: {
+  case AMDGPU::BI__builtin_amdgcn_div_scale:
+  case AMDGPU::BI__builtin_amdgcn_div_scalef: {
 // Translate from the intrinsics's struct return to the builtin's out
 // argument.
 
@@ -6898,7 +6898,7 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 llvm::Value *Y = EmitScalarExpr(E->getArg(1));
 llvm::Value *Z = EmitScalarExpr(E->getArg(2));
 
-llvm::Value *Callee = CGM.getIntrinsic(Intrinsic::AMDGPU_div_scale,
+llvm::Value *Callee = CGM.getIntrinsic(Intrinsic::amdgcn_div_scale,
X->getType());
 
 llvm::Value *Tmp = Builder.CreateCall(Callee, {X, Y, Z});
@@ -6913,40 +6913,54 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 Builder.CreateStore(FlagExt, FlagOutPtr);
 return Result;
   }
-  case AMDGPU::BI__builtin_amdgpu_div_fmas:
-  case AMDGPU::BI__builtin_amdgpu_div_fmasf: {
+  case AMDGPU::BI__builtin_

Re: [PATCH] D16484: [CUDA] Disallow variadic functions other than printf in device code.

2016-01-22 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:8291-8293
@@ +8290,5 @@
+// in device-side CUDA code.
+if (NewFD->isVariadic() && (NewFD->hasAttr() ||
+NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);

tra wrote:
> It would be nice to emit this diagnostics on one side of compilation only.
> 
> Nit - unneeded {}
Resolved irl.


http://reviews.llvm.org/D16484



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


Re: [PATCH] D16484: [CUDA] Disallow variadic functions other than printf in device code.

2016-01-22 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 45736.
jlebar marked an inline comment as done.
jlebar added a comment.

Add check for extern "C" printf -- we don't want to take just any printf!


http://reviews.llvm.org/D16484

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCUDA/va-arg.cu
  test/SemaCUDA/vararg.cu

Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
 // RUN:   -verify -DEXPECT_ERR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
 
 #include 
 #include "Inputs/cuda.h"
@@ -26,3 +26,17 @@
   va_arg(list, int);  // OK: only seen when compiling for host
 #endif
 }
+
+__device__ void vararg(const char* x, ...) {}
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
+
+// Definition of printf not allowed.
+extern "C" __device__ int printf(const char* fmt, ...) { return 0; }
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+namespace ns {
+__device__ int printf(const char* fmt, ...);
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8276,18 +8276,26 @@
 
   MarkUnusedFileScopedDecl(NewFD);
 
-  if (getLangOpts().CUDA)
-if (IdentifierInfo *II = NewFD->getIdentifier())
-  if (!NewFD->isInvalidDecl() &&
-  NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-if (II->isStr("cudaConfigureCall")) {
-  if (!R->getAs()->getReturnType()->isScalarType())
-Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+  if (getLangOpts().CUDA) {
+IdentifierInfo *II = NewFD->getIdentifier();
+if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() &&
+NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
+  if (!R->getAs()->getReturnType()->isScalarType())
+Diag(NewFD->getLocation(), diag::err_config_scalar_return);
+
+  Context.setcudaConfigureCallDecl(NewFD);
+}
+
+// Variadic functions, other than a *declaration* of printf, are not 
allowed
+// in device-side CUDA code.
+if (NewFD->isVariadic() && (NewFD->hasAttr() ||
+NewFD->hasAttr()) &&
+!(II && II->isStr("printf") && NewFD->isExternC() &&
+  !D.isFunctionDefinition())) {
+  Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
+}
+  }
 
-  Context.setcudaConfigureCallDecl(NewFD);
-}
-  }
-  
   // Here we have an function template explicit specialization at class scope.
   // The actually specialization will be postponed to template instatiation
   // time via the ClassScopeFunctionSpecializationDecl node.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6423,6 +6423,8 @@
 def warn_kern_is_inline : Warning<
   "ignored 'inline' attribute on kernel function %0">,
   InGroup;
+def err_variadic_device_fn : Error<
+  "CUDA device code does not support variadic functions">;
 def err_va_arg_in_device : Error<
   "CUDA device code does not support va_arg">;
 


Index: test/SemaCUDA/vararg.cu
===
--- test/SemaCUDA/vararg.cu
+++ test/SemaCUDA/vararg.cu
@@ -2,7 +2,7 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
 // RUN:   -verify -DEXPECT_ERR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
 
 #include 
 #include "Inputs/cuda.h"
@@ -26,3 +26,17 @@
   va_arg(list, int);  // OK: only seen when compiling for host
 #endif
 }
+
+__device__ void vararg(const char* x, ...) {}
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+extern "C" __device__ int printf(const char* fmt, ...);  // OK, special case.
+
+// Definition of printf not allowed.
+extern "C" __device__ int printf(const char* fmt, ...) { return 0; }
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+
+namespace ns {
+__device__ int printf(const char* fmt, ...);
+// expected-error@-1 {{CUDA device code does not support variadic functions}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.c

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Sean Silva via cfe-commits
silvas added a comment.

In http://reviews.llvm.org/D15829#333902, @davidxl wrote:

> For the longer term, one possible solution is to make FE based
>  instrumentation only used for coverage testing which can be turned on
>  with -fcoverage-mapping option (currently, -fcoverage-mapping can not
>  be used alone and must be used together with
>  -fprofile-instr-generate). To summarize:
>
> A. Current behavior:
>
>  ---
>
> 1. -fprofile-instr-generate turns on FE based instrumentation
> 2. -fprofile-instr-generate -fcoverage-mapping turns on FE based 
> instrumentation and coverage mapping data generation.
> 3. -fprofile-instr-use=<..> assumes profile data from FE instrumentation.
>
> B. Proposed new behavior:
>
>  
>
> 1. -fprofile-instr-generate turns on IR late instrumentation
> 2. -fcoverage-mapping turns on FE instrumentation and coverage-mapping
> 3. -fprofile-instr-generate -fcoverage-mapping result in compiler warning
> 4. -fprofile-instr-use=<> will automatically determine how to use the profile 
> data.


Very good observation that we can determine FE or IR automatically based on the 
input profdata. That simplifies things.

> B.2) above can be done today for improved usability.


I don't see how this improves usability. In fact, it is confusing because it 
hijacks an existing option.

Also B.3 causes existing user builds to emit a warning, which is annoying.

I would propose the following modification of B:

C.:

1. -fprofile-instr-generate defaults to IR instrumentation (i.e. behaves 
exactly as before, except that it uses IR instrumentation)
2. -fprofile-instr-generate -fcoverage-mapping turns on frontend 
instrumentation and coverage. (i.e. behaves exactly as before)
3. -fprofile-instr-use=<> automatically determines which method to use

All existing user workflows continue to work, except for workflows that attempt 
to `llvm-profdata merge` some old frontend profile data (e.g. they have 
checked-in to version control and represents some special workload) with the 
profile data from new binaries.

Concretely, imagine the following workflow:

  clang -fprofile-instr-generate foo.c -o foo
  ./foo
  llvm-profdata merge default.profraw -o new.profdata
  llvm-profdata merge new.profdata 
/versioncontrol/some-important-but-expensive-to-reproduce-workload.profdata -o 
foo.profdata
  clang -fprofile-instr-use=foo.profdata foo.c -o foo_pgo

I think this is a reasonable breakage. We would need to add a note in the 
release notes. Unfortunately this is not expected breakage if we claim to have 
forward compatibility for profdata (which IIRC Apple requires; @bogner?). But I 
think this case will be rare and exceptional enough that we can tolerate it:

- a simple immediate workaround is to specify `-fcoverage-mapping` (which also 
adds some extra stuff, but works around the issue)
- Presumably 
/versioncontrol/some-important-but-expensive-to-reproduce-workload.profdata is 
regenerated with some frequency which is more frequent than upgrading the 
compiler, and so it is likely reasonable to regenerate it alongside a compiler 
upgrade, using the workaround until then.



> B.1) needs a

>  transition period before  the IR based instrumentation becomes

>  stablized (and can be flipped to the default).  During the transition

>  period, the behavior of 1) does not change, but a cc1 option can be

>  used to turn on IR instrumentation (as proposed by Sean).


Just to clarify, users are not allowed to use cc1 options. The cc1 option is 
purely for us as compiler developers to do integration and testing, put off 
some discussions for later, etc.


http://reviews.llvm.org/D15829



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


[clang-tools-extra] r258562 - [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-22 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Jan 22 15:45:51 2016
New Revision: 258562

URL: http://llvm.org/viewvc/llvm-project?rev=258562&view=rev
Log:
[clang-tidy] Handle decayed types and other improvements in VirtualNearMiss 
check.

Handle decayed types, ignore qualifiers and accessibility when considering a
method as a possible overload.

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp?rev=258562&r1=258561&r2=258562&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp Fri Jan 22 
15:45:51 2016
@@ -45,31 +45,20 @@ static bool checkOverridingFunctionRetur
 return true;
 
   /// Check if the return types are covariant.
-  /// BTy is the class type in return type of BaseMD. For example,
-  ///B* Base::md()
-  /// While BRD is the declaration of B.
-  QualType BTy, DTy;
-  const CXXRecordDecl *BRD, *DRD;
 
   // Both types must be pointers or references to classes.
-  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
-if (const auto *BasePT = BaseReturnTy->getAs()) {
-  DTy = DerivedPT->getPointeeType();
-  BTy = BasePT->getPointeeType();
-}
-  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
-if (const auto *BaseRT = BaseReturnTy->getAs()) {
-  DTy = DerivedRT->getPointeeType();
-  BTy = BaseRT->getPointeeType();
-}
-  }
-
-  // The return types aren't either both pointers or references to a class 
type.
-  if (DTy.isNull())
+  if (!(BaseReturnTy->isPointerType() && DerivedReturnTy->isPointerType()) &&
+  !(BaseReturnTy->isReferenceType() && DerivedReturnTy->isReferenceType()))
 return false;
 
-  DRD = DTy->getAsCXXRecordDecl();
-  BRD = BTy->getAsCXXRecordDecl();
+  /// BTy is the class type in return type of BaseMD. For example,
+  ///B* Base::md()
+  /// While BRD is the declaration of B.
+  QualType DTy = DerivedReturnTy->getPointeeType();
+  QualType BTy = BaseReturnTy->getPointeeType();
+
+  const CXXRecordDecl *DRD = DTy->getAsCXXRecordDecl();
+  const CXXRecordDecl *BRD = BTy->getAsCXXRecordDecl();
   if (DRD == nullptr || BRD == nullptr)
 return false;
 
@@ -116,6 +105,13 @@ static bool checkOverridingFunctionRetur
   return true;
 }
 
+/// \returns decayed type for arrays and functions.
+static QualType getDecayedType(QualType Type) {
+  if (const auto *Decayed = Type->getAs())
+return Decayed->getDecayedType();
+  return Type;
+}
+
 /// \returns true if the param types are the same.
 static bool checkParamTypes(const CXXMethodDecl *BaseMD,
 const CXXMethodDecl *DerivedMD) {
@@ -125,8 +121,8 @@ static bool checkParamTypes(const CXXMet
 return false;
 
   for (unsigned I = 0; I < NumParamA; I++) {
-if (BaseMD->getParamDecl(I)->getType() !=
-DerivedMD->getParamDecl(I)->getType())
+if (getDecayedType(BaseMD->getParamDecl(I)->getType()) !=
+getDecayedType(DerivedMD->getParamDecl(I)->getType()))
   return false;
   }
   return true;
@@ -137,15 +133,9 @@ static bool checkParamTypes(const CXXMet
 static bool checkOverrideWithoutName(const ASTContext *Context,
  const CXXMethodDecl *BaseMD,
  const CXXMethodDecl *DerivedMD) {
-  if (BaseMD->getTypeQualifiers() != DerivedMD->getTypeQualifiers())
-return false;
-
   if (BaseMD->isStatic() != DerivedMD->isStatic())
 return false;
 
-  if (BaseMD->getAccess() != DerivedMD->getAccess())
-return false;
-
   if (BaseMD->getType() == DerivedMD->getType())
 return true;
 
@@ -187,7 +177,8 @@ bool VirtualNearMissCheck::isPossibleToB
 return Iter->second;
 
   bool IsPossible = !BaseMD->isImplicit() && !isa(BaseMD) 
&&
-BaseMD->isVirtual();
+!isa(BaseMD) && BaseMD->isVirtual() &&
+!BaseMD->isOverloadedOperator();
   PossibleMap[Id] = IsPossible;
   return IsPossible;
 }
@@ -218,19 +209,23 @@ void VirtualNearMissCheck::registerMatch
   if (!getLangOpts().CPlusPlus)
 return;
 
-  Finder->addMatcher(cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(),
-cxxConstructorDecl(
- .bind("method"),
- this);
+  Finder->addMatcher(
+  cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(),
+ cxxConstructorDecl(), cxxDestructorDecl(
+  .bind("method"),
+  this);
 }
 
 void Virt

Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258562: [clang-tidy] Handle decayed types and other 
improvements in VirtualNearMiss… (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D16179?vs=45482&id=45739#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16179

Files:
  clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
  clang-tools-extra/trunk/test/clang-tidy/misc-virtual-near-miss.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
@@ -34,7 +34,7 @@
 
 private:
   /// Check if the given method is possible to be overridden by some other
-  /// method.
+  /// method. Operators and destructors are excluded.
   ///
   /// Results are memoized in PossibleMap.
   bool isPossibleToBeOverridden(const CXXMethodDecl *BaseMD);
Index: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.cpp
@@ -45,31 +45,20 @@
 return true;
 
   /// Check if the return types are covariant.
-  /// BTy is the class type in return type of BaseMD. For example,
-  ///B* Base::md()
-  /// While BRD is the declaration of B.
-  QualType BTy, DTy;
-  const CXXRecordDecl *BRD, *DRD;
 
   // Both types must be pointers or references to classes.
-  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
-if (const auto *BasePT = BaseReturnTy->getAs()) {
-  DTy = DerivedPT->getPointeeType();
-  BTy = BasePT->getPointeeType();
-}
-  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
-if (const auto *BaseRT = BaseReturnTy->getAs()) {
-  DTy = DerivedRT->getPointeeType();
-  BTy = BaseRT->getPointeeType();
-}
-  }
-
-  // The return types aren't either both pointers or references to a class type.
-  if (DTy.isNull())
+  if (!(BaseReturnTy->isPointerType() && DerivedReturnTy->isPointerType()) &&
+  !(BaseReturnTy->isReferenceType() && DerivedReturnTy->isReferenceType()))
 return false;
 
-  DRD = DTy->getAsCXXRecordDecl();
-  BRD = BTy->getAsCXXRecordDecl();
+  /// BTy is the class type in return type of BaseMD. For example,
+  ///B* Base::md()
+  /// While BRD is the declaration of B.
+  QualType DTy = DerivedReturnTy->getPointeeType();
+  QualType BTy = BaseReturnTy->getPointeeType();
+
+  const CXXRecordDecl *DRD = DTy->getAsCXXRecordDecl();
+  const CXXRecordDecl *BRD = BTy->getAsCXXRecordDecl();
   if (DRD == nullptr || BRD == nullptr)
 return false;
 
@@ -116,6 +105,13 @@
   return true;
 }
 
+/// \returns decayed type for arrays and functions.
+static QualType getDecayedType(QualType Type) {
+  if (const auto *Decayed = Type->getAs())
+return Decayed->getDecayedType();
+  return Type;
+}
+
 /// \returns true if the param types are the same.
 static bool checkParamTypes(const CXXMethodDecl *BaseMD,
 const CXXMethodDecl *DerivedMD) {
@@ -125,8 +121,8 @@
 return false;
 
   for (unsigned I = 0; I < NumParamA; I++) {
-if (BaseMD->getParamDecl(I)->getType() !=
-DerivedMD->getParamDecl(I)->getType())
+if (getDecayedType(BaseMD->getParamDecl(I)->getType()) !=
+getDecayedType(DerivedMD->getParamDecl(I)->getType()))
   return false;
   }
   return true;
@@ -137,15 +133,9 @@
 static bool checkOverrideWithoutName(const ASTContext *Context,
  const CXXMethodDecl *BaseMD,
  const CXXMethodDecl *DerivedMD) {
-  if (BaseMD->getTypeQualifiers() != DerivedMD->getTypeQualifiers())
-return false;
-
   if (BaseMD->isStatic() != DerivedMD->isStatic())
 return false;
 
-  if (BaseMD->getAccess() != DerivedMD->getAccess())
-return false;
-
   if (BaseMD->getType() == DerivedMD->getType())
 return true;
 
@@ -187,7 +177,8 @@
 return Iter->second;
 
   bool IsPossible = !BaseMD->isImplicit() && !isa(BaseMD) &&
-BaseMD->isVirtual();
+!isa(BaseMD) && BaseMD->isVirtual() &&
+!BaseMD->isOverloadedOperator();
   PossibleMap[Id] = IsPossible;
   return IsPossible;
 }
@@ -218,19 +209,23 @@
   if (!getLangOpts().CPlusPlus)
 return;
 
-  Finder->addMatcher(cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(),
-cxxConstructorDecl(
- .bind("method"),
- this);
+  Finder->addMatcher(
+  cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(),
+ cxxConstructorDecl(), cxxDestructorDecl())

r258564 - AMDGPU: Add barrier builtin

2016-01-22 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Fri Jan 22 15:56:30 2016
New Revision: 258564

URL: http://llvm.org/viewvc/llvm-project?rev=258564&view=rev
Log:
AMDGPU: Add barrier builtin

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=258564&r1=258563&r2=258564&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri Jan 22 15:56:30 2016
@@ -14,6 +14,7 @@
 
 // The format of this database matches clang/Basic/Builtins.def.
 
+BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
 BUILTIN(__builtin_amdgcn_div_fmas, "b", "nc")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=258564&r1=258563&r2=258564&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri Jan 22 15:56:30 2016
@@ -141,6 +141,12 @@ void test_class_f64(global double* out,
   *out = __builtin_amdgcn_class(a, b);
 }
 
+// CHECK-LABEL: @test_s_barrier
+// CHECK: call void @llvm.amdgcn.s.barrier(
+void test_s_barrier()
+{
+  __builtin_amdgcn_s_barrier();
+}
 
 // Legacy intrinsics with AMDGPU prefix
 


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


Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-01-22 Thread Sean Silva via cfe-commits
silvas added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:440
@@ +439,3 @@
+  if (CodeGenOpts.ProfileIRInstr) {
+// Should not have ProfileInstrGenerate set -- it is for clang
+// instrumentation only.

Then change the existing references in clang. Please try to cleanly integrate 
the new functionality, not "sneak it in" with the smallest number of lines 
changed (and creating technical debt for future maintainers).


Comment at: lib/Frontend/CompilerInvocation.cpp:482
@@ +481,3 @@
+  Opts.ProfileIRInstr = Args.hasArg(OPT_fprofile_ir_instr) &&
+(Args.hasArg(OPT_fprofile_instr_generate) ||
+ Args.hasArg(OPT_fprofile_instr_generate_EQ) ||

xur wrote:
> mcrosier wrote:
> > IIRC, the general practice is to put this type of logic in the driver.  
> > Specifically, in Driver.cpp include something like
> > 
> > if (Args.hasArg(OPT_fprofile_ir_instr) &&
> > (Args.hasArg(OPT_fprofile_instr_generate) ||
> >  Args.hasArg(OPT_fprofile_instr_generate_EQ) ||
> >  Args.hasArg(OPT_fprofile_instr_use_EQ)))
> >   // Add -fprofile_ir_instr flag
> > 
> > 
> In the most recent patch (Suggested by Sean as a temporary measure to speed 
> up the code review)  where -fprofiel-ir-instr becomes a CC1 only option, I 
> have to do it here. Driver won't see the OPT_fprofile_ir_instr. 
> 
> But I'll remember you point when this becomes a Driver option in the next 
> step. Also note that the driver could convert "-fprofile-genearte" to 
> "-fprofiel-instr-generate" and also for "-fprofile-use".  So the condition 
> will be longer if we move to driver.
Chad makes a good point though. This should be just `Opts.ProfileIRInstr = 
Args.hasArg(OPT_fprofile_ir_instr);` because we can assume that for cc11 this 
option is not used except in conjunction with `-fprofile-instr-{generate,use}`


Comment at: lib/Frontend/CompilerInvocation.cpp:487
@@ +486,3 @@
+  // Opts.ProfileInstrGenerate will be used for Clang instrumentation only.
+  if (!Opts.ProfileIRInstr)
+Opts.ProfileInstrGenerate = Args.hasArg(OPT_fprofile_instr_generate) ||

I don't like this. It breaks the 1:1 mapping of flags to codegen options. Like 
Chad said, this sort of complexity should be kept in the driver.

Some refactoring may be needed to cleanly integrate the new IR instrumentation.


Comment at: test/CodeGen/pgo-instrumentation.c:9
@@ +8,2 @@
+// RUN: %clang -O2 -c -Xclang -fprofile-ir-instr %s -mllvm 
-debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PASS2
+// CHECK-PASS2-NOT: PGOInstrumentationGenPass

Please test both Gen and Use phases.

Also, please use more descriptive CHECK names.


http://reviews.llvm.org/D15829



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


Re: [PATCH] D15699: [cfi] Cross-DSO CFI diagnostic mode (clang part)

2016-01-22 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

ping


Repository:
  rL LLVM

http://reviews.llvm.org/D15699



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


Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258572: [analyzer] Utility to match function calls. 
(authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D15921?vs=44721&id=45748#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15921

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -210,6 +210,16 @@
   return PostImplicitCall(D, Loc, getLocationContext(), Tag);
 }
 
+bool CallEvent::isCalled(const CallDescription &CD) const {
+  assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  if (!CD.II)
+CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName);
+  if (getCalleeIdentifier() != CD.II)
+return false;
+  return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
+  CD.RequiredArgs == getNumArgs());
+}
+
 SVal CallEvent::getArgSVal(unsigned Index) const {
   const Expr *ArgE = getArgExpr(Index);
   if (!ArgE)
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -51,14 +51,11 @@
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext &Ctx) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent &Call,
  CheckerContext &C) const;
@@ -106,7 +103,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@
 
 void SimpleStreamChecker::checkPostCall(const CallEvent &Call,
 CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!Call.isCalled(OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@
 
 void SimpleStreamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!Call.isCalled(CloseFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -275,13 +265,6 @@
   return State;
 }
 
-void SimpleStreamChecker::initIdentifierInfo(ASTContext &Ctx) const {
-  if (IIfopen)
-return;
-  IIfopen = &Ctx.Idents.get("fopen");
-  IIfclose = &Ctx.Idents.get("fclose");
-}
-
 void ento::registerSimpleStreamChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -49,6 +49,27 @@
 class CallEvent;
 class CallEventManager;
 
+/// This class represents a description of a function call using the number of
+/// arguments and the name of the function.
+class CallDescription {
+  friend CallEvent;
+  mutable IdentifierInfo *II;
+  StringRef FuncName;
+  unsigned RequiredArgs;
+
+public:
+  const static unsigned NoArgRequirement = ~0;
+  /// \brief Constructs a CallDescription object.
+  ///
+  /// @param FuncName The name of the function that will be matched.
+  ///
+  /// @param RequiredArgs The number of arguments that is expected to match a
+  /// call. Omit this parameter to match every occurance of call with a given
+  /// name regardless the number of arguments.
+  CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
+  : FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+};
+
 template
 class CallEventRef : public IntrusiveRefCntPtr {
 public:
@@ -227,6 +248,13 @@
 return false;
   }
 
+  /// \brief Returns true if the CallEvent is a call to a fun

r258572 - [analyzer] Utility to match function calls.

2016-01-22 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Jan 22 16:32:46 2016
New Revision: 258572

URL: http://llvm.org/viewvc/llvm-project?rev=258572&view=rev
Log:
[analyzer] Utility to match function calls.

This patch adds a small utility to match function calls. This utility abstracts 
away the mutable keywords and the lazy initialization and caching logic of 
identifiers from the checkers. The SimpleStreamChecker is ported over this 
utility within this patch to show the reduction of code and to test this change.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=258572&r1=258571&r2=258572&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Fri 
Jan 22 16:32:46 2016
@@ -49,6 +49,27 @@ enum CallEventKind {
 class CallEvent;
 class CallEventManager;
 
+/// This class represents a description of a function call using the number of
+/// arguments and the name of the function.
+class CallDescription {
+  friend CallEvent;
+  mutable IdentifierInfo *II;
+  StringRef FuncName;
+  unsigned RequiredArgs;
+
+public:
+  const static unsigned NoArgRequirement = ~0;
+  /// \brief Constructs a CallDescription object.
+  ///
+  /// @param FuncName The name of the function that will be matched.
+  ///
+  /// @param RequiredArgs The number of arguments that is expected to match a
+  /// call. Omit this parameter to match every occurance of call with a given
+  /// name regardless the number of arguments.
+  CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
+  : FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+};
+
 template
 class CallEventRef : public IntrusiveRefCntPtr {
 public:
@@ -227,6 +248,13 @@ public:
 return false;
   }
 
+  /// \brief Returns true if the CallEvent is a call to a function that matches
+  /// the CallDescription.
+  ///
+  /// Note that this function is not intended to be used to match Obj-C method
+  /// calls.
+  bool isCalled(const CallDescription &CD) const;
+
   /// \brief Returns a source range for the entire call, suitable for
   /// outputting in diagnostics.
   virtual SourceRange getSourceRange() const {

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp?rev=258572&r1=258571&r2=258572&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp Fri Jan 22 
16:32:46 2016
@@ -51,14 +51,11 @@ class SimpleStreamChecker : public Check
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext &Ctx) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent &Call,
  CheckerContext &C) const;
@@ -106,7 +103,7 @@ public:
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@ SimpleStreamChecker::SimpleStreamChecker
 
 void SimpleStreamChecker::checkPostCall(const CallEvent &Call,
 CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!Call.isCalled(OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@ void SimpleStreamChecker::checkPostCall(
 
 void SimpleStreamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!Call.isCalled(CloseFn))
 return;
 
   // Get the symbolic value corresponding to t

Re: [PATCH] D16377: Ensure virtual-near-miss does not crash on functions without names

2016-01-22 Thread Alexander Kornienko via cfe-commits
Should be fixed in http://reviews.llvm.org/D16179.
On Jan 20, 2016 23:55, "Aaron Ballman"  wrote:

> aaron.ballman updated this revision to Diff 45451.
> aaron.ballman added a comment.
>
> Now checking that both the base *and* the derived functions have names.
>
>
> http://reviews.llvm.org/D16377
>
> Files:
>   clang-tidy/misc/VirtualNearMissCheck.cpp
>   test/clang-tidy/misc-virtual-near-miss.cpp
>
> Index: test/clang-tidy/misc-virtual-near-miss.cpp
> ===
> --- test/clang-tidy/misc-virtual-near-miss.cpp
> +++ test/clang-tidy/misc-virtual-near-miss.cpp
> @@ -63,3 +63,20 @@
>  private:
>void funk(); // Should not warn: access qualifers don't match.
>  };
> +
> +namespace {
> +// Ensure this code does not crash due to special member functions.
> +class  _Facet_base {
> +public:
> +  virtual ~_Facet_base() noexcept {}
> +};
> +
> +class facet : public _Facet_base {
> +protected:
> +  virtual ~facet() noexcept {}
> +
> +public:
> +  facet(const facet&) = delete;
> +  facet& operator=(const facet&) = delete;
> +};
> +}
> Index: clang-tidy/misc/VirtualNearMissCheck.cpp
> ===
> --- clang-tidy/misc/VirtualNearMissCheck.cpp
> +++ clang-tidy/misc/VirtualNearMissCheck.cpp
> @@ -244,8 +244,16 @@
>  if (isOverriddenByDerivedClass(BaseMD, DerivedRD))
>continue;
>
> +// If the function has an identifier for a name, then use that
> +// identifier to determine the edit distance. If the function is a
> +// special member function without an identifier, assume the edit
> +// distance is nonzero to determine whether the signature is a
> near
> +// miss or not.
>  unsigned EditDistance =
> -BaseMD->getName().edit_distance(DerivedMD->getName());
> +(BaseMD->getDeclName().isIdentifier() &&
> + DerivedMD->getDeclName().isIdentifier())
> +? BaseMD->getName().edit_distance(DerivedMD->getName())
> +: 1;
>  if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
>if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
>  // A "virtual near miss" is found.
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >