Re: [PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-24 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261829: [Sema] Remove assert in 
TreeTransform::TransformObjCObjectType. (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D17355?vs=48247=49012#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17355

Files:
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/SemaObjCXX/base-type-as-written.mm

Index: cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
===
--- cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
+++ cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Make sure we don't crash in TreeTransform::TransformObjCObjectType.
+
+@protocol P1
+@end
+
+template  foo1(T1) { // expected-warning {{protocol has no 
object type specified; defaults to qualified 'id'}}
+  foo1(0);
+}
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -5932,7 +5932,6 @@
   }
 
   ObjCObjectTypeLoc NewT = TLB.push(Result);
-  assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");
   NewT.setHasBaseTypeAsWritten(true);
   NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)


Index: cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
===
--- cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
+++ cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Make sure we don't crash in TreeTransform::TransformObjCObjectType.
+
+@protocol P1
+@end
+
+template  foo1(T1) { // expected-warning {{protocol has no object type specified; defaults to qualified 'id'}}
+  foo1(0);
+}
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -5932,7 +5932,6 @@
   }
 
   ObjCObjectTypeLoc NewT = TLB.push(Result);
-  assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");
   NewT.setHasBaseTypeAsWritten(true);
   NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261829 - [Sema] Remove assert in TreeTransform::TransformObjCObjectType.

2016-02-24 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Feb 25 01:08:33 2016
New Revision: 261829

URL: http://llvm.org/viewvc/llvm-project?rev=261829=rev
Log:
[Sema] Remove assert in TreeTransform::TransformObjCObjectType.

The assert isn't correct since TypeLoc::ObjCObjectTypeLoc doesn't
indicate whether the type is a dependent type. The function returns
false for a type like "" which is a synonym for
"id".

rdar://problem/23838912

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

Added:
cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
Modified:
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=261829=261828=261829=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Feb 25 01:08:33 2016
@@ -5932,7 +5932,6 @@ TreeTransform::TransformObjCObj
   }
 
   ObjCObjectTypeLoc NewT = TLB.push(Result);
-  assert(TL.hasBaseTypeAsWritten() && "Can't be dependent");
   NewT.setHasBaseTypeAsWritten(true);
   NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
   for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)

Added: cfe/trunk/test/SemaObjCXX/base-type-as-written.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/base-type-as-written.mm?rev=261829=auto
==
--- cfe/trunk/test/SemaObjCXX/base-type-as-written.mm (added)
+++ cfe/trunk/test/SemaObjCXX/base-type-as-written.mm Thu Feb 25 01:08:33 2016
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Make sure we don't crash in TreeTransform::TransformObjCObjectType.
+
+@protocol P1
+@end
+
+template  foo1(T1) { // expected-warning {{protocol has no 
object type specified; defaults to qualified 'id'}}
+  foo1(0);
+}


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


Re: [PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-24 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Thanks, I'll commit this shortly.


http://reviews.llvm.org/D17355



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


Re: [PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-24 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

  foo((event_t)0);

Is above use have been hint by some test cases?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7679
@@ -7678,2 +7678,3 @@
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<

Please do not use DOS format.


Comment at: lib/Sema/SemaCast.cpp:2316
@@ -2315,1 +2315,3 @@
 
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {

1. Comments start with capital.
2. End a sentence with a period.
3. Give spec reference here, start with:
OpenCL v2.0 s6.13.10 - 


Comment at: lib/Sema/SemaCast.cpp:2317
@@ +2316,3 @@
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;

(Self.getLangOpts().OpenCL) -> Self.getLangOpts().OpenCL


Comment at: lib/Sema/SemaCast.cpp:2318
@@ +2317,3 @@
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {

Indent.


Comment at: lib/Sema/SemaCast.cpp:2319
@@ +2318,3 @@
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+if(0 == intValue) {

Sema has a context.
Self.getASTContext() ->Self.Context


Comment at: lib/Sema/SemaCast.cpp:2321
@@ +2320,3 @@
+if(0 == intValue) {
+  Kind = CK_IntegralToPointer;
+  return;

There is a CK_ZeroToOCLEvent, why not use that?


Comment at: lib/Sema/SemaCast.cpp:2324-2328
@@ +2323,7 @@
+} else {
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+}

Indent.
You can try to use clang-format to help keep these right.


http://reviews.llvm.org/D17578



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


Re: [PATCH] D17528: [analyzer] Warn on use of 'self' after call to to [super dealloc].

2016-02-24 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp:165
@@ +164,3 @@
+  if (Desc.empty())
+Desc = "use of 'self' after it is freed with call to [super dealloc]";
+

Does "has been freed" sound better?


Comment at: test/Analysis/DeallocUseAfterFreeErrors.m:59
@@ +58,3 @@
+  [super dealloc]; // expected-note {{[super dealloc] called here}}
+  _delegate = nil; // expected-warning {{use of 'self' after it is freed with 
call to [super dealloc]}}
+  // expected-note@-1 {{use of 'self' after it is freed with call to 
[super dealloc]}}

Would it be possible to provide a more presice error message here? 
Specifically, we refer to 'self' here but the reference is implicit. I guess we 
could say something like "accessing an instance variable after the object has 
been freed". Would that require extra checking to ensure that we are indeed 
accessing a member in checkLocation?


http://reviews.llvm.org/D17528



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


Re: [PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-24 Thread Doug Gregor via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

LGTM, sorry for the delay.


http://reviews.llvm.org/D17355



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


Re: [PATCH] D17355: [Sema] Remove assert in TreeTransform::TransformObjCObjectType

2016-02-24 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Is this OK to commit?

I've committed the patch to fix the TypeLocBuilder bug in r261260.


http://reviews.llvm.org/D17355



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


Re: [PATCH] D16876: [OpenCL] Refine pipe builtin support

2016-02-24 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 49008.
pxli168 added a comment.

1. Make new indent and leave space for the incoming OpenCL C++.
2. Check for the index to see if they are integers.


http://reviews.llvm.org/D16876

Files:
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -5,51 +5,51 @@
   reserve_id_t rid;
 
   // read/write_pipe
-  read_pipe(tmp, p);// expected-error {{first argument to read_pipe must be a pipe type}}
-  read_pipe(p);   // expected-error {{invalid number of arguments to function: read_pipe}}
-  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'reserve_id_t')}}
-  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function read_pipe (expecting 'unsigned int')}}
-  read_pipe(p, tmp);   // expected-error {{invalid argument type to function read_pipe (expecting 'int *')}}
+  read_pipe(tmp, p);// expected-error {{first argument to 'read_pipe' must be a pipe type}}
+  read_pipe(p);   // expected-error {{invalid number of arguments to function: 'read_pipe'}}
+  read_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'reserve_id_t')}}
+  read_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'unsigned int')}}
+  read_pipe(p, tmp);   // expected-error {{invalid argument type to function 'read_pipe' (expecting 'int *')}}
   write_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
   write_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting write_only)}}
 
   // reserve_read/write_pipe
-  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_read_pipe (expecting 'unsigned int')}}
-  work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to work_group_reserve_read_pipe must be a pipe type}}
+  reserve_read_pipe(p, ptr);// expected-error{{invalid argument type to function 'reserve_read_pipe' (expecting 'unsigned int')}}
+  work_group_reserve_read_pipe(tmp, tmp);// expected-error{{first argument to 'work_group_reserve_read_pipe' must be a pipe type}}
   sub_group_reserve_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}}
 
   // commit_read/write_pipe
-  commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}}
-  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting 'reserve_id_t')}}
+  commit_read_pipe(tmp, rid);// expected-error{{first argument to 'commit_read_pipe' must be a pipe type}}
+  work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function 'work_group_commit_read_pipe' (expecting 'reserve_id_t')}}
   sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}}
 }
 
 void test2(write_only pipe int p, global int* ptr){
   int tmp;
   reserve_id_t rid;
 
   // read/write_pipe
-  write_pipe(tmp, p);// expected-error {{first argument to write_pipe must be a pipe type}}
-  write_pipe(p);   // expected-error {{invalid number of arguments to function: write_pipe}}
-  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'reserve_id_t')}}
-  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function write_pipe (expecting 'unsigned int')}}
-  write_pipe(p, tmp);   // expected-error {{invalid argument type to function write_pipe (expecting 'int *')}}
+  write_pipe(tmp, p);// expected-error {{first argument to 'write_pipe' must be a pipe type}}
+  write_pipe(p);   // expected-error {{invalid number of arguments to function: 'write_pipe'}}
+  write_pipe(p, tmp, tmp, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'reserve_id_t')}}
+  write_pipe(p, rid, rid, ptr);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'unsigned int')}}
+  write_pipe(p, tmp);   // expected-error {{invalid argument type to function 'write_pipe' (expecting 'int *')}}
   read_pipe(p, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
   read_pipe(p, rid, tmp, ptr);// expected-error {{invalid pipe access modifier (expecting read_only)}}
 
   // reserve_read/write_pipe
-  reserve_write_pipe(p, ptr);// expected-error{{invalid argument type to function reserve_write_pipe (expecting 'unsigned int')}}
-  

r261824 - [OPENMP 4.5] Codegen for member decls in 'lastprivate' clause.

2016-02-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 24 23:25:57 2016
New Revision: 261824

URL: http://llvm.org/viewvc/llvm-project?rev=261824=rev
Log:
[OPENMP 4.5] Codegen for member decls in 'lastprivate' clause.

OpenMP 4.5 allows to privatize non-static member decls in non-static
member functions. Patch captures such decls by reference in general (for
bitfields, by value) and then operates with this capture. For bitfields,
at the end of codegen for lastprivates original bitfield is updated with the 
value of captured copy.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/for_lastprivate_codegen.cpp
cfe/trunk/test/OpenMP/parallel_num_threads_codegen.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=261824=261823=261824=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Wed Feb 24 23:25:57 2016
@@ -92,6 +92,28 @@ public:
   static const OMPClauseWithPreInit *get(const OMPClause *C);
 };
 
+/// Class that handles post-update expression for some clauses, like
+/// 'lastprivate', 'reduction' etc.
+class OMPClauseWithPostUpdate {
+  friend class OMPClauseReader;
+  /// Post-update expression for the clause.
+  Expr *PostUpdate;
+protected:
+  /// Set pre-initialization statement for the clause.
+  void setPostUpdateExpr(Expr *S) { PostUpdate = S; }
+  OMPClauseWithPostUpdate(const OMPClause *This) : PostUpdate(nullptr) {
+assert(get(This) && "get is not tuned.");
+  }
+
+public:
+  /// Get post-update expression for the clause.
+  const Expr *getPostUpdateExpr() const { return PostUpdate; }
+  /// Get post-update expression for the clause.
+  Expr *getPostUpdateExpr() { return PostUpdate; }
+  static OMPClauseWithPostUpdate *get(OMPClause *C);
+  static const OMPClauseWithPostUpdate *get(const OMPClause *C);
+};
+
 /// \brief This represents clauses with the list of variables like 'private',
 /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the
 /// '#pragma omp ...' directives.
@@ -1382,6 +1404,8 @@ public:
 /// with the variables 'a' and 'b'.
 class OMPLastprivateClause final
 : public OMPVarListClause,
+  public OMPClauseWithPreInit,
+  public OMPClauseWithPostUpdate,
   private llvm::TrailingObjects {
   // There are 4 additional tail-allocated arrays at the end of the class:
   // 1. Contains list of pseudo variables with the default initialization for
@@ -1414,7 +1438,8 @@ class OMPLastprivateClause final
   OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation EndLoc, unsigned N)
   : OMPVarListClause(OMPC_lastprivate, StartLoc,
-   LParenLoc, EndLoc, N) {}
+   LParenLoc, EndLoc, N),
+OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this) {}
 
   /// \brief Build an empty clause.
   ///
@@ -1423,7 +1448,8 @@ class OMPLastprivateClause final
   explicit OMPLastprivateClause(unsigned N)
   : OMPVarListClause(
 OMPC_lastprivate, SourceLocation(), SourceLocation(),
-SourceLocation(), N) {}
+SourceLocation(), N),
+OMPClauseWithPreInit(this), OMPClauseWithPostUpdate(this) {}
 
   /// \brief Get the list of helper expressions for initialization of private
   /// copies for lastprivate variables.
@@ -1496,12 +1522,16 @@ public:
   /// \endcode
   /// Required for proper codegen of final assignment performed by the
   /// lastprivate clause.
-  ///
+  /// \param PreInit Statement that must be executed before entering the OpenMP
+  /// region with this clause.
+  /// \param PostInit Expression that must be executed after exit from the
+  /// OpenMP region with this clause.
   ///
   static OMPLastprivateClause *
   Create(const ASTContext , SourceLocation StartLoc, SourceLocation 
LParenLoc,
  SourceLocation EndLoc, ArrayRef VL, ArrayRef SrcExprs,
- ArrayRef DstExprs, ArrayRef AssignmentOps);
+ ArrayRef DstExprs, ArrayRef AssignmentOps,
+ Stmt *PreInit, Expr *PostUpdate);
   /// \brief Creates an empty clause with the place for \a N variables.
   ///
   /// \param C AST context.

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=261824=261823=261824=diff

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

2016-02-24 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 49007.

http://reviews.llvm.org/D16040

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Parse/ParseDecl.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
  test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl
@@ -21,7 +21,7 @@
   // commit_read/write_pipe
   commit_read_pipe(tmp, rid);// expected-error{{first argument to commit_read_pipe must be a pipe type}}
   work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_read_pipe (expecting 'reserve_id_t')}}
-  sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting write_only)}}
+  sub_group_commit_write_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting write_only)}}
 }
 
 void test2(write_only pipe int p, global int* ptr){
@@ -45,7 +45,7 @@
   // commit_read/write_pipe
   commit_write_pipe(tmp, rid);// expected-error{{first argument to commit_write_pipe must be a pipe type}}
   work_group_commit_write_pipe(p, tmp);// expected-error{{invalid argument type to function work_group_commit_write_pipe (expecting 'reserve_id_t')}}
-  sub_group_commit_read_pipe(p, tmp);// expected-error{{nvalid pipe access modifier (expecting read_only)}}
+  sub_group_commit_read_pipe(p, tmp);// expected-error{{invalid pipe access modifier (expecting read_only)}}
 }
 
 void test3(){
Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -28,8 +28,6 @@
 
 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}}
 }
 
 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,14 @@
+// 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 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,19 @@
-// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify -cl-std=CL2.0 -DCL20
+// expected-no-diagnostics
 
 __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
@@ -6237,6 +6237,17 @@
   CurType = S.Context.getVectorType(CurType, numElts, VecKind);
 }
 
+/// Handle OpenCL Access Qualifier Attribute.
+static void HandleOpenCLAccessAttr(QualType , const AttributeList ,
+   Sema ) {
+  // 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 , QualType 

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

2016-02-24 Thread Sean Silva via cfe-commits
silvas added a comment.

In http://reviews.llvm.org/D15829#360006, @xur wrote:

> Here is the new patch that removes the auto detection of profile kind.
>
> In this patch, I replace the CC1 option of -fprofile-instr-use=<> with 
> -fprofile-instrument={llvm-use|clang-use}. For the use compilation, the 
> profile reuses the -fprofile-instrument-path= option.
>
> Again, all changes are of CC1 options. Driver options are intact.
>
> Some test are modified due to the -fprofile-instr-use= option change.
>
> A new test is added to test IR profile compilation. 
>  test/CodeGen/pgo-instrumentation.c


I meant in a new phabricator review. This one is has gone on for too long and 
is convoluted and hard to follow. (lots of stray inline comments 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


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

2016-02-24 Thread Xiuli PAN via cfe-commits
pxli168 marked 2 inline comments as done.
pxli168 added a comment.

Remove test case for access quilifier in 
test/SemaOpenCL/invalid-kernel-attrs.cl.
Due to the patch http://reviews.llvm.org/D17437.
read_only can only be used in parameters with pipe and image type.



Comment at: test/SemaOpenCL/invalid-pipe-builtin-cl2.0.cl:24
@@ -23,3 +23,3 @@
   work_group_commit_read_pipe(p, tmp);// expected-error{{invalid argument 
type to function work_group_commit_read_pipe (expecting 'reserve_id_t')}}
-  sub_group_commit_write_pipe(p, tmp);// expected-error{{nvalid pipe 
access modifier (expecting write_only)}}
 }

Anastasia wrote:
> Anastasia wrote:
> > This test doesn't seem to work correctly because it didn't detect that we 
> > were checking for the wrong error message!
> > 
> > I am thinking it might be the issue of adding "-ferror-limit 100" to the 
> > RUN line as it might have stopped to diagnose after certain number of 
> > errors given. Could you please double check this?
> I just checked it and I guess it's passing because it's doing substring 
> check, so no need to add anything to the RUN line. Your change is fine here!
I found these bug by testing with the access qualifier, and find some word 
missing and just add them in this patch.


http://reviews.llvm.org/D16040



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


r261823 - Twek fix for PR24473 (r261506) - Preserve the template arguments as written

2016-02-24 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Wed Feb 24 23:09:30 2016
New Revision: 261823

URL: http://llvm.org/viewvc/llvm-project?rev=261823=rev
Log:
Twek fix for PR24473 (r261506) - Preserve the template arguments as written
(within the DeclRefExpr Node) when creating AST nodes that reference 
specializations of static data member templates.  While we pass the template 
args through for all non-instance members, they should only be relevant (i.e. 
non-null) for variable template ids (assertion added for that assumption)

Also preserve the FoundDecl that refers to the canonical Decl (the  primary 
VarTemplateDecl for a variable template specialization) that we are referencing 
in our DeclRefExpr. Not sure why this was not being done for non-variable 
template-ids.  

No functionality change - so no tests added.

Thanks to Richard Smith for drawing my attention to this!

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

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=261823=261822=261823=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Wed Feb 24 23:09:30 2016
@@ -1100,6 +1100,8 @@ Sema::BuildMemberReferenceExpr(Expr *Bas
   // declaration corresponding to the supplied template arguments
   // (while emitting diagnostics as necessary) that will be referenced
   // by this expression.
+  assert((!TemplateArgs || isa(MemberDecl)) &&
+ "How did we get template arguments here sans a variable 
template");
   if (isa(MemberDecl)) {
 MemberDecl = getVarTemplateSpecialization(
 *this, cast(MemberDecl), TemplateArgs,
@@ -1107,7 +1109,8 @@ Sema::BuildMemberReferenceExpr(Expr *Bas
 if (!MemberDecl)
   return ExprError();
   }
-  return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl);
+  return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl,
+  FoundDecl, TemplateArgs);
 }
 SourceLocation Loc = R.getNameLoc();
 if (SS.getRange().isValid())


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


r261820 - [OPENMP 4.5] Support fielddecls in 'shared' clause.

2016-02-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 24 21:59:29 2016
New Revision: 261820

URL: http://llvm.org/viewvc/llvm-project?rev=261820=rev
Log:
[OPENMP 4.5] Support fielddecls in 'shared' clause.

OpenMP 4.5 allows to use non-static data members of current class in
non-static member functions in different kind of clauses. Patch adds
support for data members in 'shared' clause.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_ast_print.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=261820=261819=261820=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Feb 24 21:59:29 2016
@@ -1739,16 +1739,19 @@ static OMPCapturedExprDecl *buildCapture
   return CED;
 }
 
-static DeclRefExpr *buildCapture(Sema , IdentifierInfo *Id,
- Expr *CaptureExpr) {
-  auto *CD = buildCaptureDecl(S, Id, CaptureExpr);
+static DeclRefExpr *buildCapture(Sema , ValueDecl *D, Expr *CaptureExpr) {
+  OMPCapturedExprDecl *CD;
+  if (auto *VD = S.IsOpenMPCapturedDecl(D))
+CD = cast(VD);
+  else
+CD = buildCaptureDecl(S, D->getIdentifier(), CaptureExpr);
   return buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
   SourceLocation());
 }
 
-static DeclRefExpr *buildCapture(Sema , StringRef Name, Expr *CaptureExpr) {
-  auto *CD =
-  buildCaptureDecl(S, ().Idents.get(Name), CaptureExpr);
+static DeclRefExpr *buildCapture(Sema , Expr *CaptureExpr) {
+  auto *CD = buildCaptureDecl(
+  S, ().Idents.get(".capture_expr."), CaptureExpr);
   return buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
   SourceLocation());
 }
@@ -6841,7 +6844,7 @@ OMPClause *Sema::ActOnOpenMPScheduleClau
   return nullptr;
 }
   } else if (isParallelOrTaskRegion(DSAStack->getCurrentDirective())) {
-ValExpr = buildCapture(*this, ".chunk.", ValExpr);
+ValExpr = buildCapture(*this, ValExpr);
 Decl *D = cast(ValExpr)->getDecl();
 HelperValStmt =
 new (Context) DeclStmt(DeclGroupRef::Create(Context, ,
@@ -7205,7 +7208,7 @@ OMPClause *Sema::ActOnOpenMPPrivateClaus
 
 DeclRefExpr *Ref = nullptr;
 if (!VD)
-  Ref = buildCapture(*this, D->getIdentifier(), RefExpr);
+  Ref = buildCapture(*this, D, RefExpr);
 DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_private, Ref);
 Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);
 PrivateCopies.push_back(VDPrivateRefExpr);
@@ -7482,7 +7485,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
 RefExpr->getExprLoc());
 DeclRefExpr *Ref = nullptr;
 if (!VD) {
-  Ref = buildCapture(*this, D->getIdentifier(), RefExpr);
+  Ref = buildCapture(*this, D, RefExpr);
   ExprCaptures.push_back(Ref->getDecl());
 }
 DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_firstprivate, Ref);
@@ -7618,7 +7621,7 @@ OMPClause *Sema::ActOnOpenMPLastprivateC
 
 DeclRefExpr *Ref = nullptr;
 if (!VD)
