[PATCH] D27898: [compiler-rt] [builtins] Implement __floattitf() & __floatuntitf()

2016-12-20 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz added a comment.

The code looks OK except for the formatting.  Since the logic is almost the 
same as floattixf / floatuntixf except that some constants are different, I'm 
wondering if it makes sense to reuse the existing code? For example, make 
existing code as floattixf_impl.inc




Comment at: lib/builtins/floattitf.c:32
+COMPILER_RT_ABI fp_t
+__floattitf(ti_int a)
+{

Please put "{" on the same line like __floattitf(ti_int a) {
Same for other occurrences below 



https://reviews.llvm.org/D27898



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


[PATCH] D28008: Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

2016-12-20 Thread David L. Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290236: Rename several methods on ASTRecordReader to follow 
LLVM style (lowerCamelCase). (authored by dlj).

Changed prior to commit:
  https://reviews.llvm.org/D28008?vs=82183=82197#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28008

Files:
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Index: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
===
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
@@ -31,37 +31,37 @@
 llvm::BitstreamCursor 
 
 SourceLocation ReadSourceLocation() {
-  return Record.ReadSourceLocation();
+  return Record.readSourceLocation();
 }
 
 SourceRange ReadSourceRange() {
-  return Record.ReadSourceRange();
+  return Record.readSourceRange();
 }
 
 std::string ReadString() {
-  return Record.ReadString();
+  return Record.readString();
 }
 
 TypeSourceInfo *GetTypeSourceInfo() {
-  return Record.GetTypeSourceInfo();
+  return Record.getTypeSourceInfo();
 }
 
 Decl *ReadDecl() {
-  return Record.ReadDecl();
+  return Record.readDecl();
 }
 
 template
 T *ReadDeclAs() {
-  return Record.ReadDeclAs();
+  return Record.readDeclAs();
 }
 
 void ReadDeclarationNameLoc(DeclarationNameLoc ,
 DeclarationName Name) {
-  Record.ReadDeclarationNameLoc(DNLoc, Name);
+  Record.readDeclarationNameLoc(DNLoc, Name);
 }
 
 void ReadDeclarationNameInfo(DeclarationNameInfo ) {
-  Record.ReadDeclarationNameInfo(NameInfo);
+  Record.readDeclarationNameInfo(NameInfo);
 }
 
   public:
@@ -99,7 +99,7 @@
   ArgInfo.setLAngleLoc(ReadSourceLocation());
   ArgInfo.setRAngleLoc(ReadSourceLocation());
   for (unsigned i = 0; i != NumTemplateArgs; ++i)
-ArgInfo.addArgument(Record.ReadTemplateArgumentLoc());
+ArgInfo.addArgument(Record.readTemplateArgumentLoc());
   Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
 }
 
@@ -118,72 +118,72 @@
   SmallVector Stmts;
   unsigned NumStmts = Record.readInt();
   while (NumStmts--)
-Stmts.push_back(Record.ReadSubStmt());
+Stmts.push_back(Record.readSubStmt());
   S->setStmts(Record.getContext(), Stmts);
   S->LBraceLoc = ReadSourceLocation();
   S->RBraceLoc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
   VisitStmt(S);
-  Record.RecordSwitchCaseID(S, Record.readInt());
+  Record.recordSwitchCaseID(S, Record.readInt());
   S->setKeywordLoc(ReadSourceLocation());
   S->setColonLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
   VisitSwitchCase(S);
-  S->setLHS(Record.ReadSubExpr());
-  S->setRHS(Record.ReadSubExpr());
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setLHS(Record.readSubExpr());
+  S->setRHS(Record.readSubExpr());
+  S->setSubStmt(Record.readSubStmt());
   S->setEllipsisLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
   VisitSwitchCase(S);
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setSubStmt(Record.readSubStmt());
 }
 
 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
   VisitStmt(S);
   LabelDecl *LD = ReadDeclAs();
   LD->setStmt(S);
   S->setDecl(LD);
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setSubStmt(Record.readSubStmt());
   S->setIdentLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
   VisitStmt(S);
   uint64_t NumAttrs = Record.readInt();
   AttrVec Attrs;
-  Record.ReadAttributes(Attrs);
+  Record.readAttributes(Attrs);
   (void)NumAttrs;
   assert(NumAttrs == S->NumAttrs);
   assert(NumAttrs == Attrs.size());
   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
-  S->SubStmt = Record.ReadSubStmt();
+  S->SubStmt = Record.readSubStmt();
   S->AttrLoc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
   VisitStmt(S);
   S->setConstexpr(Record.readInt());
-  S->setInit(Record.ReadSubStmt());
+  S->setInit(Record.readSubStmt());
   S->setConditionVariable(Record.getContext(), ReadDeclAs());
-  S->setCond(Record.ReadSubExpr());
-  S->setThen(Record.ReadSubStmt());
-  S->setElse(Record.ReadSubStmt());
+  S->setCond(Record.readSubExpr());
+  S->setThen(Record.readSubStmt());
+  S->setElse(Record.readSubStmt());
   S->setIfLoc(ReadSourceLocation());
   S->setElseLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
   VisitStmt(S);
-  S->setInit(Record.ReadSubStmt());
+  S->setInit(Record.readSubStmt());
   S->setConditionVariable(Record.getContext(), ReadDeclAs());
-  S->setCond(Record.ReadSubExpr());
-  S->setBody(Record.ReadSubStmt());
+  S->setCond(Record.readSubExpr());
+  S->setBody(Record.readSubStmt());
   

r290236 - Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

2016-12-20 Thread David L. Jones via cfe-commits
Author: dlj
Date: Tue Dec 20 22:34:52 2016
New Revision: 290236

URL: http://llvm.org/viewvc/llvm-project?rev=290236=rev
Log:
Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

Summary:
This follows up to r290217, and makes functions on ASTRecordReader consistent
and valid style.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=290236=290235=290236=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Dec 20 22:34:52 2016
@@ -2250,13 +2250,13 @@ public:
   }
 
   /// \brief Read the record that describes the lexical contents of a DC.
-  bool ReadLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
+  bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) {
 return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
  DC);
   }
 
   /// \brief Read the record that describes the visible contents of a DC.
-  bool ReadVisibleDeclContextStorage(uint64_t Offset,
+  bool readVisibleDeclContextStorage(uint64_t Offset,
  serialization::DeclID ID) {
 return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor, Offset,
  ID);
@@ -2273,37 +2273,37 @@ public:
   }
 
   /// \brief Reads a statement.
-  Stmt *ReadStmt() { return Reader->ReadStmt(*F); }
+  Stmt *readStmt() { return Reader->ReadStmt(*F); }
 
   /// \brief Reads an expression.
-  Expr *ReadExpr() { return Reader->ReadExpr(*F); }
+  Expr *readExpr() { return Reader->ReadExpr(*F); }
 
   /// \brief Reads a sub-statement operand during statement reading.
-  Stmt *ReadSubStmt() { return Reader->ReadSubStmt(); }
+  Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
 
   /// \brief Reads a sub-expression operand during statement reading.
-  Expr *ReadSubExpr() { return Reader->ReadSubExpr(); }
+  Expr *readSubExpr() { return Reader->ReadSubExpr(); }
 
   /// \brief Reads a TemplateArgumentLocInfo appropriate for the
   /// given TemplateArgument kind, advancing Idx.
   TemplateArgumentLocInfo
-  GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
+  getTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
 return Reader->GetTemplateArgumentLocInfo(*F, Kind, Record, Idx);
   }
 
   /// \brief Reads a TemplateArgumentLoc, advancing Idx.
   TemplateArgumentLoc
-  ReadTemplateArgumentLoc() {
+  readTemplateArgumentLoc() {
 return Reader->ReadTemplateArgumentLoc(*F, Record, Idx);
   }
 
   const ASTTemplateArgumentListInfo*
-  ReadASTTemplateArgumentListInfo() {
+  readASTTemplateArgumentListInfo() {
 return Reader->ReadASTTemplateArgumentListInfo(*F, Record, Idx);
   }
 
   /// \brief Reads a declarator info from the given record, advancing Idx.
-  TypeSourceInfo *GetTypeSourceInfo() {
+  TypeSourceInfo *getTypeSourceInfo() {
 return Reader->GetTypeSourceInfo(*F, Record, Idx);
   }
 
@@ -2320,13 +2320,13 @@ public:
   /// \brief Reads a declaration ID from the given position in this record.
   ///
   /// \returns The declaration ID read from the record, adjusted to a global 
ID.
-  serialization::DeclID ReadDeclID() {
+  serialization::DeclID readDeclID() {
 return Reader->ReadDeclID(*F, Record, Idx);
   }
 
   /// \brief Reads a declaration from the given position in a record in the
   /// given module, advancing Idx.
-  Decl *ReadDecl() {
+  Decl *readDecl() {
 return Reader->ReadDecl(*F, Record, Idx);
   }
 
@@ -2336,134 +2336,134 @@ public:
   /// \returns The declaration read from this location, casted to the given
   /// result type.
   template
-  T *ReadDeclAs() {
+  T *readDeclAs() {
 return Reader->ReadDeclAs(*F, Record, Idx);
   }
 
-  IdentifierInfo *GetIdentifierInfo() {
+  IdentifierInfo *getIdentifierInfo() {
 return Reader->GetIdentifierInfo(*F, Record, Idx);
   }
 
   /// \brief Read a selector from the Record, advancing Idx.
-  Selector ReadSelector() {
+  Selector readSelector() {
 return Reader->ReadSelector(*F, Record, Idx);
   }
 
   /// \brief Read a declaration name, advancing Idx.
-  DeclarationName ReadDeclarationName() {
+  DeclarationName readDeclarationName() {
 return Reader->ReadDeclarationName(*F, Record, Idx);
   }
-  void ReadDeclarationNameLoc(DeclarationNameLoc , DeclarationName Name) 
{
+  void readDeclarationNameLoc(DeclarationNameLoc , DeclarationName Name) 
{
 return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, Record, Idx);
   }
-  void 

[PATCH] D26882: Refactor how FunctionDecl handles constexpr:

2016-12-20 Thread Nathan Wilson via Phabricator via cfe-commits
nwilson updated this revision to Diff 82194.
nwilson added a comment.

- Remove the call to `setImplicitlyInline()` within `setImplicitlyConstexpr()` 
and call `setImplicitlyInline()` directly for function concepts.


https://reviews.llvm.org/D26882

Files:
  include/clang/AST/Decl.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp
@@ -11,3 +11,30 @@
 };
 
 template concept constexpr bool FCC() { return true; } // expected-error {{function concept cannot be declared 'constexpr'}}
+
+template  concept bool FCSizeOf() { return sizeof(T) == 8; }
+static_assert(FCSizeOf(), "");
+static_assert(FCSizeOf(), "size of argument not equal to expected (8)"); // expected-error {{static_assert failed "size of argument not equal to expected (8)"}}
+
+struct TestType {};
+template  concept bool FCSameType() { return __is_same(T, U); }
+static_assert(FCSameType(), "");
+
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+template 
+struct remove_reference { typedef T type; };
+
+template 
+constexpr T &(typename remove_reference::type ) noexcept { return static_cast(t); }
+template 
+constexpr T &(typename remove_reference::type &) noexcept { return static_cast(t); }
+
+template 
+constexpr decltype(auto) CFFwdCall(F &, Args &&... args) {
+  return forward(func)(forward(args)...);
+}
+
+static_assert(CFFwdCall(FCSameType), "");
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7086,7 +7086,7 @@
 // C++11 [dcl.constexpr]p1: An explicit specialization of a constexpr
 // function can differ from the template declaration with respect to
 // the constexpr specifier.
-Specialization->setConstexpr(FD->isConstexpr());
+Specialization->setImplicitlyConstexpr(FD->isConstexpr());
   }
 
   // FIXME: Check if the prior specialization has a point of instantiation.
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1619,7 +1619,7 @@
   !CallOperator->isConstexpr() &&
   !Class->getDeclContext()->isDependentContext()) {
 TentativeAnalysisScope DiagnosticScopeGuard(*this);
-CallOperator->setConstexpr(
+CallOperator->setImplicitlyConstexpr(
 CheckConstexprFunctionDecl(CallOperator) &&
 CheckConstexprFunctionBody(CallOperator, CallOperator->getBody()));
   }
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -6253,7 +6253,7 @@
   if (First) {
 //  -- it is implicitly considered to be constexpr if the implicit
 // definition would be,
-MD->setConstexpr(Constexpr);
+MD->setImplicitlyConstexpr(Constexpr);
 
 //  -- it is implicitly considered to have the same exception-specification
 // as if it had been implicitly declared,
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8082,7 +8082,8 @@
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
-  // implicity defined to be a constexpr declaration (implicitly inline)
+  // implicity defined to be a constexpr declaration
+  NewFD->setImplicitlyConstexpr(true);
   NewFD->setImplicitlyInline();
 
   // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
@@ -9104,7 +9105,7 @@
   if (FD->isConstexpr()) {
 Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main)
   << FixItHint::CreateRemoval(DS.getConstexprSpecLoc());
-FD->setConstexpr(false);
+FD->setImplicitlyConstexpr(false);
   }
 
   if (getLangOpts().OpenCL) {
Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -1624,6 +1624,7 @@
   unsigned HasImplicitReturnZero : 1;
   unsigned IsLateTemplateParsed : 1;
   unsigned IsConstexpr : 1;
+  unsigned IsConstexprSpecified : 1;
 
   /// \brief Indicates if the function uses __try.
   unsigned UsesSEHTry : 1;
@@ -1718,6 +1719,7 @@
 IsDeleted(false), IsTrivial(false), IsDefaulted(false),
 IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
 IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
+IsConstexprSpecified(isConstexprSpecified),
 

r290233 - Fix windows build breakage in r290219. Unix path separators in testcase.

2016-12-20 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Tue Dec 20 21:00:11 2016
New Revision: 290233

URL: http://llvm.org/viewvc/llvm-project?rev=290233=rev
Log:
Fix windows build breakage in r290219. Unix path separators in testcase.

Modified:
cfe/trunk/test/Modules/implicit-private-with-different-name.m

Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-different-name.m?rev=290233=290232=290233=diff
==
--- cfe/trunk/test/Modules/implicit-private-with-different-name.m (original)
+++ cfe/trunk/test/Modules/implicit-private-with-different-name.m Tue Dec 20 
21:00:11 2016
@@ -11,7 +11,7 @@
 
 // 
expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level
 module 'APrivate' in private module map, expected a submodule of 'A'}}
 // 
expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make
 'APrivate' a submodule of 'A' to ensure it can be found by name}}
-// CHECK: 
fix-it:"{{.*}}/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap":{1:18-1:26}:"A.Private"
+// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:18-1:26}:"A.Private"
 
 #ifndef HEADER
 #define HEADER


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


Re: r290146 - Fix completely bogus types for some builtins:

2016-12-20 Thread Richard Smith via cfe-commits
On 20 December 2016 at 18:14, Richard Smith  wrote:

> On 19 December 2016 at 17:00, Friedman, Eli via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On 12/19/2016 3:59 PM, Richard Smith via cfe-commits wrote:
>>
>>> Author: rsmith
>>> Date: Mon Dec 19 17:59:34 2016
>>> New Revision: 290146
>>>
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vfpr
>>> intf-valid-redecl.c?rev=290146=290145=290146=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/Sema/vfprintf-valid-redecl.c (original)
>>> +++ cfe/trunk/test/Sema/vfprintf-valid-redecl.c Mon Dec 19 17:59:34 2016
>>> @@ -1,16 +1,18 @@
>>>   // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
>>>   // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -DPREDECLARE
>>> -// expected-no-diagnostics
>>> #ifdef PREDECLARE
>>>   // PR16344
>>>   // Clang has defined 'vfprint' in builtin list. If the following line
>>> occurs before any other
>>>   // `vfprintf' in this file, and we getPreviousDecl()->getTypeSourceInfo()
>>> on it, then we will
>>>   // get a null pointer since the one in builtin list doesn't has valid
>>> TypeSourceInfo.
>>> -int vfprintf(void) { return 0; }
>>> +int vfprintf(void) { return 0; } // expected-warning {{requires
>>> inclusion of the header }}
>>>   #endif
>>> // PR4290
>>>   // The following declaration is compatible with vfprintf, so we
>>> shouldn't
>>> -// warn.
>>> +// reject.
>>>   int vfprintf();
>>> +#ifndef PREDECLARE
>>> +// expected-warning@-2 {{requires inclusion of the header }}
>>> +#endif
>>>
>>
>> We shouldn't warn here; this declaration of vfprintf() is compatible with
>> the actual prototype.  (Granted, you can't call vfprintf() without
>> including stdio.h, but that's a separate problem.)
>
>
> I agree (but I'd note that this is a pre-existing problem for other lib
> builtins taking a FILE*, particularly vfscanf). Perhaps we could deem the
> builtin to have a FunctionNoProtoType type in C if it's not variadic and
> depends on a type that is not yet declared?
>

What do you think of the attached approach? I'm a little uncomfortable that
we no longer recognise a declaration of sigsetjmp as a builtin if it has
the wrong return type (and issue only a warning for that case).

Alternatively, if we're OK with recognising wrongly-typed declarations as
library builtins in this corner case, we could just remove the warning
entirely.
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp  (revision 290192)
+++ lib/AST/ASTContext.cpp  (working copy)
@@ -8690,6 +8690,10 @@
 unsigned *IntegerConstantArgs) const {
   const char *TypeStr = BuiltinInfo.getTypeString(Id);
 
+  FunctionType::ExtInfo EI(CC_C);
+  if (BuiltinInfo.isNoReturn(Id))
+EI = EI.withNoReturn(true);
+
   SmallVector ArgTypes;
 
   bool RequiresICE = false;
@@ -8703,8 +8707,18 @@
   
   while (TypeStr[0] && TypeStr[0] != '.') {
 QualType Ty = DecodeTypeFromStr(TypeStr, *this, Error, RequiresICE, true);
-if (Error != GE_None)
-  return QualType();
+if (Error != GE_None) {
+  if (getLangOpts().CPlusPlus || StringRef(TypeStr).back() == '.' ||
+  !BuiltinInfo.isPredefinedLibFunction(Id))
+return QualType();
+  // In C, if a non-variadic builtin library function can't be implicitly
+  // declared with the right signature (because we're missing a necessary
+  // type declaration), declare it as an unprototyped function instead, so
+  // that we can at least still add attributes to it. We should not 
complain
+  // about a missing #include in this case.
+  Error = GE_None;
+  return getFunctionNoProtoType(ResType, EI);
+}
 
 // If this argument is required to be an IntegerConstantExpression and the
 // caller cares, fill in the bitmask we return.
@@ -8724,9 +8738,6 @@
   assert((TypeStr[0] != '.' || TypeStr[1] == 0) &&
  "'.' should only occur at end of builtin type list!");
 
-  FunctionType::ExtInfo EI(CC_C);
-  if (BuiltinInfo.isNoReturn(Id)) EI = EI.withNoReturn(true);
-
   bool Variadic = (TypeStr[0] == '.');
 
   // We really shouldn't be making a no-proto type here.
Index: test/Sema/implicit-builtin-decl.c
===
--- test/Sema/implicit-builtin-decl.c   (revision 290192)
+++ test/Sema/implicit-builtin-decl.c   (working copy)
@@ -56,13 +56,17 @@
 void snprintf() { }
 
 // PR8316
-void longjmp(); // expected-warning{{declaration of built-in function 
'longjmp' requires inclusion of the header }}
+void longjmp();
 
 extern float fmaxf(float, float);
 
 struct __jmp_buf_tag {};
-void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration 
of built-in function 'sigsetjmp' requires inclusion of the header }}
+int sigsetjmp(struct __jmp_buf_tag[1], int);
 
-// 

Re: r290146 - Fix completely bogus types for some builtins:

2016-12-20 Thread Richard Smith via cfe-commits
On 19 December 2016 at 17:00, Friedman, Eli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 12/19/2016 3:59 PM, Richard Smith via cfe-commits wrote:
>
>> Author: rsmith
>> Date: Mon Dec 19 17:59:34 2016
>> New Revision: 290146
>>
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vfpr
>> intf-valid-redecl.c?rev=290146=290145=290146=diff
>> 
>> ==
>> --- cfe/trunk/test/Sema/vfprintf-valid-redecl.c (original)
>> +++ cfe/trunk/test/Sema/vfprintf-valid-redecl.c Mon Dec 19 17:59:34 2016
>> @@ -1,16 +1,18 @@
>>   // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
>>   // RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -DPREDECLARE
>> -// expected-no-diagnostics
>> #ifdef PREDECLARE
>>   // PR16344
>>   // Clang has defined 'vfprint' in builtin list. If the following line
>> occurs before any other
>>   // `vfprintf' in this file, and we getPreviousDecl()->getTypeSourceInfo()
>> on it, then we will
>>   // get a null pointer since the one in builtin list doesn't has valid
>> TypeSourceInfo.
>> -int vfprintf(void) { return 0; }
>> +int vfprintf(void) { return 0; } // expected-warning {{requires
>> inclusion of the header }}
>>   #endif
>> // PR4290
>>   // The following declaration is compatible with vfprintf, so we
>> shouldn't
>> -// warn.
>> +// reject.
>>   int vfprintf();
>> +#ifndef PREDECLARE
>> +// expected-warning@-2 {{requires inclusion of the header }}
>> +#endif
>>
>
> We shouldn't warn here; this declaration of vfprintf() is compatible with
> the actual prototype.  (Granted, you can't call vfprintf() without
> including stdio.h, but that's a separate problem.)


I agree (but I'd note that this is a pre-existing problem for other lib
builtins taking a FILE*, particularly vfscanf). Perhaps we could deem the
builtin to have a FunctionNoProtoType type in C if it's not variadic and
depends on a type that is not yet declared?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290229 - Fix defaulted-functions-in-C++98 extension to give the functions the same

2016-12-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 20 19:57:02 2016
New Revision: 290229

URL: http://llvm.org/viewvc/llvm-project?rev=290229=rev
Log:
Fix defaulted-functions-in-C++98 extension to give the functions the same
effect they would have in C++11. In particular, they do not prevent
value-initialization from performing zero-initialization, nor do they prevent a
struct from being an aggregate.

Added:
cfe/trunk/test/SemaCXX/aggregate-init-cxx98.cpp
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/CodeGenCXX/value-init.cpp
cfe/trunk/test/SemaCXX/aggregate-initialization.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=290229=290228=290229=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Dec 20 19:57:02 2016
@@ -534,15 +534,10 @@ void CXXRecordDecl::addedMember(Decl *D)
 SMKind |= SMF_MoveConstructor;
 }
 
-// C++ [dcl.init.aggr]p1:
-//   An aggregate is an array or a class with no user-declared
-//   constructors [...].
 // C++11 [dcl.init.aggr]p1: DR1518