-  Ref = buildCapture(*this, D->getIdentifier(), RefExpr);
+  Ref = buildCapture(*this, D, RefExpr);
 if (TopDVar.CKind != OMPC_firstprivate)
   DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_lastprivate, Ref);
 Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);
@@ -7640,36 +7643,18 @@ OMPClause *Sema::ActOnOpenMPSharedClause
  SourceLocation EndLoc) {
   SmallVector Vars;
   for (auto  : VarList) {
-assert(RefExpr && "NULL expr in OpenMP shared clause.");
-if (isa(RefExpr)) {
+assert(RefExpr && "NULL expr in OpenMP lastprivate clause.");
+auto Res = getPrivateItem(*this, RefExpr);
+if (Res.second) {
   // It will be analyzed later.
   Vars.push_back(RefExpr);
-  continue;
-}
-
-SourceLocation ELoc = RefExpr->getExprLoc();
-// OpenMP [2.1, C/C++]
-//  A list item is a variable name.
-// OpenMP  [2.14.3.2, Restrictions, p.1]
-//  A variable that is part of another variable (as an array or structure
-//  element) cannot appear in a shared unless it is a static data member
-//  of a C++ class.
-DeclRefExpr *DE = dyn_cast(RefExpr);
-if (!DE || !isa(DE->getDecl())) {
-  Diag(ELoc, diag::err_omp_expected_var_name_member_expr)
-  << 0 << RefExpr->getSourceRange();
-  continue;
 }
-Decl *D = DE->getDecl();
-VarDecl *VD = cast(D);
-
-QualType Type = VD->getType();
-if (Type->isDependentType() || Type->isInstantiationDependentType()) {
-  // It will be analyzed later.
-  Vars.push_back(DE);
+ValueDecl *D = Res.first;
+if (!D)
   continue;
-}
 
+SourceLocation ELoc = RefExpr->getExprLoc();
+auto *VD = dyn_cast(D);
 // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
 // in a Construct]

Re: [clang-tools-extra] r261737 - [clang-tidy] Added a check for forward declaration in the potentially wrong namespace

2016-02-24 Thread Sean Silva via cfe-commits
This or r261737 seem to be causing a bot failure:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/636

-- Sean Silva

On Wed, Feb 24, 2016 at 5:35 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Feb 24 07:35:32 2016
> New Revision: 261737
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261737=rev
> Log:
> [clang-tidy] Added a check for forward declaration in the potentially
> wrong namespace
>
> Adds a new check "misc-forward-declaration-namespace".
> In check, A forward declaration is considerred in a potentially wrong
> namespace
> if there is any definition/declaration with the same name exists in a
> different
> namespace.
>
> Reviewers: akuegel, hokein, alexfh
>
> Patch by Eric Liu!
>
> Differential Revision: http://reviews.llvm.org/D17195
>
> Added:
>
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forward-declaration-namespace.rst
>
> clang-tools-extra/trunk/test/clang-tidy/misc-forward-declaration-namespace.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=261737=261736=261737=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Wed Feb 24
> 07:35:32 2016
> @@ -6,6 +6,7 @@ add_clang_library(clangTidyMiscModule
>AssignOperatorSignatureCheck.cpp
>BoolPointerImplicitConversionCheck.cpp
>DefinitionsInHeadersCheck.cpp
> +  ForwardDeclarationNamespaceCheck.cpp
>InaccurateEraseCheck.cpp
>IncorrectRoundings.cpp
>InefficientAlgorithmCheck.cpp
>
> Added:
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=261737=auto
>
> ==
> ---
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> (added)
> +++
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> Wed Feb 24 07:35:32 2016
> @@ -0,0 +1,174 @@
> +//===--- ForwardDeclarationNamespaceCheck.cpp - clang-tidy --*- C++
> -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===--===//
> +
> +#include "ForwardDeclarationNamespaceCheck.h"
> +#include 
> +#include 
> +#include "clang/AST/ASTContext.h"
> +#include "clang/AST/Decl.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +#include "clang/ASTMatchers/ASTMatchers.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace misc {
> +
> +void ForwardDeclarationNamespaceCheck::registerMatchers(MatchFinder
> *Finder) {
> +  // Match all class declarations/definitions *EXCEPT*
> +  // 1. implicit classes, e.g. `class A {};` has implicit `class A`
> inside `A`.
> +  // 2. nested classes declared/defined inside another class.
> +  // 3. template class declaration, template instantiation or
> +  //specialization (NOTE: extern specialization is filtered out by
> +  //`unless(hasAncestor(cxxRecordDecl()))`).
> +  auto IsInSpecialization = hasAncestor(
> +  decl(anyOf(cxxRecordDecl(isExplicitTemplateSpecialization()),
> + functionDecl(isExplicitTemplateSpecialization();
> +  Finder->addMatcher(
> +  cxxRecordDecl(
> +  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl(,
> +  unless(isImplicit()), unless(hasAncestor(cxxRecordDecl())),
> +  unless(isInstantiated()), unless(IsInSpecialization),
> +  unless(classTemplateSpecializationDecl()))
> +  .bind("record_decl"),
> +  this);
> +
> +  // Match all friend declarations. Classes used in friend declarations
> are not
> +  // marked as referenced in AST. We need to record all record classes
> used in
> +  // friend declarations.
> +  Finder->addMatcher(friendDecl().bind("friend_decl"), this);
> +}
> +
> +void ForwardDeclarationNamespaceCheck::check(
> +const MatchFinder::MatchResult ) {
> +  if (const auto *RecordDecl =
> +  Result.Nodes.getNodeAs("record_decl")) {
> +StringRef DeclName = RecordDecl->getName();
> +if 

r261818 - [OpenCL] Add Sema checks for types

2016-02-24 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Wed Feb 24 21:34:20 2016
New Revision: 261818

URL: http://llvm.org/viewvc/llvm-project?rev=261818=rev
Log:
[OpenCL] Add Sema checks for types

Summary:
Add Sema checks for opencl type: image, pipe
This patch is partitioned from http://reviews.llvm.org/D16047

Reviewers: Anastasia, yaxunl

Subscribers: pekka.jaaskelainen, cfe-commits

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

Added:
cfe/trunk/test/SemaOpenCL/invalid-image.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl
cfe/trunk/test/SemaOpenCL/sampler_t.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=261818=261817=261818=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Feb 24 21:34:20 
2016
@@ -7720,6 +7720,10 @@ def err_opencl_invalid_type_array : Erro
   "array of %0 type is invalid in OpenCL">;
 def err_opencl_ternary_with_block : Error<
   "block type cannot be used as expression in ternary expression in OpenCL">;
+def err_opencl_pointer_to_type : Error<
+  "pointer to type %0 is invalid in OpenCL">;
+def err_opencl_type_can_only_be_used_as_function_parameter : Error <
+  "type %0 can only be used as a function parameter in OpenCL">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=261818=261817=261818=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 24 21:34:20 2016
@@ -5710,6 +5710,17 @@ Sema::ActOnVariableDeclarator(Scope *S,
   QualType R = TInfo->getType();
   DeclarationName Name = GetNameForDeclarator(D).getName();
 
+  // OpenCL v2.0 s6.9.b - Image type can only be used as a function argument.
+  // OpenCL v2.0 s6.13.16.1 - Pipe type can only be used as a function
+  // argument.
+  if (getLangOpts().OpenCL && (R->isImageType() || R->isPipeType())) {
+Diag(D.getIdentifierLoc(),
+ diag::err_opencl_type_can_only_be_used_as_function_parameter)
+<< R;
+D.setInvalidType();
+return nullptr;
+  }
+
   DeclSpec::SCS SCSpec = D.getDeclSpec().getStorageClassSpec();
   StorageClass SC = StorageClassSpecToVarDeclStorageClass(D.getDeclSpec());
 
@@ -10737,7 +10748,17 @@ ParmVarDecl *Sema::CheckParameter(DeclCo
   Diag(NameLoc, diag::err_arg_with_address_space);
   New->setInvalidDecl();
 }
-  }   
+  }
+
+  // OpenCL v2.0 s6.9b - Pointer to image/sampler cannot be used.
+  // OpenCL v2.0 s6.13.16.1 - Pointer to pipe cannot be used.
+  if (getLangOpts().OpenCL && T->isPointerType()) {
+const QualType PTy = T->getPointeeType();
+if (PTy->isImageType() || PTy->isSamplerT() || PTy->isPipeType()) {
+  Diag(NameLoc, diag::err_opencl_pointer_to_type) << PTy;
+  New->setInvalidDecl();
+}
+  }
 
   return New;
 }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=261818=261817=261818=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 24 21:34:20 2016
@@ -2176,9 +2176,12 @@ QualType Sema::BuildArrayType(QualType T
   }
 
   // OpenCL v2.0 s6.12.5 - Arrays of blocks are not supported.
+  // OpenCL v2.0 s6.16.13.1 - Arrays of pipe type are not supported.
+  // OpenCL v2.0 s6.9.b - Arrays of image/sampler type are not supported.
   if (getLangOpts().OpenCL) {
 const QualType ArrType = Context.getBaseElementType(T);
-if (ArrType->isBlockPointerType()) {
+if (ArrType->isBlockPointerType() || ArrType->isPipeType() ||
+ArrType->isSamplerT() || ArrType->isImageType()) {
   Diag(Loc, diag::err_opencl_invalid_type_array) << ArrType;
   return QualType();
 }

Modified: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/opencl_types.cl?rev=261818=261817=261818=diff
==
--- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Wed Feb 24 21:34:20 2016
@@ -36,5 +36,5 @@ kernel void foo(image1d_t img) {
 // CHECK: call {{.*}}void @fnc4smp(i32
 }
 
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t 
*d) {}
-// CHECK-LABEL: 

Re: [PATCH] D17589: Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT

2016-02-24 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/D17589



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


Re: [PATCH] D17519: AMDGPU: Fix broken/confusing predefined macro

2016-02-24 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/D17519



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


Re: [PATCH] D17520: AMDGPU: Fix inconsistent register name for flat_scratch

2016-02-24 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/D17520



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


Re: [PATCH] D17515: AMDGPU: Add builtins for recently added intrinsics

2016-02-24 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/D17515



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


Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-02-24 Thread Eric Christopher via cfe-commits
Those are all compelling reasons for me. Let's go with whatever you and
Dmitri think would be best for now. :)

-eric

On Wed, Feb 24, 2016 at 12:41 PM Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Hello,
>
>
>
> I don’t think it will too hard to convert C++ style doxygen comments into
> C style doxygen comments by writing a post-processing python script.
> However, at first we need to decide if we really want to do that. If so, we
> need to settle on the exact format. After that, I need to make sure that
> the comments in the new format will be rendered correctly in MS Tooltips,
> XCode, online documentation and PS4 internal documentation. This discussion
> + investigation might take a few days.
>
>
>
> Before we start discussing the exact format, I want to make sure that we
> really want to change to C-style doxygen comments.
>
> Here are my not-so-strong arguments against it:
>
> -There currently are 257 occurrences C++ style comments in 14
> other header files in /llvm/tools/clang/lib/Headers directory (I’m talking
> about the files that I didn’t touch). C++ style comments were there for
> AGES and nobody complained so far. If we decide to change C++ style doxygen
> comments -> C-style, we also need to change all regular C++ comments to
> C-style in these header files.
>
> -c99 (and later) supports C++ style comments, while I c89
> doesn’t. I’m not sure if we have users that still use c89 format and x86
> intrinsic headers at the same time.
>
> -C++ style doxygen comments are more pretty and readable compared
> to C-style comment (though it might be my subjective opinion).
>
>
>
> Let me know what you think.
>
>
>
> I will try to get Dmitri Gribenko’s opinion. He did a lot of work on
> doxygen in LLVM. I’m curious what he thinks about Javadoc style format.
>
>
>
> Katya.
>
>
>
>
>
> *From:* Eric Christopher [mailto:echri...@gmail.com]
> *Sent:* Tuesday, February 23, 2016 10:51 PM
> *To:* reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; Romanova,
> Katya; Gao, Yunzhong; griboz...@gmail.com; craig.top...@gmail.com;
> Robinson, Paul
> *Cc:* Bedwell, Greg; cfe-commits@lists.llvm.org
> *Subject:* Re: [PATCH] D17550: Adding doxygen comments to the LLVM
> intrinsics (part 6, popcntintrin.h)
>
>
>
> Yeah, we should be doing this. Nice catch Paul and Greg.
>
>
>
> On Tue, Feb 23, 2016, 10:34 PM Greg Bedwell 
> wrote:
>
> gbedwell added a subscriber: gbedwell.
> gbedwell added a comment.
>
> In http://reviews.llvm.org/D17550#360177, @probinson wrote:
>
> > One question I have, which shouldn't block this (as we've done several
> like this already):
> >  Is is okay to be using C++ style comments in these headers?
> >  (Is there a C-style comment that Doxygen recognizes?)
>
>
> There are a few various formats that Doxygen supports.  Looking at headers
> from llvm-c the most common convention appears to be JavaDoc style,
> although there are a few examples of other supported styles floating around
> the codebase.  E.g. from include/llvm-c/lto.h using JavaDoc style:
>
> /**
>
> - Diagnostic handler type.
> - \p severity defines the severity.
> - \p diag is the actual diagnostic.
> - The diagnostic is not prefixed by any of severity keyword, e.g., 'error:
> '.
> - \p ctxt is used to pass the context set with the diagnostic handler. *
> - \since LTO_API_VERSION=7 */
>
> -Greg
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D17550
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 5:36 AM, Alexander Kornienko via cfe-commits
 wrote:
> Author: alexfh
> Date: Wed Feb 24 07:36:34 2016
> New Revision: 261738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261738=rev
> Log:
> [clang-tidy] introduce modernize-deprecated-headers check
>
> Summary:
> This patch introduces the modernize-deprecated-headers check, which is 
> supposed to replace deprecated C library headers with the C++ STL-ones.
>
> For information see documentation; for exmaples see the test cases.
>
> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>
> Subscribers: cfe-commits
>
> Patch by Kirill Bobyrev!
>
> Differential Revision: http://reviews.llvm.org/D17484
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
> 
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
> 
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738=261737=261738=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24 
> 07:36:34 2016
> @@ -1,6 +1,7 @@
>  set(LLVM_LINK_COMPONENTS support)
>
>  add_clang_library(clangTidyModernizeModule
> +  DeprecatedHeadersCheck.cpp
>LoopConvertCheck.cpp
>LoopConvertUtils.cpp
>MakeUniqueCheck.cpp
>
> Added: clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261738=auto
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
> Wed Feb 24 07:36:34 2016
> @@ -0,0 +1,110 @@
> +//===--- DeprecatedHeadersCheck.cpp - 
> clang-tidy---===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--===//
> +
> +#include "DeprecatedHeadersCheck.h"
> +#include "clang/Frontend/CompilerInstance.h"
> +#include "clang/Lex/PPCallbacks.h"
> +#include "clang/Lex/Preprocessor.h"
> +#include "llvm/ADT/StringMap.h"
> +
> +#include 
> +
> +namespace clang {
> +namespace tidy {
> +namespace modernize {
> +
> +namespace {
> +class IncludeModernizePPCallbacks : public PPCallbacks {
> +public:
> +  explicit IncludeModernizePPCallbacks(ClangTidyCheck ,
> +   LangOptions LangOpts);
> +
> +  void InclusionDirective(SourceLocation HashLoc, const Token ,
> +  StringRef FileName, bool IsAngled,
> +  CharSourceRange FilenameRange, const FileEntry 
> *File,
> +  StringRef SearchPath, StringRef RelativePath,
> +  const Module *Imported) override;
> +
> +private:
> +  ClangTidyCheck 
> +  LangOptions LangOpts;
> +  llvm::StringMap CStyledHeaderToCxx;
> +};
> +} // namespace
> +
> +void DeprecatedHeadersCheck::registerPPCallbacks(CompilerInstance ) 
> {
> +  if (this->getLangOpts().CPlusPlus) {
> +Compiler.getPreprocessor().addPPCallbacks(
> +::llvm::make_unique(*this,
> + 
> this->getLangOpts()));
> +  }
> +}
> +
> +IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck 
> ,
> + LangOptions 
> LangOpts)
> +: Check(Check), LangOpts(LangOpts),
> +  CStyledHeaderToCxx({{"assert.h", "cassert"},
> +  {"complex.h", "ccomplex"},

It'd be better to convert this one to , or leave it alone.
 is an unnecessary wart.

(The contents of C++11's  /  /  (all of
which are identical) aren't comparable to C99's , so if
this was C++98 code using the C99 header, the code will be broken with
or without this transformation.)

> +  {"ctype.h", "cctype"},
> +  {"errno.h", "cerrno"},
> +  {"float.h", "cfloat"},
> +

[PATCH] D17589: Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT

2016-02-24 Thread Paul Robinson via cfe-commits
probinson created this revision.
probinson added reviewers: jyknight, dexonsmith.
probinson added a subscriber: cfe-commits.
Herald added a reviewer: tstellarAMD.

FileCheck actually doesn't support combo suffixes.  In D17587 I made it 
complain, and these are the Clang tests that it caught.

http://reviews.llvm.org/D17589

Files:
  test/CodeGen/aarch64-fix-cortex-a53-835769.c
  test/CodeGen/alias.c
  test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
  test/Driver/hexagon-toolchain-elf.c
  test/SemaCXX/pragma-optimize.cpp

Index: test/SemaCXX/pragma-optimize.cpp
===
--- test/SemaCXX/pragma-optimize.cpp
+++ test/SemaCXX/pragma-optimize.cpp
@@ -151,14 +151,14 @@
 // CHECK-DAG: attributes [[ATTRYETANOTHEROPTNONE]] = { {{.*}}noinline{{.*}}optnone{{.*}} }
 
 // Check that the other functions do NOT have optnone.
-// CHECK-DAG-NOT: attributes [[ATTRFOO]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRBAZ]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRBAX]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRWOMBAT]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRTWICE]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER2]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRCONTAINER3]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRTHRICEINT]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
-// CHECK-DAG-NOT: attributes [[ATTRYETANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRFOO]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRBAZ]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRBAX]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRWOMBAT]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRTWICE]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER2]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRCONTAINER3]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRTHRICEINT]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
+// CHECK-NOT: attributes [[ATTRYETANOTHERNORMAL]] = { {{.*}}optnone{{.*}} }
Index: test/Driver/hexagon-toolchain-elf.c
===
--- test/Driver/hexagon-toolchain-elf.c
+++ test/Driver/hexagon-toolchain-elf.c
@@ -41,7 +41,7 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK012 %s
 // CHECK012: "-cc1"
-// CHECK012-DAG-NOT: "-internal-isystem"
+// CHECK012-NOT: "-internal-isystem"
 // CHECK012-DAG: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/include"
 
 // RUN: %clangxx -### -target hexagon-unknown-elf -fno-integrated-as\
@@ -51,8 +51,8 @@
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK013 %s
 // CHECK013: "-cc1"
-// CHECK013-DAG-NOT: "-internal-isystem"
-// CHECK013-DAG-NOT: "-internal-externc-isystem"
+// CHECK013-NOT: "-internal-isystem"
+// CHECK013-NOT: "-internal-externc-isystem"
 
 // -
 // Test -mcpu= -mv
Index: test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
===
--- test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
+++ test/CodeGenOpenCL/amdgpu-num-gpr-attr.cl
@@ -40,8 +40,8 @@
 // X86-NOT: "amdgpu_num_vgpr"
 // X86-NOT: "amdgpu_num_sgpr"
 
-// CHECK-DAG-NOT: "amdgpu_num_vgpr"="0"
-// CHECK-DAG-NOT: "amdgpu_num_sgpr"="0"
+// CHECK-NOT: "amdgpu_num_vgpr"="0"
+// CHECK-NOT: "amdgpu_num_sgpr"="0"
 // CHECK-DAG: attributes [[ATTR_VGPR64]] = { nounwind "amdgpu_num_vgpr"="64"
 // CHECK-DAG: attributes [[ATTR_SGPR32]] = { nounwind "amdgpu_num_sgpr"="32"
 // CHECK-DAG: attributes [[ATTR_VGPR64_SGPR32]] = { nounwind "amdgpu_num_sgpr"="32" "amdgpu_num_vgpr"="64"
Index: test/CodeGen/alias.c
===
--- test/CodeGen/alias.c
+++ test/CodeGen/alias.c
@@ -24,20 +24,20 @@
 // CHECKBASIC-DAG: @__mod_usb_device_table = alias i32, getelementptr inbounds ([8 x i32], [8 x i32]* @wacom_usb_ids, i32 0, i32 0)
 // CHECKASM-DAG: .globl __mod_usb_device_table
 // CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids
-// CHECKASM-DAG-NOT: .size __mod_usb_device_table
+// CHECKASM-NOT: .size __mod_usb_device_table
 
 extern int g1;
 extern int g1 __attribute((alias("g0")));
 // CHECKBASIC-DAG: @g1 = alias i32, i32* @g0
 // CHECKASM-DAG: .globl g1
 // CHECKASM-DAG: g1 = g0
-// CHECKASM-DAG-NOT: .size g1
+// CHECKASM-NOT: .size g1
 
 extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
 // CHECKBASIC-DAG: @__libc_errno = thread_local alias i32, i32* @TL_WITH_ALIAS
 // 

Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.

2016-02-24 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:184
@@ -144,21 +183,3 @@
 
-  // Determine if the class subclasses NSObject.
-  IdentifierInfo* NSObjectII = ("NSObject");
-  IdentifierInfo* SenTestCaseII = ("SenTestCase");
-
-  for ( ; ID ; ID = ID->getSuperClass()) {
-IdentifierInfo *II = ID->getIdentifier();
-
-if (II == NSObjectII)
-  break;
-
-// FIXME: For now, ignore classes that subclass SenTestCase, as these don't
-// need to implement -dealloc.  They implement tear down in another way,
-// which we should try and catch later.
-//  http://llvm.org/bugs/show_bug.cgi?id=3187
-if (II == SenTestCaseII)
-  return;
-  }
-
-  if (!ID)
+  if (isSuppressedClass(ID))
 return;

I've changed the method name to 'classHasSeparateTeardown()'.


Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:249
@@ +248,3 @@
+// in that location has not changed.
+State = State->bindLoc(LValLoc.getValue(), InitialVal,
+   /*notifyChanges*/false);

I've removed this. It is not needed now that the program state is a map from 
instance symbols to sets of initial field values that must be released.


Comment at: lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp:383
@@ +382,3 @@
+// at, for example, both a return and at the end of of the function.
+State = State->remove(IvarSymbol);
+

I've added an assertion to catch when these aren't being removed. (You were 
right, they weren't always.)


http://reviews.llvm.org/D17511



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


Re: [PATCH] D17511: [analyzer] Make ObjCDeallocChecker path sensitive.

2016-02-24 Thread Devin Coughlin via cfe-commits
dcoughlin updated this revision to Diff 48995.
dcoughlin marked 8 inline comments as done.
dcoughlin added a comment.

This update addresses Anna's review comments. The big change is that the 
program state now maps instance symbols to sets of initial ivar symbols that 
must be released. (Rather than just storing the set, as before). With this 
approach we don't need to play the trick of explicitly binding the initial 
field symbols in the store to get notified that they escape when the instance 
escapes. Instead, we can look up the instance in the map when it escapes and 
remove the entire set.

I've also fixed a leak where we weren't removing values properly from the set 
that must be released and fixed a false positive so we no longer warn about a 
missing release when the field is known to be nil.


http://reviews.llvm.org/D17511

Files:
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  test/Analysis/DeallocMissingRelease.m
  test/Analysis/MissingDealloc.m
  test/Analysis/PR2978.m
  test/Analysis/properties.m

Index: test/Analysis/properties.m
===
--- test/Analysis/properties.m
+++ test/Analysis/properties.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s
 
 void clang_analyzer_eval(int);
 
@@ -22,6 +22,7 @@
 -(id)copy;
 -(id)retain;
 -(oneway void)release;
+-(void)dealloc;
 @end
 @interface NSString : NSObject 
 - (NSUInteger)length;
@@ -138,6 +139,14 @@
 
 @implementation Person
 @synthesize name = _name;
+
+-(void)dealloc {
+#if !__has_feature(objc_arc)
+  self.name = [[NSString alloc] init]; // expected-warning {{leak}}
+
+  [super dealloc]; // expected-warning {{The '_name' ivar in 'Person' was retained by a synthesized property but not released before '[super dealloc]}}
+#endif
+}
 @end
 
 #if !__has_feature(objc_arc)
Index: test/Analysis/PR2978.m
===
--- test/Analysis/PR2978.m
+++ test/Analysis/PR2978.m
@@ -5,7 +5,7 @@
 
 @interface NSObject
 - (void)release;
-- dealloc;
+- (void)dealloc;
 @end
 
 @interface MyClass : NSObject {
@@ -19,55 +19,97 @@
   id _M;
   id _P;
   id _Q;
+  id _R;
+  id _S;
   id _V;
   id _W;
+
+  MyClass *_other;
+
+  id _nonPropertyIvar;
 }
 @property(retain) id X;
 @property(retain) id Y;
 @property(assign) id Z;
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
-@property(weak) id P; // expected-warning {{'_P' instance variable in 'MyClass' was not retained by a synthesized property but was released in 'dealloc'}}
+@property(weak) id P;
 @property(weak) id Q;
+@property(retain) id R;
+@property(weak, readonly) id S;
+
+@property(assign, readonly) id T; // Shadowed in class extension
+@property(assign) id U;
 
 @property(retain) id V;
 @property(retain) id W;
 -(id) O;
 -(void) setO: (id) arg;
 @end
 
+@interface MyClass ()
+// Shadows T to make it readwrite internally but readonly externally.
+@property(assign, readwrite) id T;
+@end
+
 @implementation MyClass
 @synthesize X = _X;
-@synthesize Y = _Y; // expected-warning{{The '_Y' instance variable in 'MyClass' was retained by a synthesized property but was not released in 'dealloc'}}
-@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable in 'MyClass' was not retained by a synthesized property but was released in 'dealloc'}}
+@synthesize Y = _Y;
+@synthesize Z = _Z;
 @synthesize K = _K;
-@synthesize L = _L; // no-warning
-@synthesize N = _N; // no-warning
+@synthesize L = _L;
+@synthesize N = _N;
 @synthesize M = _M;
-@synthesize Q = _Q; // expected-warning {{'_Q' instance variable in 'MyClass' was not retained by a synthesized property but was released in 'dealloc'}}
+@synthesize Q = _Q;
+@synthesize R = _R;
 @synthesize V = _V;
-@synthesize W = _W; // expected-warning{{The '_W' instance variable in 'MyClass' was retained by a synthesized property but was not released in 'dealloc'}}
+@synthesize W = _W;
 
 -(id) O{ return 0; }
 -(void) setO:(id)arg { }
 
-- (id)dealloc
+
+-(void) releaseInHelper {
+  [_R release]; // no-warning
+  _R = @"Hi";
+}
+
+- (void)dealloc
 {
+
   [_X release];
-  [_Z release];
+  [_Z release]; // expected-warning{{The '_Z' ivar in 'MyClass' was synthesized for an assign, readwrite property but was released in 'dealloc'}}
+  [_T 

[clang-tools-extra] r261814 - check-clang-tools: Introduce the feature "target-headers".

2016-02-24 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Feb 24 19:12:57 2016
New Revision: 261814

URL: http://llvm.org/viewvc/llvm-project?rev=261814=rev
Log:
check-clang-tools: Introduce the feature "target-headers".

For now, it just detects that host is non-Windows and target is msvc.

FIXME: It should be probable for cross compilations. Detect whether target's 
headers would be available.

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
clang-tools-extra/trunk/test/lit.cfg

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=261814=261813=261814=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp 
Wed Feb 24 19:12:57 2016
@@ -1,4 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 
-isystem %S/Inputs/Headers
+// REQUIRES: target-headers
 
 #include 
 #include 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=261814=261813=261814=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp 
Wed Feb 24 19:12:57 2016
@@ -1,4 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 
-isystem %S/Inputs/Headers
+// REQUIRES: target-headers
 
 #include 
 #include 

Modified: clang-tools-extra/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=261814=261813=261814=diff
==
--- clang-tools-extra/trunk/test/lit.cfg (original)
+++ clang-tools-extra/trunk/test/lit.cfg Wed Feb 24 19:12:57 2016
@@ -189,6 +189,12 @@ if not platform.system() in ['Windows']
 if platform.system() not in ['Windows']:
 config.available_features.add('ansi-escape-sequences')
 
+# Set if default-target's system headers available.
+# For example in general, MS headers are supposed unavailable on non-Windows 
hosts.
+# FIXME: It should be probable for cross compilations.
+if not (platform.system() not in ['Windows'] and re.match(r'.*-win32$', 
config.target_triple)):
+config.available_features.add('target-headers')
+
 check_clang_tidy = os.path.join(
 config.test_source_root, "clang-tidy", "check_clang_tidy.py")
 config.substitutions.append(


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


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
The build should be fixed, but the tests for this check fail. I'll fix the
tests tomorrow.

On Thu, Feb 25, 2016 at 12:46 AM, Alexander Kornienko 
wrote:

> I have a couple ideas, will try on the buildbot, since I don't have MSVC
> to try fixes locally.
>
> On Wed, Feb 24, 2016 at 10:27 PM, Alexander Kornienko 
> wrote:
>
>> Looking into this...
>>
>>
>> On Wed, Feb 24, 2016 at 10:21 PM, Nico Weber  wrote:
>>
>>> This broke the Windows bot:
>>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
>>>
>>> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
>>> /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
>>> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
>>> -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
>>> -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
>>> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
>>> /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
>>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
>>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
>>> -Itools\clang\include -Iinclude
>>> -ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
>>> /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
>>> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
>>> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
>>> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
>>> -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
>>> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
>>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>>> /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
>>> /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
>>> /FS -c
>>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
>>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
>>> : error C2668:
>>> 'llvm::StringMap::StringMap' : ambiguous
>>> call to overloaded function
>>>
>>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
>>> could be
>>> 'llvm::StringMap::StringMap(const
>>> llvm::StringMap &)'
>>>
>>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
>>> or
>>> 'llvm::StringMap::StringMap(llvm::StringMap
>>> &&)'
>>>
>>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
>>> or
>>> 'llvm::StringMap::StringMap(std::initializer_list>)'
>>> with
>>> [
>>> ValueTy=std::string
>>> ]
>>>
>>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
>>> or
>>> 'llvm::StringMap::StringMap(AllocatorTy)'
>>> with
>>> [
>>> AllocatorTy=llvm::MallocAllocator
>>> ]
>>>
>>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
>>> or
>>> 'llvm::StringMap::StringMap(unsigned
>>> int)'
>>> while trying to match the argument list '(initializer-list)'
>>>Creating library lib\libclang.lib and object lib\libclang.exp
>>>
>>>
>>> On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: alexfh
 Date: Wed Feb 24 07:36:34 2016
 New Revision: 261738

 URL: http://llvm.org/viewvc/llvm-project?rev=261738=rev
 Log:
 [clang-tidy] introduce modernize-deprecated-headers check

 Summary:
 This patch introduces the modernize-deprecated-headers check, which is
 supposed to replace deprecated C library headers with the C++ STL-ones.

 For information see documentation; for exmaples see the test cases.

 Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh

 Subscribers: cfe-commits

 Patch by Kirill Bobyrev!

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

 Added:

 clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

 clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h

 clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst

 clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp

 

[clang-tools-extra] r261811 - [clang-tidy] Another attempt to fix MSVC build

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 18:39:11 2016
New Revision: 261811

URL: http://llvm.org/viewvc/llvm-project?rev=261811=rev
Log:
[clang-tidy] Another attempt to fix MSVC build

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261811=261810=261811=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed 
Feb 24 18:39:11 2016
@@ -48,22 +48,26 @@ void DeprecatedHeadersCheck::registerPPC
 
 IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck ,
  LangOptions LangOpts)
-: Check(Check), LangOpts(LangOpts),
-  CStyledHeaderToCxx{{"assert.h", "cassert"}, {"complex.h", "ccomplex"},
- {"ctype.h", "cctype"},   {"errno.h", "cerrno"},
- {"float.h", "cfloat"},   {"inttypes.h", "cinttypes"},
- {"iso646.h", "ciso646"}, {"limits.h", "climits"},
- {"locale.h", "clocale"}, {"math.h", "cmath"},
- {"setjmp.h", "csetjmp"}, {"signal.h", "csignal"},
- {"stdarg.h", "cstdarg"}, {"stddef.h", "cstddef"},
- {"stdint.h", "cstdint"}, {"stdio.h", "cstdio"},
- {"stdlib.h", "cstdlib"}, {"string.h", "cstring"},
- {"time.h", "ctime"}, {"wchar.h", "cwchar"},
- {"wctype.h", "cwctype"}} {
+: Check(Check), LangOpts(LangOpts) {
+  for (const auto  :
+   std::vector>(
+   {{"assert.h", "cassert"}, {"complex.h", "ccomplex"},
+{"ctype.h", "cctype"},   {"errno.h", "cerrno"},
+{"float.h", "cfloat"},   {"inttypes.h", "cinttypes"},
+{"iso646.h", "ciso646"}, {"limits.h", "climits"},
+{"locale.h", "clocale"}, {"math.h", "cmath"},
+{"setjmp.h", "csetjmp"}, {"signal.h", "csignal"},
+{"stdarg.h", "cstdarg"}, {"stddef.h", "cstddef"},
+{"stdint.h", "cstdint"}, {"stdio.h", "cstdio"},
+{"stdlib.h", "cstdlib"}, {"string.h", "cstring"},
+{"time.h", "ctime"}, {"wchar.h", "cwchar"},
+{"wctype.h", "cwctype"}})) {
+CStyledHeaderToCxx.insert(KeyValue);
+  }
   // Add C++ 11 headers.
   if (LangOpts.CPlusPlus11) {
 for (const auto  :
- std::vector>(
+ std::vector>(
  {{"fenv.h", "cfenv"},
   {"stdalign.h", "cstdalign"},
   {"stdbool.h", "cstdbool"},


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


[clang-tools-extra] r261806 - Trying to fix MSVC build

2016-02-24 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Feb 24 17:48:24 2016
New Revision: 261806

URL: http://llvm.org/viewvc/llvm-project?rev=261806=rev
Log:
Trying to fix MSVC build

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp?rev=261806=261805=261806=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp Wed 
Feb 24 17:48:24 2016
@@ -49,36 +49,27 @@ void DeprecatedHeadersCheck::registerPPC
 IncludeModernizePPCallbacks::IncludeModernizePPCallbacks(ClangTidyCheck ,
  LangOptions LangOpts)
 : Check(Check), LangOpts(LangOpts),
-  CStyledHeaderToCxx({{"assert.h", "cassert"},
-  {"complex.h", "ccomplex"},
-  {"ctype.h", "cctype"},
-  {"errno.h", "cerrno"},
-  {"float.h", "cfloat"},
-  {"inttypes.h", "cinttypes"},
-  {"iso646.h", "ciso646"},
-  {"limits.h", "climits"},
-  {"locale.h", "clocale"},
-  {"math.h", "cmath"},
-  {"setjmp.h", "csetjmp"},
-  {"signal.h", "csignal"},
-  {"stdarg.h", "cstdarg"},
-  {"stddef.h", "cstddef"},
-  {"stdint.h", "cstdint"},
-  {"stdio.h", "cstdio"},
-  {"stdlib.h", "cstdlib"},
-  {"string.h", "cstring"},
-  {"time.h", "ctime"},
-  {"wchar.h", "cwchar"},
-  {"wctype.h", "cwctype"}}) {
+  CStyledHeaderToCxx{{"assert.h", "cassert"}, {"complex.h", "ccomplex"},
+ {"ctype.h", "cctype"},   {"errno.h", "cerrno"},
+ {"float.h", "cfloat"},   {"inttypes.h", "cinttypes"},
+ {"iso646.h", "ciso646"}, {"limits.h", "climits"},
+ {"locale.h", "clocale"}, {"math.h", "cmath"},
+ {"setjmp.h", "csetjmp"}, {"signal.h", "csignal"},
+ {"stdarg.h", "cstdarg"}, {"stddef.h", "cstddef"},
+ {"stdint.h", "cstdint"}, {"stdio.h", "cstdio"},
+ {"stdlib.h", "cstdlib"}, {"string.h", "cstring"},
+ {"time.h", "ctime"}, {"wchar.h", "cwchar"},
+ {"wctype.h", "cwctype"}} {
   // Add C++ 11 headers.
   if (LangOpts.CPlusPlus11) {
-for (const auto  : std::vector>(
+for (const auto  :
+ std::vector>(
  {{"fenv.h", "cfenv"},
   {"stdalign.h", "cstdalign"},
   {"stdbool.h", "cstdbool"},
   {"tgmath.h", "ctgmath"},
   {"uchar.h", "cuchar"}})) {
-  CStyledHeaderToCxx.insert(it);
+  CStyledHeaderToCxx.insert(KeyValue);
 }
   }
 }


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


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
I have a couple ideas, will try on the buildbot, since I don't have MSVC to
try fixes locally.

On Wed, Feb 24, 2016 at 10:27 PM, Alexander Kornienko 
wrote:

> Looking into this...
>
>
> On Wed, Feb 24, 2016 at 10:21 PM, Nico Weber  wrote:
>
>> This broke the Windows bot:
>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
>>
>> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
>> /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
>> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
>> -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
>> -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
>> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
>> /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
>> -Itools\clang\include -Iinclude
>> -ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
>> /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
>> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
>> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
>> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
>> -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
>> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>> /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
>> /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
>> /FS -c
>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
>> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
>> : error C2668:
>> 'llvm::StringMap::StringMap' : ambiguous
>> call to overloaded function
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
>> could be
>> 'llvm::StringMap::StringMap(const
>> llvm::StringMap &)'
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
>> or
>> 'llvm::StringMap::StringMap(llvm::StringMap
>> &&)'
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
>> or
>> 'llvm::StringMap::StringMap(std::initializer_list>)'
>> with
>> [
>> ValueTy=std::string
>> ]
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
>> or
>> 'llvm::StringMap::StringMap(AllocatorTy)'
>> with
>> [
>> AllocatorTy=llvm::MallocAllocator
>> ]
>>
>> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
>> or
>> 'llvm::StringMap::StringMap(unsigned
>> int)'
>> while trying to match the argument list '(initializer-list)'
>>Creating library lib\libclang.lib and object lib\libclang.exp
>>
>>
>> On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Wed Feb 24 07:36:34 2016
>>> New Revision: 261738
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=261738=rev
>>> Log:
>>> [clang-tidy] introduce modernize-deprecated-headers check
>>>
>>> Summary:
>>> This patch introduces the modernize-deprecated-headers check, which is
>>> supposed to replace deprecated C library headers with the C++ STL-ones.
>>>
>>> For information see documentation; for exmaples see the test cases.
>>>
>>> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>>>
>>> Subscribers: cfe-commits
>>>
>>> Patch by Kirill Bobyrev!
>>>
>>> Differential Revision: http://reviews.llvm.org/D17484
>>>
>>> Added:
>>>
>>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>>>
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>>
>>> Modified: 

Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261803: Fix assertion failure on MaybeODRUseExprs. (authored 
by mren).

Changed prior to commit:
  http://reviews.llvm.org/D17576?vs=48963=48986#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17576

Files:
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());


Index: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261803 - Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Feb 24 17:05:43 2016
New Revision: 261803

URL: http://llvm.org/viewvc/llvm-project?rev=261803=rev
Log:
Fix assertion failure on MaybeODRUseExprs.

In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.

This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.

Part of PR13986.
rdar://24480205

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

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=261803=261802=261803=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Feb 24 17:05:43 2016
@@ -2110,6 +2110,8 @@ Decl *TemplateDeclInstantiator::VisitNon
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());

Modified: cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp?rev=261803=261802=261803=diff
==
--- cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments-cxx0x.cpp Wed Feb 24 17:05:43 
2016
@@ -75,3 +75,13 @@ namespace rdar23810407 {
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}


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


r261798 - Minor cleanup of Sema::CheckEnableIf. NFC.

2016-02-24 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Feb 24 16:31:14 2016
New Revision: 261798

URL: http://llvm.org/viewvc/llvm-project?rev=261798=rev
Log:
Minor cleanup of Sema::CheckEnableIf. NFC.

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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=261798=261797=261798=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 24 16:31:14 2016
@@ -5958,34 +5958,27 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
   bool ContainsValueDependentExpr = false;
 
   // Convert the arguments.
-  for (unsigned i = 0, e = Args.size(); i != e; ++i) {
-if (i == 0 && !MissingImplicitThis && isa(Function) &&
+  for (unsigned I = 0, E = Args.size(); I != E; ++I) {
+ExprResult R;
+if (I == 0 && !MissingImplicitThis && isa(Function) &&
 !cast(Function)->isStatic() &&
 !isa(Function)) {
   CXXMethodDecl *Method = cast(Function);
-  ExprResult R =
-PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr,
-Method, Method);
-  if (R.isInvalid()) {
-InitializationFailed = true;
-break;
-  }
-  ContainsValueDependentExpr |= R.get()->isValueDependent();
-  ConvertedArgs.push_back(R.get());
+  R = PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/nullptr,
+  Method, Method);
 } else {
-  ExprResult R =
-PerformCopyInitialization(InitializedEntity::InitializeParameter(
-Context,
-Function->getParamDecl(i)),
-  SourceLocation(),
-  Args[i]);
-  if (R.isInvalid()) {
-InitializationFailed = true;
-break;
-  }
-  ContainsValueDependentExpr |= R.get()->isValueDependent();
-  ConvertedArgs.push_back(R.get());
+  R = PerformCopyInitialization(InitializedEntity::InitializeParameter(
+Context, Function->getParamDecl(I)),
+SourceLocation(), Args[I]);
 }
+
+if (R.isInvalid()) {
+  InitializationFailed = true;
+  break;
+}
+
+ContainsValueDependentExpr |= R.get()->isValueDependent();
+ConvertedArgs.push_back(R.get());
   }
 
   if (InitializationFailed || Trap.hasErrorOccurred())


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


r261784 - Revert "Don't convert a char to a const char *"

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 16:07:26 2016
New Revision: 261784

URL: http://llvm.org/viewvc/llvm-project?rev=261784=rev
Log:
Revert "Don't convert a char to a const char *"

This reverts commit r261780.  It turns out the original code was just
fine.  An overload for ltrim which takes char was added but the Doxygen
docs haven't seemed to pick it up.

Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261784=261783=261784=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 16:07:26 2016
@@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
 
   // Find the first non-whitespace character, so that we can make the
   // diagnostic more succinct.
-  StringRef Msg = StringRef(Message).ltrim(" ");
+  StringRef Msg = StringRef(Message).ltrim(' ');
 
   if (isWarning)
 Diag(Tok, diag::pp_hash_warning) << Msg;


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


Re: r261780 - Don't convert a char to a const char *

2016-02-24 Thread David Majnemer via cfe-commits
Ah, good point.  I assumed that the report was valid because they aren't
showing up in the doxygen:
http://llvm.org/docs/doxygen/html/classllvm_1_1StringRef.html

I'll go ahead and revert.

On Wed, Feb 24, 2016 at 2:06 PM, Benjamin Kramer 
wrote:

> Were you able to reproduce this build failure? ltrim has overloads for
> "char" and "StringRef", the former being very new. From the error
> message I suspect out of sync LLVM and Clang checkouts.
>
> On Wed, Feb 24, 2016 at 10:55 PM, David Majnemer via cfe-commits
>  wrote:
> > Author: majnemer
> > Date: Wed Feb 24 15:55:58 2016
> > New Revision: 261780
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=261780=rev
> > Log:
> > Don't convert a char to a const char *
> >
> > This fixes PR26728.
> >
> > Modified:
> > cfe/trunk/lib/Lex/PPDirectives.cpp
> >
> > Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261780=261779=261780=diff
> >
> ==
> > --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> > +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 15:55:58 2016
> > @@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
> >
> >// Find the first non-whitespace character, so that we can make the
> >// diagnostic more succinct.
> > -  StringRef Msg = StringRef(Message).ltrim(' ');
> > +  StringRef Msg = StringRef(Message).ltrim(" ");
> >
> >if (isWarning)
> >  Diag(Tok, diag::pp_hash_warning) << Msg;
> >
> >
> > ___
> > 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] Canonicalize UnaryTransformType types when they don't have a known underlying type

2016-02-24 Thread Richard Smith via cfe-commits
A UnaryTransformType should itself be a canonical type if its BaseType
is dependent -- that is, its CanonicalType should be QualType(this,
0). It should definitely not be treated as being canonically
equivalent to its BaseType.

On Wed, Feb 24, 2016 at 2:03 PM, Vassil Vassilev  wrote:
> ping...
>
> On 07/01/16 08:09, Vassil Vassilev via cfe-commits wrote:
>
> Hi all,
>   I am attaching a fix for https://llvm.org/bugs/show_bug.cgi?id=26014
>   To which type should I tie the canonical type of the unknown underlying
> type? Currently it is tied to its BaseType.
>
>   Please review.
> --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


r261782 - Fix build by using hasFlag instead of hasArg.

2016-02-24 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Feb 24 16:03:06 2016
New Revision: 261782

URL: http://llvm.org/viewvc/llvm-project?rev=261782=rev
Log:
Fix build by using hasFlag instead of hasArg.

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

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261782=261781=261782=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 24 16:03:06 2016
@@ -4270,8 +4270,8 @@ void Clang::ConstructJob(Compilation ,
 CmdArgs.push_back("-ffunction-sections");
   }
 
-  if (Args.hasArg(options::OPT_fwhole_program_vtables,
-  options::OPT_fno_whole_program_vtables, false)) {
+  if (Args.hasFlag(options::OPT_fwhole_program_vtables,
+   options::OPT_fno_whole_program_vtables, false)) {
 if (!D.isUsingLTO())
   D.Diag(diag::err_drv_argument_only_allowed_with)
   << "-fwhole-program-vtables"


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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits

On 24/02/16 23:03, Richard Smith wrote:

On Wed, Feb 24, 2016 at 2:01 PM, Vassil Vassilev  wrote:

On 24/02/16 22:50, Richard Smith wrote:

On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev 
wrote:

On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
  unsigned I = Record.size();
  Record.push_back(0);

+  auto  = Common->Specializations;
+  auto & =
getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization,
invalidating
+  // *Specializations iterators. Force the deserialization in
advance.
+  llvm::SmallVector Specs;
+  for (auto  : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto  : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
  for (auto  : Specializations) {

... iterate over "Specs" here

auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations
loop.

Done.

+  // *Specializations iterators. Force the deserialization in
advance.

Drop the second sentence of this comment, since it's no longer accurate.

oops... thanks!



You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured
emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Will do. Could you check this patch in meanwhile, please?

r261781. Thanks!

Thanks a lot!



On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev

wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev

wrote:

AFAICT the making a test case independent on STL is the hard part. I
think
it will be always failing due to the relocation of the memory region
of
the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to
the
instability of test cases for UB (especially library UB), we don't
usually
commit test cases for them - we just fix them without tests. About the
only
time I think committing a test is helpful for UB (especially library
UB)
is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it
would
be good to provide/demonstrate your test case, I would not commit the
test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix
without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the
modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil



On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit
one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a
fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some
of
the
specializations need to be deserialized from a third module. This
triggers
an iterator invalidation bug because of the deserialization happening
when
iterating the specializations container itself. This happens only
when
the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug
number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

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



___

r261781 - PR26237: Fix iterator invalidation bug that occurs if serializing

2016-02-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Feb 24 15:59:10 2016
New Revision: 261781

URL: http://llvm.org/viewvc/llvm-project?rev=261781=rev
Log:
PR26237: Fix iterator invalidation bug that occurs if serializing
specializations of a template manages to trigger deserialization of more
specializations of the same template.

No test case provided: this is hard to reliably test due to standard library
differences.

Patch by Vassil Vassilev!

Modified:
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=261781=261780=261781=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Feb 24 15:59:10 2016
@@ -192,8 +192,8 @@ namespace clang {
   return None;
 }
 
-template
-void AddTemplateSpecializations(Decl *D) {
+template
+void AddTemplateSpecializations(DeclTy *D) {
   auto *Common = D->getCommonPtr();
 
   // If we have any lazy specializations, and the external AST source is
@@ -205,8 +205,6 @@ namespace clang {
 assert(!Common->LazySpecializations);
   }
 
-  auto  = Common->Specializations;
-  auto & = getPartialSpecializations(Common);
   ArrayRef LazySpecializations;
   if (auto *LS = Common->LazySpecializations)
 LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
@@ -215,13 +213,15 @@ namespace clang {
   unsigned I = Record.size();
   Record.push_back(0);
 
-  for (auto  : Specializations) {
-auto *D = getSpecializationDecl(Entry);
-assert(D->isCanonicalDecl() && "non-canonical decl in set");
-AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
-  }
-  for (auto  : PartialSpecializations) {
-auto *D = getSpecializationDecl(Entry);
+  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
+  // *Specializations iterators.
+  llvm::SmallVector Specs;
+  for (auto  : Common->Specializations)
+Specs.push_back(getSpecializationDecl(Entry));
+  for (auto  : getPartialSpecializations(Common))
+Specs.push_back(getSpecializationDecl(Entry));
+
+  for (auto *D : Specs) {
 assert(D->isCanonicalDecl() && "non-canonical decl in set");
 AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
   }


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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 2:01 PM, Vassil Vassilev  wrote:
> On 24/02/16 22:50, Richard Smith wrote:
>>
>> On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev 
>> wrote:
>>>
>>> On 24/02/16 02:05, Richard Smith wrote:

 Calling getMostRecentDecl seems like a slightly fragile way to avoid
 iterator invalidation here. Instead...

 @@ -214,6 +212,19 @@ namespace clang {
  unsigned I = Record.size();
  Record.push_back(0);

 +  auto  = Common->Specializations;
 +  auto & =
 getPartialSpecializations(Common);
 +
 +  // AddFirstDeclFromEachModule might trigger deserialization,
 invalidating
 +  // *Specializations iterators. Force the deserialization in
 advance.
 +  llvm::SmallVector Specs;
 +  for (auto  : Specializations)
 + Specs.push_back(getSpecializationDecl(Entry));
 +  for (auto  : PartialSpecializations)
 + Specs.push_back(getSpecializationDecl(Entry));
 +  for (auto *D : Specs)
 + D->getMostRecentDecl();

 ... delete these two lines, and...

 +
  for (auto  : Specializations) {

 ... iterate over "Specs" here

auto *D = getSpecializationDecl(Entry);

 ... and you don't need this line any more.

assert(D->isCanonicalDecl() && "non-canonical decl in set");

 You can then remove the following, identical, PartialSpecializations
 loop.
>>>
>>> Done.
>>
>> +  // *Specializations iterators. Force the deserialization in
>> advance.
>>
>> Drop the second sentence of this comment, since it's no longer accurate.
>
> oops... thanks!
>>
>>
 You also have some tabs in your patch (on the Specs.push_back lines);
>>>
>>> Sorry about the tabs, they came from a brand new VM and unconfigured
>>> emacs.

 please fix those prior to commit. With those changes, this LGTM.
>>>
>>> Would it make sense to ask for commit perms?
>>
>> Yes, please see the instructions here:
>> http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access
>
> Will do. Could you check this patch in meanwhile, please?

r261781. Thanks!

 On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev
 
 wrote:
>
> ping...
>
> On 30/01/16 21:13, Vassil Vassilev wrote:
>
> On 30/01/16 18:36, David Blaikie wrote:
>
>
>
> On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev
> 
> wrote:
>>
>> AFAICT the making a test case independent on STL is the hard part. I
>> think
>> it will be always failing due to the relocation of the memory region
>> of
>> the
>> underlying SmallVector.
>
>
> Sorry, I think I didn't explain myself well. What I mean is - due to
> the
> instability of test cases for UB (especially library UB), we don't
> usually
> commit test cases for them - we just fix them without tests. About the
> only
> time I think committing a test is helpful for UB (especially library
> UB)
> is
> if we have a reliable way to test/catch the UB (eg: the sanitizers or a
> checking STL that fails fast on validation violations). So, while it
> would
> be good to provide/demonstrate your test case, I would not commit the
> test
> case unless it's a minimal reproduction in the presence of one of those
> tools (sanitizers or checking STL) - and would just commit the fix
> without a
> test case, usually.
>
> (I'm not actually reviewing this patch - I don't know much about the
> modules
> code, but just providing a bit of context and first-pass-review)
>
> Got it. Thanks!
> --Vassil
>
>
>> On 30/01/16 17:37, David Blaikie wrote:
>>
>> Yeah, it's good to have a reproduction, but I wouldn't actually commit
>> one
>> - unless you have a checked stl to test against that always fails on
>> possibly-invalidating sequences of operations, then you'd have a
>> fairly
>> simple reproduction
>>
>> On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
>> wrote:
>>>
>>> Sorry.
>>>
>>> Our module builds choke on merging several modules, containing
>>> declarations from STL (we are using libc++, no modulemaps).
>>>
>>> When writing a new module containing the definition of a STL
>>> reverse_iterator, it collects all its template specializations. Some
>>> of
>>> the
>>> specializations need to be deserialized from a third module. This
>>> triggers
>>> an iterator invalidation bug because of the deserialization happening
>>> when
>>> iterating the specializations container itself. This happens only
>>> when
>>> the
>>> container's capacity is exceeded and the relocation invalidates the
>>> iterators and at best causes a 

Re: [PATCH] D17313: [CUDA] Annotate all calls in CUDA device mode as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar abandoned this revision.
jlebar added a comment.

Subsumed by http://reviews.llvm.org/D17056.


http://reviews.llvm.org/D17313



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


Re: [PATCH] Canonicalize UnaryTransformType types when they don't have a known underlying type

2016-02-24 Thread Vassil Vassilev via cfe-commits

ping...
On 07/01/16 08:09, Vassil Vassilev via cfe-commits wrote:

Hi all,
  I am attaching a fix for https://llvm.org/bugs/show_bug.cgi?id=26014
  To which type should I tie the canonical type of the unknown 
underlying type? Currently it is tied to its BaseType.


  Please review.
--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


Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2114
@@ -2113,1 +2113,3 @@
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);

faisalv wrote:
> Looks reasonable to me - since it is consistent with the other changes I had 
> made.  But somewhat orthogonal to your fix, I wouldn't mind Richard 
> commenting on why constant expression evaluation does not have 
> IsPotentiallyEvaluatedContext return false (and avoid adding an entry to 
> MaybeODRUse)
> Also, just as SubstituteDefaultTemplateArgument does, Perhaps we should add 
> an InstantiatingTemplate on the stack that marks this as a substitution into  
> default arguments.  It would be nice if we could refactor both into a call to 
> the same function (i.e SubstittueDefaultTempalteArgument) - but looking at 
> the code for it, that would be a little tricky.
> My 2 cents.
"Potentially evaluated" is a term defined in the standard; it would be 
confusing for us to use it to mean something else. Constant expressions *are* 
evaluated (typically only during compilation), and they can result in odr-use. 
The cases where they don't do so are somewhat specialized.

I don't think we need or want a separate entry on the instantiation stack, as 
we're still instantiating pieces of the same entity, with the same 
instantiation semantics.


http://reviews.llvm.org/D17576



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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits

On 24/02/16 22:50, Richard Smith wrote:

On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev  wrote:

On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
 unsigned I = Record.size();
 Record.push_back(0);

+  auto  = Common->Specializations;
+  auto & = getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization,
invalidating
+  // *Specializations iterators. Force the deserialization in
advance.
+  llvm::SmallVector Specs;
+  for (auto  : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto  : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
 for (auto  : Specializations) {

... iterate over "Specs" here

   auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

   assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations loop.

Done.

+  // *Specializations iterators. Force the deserialization in advance.

Drop the second sentence of this comment, since it's no longer accurate.

oops... thanks!



You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Will do. Could you check this patch in meanwhile, please?



On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev 
wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
wrote:

AFAICT the making a test case independent on STL is the hard part. I
think
it will be always failing due to the relocation of the memory region of
the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to the
instability of test cases for UB (especially library UB), we don't
usually
commit test cases for them - we just fix them without tests. About the
only
time I think committing a test is helpful for UB (especially library UB)
is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it
would
be good to provide/demonstrate your test case, I would not commit the
test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix
without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the
modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil



On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit
one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some of
the
specializations need to be deserialized from a third module. This
triggers
an iterator invalidation bug because of the deserialization happening
when
iterating the specializations container itself. This happens only when
the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

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





From 22c67c14843f119f0cdb64c3fa0ab3ef272f7b5f Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 30 Jan 2016 14:50:06 +0100
Subject: [PATCH] Writing out template specializations 

r261780 - Don't convert a char to a const char *

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 15:55:58 2016
New Revision: 261780

URL: http://llvm.org/viewvc/llvm-project?rev=261780=rev
Log:
Don't convert a char to a const char *

This fixes PR26728.

Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261780=261779=261780=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Feb 24 15:55:58 2016
@@ -1226,7 +1226,7 @@ void Preprocessor::HandleUserDiagnosticD
 
   // Find the first non-whitespace character, so that we can make the
   // diagnostic more succinct.
-  StringRef Msg = StringRef(Message).ltrim(' ');
+  StringRef Msg = StringRef(Message).ltrim(" ");
 
   if (isWarning)
 Diag(Tok, diag::pp_hash_warning) << Msg;


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


r261778 - [CUDA] do not allow attribute-based overloading for __global__ functions.

2016-02-24 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Feb 24 15:54:45 2016
New Revision: 261778

URL: http://llvm.org/viewvc/llvm-project?rev=261778=rev
Log:
[CUDA] do not allow attribute-based overloading for __global__ functions.

__global__ functions are present on both host and device side,
so providing __host__ or __device__ overloads is not going to
do anything useful.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCUDA/function-overload.cu

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=261778=261777=261778=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Feb 24 15:54:45 2016
@@ -1129,7 +1129,10 @@ bool Sema::IsOverload(FunctionDecl *New,
 // Don't allow mixing of HD with other kinds. This guarantees that
 // we have only one viable function with this signature on any
 // side of CUDA compilation .
-if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice))
+// __global__ functions can't be overloaded based on attribute
+// difference because, like HD, they also exist on both sides.
+if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
+(NewTarget == CFT_Global) || (OldTarget == CFT_Global))
   return false;
 
 // Allow overloading of functions with same signature, but

Modified: cfe/trunk/test/SemaCUDA/function-overload.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=261778=261777=261778=diff
==
--- cfe/trunk/test/SemaCUDA/function-overload.cu (original)
+++ cfe/trunk/test/SemaCUDA/function-overload.cu Wed Feb 24 15:54:45 2016
@@ -302,3 +302,13 @@ struct m_hdd {
   __host__ __device__ void operator delete(void *ptr) {} // expected-note 
{{previous declaration is here}}
   __device__ void operator delete(void *ptr) {} // expected-error {{class 
member cannot be redeclared}}
 };
+
+// __global__ functions can't be overloaded based on attribute
+// difference.
+struct G {
+  friend void friend_of_g(G );
+private:
+  int x;
+};
+__global__ void friend_of_g(G ) { int x = arg.x; } // expected-note 
{{previous definition is here}}
+void friend_of_g(G ) { int x = arg.x; } // expected-error {{redefinition 
of 'friend_of_g'}}


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


r261779 - [CUDA] Mark all CUDA device-side function defs, decls, and calls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:55:11 2016
New Revision: 261779

URL: http://llvm.org/viewvc/llvm-project?rev=261779=rev
Log:
[CUDA] Mark all CUDA device-side function defs, decls, and calls as convergent.

Summary:
This is important for e.g. the following case:

  void sync() { __syncthreads(); }
  void foo() {
do_something();
sync();
do_something_else():
  }

Without this change, if the optimizer does not inline sync() (which it
won't because __syncthreads is also marked as noduplicate, for now
anyway), it is free to perform optimizations on sync() that it would not
be able to perform on __syncthreads(), because sync() is not marked as
convergent.

Similarly, we need a notion of convergent calls, since in the case when
we can't statically determine a call's target(s), we need to know
whether it's safe to perform optimizations around the call.

This change is conservative; the optimizer will remove these attrs where
it can, see r260318, r260319.

Reviewers: majnemer

Subscribers: cfe-commits, jhen, echristo, tra

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

Added:
cfe/trunk/test/CodeGenCUDA/convergent.cu
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=261779=261778=261779=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 24 15:55:11 2016
@@ -1595,6 +1595,14 @@ void CodeGenModule::ConstructAttributeLi
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();

Added: cfe/trunk/test/CodeGenCUDA/convergent.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/convergent.cu?rev=261779=auto
==
--- cfe/trunk/test/CodeGenCUDA/convergent.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu Wed Feb 24 15:55:11 2016
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+// DEVICE: attributes [[CALL_ATTR]] = { convergent }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=261779=261778=261779=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Wed Feb 24 15:55:11 2016
@@ -382,7 +382,7 @@ __device__ void df() {
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)


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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261779: [CUDA] Mark all CUDA device-side function defs, 
decls, and calls as convergent. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17056?vs=48261=48979#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17056

Files:
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/test/CodeGenCUDA/convergent.cu
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1595,6 +1595,14 @@
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();
Index: cfe/trunk/test/CodeGenCUDA/convergent.cu
===
--- cfe/trunk/test/CodeGenCUDA/convergent.cu
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3barv
+__host__ __device__ void baz();
+__host__ __device__ void bar() {
+  // DEVICE: call void @_Z3bazv() [[CALL_ATTR:#[0-9]+]]
+  baz();
+}
+
+// DEVICE: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// DEVICE: attributes [[BAZ_ATTR]] = {
+// DEVICE-SAME: convergent
+// DEVICE-SAME: }
+// DEVICE: attributes [[CALL_ATTR]] = { convergent }
+
+// HOST: declare void @_Z3bazv() [[BAZ_ATTR:#[0-9]+]]
+// HOST: attributes [[BAZ_ATTR]] = {
+// HOST-NOT: convergent
+// NOST-SAME: }
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -382,7 +382,7 @@
 // CHECK:   call void @_ZN4NETCC1IJEEEDpT_(%struct.NETC* %netc)
 // CHECK:   call void @_ZN7EC_I_ECC1Ev(%struct.EC_I_EC* %ec_i_ec)
 // CHECK:   call void @_ZN8EC_I_EC1C1Ev(%struct.EC_I_EC1* %ec_i_ec1)
-// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t) #3
+// CHECK:   call void @_ZN5T_V_TC1Ev(%struct.T_V_T* %t_v_t)
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)


Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -1595,6 +1595,14 @@
 }
   }
 
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+// Conservatively, mark all functions and calls in CUDA as convergent
+// (meaning, they may call an intrinsically convergent op, such as
+// __syncthreads(), and so can't have certain optimizations applied around
+// them).  LLVM will remove this attribute where it safely can.
+FuncAttrs.addAttribute(llvm::Attribute::Convergent);
+  }
+
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
   QualType RetTy = FI.getReturnType();
Index: cfe/trunk/test/CodeGenCUDA/convergent.cu
===
--- cfe/trunk/test/CodeGenCUDA/convergent.cu
+++ cfe/trunk/test/CodeGenCUDA/convergent.cu
@@ -0,0 +1,39 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -fcuda-is-device -triple nvptx-nvidia-cuda -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | FileCheck -check-prefix DEVICE %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm \
+// RUN:   -disable-llvm-passes -o - %s | \
+// RUN:  FileCheck -check-prefix HOST %s
+
+#include "Inputs/cuda.h"
+
+// DEVICE: Function Attrs:
+// DEVICE-SAME: convergent
+// DEVICE-NEXT: define void @_Z3foov
+__device__ void foo() {}
+
+// HOST: Function Attrs:
+// HOST-NOT: convergent
+// HOST-NEXT: define void @_Z3barv
+// DEVICE: 

Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261777: [CUDA] Add conversion operators for threadIdx, 
blockIdx, gridDim, and… (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17561?vs=48884=48978#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17561

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

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -245,6 +245,33 @@
 }
 } // namespace std
 
+// Out-of-line implementations from cuda_builtin_vars.h.  These need to come
+// after we've pulled in the definition of uint3 and dim3.
+
+__device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
+__device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 #include <__clang_cuda_cmath.h>
 
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
Index: cfe/trunk/lib/Headers/cuda_builtin_vars.h
===
--- cfe/trunk/lib/Headers/cuda_builtin_vars.h
+++ cfe/trunk/lib/Headers/cuda_builtin_vars.h
@@ -24,10 +24,14 @@
 #ifndef __CUDA_BUILTIN_VARS_H
 #define __CUDA_BUILTIN_VARS_H
 
+// Forward declares from vector_types.h.
+struct uint3;
+struct dim3;
+
 // The file implements built-in CUDA variables using __declspec(property).
 // https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
 // All read accesses of built-in variable fields get converted into calls to a
-// getter function which in turn would call appropriate builtin to fetch the
+// getter function which in turn calls the appropriate builtin to fetch the
 // value.
 //
 // Example:
@@ -63,30 +67,42 @@
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_tid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_tid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_tid_z());
+  // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
 
 struct __cuda_builtin_blockIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ctaid_z());
+  // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
 
 struct __cuda_builtin_blockDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ntid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ntid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ntid_z());
+  // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
 
 struct __cuda_builtin_gridDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_nctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_nctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_nctaid_z());
+  // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17056



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


Re: [PATCH] D17216: Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261773: Make test/Driver/output-file-cleanup.c hermetic. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17216?vs=47857=48975#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17216

Files:
  cfe/trunk/test/Driver/output-file-cleanup.c

Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s


Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17217: Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261774: Bail on compilation as soon as a job fails. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17217?vs=47858=48976#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17217

Files:
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/test/Driver/output-file-cleanup.c

Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList ) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command ,
- const FailingCommandList ) {
-  return !ActionFailed((), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList ,
-  FailingCommandList ) const {
+void Compilation::ExecuteJobs(
+const JobList ,
+SmallVectorImpl> ) const {
   for (const auto  : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -38,14 +38,17 @@
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
 // RUN: touch %t1.c
 // RUN: echo "invalid C code" > %t2.c
 // RUN: touch %t3.c
 // RUN: echo "invalid C code" > %t4.c
 // RUN: touch %t5.c
 // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
-// RUN: test -f %t3.s
+// RUN: test ! -f %t3.s
 // RUN: test ! -f %t4.s
-// RUN: test -f %t5.s
+// RUN: test ! -f %t5.s


Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList ) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command ,
- const FailingCommandList ) {
-  return !ActionFailed((), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList ,
-  FailingCommandList ) const {
+void Compilation::ExecuteJobs(
+const JobList ,
+SmallVectorImpl> ) const {
   for (const auto  : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
Index: cfe/trunk/test/Driver/output-file-cleanup.c
===
--- cfe/trunk/test/Driver/output-file-cleanup.c
+++ cfe/trunk/test/Driver/output-file-cleanup.c
@@ -38,14 +38,17 @@
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
 // RUN: touch %t1.c
 // RUN: echo "invalid C code" > %t2.c
 // RUN: touch 

Re: [PATCH] D17562: [CUDA] Add hack so code which includes "curand.h" doesn't break.

2016-02-24 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261776: [CUDA] Add hack so code which includes "curand.h" 
doesn't break. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D17562?vs=48885=48977#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17562

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

Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -247,5 +247,19 @@
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__


Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -247,5 +247,19 @@
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261777 - [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:33 2016
New Revision: 261777

URL: http://llvm.org/viewvc/llvm-project?rev=261777=rev
Log:
[CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim 
to uint3 and dim3.

Summary:
This lets you write, e.g.

  uint3 a = threadIdx;
  uint3 b = blockIdx;
  dim3 c = gridDim;
  dim3 d = blockDim;

which is legal in nvcc, but was not legal in clang.

The fact that e.g. the type of threadIdx is not actually uint3 is still
observable, but now you have to try to observe it.

Reviewers: tra

Subscribers: echristo, cfe-commits

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
cfe/trunk/lib/Headers/cuda_builtin_vars.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=261777=261776=261777=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Feb 24 15:49:33 
2016
@@ -245,6 +245,33 @@ __device__ static inline void *malloc(si
 }
 } // namespace std
 
+// Out-of-line implementations from cuda_builtin_vars.h.  These need to come
+// after we've pulled in the definition of uint3 and dim3.
+
+__device__ inline __cuda_builtin_threadIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockIdx_t::operator uint3() const {
+  uint3 ret;
+  ret.x = x;
+  ret.y = y;
+  ret.z = z;
+  return ret;
+}
+
+__device__ inline __cuda_builtin_blockDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
+__device__ inline __cuda_builtin_gridDim_t::operator dim3() const {
+  return dim3(x, y, z);
+}
+
 #include <__clang_cuda_cmath.h>
 
 // curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host

Modified: cfe/trunk/lib/Headers/cuda_builtin_vars.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cuda_builtin_vars.h?rev=261777=261776=261777=diff
==
--- cfe/trunk/lib/Headers/cuda_builtin_vars.h (original)
+++ cfe/trunk/lib/Headers/cuda_builtin_vars.h Wed Feb 24 15:49:33 2016
@@ -24,10 +24,14 @@
 #ifndef __CUDA_BUILTIN_VARS_H
 #define __CUDA_BUILTIN_VARS_H
 
+// Forward declares from vector_types.h.
+struct uint3;
+struct dim3;
+
 // The file implements built-in CUDA variables using __declspec(property).
 // https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
 // All read accesses of built-in variable fields get converted into calls to a
-// getter function which in turn would call appropriate builtin to fetch the
+// getter function which in turn calls the appropriate builtin to fetch the
 // value.
 //
 // Example:
@@ -63,6 +67,9 @@ struct __cuda_builtin_threadIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_tid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_tid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_tid_z());
+  // threadIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_threadIdx_t);
 };
@@ -71,6 +78,9 @@ struct __cuda_builtin_blockIdx_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ctaid_z());
+  // blockIdx should be convertible to uint3 (in fact in nvcc, it *is* a
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockIdx_t);
 };
@@ -79,6 +89,9 @@ struct __cuda_builtin_blockDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_ntid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_ntid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_ntid_z());
+  // blockDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_blockDim_t);
 };
@@ -87,6 +100,9 @@ struct __cuda_builtin_gridDim_t {
   __CUDA_DEVICE_BUILTIN(x,__builtin_ptx_read_nctaid_x());
   __CUDA_DEVICE_BUILTIN(y,__builtin_ptx_read_nctaid_y());
   __CUDA_DEVICE_BUILTIN(z,__builtin_ptx_read_nctaid_z());
+  // gridDim should be convertible to dim3 (in fact in nvcc, it *is* a
+  // dim3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator dim3() const;
 private:
   __CUDA_DISALLOW_BUILTINVAR_ACCESS(__cuda_builtin_gridDim_t);
 };


___
cfe-commits 

r261773 - Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:26 2016
New Revision: 261773

URL: http://llvm.org/viewvc/llvm-project?rev=261773=rev
Log:
Make test/Driver/output-file-cleanup.c hermetic.

Summary:
It checks that certain files do and exist, so make sure that they don't
exist at the beginning of the test.

This hid a failure in r260448; to see the failure, you had to run the test with
a clean-ish objdir.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/Driver/output-file-cleanup.c

Modified: cfe/trunk/test/Driver/output-file-cleanup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/output-file-cleanup.c?rev=261773=261772=261773=diff
==
--- cfe/trunk/test/Driver/output-file-cleanup.c (original)
+++ cfe/trunk/test/Driver/output-file-cleanup.c Wed Feb 24 15:49:26 2016
@@ -1,3 +1,5 @@
+// RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
+//
 // RUN: touch %t.s
 // RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
 // RUN: test ! -f %t.s


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


r261774 - Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:28 2016
New Revision: 261774

URL: http://llvm.org/viewvc/llvm-project?rev=261774=rev
Log:
Bail on compilation as soon as a job fails.

Summary:
(Re-land of r260448, which was reverted in r260522 due to a test failure
in Driver/output-file-cleanup.c that only showed up in fresh builds.)

Previously we attempted to be smart; if one job failed, we'd run all
jobs that didn't depend on the failing job.

Problem is, this doesn't work well for e.g. CUDA compilation without
-save-temps.  In this case, the device-side and host-side Assemble
actions (which actually are responsible for preprocess, compile,
backend, and assemble, since we're not saving temps) are necessarily
distinct.  So our clever heuristic doesn't help us, and we repeat every
error message once for host and once for each device arch.

The main effect of this change, other than fixing CUDA, is that if you
pass multiple cc files to one instance of clang and you get a compile
error, we'll stop when the first cc1 job fails.

Reviewers: echristo

Subscribers: cfe-commits, jhen, echristo, tra, rafael

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

Modified:
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/test/Driver/output-file-cleanup.c

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=261774=261773=261774=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 24 15:49:28 2016
@@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Co
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList ) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (const Action *AI : A->inputs())
-if (ActionFailed(AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command ,
- const FailingCommandList ) {
-  return !ActionFailed((), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList ,
-  FailingCommandList ) const {
+void Compilation::ExecuteJobs(
+const JobList ,
+SmallVectorImpl> ) const {
   for (const auto  : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 

Modified: cfe/trunk/test/Driver/output-file-cleanup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/output-file-cleanup.c?rev=261774=261773=261774=diff
==
--- cfe/trunk/test/Driver/output-file-cleanup.c (original)
+++ cfe/trunk/test/Driver/output-file-cleanup.c Wed Feb 24 15:49:28 2016
@@ -38,6 +38,9 @@ invalid C code
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
 
+// When given multiple .c files to compile, clang compiles them in order until
+// it hits an error, at which point it stops.
+//
 // RUN: touch %t1.c
 // RUN: echo "invalid C code" > %t2.c
 // RUN: touch %t3.c
@@ -46,6 +49,6 @@ invalid C code
 // RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c
 // RUN: test -f %t1.s
 // RUN: test ! -f %t2.s
-// RUN: test -f %t3.s
+// RUN: test ! -f %t3.s
 // RUN: test ! -f %t4.s
-// RUN: test -f %t5.s
+// RUN: test ! -f %t5.s


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


r261775 - [CUDA] Don't specify exact line numbers in cuda-builtin-vars.cu.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:30 2016
New Revision: 261775

URL: http://llvm.org/viewvc/llvm-project?rev=261775=rev
Log:
[CUDA] Don't specify exact line numbers in cuda-builtin-vars.cu.

This makes the test less fragile to changes to cuda_builtin_vars.h.

Test-only change.

Modified:
cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu

Modified: cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu?rev=261775=261774=261775=diff
==
--- cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu (original)
+++ cfe/trunk/test/SemaCUDA/cuda-builtin-vars.cu Wed Feb 24 15:49:30 2016
@@ -34,20 +34,20 @@ void kernel(int *out) {
 
   out[i++] = warpSize;
   warpSize = 0; // expected-error {{cannot assign to variable 'warpSize' with 
const-qualified type 'const int'}}
-  // expected-note@cuda_builtin_vars.h:104 {{variable 'warpSize' declared 
const here}}
+  // expected-note@cuda_builtin_vars.h:* {{variable 'warpSize' declared const 
here}}
 
   // Make sure we can't construct or assign to the special variables.
   __cuda_builtin_threadIdx_t x; // expected-error {{calling a private 
constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   __cuda_builtin_threadIdx_t y = threadIdx; // expected-error {{calling a 
private constructor of class '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   threadIdx = threadIdx; // expected-error {{'operator=' is a private member 
of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   void *ptr =  // expected-error {{'operator&' is a private member 
of '__cuda_builtin_threadIdx_t'}}
-  // expected-note@cuda_builtin_vars.h:67 {{declared private here}}
+  // expected-note@cuda_builtin_vars.h:* {{declared private here}}
 
   // Following line should've caused an error as one is not allowed to
   // take address of a built-in variable in CUDA. Alas there's no way


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


r261776 - [CUDA] Add hack so code which includes "curand.h" doesn't break.

2016-02-24 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 24 15:49:31 2016
New Revision: 261776

URL: http://llvm.org/viewvc/llvm-project?rev=261776=rev
Log:
[CUDA] Add hack so code which includes "curand.h" doesn't break.

Summary:
curand.h includes curand_mtgp32_kernel.h.  In host mode, this header
redefines threadIdx and blockDim, giving them their "proper" types of
uint3 and dim3, respectively.

clang has its own plan for these variables -- their types are magic
builtin classes.  So these redefinitions are incompatible.

As a hack, we force-include the offending CUDA header and use #defines
to get the right types for threadIdx and blockDim.

Reviewers: tra

Subscribers: echristo, cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h?rev=261776=261775=261776=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Wed Feb 24 15:49:31 
2016
@@ -247,5 +247,19 @@ __device__ static inline void *malloc(si
 
 #include <__clang_cuda_cmath.h>
 
+// curand_mtgp32_kernel helpfully redeclares blockDim and threadIdx in host
+// mode, giving them their "proper" types of dim3 and uint3.  This is
+// incompatible with the types we give in cuda_builtin_vars.h.  As as hack,
+// force-include the header (nvcc doesn't include it by default) but redefine
+// dim3 and uint3 to our builtin types.  (Thankfully dim3 and uint3 are only
+// used here for the redeclarations of blockDim and threadIdx.)
+#pragma push_macro("dim3")
+#pragma push_macro("uint3")
+#define dim3 __cuda_builtin_blockDim_t
+#define uint3 __cuda_builtin_threadIdx_t
+#include "curand_mtgp32_kernel.h"
+#pragma pop_macro("dim3")
+#pragma pop_macro("uint3")
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__


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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 8:10 AM, Vassil Vassilev  wrote:
>
> On 24/02/16 02:05, Richard Smith wrote:
>>
>> Calling getMostRecentDecl seems like a slightly fragile way to avoid
>> iterator invalidation here. Instead...
>>
>> @@ -214,6 +212,19 @@ namespace clang {
>> unsigned I = Record.size();
>> Record.push_back(0);
>>
>> +  auto  = Common->Specializations;
>> +  auto & = getPartialSpecializations(Common);
>> +
>> +  // AddFirstDeclFromEachModule might trigger deserialization,
>> invalidating
>> +  // *Specializations iterators. Force the deserialization in
>> advance.
>> +  llvm::SmallVector Specs;
>> +  for (auto  : Specializations)
>> + Specs.push_back(getSpecializationDecl(Entry));
>> +  for (auto  : PartialSpecializations)
>> + Specs.push_back(getSpecializationDecl(Entry));
>> +  for (auto *D : Specs)
>> + D->getMostRecentDecl();
>>
>> ... delete these two lines, and...
>>
>> +
>> for (auto  : Specializations) {
>>
>> ... iterate over "Specs" here
>>
>>   auto *D = getSpecializationDecl(Entry);
>>
>> ... and you don't need this line any more.
>>
>>   assert(D->isCanonicalDecl() && "non-canonical decl in set");
>>
>> You can then remove the following, identical, PartialSpecializations loop.
>
> Done.

+  // *Specializations iterators. Force the deserialization in advance.

Drop the second sentence of this comment, since it's no longer accurate.

>> You also have some tabs in your patch (on the Specs.push_back lines);
>
> Sorry about the tabs, they came from a brand new VM and unconfigured emacs.
>>
>> please fix those prior to commit. With those changes, this LGTM.
>
> Would it make sense to ask for commit perms?

Yes, please see the instructions here:
http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

>> On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev 
>> wrote:
>>>
>>> ping...
>>>
>>> On 30/01/16 21:13, Vassil Vassilev wrote:
>>>
>>> On 30/01/16 18:36, David Blaikie wrote:
>>>
>>>
>>>
>>> On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
>>> wrote:

 AFAICT the making a test case independent on STL is the hard part. I
 think
 it will be always failing due to the relocation of the memory region of
 the
 underlying SmallVector.
>>>
>>>
>>> Sorry, I think I didn't explain myself well. What I mean is - due to the
>>> instability of test cases for UB (especially library UB), we don't
>>> usually
>>> commit test cases for them - we just fix them without tests. About the
>>> only
>>> time I think committing a test is helpful for UB (especially library UB)
>>> is
>>> if we have a reliable way to test/catch the UB (eg: the sanitizers or a
>>> checking STL that fails fast on validation violations). So, while it
>>> would
>>> be good to provide/demonstrate your test case, I would not commit the
>>> test
>>> case unless it's a minimal reproduction in the presence of one of those
>>> tools (sanitizers or checking STL) - and would just commit the fix
>>> without a
>>> test case, usually.
>>>
>>> (I'm not actually reviewing this patch - I don't know much about the
>>> modules
>>> code, but just providing a bit of context and first-pass-review)
>>>
>>> Got it. Thanks!
>>> --Vassil
>>>
>>>

 On 30/01/16 17:37, David Blaikie wrote:

 Yeah, it's good to have a reproduction, but I wouldn't actually commit
 one
 - unless you have a checked stl to test against that always fails on
 possibly-invalidating sequences of operations, then you'd have a fairly
 simple reproduction

 On Jan 30, 2016 8:23 AM, "Vassil Vassilev" 
 wrote:
>
> Sorry.
>
> Our module builds choke on merging several modules, containing
> declarations from STL (we are using libc++, no modulemaps).
>
> When writing a new module containing the definition of a STL
> reverse_iterator, it collects all its template specializations. Some of
> the
> specializations need to be deserialized from a third module. This
> triggers
> an iterator invalidation bug because of the deserialization happening
> when
> iterating the specializations container itself. This happens only when
> the
> container's capacity is exceeded and the relocation invalidates the
> iterators and at best causes a crash (see valgrind reports in the bug
> report). Unfortunately I haven't been able to make the reproducer
> independent on STL.
>
> --Vassil
>
> On 30/01/16 17:08, David Blaikie wrote:
>
> It might be handy to give an overview of the issue in the review (&
> certainly in the commit) message rather than only citing the bug number
>
> On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
>  wrote:
>>
>> Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237
>>

Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

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

OK.


http://reviews.llvm.org/D17561



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


Re: [PATCH] D17217: Bail on compilation as soon as a job fails.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Upon further consideration, I'm going to push this with post-submit review -- 
the only difference from what echristo reviewed is an obvious change to 
output-file-cleanup.c.


http://reviews.llvm.org/D17217



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


Re: [PATCH] D17056: Mark all CUDA device-side function defs and decls as convergent.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Friendly ping -- are we happy with this?


http://reviews.llvm.org/D17056



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


Re: [PATCH] D17216: Make test/Driver/output-file-cleanup.c hermetic.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Upon further consideration, I think I'm going to push this with post-submit 
review, as we know this test is quite broken, and I think this change is 
unlikely to make the situation worse.


http://reviews.llvm.org/D17216



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


Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Alexander Kornienko via cfe-commits
Looking into this...

On Wed, Feb 24, 2016 at 10:21 PM, Nico Weber  wrote:

> This broke the Windows bot:
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio
>
> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
> /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
> -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
> -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
> /Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
> -ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
> -Itools\clang\include -Iinclude
> -ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
> /showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
> -D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> /Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
> /Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
> /FS -c
> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
> D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
> : error C2668:
> 'llvm::StringMap::StringMap' : ambiguous
> call to overloaded function
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
> could be
> 'llvm::StringMap::StringMap(const
> llvm::StringMap &)'
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
> or
> 'llvm::StringMap::StringMap(llvm::StringMap
> &&)'
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
> or
> 'llvm::StringMap::StringMap(std::initializer_list>)'
> with
> [
> ValueTy=std::string
> ]
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
> or
> 'llvm::StringMap::StringMap(AllocatorTy)'
> with
> [
> AllocatorTy=llvm::MallocAllocator
> ]
>
> D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
> or
> 'llvm::StringMap::StringMap(unsigned
> int)'
> while trying to match the argument list '(initializer-list)'
>Creating library lib\libclang.lib and object lib\libclang.exp
>
>
> On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Wed Feb 24 07:36:34 2016
>> New Revision: 261738
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261738=rev
>> Log:
>> [clang-tidy] introduce modernize-deprecated-headers check
>>
>> Summary:
>> This patch introduces the modernize-deprecated-headers check, which is
>> supposed to replace deprecated C library headers with the C++ STL-ones.
>>
>> For information see documentation; for exmaples see the test cases.
>>
>> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>>
>> Subscribers: cfe-commits
>>
>> Patch by Kirill Bobyrev!
>>
>> Differential Revision: http://reviews.llvm.org/D17484
>>
>> Added:
>>
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>>
>> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>>
>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>>
>> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738=261737=261738=diff
>>
>> ==
>> --- 

Re: [clang-tools-extra] r261738 - [clang-tidy] introduce modernize-deprecated-headers check

2016-02-24 Thread Nico Weber via cfe-commits
This broke the Windows bot:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10093/steps/build%20stage%201/logs/stdio

FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP /DWIN32
/D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624
-wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
-wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Oi
/Zc:rvalueCast /MD /O2 /Ob2 -Itools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize
-ID:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-ID:\buildslave\clang-x64-ninja-win7\llvm\include-UNDEBUG  /EHs-c- /GR-
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
-D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\DeprecatedHeadersCheck.cpp.obj
/Fdtools\clang\tools\extra\clang-tidy\modernize\CMakeFiles\clangTidyModernizeModule.dir\
/FS -c
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp
D:\buildslave\clang-x64-ninja-win7\llvm\tools\clang\tools\extra\clang-tidy\modernize\DeprecatedHeadersCheck.cpp(72)
: error C2668:
'llvm::StringMap::StringMap' : ambiguous
call to overloaded function

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(399):
could be
'llvm::StringMap::StringMap(const
llvm::StringMap &)'

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(242):
or
'llvm::StringMap::StringMap(llvm::StringMap
&&)'

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(235):
or
'llvm::StringMap::StringMap(std::initializer_list>)'
with
[
ValueTy=std::string
]

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(228):
or
'llvm::StringMap::StringMap(AllocatorTy)'
with
[
AllocatorTy=llvm::MallocAllocator
]

D:\buildslave\clang-x64-ninja-win7\llvm\include\llvm/ADT/StringMap.h(225):
or
'llvm::StringMap::StringMap(unsigned
int)'
while trying to match the argument list '(initializer-list)'
   Creating library lib\libclang.lib and object lib\libclang.exp


On Wed, Feb 24, 2016 at 8:36 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Feb 24 07:36:34 2016
> New Revision: 261738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261738=rev
> Log:
> [clang-tidy] introduce modernize-deprecated-headers check
>
> Summary:
> This patch introduces the modernize-deprecated-headers check, which is
> supposed to replace deprecated C library headers with the C++ STL-ones.
>
> For information see documentation; for exmaples see the test cases.
>
> Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
>
> Subscribers: cfe-commits
>
> Patch by Kirill Bobyrev!
>
> Differential Revision: http://reviews.llvm.org/D17484
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/DeprecatedHeadersCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-deprecated-headers.rst
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=261738=261737=261738=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Feb 24
> 07:36:34 2016
> @@ -1,6 +1,7 @@
>  set(LLVM_LINK_COMPONENTS support)
>
>  add_clang_library(clangTidyModernizeModule
> +  

Re: [PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Aaron Ballman via cfe-commits
On Wed, Feb 24, 2016 at 4:14 PM, Samuel Benzaquen via cfe-commits
 wrote:
> sbenza added a comment.
>
> I assume you checked that the new trait works on MSVC.

Yes. It's also used in ThreadSafety.cpp, so maybe at some point we may
want to consider generalizing the trait.

> Aren't both the same type of expression SFINAE?

I believe so, yes.

> Is somehow one supported but not the other?

Compiler bugs, most likely. The one I am proposing has the benefit of
working everywhere we care about, at least as far as it's been used in
thread safety analysis for a few releases (so it also works with MSVC
2013 as well as MSVC 2015).

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


Re: [PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

I assume you checked that the new trait works on MSVC.
Aren't both the same type of expression SFINAE? Is somehow one supported but 
not the other?


http://reviews.llvm.org/D17575



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


Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Nico Weber via cfe-commits
On Wed, Feb 24, 2016 at 3:53 PM, Richard Smith 
wrote:

> On Wed, Feb 24, 2016 at 10:47 AM, Nico Weber  wrote:
> > Thanks for patiently explaining this. The attached patch is your email in
> > diff form. Does this look alright?
>
> Yes, it looks great. Thanks for the excellent test cases.
>

r261770, thanks!


>
> > Since you mention C++98: We emit this diagnostic in C++98 mode (before
> and
> > after my change). The rule is new in C+++11, right? Should I add a check
> for
> > CPlusPlus11 before emitting this diagnostic (in a separate change)?
>
> The rule was present (although worded differently), in paragraph 9:
> "If no initializer is specified for an object, and the object is of
> (possibly cv-qualified) non-POD class type (or array thereof), the
> object shall be default-initialized; if the object is of
> const-qualified type, the underlying class type shall have a
> user-declared default constructor."
>
> > I first forgot to undo my isDefaultCtor() change, and all the tests pass
> > both with and without it. Can you think of a test case that fails with
> the
> > isDefaultCtor() patch? (The new tests fail with _just_ the
> isDefaultCtor()
> > change.)
>
> Looking through the uses, there seem to be roughly four different
> things going on:
>
> 1) Checks for a trivial default constructor. These are unaffected by
> your change because a templated default constructor can never be
> trivial.
> 2) Checks for a default constructor for diagnostic purposes. I think
> they'd be surprised if we called a constructor template a default
> constructor, especially if it's being passed arguments (the same is
> true in the default argument case, though).
> 3) Checks for a default constructor for type traits and the like.
> These aren't really all that meaningful, but we probably shouldn't
> change their outcomes (we're emlating GCC behavior).
> 4) A very small number of language semantic checks; the ones whose
> outcomes change seem to mostly be wrong (they want to find the
> constructor that overload resolution would actually select for a
> 0-argument call).
>
> The easiest way to test this would probably be to static_assert that a
> class with a constructor template returns false for __is_trivial:
>
> struct X { template X(T...); };
> static_assert(!__is_trivial(X), "");
>

I had tried something like that (I think it was the
`static_assert(__has_nothrow_constructor(X), "");` upthread), but I can't
manage to behave it differently by changing isDefaultConstructor(). A
mystery for another day, I suppose :-) Thanks again!


>
> > On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
> > wrote:
> >>
> >> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber 
> wrote:
> >> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
> >> > wrote:
> >> >>
> >> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
> >> >> wrote:
> >> >>>
> >> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith <
> rich...@metafoo.co.uk>
> >> >>> wrote:
> >> 
> >>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
> >>  wrote:
> >>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
> >>  >  wrote:
> >>  >>
> >>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
> >>  >>  wrote:
> >>  >> > Author: nico
> >>  >> > Date: Thu Feb 18 19:52:46 2016
> >>  >> > New Revision: 261297
> >>  >> >
> >>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297=rev
> >>  >> > Log:
> >>  >> > Implement the likely resolution of core issue 253.
> >>  >> >
> >>  >> > C++11 requires const objects to have a user-provided
> >>  >> > constructor,
> >>  >> > even
> >>  >> > for
> >>  >> > classes without any fields. DR 253 relaxes this to say "If the
> >>  >> > implicit
> >>  >> > default
> >>  >> > constructor initializes all subobjects, no initializer should
> be
> >>  >> > required."
> >>  >> >
> >>  >> > clang is currently the only compiler that implements this
> C++11
> >>  >> > rule,
> >>  >> > and e.g.
> >>  >> > libstdc++ relies on something like DR 253 to compile in newer
> >>  >> > versions.
> >>  >> > This
> >>  >> > change  makes it possible to build code that says `const
> >>  >> > vector v;'
> >>  >> > again
> >>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
> >>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
> >>  >> >
> >>  >> > Fixes PR23381.
> >>  >> >
> >>  >> > http://reviews.llvm.org/D16552
> >>  >> >
> >>  >> > Modified:
> >>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
> >>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
> >>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
> >>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
> >>  >> > 

r261770 - Fix rejects-valid caused by r261297.

2016-02-24 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Feb 24 14:58:14 2016
New Revision: 261770

URL: http://llvm.org/viewvc/llvm-project?rev=261770=rev
Log:
Fix rejects-valid caused by r261297.

r261297 called hasUserProvidedDefaultConstructor() to check if defining a
const object is ok.  This is incorrect for this example:

  struct X { template X(T...); int n; };
  const X x; // formerly OK, now bogus error

Instead, track if a class has a defaulted default constructor, and disallow
a const object for classes that either have defaulted default constructors or
if they need an implicit constructor.

Bug report and fix approach by Richard Smith, thanks!

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=261770=261769=261770=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Feb 24 14:58:14 2016
@@ -421,6 +421,10 @@ class CXXRecordDecl : public RecordDecl
 /// constructor which is neither the copy nor move constructor.
 bool HasConstexprNonCopyMoveConstructor : 1;
 
+/// \brief True if this class has a (possibly implicit) defaulted default
+/// constructor.
+bool HasDefaultedDefaultConstructor : 1;
+
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 bool DefaultedDefaultConstructorIsConstexpr : 1;
@@ -1278,7 +1282,8 @@ public:
   /// per core issue 253.
   bool allowConstDefaultInit() const {
 return !data().HasUninitializedFields ||
-   hasUserProvidedDefaultConstructor();
+   !(data().HasDefaultedDefaultConstructor ||
+ needsImplicitDefaultConstructor());
   }
 
   /// \brief Determine whether this class has a destructor which has no

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=261770=261769=261770=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Feb 24 14:58:14 2016
@@ -2040,6 +2040,8 @@ bool ASTNodeImporter::ImportDefinition(R
 ToData.HasIrrelevantDestructor = FromData.HasIrrelevantDestructor;
 ToData.HasConstexprNonCopyMoveConstructor
   = FromData.HasConstexprNonCopyMoveConstructor;
+ToData.HasDefaultedDefaultConstructor
+  = FromData.HasDefaultedDefaultConstructor;
 ToData.DefaultedDefaultConstructorIsConstexpr
   = FromData.DefaultedDefaultConstructorIsConstexpr;
 ToData.HasConstexprDefaultConstructor

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=261770=261769=261770=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Wed Feb 24 14:58:14 2016
@@ -61,6 +61,7 @@ CXXRecordDecl::DefinitionData::Definitio
   DefaultedDestructorIsDeleted(false), HasTrivialSpecialMembers(SMF_All),
   DeclaredNonTrivialSpecialMembers(0), HasIrrelevantDestructor(true),
   HasConstexprNonCopyMoveConstructor(false),
+  HasDefaultedDefaultConstructor(false),
   DefaultedDefaultConstructorIsConstexpr(true),
   HasConstexprDefaultConstructor(false),
   HasNonLiteralTypeFieldsOrBases(false), ComputedVisibleConversions(false),
@@ -497,6 +498,8 @@ void CXXRecordDecl::addedMember(Decl *D)
 data().UserProvidedDefaultConstructor = true;
   if (Constructor->isConstexpr())
 data().HasConstexprDefaultConstructor = true;
+  if (Constructor->isDefaulted())
+data().HasDefaultedDefaultConstructor = true;
 }
 
 if (!FunTmpl) {

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=261770=261769=261770=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Feb 24 14:58:14 2016
@@ -1423,6 +1423,7 @@ void ASTDeclReader::ReadCXXDefinitionDat
   Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
   Data.HasIrrelevantDestructor = Record[Idx++];
   Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
+  Data.HasDefaultedDefaultConstructor = Record[Idx++];
   Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
   Data.HasConstexprDefaultConstructor = Record[Idx++];
   Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
@@ -1548,6 +1549,7 @@ void 

Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Richard Smith via cfe-commits
On Wed, Feb 24, 2016 at 10:47 AM, Nico Weber  wrote:
> Thanks for patiently explaining this. The attached patch is your email in
> diff form. Does this look alright?

Yes, it looks great. Thanks for the excellent test cases.

> Since you mention C++98: We emit this diagnostic in C++98 mode (before and
> after my change). The rule is new in C+++11, right? Should I add a check for
> CPlusPlus11 before emitting this diagnostic (in a separate change)?

The rule was present (although worded differently), in paragraph 9:
"If no initializer is specified for an object, and the object is of
(possibly cv-qualified) non-POD class type (or array thereof), the
object shall be default-initialized; if the object is of
const-qualified type, the underlying class type shall have a
user-declared default constructor."

> I first forgot to undo my isDefaultCtor() change, and all the tests pass
> both with and without it. Can you think of a test case that fails with the
> isDefaultCtor() patch? (The new tests fail with _just_ the isDefaultCtor()
> change.)

Looking through the uses, there seem to be roughly four different
things going on:

1) Checks for a trivial default constructor. These are unaffected by
your change because a templated default constructor can never be
trivial.
2) Checks for a default constructor for diagnostic purposes. I think
they'd be surprised if we called a constructor template a default
constructor, especially if it's being passed arguments (the same is
true in the default argument case, though).
3) Checks for a default constructor for type traits and the like.
These aren't really all that meaningful, but we probably shouldn't
change their outcomes (we're emlating GCC behavior).
4) A very small number of language semantic checks; the ones whose
outcomes change seem to mostly be wrong (they want to find the
constructor that overload resolution would actually select for a
0-argument call).

The easiest way to test this would probably be to static_assert that a
class with a constructor template returns false for __is_trivial:

struct X { template X(T...); };
static_assert(!__is_trivial(X), "");

> On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
> wrote:
>>
>> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber  wrote:
>> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
>> > wrote:
>> >>
>> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
>> >> wrote:
>> >>>
>> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith 
>> >>> wrote:
>> 
>>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
>>  wrote:
>>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
>>  >  wrote:
>>  >>
>>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
>>  >>  wrote:
>>  >> > Author: nico
>>  >> > Date: Thu Feb 18 19:52:46 2016
>>  >> > New Revision: 261297
>>  >> >
>>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297=rev
>>  >> > Log:
>>  >> > Implement the likely resolution of core issue 253.
>>  >> >
>>  >> > C++11 requires const objects to have a user-provided
>>  >> > constructor,
>>  >> > even
>>  >> > for
>>  >> > classes without any fields. DR 253 relaxes this to say "If the
>>  >> > implicit
>>  >> > default
>>  >> > constructor initializes all subobjects, no initializer should be
>>  >> > required."
>>  >> >
>>  >> > clang is currently the only compiler that implements this C++11
>>  >> > rule,
>>  >> > and e.g.
>>  >> > libstdc++ relies on something like DR 253 to compile in newer
>>  >> > versions.
>>  >> > This
>>  >> > change  makes it possible to build code that says `const
>>  >> > vector v;'
>>  >> > again
>>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
>>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
>>  >> >
>>  >> > Fixes PR23381.
>>  >> >
>>  >> > http://reviews.llvm.org/D16552
>>  >> >
>>  >> > Modified:
>>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
>>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
>>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
>>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
>>  >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>  >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>>  >> >
>>  >> >
>>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
>>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.init/p6.cpp
>>  >> > cfe/trunk/test/CXX/drs/dr4xx.cpp
>>  >> > cfe/trunk/test/SemaCXX/attr-selectany.cpp
>>  >> > cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
>>  >> > cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp
>>  >> > cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp
>> 

Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-24 Thread Peter Collingbourne via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261767: Add whole-program vtable optimization feature to 
Clang. (authored by pcc).

Changed prior to commit:
  http://reviews.llvm.org/D16821?vs=46697=48968#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16821

Files:
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/include/clang/Frontend/CodeGenOptions.h
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/runtime/CMakeLists.txt
  cfe/trunk/runtime/vtables_blacklist.txt
  cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
  cfe/trunk/test/CodeGenCXX/bitsets.cpp
  cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
  cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
  cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt
  cfe/trunk/test/Driver/whole-program-vtables.c

Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -1053,6 +1053,21 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -fwhole-program-vtables
+
+   Enable whole-program vtable optimizations, such as single-implementation
+   devirtualization and virtual constant propagation. Requires ``-flto``.
+
+   By default, the compiler will assume that all type hierarchies are
+   closed except those in the ``std`` namespace, the ``stdext`` namespace
+   and classes with the ``__declspec(uuid())`` attribute.
+
+.. option:: -fwhole-program-vtables-blacklist=path
+
+   Allows the user to specify the path to a list of additional classes to
+   blacklist from whole-program vtable optimizations. This list is in the
+   :ref:`CFI blacklist ` format.
+
 .. option:: -fno-assume-sane-operator-new
 
Don't assume that the C++'s new operator is sane.
Index: cfe/trunk/runtime/CMakeLists.txt
===
--- cfe/trunk/runtime/CMakeLists.txt
+++ cfe/trunk/runtime/CMakeLists.txt
@@ -134,3 +134,13 @@
   VERBATIM)
   endif()
 endif()