-//  An aggregate is an array or a class with no user-provided, explicit, or
-//  inherited constructors
-if (getASTContext().getLangOpts().CPlusPlus11
-? (Constructor->isUserProvided() || Constructor->isExplicit())
-: !Constructor->isImplicit())
+//   An aggregate is an array or a class with no user-provided, explicit, 
or
+//   inherited constructors
+if (Constructor->isUserProvided() || Constructor->isExplicit())
   data().Aggregate = false;
   }
 

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=290229=290228=290229=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Dec 20 19:57:02 2016
@@ -4539,23 +4539,21 @@ static void TryValueInitialization(Sema
   if (const RecordType *RT = T->getAs()) {
 if (CXXRecordDecl *ClassDecl = dyn_cast(RT->getDecl())) {
   bool NeedZeroInitialization = true;
-  if (!S.getLangOpts().CPlusPlus11) {
-// C++98:
-// -- if T is a class type (clause 9) with a user-declared constructor
-//(12.1), then the default constructor for T is called (and the
-//initialization is ill-formed if T has no accessible default
-//constructor);
-if (ClassDecl->hasUserDeclaredConstructor())
-  NeedZeroInitialization = false;
-  } else {
-// C++11:
-// -- if T is a class type (clause 9) with either no default 
constructor
-//(12.1 [class.ctor]) or a default constructor that is 
user-provided
-//or deleted, then the object is default-initialized;
-CXXConstructorDecl *CD = S.LookupDefaultConstructor(ClassDecl);
-if (!CD || !CD->getCanonicalDecl()->isDefaulted() || CD->isDeleted())
-  NeedZeroInitialization = false;
-  }
+  // C++98:
+  // -- if T is a class type (clause 9) with a user-declared constructor
+  //(12.1), then the default constructor for T is called (and the
+  //initialization is ill-formed if T has no accessible default
+  //constructor);
+  // C++11:
+  // -- if T is a class type (clause 9) with either no default constructor
+  //(12.1 [class.ctor]) or a default constructor that is user-provided
+  //or deleted, then the object is default-initialized;
+  //
+  // Note that the C++11 rule is the same as the C++98 rule if there are no
+  // defaulted or deleted constructors, so we just use it unconditionally.
+  CXXConstructorDecl *CD = S.LookupDefaultConstructor(ClassDecl);
+  if (!CD || !CD->getCanonicalDecl()->isDefaulted() || CD->isDeleted())
+NeedZeroInitialization = false;
 
   // -- if T is a (possibly cv-qualified) non-union class type without a
   //user-provided or deleted default constructor, then the object is

Modified: cfe/trunk/test/CodeGenCXX/global-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/global-init.cpp?rev=290229=290228=290229=diff
==
--- cfe/trunk/test/CodeGenCXX/global-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp Tue Dec 20 19:57:02 2016
@@ -171,6 +171,8 @@ namespace test7 {
   const int b3 = B().n;
 
   // CHECK-NOT: @_ZN5test7L2c1E
+  // CHECK: call void @llvm.memset{{.*}} @_ZN5test7L2c1E
+  // CHECK-NOT: @_ZN5test7L2c1E
   // CHECK: @_ZN5test7L2c2E
   // CHECK-NOT: @_ZN5test7L2c3E
   // CHECK: @_ZN5test7L2c4E

Modified: cfe/trunk/test/CodeGenCXX/value-init.cpp
URL: 

[PATCH] D27971: Make FormatStyle.GetStyleOfFile test work on MSVC

2016-12-20 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 82185.
amaiorano added a comment.

As agreed, modified getStyle to make use of vfs::FileSystem::makeAbsolute. I 
would modify the body of the commit as follows:

Modify getStyle to use vfs::FileSystem::makeAbsolute just like FS.addFile does,
rather than sys::fs::make_absolute. The latter gets the CWD from the platform,
while the former expects it to be set by the client, causing a mismatch when
converting relative paths to absolute.

(not sure if I should have just modified the Summary section of this 
Phabricator review)


https://reviews.llvm.org/D27971

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10907,10 +10907,6 @@
 format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
 }
 
-// Since this test case uses UNIX-style file path. We disable it for MS
-// compiler.
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-
 TEST(FormatStyle, GetStyleOfFile) {
   vfs::InMemoryFileSystem FS;
   // Test 1: format file in the same directory.
@@ -10938,8 +10934,6 @@
   ASSERT_EQ(Style3, getGoogleStyle());
 }
 
-#endif // _MSC_VER
-
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1917,7 +1917,10 @@
   // Look for .clang-format/_clang-format file in the file's parent 
directories.
   SmallString<128> UnsuitableConfigFiles;
   SmallString<128> Path(FileName);
-  llvm::sys::fs::make_absolute(Path);
+  std::error_code EC = FS->makeAbsolute(Path);
+  assert(!EC);
+  (void)EC;
+
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10907,10 +10907,6 @@
 format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
 }
 
-// Since this test case uses UNIX-style file path. We disable it for MS
-// compiler.
-#if !defined(_MSC_VER) && !defined(__MINGW32__)
-
 TEST(FormatStyle, GetStyleOfFile) {
   vfs::InMemoryFileSystem FS;
   // Test 1: format file in the same directory.
@@ -10938,8 +10934,6 @@
   ASSERT_EQ(Style3, getGoogleStyle());
 }
 
-#endif // _MSC_VER
-
 TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
   // Column limit is 20.
   std::string Code = "Type *a =\n"
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1917,7 +1917,10 @@
   // Look for .clang-format/_clang-format file in the file's parent directories.
   SmallString<128> UnsuitableConfigFiles;
   SmallString<128> Path(FileName);
-  llvm::sys::fs::make_absolute(Path);
+  std::error_code EC = FS->makeAbsolute(Path);
+  assert(!EC);
+  (void)EC;
+
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290227 - [c++1z] When initializing a const-qualified class type, don't forget to add on

2016-12-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 20 19:31:56 2016
New Revision: 290227

URL: http://llvm.org/viewvc/llvm-project?rev=290227=rev
Log:
[c++1z] When initializing a const-qualified class type, don't forget to add on
the requested cv-qualifiers after construction. This usually doesn't matter,
but it does matter within a ?: operator.

Added:
cfe/trunk/test/CXX/expr/expr.cond/p4.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=290227=290226=290227=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 20 19:31:56 2016
@@ -5199,8 +5199,7 @@ static bool TryClassUnification(Sema 
   //
   // This actually refers very narrowly to the lvalue-to-rvalue conversion, not
   // to the array-to-pointer or function-to-pointer conversions.
-  if (!TTy->getAs())
-TTy = TTy.getUnqualifiedType();
+  TTy = TTy.getNonLValueExprType(Self.Context);
 
   InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy);
   InitializationSequence InitSeq(Self, Entity, Kind, From);

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=290227=290226=290227=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Dec 20 19:31:56 2016
@@ -3609,17 +3609,7 @@ static void TryConstructorInitialization
   UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
   S.Context.hasSameUnqualifiedType(UnwrappedArgs[0]->getType(), DestType)) 
{
 // Convert qualifications if necessary.
-QualType InitType = UnwrappedArgs[0]->getType();
-ImplicitConversionSequence ICS;
-ICS.setStandard();
-ICS.Standard.setAsIdentityConversion();
-ICS.Standard.setFromType(InitType);
-ICS.Standard.setAllToTypes(InitType);
-if (!S.Context.hasSameType(InitType, DestType)) {
-  ICS.Standard.Third = ICK_Qualification;
-  ICS.Standard.setToType(2, DestType);
-}
-Sequence.AddConversionSequenceStep(ICS, DestType);
+Sequence.AddQualificationConversionStep(DestType, VK_RValue);
 if (ILE)
   Sequence.RewrapReferenceInitList(DestType, ILE);
 return;
@@ -4790,6 +4780,8 @@ static void TryUserDefinedConversion(Sem
 // FIXME: Mark this copy as extraneous.
 if (!S.getLangOpts().CPlusPlus1z)
   Sequence.AddFinalCopy(DestType);
+else if (DestType.hasQualifiers())
+  Sequence.AddQualificationConversionStep(DestType, VK_RValue);
 return;
   }
 
@@ -4812,6 +4804,8 @@ static void TryUserDefinedConversion(Sem
 Function->getReturnType()->isReferenceType() ||
 !S.Context.hasSameUnqualifiedType(ConvType, DestType))
   Sequence.AddFinalCopy(DestType);
+else if (!S.Context.hasSameType(ConvType, DestType))
+  Sequence.AddQualificationConversionStep(DestType, VK_RValue);
 return;
   }
 

Added: cfe/trunk/test/CXX/expr/expr.cond/p4.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.cond/p4.cpp?rev=290227=auto
==
--- cfe/trunk/test/CXX/expr/expr.cond/p4.cpp (added)
+++ cfe/trunk/test/CXX/expr/expr.cond/p4.cpp Tue Dec 20 19:31:56 2016
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++98 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+// expected-no-diagnostics
+
+struct A { A(); A(int); };
+void f() {
+  const A a;
+  true ? a : 0;
+}


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


[PATCH] D28008: Rename several methods on ASTRecordReader to follow LLVM style (lowerCamelCase).

2016-12-20 Thread David L. Jones via Phabricator via cfe-commits
dlj created this revision.
dlj added a reviewer: rsmith.
dlj added a subscriber: cfe-commits.

This follows up to r290217, and makes functions on ASTRecordReader consistent
and valid style.


https://reviews.llvm.org/D28008

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTReaderStmt.cpp

Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -31,37 +31,37 @@
 llvm::BitstreamCursor 
 
 SourceLocation ReadSourceLocation() {
-  return Record.ReadSourceLocation();
+  return Record.readSourceLocation();
 }
 
 SourceRange ReadSourceRange() {
-  return Record.ReadSourceRange();
+  return Record.readSourceRange();
 }
 
 std::string ReadString() {
-  return Record.ReadString();
+  return Record.readString();
 }
 
 TypeSourceInfo *GetTypeSourceInfo() {
-  return Record.GetTypeSourceInfo();
+  return Record.getTypeSourceInfo();
 }
 
 Decl *ReadDecl() {
-  return Record.ReadDecl();
+  return Record.readDecl();
 }
 
 template
 T *ReadDeclAs() {
-  return Record.ReadDeclAs();
+  return Record.readDeclAs();
 }
 
 void ReadDeclarationNameLoc(DeclarationNameLoc ,
 DeclarationName Name) {
-  Record.ReadDeclarationNameLoc(DNLoc, Name);
+  Record.readDeclarationNameLoc(DNLoc, Name);
 }
 
 void ReadDeclarationNameInfo(DeclarationNameInfo ) {
-  Record.ReadDeclarationNameInfo(NameInfo);
+  Record.readDeclarationNameInfo(NameInfo);
 }
 
   public:
@@ -99,7 +99,7 @@
   ArgInfo.setLAngleLoc(ReadSourceLocation());
   ArgInfo.setRAngleLoc(ReadSourceLocation());
   for (unsigned i = 0; i != NumTemplateArgs; ++i)
-ArgInfo.addArgument(Record.ReadTemplateArgumentLoc());
+ArgInfo.addArgument(Record.readTemplateArgumentLoc());
   Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
 }
 
@@ -118,72 +118,72 @@
   SmallVector Stmts;
   unsigned NumStmts = Record.readInt();
   while (NumStmts--)
-Stmts.push_back(Record.ReadSubStmt());
+Stmts.push_back(Record.readSubStmt());
   S->setStmts(Record.getContext(), Stmts);
   S->LBraceLoc = ReadSourceLocation();
   S->RBraceLoc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
   VisitStmt(S);
-  Record.RecordSwitchCaseID(S, Record.readInt());
+  Record.recordSwitchCaseID(S, Record.readInt());
   S->setKeywordLoc(ReadSourceLocation());
   S->setColonLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
   VisitSwitchCase(S);
-  S->setLHS(Record.ReadSubExpr());
-  S->setRHS(Record.ReadSubExpr());
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setLHS(Record.readSubExpr());
+  S->setRHS(Record.readSubExpr());
+  S->setSubStmt(Record.readSubStmt());
   S->setEllipsisLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
   VisitSwitchCase(S);
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setSubStmt(Record.readSubStmt());
 }
 
 void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
   VisitStmt(S);
   LabelDecl *LD = ReadDeclAs();
   LD->setStmt(S);
   S->setDecl(LD);
-  S->setSubStmt(Record.ReadSubStmt());
+  S->setSubStmt(Record.readSubStmt());
   S->setIdentLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
   VisitStmt(S);
   uint64_t NumAttrs = Record.readInt();
   AttrVec Attrs;
-  Record.ReadAttributes(Attrs);
+  Record.readAttributes(Attrs);
   (void)NumAttrs;
   assert(NumAttrs == S->NumAttrs);
   assert(NumAttrs == Attrs.size());
   std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
-  S->SubStmt = Record.ReadSubStmt();
+  S->SubStmt = Record.readSubStmt();
   S->AttrLoc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
   VisitStmt(S);
   S->setConstexpr(Record.readInt());
-  S->setInit(Record.ReadSubStmt());
+  S->setInit(Record.readSubStmt());
   S->setConditionVariable(Record.getContext(), ReadDeclAs());
-  S->setCond(Record.ReadSubExpr());
-  S->setThen(Record.ReadSubStmt());
-  S->setElse(Record.ReadSubStmt());
+  S->setCond(Record.readSubExpr());
+  S->setThen(Record.readSubStmt());
+  S->setElse(Record.readSubStmt());
   S->setIfLoc(ReadSourceLocation());
   S->setElseLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
   VisitStmt(S);
-  S->setInit(Record.ReadSubStmt());
+  S->setInit(Record.readSubStmt());
   S->setConditionVariable(Record.getContext(), ReadDeclAs());
-  S->setCond(Record.ReadSubExpr());
-  S->setBody(Record.ReadSubStmt());
+  S->setCond(Record.readSubExpr());
+  S->setBody(Record.readSubStmt());
   S->setSwitchLoc(ReadSourceLocation());
   if (Record.readInt())
 S->setAllEnumCasesCovered();
@@ -204,27 +204,27 @@
   VisitStmt(S);
   S->setConditionVariable(Record.getContext(), 

r290225 - Factor out checking of template arguments after deduction into a separate

2016-12-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 20 19:10:31 2016
New Revision: 290225

URL: http://llvm.org/viewvc/llvm-project?rev=290225=rev
Log:
Factor out checking of template arguments after deduction into a separate
function. (This change would also allow us to handle default template arguments
in partial specializations if the standard ever permits them.)

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

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=290225=290224=290225=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Dec 20 19:10:31 2016
@@ -2214,6 +2214,130 @@ ConvertDeducedTemplateArgument(Sema ,
   return ConvertArg(Arg, 0);
 }
 
+// FIXME: This should not be a template, but
+// ClassTemplatePartialSpecializationDecl sadly does not derive from
+// TemplateDecl.
+template
+static Sema::TemplateDeductionResult ConvertDeducedTemplateArguments(
+Sema , TemplateDeclT *Template,
+SmallVectorImpl ,
+TemplateDeductionInfo , SmallVectorImpl ,
+LocalInstantiationScope *CurrentInstantiationScope = nullptr,
+unsigned NumAlreadyConverted = 0, bool PartialOverloading = false) {
+  TemplateParameterList *TemplateParams = Template->getTemplateParameters();
+
+  for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
+NamedDecl *Param = TemplateParams->getParam(I);
+
+if (!Deduced[I].isNull()) {
+  if (I < NumAlreadyConverted) {
+// We have already fully type-checked and converted this
+// argument, because it was explicitly-specified. Just record the
+// presence of this argument.
+Builder.push_back(Deduced[I]);
+// We may have had explicitly-specified template arguments for a
+// template parameter pack (that may or may not have been extended
+// via additional deduced arguments).
+if (Param->isParameterPack() && CurrentInstantiationScope) {
+  if (CurrentInstantiationScope->getPartiallySubstitutedPack() ==
+  Param) {
+// Forget the partially-substituted pack; its substitution is now
+// complete.
+CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+  }
+}
+continue;
+  }
+
+  // We have deduced this argument, so it still needs to be
+  // checked and converted.
+  if (ConvertDeducedTemplateArgument(S, Param, Deduced[I], Template, Info,
+ isa(Template),
+ Builder)) {
+Info.Param = makeTemplateParameter(Param);
+// FIXME: These template arguments are temporary. Free them!
+Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder));
+return Sema::TDK_SubstitutionFailure;
+  }
+
+  continue;
+}
+
+// C++0x [temp.arg.explicit]p3:
+//A trailing template parameter pack (14.5.3) not otherwise deduced 
will
+//be deduced to an empty sequence of template arguments.
+// FIXME: Where did the word "trailing" come from?
+if (Param->isTemplateParameterPack()) {
+  // We may have had explicitly-specified template arguments for this
+  // template parameter pack. If so, our empty deduction extends the
+  // explicitly-specified set (C++0x [temp.arg.explicit]p9).
+  const TemplateArgument *ExplicitArgs;
+  unsigned NumExplicitArgs;
+  if (CurrentInstantiationScope &&
+  CurrentInstantiationScope->getPartiallySubstitutedPack(
+  , ) == Param) {
+Builder.push_back(TemplateArgument(
+llvm::makeArrayRef(ExplicitArgs, NumExplicitArgs)));
+
+// Forget the partially-substituted pack; its substitution is now
+// complete.
+CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+  } else {
+// Go through the motions of checking the empty argument pack against
+// the parameter pack.
+DeducedTemplateArgument DeducedPack(TemplateArgument::getEmptyPack());
+if (ConvertDeducedTemplateArgument(
+S, Param, DeducedPack, Template, Info,
+isa(Template), Builder)) {
+  Info.Param = makeTemplateParameter(Param);
+  // FIXME: These template arguments are temporary. Free them!
+  Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder));
+  return Sema::TDK_SubstitutionFailure;
+}
+  }
+  continue;
+}
+
+// Substitute into the default template argument, if available.
+bool HasDefaultArg = false;
+TemplateDecl *TD = dyn_cast(Template);
+if (!TD) {
+  assert(isa(Template));
+  return Sema::TDK_Incomplete;
+}
+
+TemplateArgumentLoc DefArg = S.SubstDefaultTemplateArgumentIfAvailable(
+TD, 

r290221 - Fix build breakage in r290219. Notes should not be in diagnostic groups.

2016-12-20 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Tue Dec 20 18:48:14 2016
New Revision: 290221

URL: http://llvm.org/viewvc/llvm-project?rev=290221=rev
Log:
Fix build breakage in r290219. Notes should not be in diagnostic groups.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=290221=290220=290221=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 20 18:48:14 2016
@@ -646,8 +646,7 @@ def warn_mmap_mismatched_top_level_priva
   "top-level module '%0' in private module map, expected a submodule of '%1'">,
   InGroup;
 def note_mmap_rename_top_level_private_as_submodule : Note<
-  "make '%0' a submodule of '%1' to ensure it can be found by name">,
-  InGroup;
+  "make '%0' a submodule of '%1' to ensure it can be found by name">;
 
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "


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


[PATCH] D28007: Switch TableGen to emit calls to ASTRecordReader for AttrPCHRead.

2016-12-20 Thread David L. Jones via Phabricator via cfe-commits
dlj created this revision.
dlj added a reviewer: rsmith.
dlj added a subscriber: cfe-commits.

This patch changes TableGen-generated code in AttrPCHRead to call functions on
ASTRecordReader, instead of passing separate parameters to ASTReader. This is a
follow-up to r290217.


https://reviews.llvm.org/D28007

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReaderDecl.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -90,13 +90,13 @@
 
 static std::string ReadPCHRecord(StringRef type) {
   return StringSwitch(type)
-.EndsWith("Decl *", "GetLocalDeclAs<" 
-  + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])")
-.Case("TypeSourceInfo *", "GetTypeSourceInfo(F, Record, Idx)")
-.Case("Expr *", "ReadExpr(F)")
-.Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)")
-.Case("StringRef", "ReadString(Record, Idx)")
-.Default("Record[Idx++]");
+.EndsWith("Decl *", "Record.GetLocalDeclAs<" 
+  + std::string(type, 0, type.size()-1) + ">(Record.readInt())")
+.Case("TypeSourceInfo *", "Record.GetTypeSourceInfo()")
+.Case("Expr *", "Record.ReadExpr()")
+.Case("IdentifierInfo *", "Record.GetIdentifierInfo()")
+.Case("StringRef", "Record.ReadString()")
+.Default("Record.readInt()");
 }
 
 // Get a type that is suitable for storing an object of the specified type.