+
+set(src "${CMAKE_CURRENT_SOURCE_DIR}/vtables_blacklist.txt")
+set(dst "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/vtables_blacklist.txt")
+add_custom_command(OUTPUT ${dst}
+   DEPENDS ${src}
+   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+   COMMENT "Copying vtables blacklist")
+add_custom_target(vtables_blacklist DEPENDS ${dst})
+add_dependencies(clang vtables_blacklist)
+install(FILES ${src} DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
Index: cfe/trunk/runtime/vtables_blacklist.txt
===
--- cfe/trunk/runtime/vtables_blacklist.txt
+++ cfe/trunk/runtime/vtables_blacklist.txt
@@ -0,0 +1,8 @@
+# Standard library types.
+type:std::*
+
+# The stdext namespace contains Microsoft standard library extensions.
+type:stdext::*
+
+# Types with a uuid attribute, i.e. COM types.
+type:attr:uuid
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -179,6 +179,9 @@
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
+CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
+  ///  vtable optimization.
+
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
 VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h
@@ -201,6 +201,9 @@
   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
   std::vector NoBuiltinFuncs;
 
+  /// List of blacklist files for the whole-program vtable optimization feature.
+  std::vector WholeProgramVTablesBlacklistFiles;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ 

r261767 - Add whole-program vtable optimization feature to Clang.

2016-02-24 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Feb 24 14:46:36 2016
New Revision: 261767

URL: http://llvm.org/viewvc/llvm-project?rev=261767=rev
Log:
Add whole-program vtable optimization feature to Clang.

This patch introduces the -fwhole-program-vtables flag, which enables the
whole-program vtable optimization feature (D16795) in Clang.

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

Added:
cfe/trunk/runtime/vtables_blacklist.txt
cfe/trunk/test/CodeGenCXX/bitset-blacklist.cpp
  - copied, changed from r261762, 
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/CodeGenCXX/bitsets.cpp
  - copied, changed from r261762, cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
cfe/trunk/test/Driver/Inputs/resource_dir/vtables_blacklist.txt
cfe/trunk/test/Driver/whole-program-vtables.c
Removed:
cfe/trunk/test/CodeGenCXX/cfi-blacklist.cpp
cfe/trunk/test/CodeGenCXX/cfi-vcall.cpp
Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=261767=261766=261767=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Feb 24 14:46:36 2016
@@ -1053,6 +1053,21 @@ are listed below.
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -fwhole-program-vtables
+
+   Enable whole-program vtable optimizations, such as single-implementation
+   devirtualization and virtual constant propagation. Requires ``-flto``.
+
+   By default, the compiler will assume that all type hierarchies are
+   closed except those in the ``std`` namespace, the ``stdext`` namespace
+   and classes with the ``__declspec(uuid())`` attribute.
+
+.. option:: -fwhole-program-vtables-blacklist=path
+
+   Allows the user to specify the path to a list of additional classes to
+   blacklist from whole-program vtable optimizations. This list is in the
+   :ref:`CFI blacklist ` format.
+
 .. option:: -fno-assume-sane-operator-new
 
Don't assume that the C++'s new operator is sane.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261767=261766=261767=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 24 14:46:36 2016
@@ -1124,6 +1124,13 @@ def fvisibility_inlines_hidden : Flag<["
 def fvisibility_ms_compat : Flag<["-"], "fvisibility-ms-compat">, 
Group,
   HelpText<"Give global types 'default' visibility and global functions and "
"variables 'hidden' visibility by default">;
+def fwhole_program_vtables : Flag<["-"], "fwhole-program-vtables">, 
Group,
+  Flags<[CC1Option]>,
+  HelpText<"Enables whole-program vtable optimization. Requires -flto">;
+def fno_whole_program_vtables : Flag<["-"], "fno-whole-program-vtables">, 
Group;
+def fwhole_program_vtables_blacklist_EQ : Joined<["-"], 
"fwhole-program-vtables-blacklist=">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Path to a blacklist file for whole-program vtable optimization">;
 def fwrapv : Flag<["-"], "fwrapv">, Group, Flags<[CC1Option]>,
   HelpText<"Treat signed integer overflow as two's complement">;
 def fwritable_strings : Flag<["-"], "fwritable-strings">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=261767=261766=261767=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Feb 24 14:46:36 2016
@@ -179,6 +179,9 @@ CODEGENOPT(DebugExplicitImport, 1, 0)  /
 
 CODEGENOPT(EmitLLVMUseLists, 1, 0) ///< Control whether to serialize use-lists.
 
+CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program
+  ///  vtable optimization.
+
 /// The user specified number of registers to be used for integral arguments,
 /// or 0 if unspecified.
 VALUE_CODEGENOPT(NumRegisterParameters, 32, 0)

Modified: 

RE: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-02-24 Thread Romanova, Katya via cfe-commits
Hello,

I don’t think it will too hard to convert C++ style doxygen comments into C 
style doxygen comments by writing a post-processing python script. However, at 
first we need to decide if we really want to do that. If so, we need to settle 
on the exact format. After that, I need to make sure that the comments in the 
new format will be rendered correctly in MS Tooltips, XCode, online 
documentation and PS4 internal documentation. This discussion + investigation 
might take a few days.

Before we start discussing the exact format, I want to make sure that we really 
want to change to C-style doxygen comments.
Here are my not-so-strong arguments against it:

-There currently are 257 occurrences C++ style comments in 14 other 
header files in /llvm/tools/clang/lib/Headers directory (I’m talking about the 
files that I didn’t touch). C++ style comments were there for AGES and nobody 
complained so far. If we decide to change C++ style doxygen comments -> 
C-style, we also need to change all regular C++ comments to C-style in these 
header files.

-c99 (and later) supports C++ style comments, while I c89 doesn’t. I’m 
not sure if we have users that still use c89 format and x86 intrinsic headers 
at the same time.

-C++ style doxygen comments are more pretty and readable compared to 
C-style comment (though it might be my subjective opinion).

Let me know what you think.

I will try to get Dmitri Gribenko’s opinion. He did a lot of work on doxygen in 
LLVM. I’m curious what he thinks about Javadoc style format.

Katya.


From: Eric Christopher [mailto:echri...@gmail.com]
Sent: Tuesday, February 23, 2016 10:51 PM
To: reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; Romanova, Katya; 
Gao, Yunzhong; griboz...@gmail.com; craig.top...@gmail.com; Robinson, Paul
Cc: Bedwell, Greg; cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics 
(part 6, popcntintrin.h)


Yeah, we should be doing this. Nice catch Paul and Greg.

On Tue, Feb 23, 2016, 10:34 PM Greg Bedwell 
> wrote:
gbedwell added a subscriber: gbedwell.
gbedwell added a comment.

In http://reviews.llvm.org/D17550#360177, @probinson wrote:

> One question I have, which shouldn't block this (as we've done several like 
> this already):
>  Is is okay to be using C++ style comments in these headers?
>  (Is there a C-style comment that Doxygen recognizes?)


There are a few various formats that Doxygen supports.  Looking at headers from 
llvm-c the most common convention appears to be JavaDoc style, although there 
are a few examples of other supported styles floating around the codebase.  
E.g. from include/llvm-c/lto.h using JavaDoc style:

/**

- Diagnostic handler type.
- \p severity defines the severity.
- \p diag is the actual diagnostic.
- The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '.
- \p ctxt is used to pass the context set with the diagnostic handler. *
- \since LTO_API_VERSION=7 */

-Greg


Repository:
  rL LLVM

http://reviews.llvm.org/D17550


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


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

2016-02-24 Thread Yaxun Liu via cfe-commits
yaxunl updated the summary for this revision.
yaxunl removed a reviewer: pekka.jaaskelainen.
yaxunl added a subscriber: pekka.jaaskelainen.
yaxunl set the repository for this revision to rL LLVM.
yaxunl updated this revision to Diff 48967.
yaxunl marked 5 inline comments as done.
yaxunl added a comment.

Revised as Anastasia suggested.

Modified ASTContext::mergeTypes to handle types with different address space 
properly.
Added more sema tests.


Repository:
  rL LLVM

http://reviews.llvm.org/D17412

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

Index: test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -206,6 +206,38 @@
 // expected-error@-2{{arithmetic operation with operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
 #endif
 
+  AS int *var_cond;
+  arg_gen = 0 ? var_cond : arg_glob;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_loc;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__local int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  var_cond = 0 ? var_cond : arg_const;
+#ifdef GENERIC
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__generic int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_priv;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#elif defined(GLOBAL)
+// expected-error@-4{{conditional operator with the second and third operands of type  ('__global int *' and 'int *') which are pointers to non-overlapping address spaces}}
+#endif
+
+  arg_gen = 0 ? var_cond : arg_gen;
+#ifdef CONSTANT
+// expected-error@-2{{conditional operator with the second and third operands of type  ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
+#endif
+
   f_glob(var_sub);
 #ifndef GLOBAL
 // expected-error-re@-2{{passing '__{{constant|generic}} int *' to parameter of type '__global int *' changes address space of pointer}}
Index: test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- test/CodeGenOpenCL/address-spaces-conversions.cl
+++ test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -19,4 +19,6 @@
   // CHECK: %{{.*}} = ptrtoint i32 addrspace(1)* %{{.*}} to i64
   var_priv = arg_gen > arg_glob; // comparison
   // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)*
+  arg_gen = arg_glob ? arg_gen : arg_glob; // conditional operator
+  // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)*
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -171,7 +171,6 @@
   // Don't do this for enums, they can't be redeclared.
   if (isa(D) || isa(D))
 break;
- 
   bool Warn = !AA->isInherited();
   // Objective-C method declarations in categories are not modelled as
   // redeclarations, so manually look for a redeclaration in a category
@@ -6168,27 +6167,69 @@
   QualType CompositeTy = S.Context.mergeTypes(lhptee, rhptee);
 
   if (CompositeTy.isNull()) {
-S.Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
-  << LHSTy << RHSTy << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
 // In this situation, we assume void* type. No especially good
 // reason, but this is what gcc does, and we do have to pick
 // to get a consistent AST.
-QualType incompatTy = S.Context.getPointerType(S.Context.VoidTy);
-LHS = S.ImpCastExprToType(LHS.get(), incompatTy, CK_BitCast);
-RHS = S.ImpCastExprToType(RHS.get(), incompatTy, CK_BitCast);
+QualType incompatTy;
+if (S.getLangOpts().OpenCL) {
+   

Re: [PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Faisal Vali via cfe-commits
faisalv added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2114
@@ -2113,1 +2113,3 @@
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);

Looks reasonable to me - since it is consistent with the other changes I had 
made.  But somewhat orthogonal to your fix, I wouldn't mind Richard commenting 
on why constant expression evaluation does not have 
IsPotentiallyEvaluatedContext return false (and avoid adding an entry to 
MaybeODRUse)
Also, just as SubstituteDefaultTemplateArgument does, Perhaps we should add an 
InstantiatingTemplate on the stack that marks this as a substitution into  
default arguments.  It would be nice if we could refactor both into a call to 
the same function (i.e SubstittueDefaultTempalteArgument) - but looking at the 
code for it, that would be a little tricky.
My 2 cents.


http://reviews.llvm.org/D17576



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


[PATCH] D17578: [OpenCL]Allowing explicit conversion of "0" to event_t type

2016-02-24 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: Anastasia, pxli168, yaxunl.
ashi1 added subscribers: pekka.jaaskelainen, tstellarAMD, cfe-commits.

This patch will allow the cast of 0 to event_t type.

http://reviews.llvm.org/D17578

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCL/event_t.cl

Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+if(0 == intValue) {
+  Kind = CK_IntegralToPointer;
+  return;
+} else {
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7676,7 +7676,9 @@
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+  "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "program scope variable must reside in %0 address space">;
 def err_missing_actual_pipe_type : Error<


Index: test/CodeGenOpenCL/event_t.cl
===
--- test/CodeGenOpenCL/event_t.cl
+++ test/CodeGenOpenCL/event_t.cl
@@ -9,4 +9,6 @@
 // CHECK: call {{.*}}void @foo(%opencl.event_t* %
   foo(0);
 // CHECK: call {{.*}}void @foo(%opencl.event_t* null)
+  foo((event_t)0);
+// CHECK: call {{.*}}void @foo(%opencl.event_t* null)
 }
Index: lib/Sema/SemaCast.cpp
===
--- lib/Sema/SemaCast.cpp
+++ lib/Sema/SemaCast.cpp
@@ -2313,6 +2313,23 @@
   return;
 }
 
+// for OpenCL, allow casts from '0' to event_t type
+if ((Self.getLangOpts().OpenCL) && DestType->isEventT()) {
+  llvm::APSInt intValue;
+  if(SrcExpr.get()->EvaluateAsInt(intValue, Self.getASTContext())) {
+if(0 == intValue) {
+  Kind = CK_IntegralToPointer;
+  return;
+} else {
+Self.Diag(OpRange.getBegin(),
+  diag::error_opencl_cast_non_zero_to_event_t)
+  << intValue.toString(10) << SrcExpr.get()->getSourceRange();
+SrcExpr = ExprError();
+return;
+}
+  }
+}
+
 // Reject any other conversions to non-scalar types.
 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
   << DestType << SrcExpr.get()->getSourceRange();
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7676,7 +7676,9 @@
 def err_sampler_argument_required : Error<
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
-  "sampler type cannot be used with the __local and __global address space qualifiers">;
+  "sampler type cannot be used with the __local and __global address space qualifiers">;
+def error_opencl_cast_non_zero_to_event_t : Error<
+  "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<
   "program scope variable must reside in %0 address space">;
 def err_missing_actual_pipe_type : Error<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17562: [CUDA] Add hack so code which includes "curand.h" doesn't break.

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

OK.


http://reviews.llvm.org/D17562



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


Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/Headers/cuda_builtin_vars.h:72
@@ -66,1 +71,3 @@
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:

tra wrote:
> Considering that built-in variables are never instantiated, I wonder how it's 
> going to work as the operator will presumably need 'this' pointing 
> *somewhere*, even if we don't use it. Unused 'this' would probably get 
> optimized away with optimizations on, but -O0 may cause problems.
This is interesting.  In the ptx, threadIdx actually gets instantiated, as a 
non-weak global:

  .global .align 1 .b8 threadIdx[1];

Then we take the address of this thing.

At -O2, we don't emit a threadIdx global at all.

I think this is basically fine.  It's actually not right to change extern to 
static in the decl, because then we try to construct a 
__cuda_builtin_threadIdx_t, and the default constructor is deleted.  :)


http://reviews.llvm.org/D17561



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


[PATCH] D17576: Fix assertion failure on MaybeODRUseExprs.

2016-02-24 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: rsmith, EricWF, faisalv.
manmanren added a subscriber: cfe-commits.

In VisitNonTypeTemplateParamDecl, before SubstExpr with the default argument,
we should create a ConstantEvaluated ExpressionEvaluationContext. Without this,
it is possible to use a PotentiallyEvaluated ExpressionEvaluationContext; and
MaybeODRUseExprs will not be cleared when popping the context, causing
assertion failure.

This is similar to how we handle the context before SubstExpr with the
default argument, in SubstDefaultTemplateArgument.

Part of PR13986.
rdar://24480205

http://reviews.llvm.org/D17576

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaTemplate/default-arguments-cxx0x.cpp

Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   
Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), 
TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());