@@ -414,7 +414,7 @@
 
 void writePCHReadDecls(raw_ostream ) const override {
   OS << "std::string " << getLowerName()
- << "= ReadString(Record, Idx);\n";
+ << "= Record.ReadString();\n";
 }
 
 void writePCHReadArgs(raw_ostream ) const override {
@@ -540,13 +540,13 @@
 }
 
 void writePCHReadDecls(raw_ostream ) const override {
-  OS << "bool is" << getLowerName() << "Expr = Record[Idx++];\n";
+  OS << "bool is" << getLowerName() << "Expr = Record.readInt();\n";
   OS << "void *" << getLowerName() << "Ptr;\n";
   OS << "if (is" << getLowerName() << "Expr)\n";
-  OS << "  " << getLowerName() << "Ptr = ReadExpr(F);\n";
+  OS << "  " << getLowerName() << "Ptr = Record.ReadExpr();\n";
   OS << "else\n";
   OS << "  " << getLowerName()
- << "Ptr = GetTypeSourceInfo(F, Record, Idx);\n";
+ << "Ptr = Record.GetTypeSourceInfo();\n";
 }
 
 void writePCHWrite(raw_ostream ) const override {
@@ -659,7 +659,7 @@
 }
 
 void writePCHReadDecls(raw_ostream ) const override {
-  OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n";
+  OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n";
   OS << "SmallVector<" << getType() << ", 4> "
  << getLowerName() << ";\n";
   OS << "" << getLowerName() << ".reserve(" << getLowerName()
@@ -784,7 +784,7 @@
 void writePCHReadDecls(raw_ostream ) const override {
   OS << "" << getAttrName() << "Attr::" << type << " " << getLowerName()
  << "(static_cast<" << getAttrName() << "Attr::" << type
- << ">(Record[Idx++]));\n";
+ << ">(Record.readInt()));\n";
 }
 
 void writePCHReadArgs(raw_ostream ) const override {
@@ -907,14 +907,14 @@
 }
 
 void writePCHReadDecls(raw_ostream ) const override {
-  OS << "unsigned " << getLowerName() << "Size = Record[Idx++];\n";
+  OS << "unsigned " << getLowerName() << "Size = Record.readInt();\n";
   OS << "SmallVector<" << QualifiedTypeName << ", 4> " << getLowerName()
  << ";\n";
   OS << "" << getLowerName() << ".reserve(" << getLowerName()
  << "Size);\n";
   OS << "for (unsigned i = " << getLowerName() << "Size; i; --i)\n";
   OS << "  " << getLowerName() << ".push_back(" << "static_cast<"
- << QualifiedTypeName << ">(Record[Idx++]));\n";
+ << QualifiedTypeName << ">(Record.readInt()));\n";
 }
 
 void writePCHWrite(raw_ostream ) const override {
@@ -997,7 +997,7 @@
 
 void writePCHReadDecls(raw_ostream ) const override {
   OS << "VersionTuple " << getLowerName()
- << "= ReadVersionTuple(Record, Idx);\n";
+ << "= Record.ReadVersionTuple();\n";
 }
 
 void writePCHReadArgs(raw_ostream ) const override {
@@ -2127,9 +2127,9 @@
 
 OS << "  case attr::" << R.getName() << ": {\n";
 if (R.isSubClassOf(InhClass))
-  OS << "bool isInherited = Record[Idx++];\n";
-OS << "bool isImplicit = Record[Idx++];\n";
-OS << "unsigned Spelling = Record[Idx++];\n";
+  OS << "bool isInherited = Record.readInt();\n";
+OS << "bool isImplicit = Record.readInt();\n";
+OS << "unsigned Spelling = Record.readInt();\n";
 ArgRecords = R.getValueAsListOfDefs("Args");
 Args.clear();
 for (const auto *Arg : 

[PATCH] D26882: Refactor how FunctionDecl handles constexpr:

2016-12-20 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/Decl.h:1923
+IsConstexpr = IC;
+setImplicitlyInline();
+  }

nwilson wrote:
> hubert.reinterpretcast wrote:
> > I am quite sure this is not the right thing to do when `IC` is `false`.
> Good point. I //could// do `if (IC) setImplicitlyInline();`, but that doesn't 
> seem great with these smaller functions. Any suggestions by you or @rsmith 
> would be great!
Doing something automatic here with the inline specifier is turning out to be 
too complex. Instead, let's just remove the `setImplicitlyInline()` call from 
here and call it explicitly when handling a concept.


https://reviews.llvm.org/D26882



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


r290219 - [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Graydon Hoare via cfe-commits
Author: graydon
Date: Tue Dec 20 18:24:39 2016
New Revision: 290219

URL: http://llvm.org/viewvc/llvm-project?rev=290219=rev
Log:
[modules] Handle modules with nonstandard names in module.private.modulemaps

Summary:
The module system supports accompanying a primary module (say Foo) with
an auxiliary "private" module (defined in an adjacent module.private.modulemap
file) that augments the primary module when associated private headers are
available. The feature is intended to be used to augment the primary
module with a submodule (say Foo.Private), however some users in the wild
are choosing to augment the primary module with an additional top-level module
with a "similar" name (in all cases so far: FooPrivate).

This "works" when a user of the module initially imports a private header,
such as '#import "Foo/something_private.h"' since the Foo import winds up
importing FooPrivate in passing. But if the import is subsequently recorded
in a PCH file, reloading the PCH will fail to validate because of a cross-check
that attempts to find the module.modulemap (or module.private.modulemap) using
HeaderSearch algorithm, applied to the "FooPrivate" name. Since it's stored in
Foo.framework/Modules, not FooPrivate.framework/Modules, the check fails and
the PCH is rejected.

This patch adds a compensatory workaround in the HeaderSearch algorithm
when searching (and failing to find) a module of the form FooPrivate: the
name used to derive filesystem paths is decoupled from the module name
being searched for, and if the initial search fails and the module is
named "FooPrivate", the filesystem search name is altered to remove the
"Private" suffix, and the algorithm is run a second time (still looking for
a module named FooPrivate, but looking in directories derived from Foo).

Accompanying this change is a new warning that triggers when a user loads
a module.private.modulemap that defines a top-level module with a different
name from the top-level module defined in its adjacent module.modulemap.

Reviewers: doug.gregor, manmanren, bruno

Subscribers: bruno, cfe-commits

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

Added:
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/implicit-private-with-different-name.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=290219=290218=290219=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 20 18:24:39 2016
@@ -243,6 +243,7 @@ def NonModularIncludeInModule : DiagGrou
   
[NonModularIncludeInFrameworkModule]>;
 def IncompleteModule : DiagGroup<"incomplete-module",
 [IncompleteUmbrella, NonModularIncludeInModule]>;
+def PrivateModule : DiagGroup<"private-module">;
 
 def CXX11InlineNamespace : DiagGroup<"c++11-inline-namespace">;
 def InvalidNoreturn : DiagGroup<"invalid-noreturn">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=290219=290218=290219=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 20 18:24:39 2016
@@ -642,6 +642,12 @@ def err_mmap_expected_feature : Error<"e
 def err_mmap_expected_attribute : Error<"expected an attribute name">;
 def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">,
   InGroup;
+def warn_mmap_mismatched_top_level_private : Warning<
+  "top-level module '%0' in private module map, expected a submodule of '%1'">,
+  InGroup;
+def note_mmap_rename_top_level_private_as_submodule : Note<
+  "make '%0' a submodule of '%1' to ensure it can be found by name">,
+  InGroup;
 
 def 

[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Graydon Hoare via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290219: [modules] Handle modules with nonstandard names in 
module.private.modulemaps (authored by graydon).

Changed prior to commit:
  https://reviews.llvm.org/D27852?vs=82161=82177#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27852

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
  cfe/trunk/include/clang/Lex/HeaderSearch.h
  cfe/trunk/lib/Lex/HeaderSearch.cpp
  cfe/trunk/lib/Lex/ModuleMap.cpp
  
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
  
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
  
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
  
cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
  cfe/trunk/test/Modules/implicit-private-with-different-name.m

Index: cfe/trunk/lib/Lex/ModuleMap.cpp
===
--- cfe/trunk/lib/Lex/ModuleMap.cpp
+++ cfe/trunk/lib/Lex/ModuleMap.cpp
@@ -1490,6 +1490,42 @@
 ActiveModule->NoUndeclaredIncludes = true;
   ActiveModule->Directory = Directory;
 
+  if (!ActiveModule->Parent) {
+StringRef MapFileName(ModuleMapFile->getName());
+if (MapFileName.endswith("module.private.modulemap") ||
+MapFileName.endswith("module_private.map")) {
+  // Adding a top-level module from a private modulemap is likely a
+  // user error; we check to see if there's another top-level module
+  // defined in the non-private map in the same dir, and if so emit a
+  // warning.
+  for (auto E = Map.module_begin(); E != Map.module_end(); ++E) {
+auto const *M = E->getValue();
+if (!M->Parent &&
+M->Directory == ActiveModule->Directory &&
+M->Name != ActiveModule->Name) {
+  Diags.Report(ActiveModule->DefinitionLoc,
+   diag::warn_mmap_mismatched_top_level_private)
+<< ActiveModule->Name << M->Name;
+  // The pattern we're defending against here is typically due to
+  // a module named FooPrivate which is supposed to be a submodule
+  // called Foo.Private. Emit a fixit in that case.
+  auto D =
+Diags.Report(ActiveModule->DefinitionLoc,
+ diag::note_mmap_rename_top_level_private_as_submodule);
+  D << ActiveModule->Name << M->Name;
+  StringRef Bad(ActiveModule->Name);
+  if (Bad.consume_back("Private")) {
+SmallString<128> Fixed = Bad;
+Fixed.append(".Private");
+D << FixItHint::CreateReplacement(ActiveModule->DefinitionLoc,
+  Fixed);
+  }
+  break;
+}
+  }
+}
+  }
+
   bool Done = false;
   do {
 switch (Tok.Kind) {
Index: cfe/trunk/lib/Lex/HeaderSearch.cpp
===
--- cfe/trunk/lib/Lex/HeaderSearch.cpp
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp
@@ -194,16 +194,36 @@
   Module *Module = ModMap.findModule(ModuleName);
   if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
 return Module;
-  
+
+  StringRef SearchName = ModuleName;
+  Module = lookupModule(ModuleName, SearchName);
+
+  // The facility for "private modules" -- adjacent, optional module maps named
+  // module.private.modulemap that are supposed to define private submodules --
+  // is sometimes misused by frameworks that name their associated private
+  // module FooPrivate, rather than as a submodule named Foo.Private as
+  // intended. Here we compensate for such cases by looking in directories named
+  // Foo.framework, when we previously looked and failed to find a
+  // FooPrivate.framework.
+  if (!Module && SearchName.consume_back("Private"))
+Module = lookupModule(ModuleName, SearchName);
+  return Module;
+}
+
+Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) {
+  Module *Module = nullptr;
+
   // Look through the various header search paths to load any available module
   // maps, searching for a module map that describes this module.
   for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) {
 if (SearchDirs[Idx].isFramework()) {
-  // Search for or infer a module map for a framework.
+  // Search for or infer a module map for a framework. Here we use
+  // SearchName rather than ModuleName, to permit finding private modules
+  // named FooPrivate in buggy frameworks named Foo.
   SmallString<128> FrameworkDirName;
   FrameworkDirName += SearchDirs[Idx].getFrameworkDir()->getName();
-  llvm::sys::path::append(FrameworkDirName, ModuleName + ".framework");
-  if (const DirectoryEntry *FrameworkDir 
+  

[PATCH] D26882: Refactor how FunctionDecl handles constexpr:

2016-12-20 Thread Nathan Wilson via Phabricator via cfe-commits
nwilson added a comment.

Ping


https://reviews.llvm.org/D26882



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


[PATCH] D27836: Store the "current position" index within the ASTRecordReader.

2016-12-20 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.

In https://reviews.llvm.org/D27836#628029, @rsmith wrote:

> LGTM, any chance I can tempt you to lowerCamelCase all the other 
> ASTRecordReader members to match the new ones as a follow-up change?


Yup, will do.


https://reviews.llvm.org/D27836



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


[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.

Right, I missed it, LGTM


https://reviews.llvm.org/D27852



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


[clang-tools-extra] r290210 - Comment out char16_t and char32_t tests

2016-12-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 20 16:57:21 2016
New Revision: 290210

URL: http://llvm.org/viewvc/llvm-project?rev=290210=rev
Log:
Comment out char16_t and char32_t tests

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp?rev=290210=290209=290210=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 Tue Dec 20 16:57:21 2016
@@ -5,7 +5,7 @@ struct S {
 };
 
 struct PositiveValueChar {
-  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
   // CHECK-FIXES: PositiveValueChar()  {}
   const char c0;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer 
for 'c0' [modernize-use-default-member-init]
@@ -13,12 +13,12 @@ struct PositiveValueChar {
   wchar_t c1;
   // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer 
for 'c1'
   // CHECK-FIXES: wchar_t c1 = L'\0';
-  char16_t c2;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
-  // CHECK-FIXES: char16_t c2 = u'\0';
-  char32_t c3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
-  // CHECK-FIXES: char32_t c3 = U'\0';
+  // FIXME: char16_t c2;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
+  // C HECK-FIXES: char16_t c2 = u'\0';
+  // FIXME: char32_t c3;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
+  // C HECK-FIXES: char32_t c3 = U'\0';
 };
 
 struct PositiveChar {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=290210=290209=290210=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Tue Dec 20 16:57:21 2016
@@ -4,7 +4,7 @@ struct S {
 };
 
 struct PositiveValueChar {
-  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
   // CHECK-FIXES: PositiveValueChar()  {}
   const char c0;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer 
for 'c0' [modernize-use-default-member-init]
@@ -12,12 +12,12 @@ struct PositiveValueChar {
   wchar_t c1;
   // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer 
for 'c1'
   // CHECK-FIXES: wchar_t c1{};
-  char16_t c2;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
-  // CHECK-FIXES: char16_t c2{};
-  char32_t c3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
-  // CHECK-FIXES: char32_t c3{};
+  // FIXME: char16_t c2;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
+  // C HECK-FIXES: char16_t c2{};
+  // FIXME: char32_t c3;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
+  // C HECK-FIXES: char32_t c3{};
 };
 
 struct PositiveChar {


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


[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Graydon Hoare via Phabricator via cfe-commits
graydon added inline comments.



Comment at: test/Modules/implicit-private-with-different-name.m:13
+// 
expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level
 module 'APrivate' in private module map, expected a submodule of 'A'}}
+// 
expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make
 'APrivate' a submodule of 'A' to ensure it can be found by name}}
+// CHECK: 
fix-it:"{{.*}}/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap":{1:18-1:26}:"A.Private"

bruno wrote:
> I think we can enhance the usability a bit here, how about:
> 
> warning: top-level module 'APrivate' in private module map, expected a 
> submodule of 'A'
> note: make 'APrivate' a submodule of 'A' to ensure it can be found by name
>   framework module APrivate {
>^
> A.Private
> 
> 
I'm not sure what you're requesting; as far as I can see that is exactly the 
diagnostic I'm emitting (along with the fixit)


https://reviews.llvm.org/D27852



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


[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a reviewer: bruno.
bruno added inline comments.



Comment at: test/Modules/implicit-private-with-different-name.m:13
+// 
expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level
 module 'APrivate' in private module map, expected a submodule of 'A'}}
+// 
expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make
 'APrivate' a submodule of 'A' to ensure it can be found by name}}
+// CHECK: 
fix-it:"{{.*}}/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap":{1:18-1:26}:"A.Private"

I think we can enhance the usability a bit here, how about:

warning: top-level module 'APrivate' in private module map, expected a 
submodule of 'A'
note: make 'APrivate' a submodule of 'A' to ensure it can be found by name
  framework module APrivate {
   ^
A.Private




https://reviews.llvm.org/D27852



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


[PATCH] D26846: __uuidof() and declspec(uuid("...")) should be allowed on enumeration types

2016-12-20 Thread Kevin Puetz via Phabricator via cfe-commits
puetzk added a comment.

I see that you added a FIXME mentioning that it should be C++-only, but I don't 
see where you actually did anything that would make it so. What am I missing?

Also, did you mean to drop the changes to utils/TableGen/ClangAttrEmitter.cpp 
and bring back the WarnDiag, "ExpectedEnumOrClass" @aaron.ballman asked for in 
the first review?


Repository:
  rL LLVM

https://reviews.llvm.org/D26846



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


Re: [clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via cfe-commits
On 20 December 2016 at 22:32, Aaron Ballman  wrote:
> On Tue, Dec 20, 2016 at 4:26 PM, Malcolm Parsons via cfe-commits
>  wrote:
>> Author: malcolm.parsons
>> Date: Tue Dec 20 15:26:07 2016
>> New Revision: 290202
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
>> Log:
>> [clang-tidy] Add modernize-use-default-member-init check
>>
>> Summary: Fixes PR18858
>
> This appears to have broken one of the bots:
>
> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/33046

error: unknown type name 'char16_t'
error: unknown type name 'char32_t'

I see commented tests in other clang-tidy tests:

// TODO: enable these tests once all supported compilers
// support char16_t and char32_t (VS2013 does not)

// disabled for now until it is clear
// how to enable them in the test
//} catch (const char16_t*) {

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


[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2016-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D27604



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


[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Graydon Hoare via Phabricator via cfe-commits
graydon updated this revision to Diff 82161.
graydon added a comment.

Updates to address review comments


https://reviews.llvm.org/D27852

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  include/clang/Lex/HeaderSearch.h
  lib/Lex/HeaderSearch.cpp
  lib/Lex/ModuleMap.cpp
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
  
test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
  test/Modules/implicit-private-with-different-name.m

Index: test/Modules/implicit-private-with-different-name.m
===
--- /dev/null
+++ test/Modules/implicit-private-with-different-name.m
@@ -0,0 +1,20 @@
+// RUN: rm -rf %t
+
+// Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s
+
+// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only
+
+// Check the fixit
+// RUN: %clang_cc1  -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level module 'APrivate' in private module map, expected a submodule of 'A'}}
+// expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make 'APrivate' a submodule of 'A' to ensure it can be found by name}}
+// CHECK: fix-it:"{{.*}}/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap":{1:18-1:26}:"A.Private"
+
+#ifndef HEADER
+#define HEADER
+#import "A/aprivate.h"
+const int *y = 
+#endif
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap
@@ -0,0 +1,4 @@
+framework module APrivate {
+  header "aprivate.h"
+  export *
+}
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module A {
+  header "a.h"
+  export *
+}
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h
@@ -0,0 +1 @@
+extern int APRIVATE;
Index: test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
===
--- /dev/null
+++ test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h
@@ -0,0 +1 @@
+extern int APUBLIC;
Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -1490,6 +1490,42 @@
 ActiveModule->NoUndeclaredIncludes = true;
   ActiveModule->Directory = Directory;
 
+  if (!ActiveModule->Parent) {
+StringRef MapFileName(ModuleMapFile->getName());
+if (MapFileName.endswith("module.private.modulemap") ||
+MapFileName.endswith("module_private.map")) {
+  // Adding a top-level module from a private modulemap is likely a
+  // user error; we check to see if there's another top-level module
+  // defined in the non-private map in the same dir, and if so emit a
+  // warning.
+  for (auto E = Map.module_begin(); E != Map.module_end(); ++E) {
+auto const *M = E->getValue();
+if (!M->Parent &&
+M->Directory == ActiveModule->Directory &&
+M->Name != ActiveModule->Name) {
+  Diags.Report(ActiveModule->DefinitionLoc,
+   diag::warn_mmap_mismatched_top_level_private)
+<< ActiveModule->Name << M->Name;
+  // The pattern we're defending against here is typically due to
+  // a module named FooPrivate which is supposed to be a submodule
+ 

[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Graydon Hoare via Phabricator via cfe-commits
graydon marked 5 inline comments as done.
graydon added a comment.

Addressed review comments


https://reviews.llvm.org/D27852



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


r290208 - Make a test use a specific C++ dialect

2016-12-20 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Dec 20 16:30:44 2016
New Revision: 290208

URL: http://llvm.org/viewvc/llvm-project?rev=290208=rev
Log:
Make a test use a specific C++ dialect

In stack-reuse-miscompile.cpp, the allocas for the temps come out in
a different order depending on whether the dialect is C++03 or
C++11. Specify C++03 explicitly to avoid depending on the default.

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

Modified:
cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp

Modified: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp?rev=290208=290207=290208=diff
==
--- cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp Tue Dec 20 16:30:44 
2016
@@ -1,4 +1,4 @@
-// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm 
-disable-llvm-optzns -S %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 
-disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s
 
 // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for
 // f function because all temporary objects in this function are used for the


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


[PATCH] D27956: Make CodeGenCXX/stack-reuse-miscompile.cpp tolerate C++11

2016-12-20 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290208: Make a test use a specific C++ dialect (authored by 
probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27956?vs=82020=82160#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27956

Files:
  cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp


Index: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
===
--- cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm 
-disable-llvm-optzns -S %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 
-disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s
 
 // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for
 // f function because all temporary objects in this function are used for the


Index: cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
===
--- cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
+++ cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -S -target armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -mllvm -disable-llvm-optzns -S %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-optzns -std=c++03 %s -o - | FileCheck %s
 
 // This test should not to generate llvm.lifetime.start/llvm.lifetime.end for
 // f function because all temporary objects in this function are used for the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27936: C++11 test cleanup: nonthrowing destructors

2016-12-20 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290207: C++11 test cleanup: nonthrowing destructors 
(authored by probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27936?vs=81982=82157#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27936

Files:
  cfe/trunk/test/CodeGenCXX/destructors.cpp
  cfe/trunk/test/CodeGenCXX/nrvo.cpp
  cfe/trunk/test/CodeGenCXX/partial-destruction.cpp

Index: cfe/trunk/test/CodeGenCXX/partial-destruction.cpp
===
--- cfe/trunk/test/CodeGenCXX/partial-destruction.cpp
+++ cfe/trunk/test/CodeGenCXX/partial-destruction.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11
 
 // Test IR generation for partial destruction of aggregates.
 
@@ -45,7 +46,8 @@
   // CHECK-NEXT: br label
   // CHECK:  [[ED_AFTER:%.*]] = phi [[A]]* [ [[ED_END]], {{%.*}} ], [ [[ED_CUR:%.*]], {{%.*}} ]
   // CHECK-NEXT: [[ED_CUR]] = getelementptr inbounds [[A]], [[A]]* [[ED_AFTER]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]])
+  // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]])
+  // CHECKv11-NEXT: call   void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]])
   // CHECK:  [[T0:%.*]] = icmp eq [[A]]* [[ED_CUR]], [[ED_BEGIN]]
   // CHECK-NEXT: br i1 [[T0]],
   // CHECK:  ret void
@@ -58,7 +60,8 @@
   // CHECK-NEXT: br i1 [[T0]],
   // CHECK:  [[E_AFTER:%.*]] = phi [[A]]* [ [[PARTIAL_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ]
   // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+  // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+  // CHECKv11-NEXT: call   void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
   // CHECK:  [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E_BEGIN]]
   // CHECK-NEXT: br i1 [[T0]],
 
@@ -73,20 +76,21 @@
   // FIXME: There's some really bad block ordering here which causes
   // the partial destroy for the primary normal destructor to fall
   // within the primary EH destructor.
-  // CHECK:  landingpad { i8*, i32 }
-  // CHECK-NEXT:   cleanup
-  // CHECK:  [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]]
-  // CHECK-NEXT: br i1 [[T0]]
-  // CHECK:  [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ]
-  // CHECK-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]])
-  // CHECK:  [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]]
-  // CHECK-NEXT: br i1 [[T0]]
+  // CHECKv03:  landingpad { i8*, i32 }
+  // CHECKv03-NEXT:   cleanup
+  // CHECKv03:  [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]]
+  // CHECKv03-NEXT: br i1 [[T0]]
+  // CHECKv03:  [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ]
+  // CHECKv03-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]], [[A]]* [[EDD_AFTER]], i64 -1
+  // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]])
+  // CHECKv03:  [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]]
+  // CHECKv03-NEXT: br i1 [[T0]]
 
   // Back to the primary EH destructor.
   // CHECK:  [[E_AFTER:%.*]] = phi [[A]]* [ [[E_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ]
   // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]], [[A]]* [[E_AFTER]], i64 -1
-  // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+  // CHECKv03-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+  // CHECKv11-NEXT: call   void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
   // CHECK:  [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E0]]
   // CHECK-NEXT: br i1 [[T0]],
 
@@ -120,8 +124,10 @@
   // CHECK-NEXT:   cleanup
   // CHECK:  landingpad { i8*, i32 }
   // CHECK-NEXT:   cleanup
-  // CHECK:  invoke void @_ZN5test11AD1Ev([[A]]* [[Y]])
-  // CHECK:  invoke void @_ZN5test11AD1Ev([[A]]* [[X]])
+  // CHECKv03:  invoke void @_ZN5test11AD1Ev([[A]]* [[Y]])
+  // CHECKv03:  invoke void @_ZN5test11AD1Ev([[A]]* [[X]])
+  // CHECKv11:  call   void @_ZN5test11AD1Ev([[A]]* [[Y]])
+  // CHECKv11:  call   void @_ZN5test11AD1Ev([[A]]* [[X]])
 }
 
 namespace test2 {
@@ -153,7 +159,8 @@
 // CHECK-NEXT: br i1 [[EMPTY]],
 // CHECK:  [[PAST:%.*]] = phi [[A]]* [ [[CUR]], {{%.*}} ], [ [[DEL:%.*]], {{%.*}} ]
 // CHECK-NEXT: [[DEL]] = getelementptr inbounds [[A]], [[A]]* [[PAST]], i64 -1
-// CHECK-NEXT: invoke void @_ZN5test21AD1Ev([[A]]* [[DEL]])
+// CHECKv03-NEXT: invoke void 

r290207 - C++11 test cleanup: nonthrowing destructors

2016-12-20 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Dec 20 16:26:11 2016
New Revision: 290207

URL: http://llvm.org/viewvc/llvm-project?rev=290207=rev
Log:
C++11 test cleanup: nonthrowing destructors

If a dtor has no interesting members, then it ends up being nothrow,
which affects the generated IR. Modify some tests to tolerate this
difference between C++03 and C++11.

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

Modified:
cfe/trunk/test/CodeGenCXX/destructors.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/partial-destruction.cpp

Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=290207=290206=290207=diff
==
--- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructors.cpp Tue Dec 20 16:26:11 2016
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns > 
%t
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++03 > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
-// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
-// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns -std=c++11 > %t2
-// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v03 --input-file=%t %s
+// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v03 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++11 > %t2
+// RUN: FileCheck --check-prefix=CHECK1--input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK2v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK3--input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK6--input-file=%t2 %s
 // REQUIRES: asserts
 
 struct A {
@@ -98,6 +103,12 @@ namespace test0 {
 // CHECK2: invoke void @_ZN5test04BaseD2Ev
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
+// In C++11, the destructors are often known not to throw.
+// CHECK2v11-LABEL: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK2v11-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) 
unnamed_addr
+// CHECK2v11: call void @_ZN5test06MemberD1Ev
+// CHECK2v11: call void @_ZN5test04BaseD2Ev
+
   struct B : Base, virtual VBase {
 Member M;
 ~B();
@@ -111,6 +122,10 @@ namespace test0 {
 // CHECK2: invoke void @_ZN5test04BaseD2Ev
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
+// CHECK2v11-LABEL: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, 
i8** %vtt) unnamed_addr
+// CHECK2v11: call void @_ZN5test06MemberD1Ev
+// CHECK2v11: call void @_ZN5test04BaseD2Ev
+
 // CHECK2-LABEL: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) 
unnamed_addr
 // CHECK2: invoke void @_ZN5test06MemberD1Ev
 // CHECK2:   unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
@@ -118,6 +133,11 @@ namespace test0 {
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 // CHECK2: invoke void @_ZN5test05VBaseD2Ev
 // CHECK2:   unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]]
+
+// CHECK2v11-LABEL: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) 
unnamed_addr
+// CHECK2v11: call void @_ZN5test06MemberD1Ev
+// CHECK2v11: call void @_ZN5test04BaseD2Ev
+// CHECK2v11: call void @_ZN5test05VBaseD2Ev
 }
 
 // Test base-class aliasing.
@@ -189,19 +209,22 @@ namespace test3 {
   }
 
   // CHECK4-LABEL: define internal void 
@_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::(anonymous namespace)::C"* 
%this) unnamed_addr
-  // CHECK4: invoke void @_ZN5test31BD2Ev(
+  // CHECK4v03: invoke void @_ZN5test31BD2Ev(
+  // CHECK4v11: call   void @_ZN5test31BD2Ev(
   // CHECK4: call void @_ZN5test31AD2Ev(
   // CHECK4: ret void
 
   // CHECK4-LABEL: define internal void 
@_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::(anonymous namespace)::D"* 
%this) unnamed_addr
-  // CHECK4-SAME:  personality i8* bitcast (i32 (...)* @__gxx_personality_v0 
to i8*)
-  // CHECK4: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+  // CHECK4v03-SAME:  personality i8* bitcast (i32 (...)* 
@__gxx_personality_v0 to i8*)
+  // CHECK4v03: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+  // CHECK4v11: call   void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
   // CHECK4: call void @_ZdlPv({{.*}}) [[NUW:#[0-9]+]]
   // 

[PATCH] D27994: Make two vtable tests tolerate C++11

2016-12-20 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290205: Make two vtable tests tolerate C++11. (authored by 
probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27994?vs=82126=82156#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27994

Files:
  cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
  cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp


Index: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
@@ -1919,6 +1919,8 @@
 virtual int i(int);
 virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 
Index: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
+++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 
-emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template
 struct E {


Index: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
@@ -1919,6 +1919,8 @@
 virtual int i(int);
 virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 
Index: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
===
--- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
+++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template
 struct E {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290205 - Make two vtable tests tolerate C++11.

2016-12-20 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Dec 20 16:22:24 2016
New Revision: 290205

URL: http://llvm.org/viewvc/llvm-project?rev=290205=rev
Log:
Make two vtable tests tolerate C++11.

In C++11 we don't emit vtables as eagerly as we do for C++03, so
fiddle the tests to emit them when the test expects them.

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

Modified:
cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp

Modified: cfe/trunk/test/CodeGenCXX/vtable-layout.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-layout.cpp?rev=290205=290204=290205=diff
==
--- cfe/trunk/test/CodeGenCXX/vtable-layout.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-layout.cpp Tue Dec 20 16:22:24 2016
@@ -1919,6 +1919,8 @@ namespace Test40 {
 virtual int i(int);
 virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 

Modified: cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp?rev=290205=290204=290205=diff
==
--- cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/vtable-linkage.cpp Tue Dec 20 16:22:24 2016
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 
-emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@ void D::f() { }
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template
 struct E {


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


Re: [clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Aaron Ballman via cfe-commits
On Tue, Dec 20, 2016 at 4:26 PM, Malcolm Parsons via cfe-commits
 wrote:
> Author: malcolm.parsons
> Date: Tue Dec 20 15:26:07 2016
> New Revision: 290202
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
> Log:
> [clang-tidy] Add modernize-use-default-member-init check
>
> Summary: Fixes PR18858

This appears to have broken one of the bots:

http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/33046

~Aaron

>
> Reviewers: alexfh, hokein, aaron.ballman
>
> Subscribers: JDevlieghere, Eugene.Zelenko, Prazek, mgorny, cfe-commits, 
> modocache
>
> Differential Revision: https://reviews.llvm.org/D26750
>
> Added:
> clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
> 
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
> 
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.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/ReleaseNotes.rst
> 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=290202=290201=290202=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Dec 20 
> 15:26:07 2016
> @@ -16,6 +16,7 @@ add_clang_library(clangTidyModernizeModu
>ShrinkToFitCheck.cpp
>UseAutoCheck.cpp
>UseBoolLiteralsCheck.cpp
> +  UseDefaultMemberInitCheck.cpp
>UseEmplaceCheck.cpp
>UseEqualsDefaultCheck.cpp
>UseEqualsDeleteCheck.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=290202=290201=290202=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
> Dec 20 15:26:07 2016
> @@ -22,6 +22,7 @@
>  #include "ShrinkToFitCheck.h"
>  #include "UseAutoCheck.h"
>  #include "UseBoolLiteralsCheck.h"
> +#include "UseDefaultMemberInitCheck.h"
>  #include "UseEmplaceCheck.h"
>  #include "UseEqualsDefaultCheck.h"
>  #include "UseEqualsDeleteCheck.h"
> @@ -56,6 +57,8 @@ public:
>  CheckFactories.registerCheck("modernize-use-auto");
>  CheckFactories.registerCheck(
>  "modernize-use-bool-literals");
> +CheckFactories.registerCheck(
> +"modernize-use-default-member-init");
>  CheckFactories.registerCheck("modernize-use-emplace");
>  
> CheckFactories.registerCheck("modernize-use-equals-default");
>  CheckFactories.registerCheck(
>
> Added: 
> clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290202=auto
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
> (added)
> +++ 
> clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
> Tue Dec 20 15:26:07 2016
> @@ -0,0 +1,241 @@
> +//===--- UseDefaultMemberInitCheck.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 "UseDefaultMemberInitCheck.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +#include "clang/Lex/Lexer.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace modernize {
> +
> +static StringRef getValueOfValueInit(const QualType InitType) {
> +  switch (InitType->getScalarTypeKind()) {
> +  case Type::STK_CPointer:
> +  case Type::STK_BlockPointer:
> +  case Type::STK_ObjCObjectPointer:
> +  case Type::STK_MemberPointer:
> +return "nullptr";
> +
> +  case Type::STK_Bool:
> +return "false";
> +
> +  case Type::STK_Integral:
> +switch (InitType->getAs()->getKind()) {
> +case BuiltinType::Char_U:
> +case BuiltinType::UChar:
> +case BuiltinType::Char_S:
> +case 

[PATCH] D27956: Make CodeGenCXX/stack-reuse-miscompile.cpp tolerate C++11

2016-12-20 Thread Leny Kholodov via Phabricator via cfe-commits
lenykholodov added a comment.

LGTM


https://reviews.llvm.org/D27956



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


[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Wouldn't it be simpler to just record an insertion point for the beginning of 
the current lexical scope and insert the lifetime.begin there instead of at the 
current IP?




Comment at: lib/CodeGen/CodeGenFunction.h:351
 llvm::Value *Size;
+llvm::CallInst *LifetimeStart;
 

Addr and Size are recoverable from this.


https://reviews.llvm.org/D27680



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


[PATCH] D27936: C++11 test cleanup: nonthrowing destructors

2016-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Nicely done.


https://reviews.llvm.org/D27936



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


[PATCH] D27994: Make two vtable tests tolerate C++11

2016-12-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

No, seems fine to me.


https://reviews.llvm.org/D27994



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


Re: r290080 - [c++1z] P0195R2: Support pack-expansion of using-declarations.

2016-12-20 Thread Richard Smith via cfe-commits
On 19 December 2016 at 04:26, Renato Golin  wrote:

> On 19 December 2016 at 11:28, Daniel Jasper via cfe-commits
>  wrote:
> > I have reverted this in r290092 as it was leading to Clang crashes on the
> > bots and elsewhere, e.g.:
> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814
>
> Hi Daniel, Richard,
>
> This is will red on our LNT bot, which started with this commit:
>
> http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1354
>
> and still has the same failures on the last build:
>
> http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1360
>
> this is one of the 5 different failures we have in all our bots...
> After so many fix-patches and reverts, I'm not surprised we got into
> this corner of mayhem.
>
> I'd like to ask people a bit more care and worry about the bots.
>

Sorry about that. There was an unrelated change causing bot failures at the
same time, and having checked some of the buildbot failures I incorrectly
assumed they were all caused by that other failure.

Should be fixed in r290203, but I'll see whether the bots agree :)

Most of the time, reverting the whole patch and talking to the bot
> owners is a much better strategy than push-fix a bunch of trail and
> errors.
>
> cheers,
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290203 - [c++1z] P0195R2: Support pack-expansion of using-declarations.

2016-12-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Dec 20 15:35:28 2016
New Revision: 290203

URL: http://llvm.org/viewvc/llvm-project?rev=290203=rev
Log:
[c++1z] P0195R2: Support pack-expansion of using-declarations.

This change introduces UsingPackDecl as a marker for the set of UsingDecls
produced by pack expansion of a single (unresolved) using declaration. This is
not strictly necessary (we just need to be able to map from the original using
declaration to its expansions somehow), but it's useful to maintain the
invariant that each declaration reference instantiates to refer to one
declaration.

This is a re-commit of r290080 (reverted in r290092) with a fix for a
use-after-lifetime bug.

Added:
cfe/trunk/test/PCH/cxx1z-using-declaration.cpp
  - copied unchanged from r290091, 
cfe/trunk/test/PCH/cxx1z-using-declaration.cpp
cfe/trunk/test/SemaTemplate/cxx1z-using-declaration.cpp
  - copied unchanged from r290091, 
cfe/trunk/test/SemaTemplate/cxx1z-using-declaration.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/Template.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Parser/cxx1z-using-declaration.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=290203=290202=290203=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Dec 20 15:35:28 2016
@@ -3140,6 +3140,77 @@ public:
   friend class ASTDeclWriter;
 };
 
+/// Represents a pack of using declarations that a single
+/// using-declarator pack-expanded into.
+///
+/// \code
+/// template struct X : T... {
+///   using T::operator()...;
+///   using T::operator T...;
+/// };
+/// \endcode
+///
+/// In the second case above, the UsingPackDecl will have the name
+/// 'operator T' (which contains an unexpanded pack), but the individual
+/// UsingDecls and UsingShadowDecls will have more reasonable names.
+class UsingPackDecl final
+: public NamedDecl, public Mergeable,
+  private llvm::TrailingObjects {
+  void anchor() override;
+
+  /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from
+  /// which this waas instantiated.
+  NamedDecl *InstantiatedFrom;
+
+  /// The number of using-declarations created by this pack expansion.
+  unsigned NumExpansions;
+
+  UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom,
+ArrayRef UsingDecls)
+  : NamedDecl(UsingPack, DC,
+  InstantiatedFrom ? InstantiatedFrom->getLocation()
+   : SourceLocation(),
+  InstantiatedFrom ? InstantiatedFrom->getDeclName()
+   : DeclarationName()),
+InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
+std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
+getTrailingObjects());
+  }
+
+public:
+  /// Get the using declaration from which this was instantiated. This will
+  /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl
+  /// that is a pack expansion.
+  NamedDecl *getInstantiatedFromUsingDecl() { return InstantiatedFrom; }
+
+  /// Get the set of using declarations that this pack expanded into. Note that
+  /// some of these may still be unresolved.
+  ArrayRef expansions() const {
+return llvm::makeArrayRef(getTrailingObjects(), 
NumExpansions);
+  }
+
+  static UsingPackDecl *Create(ASTContext , DeclContext *DC,
+   NamedDecl *InstantiatedFrom,
+   ArrayRef UsingDecls);
+
+  static UsingPackDecl *CreateDeserialized(ASTContext , unsigned ID,
+   unsigned NumExpansions);
+
+  SourceRange getSourceRange() const override LLVM_READONLY {
+return InstantiatedFrom->getSourceRange();
+  }
+
+  UsingPackDecl *getCanonicalDecl() override { return getFirstDecl(); }
+  const 

[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2016-12-20 Thread Tim Shen via Phabricator via cfe-commits
timshen added a comment.

I changed type style to early return.

For constructors and destructors, I use:

  if (...) {
// statement;
return;
  }

For normal functions that returns void, I chose:

  if (...)
return Foo();
  llvm_unreachable(...);

since it's more compact. If returning void looks weird, we should add it to the 
style guide.

Other functions are not controversial.


https://reviews.llvm.org/D27872



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


[PATCH] D27872: [APFloat] Switch from (PPCDoubleDoubleImpl, IEEEdouble) layout to (IEEEdouble, IEEEdouble)

2016-12-20 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 82148.
timshen added a comment.

Consistently use early return style.


https://reviews.llvm.org/D27872

Files:
  clang/test/CodeGen/ppc64-complex-parms.c
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp
  llvm/test/CodeGen/PowerPC/fp128-bitcast-after-operation.ll
  llvm/unittests/ADT/APFloatTest.cpp

Index: llvm/unittests/ADT/APFloatTest.cpp
===
--- llvm/unittests/ADT/APFloatTest.cpp
+++ llvm/unittests/ADT/APFloatTest.cpp
@@ -9,6 +9,7 @@
 
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
@@ -3262,7 +3263,7 @@
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) + ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3296,7 +3297,7 @@
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
-EXPECT_EQ(Expected[1], A1.getSecondFloat().bitcastToAPInt().getRawData()[0])
+EXPECT_EQ(Expected[1], A1.bitcastToAPInt().getRawData()[1])
 << formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
@@ -3496,12 +3497,53 @@
 APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
 APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
 EXPECT_EQ(Expected, A1.compare(A2))
-<< formatv("({0:x} + {1:x}) - ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
+<< formatv("compare(({0:x} + {1:x}), ({2:x} + {3:x}))", Op1[0], Op1[1],
+   Op2[0], Op2[1])
+   .str();
+  }
+}
+
+TEST(APFloatTest, PPCDoubleDoubleBitwiseIsEqual) {
+  using DataType = std::tuple;
+
+  DataType Data[] = {
+  // (1 + 0) = (1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff0ull, 0, true),
+  // (1 + 0) != (1.00...1 + 0)
+  std::make_tuple(0x3ff0ull, 0, 0x3ff1ull, 0,
+  false),
+  // NaN = NaN
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull, 0, true),
+  // NaN != NaN with a different bit pattern
+  std::make_tuple(0x7ff8ull, 0, 0x7ff8ull,
+  0x3ff0ull, false),
+  // Inf = Inf
+  std::make_tuple(0x7ff0ull, 0, 0x7ff0ull, 0, true),
+  };
+
+  for (auto Tp : Data) {
+uint64_t Op1[2], Op2[2];
+bool Expected;
+std::tie(Op1[0], Op1[1], Op2[0], Op2[1], Expected) = Tp;
+
+APFloat A1(APFloat::PPCDoubleDouble(), APInt(128, 2, Op1));
+APFloat A2(APFloat::PPCDoubleDouble(), APInt(128, 2, Op2));
+EXPECT_EQ(Expected, A1.bitwiseIsEqual(A2))
+<< formatv("({0:x} + {1:x}) = ({2:x} + {3:x})", Op1[0], Op1[1], Op2[0],
Op2[1])
.str();
   }
 }
 
+TEST(APFloatTest, PPCDoubleDoubleHashValue) {
+  uint64_t Data1[] = {0x3ff1ull, 0x0001ull};
+  uint64_t Data2[] = {0x3ff1ull, 0};
+  // The hash values are *hopefully* different.
+  EXPECT_NE(
+  hash_value(APFloat(APFloat::PPCDoubleDouble(), APInt(128, 2, Data1))),
+  hash_value(APFloat(APFloat::PPCDoubleDouble(), APInt(128, 2, Data2;
+}
+
 TEST(APFloatTest, PPCDoubleDoubleChangeSign) {
   uint64_t Data[] = {
   0x400full, 0xbcb0ull,
@@ -3531,6 +3573,13 @@
   }
   {
 uint64_t Data[] = {
+0x7fefull, 0x7c8eull,
+};
+EXPECT_EQ(APInt(128, 2, Data),
+  APFloat::getLargest(APFloat::PPCDoubleDouble()).bitcastToAPInt());
+  }
+  {
+uint64_t Data[] = {
 0x0001ull, 0,
 };
 EXPECT_EQ(
@@ -3553,24 +3602,72 @@
   }
   {
 uint64_t Data[] = {
+0xffefull, 0xfc8eull,
+};
+EXPECT_EQ(
+APInt(128, 2, Data),
+APFloat::getLargest(APFloat::PPCDoubleDouble(), true).bitcastToAPInt());
+  }
+  {
+uint64_t Data[] = {
 0x8001ull, 0xull,
 };
 EXPECT_EQ(APInt(128, 2, Data),
   APFloat::getSmallest(APFloat::PPCDoubleDouble(), true)
   .bitcastToAPInt());
   }
-
-  EXPECT_EQ(0x8360ull,
-APFloat::getSmallestNormalized(APFloat::PPCDoubleDouble(), true)
-.bitcastToAPInt()
-.getRawData()[0]);
-  EXPECT_EQ(0xull,
-APFloat::getSmallestNormalized(APFloat::PPCDoubleDouble(), true)
-

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290202: [clang-tidy] Add modernize-use-default-member-init 
check (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26750?vs=82113=82144#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26750

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -108,6 +108,12 @@
 
 - The modernize-use-default check has been renamed to `modernize-use-equals-default
   `_.
+  
+- New `modernize-use-default-member-init
+  `_ check
+
+  Converts a default constructor's member initializers into default member initializers.
+  Removes member initializers that are the same as a default member initializer.
 
 - New `modernize-use-equals-delete
   `_ check
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
@@ -110,6 +110,7 @@
modernize-shrink-to-fit
modernize-use-auto
modernize-use-bool-literals
+   modernize-use-default-member-init
modernize-use-emplace
modernize-use-equals-default
modernize-use-equals-delete
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - modernize-use-default-member-init
+
+modernize-use-default-member-init
+=
+
+This check converts a default constructor's member initializers into the new
+default member initializers in C++11. Other member initializers that match the
+default member initializer are removed. This can reduce repeated code or allow
+use of '= default'.
+
+.. code-block:: c++
+
+  struct A {
+A() : i(5), j(10.0) {}
+A(int i) : i(i), j(10.0) {}
+int i;
+double j;
+  };
+
+  // becomes
+
+  struct A {
+A() {}
+A(int i) : i(i) {}
+int i{5};
+double j{10.0};
+  };
+
+.. note::
+  Only converts member initializers for built-in types, enums, and pointers.
+  The `readability-redundant-member-init` check will remove redundant member
+  initializers for classes.
+
+Options
+---
+
+.. option:: UseAssignment
+
+   If this option is set to non-zero (default is `0`), the check will initialise
+   members with an assignment. For example:
+
+.. code-block:: c++
+
+  struct A {
+A() {}
+A(int i) : i(i) {}
+int i = 5;
+double j = 10.0;
+  };
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,376 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueChar {
+  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  // CHECK-FIXES: PositiveValueChar()  {}
+  const char c0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c0' [modernize-use-default-member-init]
+  // CHECK-FIXES: const char c0{};
+  wchar_t c1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer for 'c1'
+  // CHECK-FIXES: wchar_t c1{};
+  char16_t c2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c2'
+  // CHECK-FIXES: char16_t c2{};
+  char32_t c3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c3'
+  // CHECK-FIXES: char32_t c3{};
+};
+
+struct PositiveChar {

[clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 20 15:26:07 2016
New Revision: 290202

URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
Log:
[clang-tidy] Add modernize-use-default-member-init check

Summary: Fixes PR18858

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: JDevlieghere, Eugene.Zelenko, Prazek, mgorny, cfe-commits, 
modocache

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.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/ReleaseNotes.rst
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=290202=290201=290202=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Dec 20 
15:26:07 2016
@@ -16,6 +16,7 @@ add_clang_library(clangTidyModernizeModu
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
+  UseDefaultMemberInitCheck.cpp
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=290202=290201=290202=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
Dec 20 15:26:07 2016
@@ -22,6 +22,7 @@
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
+#include "UseDefaultMemberInitCheck.h"
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
@@ -56,6 +57,8 @@ public:
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
+CheckFactories.registerCheck(
+"modernize-use-default-member-init");
 CheckFactories.registerCheck("modernize-use-emplace");
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290202=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Tue Dec 20 15:26:07 2016
@@ -0,0 +1,241 @@
+//===--- UseDefaultMemberInitCheck.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 "UseDefaultMemberInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+static StringRef getValueOfValueInit(const QualType InitType) {
+  switch (InitType->getScalarTypeKind()) {
+  case Type::STK_CPointer:
+  case Type::STK_BlockPointer:
+  case Type::STK_ObjCObjectPointer:
+  case Type::STK_MemberPointer:
+return "nullptr";
+
+  case Type::STK_Bool:
+return "false";
+
+  case Type::STK_Integral:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::Char_U:
+case BuiltinType::UChar:
+case BuiltinType::Char_S:
+case BuiltinType::SChar:
+  return "'\\0'";
+case BuiltinType::WChar_U:
+case BuiltinType::WChar_S:
+  return "L'\\0'";
+case BuiltinType::Char16:
+  return "u'\\0'";
+case BuiltinType::Char32:
+  return "U'\\0'";
+default:
+  return "0";
+}
+
+  case Type::STK_Floating:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::Half:
+case BuiltinType::Float:
+  return "0.0f";
+default:
+  return "0.0";
+

[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

2016-12-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 82142.
ahatanak added a comment.

Rebase and improve test cases.

- Add "-mllvm -disable-llvm-optzns" to the RUN line.
- Add a test case that shows lifetime.start of a variable isn't moved to the 
beginning of its scope when the goto leaves the scope.


https://reviews.llvm.org/D27680

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,4 +1,4 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O2 -mllvm -disable-llvm-optzns %s | FileCheck %s -check-prefixes=CHECK,O2
 // RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
@@ -19,11 +19,11 @@
 
 // CHECK-LABEL: @no_goto_bypass
 void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 5
   // O2: @llvm.lifetime.start(i64 1
   char x;
 l1:
   bar(, 1);
-  // O2: @llvm.lifetime.start(i64 5
   // O2: @llvm.lifetime.end(i64 5
   char y[5];
   bar(y, 5);
@@ -89,3 +89,58 @@
 L:
   bar(, 1);
 }
+
+// O2-LABEL: define i32 @move_lifetime_start
+// O2: %i = alloca i32, align 4
+// O2: %[[BITCAST:[0-9]+]] = bitcast i32* %i to i8*
+// O2: call void @llvm.lifetime.start(i64 4, i8* %[[BITCAST]])
+// O2: br label %[[DESTLABEL:[a-z0-9]+]]
+// O2: [[DESTLABEL]]:
+// O2: switch i32 %{{.*}}, label %{{.*}} [
+// O2-NEXT: i32 2, label %[[DESTLABEL]]
+
+extern void foo2(int p);
+
+int move_lifetime_start(int a) {
+  int *p = 0;
+label1:
+  if (p) {
+foo2(*p);
+return 0;
+  }
+
+  int i = 999;
+  if (a != 2) {
+p = 
+goto label1;
+  }
+  return -1;
+}
+
+// O2-LABEL: define i32 @dont_move_lifetime_start
+// O2: %i = alloca i32, align 4
+// O2: br label %[[DESTLABEL:[a-z0-9]+]]
+// O2: [[DESTLABEL]]:
+// O2: %[[BITCAST:[0-9]+]] = bitcast i32* %i to i8*
+// O2: call void @llvm.lifetime.start(i64 4, i8* %[[BITCAST]])
+// O2: switch i32 %{{.*}}, label %{{.*}} [
+// O2-NEXT: i32 0, label %{{.*}}
+// O2-NEXT: i32 2, label %[[DESTLABEL]]
+
+int dont_move_lifetime_start(int a) {
+  int *p = 0;
+label1:
+  {
+if (p) {
+  foo2(*p);
+  return 0;
+}
+
+int i = 999;
+if (a != 2) {
+  p = 
+  goto label1;
+}
+  }
+  return -1;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -348,14 +348,20 @@
   class CallLifetimeEnd final : public EHScopeStack::Cleanup {
 llvm::Value *Addr;
 llvm::Value *Size;
+llvm::CallInst *LifetimeStart;
 
   public:
-CallLifetimeEnd(Address addr, llvm::Value *size)
-: Addr(addr.getPointer()), Size(size) {}
+CallLifetimeEnd(Address addr, llvm::Value *size,
+llvm::CallInst *lifetimeStart = nullptr)
+: Addr(addr.getPointer()), Size(size), LifetimeStart(lifetimeStart) {}
 
 void Emit(CodeGenFunction , Flags flags) override {
   CGF.EmitLifetimeEnd(Size, Addr);
 }
+
+llvm::CallInst *() {
+  return LifetimeStart;
+}
   };
 
   /// Header for data within LifetimeExtendedCleanupStack.
@@ -523,10 +529,10 @@
   /// \brief Enters a new scope for capturing cleanups, all of which
   /// will be executed once the scope is exited.
   class RunCleanupsScope {
-EHScopeStack::stable_iterator CleanupStackDepth;
 size_t LifetimeExtendedCleanupStackSize;
 bool OldDidCallStackSave;
   protected:
+EHScopeStack::stable_iterator CleanupStackDepth;
 bool PerformCleanup;
   private:
 
@@ -578,6 +584,7 @@
 SourceRange Range;
 SmallVector Labels;
 LexicalScope *ParentScope;
+llvm::BasicBlock *BB;
 
 LexicalScope(const LexicalScope &) = delete;
 void operator=(const LexicalScope &) = delete;
@@ -589,13 +596,27 @@
   CGF.CurLexicalScope = this;
   if (CGDebugInfo *DI = CGF.getDebugInfo())
 DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
+  CGF.EnsureInsertPoint();
+  BB = CGF.Builder.GetInsertBlock();
 }
 
 void addLabel(const LabelDecl *label) {
   assert(PerformCleanup && "adding label to dead scope?");
   Labels.push_back(label);
 }
 
+EHScopeStack::stable_iterator getCleanupStackDepth() const {
+  return CleanupStackDepth;
+}
+
+llvm::BasicBlock *getBasicBlock() const {
+  return BB;
+}
+
+LexicalScope *getParentScope() const {
+  return ParentScope;
+}
+
 /// \brief Exit this cleanup scope, emitting any accumulated
 /// cleanups.
 ~LexicalScope() {
@@ -620,6 +641,10 @@
 rescopeLabels();
 }
 
+bool hasLabel(const LabelDecl *LD) const {
+  return llvm::is_contained(Labels, LD);
+}
+
 void rescopeLabels();
   };
 
@@ -2184,7 +2209,7 @@
   void 

[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

2016-12-20 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM, but fix what @bruno spotted before committing.


https://reviews.llvm.org/D27832



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-12-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/TreeTransform.h:8766-8767
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
 

rsmith wrote:
> Likewise here, you should return `ExprError()` if the transformed name is 
> null (please also add an assert that the name is not null before the 
> transform, as in that case a null transformed name would not indicate an 
> error has been diagnosed).
I discovered that the name can be null when the member expression is a member 
of an anonymous union and therefore an assert would cause a few regression 
tests to fail. For example, the following code would assert:


```
struct T0 {
  union {
void *m0;
  };
};
template 
struct T1 : public T0 {
  void f0() {
m0 = 0;
  }
};

struct A : public T0 { };

void f1(T1 *S) { S->f0(); }
```


https://reviews.llvm.org/D24969



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-12-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 82134.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Add code for error recovery.


https://reviews.llvm.org/D24969

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/destructor.cpp


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8763,12 +8763,18 @@
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+  if (MemberNameInfo.getName()) {
+MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+if (!MemberNameInfo.getName())
+  return ExprError();
+  }
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4846,8 +4846,12 @@
 }
 
 NamedDecl *Result = nullptr;
-if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+if (auto Name = D->getDeclName()) {
+  DeclarationNameInfo NameInfo(Name, D->getLocation());
+  Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+  if (!Name)
+return nullptr;
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8763,12 +8763,18 @@
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+  if (MemberNameInfo.getName()) {
+MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+if (!MemberNameInfo.getName())
+  return ExprError();
+  }
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4846,8 +4846,12 @@
 }
 
 NamedDecl *Result = nullptr;
-if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+if (auto Name = D->getDeclName()) {
+  DeclarationNameInfo NameInfo(Name, D->getLocation());
+  Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+  if (!Name)
+return nullptr;
+  

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you!


https://reviews.llvm.org/D26750



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


[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

2016-12-20 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Are there any negative effects from having the duplicates in edges?

When does this occur? It's a bit suspicious since we have a FromN, and a path 
is split at that node, resulting in successors that are the same. Is it 
possible that whoever split the state did not encode enough interesting info?


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



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


[PATCH] D27994: Make two vtable tests tolerate C++11

2016-12-20 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: rjmccall.
probinson added a subscriber: cfe-commits.

In C++11, we don't emit vtables as eagerly as we do for C++03, so fiddle the 
tests to emit them when the test expects them.

In the C++11 test cleanup project, we're commonly making the tests run in both 
dialects and sometimes with no dialect specified (as Clang's default will 
presumably advance to C++14/17 at some point).  I didn't do that for 
vtable-layout.cpp because it runs FileCheck 46 times, and replicating that 
really seemed like too much.
If it also seems like too much for vtable-linkage.cpp, the easy thing is to 
force it to C++03.


https://reviews.llvm.org/D27994

Files:
  test/CodeGenCXX/vtable-layout.cpp
  test/CodeGenCXX/vtable-linkage.cpp


Index: test/CodeGenCXX/vtable-linkage.cpp
===
--- test/CodeGenCXX/vtable-linkage.cpp
+++ test/CodeGenCXX/vtable-linkage.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 
-emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template
 struct E {
Index: test/CodeGenCXX/vtable-layout.cpp
===
--- test/CodeGenCXX/vtable-layout.cpp
+++ test/CodeGenCXX/vtable-layout.cpp
@@ -1919,6 +1919,8 @@
 virtual int i(int);
 virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 


Index: test/CodeGenCXX/vtable-linkage.cpp
===
--- test/CodeGenCXX/vtable-linkage.cpp
+++ test/CodeGenCXX/vtable-linkage.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++03 -o %t.03
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux -emit-llvm -std=c++11 -o %t.11
 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -disable-llvm-optzns -O3 -emit-llvm -o %t.opt
 // RUN: FileCheck %s < %t
+// RUN: FileCheck %s < %t.03
+// RUN: FileCheck %s < %t.11
 // RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt
 
 namespace {
@@ -33,6 +37,11 @@
 
 static struct : D { } e;
 
+// Force 'e' to be constructed and therefore have a vtable defined.
+void use_e() {
+  e.f();
+}
+
 // The destructor is the key function.
 template
 struct E {
Index: test/CodeGenCXX/vtable-layout.cpp
===
--- test/CodeGenCXX/vtable-layout.cpp
+++ test/CodeGenCXX/vtable-layout.cpp
@@ -1919,6 +1919,8 @@
 virtual int i(int);
 virtual int i();
   };
+  // Force C's vtable to be generated.
+  int C::f() { return 1; }
 
   class D : C {};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27836: Store the "current position" index within the ASTRecordReader.

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

LGTM, any chance I can tempt you to lowerCamelCase all the other 
ASTRecordReader members to match the new ones as a follow-up change?


https://reviews.llvm.org/D27836



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


[PATCH] D27936: C++11 test cleanup: nonthrowing destructors

2016-12-20 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: rjmccall.
probinson added a comment.

+rjmccall as IR Gen owner.


https://reviews.llvm.org/D27936



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


[PATCH] D24639: [Sema] Warn when returning a lambda that captures a local variable by reference

2016-12-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D24639



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-12-20 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Looks good, other than error recovery.




Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:4851
+  DeclarationNameInfo NameInfo(Name, D->getLocation());
+  Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);

You should deal with the possibility of `SubstDeclarationNameInfo` failing 
(which will happen if substitution into the name creates an invalid type). If 
you get a null name back from the `Subst` call, just return null.



Comment at: lib/Sema/TreeTransform.h:8766-8767
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
 

Likewise here, you should return `ExprError()` if the transformed name is null 
(please also add an assert that the name is not null before the transform, as 
in that case a null transformed name would not indicate an error has been 
diagnosed).


https://reviews.llvm.org/D24969



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-12-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 82120.
ahatanak added a comment.

Call TransformDeclarationNameInfo unconditionally to transform NameInfo rather 
than doing so only for destructors. I think this is a cleaner fix.


https://reviews.llvm.org/D24969

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/destructor.cpp


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8763,12 +8763,14 @@
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4846,8 +4846,10 @@
 }
 
 NamedDecl *Result = nullptr;
-if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+if (auto Name = D->getDeclName()) {
+  DeclarationNameInfo NameInfo(Name, D->getLocation());
+  Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8763,12 +8763,14 @@
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo =
+  getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4846,8 +4846,10 @@
 }
 
 NamedDecl *Result = nullptr;
-if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+if (auto Name = D->getDeclName()) {
+  DeclarationNameInfo NameInfo(Name, D->getLocation());
+  Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,
___
cfe-commits mailing list

Re: r290181 - [OPENMP] Fix for PR31416: Clang crashes on OMPCapturedExpr during source

2016-12-20 Thread Vedant Kumar via cfe-commits
Thank you for looking into this :)!

I noticed that your test case doesn't hit the code coverage path, however.

Perhaps it would be better to remove the PROF-INSTR-PATH check and instead
introduce something like `test/CoverageMapping/openmp.cpp`:

  // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -std=c++11 -fprofile-instrument=clang 
-fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name 
openmp.cpp %s | FileCheck %s -check-prefix=COV
  // Construct an OMPCapturedExpr in some function 'f'...
  // COV: f

Initially the test can just check that we emit a coverage mapping for the
function 'f'. Later, I can flesh out the test with precise checks.

best,
vedant

> On Dec 20, 2016, at 8:51 AM, Alexey Bataev via cfe-commits 
>  wrote:
> 
> Author: abataev
> Date: Tue Dec 20 10:51:02 2016
> New Revision: 290181
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=290181=rev
> Log:
> [OPENMP] Fix for PR31416: Clang crashes on OMPCapturedExpr during source
> based coverage compilation
> 
> Added source location info to captured expression declaration + fixed
> source location info for loop based directives.
> 
> Modified:
>cfe/trunk/include/clang/AST/DeclOpenMP.h
>cfe/trunk/lib/AST/DeclOpenMP.cpp
>cfe/trunk/lib/Sema/SemaOpenMP.cpp
>cfe/trunk/test/OpenMP/for_codegen.cpp
> 
> Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=290181=290180=290181=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
> +++ cfe/trunk/include/clang/AST/DeclOpenMP.h Tue Dec 20 10:51:02 2016
> @@ -173,18 +173,21 @@ class OMPCapturedExprDecl final : public
>   void anchor() override;
> 
>   OMPCapturedExprDecl(ASTContext , DeclContext *DC, IdentifierInfo *Id,
> -  QualType Type)
> -  : VarDecl(OMPCapturedExpr, C, DC, SourceLocation(), SourceLocation(), 
> Id,
> -Type, nullptr, SC_None) {
> +  QualType Type, SourceLocation StartLoc)
> +  : VarDecl(OMPCapturedExpr, C, DC, StartLoc, SourceLocation(), Id, Type,
> +nullptr, SC_None) {
> setImplicit();
>   }
> 
> public:
>   static OMPCapturedExprDecl *Create(ASTContext , DeclContext *DC,
> - IdentifierInfo *Id, QualType T);
> + IdentifierInfo *Id, QualType T,
> + SourceLocation StartLoc);
> 
>   static OMPCapturedExprDecl *CreateDeserialized(ASTContext , unsigned ID);
> 
> +  SourceRange getSourceRange() const override LLVM_READONLY;
> +
>   // Implement isa/cast/dyncast/etc.
>   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
>   static bool classofKind(Kind K) { return K == OMPCapturedExpr; }
> 
> Modified: cfe/trunk/lib/AST/DeclOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclOpenMP.cpp?rev=290181=290180=290181=diff
> ==
> --- cfe/trunk/lib/AST/DeclOpenMP.cpp (original)
> +++ cfe/trunk/lib/AST/DeclOpenMP.cpp Tue Dec 20 10:51:02 2016
> @@ -90,13 +90,18 @@ OMPDeclareReductionDecl::getPrevDeclInSc
> void OMPCapturedExprDecl::anchor() {}
> 
> OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext , DeclContext 
> *DC,
> - IdentifierInfo *Id,
> - QualType T) {
> -  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T);
> + IdentifierInfo *Id, 
> QualType T,
> + SourceLocation StartLoc) {
> +  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T, StartLoc);
> }
> 
> OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext ,
>  unsigned ID) {
> -  return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType());
> +  return new (C, ID)
> +  OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), SourceLocation());
> }
> 
> +SourceRange OMPCapturedExprDecl::getSourceRange() const {
> +  assert(hasInit());
> +  return SourceRange(getInit()->getLocStart(), getInit()->getLocEnd());
> +}
> 
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=290181=290180=290181=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec 20 10:51:02 2016
> @@ -1753,7 +1753,8 @@ static OMPCapturedExprDecl *buildCapture
> }
> WithInit = true;
>   }
> -  auto *CED = OMPCapturedExprDecl::Create(C, S.CurContext, Id, Ty);
> +  auto *CED = 

[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Hi,

Thanks for working on this.




Comment at: include/clang/Basic/DiagnosticLexKinds.td:647
+  "top-level module '%0' in private module map, expected a submodule of '%1'">,
+  InGroup>;
 

It would be nice if we could also emit a FixIt to tell the user how should the 
modulemap be fixed.



Comment at: lib/Lex/HeaderSearch.cpp:208
+  // FooPrivate.framework.
+  if (!Module && SearchName.consume_back("Private")) {
+Module = lookupModule(ModuleName, SearchName);

Remove the curly braces here



Comment at: lib/Lex/HeaderSearch.cpp:211
+  }
+
+  return Module;

Remove this newline



Comment at: lib/Lex/HeaderSearch.cpp:216
+Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) 
{
+
+  Module *Module = nullptr;

Remove this newline



Comment at: test/Modules/implicit-private-with-different-name.m:9
+
+// 
expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{expected
 a submodule}}
+

Can you check for the entire warning message?


https://reviews.llvm.org/D27852



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


[PATCH] D27852: [modules] Handle modules with nonstandard names in module.private.modulemaps

2016-12-20 Thread Manman Ren via Phabricator via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

Thanks,
Manman


https://reviews.llvm.org/D27852



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


Re: [PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-12-20 Thread Attila Török via cfe-commits
Thank you for your detailed explanation!
It would seem perfectly reasonable to define the behavior in this case, at
least (and I suppose not only) to me.
Attila

2016-12-20 14:50 GMT+01:00 Aaron Ballman :

> On Tue, Dec 20, 2016 at 7:58 AM, Attila Török 
> wrote:
> > I did not see that it was reapplied later, sorry.
> >
> > With clang version 3.9.0 (tags/RELEASE_390/final) I get the warning in
> both
> > c11 and c++11 mode.
> > With clang version 4.0.0 (trunk 290146) (llvm/trunk 290118) it's gone in
> c11
> > mode, but still there in c++11.
> > The piece of code I tested it on:
> > https://gist.github.com/torokati44/37e6aca2d516cb7c3cb31b7ccf8a519e
> >
> > In the part of the code affected by the patch, ED->getPromotionType() is
> > BuiltinType 'int', and Type is EnumType 'enum E'.
> > For these two types, Context.typesAreCompatible returns true in c11 mode,
> > but false in c++11 mode (regardless of which underlying type - or if any
> -
> > is specified).
> > I presume this is the intended behavior. And if so, how could the example
> > code be modified to make it warning-free in c++, while keeping the
> parameter
> > an enum, and not making it a simple int?
>
> Yes, that behavior is intended. The answer to how to modify the code
> involves the C++ standards committee, though. [cstdarg.syn]p1 says, in
> part,
>
> The parameter parmN is the identifier of the rightmost parameter in
> the variable parameter list of the function definition (the one just
> before the ...). If the parameter parmN is of a reference type, or of
> a type that is not compatible with the type that results when passing
> an argument for which there is no parameter, the behavior is
> undefined.
>
> When typesAreCompatible() returns false, that means you are triggering
> UB with your code.
>
> The reason the C++ behavior differs from the C behavior when calling
> typesAreCompaible() is because type compatibility (as a language
> construct) is a C notion; in C++ this maps to "are the types the
> same", which is not true for an enum type and an int type (even with
> an explicit underlying type).
>
> However, there are questions as to whether this should be UB or not
> that I've raised with WG21 (I don't have a Core defect report for it
> yet though). For right now, the safest answer is: change the parameter
> to be an int, because that is definitely not UB. There may be a more
> satisfactory answer in the future.
>
> ~Aaron
>
> >
> > Thank you,
> > Attila
> >
> > 2016-12-19 18:36 GMT+01:00 Aaron Ballman :
> >>
> >> On Fri, Dec 16, 2016 at 7:00 AM, Attila Török via Phabricator
> >>  wrote:
> >> > torokati44 added a comment.
> >> >
> >> > I see this has been reverted in r281612, but I can no longer access
> the
> >> > build log serving as a reason linked in the message:
> >> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg35386.html
> >> > We have a few false-positive warnings that (I think) would be silenced
> >> > by this change. I'm just wondering if something like this, if not
> this,
> >> > could be included anyway? Not critical of course, it just would be
> nice.
> >>
> >> This patch was reapplied in r281632:
> >>
> >>
> >> http://lists.llvm.org/pipermail/cfe-commits/Week-of-
> Mon-20160912/170772.html
> >>
> >> Do you still have false positives even with that applied?
> >>
> >> Thanks!
> >>
> >> ~Aaron
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23325: [WIP] Binding of references to packed fields

2016-12-20 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 updated this revision to Diff 82114.
rogfer01 added a comment.

Minor issues addressed


https://reviews.llvm.org/D23325

Files:
  include/clang/AST/Decl.h
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Sema/Initialization.h
  lib/AST/ASTDumper.cpp
  lib/AST/Decl.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaFixItUtils.cpp
  lib/Sema/SemaInit.cpp
  test/CodeGenCXX/pod-member-memcpys.cpp
  test/SemaCXX/bind-packed-member.cpp

Index: test/SemaCXX/bind-packed-member.cpp
===
--- test/SemaCXX/bind-packed-member.cpp
+++ test/SemaCXX/bind-packed-member.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -verify %s
+
+struct __attribute__((packed)) A {
+  char x;
+  float y;
+  char z;
+} a;
+
+char  = a.x;  // no-error
+float  = a.y; // expected-error {{reference cannot bind to packed field}}
+char  = a.z;  // no-error
+
+struct __attribute__((packed, aligned(2))) B {
+  // Regardless of aligned(2) the fields are aligned(1) because of packed.
+  // The whole struct is aligned(2), though.
+  short x;
+  float y;
+  short z;
+  char w;
+} b;
+
+const short  = b.x; // no-error
+short  = b.x; // expected-error {{reference cannot bind to packed field}}
+float  = b.y; // expected-error {{reference cannot bind to packed field}}
+short  = b.z; // expected-error {{reference cannot bind to packed field}}
+char  = b.w;  // no-error
+
+struct __attribute__((packed)) B2 {
+  short x __attribute__((aligned(2)));
+  float y;
+  short z __attribute__((aligned(4)));
+  char w;
+} b2;
+
+short  = b2.x; // no-error
+short  = b2.z; // no-error
+
+struct C {
+  int c;
+};
+
+struct __attribute__((packed)) D {
+  char x;
+  int y;
+  C z;
+} d;
+
+C  = d.z; // expected-error {{reference cannot bind to packed field}}
+int  = d.z.c; // expected-error {{reference cannot bind to packed field}}
+
+struct E {
+int x __attribute__((packed));
+C y __attribute__((packed));
+C z;
+} e;
+
+int& rex = e.x; // expected-error {{reference cannot bind to packed field}}
+C& rey = e.y; // expected-error {{reference cannot bind to packed field}}
+C& rez = e.z;  // no-error
+
+struct NonTrivialCopy
+{
+int w;
+NonTrivialCopy();
+NonTrivialCopy(const NonTrivialCopy&);
+};
+
+struct F
+{
+char c;
+NonTrivialCopy x __attribute__((packed));
+int w __attribute__((packed));
+} f;
+
+
+void fun1(int &);
+void fun2(const int &);
+
+void bar()
+{
+const NonTrivialCopy& rx = f.x; // expected-error {{reference cannot bind to packed field}}
+const int  = f.w; // no-error
+
+fun1(f.w); // expected-error {{reference cannot bind to packed field}}
+   // expected-note@76 {{passing argument to parameter here}}
+fun2(f.w); // no-error
+}
+
+struct __attribute__((packed)) IgnorePacked {
+  int c;
+  NonTrivialCopy x; // expected-warning {{ignoring packed attribute because of unpacked non-POD field}}
+} nopacked1;
+
+int  = nopacked1.c; // no-error
+
+template 
+struct __attribute__((packed)) IgnorePackedTpl {
+  int c;
+  T x;
+};
+
+IgnorePackedTpl nopacked2; // expected-warning@99 {{ignoring packed attribute because of unpacked non-POD field}}
+   // expected-note@102 {{in instantiation of template class}}
+int  = nopacked2.c; // no-error
+
+IgnorePackedTpl packed3;
+int  = packed3.c; // expected-error {{reference cannot bind to packed field}}
Index: test/CodeGenCXX/pod-member-memcpys.cpp
===
--- test/CodeGenCXX/pod-member-memcpys.cpp
+++ test/CodeGenCXX/pod-member-memcpys.cpp
@@ -168,7 +168,7 @@
 // PackedMembers copy-assignment:
 // CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %struct.PackedMembers* @_ZN13PackedMembersaSERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}}))
 // CHECK: call dereferenceable({{[0-9]+}}) %struct.NonPOD* @_ZN6NonPODaSERKS_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}})
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret %struct.PackedMembers*
 
 // COPY-CONSTRUCTORS:
@@ -183,7 +183,7 @@
 // PackedMembers copy-assignment:
 // CHECK-LABEL: define linkonce_odr void @_ZN13PackedMembersC2ERKS_(%struct.PackedMembers* %this, %struct.PackedMembers* dereferenceable({{[0-9]+}}))
 // CHECK: call void @_ZN6NonPODC1ERKS_
-// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 1{{.*}})
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64({{.*}}i64 16, i32 4{{.*}})
 // CHECK: ret void
 
 CALL_CC(BitfieldMember2)
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -3111,6 +3111,7 @@
   case FK_AddressOfOverloadFailed: // FIXME: Could do 

r290181 - [OPENMP] Fix for PR31416: Clang crashes on OMPCapturedExpr during source

2016-12-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec 20 10:51:02 2016
New Revision: 290181

URL: http://llvm.org/viewvc/llvm-project?rev=290181=rev
Log:
[OPENMP] Fix for PR31416: Clang crashes on OMPCapturedExpr during source
based coverage compilation

Added source location info to captured expression declaration + fixed
source location info for loop based directives.

Modified:
cfe/trunk/include/clang/AST/DeclOpenMP.h
cfe/trunk/lib/AST/DeclOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp

Modified: cfe/trunk/include/clang/AST/DeclOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclOpenMP.h?rev=290181=290180=290181=diff
==
--- cfe/trunk/include/clang/AST/DeclOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/DeclOpenMP.h Tue Dec 20 10:51:02 2016
@@ -173,18 +173,21 @@ class OMPCapturedExprDecl final : public
   void anchor() override;
 
   OMPCapturedExprDecl(ASTContext , DeclContext *DC, IdentifierInfo *Id,
-  QualType Type)
-  : VarDecl(OMPCapturedExpr, C, DC, SourceLocation(), SourceLocation(), Id,
-Type, nullptr, SC_None) {
+  QualType Type, SourceLocation StartLoc)
+  : VarDecl(OMPCapturedExpr, C, DC, StartLoc, SourceLocation(), Id, Type,
+nullptr, SC_None) {
 setImplicit();
   }
 
 public:
   static OMPCapturedExprDecl *Create(ASTContext , DeclContext *DC,
- IdentifierInfo *Id, QualType T);
+ IdentifierInfo *Id, QualType T,
+ SourceLocation StartLoc);
 
   static OMPCapturedExprDecl *CreateDeserialized(ASTContext , unsigned ID);
 
+  SourceRange getSourceRange() const override LLVM_READONLY;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K == OMPCapturedExpr; }

Modified: cfe/trunk/lib/AST/DeclOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclOpenMP.cpp?rev=290181=290180=290181=diff
==
--- cfe/trunk/lib/AST/DeclOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/DeclOpenMP.cpp Tue Dec 20 10:51:02 2016
@@ -90,13 +90,18 @@ OMPDeclareReductionDecl::getPrevDeclInSc
 void OMPCapturedExprDecl::anchor() {}
 
 OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext , DeclContext 
*DC,
- IdentifierInfo *Id,
- QualType T) {
-  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T);
+ IdentifierInfo *Id, QualType 
T,
+ SourceLocation StartLoc) {
+  return new (C, DC) OMPCapturedExprDecl(C, DC, Id, T, StartLoc);
 }
 
 OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext ,
  unsigned ID) {
-  return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType());
+  return new (C, ID)
+  OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), SourceLocation());
 }
 
+SourceRange OMPCapturedExprDecl::getSourceRange() const {
+  assert(hasInit());
+  return SourceRange(getInit()->getLocStart(), getInit()->getLocEnd());
+}

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=290181=290180=290181=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Dec 20 10:51:02 2016
@@ -1753,7 +1753,8 @@ static OMPCapturedExprDecl *buildCapture
 }
 WithInit = true;
   }
-  auto *CED = OMPCapturedExprDecl::Create(C, S.CurContext, Id, Ty);
+  auto *CED = OMPCapturedExprDecl::Create(C, S.CurContext, Id, Ty,
+  CaptureExpr->getLocStart());
   if (!WithInit)
 CED->addAttr(OMPCaptureNoInitAttr::CreateImplicit(C, SourceRange()));
   S.CurContext->addHiddenDecl(CED);
@@ -3862,14 +3863,16 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKin
   Scope *CurScope = DSA.getCurScope();
   for (unsigned Cnt = 1; Cnt < NestedLoopCount; ++Cnt) {
 if (PreCond.isUsable()) {
-  PreCond = SemaRef.BuildBinOp(CurScope, SourceLocation(), BO_LAnd,
-   PreCond.get(), IterSpaces[Cnt].PreCond);
+  PreCond =
+  SemaRef.BuildBinOp(CurScope, PreCond.get()->getExprLoc(), BO_LAnd,
+ PreCond.get(), IterSpaces[Cnt].PreCond);
 }
 auto N = IterSpaces[Cnt].NumIterations;
+SourceLocation Loc = N->getExprLoc();
 AllCountsNeedLessThan32Bits &= C.getTypeSize(N->getType()) < 32;
 if (LastIteration32.isUsable())
   LastIteration32 = 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 82113.
malcolm.parsons added a comment.

Use character literal prefixes.
Use float literal suffix.


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,376 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueChar {
+  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  // CHECK-FIXES: PositiveValueChar()  {}
+  const char c0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c0' [modernize-use-default-member-init]
+  // CHECK-FIXES: const char c0{};
+  wchar_t c1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer for 'c1'
+  // CHECK-FIXES: wchar_t c1{};
+  char16_t c2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c2'
+  // CHECK-FIXES: char16_t c2{};
+  char32_t c3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c3'
+  // CHECK-FIXES: char32_t c3{};
+};
+
+struct PositiveChar {
+  PositiveChar() : d('a') {}
+  // CHECK-FIXES: PositiveChar()  {}
+  char d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'd'
+  // CHECK-FIXES: char d{'a'};
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i'
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveUnaryMinusInt {
+  PositiveUnaryMinusInt() : j(-1) {}
+  // CHECK-FIXES: PositiveUnaryMinusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{-1};
+};
+
+struct PositiveUnaryPlusInt {
+  PositiveUnaryPlusInt() : j(+1) {}
+  // CHECK-FIXES: PositiveUnaryPlusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{+1};
+};
+
+struct PositiveValueComplexInt {
+  PositiveValueComplexInt() : i() {}
+  // CHECK-FIXES: PositiveValueComplexInt()  {}
+  _Complex int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use default member initializer for 'i'
+  // CHECK-FIXES: _Complex int i{};
+};
+
+struct PositiveValueFloat {
+  PositiveValueFloat() : f() {}
+  // CHECK-FIXES: PositiveValueFloat()  {}
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'f'
+  // CHECK-FIXES: float f{};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveValueComplexFloat {
+  PositiveValueComplexFloat() : f() {}
+  // CHECK-FIXES: PositiveValueComplexFloat()  {}
+  _Complex float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use default member initializer for 'f'
+  // CHECK-FIXES: _Complex float f{};
+};
+
+struct PositiveValueComplexDouble {
+  PositiveValueComplexDouble() : f() {}
+  // CHECK-FIXES: PositiveValueComplexDouble()  {}
+  _Complex double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use default member initializer for 'f'
+  // CHECK-FIXES: _Complex double f{};
+};
+
+struct PositiveUnaryMinusDouble {
+  PositiveUnaryMinusDouble() : f(-2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryMinusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{-2.5463e43};
+};
+
+struct PositiveUnaryPlusDouble {
+  PositiveUnaryPlusDouble() : f(+2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryPlusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{+2.5463e43};
+};
+
+struct PositiveValueBool 

[PATCH] D27180: Testbed and skeleton of a new expression parser

2016-12-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Looks good now, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D27180



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


[PATCH] D27410: Always issue vtables when generating coverage instrumentation

2016-12-20 Thread Phil Camp via Phabricator via cfe-commits
FlameTop abandoned this revision.
FlameTop added a comment.

I must apologise to you all. The problem was reported in our out-of-tree 
version of the compiler and I must have hit finger problems when I confirmed it 
in tree. Repeating the test I can no longer reproduce the fault with the 3.9.0 
public build. It must be some effect of a local change.

Again apologies.

Phil


https://reviews.llvm.org/D27410



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:34
+  case Type::STK_IntegralComplex:
+return InitType->isCharType() ? "'\\0'" : "0";
+  case Type::STK_Floating:

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > This is incorrect if the char type is not a narrow character type. I 
> > > > would probably just initialize the integral with `0`, regardless of 
> > > > whether it was a character or not. You should add a test for char, 
> > > > wchar_t, char16_t (et al), and probably all of the other types (just to 
> > > > make sure we handle them properly and don't introduce later 
> > > > regressions).
> > > `isCharType()` returns true for narrow character types only.
> > > So if this is incorrect, wouldn't your suggestion be incorrect too?
> > Ah, I think I made a confusing statement. By "incorrect", I meant, 
> > "inconsistent." For int, you would get 0, for char, you would get '\0', but 
> > for wchar_t you would get 0 instead of L'\0', for char16_t you would get 0 
> > instead of u'\0', etc. Rather than deal with all of the prefixing, I think 
> > it's better to just initialize with 0 for all integral types.
> All of these scalar types could be initialised with 0, but I prefer nullptr, 
> false, '\0' and 0.0 for pointers, bool, char and float respectively.
> If I used wchar_t, char16_t or char32_t, I'd probably want the prefixing.
I can agree that this may be a matter of preference, but my point still stands. 
If we're going to use a literal type that matches the variable type, we should 
do that consistently. So if you want to go with `'\0'` for a `char`, please use 
`L'\0'` for a `wchar_t`, and similar for the other character types.

You may also want to consider using the `f` suffix for a `float` rather than 
relying on the narrowing conversion from double to float. Similar for the 
complex type suffixes.


https://reviews.llvm.org/D26750



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


r290177 - clang-format: Fix bug in understanding string-label analysis.

2016-12-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Dec 20 09:27:46 2016
New Revision: 290177

URL: http://llvm.org/viewvc/llvm-project?rev=290177=rev
Log:
clang-format: Fix bug in understanding string-label analysis.

While for <<-operators often used in log statments, a single key value
pair is always on the second operator, e.g.

  llvm::errs() << "a=" << a;

It is on the first operator for plus- or comma-concatenated strings:

  string s = "aa: " + ;

(the "=" not counting because that's a different operator precedence)

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=290177=290176=290177=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Dec 20 09:27:46 2016
@@ -2000,11 +2000,14 @@ unsigned TokenAnnotator::splitPenalty(co
 
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
-  (Left.NextOperator || Left.OperatorIndex != 1))
+  (Left.NextOperator || Left.OperatorIndex != 0))
 return 100;
+  if (Right.is(tok::plus) && Left.isLabelString() &&
+  (Right.NextOperator || Right.OperatorIndex != 0))
+return 25;
   if (Left.is(tok::comma))
 return 1;
-  if (Right.isOneOf(tok::lessless, tok::plus) && Left.isLabelString() &&
+  if (Right.is(tok::lessless) && Left.isLabelString() &&
   (Right.NextOperator || Right.OperatorIndex != 1))
 return 25;
   if (Right.is(tok::lessless)) {

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290177=290176=290177=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Dec 20 09:27:46 2016
@@ -5214,6 +5214,12 @@ TEST_F(FormatTest, KeepStringLabelValueP
   verifyFormat("string v = StrCat(\": \", ,\n"
"  \": \", ,\n"
"  \": \", );");
+  verifyFormat("string v = \": \" +\n"
+   "   ( + );",
+   getLLVMStyleWithColumns(40));
+  verifyFormat("string v = StrCat(\": \" +\n"
+   "  (aaa + a));",
+   getLLVMStyleWithColumns(40));
 }
 
 TEST_F(FormatTest, UnderstandsEquals) {


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


[PATCH] D27971: Make FormatStyle.GetStyleOfFile test work on MSVC

2016-12-20 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D27971#627543, @klimek wrote:

> Why isn't the right solution to make getStyle() use vfs::FileSystem? 
> Generally, everything in clang-format (well, in clang) should use 
> vfs::FileSystem for file access.


You're absolutely right, this is the right solution. I was under the false 
impression that llvm::fs was preferred. What threw me off was that 
vfs::FileSystem::status() returns llvm::fs::file_type::* values.

I already made the change locally to getStyle() to use vfs::FileSystem and it 
works great. Will update the patch asap. Thanks!


https://reviews.llvm.org/D27971



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


[PATCH] D27982: [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290176: [change-namespace] do not fix calls to overloaded 
operator functions. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D27982?vs=82104=82105#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27982

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp


Index: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+  "  auto f = operator<;\n"
+  "  return (x == y) && (x < y) && (operator<(x, y));\n"
+  "}\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "bool f() {\n"
+  "  ::na::A x, y;\n"
+  "  auto f = ::na::operator<;\n"
+  // FIXME: function calls to overloaded operators are not fixed now even 
if
+  // they are referenced by qualified names.
+  "  return (x == y) && (x < y) && (operator<(x,y));\n"
+  "}\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, FixNonCallingFunctionReferences) {
   std::string Code = "namespace na {\n"
  "class A {\n"
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -481,6 +481,11 @@
llvm::cast(Var), VarRef);
   } else if (const auto *FuncRef =
  Result.Nodes.getNodeAs("func_ref")) {
+// If this reference has been processed as a function call, we do not
+// process it again.
+if (ProcessedFuncRefs.count(FuncRef))
+  return;
+ProcessedFuncRefs.insert(FuncRef);
 const auto *Func = Result.Nodes.getNodeAs("func_decl");
 assert(Func);
 const auto *Context = Result.Nodes.getNodeAs("dc");
@@ -490,8 +495,16 @@
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
+const auto *CalleeFuncRef =
+llvm::cast(Call->getCallee()->IgnoreImplicit());
+ProcessedFuncRefs.insert(CalleeFuncRef);
 const FunctionDecl *Func = Call->getDirectCallee();
 assert(Func != nullptr);
+// FIXME: ignore overloaded operators. This would miss cases where 
operators
+// are called by qualified names (i.e. "ns::operator <"). Ignore such
+// cases for now.
+if (Func->isOverloadedOperator())
+  return;
 // Ignore out-of-line static methods since they will be handled by nested
 // name specifiers.
 if (Func->getCanonicalDecl()->getStorageClass() ==
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
@@ -157,6 +157,10 @@
   // TypeLocs of CXXCtorInitializer. Types of CXXCtorInitializers do not need 
to
   // be fixed.
   llvm::SmallVector BaseCtorInitializerTypeLocs;
+  // Since a DeclRefExpr for a function call can be matched twice (one as
+  // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
+  // been processed so that we don't handle them twice.
+  llvm::SmallPtrSet ProcessedFuncRefs;
 };
 
 } // namespace change_namespace


Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ 

[clang-tools-extra] r290176 - [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Dec 20 08:39:04 2016
New Revision: 290176

URL: http://llvm.org/viewvc/llvm-project?rev=290176=rev
Log:
[change-namespace] do not fix calls to overloaded operator functions.

Summary: Also make sure one function reference is only processed once.

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=290176=290175=290176=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Tue Dec 20 
08:39:04 2016
@@ -481,6 +481,11 @@ void ChangeNamespaceTool::run(
llvm::cast(Var), VarRef);
   } else if (const auto *FuncRef =
  Result.Nodes.getNodeAs("func_ref")) {
+// If this reference has been processed as a function call, we do not
+// process it again.
+if (ProcessedFuncRefs.count(FuncRef))
+  return;
+ProcessedFuncRefs.insert(FuncRef);
 const auto *Func = Result.Nodes.getNodeAs("func_decl");
 assert(Func);
 const auto *Context = Result.Nodes.getNodeAs("dc");
@@ -490,8 +495,16 @@ void ChangeNamespaceTool::run(
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
+const auto *CalleeFuncRef =
+llvm::cast(Call->getCallee()->IgnoreImplicit());
+ProcessedFuncRefs.insert(CalleeFuncRef);
 const FunctionDecl *Func = Call->getDirectCallee();
 assert(Func != nullptr);
+// FIXME: ignore overloaded operators. This would miss cases where 
operators
+// are called by qualified names (i.e. "ns::operator <"). Ignore such
+// cases for now.
+if (Func->isOverloadedOperator())
+  return;
 // Ignore out-of-line static methods since they will be handled by nested
 // name specifiers.
 if (Func->getCanonicalDecl()->getStorageClass() ==

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.h?rev=290176=290175=290176=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Tue Dec 20 
08:39:04 2016
@@ -157,6 +157,10 @@ private:
   // TypeLocs of CXXCtorInitializer. Types of CXXCtorInitializers do not need 
to
   // be fixed.
   llvm::SmallVector BaseCtorInitializerTypeLocs;
+  // Since a DeclRefExpr for a function call can be matched twice (one as
+  // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
+  // been processed so that we don't handle them twice.
+  llvm::SmallPtrSet ProcessedFuncRefs;
 };
 
 } // namespace change_namespace

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=290176=290175=290176=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Tue Dec 20 08:39:04 2016
@@ -575,6 +575,47 @@ TEST_F(ChangeNamespaceTest, FixFunctionN
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+  "  auto f = operator<;\n"
+  "  return (x == y) && (x < y) && (operator<(x, y));\n"
+  "}\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "bool f() {\n"
+  "  ::na::A x, y;\n"
+  "  auto f = ::na::operator<;\n"
+  // FIXME: function calls 

[PATCH] D27982: [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 82104.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Address comments


https://reviews.llvm.org/D27982

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+  "  auto f = operator<;\n"
+  "  return (x == y) && (x < y) && (operator<(x, y));\n"
+  "}\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "bool f() {\n"
+  "  ::na::A x, y;\n"
+  "  auto f = ::na::operator<;\n"
+  // FIXME: function calls to overloaded operators are not fixed now even 
if
+  // they are referenced by qualified names.
+  "  return (x == y) && (x < y) && (operator<(x,y));\n"
+  "}\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, FixNonCallingFunctionReferences) {
   std::string Code = "namespace na {\n"
  "class A {\n"
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -157,6 +157,10 @@
   // TypeLocs of CXXCtorInitializer. Types of CXXCtorInitializers do not need 
to
   // be fixed.
   llvm::SmallVector BaseCtorInitializerTypeLocs;
+  // Since a DeclRefExpr for a function call can be matched twice (one as
+  // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
+  // been processed so that we don't handle them twice.
+  llvm::SmallPtrSet ProcessedFuncRefs;
 };
 
 } // namespace change_namespace
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -481,6 +481,11 @@
llvm::cast(Var), VarRef);
   } else if (const auto *FuncRef =
  Result.Nodes.getNodeAs("func_ref")) {
+// If this reference has been processed as a function call, we do not
+// process it again.
+if (ProcessedFuncRefs.count(FuncRef))
+  return;
+ProcessedFuncRefs.insert(FuncRef);
 const auto *Func = Result.Nodes.getNodeAs("func_decl");
 assert(Func);
 const auto *Context = Result.Nodes.getNodeAs("dc");
@@ -490,8 +495,16 @@
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
+const auto *CalleeFuncRef =
+llvm::cast(Call->getCallee()->IgnoreImplicit());
+ProcessedFuncRefs.insert(CalleeFuncRef);
 const FunctionDecl *Func = Call->getDirectCallee();
 assert(Func != nullptr);
+// FIXME: ignore overloaded operators. This would miss cases where 
operators
+// are called by qualified names (i.e. "ns::operator <"). Ignore such
+// cases for now.
+if (Func->isOverloadedOperator())
+  return;
 // Ignore out-of-line static methods since they will be handled by nested
 // name specifiers.
 if (Func->getCanonicalDecl()->getStorageClass() ==


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+   

[PATCH] D27982: [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:578
 
+// FIXME: function calls to overloaded operators are not fixed now even if they
+// are referenced by qualified names.

Maybe also add this case in the test although it is not fixed yet.



Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:592
+  "  A x, y;\n"
+  "  auto f = operator<;"
+  "  return (x == y) && (x < y) && (operator<(x, y));"

missing a `\n`, the same below.


https://reviews.llvm.org/D27982



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:34
+  case Type::STK_IntegralComplex:
+return InitType->isCharType() ? "'\\0'" : "0";
+  case Type::STK_Floating:

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > This is incorrect if the char type is not a narrow character type. I 
> > > would probably just initialize the integral with `0`, regardless of 
> > > whether it was a character or not. You should add a test for char, 
> > > wchar_t, char16_t (et al), and probably all of the other types (just to 
> > > make sure we handle them properly and don't introduce later regressions).
> > `isCharType()` returns true for narrow character types only.
> > So if this is incorrect, wouldn't your suggestion be incorrect too?
> Ah, I think I made a confusing statement. By "incorrect", I meant, 
> "inconsistent." For int, you would get 0, for char, you would get '\0', but 
> for wchar_t you would get 0 instead of L'\0', for char16_t you would get 0 
> instead of u'\0', etc. Rather than deal with all of the prefixing, I think 
> it's better to just initialize with 0 for all integral types.
All of these scalar types could be initialised with 0, but I prefer nullptr, 
false, '\0' and 0.0 for pointers, bool, char and float respectively.
If I used wchar_t, char16_t or char32_t, I'd probably want the prefixing.


https://reviews.llvm.org/D26750



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:34
+  case Type::STK_IntegralComplex:
+return InitType->isCharType() ? "'\\0'" : "0";
+  case Type::STK_Floating:

malcolm.parsons wrote:
> aaron.ballman wrote:
> > This is incorrect if the char type is not a narrow character type. I would 
> > probably just initialize the integral with `0`, regardless of whether it 
> > was a character or not. You should add a test for char, wchar_t, char16_t 
> > (et al), and probably all of the other types (just to make sure we handle 
> > them properly and don't introduce later regressions).
> `isCharType()` returns true for narrow character types only.
> So if this is incorrect, wouldn't your suggestion be incorrect too?
Ah, I think I made a confusing statement. By "incorrect", I meant, 
"inconsistent." For int, you would get 0, for char, you would get '\0', but for 
wchar_t you would get 0 instead of L'\0', for char16_t you would get 0 instead 
of u'\0', etc. Rather than deal with all of the prefixing, I think it's better 
to just initialize with 0 for all integral types.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:112
+  }
+}
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > You'll need to add the `llvm_unreachable()` here in order to avoid MSVC 
> > warnings about not all control paths returning a value.
> AFAIK, that's when a switch covers all valid enum values but doesn't have a 
> default case.
> This switch has a default case.
Yes, but MSVC often doesn't pick up on that fact. We've used this pattern in 
the past (see `getAbsoluteValueFunctionKind()` in SemaChecking.cpp), but 
perhaps this is fine and we can deal with any diagnostics post-commit (I didn't 
check whether the warning really happens, I was going from memory).


https://reviews.llvm.org/D26750



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:34
+  case Type::STK_IntegralComplex:
+return InitType->isCharType() ? "'\\0'" : "0";
+  case Type::STK_Floating:

aaron.ballman wrote:
> This is incorrect if the char type is not a narrow character type. I would 
> probably just initialize the integral with `0`, regardless of whether it was 
> a character or not. You should add a test for char, wchar_t, char16_t (et 
> al), and probably all of the other types (just to make sure we handle them 
> properly and don't introduce later regressions).
`isCharType()` returns true for narrow character types only.
So if this is incorrect, wouldn't your suggestion be incorrect too?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:112
+  }
+}
+

aaron.ballman wrote:
> You'll need to add the `llvm_unreachable()` here in order to avoid MSVC 
> warnings about not all control paths returning a value.
AFAIK, that's when a switch covers all valid enum values but doesn't have a 
default case.
This switch has a default case.


https://reviews.llvm.org/D26750



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


Re: [PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-12-20 Thread Aaron Ballman via cfe-commits
On Tue, Dec 20, 2016 at 7:58 AM, Attila Török  wrote:
> I did not see that it was reapplied later, sorry.
>
> With clang version 3.9.0 (tags/RELEASE_390/final) I get the warning in both
> c11 and c++11 mode.
> With clang version 4.0.0 (trunk 290146) (llvm/trunk 290118) it's gone in c11
> mode, but still there in c++11.
> The piece of code I tested it on:
> https://gist.github.com/torokati44/37e6aca2d516cb7c3cb31b7ccf8a519e
>
> In the part of the code affected by the patch, ED->getPromotionType() is
> BuiltinType 'int', and Type is EnumType 'enum E'.
> For these two types, Context.typesAreCompatible returns true in c11 mode,
> but false in c++11 mode (regardless of which underlying type - or if any -
> is specified).
> I presume this is the intended behavior. And if so, how could the example
> code be modified to make it warning-free in c++, while keeping the parameter
> an enum, and not making it a simple int?

Yes, that behavior is intended. The answer to how to modify the code
involves the C++ standards committee, though. [cstdarg.syn]p1 says, in
part,

The parameter parmN is the identifier of the rightmost parameter in
the variable parameter list of the function definition (the one just
before the ...). If the parameter parmN is of a reference type, or of
a type that is not compatible with the type that results when passing
an argument for which there is no parameter, the behavior is
undefined.

When typesAreCompatible() returns false, that means you are triggering
UB with your code.

The reason the C++ behavior differs from the C behavior when calling
typesAreCompaible() is because type compatibility (as a language
construct) is a C notion; in C++ this maps to "are the types the
same", which is not true for an enum type and an int type (even with
an explicit underlying type).

However, there are questions as to whether this should be UB or not
that I've raised with WG21 (I don't have a Core defect report for it
yet though). For right now, the safest answer is: change the parameter
to be an int, because that is definitely not UB. There may be a more
satisfactory answer in the future.

~Aaron

>
> Thank you,
> Attila
>
> 2016-12-19 18:36 GMT+01:00 Aaron Ballman :
>>
>> On Fri, Dec 16, 2016 at 7:00 AM, Attila Török via Phabricator
>>  wrote:
>> > torokati44 added a comment.
>> >
>> > I see this has been reverted in r281612, but I can no longer access the
>> > build log serving as a reason linked in the message:
>> > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg35386.html
>> > We have a few false-positive warnings that (I think) would be silenced
>> > by this change. I'm just wondering if something like this, if not this,
>> > could be included anyway? Not critical of course, it just would be nice.
>>
>> This patch was reapplied in r281632:
>>
>>
>> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160912/170772.html
>>
>> Do you still have false positives even with that applied?
>>
>> Thanks!
>>
>> ~Aaron
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27985: Add demangling support for C++11 thread_local variables

2016-12-20 Thread Dave Bozier via Phabricator via cfe-commits
davidb created this revision.
davidb added reviewers: howard.hinnant, mclow.lists.
davidb added a subscriber: cfe-commits.
davidb set the repository for this revision to rL LLVM.

Add support for demangling C++11 thread_local variables. In clang, the grammar 
for mangling for these names are   " ::= TW " for 
wrapper variables or   " ::= TH " for initialization 
variables.


Repository:
  rL LLVM

https://reviews.llvm.org/D27985

Files:
  src/cxa_demangle.cpp
  test/test_demangle.pass.cpp


Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29594,6 +29594,8 @@
 // NOTE: disable this test since it is a negative test case, you cannot 
demangle a non-mangled symbol
 // {"\x6D", nullptr},  // This use to crash with ASAN
 {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
+{"_ZTW1x", "thread-local wrapper routine for x"},
+{"_ZTHN3fooE", "thread-local initialization routine for foo"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -4343,6 +4343,8 @@
 //# base is the nominal target function of thunk
 //::= GV  # Guard variable for one-time 
initialization
 // # No 
+//::= TW  # Thread-local wrapper
+//::= TH  # Thread-local initialization
 //  extension ::= TC   _  # construction 
vtable for second-in-first
 //  extension ::= GR  # reference temporary for object
 
@@ -4446,6 +4448,28 @@
 }
 }
 break;
+case 'W':
+// TW  # Thread-local wrapper
+t = parse_name(first + 2, last, db);
+if (t != first + 2) 
+{
+if (db.names.empty())
+return first;
+db.names.back().first.insert(0, "thread-local wrapper 
routine for ");
+first = t;
+}
+break;
+case 'H':
+//TH  # Thread-local initialization
+t = parse_name(first + 2, last, db);
+if (t != first + 2) 
+{
+if (db.names.empty())
+return first;
+db.names.back().first.insert(0, "thread-local 
initialization routine for ");
+first = t;
+}
+break;
 default:
 // T  
 {


Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29594,6 +29594,8 @@
 // NOTE: disable this test since it is a negative test case, you cannot demangle a non-mangled symbol
 // {"\x6D", nullptr},  // This use to crash with ASAN
 {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
+{"_ZTW1x", "thread-local wrapper routine for x"},
+{"_ZTHN3fooE", "thread-local initialization routine for foo"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -4343,6 +4343,8 @@
 //# base is the nominal target function of thunk
 //::= GV  # Guard variable for one-time initialization
 // # No 
+//::= TW  # Thread-local wrapper
+//::= TH  # Thread-local initialization
 //  extension ::= TC   _  # construction vtable for second-in-first
 //  extension ::= GR  # reference temporary for object
 
@@ -4446,6 +4448,28 @@
 }
 }
 break;
+case 'W':
+// TW  # Thread-local wrapper
+t = parse_name(first + 2, last, db);
+if (t != first + 2) 
+{
+if (db.names.empty())
+return first;
+db.names.back().first.insert(0, "thread-local wrapper routine for ");
+first = t;
+}
+break;
+case 'H':
+//TH  # Thread-local initialization
+t = parse_name(first + 2, last, db);
+if (t != first + 2) 
+{
+if (db.names.empty())
+return first;
+db.names.back().first.insert(0, "thread-local initialization routine for ");
+first = t;
+}
+break;
 default:
 // T  
 {

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:34
+  case Type::STK_IntegralComplex:
+return InitType->isCharType() ? "'\\0'" : "0";
+  case Type::STK_Floating:

This is incorrect if the char type is not a narrow character type. I would 
probably just initialize the integral with `0`, regardless of whether it was a 
character or not. You should add a test for char, wchar_t, char16_t (et al), 
and probably all of the other types (just to make sure we handle them properly 
and don't introduce later regressions).



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:112
+  }
+}
+

You'll need to add the `llvm_unreachable()` here in order to avoid MSVC 
warnings about not all control paths returning a value.


https://reviews.llvm.org/D26750



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


[PATCH] D22452: [libcxx] Fix last_write_time tests for filesystems that don't support negative and very large times.

2016-12-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 82102.
Hahnfeld added a comment.

Version that works for me


https://reviews.llvm.org/D22452

Files:
  
test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp

Index: test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
===
--- test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
+++ test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
@@ -72,13 +72,60 @@
 return {st.st_atime, st.st_mtime};
 }
 
-inline bool TimeIsRepresentableAsTimeT(file_time_type tp) {
+namespace {
+bool TestSupportsNegativeTimes() {
+using namespace std::chrono;
+std::error_code ec;
+std::time_t old_write_time, new_write_time;
+{ // WARNING: Do not assert in this scope.
+scoped_test_env env;
+const path file = env.create_file("file", 42);
+old_write_time = LastWriteTime(file);
+file_time_type tp(seconds(-5));
+fs::last_write_time(file, tp, ec);
+new_write_time = LastWriteTime(file);
+}
+return !ec && new_write_time <= -5;
+}
+
+bool TestSupportsMaxTime() {
 using namespace std::chrono;
 using Lim = std::numeric_limits;
-auto sec = duration_cast(tp.time_since_epoch()).count();
-return (sec >= Lim::min() && sec <= Lim::max());
+auto max_sec = duration_cast(file_time_type::max().time_since_epoch()).count();
+if (max_sec > Lim::max()) return false;
+std::error_code ec;
+std::time_t old_write_time, new_write_time;
+{ // WARNING: Do not assert in this scope.
+scoped_test_env env;
+const path file = env.create_file("file", 42);
+old_write_time = LastWriteTime(file);
+file_time_type tp = file_time_type::max();
+fs::last_write_time(file, tp, ec);
+new_write_time = LastWriteTime(file);
+}
+return !ec && new_write_time > max_sec - 1;
 }
 
+static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
+static const bool SupportsMaxTime = TestSupportsMaxTime();
+
+} // end namespace
+
+// Check if a time point is representable on a given filesystem. Check that:
+// (A) 'tp' is representable as a time_t
+// (B) 'tp' is non-negative or the filesystem supports negative times.
+// (C) 'tp' is not 'file_time_type::max()' or the filesystem supports the max
+// value.
+inline bool TimeIsRepresentableByFilesystem(file_time_type tp) {
+using namespace std::chrono;
+using Lim = std::numeric_limits;
+auto sec = duration_cast(tp.time_since_epoch()).count();
+auto microsec = duration_cast(tp.time_since_epoch()).count();
+if (sec < Lim::min() || sec > Lim::max())   return false;
+else if (microsec < 0 && !SupportsNegativeTimes) return false;
+else if (tp == file_time_type::max() && !SupportsMaxTime) return false;
+return true;
+}
 
 TEST_SUITE(exists_test_suite)
 
@@ -214,15 +261,17 @@
 
 file_time_type  got_time = last_write_time(TC.p);
 
-TEST_CHECK(got_time != old_time);
-if (TC.new_time < epoch_time) {
-TEST_CHECK(got_time <= TC.new_time);
-TEST_CHECK(got_time > TC.new_time - Sec(1));
-} else {
-TEST_CHECK(got_time <= TC.new_time + Sec(1));
-TEST_CHECK(got_time >= TC.new_time - Sec(1));
+if (TimeIsRepresentableByFilesystem(TC.new_time)) {
+TEST_CHECK(got_time != old_time);
+if (TC.new_time < epoch_time) {
+TEST_CHECK(got_time <= TC.new_time);
+TEST_CHECK(got_time > TC.new_time - Sec(1));
+} else {
+TEST_CHECK(got_time <= TC.new_time + Sec(1));
+TEST_CHECK(got_time >= TC.new_time - Sec(1));
+}
+TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
 }
-TEST_CHECK(LastAccessTime(TC.p) == old_times.first);
 }
 }
 
@@ -275,11 +324,7 @@
 last_write_time(p, new_time, ec);
 file_time_type tt = last_write_time(p);
 
-if (!TimeIsRepresentableAsTimeT(new_time)) {
-TEST_CHECK(ec);
-TEST_CHECK(ec != GetTestEC());
-TEST_CHECK(tt == last_time);
-} else {
+if (TimeIsRepresentableByFilesystem(new_time)) {
 TEST_CHECK(!ec);
 TEST_CHECK(tt >= new_time);
 TEST_CHECK(tt < new_time + Sec(1));
@@ -294,11 +339,7 @@
 last_write_time(p, new_time, ec);
 tt = last_write_time(p);
 
-if (!TimeIsRepresentableAsTimeT(new_time)) {
-TEST_CHECK(ec);
-TEST_CHECK(ec != GetTestEC());
-TEST_CHECK(tt == last_time);
-} else {
+if (TimeIsRepresentableByFilesystem(new_time)) {
 TEST_CHECK(!ec);
 TEST_CHECK(tt >= new_time);
 TEST_CHECK(tt < new_time + Sec(1));
@@ -324,11 +365,7 @@
 last_write_time(p, new_time, ec);
 file_time_type tt = last_write_time(p);
 
-if 

[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2016-12-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

ping


https://reviews.llvm.org/D26244



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


Re: [PATCH] D23921: Remove va_start diagnostic false positive with enumerations

2016-12-20 Thread Attila Török via cfe-commits
I did not see that it was reapplied later, sorry.

With clang version 3.9.0 (tags/RELEASE_390/final) I get the warning in both
c11 and c++11 mode.
With clang version 4.0.0 (trunk 290146) (llvm/trunk 290118) it's gone in
c11 mode, but still there in c++11.
The piece of code I tested it on:
https://gist.github.com/torokati44/37e6aca2d516cb7c3cb31b7ccf8a519e

In the part of the code affected by the patch, ED->getPromotionType() is
BuiltinType 'int', and Type is EnumType 'enum E'.
For these two types, Context.typesAreCompatible returns true in c11 mode,
but false in c++11 mode (regardless of which underlying type - or if any -
is specified).
I presume this is the intended behavior. And if so, how could the example
code be modified to make it warning-free in c++, while keeping the
parameter an enum, and not making it a simple int?

Thank you,
Attila

2016-12-19 18:36 GMT+01:00 Aaron Ballman :

> On Fri, Dec 16, 2016 at 7:00 AM, Attila Török via Phabricator
>  wrote:
> > torokati44 added a comment.
> >
> > I see this has been reverted in r281612, but I can no longer access the
> build log serving as a reason linked in the message:
> https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg35386.html
> > We have a few false-positive warnings that (I think) would be silenced
> by this change. I'm just wondering if something like this, if not this,
> could be included anyway? Not critical of course, it just would be nice.
>
> This patch was reapplied in r281632:
>
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-
> Mon-20160912/170772.html
>
> Do you still have false positives even with that applied?
>
> Thanks!
>
> ~Aaron
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27982: [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 82098.
ioeric added a comment.

- minor fix.


https://reviews.llvm.org/D27982

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+// FIXME: function calls to overloaded operators are not fixed now even if they
+// are referenced by qualified names.
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+  "  auto f = operator<;"
+  "  return (x == y) && (x < y) && (operator<(x, y));"
+  "}\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "bool f() {\n"
+  "  ::na::A x, y;\n"
+  "  auto f = ::na::operator<;"
+  "  return (x == y) && (x < y) && (operator<(x,y));"
+  "}\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, FixNonCallingFunctionReferences) {
   std::string Code = "namespace na {\n"
  "class A {\n"
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -157,6 +157,10 @@
   // TypeLocs of CXXCtorInitializer. Types of CXXCtorInitializers do not need 
to
   // be fixed.
   llvm::SmallVector BaseCtorInitializerTypeLocs;
+  // Since a DeclRefExpr for a function call can be matched twice (one as
+  // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
+  // been processed so that we don't handle them twice.
+  llvm::SmallPtrSet ProcessedFuncRefs;
 };
 
 } // namespace change_namespace
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -481,6 +481,11 @@
llvm::cast(Var), VarRef);
   } else if (const auto *FuncRef =
  Result.Nodes.getNodeAs("func_ref")) {
+// If this reference has been processed as a function call, we do not
+// process it again.
+if (ProcessedFuncRefs.count(FuncRef))
+  return;
+ProcessedFuncRefs.insert(FuncRef);
 const auto *Func = Result.Nodes.getNodeAs("func_decl");
 assert(Func);
 const auto *Context = Result.Nodes.getNodeAs("dc");
@@ -490,8 +495,16 @@
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
+const auto *CalleeFuncRef =
+llvm::cast(Call->getCallee()->IgnoreImplicit());
+ProcessedFuncRefs.insert(CalleeFuncRef);
 const FunctionDecl *Func = Call->getDirectCallee();
 assert(Func != nullptr);
+// FIXME: ignore overloaded operators. This would miss cases where 
operators
+// are called by qualified names (i.e. "ns::operator <"). Ignore such
+// cases for now.
+if (Func->isOverloadedOperator())
+  return;
 // Ignore out-of-line static methods since they will be handled by nested
 // name specifiers.
 if (Func->getCanonicalDecl()->getStorageClass() ==


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+// FIXME: function calls to overloaded operators are not fixed now even if they
+// are referenced by qualified names.
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb 

[PATCH] D27917: [OpenCL] Improve diagnostics for double type

2016-12-20 Thread Egor Churaev via Phabricator via cfe-commits
echuraev updated this revision to Diff 82094.
echuraev marked an inline comment as done.

https://reviews.llvm.org/D27917

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/unknown_type.cl


Index: test/SemaOpenCL/unknown_type.cl
===
--- /dev/null
+++ test/SemaOpenCL/unknown_type.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -cl-std=CL1.1 -fsyntax-only -verify %s
+typedef double double2 __attribute__((ext_vector_type(2)));   // 
expected-error {{use of type 'double' requires cl_khr_fp64 extension to be 
enabled}}
+typedef double double16 __attribute__((ext_vector_type(16))); // 
expected-error {{use of type 'double' requires cl_khr_fp64 extension to be 
enabled}}
+#pragma OPENCL EXTENSION all : disable
+void foo()
+{
+(double)(3.14); // expected-error {{use of type 'double' requires 
cl_khr_fp64 extension to be enabled}} // expected-warning {{double precision 
constant requires cl_khr_fp64, casting to single precision}}
+(double2)(1.0, 3.14); // expected-error {{use of type 'double2' (vector of 
2 'double' values) requires cl_khr_fp64 extension to be enabled}}
+// expected-warning@-1 2{{double precision constant requires cl_khr_fp64, 
casting to single precision}}
+(double16)(123455.134, 123455.134, 2.0, -12345.032, -12345.032, 1.0, 1.0, 
2.0, 2.0, 0.0, 0.0, 0.0, -1.23, -1.23, 1.0, 123455.134); // expected-error 
{{use of type 'double16' (vector of 16 'double' values) requires cl_khr_fp64 
extension to be enabled}}
+// expected-warning@-1 16{{double precision constant requires cl_khr_fp64, 
casting to single precision}}
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1500,6 +1500,12 @@
 S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
 << Result << "cl_khr_gl_msaa_sharing";
 declarator.setInvalidType(true);
+  } else if ((Result->isDoubleType() || Result->isDoubleVecType()) &&
+  S.getLangOpts().OpenCLVersion < 120 &&
+  !S.getOpenCLOptions().isEnabled("cl_khr_fp64")) {
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
+<< Result << "cl_khr_fp64";
+declarator.setInvalidType(true);
   }
 }
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1809,6 +1809,19 @@
   return false;
 }
 
+bool Type::isDoubleType() const {
+  if (const BuiltinType *BT = dyn_cast(CanonicalType))
+return BT->getKind() >= BuiltinType::Double &&
+   BT->getKind() <= BuiltinType::LongDouble;
+  return false;
+}
+
+bool Type::isDoubleVecType() const {
+  if (const VectorType *VT = dyn_cast(CanonicalType))
+return VT->getElementType()->isDoubleType();
+  return false;
+}
+
 bool Type::hasFloatingRepresentation() const {
   if (const VectorType *VT = dyn_cast(CanonicalType))
 return VT->getElementType()->isFloatingType();
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1649,6 +1649,8 @@
   bool isAnyComplexType() const;   // C99 6.2.5p11 (complex) + Complex Int.
   bool isFloatingType() const; // C99 6.2.5p11 (real floating + complex)
   bool isHalfType() const; // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half)
+  bool isDoubleType() const;   // (double + long double)
+  bool isDoubleVecType() const;
   bool isRealType() const; // C99 6.2.5p17 (real floating + integer)
   bool isArithmeticType() const;   // C99 6.2.5p18 (integer + floating)
   bool isVoidType() const; // C99 6.2.5p19


Index: test/SemaOpenCL/unknown_type.cl
===
--- /dev/null
+++ test/SemaOpenCL/unknown_type.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -cl-std=CL1.1 -fsyntax-only -verify %s
+typedef double double2 __attribute__((ext_vector_type(2)));   // expected-error {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
+typedef double double16 __attribute__((ext_vector_type(16))); // expected-error {{use of type 'double' requires cl_khr_fp64 extension to be enabled}}
+#pragma OPENCL EXTENSION all : disable
+void foo()
+{
+(double)(3.14); // expected-error {{use of type 'double' requires cl_khr_fp64 extension to be enabled}} // expected-warning {{double precision constant requires cl_khr_fp64, casting to single precision}}
+(double2)(1.0, 3.14); // expected-error {{use of type 'double2' (vector of 2 'double' values) requires cl_khr_fp64 extension to be enabled}}
+// expected-warning@-1 2{{double precision constant requires cl_khr_fp64, casting to single precision}}
+(double16)(123455.134, 123455.134, 2.0, -12345.032, -12345.032, 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 0.0, -1.23, -1.23, 

[PATCH] D27982: [change-namespace] do not fix calls to overloaded operator functions.

2016-12-20 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added a reviewer: hokein.
ioeric added a subscriber: cfe-commits.

Also make sure one function reference is only processed once.


https://reviews.llvm.org/D27982

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+// FIXME: function calls to overloaded operators are not fixed now even if they
+// are referenced by qualified names.
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "namespace nb {\n"
+  "bool f() {\n"
+  "  A x, y;\n"
+  "  auto f = operator<;"
+  "  return (x == y) && (x < y) && (operator<(x, y));"
+  "}\n"
+  "}  // namespace nb\n"
+  "}  // namespace na\n";
+  std::string Expected =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { return LHS.x == RHS.x; }\n"
+  "\n"
+  "}  // namespace na\n"
+  "namespace x {\n"
+  "namespace y {\n"
+  "bool f() {\n"
+  "  ::na::A x, y;\n"
+  "  auto f = ::na::operator<;"
+  "  return (x == y) && (x < y) && (operator<(x,y));"
+  "}\n"
+  "}  // namespace y\n"
+  "}  // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, FixNonCallingFunctionReferences) {
   std::string Code = "namespace na {\n"
  "class A {\n"
Index: change-namespace/ChangeNamespace.h
===
--- change-namespace/ChangeNamespace.h
+++ change-namespace/ChangeNamespace.h
@@ -157,6 +157,10 @@
   // TypeLocs of CXXCtorInitializer. Types of CXXCtorInitializers do not need 
to
   // be fixed.
   llvm::SmallVector BaseCtorInitializerTypeLocs;
+  // Since a DeclRefExpr for a function call can be matched twice (one as
+  // CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that have
+  // been processed so that we don't handle them twice.
+  llvm::SmallPtrSet ProcessedFuncRefs;
 };
 
 } // namespace change_namespace
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -481,6 +481,10 @@
llvm::cast(Var), VarRef);
   } else if (const auto *FuncRef =
  Result.Nodes.getNodeAs("func_ref")) {
+// If this reference has been processed as a function call, we do not
+// process it again.
+if (ProcessedFuncRefs.count(FuncRef))
+  return;
 const auto *Func = Result.Nodes.getNodeAs("func_decl");
 assert(Func);
 const auto *Context = Result.Nodes.getNodeAs("dc");
@@ -490,8 +494,16 @@
   } else {
 const auto *Call = Result.Nodes.getNodeAs("call");
 assert(Call != nullptr && "Expecting callback for CallExpr.");
+const auto *CalleeFuncRef =
+llvm::cast(Call->getCallee()->IgnoreImplicit());
+ProcessedFuncRefs.insert(CalleeFuncRef);
 const FunctionDecl *Func = Call->getDirectCallee();
 assert(Func != nullptr);
+// FIXME: ignore overloaded operators. This would miss cases where 
operators
+// are called by qualified names (i.e. "ns::operator <"). Ignore such
+// cases for now.
+if (Func->isOverloadedOperator())
+  return;
 // Ignore out-of-line static methods since they will be handled by nested
 // name specifiers.
 if (Func->getCanonicalDecl()->getStorageClass() ==


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -575,6 +575,47 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+// FIXME: function calls to overloaded operators are not fixed now even if they
+// are referenced by qualified names.
+TEST_F(ChangeNamespaceTest, FixOverloadedOperatorFunctionNameSpecifiers) {
+  std::string Code =
+  "namespace na {\n"
+  "class A {\n"
+  "public:\n"
+  "  int x;\n"
+  "  bool operator==(const A ) const { return x == RHS.x; }\n"
+  "};\n"
+  "bool operator<(const A , const A ) { 

r290175 - [OPENMP] Fix for PR31428: variable named like directive name modifier

2016-12-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Dec 20 06:10:05 2016
New Revision: 290175

URL: http://llvm.org/viewvc/llvm-project?rev=290175=rev
Log:
[OPENMP] Fix for PR31428: variable named like directive name modifier

Directive name modifiers in 'if' clause are allowed only for OpenMP 4.5
and higher + in OpenMP 4.5 parsing procedure emits error message if ':'
is not found after directive name modifier.

Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/cancel_ast_print.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp
cfe/trunk/test/OpenMP/cancel_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_if_codegen.cpp
cfe/trunk/test/OpenMP/parallel_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_sections_if_messages.cpp
cfe/trunk/test/OpenMP/target_ast_print.cpp
cfe/trunk/test/OpenMP/target_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_enter_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_exit_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_if_messages.cpp
cfe/trunk/test/OpenMP/target_update_if_messages.cpp
cfe/trunk/test/OpenMP/task_ast_print.cpp
cfe/trunk/test/OpenMP/task_if_codegen.cpp
cfe/trunk/test/OpenMP/task_if_messages.cpp
cfe/trunk/test/OpenMP/taskloop_ast_print.cpp
cfe/trunk/test/OpenMP/taskloop_simd_ast_print.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=290175=290174=290175=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Dec 20 06:10:05 2016
@@ -1461,15 +1461,19 @@ OMPClause *Parser::ParseOpenMPSingleExpr
   } else {
 assert(Kind == OMPC_if);
 KLoc.push_back(Tok.getLocation());
+TentativeParsingAction TPA(*this);
 Arg.push_back(ParseOpenMPDirectiveKind(*this));
 if (Arg.back() != OMPD_unknown) {
   ConsumeToken();
-  if (Tok.is(tok::colon))
+  if (Tok.is(tok::colon) && getLangOpts().OpenMP > 40) {
+TPA.Commit();
 DelimLoc = ConsumeToken();
-  else
-Diag(Tok, diag::warn_pragma_expected_colon)
-<< "directive name modifier";
-}
+  } else {
+TPA.Revert();
+Arg.back() = OMPD_unknown;
+  }
+} else
+  TPA.Revert();
   }
 
   bool NeedAnExpression = (Kind == OMPC_schedule && DelimLoc.isValid()) ||

Modified: cfe/trunk/test/OpenMP/cancel_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancel_ast_print.cpp?rev=290175=290174=290175=diff
==
--- cfe/trunk/test/OpenMP/cancel_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/cancel_ast_print.cpp Tue Dec 20 06:10:05 2016
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o 
%t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t 
-fsyntax-only -verify %s -ast-print | FileCheck %s
 // expected-no-diagnostics
 
 #ifndef HEADER

Modified: cfe/trunk/test/OpenMP/cancel_codegen.cpp
URL: 

[PATCH] D27981: Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."

2016-12-20 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added reviewers: djasper, Anastasia.
echuraev added subscribers: bader, cfe-commits, yaxunl.

Fixed warnings in commit: https://reviews.llvm.org/rL290171


https://reviews.llvm.org/D27981

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Sema/Initialization.h
  include/clang/Sema/Overload.h
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/CodeGenOpenCL/null_queue.cl
  test/SemaOpenCL/null_queue.cl
  test/SemaOpenCL/queue_t_overload.cl

Index: test/SemaOpenCL/queue_t_overload.cl
===
--- /dev/null
+++ test/SemaOpenCL/queue_t_overload.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+
+void __attribute__((overloadable)) foo(queue_t, __local char *); // expected-note {{candidate function not viable: no known conversion from 'int' to 'queue_t' for 1st argument}} // expected-note {{candidate function}}
+void __attribute__((overloadable)) foo(queue_t, __local float *); // expected-note {{candidate function not viable: no known conversion from 'int' to 'queue_t' for 1st argument}} // expected-note {{candidate function}}
+
+void kernel ker(__local char *src1, __local float *src2, __global int *src3) {
+  queue_t q;
+  foo(q, src1);
+  foo(0, src2);
+  foo(q, src3); // expected-error {{call to 'foo' is ambiguous}}
+  foo(1, src3); // expected-error {{no matching function for call to 'foo'}}
+}
Index: test/SemaOpenCL/null_queue.cl
===
--- /dev/null
+++ test/SemaOpenCL/null_queue.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+extern queue_t get_default_queue();
+
+bool compare() {
+  return 1 == get_default_queue() && // expected-error{{invalid operands to binary expression ('int' and 'queue_t')}}
+ get_default_queue() == 1; // expected-error{{invalid operands to binary expression ('queue_t' and 'int')}}
+}
+
+void init() {
+  queue_t q1 = 1; // expected-error{{initializing 'queue_t' with an expression of incompatible type 'int'}}
+  queue_t q = 0;
+}
Index: test/CodeGenOpenCL/null_queue.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/null_queue.cl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0  -emit-llvm %s -o - | FileCheck %s
+extern queue_t get_default_queue();
+
+bool compare() {
+  return 0 == get_default_queue() &&
+ get_default_queue() == 0;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+  // CHECK: icmp eq %opencl.queue_t* %{{.*}}, null
+}
+
+void func(queue_t q);
+
+void init() {
+  queue_t q = 0;
+  func(0);
+  // CHECK: store %opencl.queue_t* null, %opencl.queue_t** %q
+  // CHECK: call void @func(%opencl.queue_t* null)
+}
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -341,6 +341,7 @@
   case CK_AnyPointerToBlockPointerCast:
   case CK_ObjCObjectLValueCast:
   case CK_ZeroToOCLEvent:
+  case CK_ZeroToOCLQueue:
   case CK_IntToOCLSampler:
   case CK_LValueBitCast: {
 // Delegate to SValBuilder to process.
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1781,6 +1781,11 @@
  From->EvaluateKnownConstInt(S.getASTContext()) == 0) {
 SCS.Second = ICK_Zero_Event_Conversion;
 FromType = ToType;
+  } else if (ToType->isQueueT() &&
+ From->isIntegerConstantExpr(S.getASTContext()) &&
+ (From->EvaluateKnownConstInt(S.getASTContext()) == 0)) {
+SCS.Second = ICK_Zero_Queue_Conversion;
+FromType = ToType;
   } else {
 // No second conversion required.
 SCS.Second = ICK_Identity;
@@ -5155,6 +5160,7 @@
   case ICK_Function_Conversion:
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion: // Narrowing conversions are checked elsewhere.
+  case ICK_Zero_Queue_Conversion:
 return true;
 
   case ICK_Boolean_Conversion:
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -3073,6 +3073,7 @@
   case SK_StdInitializerListConstructorCall:
   case SK_OCLSamplerInit:
   case SK_OCLZeroEvent:
+  case SK_OCLZeroQueue:
 break;
 
   case SK_ConversionSequence:
@@ -3334,6 +3335,13 @@
   Steps.push_back(S);
 }
 
+void InitializationSequence::AddOCLZeroQueueStep(QualType T) {
+  

[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 82089.
krasimir added a comment.

Ready for review.

- Split BreakableComment back into a BreakableBlockComment and 
BreakableLineCommentSection
- Extract common reflow computation functionality
- Put LastLineNeedsDecoration and Decoration and Prefix to the appropriate 
subclasses
- Fixed a double indentation bug caused by the WhitespaceManager.
- Implement a simple heuristic to detect ascii-art to stop reflow early


https://reviews.llvm.org/D27754

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/CMakeLists.txt
  lib/Format/Comments.cpp
  lib/Format/Comments.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -111,13 +111,19 @@
 format("int   a; // comment\n"
"intb; // comment",
0, 0));
-  EXPECT_EQ("int   a; // comment\n"
-" // line 2\n"
+  EXPECT_EQ("int a; // comment\n"
+"   // line 2\n"
 "int b;",
 format("int   a; // comment\n"
"// line 2\n"
"int b;",
28, 0));
+  EXPECT_EQ("int   a; // comment\n"
+"// comment 2\n"
+"int b;",
+format("int   a; // comment\n"
+   "// comment 2\n"
+   "int b;", 28, 0));
   EXPECT_EQ("int aa; // comment\n"
 "int b;\n"
 "int c; // unrelated comment",
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1783,6 +1783,455 @@
"0x00, 0x00, 0x00, 0x00};// comment\n");
 }
 
+TEST_F(FormatTest, ReflowsComments) {
+  // Break a long line and reflow with the full next line.
+  EXPECT_EQ("// long long long\n"
+"// long long",
+format("// long long long long\n"
+   "// long",
+   getLLVMStyleWithColumns(20)));
+
+  // Keep the trailing newline while reflowing.
+  EXPECT_EQ("// long long long\n"
+"// long long\n",
+format("// long long long long\n"
+   "// long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Break a long line and reflow with a part of the next line.
+  EXPECT_EQ("// long long long\n"
+"// long long\n"
+"// long_long",
+format("// long long long long\n"
+   "// long long_long",
+   getLLVMStyleWithColumns(20)));
+
+  // Break but do not reflow if the first word from the next line is too long.
+  EXPECT_EQ("// long long long\n"
+"// long\n"
+"// long_long_long\n",
+format("// long long long long\n"
+   "// long_long_long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't break or reflow short lines.
+  verifyFormat("// long\n"
+   "// long long long lo\n"
+   "// long long long lo\n"
+   "// long",
+   getLLVMStyleWithColumns(20));
+
+  // Keep prefixes and decorations while reflowing.
+  EXPECT_EQ("/// long long long\n"
+"/// long long\n",
+format("/// long long long long\n"
+   "/// long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//! long long long\n"
+"//! long long\n",
+format("//! long long long long\n"
+   "//! long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("/* long long long\n"
+" * long long */",
+format("/* long long long long\n"
+   " * long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't bring leading whitespace up while reflowing.
+  EXPECT_EQ("/*  long long long\n"
+" * long long long\n"
+" */",
+format("/*  long long long long\n"
+   " *  long long\n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow the last line of a block comment with its trailing '*/'.
+  EXPECT_EQ("/* long long long\n"
+"   long long */",
+format("/* long long long long\n"
+   "   long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow two short lines; keep the postfix of the last one.
+  EXPECT_EQ("/* long long long\n"
+" * long long long */",
+format("/* long long long long\n"
+   " * long\n"
+   " * long */",
+   

[PATCH] D27710: [analyzer] Prohibit ExplodedGraph's edges duplicating

2016-12-20 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/CoreEngine.cpp:662
+  bool EdgeExists = false;
+  for (auto I = N->pred_begin(), E = N->pred_end(); I != E; ++I)
+if (*I == FromN) {

I prefer having the braces written in this case, but it is a minor nit.

Wouldn't using an algorithm like std::find work as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D27710



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


[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Next 2 steps: will implement a simple heuristic about some sorts of ascii-art 
types of things; next will branch and produce a version that takes the reflow 
state out of the BreakableComment classes and puts it in the 
breakProtrudingToken implementation.


https://reviews.llvm.org/D27754



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


[PATCH] D27754: [clang-format] Implement comment reflowing (again).

2016-12-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 82081.
krasimir added a comment.

- Put LastLineNeedsDecoration and Decoration and Prefix to the appropriate 
subclasses
- Fixed a double indentation bug caused by the WhitespaceManager.


https://reviews.llvm.org/D27754

Files:
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/CMakeLists.txt
  lib/Format/Comments.cpp
  lib/Format/Comments.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -111,13 +111,19 @@
 format("int   a; // comment\n"
"intb; // comment",
0, 0));
-  EXPECT_EQ("int   a; // comment\n"
-" // line 2\n"
+  EXPECT_EQ("int a; // comment\n"
+"   // line 2\n"
 "int b;",
 format("int   a; // comment\n"
"// line 2\n"
"int b;",
28, 0));
+  EXPECT_EQ("int   a; // comment\n"
+"// comment 2\n"
+"int b;",
+format("int   a; // comment\n"
+   "// comment 2\n"
+   "int b;", 28, 0));
   EXPECT_EQ("int aa; // comment\n"
 "int b;\n"
 "int c; // unrelated comment",
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -1783,6 +1783,437 @@
"0x00, 0x00, 0x00, 0x00};// comment\n");
 }
 
+TEST_F(FormatTest, ReflowsComments) {
+  // Break a long line and reflow with the full next line.
+  EXPECT_EQ("// long long long\n"
+"// long long",
+format("// long long long long\n"
+   "// long",
+   getLLVMStyleWithColumns(20)));
+
+  // Keep the trailing newline while reflowing.
+  EXPECT_EQ("// long long long\n"
+"// long long\n",
+format("// long long long long\n"
+   "// long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Break a long line and reflow with a part of the next line.
+  EXPECT_EQ("// long long long\n"
+"// long long\n"
+"// long_long",
+format("// long long long long\n"
+   "// long long_long",
+   getLLVMStyleWithColumns(20)));
+
+  // Break but do not reflow if the first word from the next line is too long.
+  EXPECT_EQ("// long long long\n"
+"// long\n"
+"// long_long_long\n",
+format("// long long long long\n"
+   "// long_long_long\n",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't break or reflow short lines.
+  verifyFormat("// long\n"
+   "// long long long lo\n"
+   "// long long long lo\n"
+   "// long",
+   getLLVMStyleWithColumns(20));
+
+  // Keep prefixes and decorations while reflowing.
+  EXPECT_EQ("/// long long long\n"
+"/// long long\n",
+format("/// long long long long\n"
+   "/// long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("//! long long long\n"
+"//! long long\n",
+format("//! long long long long\n"
+   "//! long\n",
+   getLLVMStyleWithColumns(20)));
+  EXPECT_EQ("/* long long long\n"
+" * long long */",
+format("/* long long long long\n"
+   " * long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Don't bring leading whitespace up while reflowing.
+  EXPECT_EQ("/*  long long long\n"
+" * long long long\n"
+" */",
+format("/*  long long long long\n"
+   " *  long long\n"
+   " */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow the last line of a block comment with its trailing '*/'.
+  EXPECT_EQ("/* long long long\n"
+"   long long */",
+format("/* long long long long\n"
+   "   long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Reflow two short lines; keep the postfix of the last one.
+  EXPECT_EQ("/* long long long\n"
+" * long long long */",
+format("/* long long long long\n"
+   " * long\n"
+   " * long */",
+   getLLVMStyleWithColumns(20)));
+
+  // Put the postfix of the last short reflow line on a newline if it doesn't
+  // fit.
+  EXPECT_EQ("/* long long long\n"
+" * long long longg\n"
+" */",
+  

Re: r290171 - [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-20 Thread Daniel Jasper via cfe-commits
Reverted in rL290173.

On Tue, Dec 20, 2016 at 11:02 AM, Daniel Jasper  wrote:

> This triggers a bunch of warnings:
>
>   lib/AST/Expr.cpp:1519:11: error: enumeration value 'CK_ZeroToOCLQueue'
> not handled in switch [-Werror,-Wswitch]
>   lib/CodeGen/CGExprConstant.cpp:654:13: error: enumeration value
> 'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]
>   lib/Edit/RewriteObjCFoundationAPI.cpp:1000:13: error: enumeration value
> 'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]
>   lib/StaticAnalyzer/Core/ExprEngineC.cpp:314:13: error: enumeration
> value 'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]
>
> Can you please fix or roll back quickly?
>
> On Tue, Dec 20, 2016 at 10:15 AM, Egor Churaev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: echuraev
>> Date: Tue Dec 20 03:15:21 2016
>> New Revision: 290171
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290171=rev
>> Log:
>> [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.
>>
>> Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type
>> queue_t.
>>
>> Reviewers: Anastasia
>>
>> Subscribers: cfe-commits, yaxunl, bader
>>
>> Differential Revision: https://reviews.llvm.org/D27569
>>
>> Added:
>> cfe/trunk/test/CodeGenOpenCL/null_queue.cl
>> cfe/trunk/test/SemaOpenCL/null_queue.cl
>> cfe/trunk/test/SemaOpenCL/queue_t_overload.cl
>> Modified:
>> cfe/trunk/include/clang/AST/OperationKinds.def
>> cfe/trunk/include/clang/Sema/Initialization.h
>> cfe/trunk/include/clang/Sema/Overload.h
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>> cfe/trunk/lib/CodeGen/CGExprComplex.cpp
>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/lib/Sema/SemaInit.cpp
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/OperationKinds.def
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> AST/OperationKinds.def?rev=290171=290170=290171=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/OperationKinds.def (original)
>> +++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Dec 20 03:15:21
>> 2016
>> @@ -321,6 +321,9 @@ CAST_OPERATION(BuiltinFnToFnPtr)
>>  // Convert a zero value for OpenCL event_t initialization.
>>  CAST_OPERATION(ZeroToOCLEvent)
>>
>> +// Convert a zero value for OpenCL queue_t initialization.
>> +CAST_OPERATION(ZeroToOCLQueue)
>> +
>>  // Convert a pointer to a different address space.
>>  CAST_OPERATION(AddressSpaceConversion)
>>
>>
>> Modified: cfe/trunk/include/clang/Sema/Initialization.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Initialization.h?rev=290171=290170=290171=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Initialization.h (original)
>> +++ cfe/trunk/include/clang/Sema/Initialization.h Tue Dec 20 03:15:21
>> 2016
>> @@ -751,6 +751,8 @@ public:
>>  SK_StdInitializerListConstructorCall,
>>  /// \brief Initialize an OpenCL sampler from an integer.
>>  SK_OCLSamplerInit,
>> +/// \brief Initialize queue_t from 0.
>> +SK_OCLZeroQueue,
>>  /// \brief Passing zero to a function where OpenCL event_t is
>> expected.
>>  SK_OCLZeroEvent
>>};
>> @@ -1148,6 +1150,9 @@ public:
>>/// constant.
>>void AddOCLZeroEventStep(QualType T);
>>
>> +  /// \brief Add a step to initialize an OpenCL queue_t from 0.
>> +  void AddOCLZeroQueueStep(QualType T);
>> +
>>/// \brief Add steps to unwrap a initializer list for a reference
>> around a
>>/// single element and rewrap it at the end.
>>void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);
>>
>> Modified: cfe/trunk/include/clang/Sema/Overload.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Overload.h?rev=290171=290170=290171=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Overload.h (original)
>> +++ cfe/trunk/include/clang/Sema/Overload.h Tue Dec 20 03:15:21 2016
>> @@ -83,6 +83,7 @@ namespace clang {
>>  ICK_TransparentUnionConversion, ///< Transparent Union Conversions
>>  ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
>>  ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2
>> 6.12.10)
>> +ICK_Zero_Queue_Conversion, ///< Zero constant to queue
>>  ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
>>  ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between
>> pointers
>>   ///  with incompatible types
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL: 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 82073.
malcolm.parsons marked an inline comment as done.
malcolm.parsons added a comment.

Use 0 for IntegralComplex.


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,335 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueChar {
+  PositiveValueChar() : c() {}
+  // CHECK-FIXES: PositiveValueChar()  {}
+  const char c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c' [modernize-use-default-member-init]
+  // CHECK-FIXES: const char c{};
+};
+
+struct PositiveChar {
+  PositiveChar() : d('a') {}
+  // CHECK-FIXES: PositiveChar()  {}
+  char d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'd'
+  // CHECK-FIXES: char d{'a'};
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i'
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveUnaryMinusInt {
+  PositiveUnaryMinusInt() : j(-1) {}
+  // CHECK-FIXES: PositiveUnaryMinusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{-1};
+};
+
+struct PositiveUnaryPlusInt {
+  PositiveUnaryPlusInt() : j(+1) {}
+  // CHECK-FIXES: PositiveUnaryPlusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{+1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveUnaryMinusDouble {
+  PositiveUnaryMinusDouble() : f(-2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryMinusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{-2.5463e43};
+};
+
+struct PositiveUnaryPlusDouble {
+  PositiveUnaryPlusDouble() : f(+2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryPlusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{+2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b'
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a'
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p'
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q'
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+struct PositiveString {
+  PositiveString() : s("foo") {}
+  // CHECK-FIXES: PositiveString()  {}
+  const char *s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use default member initializer for 's'
+  // CHECK-FIXES: const char *s{"foo"};
+};
+
+template 
+struct NegativeTemplate {
+

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:33-34
+  case Type::STK_Floating:
+  case Type::STK_IntegralComplex:
+  case Type::STK_FloatingComplex:
+return "0.0";

aaron.ballman wrote:
> Do these require a literal suffix to avoid conversion?
I don't think so, but using 0.0 for an integral complex value doesn't look 
right.


https://reviews.llvm.org/D26750



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


r290173 - Revert "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."

2016-12-20 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Dec 20 04:05:04 2016
New Revision: 290173

URL: http://llvm.org/viewvc/llvm-project?rev=290173=rev
Log:
Revert "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."

This reverts commit r290171. It triggers a bunch of warnings, because
the new enumerator isn't handled in all switches. We want a warning-free
build.

Replied on the commit with more details.

Removed:
cfe/trunk/test/CodeGenOpenCL/null_queue.cl
cfe/trunk/test/SemaOpenCL/null_queue.cl
cfe/trunk/test/SemaOpenCL/queue_t_overload.cl
Modified:
cfe/trunk/include/clang/AST/OperationKinds.def
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/AST/OperationKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=290173=290172=290173=diff
==
--- cfe/trunk/include/clang/AST/OperationKinds.def (original)
+++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Dec 20 04:05:04 2016
@@ -321,9 +321,6 @@ CAST_OPERATION(BuiltinFnToFnPtr)
 // Convert a zero value for OpenCL event_t initialization.
 CAST_OPERATION(ZeroToOCLEvent)
 
-// Convert a zero value for OpenCL queue_t initialization.
-CAST_OPERATION(ZeroToOCLQueue)
-
 // Convert a pointer to a different address space.
 CAST_OPERATION(AddressSpaceConversion)
 

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=290173=290172=290173=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Tue Dec 20 04:05:04 2016
@@ -751,8 +751,6 @@ public:
 SK_StdInitializerListConstructorCall,
 /// \brief Initialize an OpenCL sampler from an integer.
 SK_OCLSamplerInit,
-/// \brief Initialize queue_t from 0.
-SK_OCLZeroQueue,
 /// \brief Passing zero to a function where OpenCL event_t is expected.
 SK_OCLZeroEvent
   };
@@ -1150,9 +1148,6 @@ public:
   /// constant.
   void AddOCLZeroEventStep(QualType T);
 
-  /// \brief Add a step to initialize an OpenCL queue_t from 0.
-  void AddOCLZeroQueueStep(QualType T);
-
   /// \brief Add steps to unwrap a initializer list for a reference around a
   /// single element and rewrap it at the end.
   void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290173=290172=290173=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Tue Dec 20 04:05:04 2016
@@ -83,7 +83,6 @@ namespace clang {
 ICK_TransparentUnionConversion, ///< Transparent Union Conversions
 ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
 ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
-ICK_Zero_Queue_Conversion, ///< Zero constant to queue
 ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
 ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between 
pointers
  ///  with incompatible types

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=290173=290172=290173=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 20 04:05:04 2016
@@ -8340,7 +8340,6 @@ bool IntExprEvaluator::VisitCastExpr(con
   case CK_IntegralComplexToFloatingComplex:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLEvent:
-  case CK_ZeroToOCLQueue:
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
@@ -8838,7 +8837,6 @@ bool ComplexExprEvaluator::VisitCastExpr
   case CK_CopyAndAutoreleaseBlockObject:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLEvent:
-  case CK_ZeroToOCLQueue:
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=290173=290172=290173=diff
==
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 82072.
malcolm.parsons marked 10 inline comments as done.
malcolm.parsons added a comment.

Use IgnoreParenImpCasts().
Elide braces.
Handle character and string literals.
Require C++11.
Improve doc.


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,335 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueChar {
+  PositiveValueChar() : c() {}
+  // CHECK-FIXES: PositiveValueChar()  {}
+  const char c;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c' [modernize-use-default-member-init]
+  // CHECK-FIXES: const char c{};
+};
+
+struct PositiveChar {
+  PositiveChar() : d('a') {}
+  // CHECK-FIXES: PositiveChar()  {}
+  char d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'd'
+  // CHECK-FIXES: char d{'a'};
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i'
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveUnaryMinusInt {
+  PositiveUnaryMinusInt() : j(-1) {}
+  // CHECK-FIXES: PositiveUnaryMinusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{-1};
+};
+
+struct PositiveUnaryPlusInt {
+  PositiveUnaryPlusInt() : j(+1) {}
+  // CHECK-FIXES: PositiveUnaryPlusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{+1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveUnaryMinusDouble {
+  PositiveUnaryMinusDouble() : f(-2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryMinusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{-2.5463e43};
+};
+
+struct PositiveUnaryPlusDouble {
+  PositiveUnaryPlusDouble() : f(+2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryPlusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{+2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b'
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a'
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p'
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q'
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+struct PositiveString {
+  PositiveString() : s("foo") {}
+  // CHECK-FIXES: PositiveString()  {}
+  const char *s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use default member initializer for 's'
+  // CHECK-FIXES: 

[PATCH] D18462: Fix for clang_Cursor_getSpellingNameRange()

2016-12-20 Thread Kevin Funk via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290172: Fix for clang_Cursor_getSpellingNameRange() 
(authored by kfunk).

Changed prior to commit:
  https://reviews.llvm.org/D18462?vs=51608=82071#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D18462

Files:
  cfe/trunk/test/Index/get-cursor.cpp
  cfe/trunk/tools/libclang/CIndex.cpp


Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -4429,7 +4429,8 @@
   }
 
   if (C.kind == CXCursor_CXXMethod || C.kind == CXCursor_Destructor ||
-  C.kind == CXCursor_ConversionFunction) {
+  C.kind == CXCursor_ConversionFunction ||
+  C.kind == CXCursor_FunctionDecl) {
 if (pieceIndex > 0)
   return clang_getNullRange();
 if (const FunctionDecl *FD =
Index: cfe/trunk/test/Index/get-cursor.cpp
===
--- cfe/trunk/test/Index/get-cursor.cpp
+++ cfe/trunk/test/Index/get-cursor.cpp
@@ -143,6 +143,8 @@
   }
 }
 
+const int operator""_toint(unsigned long long val) { return int(val); }
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck 
-check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen 
(}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -207,7 +209,7 @@
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck 
-check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of 
TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -std=c++11 %s | 
FileCheck -check-prefix=CHECK-SPELLING %s
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 
-cursor-at=%s:146:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %s
 // CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 (default constructor) 
Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
 // CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 
70:15] Spelling=~A ([70:11 - 70:13])
 // CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] 
Spelling=operator= ([73:6 - 73:15])
@@ -254,6 +256,7 @@
 // CHECK-SPELLING: 129:6 CXXMethod=operator->:129:6 Extent=[129:3 - 129:18] 
Spelling=operator-> ([129:6 - 129:16])
 // CHECK-SPELLING: 130:6 CXXMethod=operator():130:6 (const) Extent=[130:3 - 
130:37] Spelling=operator() ([130:6 - 130:16])
 // CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) 
Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25])
+// CHECK-SPELLING: 146:11 FunctionDecl=operator""_toint:146:11 (Definition) 
Extent=[146:1 - 146:72] Spelling=operator""_toint ([146:11 - 146:27])
 
 // RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 
-cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s
 // CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 
141:17] Spelling=lv ([141:13 - 141:15])


Index: cfe/trunk/tools/libclang/CIndex.cpp
===

r290172 - Fix for clang_Cursor_getSpellingNameRange()

2016-12-20 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Dec 20 03:56:56 2016
New Revision: 290172

URL: http://llvm.org/viewvc/llvm-project?rev=290172=rev
Log:
Fix for clang_Cursor_getSpellingNameRange()

Summary:
Fixes spelling name ranges for user-defined string literal operators.

Example:
  constexpr int operator""_toint(unsigned long long val)
  { return int(val); }

Before this patch the spelling name range on consisted of 'operator'.

After this patch: 'operator""_toint'.

Related to http://reviews.llvm.org/D5041, which fixes the function for
other cursor kinds.

Reviewers: akyrtzi, craigt, skalinichev, klimek, milianw, bkramer

Subscribers: cfe-commits

Tags: #clang-c

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

Modified:
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=290172=290171=290172=diff
==
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Tue Dec 20 03:56:56 2016
@@ -143,6 +143,8 @@ void test(TestColl coll) {
   }
 }
 
+const int operator""_toint(unsigned long long val) { return int(val); }
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck 
-check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen 
(}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -207,7 +209,7 @@ void test(TestColl coll) {
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck 
-check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of 
TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -std=c++11 %s | 
FileCheck -check-prefix=CHECK-SPELLING %s
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 
-cursor-at=%s:146:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %
 s
 // CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 (default constructor) 
Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
 // CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 
70:15] Spelling=~A ([70:11 - 70:13])
 // CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] 
Spelling=operator= ([73:6 - 73:15])
@@ -254,6 +256,7 @@ void test(TestColl coll) {
 // CHECK-SPELLING: 129:6 CXXMethod=operator->:129:6 Extent=[129:3 - 129:18] 
Spelling=operator-> ([129:6 - 129:16])
 // CHECK-SPELLING: 130:6 CXXMethod=operator():130:6 (const) Extent=[130:3 - 
130:37] Spelling=operator() ([130:6 - 130:16])
 // CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) 
Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25])
+// CHECK-SPELLING: 146:11 FunctionDecl=operator""_toint:146:11 (Definition) 
Extent=[146:1 - 146:72] Spelling=operator""_toint ([146:11 - 146:27])
 
 // RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 
-cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s
 // CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 
141:17] Spelling=lv 

Re: r290171 - [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-20 Thread Daniel Jasper via cfe-commits
This triggers a bunch of warnings:

  lib/AST/Expr.cpp:1519:11: error: enumeration value 'CK_ZeroToOCLQueue'
not handled in switch [-Werror,-Wswitch]
  lib/CodeGen/CGExprConstant.cpp:654:13: error: enumeration value
'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]
  lib/Edit/RewriteObjCFoundationAPI.cpp:1000:13: error: enumeration value
'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]
  lib/StaticAnalyzer/Core/ExprEngineC.cpp:314:13: error: enumeration value
'CK_ZeroToOCLQueue' not handled in switch [-Werror,-Wswitch]

Can you please fix or roll back quickly?

On Tue, Dec 20, 2016 at 10:15 AM, Egor Churaev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: echuraev
> Date: Tue Dec 20 03:15:21 2016
> New Revision: 290171
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290171=rev
> Log:
> [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.
>
> Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type
> queue_t.
>
> Reviewers: Anastasia
>
> Subscribers: cfe-commits, yaxunl, bader
>
> Differential Revision: https://reviews.llvm.org/D27569
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/null_queue.cl
> cfe/trunk/test/SemaOpenCL/null_queue.cl
> cfe/trunk/test/SemaOpenCL/queue_t_overload.cl
> Modified:
> cfe/trunk/include/clang/AST/OperationKinds.def
> cfe/trunk/include/clang/Sema/Initialization.h
> cfe/trunk/include/clang/Sema/Overload.h
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprComplex.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
>
> Modified: cfe/trunk/include/clang/AST/OperationKinds.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/OperationKinds.def?rev=290171=290170=290171=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/OperationKinds.def (original)
> +++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Dec 20 03:15:21
> 2016
> @@ -321,6 +321,9 @@ CAST_OPERATION(BuiltinFnToFnPtr)
>  // Convert a zero value for OpenCL event_t initialization.
>  CAST_OPERATION(ZeroToOCLEvent)
>
> +// Convert a zero value for OpenCL queue_t initialization.
> +CAST_OPERATION(ZeroToOCLQueue)
> +
>  // Convert a pointer to a different address space.
>  CAST_OPERATION(AddressSpaceConversion)
>
>
> Modified: cfe/trunk/include/clang/Sema/Initialization.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Initialization.h?rev=290171=290170=290171=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Initialization.h (original)
> +++ cfe/trunk/include/clang/Sema/Initialization.h Tue Dec 20 03:15:21 2016
> @@ -751,6 +751,8 @@ public:
>  SK_StdInitializerListConstructorCall,
>  /// \brief Initialize an OpenCL sampler from an integer.
>  SK_OCLSamplerInit,
> +/// \brief Initialize queue_t from 0.
> +SK_OCLZeroQueue,
>  /// \brief Passing zero to a function where OpenCL event_t is
> expected.
>  SK_OCLZeroEvent
>};
> @@ -1148,6 +1150,9 @@ public:
>/// constant.
>void AddOCLZeroEventStep(QualType T);
>
> +  /// \brief Add a step to initialize an OpenCL queue_t from 0.
> +  void AddOCLZeroQueueStep(QualType T);
> +
>/// \brief Add steps to unwrap a initializer list for a reference
> around a
>/// single element and rewrap it at the end.
>void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);
>
> Modified: cfe/trunk/include/clang/Sema/Overload.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Overload.h?rev=290171=290170=290171=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Overload.h (original)
> +++ cfe/trunk/include/clang/Sema/Overload.h Tue Dec 20 03:15:21 2016
> @@ -83,6 +83,7 @@ namespace clang {
>  ICK_TransparentUnionConversion, ///< Transparent Union Conversions
>  ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
>  ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2
> 6.12.10)
> +ICK_Zero_Queue_Conversion, ///< Zero constant to queue
>  ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
>  ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between
> pointers
>   ///  with incompatible types
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=290171=290170=290171=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 

r290171 - [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-20 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Tue Dec 20 03:15:21 2016
New Revision: 290171

URL: http://llvm.org/viewvc/llvm-project?rev=290171=rev
Log:
[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t.

Reviewers: Anastasia

Subscribers: cfe-commits, yaxunl, bader

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

Added:
cfe/trunk/test/CodeGenOpenCL/null_queue.cl
cfe/trunk/test/SemaOpenCL/null_queue.cl
cfe/trunk/test/SemaOpenCL/queue_t_overload.cl
Modified:
cfe/trunk/include/clang/AST/OperationKinds.def
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/AST/OperationKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=290171=290170=290171=diff
==
--- cfe/trunk/include/clang/AST/OperationKinds.def (original)
+++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Dec 20 03:15:21 2016
@@ -321,6 +321,9 @@ CAST_OPERATION(BuiltinFnToFnPtr)
 // Convert a zero value for OpenCL event_t initialization.
 CAST_OPERATION(ZeroToOCLEvent)
 
+// Convert a zero value for OpenCL queue_t initialization.
+CAST_OPERATION(ZeroToOCLQueue)
+
 // Convert a pointer to a different address space.
 CAST_OPERATION(AddressSpaceConversion)
 

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=290171=290170=290171=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Tue Dec 20 03:15:21 2016
@@ -751,6 +751,8 @@ public:
 SK_StdInitializerListConstructorCall,
 /// \brief Initialize an OpenCL sampler from an integer.
 SK_OCLSamplerInit,
+/// \brief Initialize queue_t from 0.
+SK_OCLZeroQueue,
 /// \brief Passing zero to a function where OpenCL event_t is expected.
 SK_OCLZeroEvent
   };
@@ -1148,6 +1150,9 @@ public:
   /// constant.
   void AddOCLZeroEventStep(QualType T);
 
+  /// \brief Add a step to initialize an OpenCL queue_t from 0.
+  void AddOCLZeroQueueStep(QualType T);
+
   /// \brief Add steps to unwrap a initializer list for a reference around a
   /// single element and rewrap it at the end.
   void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290171=290170=290171=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Tue Dec 20 03:15:21 2016
@@ -83,6 +83,7 @@ namespace clang {
 ICK_TransparentUnionConversion, ///< Transparent Union Conversions
 ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
 ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
+ICK_Zero_Queue_Conversion, ///< Zero constant to queue
 ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
 ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between 
pointers
  ///  with incompatible types

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=290171=290170=290171=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 20 03:15:21 2016
@@ -8340,6 +8340,7 @@ bool IntExprEvaluator::VisitCastExpr(con
   case CK_IntegralComplexToFloatingComplex:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLEvent:
+  case CK_ZeroToOCLQueue:
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
@@ -8837,6 +8838,7 @@ bool ComplexExprEvaluator::VisitCastExpr
   case CK_CopyAndAutoreleaseBlockObject:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLEvent:
+  case CK_ZeroToOCLQueue:
   case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:

Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=290171=290170=290171=diff
==
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ 

  1   2   >