Index: test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- test/SemaTemplate/default-arguments-cxx0x.cpp
+++ test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -75,3 +75,13 @@
 g();
   }
 }
+
+// rdar://problem/24480205
+namespace PR13986 {
+  constexpr unsigned Dynamic = 0;
+  template  class A { template  void m_fn1(); };
+  class Test {
+~Test() {}
+A<1> m_target;
+  };
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2110,6 +2110,8 @@
 Param->setInvalidDecl();
 
   if (D->hasDefaultArgument() && !D->defaultArgumentWasInherited()) {
+EnterExpressionEvaluationContext ConstantEvaluated(SemaRef,
+   Sema::ConstantEvaluated);
 ExprResult Value = SemaRef.SubstExpr(D->getDefaultArgument(), TemplateArgs);
 if (!Value.isInvalid())
   Param->setDefaultArgument(Value.get());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-24 Thread Nico Weber via cfe-commits
Thanks for patiently explaining this. The attached patch is your email in
diff form. Does this look alright?

Since you mention C++98: We emit this diagnostic in C++98 mode (before and
after my change). The rule is new in C+++11, right? Should I add a check
for CPlusPlus11 before emitting this diagnostic (in a separate change)?

I first forgot to undo my isDefaultCtor() change, and all the tests pass
both with and without it. Can you think of a test case that fails with the
isDefaultCtor() patch? (The new tests fail with _just_ the isDefaultCtor()
change.)

On Tue, Feb 23, 2016 at 2:41 PM, Richard Smith 
wrote:

> On Sat, Feb 20, 2016 at 6:53 AM, Nico Weber  wrote:
> > On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber 
> wrote:
> >>
> >> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber 
> wrote:
> >>>
> >>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith 
> >>> wrote:
> 
>  On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber 
> wrote:
>  > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
>  >  wrote:
>  >>
>  >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
>  >>  wrote:
>  >> > Author: nico
>  >> > Date: Thu Feb 18 19:52:46 2016
>  >> > New Revision: 261297
>  >> >
>  >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297=rev
>  >> > Log:
>  >> > Implement the likely resolution of core issue 253.
>  >> >
>  >> > C++11 requires const objects to have a user-provided constructor,
>  >> > even
>  >> > for
>  >> > classes without any fields. DR 253 relaxes this to say "If the
>  >> > implicit
>  >> > default
>  >> > constructor initializes all subobjects, no initializer should be
>  >> > required."
>  >> >
>  >> > clang is currently the only compiler that implements this C++11
>  >> > rule,
>  >> > and e.g.
>  >> > libstdc++ relies on something like DR 253 to compile in newer
>  >> > versions.
>  >> > This
>  >> > change  makes it possible to build code that says `const
>  >> > vector v;'
>  >> > again
>  >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
>  >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
>  >> >
>  >> > Fixes PR23381.
>  >> >
>  >> > http://reviews.llvm.org/D16552
>  >> >
>  >> > Modified:
>  >> > cfe/trunk/include/clang/AST/DeclCXX.h
>  >> > cfe/trunk/lib/AST/ASTImporter.cpp
>  >> > cfe/trunk/lib/AST/DeclCXX.cpp
>  >> > cfe/trunk/lib/Sema/SemaInit.cpp
>  >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>  >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>  >> >
>  >> >
> cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
>  >> > cfe/trunk/test/CXX/dcl.decl/dcl.init/p6.cpp
>  >> > cfe/trunk/test/CXX/drs/dr4xx.cpp
>  >> > cfe/trunk/test/SemaCXX/attr-selectany.cpp
>  >> > cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
>  >> > cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp
>  >> > cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp
>  >> > cfe/trunk/www/cxx_dr_status.html
>  >> >
>  >> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>  >> > URL:
>  >> >
>  >> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=261297=261296=261297=diff
>  >> >
>  >> >
>  >> >
> ==
>  >> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>  >> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 18 19:52:46
> 2016
>  >> > @@ -378,6 +378,10 @@ class CXXRecordDecl : public RecordDecl
>  >> >  /// even if the class has a trivial default constructor.
>  >> >  bool HasUninitializedReferenceMember : 1;
>  >> >
>  >> > +/// \brief True if any non-mutable field whose type doesn't
>  >> > have a
>  >> > user-
>  >> > +/// provided default ctor also doesn't have an in-class
>  >> > initializer.
>  >> > +bool HasUninitializedFields : 1;
>  >> > +
>  >> >  /// \brief These flags are \c true if a defaulted
>  >> > corresponding
>  >> > special
>  >> >  /// member can't be fully analyzed without performing
> overload
>  >> > resolution.
>  >> >  /// @{
>  >> > @@ -1270,6 +1274,13 @@ public:
>  >> >  return !(data().HasTrivialSpecialMembers & SMF_Destructor);
>  >> >}
>  >> >
>  >> > +  /// \brief Determine whether declaring a const variable with
>  >> > this
>  >> > type is ok
>  >> > +  /// per core issue 253.
>  >> > +  bool allowConstDefaultInit() const {
>  >> > +return !data().HasUninitializedFields ||
>  >> > +  

Re: r261762 - Fix typo in test/CodeGen/object-size.c CHECK line.

2016-02-24 Thread Eric Christopher via cfe-commits
Nice catch. :)

On Wed, Feb 24, 2016, 10:43 AM Bob Wilson via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: bwilson
> Date: Wed Feb 24 12:38:35 2016
> New Revision: 261762
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261762=rev
> Log:
> Fix typo in test/CodeGen/object-size.c CHECK line.
>
> Modified:
> cfe/trunk/test/CodeGen/object-size.c
>
> Modified: cfe/trunk/test/CodeGen/object-size.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=261762=261761=261762=diff
>
> ==
> --- cfe/trunk/test/CodeGen/object-size.c (original)
> +++ cfe/trunk/test/CodeGen/object-size.c Wed Feb 24 12:38:35 2016
> @@ -505,7 +505,7 @@ void test31() {
>// CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
>gi = __builtin_object_size(ds1[9].snd, 1);
>
> -  // CHECH: store i32 2
> +  // CHECK: store i32 2
>gi = __builtin_object_size([9].snd[0], 1);
>
>// CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
>
>
> ___
> 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


r261762 - Fix typo in test/CodeGen/object-size.c CHECK line.

2016-02-24 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Wed Feb 24 12:38:35 2016
New Revision: 261762

URL: http://llvm.org/viewvc/llvm-project?rev=261762=rev
Log:
Fix typo in test/CodeGen/object-size.c CHECK line.

Modified:
cfe/trunk/test/CodeGen/object-size.c

Modified: cfe/trunk/test/CodeGen/object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=261762=261761=261762=diff
==
--- cfe/trunk/test/CodeGen/object-size.c (original)
+++ cfe/trunk/test/CodeGen/object-size.c Wed Feb 24 12:38:35 2016
@@ -505,7 +505,7 @@ void test31() {
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
   gi = __builtin_object_size(ds1[9].snd, 1);
 
-  // CHECH: store i32 2
+  // CHECK: store i32 2
   gi = __builtin_object_size([9].snd[0], 1);
 
   // CHECK: call i64 @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)


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


[PATCH] D17575: Determine if there's a getDecl member function using less hacks

2016-02-24 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: sbenza, klimek.
aaron.ballman added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

ASTMatchersInternal uses a custom type trait to determine the presence or 
absence of a getDecl member function. While the current implementation works, 
it requires compiler-specific hackery to work around some MSVC issues. This 
patch replaces the original implementation with one that requires less 
compiler-specific work.

http://reviews.llvm.org/D17575

Files:
  include/clang/ASTMatchers/ASTMatchersInternal.h

Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -569,32 +569,21 @@
   return false;
 }
 
-// Metafunction to determine if type T has a member called
-// getDecl.
-#if defined(_MSC_VER) && !defined(__clang__)
-// For MSVC, we use a weird nonstandard __if_exists statement, as it
-// is not standards-conformant enough to properly compile the standard
-// code below. (At least up through MSVC 2015 require this workaround)
-template  struct has_getDecl {
-  __if_exists(T::getDecl) {
-enum { value = 1 };
-  }
-  __if_not_exists(T::getDecl) {
-enum { value = 0 };
-  }
+// Metafunction to determine if type T has a member called getDecl.
+template 
+class has_getDecl {
+  typedef char yes[1];
+  typedef char no[2];
+
+  template 
+  static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
+
+  template 
+  static no& test(...);
+
+public:
+  static const bool value = sizeof(test(nullptr)) == sizeof(yes);
 };
-#else
-// There is a default template inheriting from "false_type". Then, a
-// partial specialization inherits from "true_type". However, this
-// specialization will only exist when the call to getDecl() isn't an
-// error -- it vanishes by SFINAE when the member doesn't exist.
-template  struct type_sink_to_void { typedef void type; };
-template  struct has_getDecl : std::false_type {};
-template 
-struct has_getDecl<
-T, typename type_sink_to_void::type>
-: std::true_type {};
-#endif
 
 /// \brief Matches overloaded operators with a specific name.
 ///


Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -569,32 +569,21 @@
   return false;
 }
 
-// Metafunction to determine if type T has a member called
-// getDecl.
-#if defined(_MSC_VER) && !defined(__clang__)
-// For MSVC, we use a weird nonstandard __if_exists statement, as it
-// is not standards-conformant enough to properly compile the standard
-// code below. (At least up through MSVC 2015 require this workaround)
-template  struct has_getDecl {
-  __if_exists(T::getDecl) {
-enum { value = 1 };
-  }
-  __if_not_exists(T::getDecl) {
-enum { value = 0 };
-  }
+// Metafunction to determine if type T has a member called getDecl.
+template 
+class has_getDecl {
+  typedef char yes[1];
+  typedef char no[2];
+
+  template 
+  static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
+
+  template 
+  static no& test(...);
+
+public:
+  static const bool value = sizeof(test(nullptr)) == sizeof(yes);
 };
-#else
-// There is a default template inheriting from "false_type". Then, a
-// partial specialization inherits from "true_type". However, this
-// specialization will only exist when the call to getDecl() isn't an
-// error -- it vanishes by SFINAE when the member doesn't exist.
-template  struct type_sink_to_void { typedef void type; };
-template  struct has_getDecl : std::false_type {};
-template 
-struct has_getDecl<
-T, typename type_sink_to_void::type>
-: std::true_type {};
-#endif
 
 /// \brief Matches overloaded operators with a specific name.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17561: [CUDA] Add conversion operators for threadIdx, blockIdx, gridDim, and blockDim to uint3 and dim3.

2016-02-24 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: lib/Headers/cuda_builtin_vars.h:72
@@ -66,1 +71,3 @@
+  // uint3).  This function is defined after we pull in vector_types.h.
+  __attribute__((device)) operator uint3() const;
 private:

Considering that built-in variables are never instantiated, I wonder how it's 
going to work as the operator will presumably need 'this' pointing *somewhere*, 
even if we don't use it. Unused 'this' would probably get optimized away with 
optimizations on, but -O0 may cause problems.


http://reviews.llvm.org/D17561



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


r261758 - AArch64: fix Cyclone CPU features list.

2016-02-24 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Feb 24 11:57:48 2016
New Revision: 261758

URL: http://llvm.org/viewvc/llvm-project?rev=261758=rev
Log:
AArch64: fix Cyclone CPU features list.

It turns out we don't have CRC after all. Who knew?

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261758=261757=261758=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 24 11:57:48 2016
@@ -2124,12 +2124,15 @@ static bool DecodeAArch64Mcpu(const Driv
   std::vector ) {
   std::pair Split = Mcpu.split("+");
   CPU = Split.first;
-  if (CPU == "cyclone" || CPU == "cortex-a53" || CPU == "cortex-a57" ||
+  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
   CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
   CPU == "kryo") {
 Features.push_back("+neon");
 Features.push_back("+crc");
 Features.push_back("+crypto");
+  } else if (CPU == "cyclone") {
+Features.push_back("+neon");
+Features.push_back("+crypto");
   } else if (CPU == "generic") {
 Features.push_back("+neon");
   } else {

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=261758=261757=261758=diff
==
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Wed Feb 24 11:57:48 
2016
@@ -94,7 +94,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-A72 %s
 // RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-M1 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-KRYO %s
-// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" 
"-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" 
"-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
@@ -103,7 +103,7 @@
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+zcm" 
"-target-feature" "+zcz"
+// CHECK-ARCH-ARM64: "-target-cpu" "cyclone" "-target-feature" "+neon" 
"-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 
 // RUN: %clang -target aarch64 -march=armv8-a+fp+simd+crc+crypto -### -c %s 
2>&1 | FileCheck -check-prefix=CHECK-MARCH-1 %s
 // RUN: %clang -target aarch64 
-march=armv8-a+nofp+nosimd+nocrc+nocrypto+fp+simd+crc+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MARCH-1 %s
@@ -125,7 +125,7 @@
 // RUN: %clang -target aarch64 -mcpu=generic+Crc -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-2 %s
 // RUN: %clang -target aarch64 -mcpu=GENERIC+nocrc+CRC -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-2 %s
 // RUN: %clang -target aarch64 -mcpu=cortex-a53+noSIMD -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-MCPU-3 %s
-// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "-crypto" "-target-feature" 
"+zcm" "-target-feature" "+zcz"
+// CHECK-MCPU-1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "-crypto" "-target-feature" "+zcm" "-target-feature" 
"+zcz"
 // CHECK-MCPU-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc"
 // CHECK-MCPU-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"-neon"
 


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


Re: [PATCH] SemaCXX: Support templates in availability attributes

2016-02-24 Thread Aaron Ballman via cfe-commits
On Tue, Feb 23, 2016 at 6:39 PM, Duncan P. N. Exon Smith
 wrote:
>
>> On 2016-Feb-23, at 11:18, Aaron Ballman  wrote:
>>
>> On Tue, Feb 23, 2016 at 1:52 PM, Manman Ren  wrote:
>>> This patch looks good to me. But I am not sure if Aaron has any comment.
>>>
>>> On Feb 22, 2016, at 6:19 PM, Duncan P. N. Exon Smith 
>>> wrote:
>>>
>>>
>>> On 2016-Feb-22, at 17:24, Manman Ren  wrote:
>>>
>>>
>>>
>>> On Feb 8, 2016, at 8:17 PM, Duncan P. N. Exon Smith 
>>> wrote:
>>>
>>> This patch adds support for templates in availability attributes.
>>> - If the context for an availability diagnostic is a
>>> `FunctionTemplateDecl`, look through it to the `FunctionDecl`.
>>>
>>>
>>> AvailabilityResult Decl::getAvailability(std::string *Message) const {
>>> +  if (auto *FTD = dyn_cast(this))
>>> +return FTD->getTemplatedDecl()->getAvailability(Message);
>>> +
>>> AvailabilityResult Result = AR_Available;
>>>
>>>
>>> This looks generally correct to me.
>>> The UnavailableAttr is attached to the FunctionDecl, not the
>>> FunctionTemplateDecl, so looking through sounds right.
>>>
>>> - Add `__has_feature(attribute_availability_in_templates)`.
>>>
>>>
>>> @Aaron, any comment on this?
>>> This patch adds extra support for Availability attribute (similar to
>>> attribute_availability_with_strict in r261548).
>>> Not sure if has_attribute can be used for this purpose.
>>
>> Given that we're already using __has_feature for the rest of the
>> availability attribute stuff, I think it's better to keep it all
>> grouped together instead of checking for some features with
>> __has_feature and others with __has_attribute.
>
> Besides that argument, this isn't adding any attributes, just checking
> how they behave.
>
>> If I understand
>> properly, this is taking code that would have previously been
>> ill-formed and making it well-formed, and that's why the feature
>> testing macro is required?
>
> Exactly.  Previously this was ill-formed:
> ```
> class Unavail __attribute__((unavailable));
>
> template 
> void foo(Unavail&) __attribute__((unavailable));
> ```
>
> Same for `__attribute((availability(macosx,unavailable)))`, and other
> triggers of "unavailable".

Okay, this makes sense to me, thank you for the explanation. LGTM!

~Aaron
>
>>
>> Thanks!
>>
>> ~Aaron
>>
>>>
>>> Manman
>>>
>>>
>>> Is there anything else I should be testing to be sure availability
>>> works correctly in templates?
>>>
>>>
>>> Maybe
>>> test()
>>> calling unavailable function from an unavailable template function
>>> calling an unavailable template function
>>>
>>> I think these all work with the current compiler. But I am not sure if we
>>> have existing test coverage.
>>>
>>>
>>> Thanks for the ideas; let me know if you have any others.
>>>
>>> Can you have a look at the new patch?
>>>
>>> Cheers,
>>> Manman
>>>
>>> I'm working on a patch to add
>>> availability markup to the libc++ headers, and this is the only
>>> problem I've hit so far.  Anyone have thoughts on other things I
>>> should test?
>>>
>>>
>>> <0001-SemaCXX-Support-templates-in-availability-attributes.patch>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/storageclass-cl20.cl:11
@@ -10,3 +10,3 @@
   static global int S2 = 5;
-  static private int S3 = 5;// expected-error{{program scope variable must 
reside in global or constant address space}}
+  static private int S3 = 5;   // expected-error{{program scope variable must 
reside in global or constant address space}}
 

yaxunl wrote:
> this error msg is confusing. better say 'function scope variable with static 
> storage must ...'
Yes, I agree. The error message is not ideal. I will think of better wording 
here.


http://reviews.llvm.org/D17345



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48959.
Alexander_Droste added a comment.

- removed `reverse`
- fixed twine usage

I think `VariableName.insert(VariableName.size() - 1, ArrayIndices);` is needed 
here. 
varName, indices -> 'varname[...]' If append would be used, the second single 
quote would be before the indices, like this: 'varname'[...]

I don't have commit access, so I need someone to commit this for me.


http://reviews.llvm.org/D16044

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Core/MemRegion.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,50 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  (llvm::Twine("[") + intValAsString.str() + "]" + ArrayIndices).str();
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  std::string idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Substring to exclude single quotes surrounding the index var name.
+ArrayIndices = (llvm::Twine("[") + idx.substr(1, idx.size() - 2) + "]" 
+
+ArrayIndices)
+   .str();
+  }
+}
+R = ER->getSuperRegion();
+  }
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices. Place indices before second single
+// quote created by printPretty. 'varName' + [..] -> 'varName[..]'
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,50 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  

r261756 - Objective-C: Add a size field to non-fragile category metadata.

2016-02-24 Thread Manman Ren via cfe-commits
Author: mren
Date: Wed Feb 24 11:49:50 2016
New Revision: 261756

URL: http://llvm.org/viewvc/llvm-project?rev=261756=rev
Log:
Objective-C: Add a size field to non-fragile category metadata.

This is mainly for extensibility. Note that fragile category metadata,
metadata for classes and protocols all have a size field.

Initial patch was provided by Greg Parker.

rdar://problem/24804226

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/metadata-class-properties.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=261756=261755=261756=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Feb 24 11:49:50 2016
@@ -5581,6 +5581,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFra
   //   const struct _protocol_list_t * const protocols;
   //   const struct _prop_list_t * const properties;
   //   const struct _prop_list_t * const class_properties;
+  //   const uint32_t size;
   // }
   CategorynfABITy = llvm::StructType::create("struct._category_t",
  Int8PtrTy, ClassnfABIPtrTy,
@@ -5589,6 +5590,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFra
  ProtocolListnfABIPtrTy,
  PropertyListPtrTy,
  PropertyListPtrTy,
+ IntTy,
  nullptr);
 
   // New types for nonfragile abi messaging.
@@ -6140,6 +6142,7 @@ llvm::Value *CGObjCNonFragileABIMac::Gen
 ///   const struct _protocol_list_t * const protocols;
 ///   const struct _prop_list_t * const properties;
 ///   const struct _prop_list_t * const class_properties;
+///   const uint32_t size;
 /// }
 ///
 void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) 
{
@@ -6154,7 +6157,7 @@ void CGObjCNonFragileABIMac::GenerateCat
   llvm::SmallString<64> ExtClassName(getClassSymbolPrefix());
   ExtClassName += Interface->getObjCRuntimeNameAsString();
 
-  llvm::Constant *Values[7];
+  llvm::Constant *Values[8];
   Values[0] = GetClassName(OCD->getIdentifier()->getName());
   // meta-class entry symbol
   llvm::GlobalVariable *ClassGV =
@@ -6212,6 +6215,9 @@ void CGObjCNonFragileABIMac::GenerateCat
 Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
   }
 
+  unsigned Size = 
CGM.getDataLayout().getTypeAllocSize(ObjCTypes.CategorynfABITy);
+  Values[7] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
+
   llvm::Constant *Init =
 llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy,
   Values);

Modified: cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata-class-properties.m?rev=261756=261755=261756=diff
==
--- cfe/trunk/test/CodeGenObjC/metadata-class-properties.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata-class-properties.m Wed Feb 24 11:49:50 
2016
@@ -4,7 +4,7 @@
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" = private global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { 
{{.*}} i32 96, i32 {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" {{.*}} }
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private global 
{{.*}} section "__DATA, __objc_const", align 8
-// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" 
{{.*}} }, section "__DATA, __objc_const", align 8
+// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" 
{{.*}}, i32 64 }, section "__DATA, __objc_const", align 8
 
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section 
"__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_METACLASS_RO_$_C" = private global %struct._class_ro_t { 
{{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} }, section "__DATA, 
__objc_const", align 8


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


Re: [PATCH] D17438: [OpenCL] Add Sema checks for atomics and implicit declaration

2016-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Yes, I think it deserves clarification. Could you submit a bug to Khronos then?


http://reviews.llvm.org/D17438



___
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-02-24 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:1572
@@ +1571,3 @@
+The __read_only, __write_only, __read_write, read_only, write_only and
+read_write names are reserved for use as access qualifiers and shall not be
+used otherwise.

Anastasia wrote:
> what about __read_write?
Oh, I see it now. May be we could group 
  __read_only/read_only, __write_only/write_only ...


http://reviews.llvm.org/D16040



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


r261755 - [CLANG] [AVX512] [BUILTIN] Adding PSHUF{L|H}W{128|256|512} builtin to clang .

2016-02-24 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Feb 24 11:39:35 2016
New Revision: 261755

URL: http://llvm.org/viewvc/llvm-project?rev=261755=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSHUF{L|H}W{128|256|512} builtin to clang .

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=261755=261754=261755=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Feb 24 11:39:35 2016
@@ -1632,6 +1632,12 @@ TARGET_BUILTIN(__builtin_ia32_prorvd128_
 TARGET_BUILTIN(__builtin_ia32_prorvd256_mask, "V8iV8iV8iV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_prorvq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw512_mask, 
"V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshuflw512_mask, 
"V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pshufhw128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshufhw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pshuflw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=261755=261754=261755=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Feb 24 11:39:35 2016
@@ -1589,6 +1589,54 @@ _mm512_maskz_cvtepu8_epi16 (__mmask32 __
   (__v32hi)(__m512i)(b), \
   (p), (__mmask32)(m)); })
 
+#define _mm512_shufflehi_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi)( __A),\
+  ( __imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32) -1);\
+})
+
+#define _mm512_mask_shufflehi_epi16( __W, __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)( __W),\
+   (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflehi_epi16( __U, __A ,__imm) __extension__ ({ \
+__builtin_ia32_pshufhw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32)( __U));\
+})
+
+#define _mm512_shufflelo_epi16( __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi)( __A),\
+  ( __imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32) -1);\
+})
+
+
+#define _mm512_mask_shufflelo_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)( __W),\
+   (__mmask32)( __U));\
+})
+
+
+#define _mm512_maskz_shufflelo_epi16( __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshuflw512_mask ((__v32hi) (__A),\
+   (__imm),\
+   (__v32hi)\
+   _mm512_setzero_hi (),\
+   (__mmask32)( __U));\
+})
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=261755=261754=261755=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Wed Feb 24 11:39:35 2016
@@ -31,6 +31,11 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("avx512vl,avx512bw")))
 
+static  __inline __m128i __DEFAULT_FN_ATTRS
+_mm_setzero_hi(void){
+return (__m128i){ 0LL, 0LL };
+}
+
 /* Integer compare */
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
@@ -2401,6 +2406,67 @@ _mm256_maskz_cvtepu8_epi16 (__mmask16 __
   (__v16hi)(__m256i)(b), \
   (p), (__mmask16)(m)); })
 
+#define _mm_mask_shufflehi_epi16( __W, __U, __A, __imm) __extension__ ({ \
+__builtin_ia32_pshufhw128_mask ((__v8hi) __A, (__imm),\
+   (__v8hi)( __W),\
+   (__mmask8)( __U));\
+})
+
+#define 

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

2016-02-24 Thread David Li via cfe-commits
davidxl added a comment.

Looks good to me -- and it makes the profile-gen and profile-use's cc1 option 
handling consistent.  Please check with Sean or Justin just in case before 
proceeding.


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] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:672
@@ +671,3 @@
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }

nit: this is in fact an append. It is cleaner instead of using insert.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getVariableName() for MemRegion

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

Since we went with the twine solution, I think we can get rid of the reverse 
stuff.

Note that:
Twine should be used like: (Twine(A) + B + C).str()
So the operator+ has twine as one of the operands.

Once these are fixed, it looks good to me.
Do you have commit access or do you need someone to commit this for you?


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 48953.
Alexander_Droste added a comment.

- remove string idx variable -> remove string copy assignments
- use Twine to reduce temporary string objects, built during concatenation

Is `ArrayIndices = llvm::Twine(ArrayIndices + "]" + intValAsString.str() + 
"[").str();`
preferable to: `ArrayIndices += llvm::Twine("]" + intValAsString.str() + 
"[").str();`
with respect to efficiency? If not, I would prefer the second version, as it is 
a bit more concise.


http://reviews.llvm.org/D16044

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  lib/StaticAnalyzer/Core/MemRegion.cpp

Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,49 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  ArrayIndices =
+  llvm::Twine(ArrayIndices + "]" + intValAsString.str() + "[").str();
+}
+// If not a ConcreteInt, try to obtain the variable
+// name by calling 'getVariableName()' recursively.
+else {
+  std::string idx = ER->getVariableName();
+  if (!idx.empty()) {
+// Substring to exclude single quotes surrounding the index var name.
+ArrayIndices = llvm::Twine(ArrayIndices + "]" +
+   idx.substr(1, idx.size() - 2) + "[")
+   .str();
+  }
+}
+R = ER->getSuperRegion();
+  }
+  std::reverse(ArrayIndices.begin(), ArrayIndices.end());
+
+  // Get variable name.
+  if (R && R->canPrintPretty()) {
+R->printPretty(os);
+VariableName = os.str();
+// Combine variable name with indices.
+VariableName.insert(VariableName.size() - 1, ArrayIndices);
+  }
+
+  return VariableName;
+}
+
 
//===--===//
 // MemRegionManager methods.
 
//===--===//


Index: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -150,6 +150,14 @@
   template const RegionTy* getAs() const;
 
   virtual bool isBoundable() const { return false; }
+
+  /// Get variable name for memory region. The name is obtained from
+  /// the variable/field declaration retrieved from the memory region.
+  /// Regions that point to an element of an array are returned as: "arr[0]".
+  /// Regions that point to a struct are returned as: "st.var".
+  ///
+  /// \returns variable name for memory region
+  std::string getVariableName() const;
 };
 
 /// MemSpaceRegion - A memory region that represents a "memory space";
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -632,6 +632,49 @@
   superRegion->printPrettyAsExpr(os);
 }
 
+std::string MemRegion::getVariableName() const {
+  std::string VariableName;
+  std::string ArrayIndices;
+  const MemRegion *R = this;
+  SmallString<50> buf;
+  llvm::raw_svector_ostream os(buf);
+
+  // Obtain array indices to add them to the variable name.
+  const ElementRegion *ER = nullptr;
+  while ((ER = R->getAs())) {
+// Index is a ConcreteInt.
+if (auto CI = ER->getIndex().getAs()) {
+  llvm::SmallString<2> intValAsString;
+  CI->getValue().toString(intValAsString);
+  

r261751 - [WinEH] Make sure terminate handlers have funclet operands

2016-02-24 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 24 11:02:45 2016
New Revision: 261751

URL: http://llvm.org/viewvc/llvm-project?rev=261751=rev
Log:
[WinEH] Make sure terminate handlers have funclet operands

Calls to the terminate handler must be annotated within the exception
region they are within.

Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=261751=261750=261751=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Feb 24 11:02:45 2016
@@ -3064,16 +3064,6 @@ CodeGenFunction::EmitRuntimeCall(llvm::V
   return EmitRuntimeCall(callee, None, name);
 }
 
-/// Emits a simple call (never an invoke) to the given runtime function.
-llvm::CallInst *
-CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
- ArrayRef args,
- const llvm::Twine ) {
-  llvm::CallInst *call = Builder.CreateCall(callee, args, name);
-  call->setCallingConv(getRuntimeCC());
-  return call;
-}
-
 // Calls which may throw must have operand bundles indicating which funclet
 // they are nested within.
 static void
@@ -3092,6 +3082,19 @@ getBundlesForFunclet(llvm::Value *Callee
   BundleList.emplace_back("funclet", CurrentFuncletPad);
 }
 
+/// Emits a simple call (never an invoke) to the given runtime function.
+llvm::CallInst *
+CodeGenFunction::EmitRuntimeCall(llvm::Value *callee,
+ ArrayRef args,
+ const llvm::Twine ) {
+  SmallVector BundleList;
+  getBundlesForFunclet(callee, CurrentFuncletPad, BundleList);
+
+  llvm::CallInst *call = Builder.CreateCall(callee, args, BundleList, name);
+  call->setCallingConv(getRuntimeCC());
+  return call;
+}
+
 /// Emits a call or invoke to the given noreturn runtime function.
 void CodeGenFunction::EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee,
ArrayRef args) {

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=261751=261750=261751=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Feb 24 11:02:45 2016
@@ -1326,11 +1326,13 @@ llvm::BasicBlock *CodeGenFunction::getTe
   TerminateHandler = createBasicBlock("terminate.handler");
   Builder.SetInsertPoint(TerminateHandler);
   llvm::Value *Exn = nullptr;
+  SaveAndRestore RestoreCurrentFuncletPad(
+  CurrentFuncletPad);
   if (EHPersonality::get(*this).usesFuncletPads()) {
 llvm::Value *ParentPad = CurrentFuncletPad;
 if (!ParentPad)
   ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
-Builder.CreateCleanupPad(ParentPad);
+CurrentFuncletPad = Builder.CreateCleanupPad(ParentPad);
   } else {
 if (getLangOpts().CPlusPlus)
   Exn = getExceptionFromSlot();

Modified: cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp?rev=261751=261750=261751=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-new.cpp Wed Feb 24 11:02:45 2016
@@ -72,6 +72,6 @@ void test_cleanup() {
 // CHECK:   ret void
 
 // CHECK: [[TERMINATE]]
-// CHECK:   cleanuppad within none []
-// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"()
+// CHECK:   %[[CLEANUPPAD:.*]] = cleanuppad within none []
+// CHECK-NEXT:   call void @"\01?terminate@@YAXXZ"() {{.*}} [ "funclet"(token 
%[[CLEANUPPAD]]) ]
 

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp?rev=261751=261750=261751=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-terminate.cpp Wed Feb 24 
11:02:45 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - 
-triple=x86_64-pc-windows-msvc -mconstructor-aliases -fexceptions 
-fcxx-exceptions -fms-compatibility-version=18.00 | FileCheck 
-check-prefix=MSVC2013 %s
-// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - 
-triple=x86_64-pc-windows-msvc -mconstructor-aliases -fexceptions 
-fcxx-exceptions -fms-compatibility-version=19.00 | FileCheck 
-check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s 

Re: [PATCH] D16044: getVariableName() for MemRegion

2016-02-24 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:636
@@ +635,3 @@
+std::string MemRegion::getVariableName() const {
+  std::string VariableName{""};
+  std::string ArrayIndices{""};

Small nit, I prefer to call the default constructor here.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:638
@@ +637,3 @@
+  std::string ArrayIndices{""};
+  const clang::ento::MemRegion *R = this;
+  llvm::SmallString<50> buf;

Small nit: the mentioning the namespaces explicitly here and for smallstring 
and at some other places is redundant.


http://reviews.llvm.org/D16044



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


Re: r261717 - Default vaarg lowering should support indirect struct types.

2016-02-24 Thread Hans Wennborg via cfe-commits
On Wed, Feb 24, 2016 at 5:11 AM, Joerg Sonnenberger via cfe-commits
 wrote:
> On Wed, Feb 24, 2016 at 03:03:32AM -, James Y Knight via cfe-commits 
> wrote:
>> Author: jyknight
>> Date: Tue Feb 23 20:59:33 2016
>> New Revision: 261717
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261717=rev
>> Log:
>> Default vaarg lowering should support indirect struct types.
>>
>> Fixes PR11517 for SPARC.
>
> It would be nice to get the PPC32 and XCore parts finished by those
> involved with the platforms, but I would like to see this merged into
> the 3.8 branch at some point after 3.8.0. It is one of the missing basic
> codegen items for SPARC.

I've put it on the list.

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


Re: [PATCH][modules][PR26237]

2016-02-24 Thread Vassil Vassilev via cfe-commits


On 24/02/16 02:05, Richard Smith wrote:

Calling getMostRecentDecl seems like a slightly fragile way to avoid
iterator invalidation here. Instead...

@@ -214,6 +212,19 @@ namespace clang {
unsigned I = Record.size();
Record.push_back(0);

+  auto  = Common->Specializations;
+  auto & = getPartialSpecializations(Common);
+
+  // AddFirstDeclFromEachModule might trigger deserialization, invalidating
+  // *Specializations iterators. Force the deserialization in advance.
+  llvm::SmallVector Specs;
+  for (auto  : Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto  : PartialSpecializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+  for (auto *D : Specs)
+ D->getMostRecentDecl();

... delete these two lines, and...

+
for (auto  : Specializations) {

... iterate over "Specs" here

  auto *D = getSpecializationDecl(Entry);

... and you don't need this line any more.

  assert(D->isCanonicalDecl() && "non-canonical decl in set");

You can then remove the following, identical, PartialSpecializations loop.

Done.


You also have some tabs in your patch (on the Specs.push_back lines);

Sorry about the tabs, they came from a brand new VM and unconfigured emacs.

please fix those prior to commit. With those changes, this LGTM.

Would it make sense to ask for commit perms?


On Mon, Feb 22, 2016 at 7:11 AM, Vassil Vassilev  wrote:

ping...

On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
wrote:

AFAICT the making a test case independent on STL is the hard part. I think
it will be always failing due to the relocation of the memory region of the
underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to the
instability of test cases for UB (especially library UB), we don't usually
commit test cases for them - we just fix them without tests. About the only
time I think committing a test is helpful for UB (especially library UB) is
if we have a reliable way to test/catch the UB (eg: the sanitizers or a
checking STL that fails fast on validation violations). So, while it would
be good to provide/demonstrate your test case, I would not commit the test
case unless it's a minimal reproduction in the presence of one of those
tools (sanitizers or checking STL) - and would just commit the fix without a
test case, usually.

(I'm not actually reviewing this patch - I don't know much about the modules
code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil




On 30/01/16 17:37, David Blaikie wrote:

Yeah, it's good to have a reproduction, but I wouldn't actually commit one
- unless you have a checked stl to test against that always fails on
possibly-invalidating sequences of operations, then you'd have a fairly
simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev"  wrote:

Sorry.

Our module builds choke on merging several modules, containing
declarations from STL (we are using libc++, no modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template specializations. Some of the
specializations need to be deserialized from a third module. This triggers
an iterator invalidation bug because of the deserialization happening when
iterating the specializations container itself. This happens only when the
container's capacity is exceeded and the relocation invalidates the
iterators and at best causes a crash (see valgrind reports in the bug
report). Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:

It might be handy to give an overview of the issue in the review (&
certainly in the commit) message rather than only citing the bug number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

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






From a90e8ec1bd8eeb7d35e43d29a2aab47fc444e12e Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sat, 30 Jan 2016 14:50:06 +0100
Subject: [PATCH] Writing out template specializations might trigger
 deserialization.

Rebuilding a redecl chain of template (partial) specialization might be trigger
deserialization. If the container's capacity is exceeded the relocation
invalidates the iterators and at best causes a crash. Force deserialization by
copying the collections before iterating.

Fixes PR26237 (https://llvm.org/bugs/show_bug.cgi?id=26237)

I haven't been successful in reducing a reasonable testcase. It should contain
multimodule 

  1   2   >