[PATCH] D25696: [Driver] Parse Debian version as integer when possible. NFC

2016-10-20 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75269.
mgorny added a comment.

Restructured and reformatted as requested.


https://reviews.llvm.org/D25696

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3905,17 +3905,30 @@
   File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
-if (Data[0] == '5')
-  return DebianLenny;
-else if (Data.startswith("squeeze/sid") || Data[0] == '6')
-  return DebianSqueeze;
-else if (Data.startswith("wheezy/sid") || Data[0] == '7')
-  return DebianWheezy;
-else if (Data.startswith("jessie/sid") || Data[0] == '8')
-  return DebianJessie;
-else if (Data.startswith("stretch/sid") || Data[0] == '9')
-  return DebianStretch;
-return UnknownDistro;
+// Contents: < major.minor > or < codename/sid >
+int MajorVersion;
+if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
+  switch (MajorVersion) {
+  case 5:
+return DebianLenny;
+  case 6:
+return DebianSqueeze;
+  case 7:
+return DebianWheezy;
+  case 8:
+return DebianJessie;
+  case 9:
+return DebianStretch;
+  default:
+return UnknownDistro;
+  }
+}
+return llvm::StringSwitch(Data.split("\n").first)
+.Case("squeeze/sid", DebianSqueeze)
+.Case("wheezy/sid", DebianWheezy)
+.Case("jessie/sid", DebianJessie)
+.Case("stretch/sid", DebianStretch)
+.Default(UnknownDistro);
   }
 
   if (D.getVFS().exists("/etc/SuSE-release"))


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3905,17 +3905,30 @@
   File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
-if (Data[0] == '5')
-  return DebianLenny;
-else if (Data.startswith("squeeze/sid") || Data[0] == '6')
-  return DebianSqueeze;
-else if (Data.startswith("wheezy/sid") || Data[0] == '7')
-  return DebianWheezy;
-else if (Data.startswith("jessie/sid") || Data[0] == '8')
-  return DebianJessie;
-else if (Data.startswith("stretch/sid") || Data[0] == '9')
-  return DebianStretch;
-return UnknownDistro;
+// Contents: < major.minor > or < codename/sid >
+int MajorVersion;
+if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
+  switch (MajorVersion) {
+  case 5:
+return DebianLenny;
+  case 6:
+return DebianSqueeze;
+  case 7:
+return DebianWheezy;
+  case 8:
+return DebianJessie;
+  case 9:
+return DebianStretch;
+  default:
+return UnknownDistro;
+  }
+}
+return llvm::StringSwitch(Data.split("\n").first)
+.Case("squeeze/sid", DebianSqueeze)
+.Case("wheezy/sid", DebianWheezy)
+.Case("jessie/sid", DebianJessie)
+.Case("stretch/sid", DebianStretch)
+.Default(UnknownDistro);
   }
 
   if (D.getVFS().exists("/etc/SuSE-release"))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25816: Use descriptive message if list initializer is incorrectly parenthesized.

2016-10-20 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a subscriber: cfe-commits.

If initializer contains parentheses around braced list where it is not allowed, 
as in
construct `int({0})`, clang issued message like `functional-style cast from 
'void' to
'int' is not allowed`, which does not much help. Both gcc and msvc issue message
`list-initializer for non-class type must not be parenthesized`, which is more
descriptive. This change implements similar behavior for clang also.


https://reviews.llvm.org/D25816

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx0x-initializer-references.cpp
  test/SemaCXX/cxx0x-initializer-scalars.cpp

Index: test/SemaCXX/cxx0x-initializer-scalars.cpp
===
--- test/SemaCXX/cxx0x-initializer-scalars.cpp
+++ test/SemaCXX/cxx0x-initializer-scalars.cpp
@@ -91,10 +91,9 @@
   }
 
   void edge_cases() {
-// FIXME: very poor error message
-int a({0}); // expected-error {{cannot initialize}}
-(void) int({0}); // expected-error {{functional-style cast}}
-new int({0});  // expected-error {{cannot initialize}}
+int a({0}); // expected-error {{list-initializer for non-class type must not be parenthesized}}
+(void) int({0}); // expected-error {{list-initializer for non-class type must not be parenthesized}}
+new int({0});  // expected-error {{list-initializer for non-class type must not be parenthesized}}
   }
 
   void default_argument(int i = {}) {
Index: test/SemaCXX/cxx0x-initializer-references.cpp
===
--- test/SemaCXX/cxx0x-initializer-references.cpp
+++ test/SemaCXX/cxx0x-initializer-references.cpp
@@ -72,10 +72,9 @@
   }
 
   void edge_cases() {
-// FIXME: very poor error message
-int const &b({0}); // expected-error {{could not bind}}
+int const &b({0}); // expected-error {{list-initializer for non-class type must not be parenthesized}}
+const int (&arr)[3] ({1, 2, 3}); // expected-error {{list-initializer for non-class type must not be parenthesized}}
   }
-
 }
 
 namespace PR12182 {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1221,6 +1221,17 @@
   if (!TInfo)
 TInfo = Context.getTrivialTypeSourceInfo(Ty, SourceLocation());
 
+  // Handle errors like: int({0})
+  if (exprs.size() == 1 && cannotBeInitializededByParenthzedList(Ty) &&
+  LParenLoc.isValid() && RParenLoc.isValid())
+if (auto IList = dyn_cast(exprs[0])) {
+  Diag(TInfo->getTypeLoc().getLocStart(), diag::err_list_init_in_parens)
+  << IList->getSourceRange()
+  << FixItHint::CreateRemoval(LParenLoc)
+  << FixItHint::CreateRemoval(RParenLoc);
+  LParenLoc = RParenLoc = SourceLocation();
+}
+
   auto Result = BuildCXXTypeConstructExpr(TInfo, LParenLoc, exprs, RParenLoc);
   // Avoid creating a non-type-dependent expression that contains typos.
   // Non-type-dependent expressions are liable to be discarded without
@@ -1562,8 +1573,20 @@
 return ExprError();
 
   SourceRange DirectInitRange;
-  if (ParenListExpr *List = dyn_cast_or_null(Initializer))
+  if (ParenListExpr *List = dyn_cast_or_null(Initializer)) {
 DirectInitRange = List->getSourceRange();
+// Handle errors like: new int a({0})
+if (List->getNumExprs() == 1 &&
+cannotBeInitializededByParenthzedList(AllocType))
+  if (auto IList = dyn_cast(List->getExpr(0))) {
+Diag(TInfo->getTypeLoc().getLocStart(), diag::err_list_init_in_parens)
+<< List->getSourceRange()
+<< FixItHint::CreateRemoval(List->getLocStart())
+<< FixItHint::CreateRemoval(List->getLocEnd());
+DirectInitRange = SourceRange();
+Initializer = IList;
+  }
+  }
 
   return BuildCXXNew(SourceRange(StartLoc, D.getLocEnd()), UseGlobal,
  PlacementLParen,
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -9788,6 +9788,18 @@
   // Perform the initialization.
   ParenListExpr *CXXDirectInit = dyn_cast(Init);
   if (!VDecl->isInvalidDecl()) {
+// Handle errors like: int a({0})
+if (CXXDirectInit && CXXDirectInit->getNumExprs() == 1 &&
+cannotBeInitializededByParenthzedList(VDecl->getType()))
+  if (auto IList = dyn_cast(CXXDirectInit->getExpr(0))) {
+Diag(VDecl->getLocation(), diag::err_list_init_in_parens)
+  << CXXDirectInit->getSourceRange()
+  << FixItHint::CreateRemoval(CXXDirectInit->getLocStart())
+  << FixItHint::CreateRemoval(CXXDirectInit->getLocEnd());
+Init = IList;
+CXXDirectInit = nullptr;
+  }
+
 InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl);
 Initializ

Re: r284685 - Refactor and simplify Sema::FindCompositePointerType. No functionality change intended.

2016-10-20 Thread Richard Smith via cfe-commits
I think I understand the MSVC bug here; workaround incoming.

On Wed, Oct 19, 2016 at 11:54 PM, Mike Aizatsky  wrote:

> I think this breaks windows bot:
>
> http://lab.llvm.org:8011/builders/sanitizer-windows/
> builds/30745/steps/build%20clang%20lld/logs/stdio
>
> C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~2\cl.exe   /nologo /TP 
> -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER 
> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -DUNICODE 
> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
> -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
> -D__STDC_LIMIT_MACROS -Itools\clang\lib\Sema 
> -IC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema 
> -IC:\b\slave\sanitizer-windows\llvm\tools\clang\include -Itools\clang\include 
> -Iinclude -IC:\b\slave\sanitizer-windows\llvm\include /DWIN32 /D_WINDOWS   
> /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 
> -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 
> -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 
> -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline /Zc:strictStrings /Oi 
> /Zc:rvalueCast /Zc:sizedDealloc- /MD /O2 /Ob2   -UNDEBUG  /EHs-c- /GR- 
> /showIncludes 
> /Fotools\clang\lib\Sema\CMakeFiles\clangSema.dir\SemaExprCXX.cpp.obj 
> /Fdtools\clang\lib\Sema\CMakeFiles\clangSema.dir\ /FS -c 
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5702): 
> error C2326: 
> 'clang::Sema::FindCompositePointerType::Conversion::Conversion(clang::Sema 
> &,clang::SourceLocation,clang::Expr *&,clang::Expr *&,clang::QualType)': 
> function cannot access 'Composite'
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5702): 
> error C2248: 'clang::InitializedEntity::InitializedEntity': cannot access 
> private member declared in class 'clang::InitializedEntity'
> C:\b\slave\sanitizer-windows\llvm\tools\clang\include\clang/Sema/Initialization.h(163):
>  note: see declaration of 'clang::InitializedEntity::InitializedEntity'
> C:\b\slave\sanitizer-windows\llvm\tools\clang\include\clang/Sema/Initialization.h(40):
>  note: see declaration of 'clang::InitializedEntity'
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5704): 
> error C2326: 
> 'clang::Sema::FindCompositePointerType::Conversion::Conversion(clang::Sema 
> &,clang::SourceLocation,clang::Expr *&,clang::Expr *&,clang::QualType)': 
> function cannot access 'Loc'
> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5704): 
> error C2512: 'clang::InitializationKind::InitializationKind': no appropriate 
> default constructor available
> 251843.519 [4/2/26] Building CXX object 
> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86WinAllocaExpander.cpp.obj
> 251843.902 [4/1/27] Building CXX object 
> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86TargetMachine.cpp.obj
> 251846.937 [4/0/28] Building CXX object 
> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86ISelLowering.cpp.obj
> ninja: build stopped: subcommand failed.
>
>
>
> On Wed, Oct 19, 2016 at 6:29 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed Oct 19 20:20:00 2016
>> New Revision: 284685
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=284685&view=rev
>> Log:
>> Refactor and simplify Sema::FindCompositePointerType. No functionality
>> change intended.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
>> SemaExprCXX.cpp?rev=284685&r1=284684&r2=284685&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 19 20:20:00 2016
>> @@ -5520,7 +5520,7 @@ QualType Sema::CXXCheckConditionalOperan
>>  /// \brief Find a merged pointer type and convert the two expressions to
>> it.
>>  ///
>>  /// This finds the composite pointer type (or member pointer type) for
>> @p E1
>> -/// and @p E2 according to C++11 5.9p2. It converts both expressions to
>> this
>> +/// and @p E2 according to C++1z 5p14. It converts both expressions to
>> this
>>  /// type and returns it.
>>  /// It does not emit diagnostics.
>>  ///
>> @@ -5538,69 +5538,87 @@ QualType Sema::FindCompositePointerType(
>>  *NonStandardCompositeType = false;
>>
>>assert(getLangOpts().CPlusPlus && "This function assumes C++");
>> +
>> +  // C++1z [expr]p14:
>> +  //   The composite pointer type of two operands p1 and p2 having types
>> T1
>> +  //   and T2
>>QualType T1 = E1->getType(), T2 = E2->getType();
>>
>> -  // C+

r284701 - Work around MSVC rejects-valid. Apparenty (some versions of) MSVC will check

2016-10-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 20 02:53:17 2016
New Revision: 284701

URL: http://llvm.org/viewvc/llvm-project?rev=284701&view=rev
Log:
Work around MSVC rejects-valid. Apparenty (some versions of) MSVC will check
that a member is default-initializable even if it's initialized by a default
member initializer.

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

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=284701&r1=284700&r2=284701&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 20 02:53:17 2016
@@ -5696,21 +5696,20 @@ QualType Sema::FindCompositePointerType(
 
   struct Conversion {
 Sema &S;
-SourceLocation Loc;
 Expr *&E1, *&E2;
 QualType Composite;
-InitializedEntity Entity =
-InitializedEntity::InitializeTemporary(Composite);
-InitializationKind Kind =
-InitializationKind::CreateCopy(Loc, SourceLocation());
+InitializedEntity Entity;
+InitializationKind Kind;
 InitializationSequence E1ToC, E2ToC;
-bool Viable = E1ToC && E2ToC;
+bool Viable;
 
 Conversion(Sema &S, SourceLocation Loc, Expr *&E1, Expr *&E2,
QualType Composite)
-: S(S), Loc(Loc), E1(E1), E2(E2), Composite(Composite),
-  E1ToC(S, Entity, Kind, E1), E2ToC(S, Entity, Kind, E2) {
-}
+: S(S), E1(E1), E2(E2), Composite(Composite),
+  Entity(InitializedEntity::InitializeTemporary(Composite)),
+  Kind(InitializationKind::CreateCopy(Loc, SourceLocation())),
+  E1ToC(S, Entity, Kind, E1), E2ToC(S, Entity, Kind, E2),
+  Viable(E1ToC && E2ToC) {}
 
 QualType perform() {
   ExprResult E1Result = E1ToC.Perform(S, Entity, Kind, E1);


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


Re: r284685 - Refactor and simplify Sema::FindCompositePointerType. No functionality change intended.

2016-10-20 Thread Richard Smith via cfe-commits
Should hopefully be fixed by r284701.

On Thu, Oct 20, 2016 at 12:55 AM, Richard Smith 
wrote:

> I think I understand the MSVC bug here; workaround incoming.
>
> On Wed, Oct 19, 2016 at 11:54 PM, Mike Aizatsky 
> wrote:
>
>> I think this breaks windows bot:
>>
>> http://lab.llvm.org:8011/builders/sanitizer-windows/builds/
>> 30745/steps/build%20clang%20lld/logs/stdio
>>
>> C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~2\cl.exe   /nologo /TP 
>> -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER 
>> -DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0 -DUNICODE 
>> -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
>> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
>> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
>> -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
>> -D__STDC_LIMIT_MACROS -Itools\clang\lib\Sema 
>> -IC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema 
>> -IC:\b\slave\sanitizer-windows\llvm\tools\clang\include 
>> -Itools\clang\include -Iinclude -IC:\b\slave\sanitizer-windows\llvm\include 
>> /DWIN32 /D_WINDOWS   /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 
>> -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 
>> -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 
>> -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 
>> -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Zc:inline 
>> /Zc:strictStrings /Oi /Zc:rvalueCast /Zc:sizedDealloc- /MD /O2 /Ob2   
>> -UNDEBUG  /EHs-c- /GR- /showIncludes 
>> /Fotools\clang\lib\Sema\CMakeFiles\clangSema.dir\SemaExprCXX.cpp.obj 
>> /Fdtools\clang\lib\Sema\CMakeFiles\clangSema.dir\ /FS -c 
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5702):
>>  error C2326: 
>> 'clang::Sema::FindCompositePointerType::Conversion::Conversion(clang::Sema 
>> &,clang::SourceLocation,clang::Expr *&,clang::Expr *&,clang::QualType)': 
>> function cannot access 'Composite'
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5702):
>>  error C2248: 'clang::InitializedEntity::InitializedEntity': cannot access 
>> private member declared in class 'clang::InitializedEntity'
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\include\clang/Sema/Initialization.h(163):
>>  note: see declaration of 'clang::InitializedEntity::InitializedEntity'
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\include\clang/Sema/Initialization.h(40):
>>  note: see declaration of 'clang::InitializedEntity'
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5704):
>>  error C2326: 
>> 'clang::Sema::FindCompositePointerType::Conversion::Conversion(clang::Sema 
>> &,clang::SourceLocation,clang::Expr *&,clang::Expr *&,clang::QualType)': 
>> function cannot access 'Loc'
>> C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp(5704):
>>  error C2512: 'clang::InitializationKind::InitializationKind': no 
>> appropriate default constructor available
>> 251843.519 [4/2/26] Building CXX object 
>> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86WinAllocaExpander.cpp.obj
>> 251843.902 [4/1/27] Building CXX object 
>> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86TargetMachine.cpp.obj
>> 251846.937 [4/0/28] Building CXX object 
>> lib\Target\X86\CMakeFiles\LLVMX86CodeGen.dir\X86ISelLowering.cpp.obj
>> ninja: build stopped: subcommand failed.
>>
>>
>>
>> On Wed, Oct 19, 2016 at 6:29 PM Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Wed Oct 19 20:20:00 2016
>>> New Revision: 284685
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=284685&view=rev
>>> Log:
>>> Refactor and simplify Sema::FindCompositePointerType. No functionality
>>> change intended.
>>>
>>> Modified:
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>>
>>> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaE
>>> xprCXX.cpp?rev=284685&r1=284684&r2=284685&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
>>> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Oct 19 20:20:00 2016
>>> @@ -5520,7 +5520,7 @@ QualType Sema::CXXCheckConditionalOperan
>>>  /// \brief Find a merged pointer type and convert the two expressions
>>> to it.
>>>  ///
>>>  /// This finds the composite pointer type (or member pointer type) for
>>> @p E1
>>> -/// and @p E2 according to C++11 5.9p2. It converts both expressions to
>>> this
>>> +/// and @p E2 according to C++1z 5p14. It converts both expressions to
>>> this
>>>  /// type and returns it.
>>>  /// It does not emit diagnostics.
>>>  ///
>>> @@ -5538,69 +5538,87 @@ QualType Sema::FindCompositePointerType(
>>>  *NonStandardCompositeType = false;
>>>
>>>assert(getLangOpts().CPlusPlus && "This function assumes C++");
>>

[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:566
+  break;
+if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) 
{
+  for (const auto *UsingShadow : Using->shadows()) {

Yeah, it works for most cases, but it can not guarantee that they are still in 
the same DeclContext after changing to new namespace.

For example, the following case where an using-decl is used in the namespace 
being renamed, we change `b::c` to `d::e`, although DeclContext `d` of callexpr 
`f()` is a nested DeclContext of `b` (also DeclContext of `using a::f`), but 
this assumption is wrong after changing namespace because we keep `using a::f` 
in its original namespace.

```
namespace a { void f(); }

namespace b {
using a::f;
namespace c {
void d() { f(); }
}  // c
} // b
```

Not sure whether we should do this in our tool. I suspect there might be a lot 
of corner cases.



https://reviews.llvm.org/D25771



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


[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-10-20 Thread Matan via cfe-commits
mharoush added a comment.

Done


Repository:
  rL LLVM

https://reviews.llvm.org/D25012



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:566
+  break;
+if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) 
{
+  for (const auto *UsingShadow : Using->shadows()) {

hokein wrote:
> Yeah, it works for most cases, but it can not guarantee that they are still 
> in the same DeclContext after changing to new namespace.
> 
> For example, the following case where an using-decl is used in the namespace 
> being renamed, we change `b::c` to `d::e`, although DeclContext `d` of 
> callexpr `f()` is a nested DeclContext of `b` (also DeclContext of `using 
> a::f`), but this assumption is wrong after changing namespace because we keep 
> `using a::f` in its original namespace.
> 
> ```
> namespace a { void f(); }
> 
> namespace b {
> using a::f;
> namespace c {
> void d() { f(); }
> }  // c
> } // b
> ```
> 
> Not sure whether we should do this in our tool. I suspect there might be a 
> lot of corner cases.
> 
I thought using decls in old namespaces should be moved with along with 
namespaces. If this is the case, the moving of using decls is unexpected 
(looking into this), but this patch is handling this correctly if using decls 
are not moved.


https://reviews.llvm.org/D25771



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:566
+  break;
+if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) 
{
+  for (const auto *UsingShadow : Using->shadows()) {

ioeric wrote:
> hokein wrote:
> > Yeah, it works for most cases, but it can not guarantee that they are still 
> > in the same DeclContext after changing to new namespace.
> > 
> > For example, the following case where an using-decl is used in the 
> > namespace being renamed, we change `b::c` to `d::e`, although DeclContext 
> > `d` of callexpr `f()` is a nested DeclContext of `b` (also DeclContext of 
> > `using a::f`), but this assumption is wrong after changing namespace 
> > because we keep `using a::f` in its original namespace.
> > 
> > ```
> > namespace a { void f(); }
> > 
> > namespace b {
> > using a::f;
> > namespace c {
> > void d() { f(); }
> > }  // c
> > } // b
> > ```
> > 
> > Not sure whether we should do this in our tool. I suspect there might be a 
> > lot of corner cases.
> > 
> I thought using decls in old namespaces should be moved with along with 
> namespaces. If this is the case, the moving of using decls is unexpected 
> (looking into this), but this patch is handling this correctly if using decls 
> are not moved.
Ahh, I was wrong. `using a::f` should not be moved. Hmm, I think we can solve 
or at least workaround this. But I still think we should support shortening 
namespace specifier based on using decls; it is quite not nice to add long 
specifiers if there are already using decls present.


https://reviews.llvm.org/D25771



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


[PATCH] D25608: [libclang] Make tests for python bindings pass on Windows.

2016-10-20 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping.


https://reviews.llvm.org/D25608



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


[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2016-10-20 Thread Bruce Mitchener via cfe-commits
brucem marked 2 inline comments as done.
brucem added a comment.

These have been addressed, so this should be good for further review.


https://reviews.llvm.org/D25241



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


[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-20 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: dblaikie, majnemer.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch improves the mismatched destructor type error by detecting when the 
destructor call has used a '.' instead of a '->' on a pointer to the destructed 
type.

For example, when given the code sample below:

  struct Bar {
~Bar();
  };
  void bar(Bar *object) {
object.~Bar();
  }

Clang will now produce the following diagnostic: `error: member reference type 
'Bar *' is a pointer; did you mean to use '->'?`.


Repository:
  rL LLVM

https://reviews.llvm.org/D25817

Files:
  lib/Sema/SemaExprCXX.cpp
  test/CXX/special/class.dtor/p10-0x.cpp
  test/SemaCXX/pseudo-destructors.cpp


Index: test/SemaCXX/pseudo-destructors.cpp
===
--- test/SemaCXX/pseudo-destructors.cpp
+++ test/SemaCXX/pseudo-destructors.cpp
@@ -89,3 +89,26 @@
 void AliasTemplate(int *p) {
   p->~Id();
 }
+
+namespace dotPointerAccess {
+struct Base {
+  virtual ~Base() {}
+};
+
+struct Derived : Base {
+  ~Derived() {}
+};
+
+void test() {
+  Derived d;
+  static_cast(&d).~Base(); // expected-error {{member reference type 
'dotPointerAccess::Base *' is a pointer; did you mean to use '->'}}
+  d->~Derived(); // expected-error {{member reference type 
'dotPointerAccess::Derived' is not a pointer; did you mean to use '.'}}
+}
+
+typedef Derived *Foo;
+
+void test2(Foo d) {
+  d.~Foo(); // This is ok
+  d.~Derived(); // expected-error {{member reference type 'Foo' (aka 
'dotPointerAccess::Derived *') is a pointer; did you mean to use '->'}}
+}
+}
Index: test/CXX/special/class.dtor/p10-0x.cpp
===
--- test/CXX/special/class.dtor/p10-0x.cpp
+++ test/CXX/special/class.dtor/p10-0x.cpp
@@ -33,7 +33,7 @@
  expected-error{{the type of object expression 
('int') does not match the type being destroyed ('decltype(intp())' (aka 'int 
*')) in pseudo-destructor expression}}
   i.~decltype(intp())(); // expected-error{{the type of object expression 
('int') does not match the type being destroyed ('decltype(intp())' (aka 'int 
*')) in pseudo-destructor expression}}
   pi->~decltype(int())();
-  pi.~decltype(int())(); // expected-error{{the type of object expression 
('int *') does not match the type being destroyed ('decltype(int())' (aka 
'int')) in pseudo-destructor expression}}
+  pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a 
pointer; did you mean to use '->'?}}
   pi.~decltype(intp())();
   pi->~decltype(intp())(); // expected-error{{the type of object expression 
('int') does not match the type being destroyed ('decltype(intp())' (aka 'int 
*')) in pseudo-destructor expression}}
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6279,9 +6279,20 @@
   = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin();
 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) {
   if (!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
-Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
-  << ObjectType << DestructedType << Base->getSourceRange()
-  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
+// Detect dot pseudo destructor calls on pointer objects, e.g.:
+//   Foo *foo;
+//   foo.~Foo();
+if (OpKind == tok::period && ObjectType->isPointerType() &&
+Context.hasSameUnqualifiedType(DestructedType,
+   ObjectType->getPointeeType())) {
+  Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
+  << ObjectType << /*IsArrow=*/0 << Base->getSourceRange()
+  << FixItHint::CreateReplacement(OpLoc, "->");
+} else {
+  Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
+  << ObjectType << DestructedType << Base->getSourceRange()
+  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
+}
 
 // Recover by setting the destructed type to the object type.
 DestructedType = ObjectType;


Index: test/SemaCXX/pseudo-destructors.cpp
===
--- test/SemaCXX/pseudo-destructors.cpp
+++ test/SemaCXX/pseudo-destructors.cpp
@@ -89,3 +89,26 @@
 void AliasTemplate(int *p) {
   p->~Id();
 }
+
+namespace dotPointerAccess {
+struct Base {
+  virtual ~Base() {}
+};
+
+struct Derived : Base {
+  ~Derived() {}
+};
+
+void test() {
+  Derived d;
+  static_cast(&d).~Base(); // expected-error {{member reference type 'dotPointerAccess::Base *' is a pointer; did you mean to use '->'}}
+  d->~Derived(); // expected-error {{member reference type 'dotPointerAcce

[PATCH] D25063: [x86][inline-asm][AVX512][clang][PART-1] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-20 Thread Matan via cfe-commits
mharoush removed rL LLVM as the repository for this revision.
mharoush updated this revision to Diff 75277.
mharoush added a comment.
Herald added a subscriber: mehdi_amini.

I renamed the test file to be more informative, added LLVM_FALLTHROUGH, removed 
check of {z} and changed the test to check LLVM IR.


https://reviews.llvm.org/D25063

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avx512-kconstraints-att_inline_asm.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3987,6 +3987,7 @@
 case 't': // Any SSE register, when SSE2 is enabled.
 case 'i': // Any SSE register, when SSE2 and inter-unit moves enabled.
 case 'm': // Any MMX register, when inter-unit moves enabled.
+case 'k': // AVX512 arch mask registers: k1-k7.
   Info.setAllowsRegister();
   return true;
 }
@@ -4008,6 +4009,8 @@
   case 'q': // Any register accessible as [r]l: a, b, c, and d.
   case 'y': // Any MMX register.
   case 'x': // Any SSE register.
+  case 'k': // Any AVX512 mask register (same as Yk, additionaly allows k0
+// for intermideate k reg operations).
   case 'Q': // Any register accessible as [r]h: a, b, c, and d.
   case 'R': // "Legacy" registers: ax, bx, cx, dx, di, si, sp, bp.
   case 'l': // "Index" registers: any general register that can be used as an
@@ -4041,6 +4044,8 @@
 unsigned Size) const {
   switch (Constraint[0]) {
   default: break;
+  case 'k':
+  // Registers k0-k7 (AVX512) size limit is 64 bit.
   case 'y':
 return Size <= 64;
   case 'f':
@@ -4061,6 +4066,7 @@
 default: break;
 case 'm':
   // 'Ym' is synonymous with 'y'.
+case 'k':
   return Size <= 64;
 case 'i':
 case 't':
@@ -4092,6 +4098,20 @@
 return std::string("{st}");
   case 'u': // second from top of floating point stack.
 return std::string("{st(1)}"); // second from top of floating point stack.
+  case 'Y':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into 
+  // the return string.
+  break;
+case 'k':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator 
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+} 
+LLVM_FALLTHROUGH;
   default:
 return std::string(1, *Constraint);
   }
Index: test/CodeGen/avx512-kconstraints-att_inline_asm.c
===
--- test/CodeGen/avx512-kconstraints-att_inline_asm.c
+++ test/CodeGen/avx512-kconstraints-att_inline_asm.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 %s -target-cpu skylake-avx512 -O0  -emit-llvm -S -o - -Wall -Werror | FileCheck %s
+// This test checks validity of att\gcc style inline assmebly for avx512 k and Yk constraints.
+// Also checks mask register allows flexible type (size <= 64 bit)
+
+void mask_Yk_i8(char msk){ 
+//CHECK: #APP 
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: #NO_APP 
+	asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
+   ://output
+   : "Yk" (msk));   //inputs
+}
+
+void mask_Yk_i16(short msk){
+//CHECK: #APP
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: #NO_APP
+	asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
+   ://output
+   :  "Yk" (msk));  //inputs
+}
+
+void mask_Yk_i32(int msk){
+//CHECK: #APP
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: #NO_APP
+asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
+   ://output
+   :  "Yk" (msk)); 	//inputs
+}
+
+void mask_Yk_i64(long long msk){
+//CHECK: #APP 
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}
+//CHECK: #NO_APP 
+	asm ("vpaddb\t %%xmm1, %%xmm0, %%xmm1 %{%0%}\t"
+   ://output
+   :  "Yk" (msk)); 	//inputs
+}
+
+void k_wise_op_i8(char msk_dst,char msk_src1,char msk_src2){
+//CHECK: #APP
+//CHECK: kandw %k1, %k0, %k0
+//CHECK: #NO_APP 
+ asm ("kandw\t%2, %1, %0"
+   : "=k" (msk_dst)
+   : "k" (msk_src1), "k" (msk_src2));
+}
+
+void k_wise_op_i16(short msk_dst, short msk_src1, short msk_src2){
+//CHECK: #APP
+//CHECK: kandw %k1, %k0, %k0
+//CHECK: #NO_APP 
+  asm ("kandw\t%2, %1, %0"
+   : "=k" (msk_dst)
+   : "k" (msk_src1), "k" (msk_src2));
+}
+
+void k_wise_op_i32(int msk_dst, int msk_src1, int msk_src2){
+//CHECK: #APP
+//CHECK: kandw %k1, %k0, %k0
+//CHECK: #NO_APP 
+  asm ("kandw\t%2, %1, %0"
+   : "=k" (msk_dst)
+   : "k" (msk_src1), "k" (msk_src2));
+}
+
+void k_wise_op_i64(long long msk_dst, long long msk_src1, long long msk_src2){
+//CHECK: #APP
+//CHECK: kandw %k1, %k0, %k0
+//CHECK: #NO_APP 
+  asm ("kandw\t%2, %1, %0"
+   : "=k" (msk_dst)
+   : "k" (msk_src1), "k" (msk_src2));
+}
\ No newline at end of file
__

[PATCH] D25062: [x86][inline-asm][AVX512][llvm][PART-2] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-20 Thread Matan via cfe-commits
mharoush removed rL LLVM as the repository for this revision.
mharoush updated this revision to Diff 75278.
mharoush added a comment.

Added LLVM_FALLTHROUGH


https://reviews.llvm.org/D25062

Files:
  lib/Target/X86/X86ISelLowering.cpp

Index: lib/Target/X86/X86ISelLowering.cpp
===
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -32225,6 +32225,7 @@
 case 'Y':
 case 'l':
   return C_RegisterClass;
+case 'k': // AVX512 masking registers.
 case 'a':
 case 'b':
 case 'c':
@@ -32248,6 +32249,19 @@
   break;
 }
   }
+  else if (Constraint.size() == 2) {
+switch (Constraint[0]) {
+default:
+  break;
+case 'Y':
+  switch (Constraint[1]) {
+  default:
+break;
+  case 'k':
+return C_Register;
+  }
+}
+  }
   return TargetLowering::getConstraintType(Constraint);
 }
 
@@ -32291,16 +32305,28 @@
 if (type->isX86_MMXTy() && Subtarget.hasMMX())
   weight = CW_SpecificReg;
 break;
+  case 'Y':
+// Other "Y" (e.g. "Yk") constraints should be implemented below.
+if (constraint[1] == 'k') {
+  // Support for 'Yk' (similarly to the 'k' variant below).
+  weight = CW_SpecificReg;
+  break;
+}
+  // Else fall through (handle "Y" constraint).
+LLVM_FALLTHROUGH;
   case 'v':
 if ((type->getPrimitiveSizeInBits() == 512) && Subtarget.hasAVX512())
   weight = CW_Register;
 LLVM_FALLTHROUGH;
   case 'x':
-  case 'Y':
 if (((type->getPrimitiveSizeInBits() == 128) && Subtarget.hasSSE1()) ||
 ((type->getPrimitiveSizeInBits() == 256) && Subtarget.hasFp256()))
   weight = CW_Register;
 break;
+  case 'k':
+// Enable conditional vector operations using %k<#> registers.
+weight = CW_SpecificReg;
+break;
   case 'I':
 if (ConstantInt *C = dyn_cast(info.CallOperandVal)) {
   if (C->getZExtValue() <= 31)
@@ -32577,6 +32603,24 @@
   // TODO: Slight differences here in allocation order and leaving
   // RIP in the class. Do they matter any more here than they do
   // in the normal allocation?
+case 'k':
+  if (Subtarget.hasAVX512()) {
+//  Only supported in AVX512 or later.
+switch (VT.SimpleTy) {
+default: break;
+case MVT::i32:
+  return std::make_pair(0U, &X86::VK32RegClass);
+case MVT::i16:
+  return std::make_pair(0U, &X86::VK16RegClass);
+case MVT::i8:
+  return std::make_pair(0U, &X86::VK8RegClass);
+case MVT::i1:
+  return std::make_pair(0U, &X86::VK1RegClass);
+case MVT::i64:
+  return std::make_pair(0U, &X86::VK64RegClass);
+}
+  }
+  break;
 case 'q':   // GENERAL_REGS in 64-bit mode, Q_REGS in 32-bit mode.
   if (Subtarget.is64Bit()) {
 if (VT == MVT::i32 || VT == MVT::f32)
@@ -32678,6 +32722,29 @@
   }
   break;
 }
+  } else if (Constraint.size() == 2 && Constraint[0] == 'Y') {
+switch (Constraint[1]) {
+default:
+  break;
+case 'k':
+  // This register class doesn't allocate k0 for masked vector operation.
+  if (Subtarget.hasAVX512()) { // Only supported in AVX512.
+switch (VT.SimpleTy) {
+default: break;
+case MVT::i32:
+  return std::make_pair(0U, &X86::VK32WMRegClass);
+case MVT::i16:
+  return std::make_pair(0U, &X86::VK16WMRegClass);
+case MVT::i8:
+  return std::make_pair(0U, &X86::VK8WMRegClass);
+case MVT::i1:
+  return std::make_pair(0U, &X86::VK1WMRegClass);
+case MVT::i64:
+  return std::make_pair(0U, &X86::VK64WMRegClass);
+} 
+  }
+  break;
+}
   }
 
   // Use the default implementation in TargetLowering to convert the register
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25011: [x86][inline-asm] Introducing (AVX512) k0-k7 registers for inline-asm usage

2016-10-20 Thread Matan via cfe-commits
mharoush added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D25011



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


[PATCH] D25777: [Sema][TreeTransform] Re-create DesignatedInitExpr when it has a field designator with a valid FieldDecl

2016-10-20 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 75279.
arphaman marked an inline comment as done.
arphaman added a comment.

The updated patch adds a comment to the modified code as request by Manman.


Repository:
  rL LLVM

https://reviews.llvm.org/D25777

Files:
  lib/Sema/TreeTransform.h
  test/SemaCXX/designated-initializers.cpp


Index: test/SemaCXX/designated-initializers.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+
+template  struct Foo {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no 
warning
+};
+
+void foo() {
+  Foo::Test();
+  Foo::Test();
+  Foo::Test();
+}
+
+template  struct Bar {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 
{{previous initialization is here}}
+.bar1 = 20}; } // expected-warning 2 
{{initializer overrides prior initialization of this subobject}}
+};
+
+void bar() {
+  Bar::Test();  // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+  Bar::Test(); // expected-note {{in instantiation of member function 
'Bar::Test' requested here}}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8923,6 +8923,12 @@
   Desig.AddDesignator(Designator::getField(D.getFieldName(),
D.getDotLoc(),
D.getFieldLoc()));
+  if (D.getField())
+// Ensure that the designator expression is rebuilt when a field
+// designator was already assigned to a specific FieldDecl because
+// that FieldDecl may be incorrect in the transformed AST if it refers
+// to a FieldDecl that has been transformed as well.
+ExprChanged = true;
   continue;
 }
 


Index: test/SemaCXX/designated-initializers.cpp
===
--- /dev/null
+++ test/SemaCXX/designated-initializers.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+
+template  struct Foo {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no warning
+};
+
+void foo() {
+  Foo::Test();
+  Foo::Test();
+  Foo::Test();
+}
+
+template  struct Bar {
+  struct SubFoo {
+int bar1;
+int bar2;
+  };
+
+  static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 {{previous initialization is here}}
+.bar1 = 20}; } // expected-warning 2 {{initializer overrides prior initialization of this subobject}}
+};
+
+void bar() {
+  Bar::Test();  // expected-note {{in instantiation of member function 'Bar::Test' requested here}}
+  Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8923,6 +8923,12 @@
   Desig.AddDesignator(Designator::getField(D.getFieldName(),
D.getDotLoc(),
D.getFieldLoc()));
+  if (D.getField())
+// Ensure that the designator expression is rebuilt when a field
+// designator was already assigned to a specific FieldDecl because
+// that FieldDecl may be incorrect in the transformed AST if it refers
+// to a FieldDecl that has been transformed as well.
+ExprChanged = true;
   continue;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 75280.
ioeric added a comment.

- Ignore using decls in old ns but not the inner-most old ns.


https://reviews.llvm.org/D25771

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
@@ -272,8 +272,8 @@
  "}\n"
  "namespace nb {\n"
  "using nc::SAME;\n"
- "using YO = nc::SAME;\n"
- "typedef nc::SAME IDENTICAL;\n"
+ "using YO = nd::SAME;\n"
+ "typedef nd::SAME IDENTICAL;\n"
  "void f(nd::SAME Same) {}\n"
  "} // namespace nb\n"
  "} // namespace na\n";
@@ -292,93 +292,14 @@
  "namespace x {\n"
  "namespace y {\n"
  "using ::na::nc::SAME;\n"
- "using YO = na::nc::SAME;\n"
- "typedef na::nc::SAME IDENTICAL;\n"
+ "using YO = na::nd::SAME;\n"
+ "typedef na::nd::SAME IDENTICAL;\n"
  "void f(na::nd::SAME Same) {}\n"
  "} // namespace y\n"
  "} // namespace x\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() {\n"
- "  using glob::Glob;\n"
- "  Glob g;\n"
- "}\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() {\n"
- "  using ::glob::Glob;\n"
- "  glob::Glob g;\n"
- "}\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingNamespace) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is "using namespace" decl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
 TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) {
   std::string Code =
   "namespace na {\n"
@@ -584,6 +505,278 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnC

[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric added a comment.

Still missing one case... working on a fix.


https://reviews.llvm.org/D25771



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 75281.
ioeric added a comment.

- Add a missing test case.


https://reviews.llvm.org/D25771

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
@@ -272,8 +272,8 @@
  "}\n"
  "namespace nb {\n"
  "using nc::SAME;\n"
- "using YO = nc::SAME;\n"
- "typedef nc::SAME IDENTICAL;\n"
+ "using YO = nd::SAME;\n"
+ "typedef nd::SAME IDENTICAL;\n"
  "void f(nd::SAME Same) {}\n"
  "} // namespace nb\n"
  "} // namespace na\n";
@@ -292,93 +292,14 @@
  "namespace x {\n"
  "namespace y {\n"
  "using ::na::nc::SAME;\n"
- "using YO = na::nc::SAME;\n"
- "typedef na::nc::SAME IDENTICAL;\n"
+ "using YO = na::nd::SAME;\n"
+ "typedef na::nd::SAME IDENTICAL;\n"
  "void f(na::nd::SAME Same) {}\n"
  "} // namespace y\n"
  "} // namespace x\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() {\n"
- "  using glob::Glob;\n"
- "  Glob g;\n"
- "}\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() {\n"
- "  using ::glob::Glob;\n"
- "  glob::Glob g;\n"
- "}\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingNamespace) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is "using namespace" decl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
 TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) {
   std::string Code =
   "namespace na {\n"
@@ -584,6 +505,312 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeName

[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-10-20 Thread Eric Liu via cfe-commits
ioeric marked 3 inline comments as done.
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:566
+  break;
+if (isDeclVisibleAtLocation(*Result.SourceManager, Using, DeclCtx, Start)) 
{
+  for (const auto *UsingShadow : Using->shadows()) {

ioeric wrote:
> ioeric wrote:
> > hokein wrote:
> > > Yeah, it works for most cases, but it can not guarantee that they are 
> > > still in the same DeclContext after changing to new namespace.
> > > 
> > > For example, the following case where an using-decl is used in the 
> > > namespace being renamed, we change `b::c` to `d::e`, although DeclContext 
> > > `d` of callexpr `f()` is a nested DeclContext of `b` (also DeclContext of 
> > > `using a::f`), but this assumption is wrong after changing namespace 
> > > because we keep `using a::f` in its original namespace.
> > > 
> > > ```
> > > namespace a { void f(); }
> > > 
> > > namespace b {
> > > using a::f;
> > > namespace c {
> > > void d() { f(); }
> > > }  // c
> > > } // b
> > > ```
> > > 
> > > Not sure whether we should do this in our tool. I suspect there might be 
> > > a lot of corner cases.
> > > 
> > I thought using decls in old namespaces should be moved with along with 
> > namespaces. If this is the case, the moving of using decls is unexpected 
> > (looking into this), but this patch is handling this correctly if using 
> > decls are not moved.
> Ahh, I was wrong. `using a::f` should not be moved. Hmm, I think we can solve 
> or at least workaround this. But I still think we should support shortening 
> namespace specifier based on using decls; it is quite not nice to add long 
> specifiers if there are already using decls present.
This should be fixed with the new matcher.


https://reviews.llvm.org/D25771



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


[PATCH] D25819: [Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC

2016-10-20 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: bruno, bkramer, rafael.
mgorny added a subscriber: cfe-commits.

Refactor the DetectDistro() function to take a single vfs::FileSystem
reference only, instead of Driver and llvm::Triple::ArchType.
The ArchType parameter was not used anyway, and Driver was only used to
obtain the VFS.

Aside to making the API simpler and more transparent, it makes it
easier to add unit tests for the function in the future -- since
the tests would need only to provide an appropriate VFS.


https://reviews.llvm.org/D25819

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3850,9 +3850,9 @@
   return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
 }
 
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
   llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile("/etc/lsb-release");
+  VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3884,7 +3884,7 @@
   return Version;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/redhat-release");
+  File = VFS.getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@
 return UnknownDistro;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/debian_version");
+  File = VFS.getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data[0] == '5')
@@ -3918,13 +3918,13 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
+  if (VFS.exists("/etc/SuSE-release"))
 return OpenSUSE;
 
-  if (D.getVFS().exists("/etc/exherbo-release"))
+  if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
 
-  if (D.getVFS().exists("/etc/arch-release"))
+  if (VFS.exists("/etc/arch-release"))
 return ArchLinux;
 
   return UnknownDistro;
@@ -4109,7 +4109,7 @@
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Distro Distro = DetectDistro(D, Arch);
+  Distro Distro = DetectDistro(D.getVFS());
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
 ExtraOpts.push_back("-z");
@@ -4313,7 +4313,7 @@
   const llvm::Triple::ArchType Arch = getArch();
   const llvm::Triple &Triple = getTriple();
 
-  const enum Distro Distro = DetectDistro(getDriver(), Arch);
+  const enum Distro Distro = DetectDistro(getDriver().getVFS());
 
   if (Triple.isAndroid())
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3850,9 +3850,9 @@
   return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
 }
 
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
   llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile("/etc/lsb-release");
+  VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3884,7 +3884,7 @@
   return Version;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/redhat-release");
+  File = VFS.getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@
 return UnknownDistro;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/debian_version");
+  File = VFS.getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data[0] == '5')
@@ -3918,13 +3918,13 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
+  if (VFS.exists("/etc/SuSE-release"))
 return OpenSUSE;
 
-  if (D.getVFS().exists("/etc/exherbo-release"))
+  if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
 
-  if (D.getVFS().exists("/etc/arch-release"))
+  if (VFS.exists("/etc/arch-release"))
 return ArchLinux;
 
   return UnknownDistro;
@@ -4109,7 +4109,7 @@
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Distro Distro = DetectDistro(D, Arch);
+  Distro Distro = DetectDistro(D.getVFS());
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
 ExtraOpts.push_back("-z");
@@ -4313,7 +4313,7 @@
   const llvm::Triple::ArchType Arch = getArch();
   const llvm::Triple &Triple = getTriple();
 
-  const enum Distro Distro = DetectDistro(getDriver(), Arch);
+  const enum Distro Distro = DetectDistro(getDriver().getVFS());
 
   if (Triple.isAndroid())
 return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system

[PATCH] D25649: [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.

2016-10-20 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.

LGTM. I will commit for you.


Repository:
  rL LLVM

https://reviews.llvm.org/D25649



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


[clang-tools-extra] r284719 - [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.

2016-10-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct 20 06:32:47 2016
New Revision: 284719

URL: http://llvm.org/viewvc/llvm-project?rev=284719&view=rev
Log:
[Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.

Hello, i would like to suggest a fix for one of the checks in clang-tidy and i 
should hope this one is the correct mailing list.
The check is modernize-avoid-bind.

Consider the following:

  void bar(int x, int y);

  namespace N {
void bar(int x, int y);
  }

  void foo(){
auto Test = std::bind(N::bar,1,1);
  }

clang-tidy’s modernize-avoid-bind check suggests writing:

  void foo(){
auto Test =[] {return bar(1,1);};
  }

instead of:

  void foo(){
auto Test = [] {return N::bar(1,1);};
  }

So clang-tidy has proposed an incorrect Fix.

Patch by IdrissRio!

Reviewers: alexfh, hokein, aaron.ballman

Subscriber: cfe-commits

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp?rev=284719&r1=284718&r2=284719&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/AvoidBindCheck.cpp Thu Oct 20 
06:32:47 2016
@@ -108,8 +108,9 @@ void AvoidBindCheck::registerMatchers(Ma
 return;
 
   Finder->addMatcher(
-  callExpr(callee(namedDecl(hasName("::std::bind"))),
-   hasArgument(0, declRefExpr(to(functionDecl().bind("f")
+  callExpr(
+  callee(namedDecl(hasName("::std::bind"))),
+  hasArgument(0, 
declRefExpr(to(functionDecl().bind("f"))).bind("ref")))
   .bind("bind"),
   this);
 }
@@ -148,14 +149,17 @@ void AvoidBindCheck::check(const MatchFi
 
   bool HasCapturedArgument = llvm::any_of(
   Args, [](const BindArgument &B) { return B.Kind == BK_Other; });
-
+  const auto *Ref = Result.Nodes.getNodeAs("ref");
   Stream << "[" << (HasCapturedArgument ? "=" : "") << "]";
   addPlaceholderArgs(Args, Stream);
-  Stream << " { return " << F->getName() << "(";
+  Stream << " { return ";
+  Ref->printPretty(Stream, nullptr, Result.Context->getPrintingPolicy());
+  Stream<< "(";
   addFunctionCallArgs(Args, Stream);
   Stream << "); };";
 
-  Diag << FixItHint::CreateReplacement(MatchedDecl->getSourceRange(), 
Stream.str());
+  Diag << FixItHint::CreateReplacement(MatchedDecl->getSourceRange(),
+   Stream.str());
 }
 
 } // namespace modernize

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp?rev=284719&r1=284718&r2=284719&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp Thu Oct 20 
06:32:47 2016
@@ -68,3 +68,12 @@ void m() {
   // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
 }
 
+namespace C {
+  int add(int x, int y){ return x + y; }
+}
+
+void n() {
+  auto clj = std::bind(C::add, 1, 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
+  // CHECK-FIXES: auto clj = [] { return C::add(1, 1); };
+}


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


[PATCH] D25820: [Sema][Objective-C] Formatting warnings should see through Objective-C message sends

2016-10-20 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added a reviewer: manmanren.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch improves the '-Wformat' warnings by ensuring that the formatting 
checker can see through Objective-C message sends when we are calling an 
Objective-C method with an appropriate `format_arg` attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D25820

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaObjC/format-strings-objc.m


Index: test/SemaObjC/format-strings-objc.m
===
--- test/SemaObjC/format-strings-objc.m
+++ test/SemaObjC/format-strings-objc.m
@@ -264,3 +264,38 @@
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object 
format flags cannot be used with 's' conversion specifier}}
 }
+
+// rdar://23622446
+@interface RD23622446_Tester: NSObject
+
++ (void)stringWithFormat:(const char *)format, ... 
__attribute__((format(__printf__, 1, 2)));
+
+@end
+
+@implementation RD23622446_Tester
+
+__attribute__ ((format_arg(1)))
+const char *rd23622446(const char *format) {
+  return format;
+}
+
++ (void)stringWithFormat:(const char *)format, ... {
+  return;
+}
+
+- (const char *)test:(const char *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (NSString *)str:(NSString *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (void)foo {
+  [RD23622446_Tester stringWithFormat:rd23622446("%u"), 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%u"], 1, 2]; // 
expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%s %s"], "name"]; // 
expected-warning {{more '%' conversions than data arguments}}
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' 
conversions than data arguments}}
+}
+
+@end
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -4291,6 +4291,20 @@
 
 return SLCT_NotALiteral;
   }
+  case Stmt::ObjCMessageExprClass: {
+const auto *ME = cast(E);
+if (const auto *ND = ME->getMethodDecl()) {
+  if (const auto *FA = ND->getAttr()) {
+unsigned ArgIndex = FA->getFormatIdx();
+const Expr *Arg = ME->getArg(ArgIndex - 1);
+return checkFormatStringExpr(
+S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+CallType, InFunctionCall, CheckedVarArgs, UncoveredArg, Offset);
+  }
+}
+
+return SLCT_NotALiteral;
+  }
   case Stmt::ObjCStringLiteralClass:
   case Stmt::StringLiteralClass: {
 const StringLiteral *StrE = nullptr;


Index: test/SemaObjC/format-strings-objc.m
===
--- test/SemaObjC/format-strings-objc.m
+++ test/SemaObjC/format-strings-objc.m
@@ -264,3 +264,38 @@
   NSLog(@"%2$[tt]@ %1$[tt]@", @"Foo", @"Bar"); // no-warning
   NSLog(@"%2$[tt]@ %1$[tt]s", @"Foo", @"Bar"); // expected-warning {{object format flags cannot be used with 's' conversion specifier}}
 }
+
+// rdar://23622446
+@interface RD23622446_Tester: NSObject
+
++ (void)stringWithFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
+
+@end
+
+@implementation RD23622446_Tester
+
+__attribute__ ((format_arg(1)))
+const char *rd23622446(const char *format) {
+  return format;
+}
+
++ (void)stringWithFormat:(const char *)format, ... {
+  return;
+}
+
+- (const char *)test:(const char *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (NSString *)str:(NSString *)format __attribute__ ((format_arg(1))) {
+  return format;
+}
+
+- (void)foo {
+  [RD23622446_Tester stringWithFormat:rd23622446("%u"), 1, 2]; // expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%u"], 1, 2]; // expected-warning {{data argument not used by format string}}
+  [RD23622446_Tester stringWithFormat:[self test: "%s %s"], "name"]; // expected-warning {{more '%' conversions than data arguments}}
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' conversions than data arguments}}
+}
+
+@end
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -4291,6 +4291,20 @@
 
 return SLCT_NotALiteral;
   }
+  case Stmt::ObjCMessageExprClass: {
+const auto *ME = cast(E);
+if (const auto *ND = ME->getMethodDecl()) {
+  if (const auto *FA = ND->getAttr()) {
+unsigned ArgIndex = FA->getFormatIdx();
+const Expr *Arg = ME->getArg(ArgIndex - 1);
+return checkFormatStringExpr(
+S, Arg, Args, HasVAListArg, format_idx, firstDataArg, Type,
+   

[PATCH] D25649: [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.

2016-10-20 Thread Haojian Wu via cfe-commits
hokein closed this revision.
hokein added a comment.

Committed in r284719 with some nits fixing.

As @jlebar mentioned above, please consider use `Arcanist` 
(http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line)
 to upload your patch, which will make the commit stuff easier.


Repository:
  rL LLVM

https://reviews.llvm.org/D25649



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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

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



Comment at: include/clang/AST/TypeLoc.h:513
 struct BuiltinLocInfo {
-  SourceLocation BuiltinLoc;
+  SourceRange BuiltinRange;
 };

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > malcolm.parsons wrote:
> > > > aaron.ballman wrote:
> > > > > malcolm.parsons wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > Since this doubles the size of the type loc for builtin types, do 
> > > > > > > you happen to have any data on what practical impact this has on 
> > > > > > > RAM usage, say for bootstrapping LLVM (or compiling any large 
> > > > > > > source base, really)? Hopefully it's not a lot, but it would be 
> > > > > > > nice to know if it's a .1%, 1%, 10%, etc increase in usage (or 
> > > > > > > does the change get lost in the noise).
> > > > > > I don't have any data.
> > > > > > I'm not sure how to collect that data.
> > > > > It's likely platform dependent, but I was thinking something as 
> > > > > simple as looking at peak RAM usage between two different builds of 
> > > > > the compiler. Something like `top` would probably work if you're on 
> > > > > Linux (unless someone knows of a better way, I'm not strong on Linux).
> > > > Before:
> > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
> > > > 5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata 
> > > > 256820maxresident)k
> > > > 
> > > > After:
> > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
> > > > 5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata 
> > > > 256940maxresident)k
> > > > 
> > > > ((256940 - 256820) / 256820) * 100 = 0.05%
> > > Thank you for this -- is there a bigger delta for compilation of LLVM as 
> > > a whole? ExprConstant.cpp is an interesting case, but not really 
> > > representative of the project as a whole (for instance, there's not a lot 
> > > of template metaprogramming in ExprConstant.cpp).
> > I can try running time on a full build.
> > For every file I sampled the increase was 0.05%.
> > Do TypeLocs increase when using TMP?
> I *think* that template arguments use TypeLocs, but I could be remembering 
> incorrectly (and I unfortunately won't have the chance to check until next 
> week sometime). I was asking for the whole project just in case there is some 
> construct that has a heavier use of them. Your findings of .05% are really 
> promising though.
Time reports max resident for building lib dir of llvm as 480780 before, 480920 
after.
0.03%


https://reviews.llvm.org/D25363



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


[PATCH] D25649: [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.

2016-10-20 Thread Idriss via cfe-commits
IdrissRio added a comment.

Can someone commit the patch  ( https://reviews.llvm.org/D25649 ) because i 
don't have commit privileges.
Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D25649



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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

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

LGTM!




Comment at: include/clang/AST/TypeLoc.h:513
 struct BuiltinLocInfo {
-  SourceLocation BuiltinLoc;
+  SourceRange BuiltinRange;
 };

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > malcolm.parsons wrote:
> > > > > aaron.ballman wrote:
> > > > > > malcolm.parsons wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > Since this doubles the size of the type loc for builtin types, 
> > > > > > > > do you happen to have any data on what practical impact this 
> > > > > > > > has on RAM usage, say for bootstrapping LLVM (or compiling any 
> > > > > > > > large source base, really)? Hopefully it's not a lot, but it 
> > > > > > > > would be nice to know if it's a .1%, 1%, 10%, etc increase in 
> > > > > > > > usage (or does the change get lost in the noise).
> > > > > > > I don't have any data.
> > > > > > > I'm not sure how to collect that data.
> > > > > > It's likely platform dependent, but I was thinking something as 
> > > > > > simple as looking at peak RAM usage between two different builds of 
> > > > > > the compiler. Something like `top` would probably work if you're on 
> > > > > > Linux (unless someone knows of a better way, I'm not strong on 
> > > > > > Linux).
> > > > > Before:
> > > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
> > > > > 5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata 
> > > > > 256820maxresident)k
> > > > > 
> > > > > After:
> > > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp
> > > > > 5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata 
> > > > > 256940maxresident)k
> > > > > 
> > > > > ((256940 - 256820) / 256820) * 100 = 0.05%
> > > > Thank you for this -- is there a bigger delta for compilation of LLVM 
> > > > as a whole? ExprConstant.cpp is an interesting case, but not really 
> > > > representative of the project as a whole (for instance, there's not a 
> > > > lot of template metaprogramming in ExprConstant.cpp).
> > > I can try running time on a full build.
> > > For every file I sampled the increase was 0.05%.
> > > Do TypeLocs increase when using TMP?
> > I *think* that template arguments use TypeLocs, but I could be remembering 
> > incorrectly (and I unfortunately won't have the chance to check until next 
> > week sometime). I was asking for the whole project just in case there is 
> > some construct that has a heavier use of them. Your findings of .05% are 
> > really promising though.
> Time reports max resident for building lib dir of llvm as 480780 before, 
> 480920 after.
> 0.03%
Awesome, thank you for getting this information; this seems like a reasonable 
consumption change to me.


https://reviews.llvm.org/D25363



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


[PATCH] D25450: [clang-tidy] Fix identifier naming in macro args.

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



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:654
+  RangeIsEntirelyWithinMacroArgument || !RangeContainsMacroExpansion;
+  Failure.ShouldFix = Failure.ShouldFix && RangeCanBeFixed;
 }

We could do an early return if `ShouldFix` is already false and simplify this 
expression with `ShouldFix = RangeCanBeFixed;`, can't we?


https://reviews.llvm.org/D25450



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


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

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

LGTM




Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:30
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();

I think this should be a public AST matcher rather than a private one; it seems 
like it would be generally useful (along with some of the other similar has* 
functions). However, I think it's fine for this patch.


https://reviews.llvm.org/D25747



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


[PATCH] D22346: [Clang-tidy] CERT-MSC50-CPP (std:rand() )

2016-10-20 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I noticed you marked several comments as done, but the patch is not updated 
with changes. Have I missed something?


https://reviews.llvm.org/D22346



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


[clang-tools-extra] r284727 - [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Oct 20 08:15:40 2016
New Revision: 284727

URL: http://llvm.org/viewvc/llvm-project?rev=284727&view=rev
Log:
[clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

Summary:
The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.

Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=284727&r1=284726&r2=284727&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Thu Oct 20 08:15:40 2016
@@ -27,6 +27,10 @@ namespace cppcoreguidelines {
 
 namespace {
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonmyous struct). If OneFieldPerUnion is true and
 // the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@ void ProTypeMemberInitCheck::registerMat
   Finder->addMatcher(
   cxxRecordDecl(
   isDefinition(), unless(isInstantiated()),
+  hasDefaultConstructor(),
   anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit(,
 unless(has(cxxConstructorDecl(,

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=284727&r1=284726&r2=284727&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Thu Oct 20 08:15:40 2016
@@ -450,3 +450,9 @@ struct NegativeIncompleteArrayMember {
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};


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


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284727: [clang-tidy] Fix an assertion failure in 
cppcoreguidelines-pro-type-member-init. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25747?vs=75066&id=75291#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25747

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,6 +27,10 @@
 
 namespace {
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonmyous struct). If OneFieldPerUnion is true and
 // the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@
   Finder->addMatcher(
   cxxRecordDecl(
   isDefinition(), unless(isInstantiated()),
+  hasDefaultConstructor(),
   anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit(,
 unless(has(cxxConstructorDecl(,
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -450,3 +450,9 @@
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -27,6 +27,10 @@
 
 namespace {
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonmyous struct). If OneFieldPerUnion is true and
 // the record type (or indirect field) is a union, forEachField will stop after
@@ -275,6 +279,7 @@
   Finder->addMatcher(
   cxxRecordDecl(
   isDefinition(), unless(isInstantiated()),
+  hasDefaultConstructor(),
   anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
unless(isImplicit(,
 unless(has(cxxConstructorDecl(,
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -450,3 +450,9 @@
   NegativeIncompleteArrayMember() {}
   char e[];
 };
+
+template  class NoCrash {
+  class B : public NoCrash {
+template  B(U u) {}
+  };
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25747: [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.

2016-10-20 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:30
 
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();

aaron.ballman wrote:
> I think this should be a public AST matcher rather than a private one; it 
> seems like it would be generally useful (along with some of the other similar 
> has* functions). However, I think it's fine for this patch.
+1, will do it in a follow-up.


https://reviews.llvm.org/D25747



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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

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



Comment at: include/clang/AST/TypeLoc.h:533
+} else {
+  BuiltinRange.setBegin(std::min(Range.getBegin(), 
BuiltinRange.getBegin()));
+  BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));

I suspect that using `min` and `max` on `SourceLocation`s is only valid if both 
locations are in the same file.

Doing this
long.h:
```
long
```
unsigned.cpp:
```
unsigned
#include "long.h"
i;
```

causes
clang-query> match typeLoc()
...
clang-query: llvm/tools/clang/lib/Frontend/DiagnosticRenderer.cpp:273: 
clang::SourceLocation retrieveMacroLocation(clang::SourceLocation, 
clang::FileID, clang::FileID, const llvm::SmallVectorImpl&, 
bool, const clang::SourceManager*): Assertion `SM->getFileID(Loc) == 
MacroFileID' failed.

Is there a better way to combine `SourceRange`s, or should the final range be 
accumulated in DeclSpec.cpp?


https://reviews.llvm.org/D25363



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


[PATCH] D25816: Use descriptive message if list initializer is incorrectly parenthesized.

2016-10-20 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

Thanks for working on this! I have a couple of comments:




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1762
 def err_init_incomplete_type : Error<"initialization of incomplete type %0">;
+def err_list_init_in_parens : Error<"list-initializer for non-class type "
+  "must not be parenthesized">;

Wouldn't it be better if we had a diagnostic with the type information? So, 
instead of showing `list-initializer for non-class type must not be 
parenthesized` clang would show `list-initializer for non-class type 'int' must 
not be parenthesized`. What do you think?

As well as that, it seems that GCC issues a warning instead of an error for 
this diagnostic, so should this be a warning in clang as well?



Comment at: include/clang/Sema/Sema.h:1802
   void ActOnInitializerError(Decl *Dcl);
+  bool cannotBeInitializededByParenthzedList(QualType TargetType);
   void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);

I think you mean `parenthesized` instead of `parenthzed` here. As well as that, 
I think that it would be better to use a name without the `not`, something like 
`canInitializeWithParenthesizedList`.

Also, please add a comment that explains what this method does.



Comment at: include/clang/Sema/Sema.h:1803
+  bool cannotBeInitializededByParenthzedList(QualType TargetType);
   void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc);
   void ActOnCXXForRangeDecl(Decl *D);

Please add a blank line here to separate unrelated `Act...` methods from the 
new method.



Comment at: lib/Sema/SemaDecl.cpp:9796
+Diag(VDecl->getLocation(), diag::err_list_init_in_parens)
+  << CXXDirectInit->getSourceRange()
+  << FixItHint::CreateRemoval(CXXDirectInit->getLocStart())

Slight formatting issue: please indent the three lines that start with '<<' 
using 4 extra spaces instead of 2  (just like you did in your changes for 
SemaExprCXX.cpp).



Comment at: lib/Sema/SemaDecl.cpp:10110
+bool Sema::cannotBeInitializededByParenthzedList(QualType TargetType) {
+  return !TargetType->isDependentType() && !TargetType->isRecordType() &&
+ !TargetType->getContainedAutoType();

If you change the name as I suggested to something like 
`canInitializeWithParenthesizedList` then the logic here would have to be 
inverted: `TargetType()->isDependentType() || TargetType()->isRecordType() || 
TargetType()->getContainedAutoType()`. Consequently, the call sites will have 
to be updated to include a `!` before the call.



Comment at: lib/Sema/SemaExprCXX.cpp:1229
+  Diag(TInfo->getTypeLoc().getLocStart(), diag::err_list_init_in_parens)
+  << IList->getSourceRange()
+  << FixItHint::CreateRemoval(LParenLoc)

Formatting issue: clang-format replaces

```
  << IList->getSourceRange()
  << FixItHint::CreateRemoval(LParenLoc)
```
with
```
  << IList->getSourceRange() << FixItHint::CreateRemoval(LParenLoc)
```



Comment at: test/SemaCXX/cxx0x-initializer-scalars.cpp:96
+(void) int({0}); // expected-error {{list-initializer for non-class type 
must not be parenthesized}}
+new int({0});  // expected-error {{list-initializer for non-class type 
must not be parenthesized}}
   }

Please add a test case for a pointer type as well, something like this should 
work:
```
int *x({0});
```
As well as that, please add a test for a dependent type.


https://reviews.llvm.org/D25816



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


[PATCH] D25769: [clang-tidy] Simplify modernize-use-default

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

LGTM with a small nit, but you may want to wait for @djasper to weigh in on the 
removed comment question.




Comment at: clang-tidy/modernize/UseDefaultCheck.cpp:266
   // If there are constructor initializers, they must be removed.
-  if (Ctor->getNumCtorInitializers() != 0) {
-StartLoc = getColonLoc(Result.Context, Ctor);
-if (!StartLoc.isValid())
-  return;
+  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+RemoveInitializers.emplace_back(

You can use `const auto *` here.


https://reviews.llvm.org/D25769



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


[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types

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



Comment at: include/clang/AST/TypeLoc.h:533
+} else {
+  BuiltinRange.setBegin(std::min(Range.getBegin(), 
BuiltinRange.getBegin()));
+  BuiltinRange.setEnd(std::max(Range.getEnd(), BuiltinRange.getEnd()));

malcolm.parsons wrote:
> I suspect that using `min` and `max` on `SourceLocation`s is only valid if 
> both locations are in the same file.
> 
> Doing this
> long.h:
> ```
> long
> ```
> unsigned.cpp:
> ```
> unsigned
> #include "long.h"
> i;
> ```
> 
> causes
> clang-query> match typeLoc()
> ...
> clang-query: llvm/tools/clang/lib/Frontend/DiagnosticRenderer.cpp:273: 
> clang::SourceLocation retrieveMacroLocation(clang::SourceLocation, 
> clang::FileID, clang::FileID, const llvm::SmallVectorImpl&, 
> bool, const clang::SourceManager*): Assertion `SM->getFileID(Loc) == 
> MacroFileID' failed.
> 
> Is there a better way to combine `SourceRange`s, or should the final range be 
> accumulated in DeclSpec.cpp?
Hmm, that's a good point, but I'm not aware of a better utility. Perhaps 
@rsmith knows of one?


https://reviews.llvm.org/D25363



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-10-20 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D25811#575105, @EricWF wrote:

> Seems like we should figure out why these pass on ToT OS X.


All of them have

// XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
// XFAIL: with_system_cxx_lib=x86_64-apple-darwin12

Maybe that's it.  I don't have access to OS X, so I can't test it there.


Repository:
  rL LLVM

https://reviews.llvm.org/D25811



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


[PATCH] D25769: [clang-tidy] Simplify modernize-use-default

2016-10-20 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a reviewer: djasper.
djasper added a comment.

I don't know whether it is an intentional choice to remove this comment. I'd be 
fine either way (I think there are arguments for and against it). So, this 
looks good to me. But maybe Eric has something to add.


https://reviews.llvm.org/D25769



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


[PATCH] D25811: [libcxx] Fix toupper/tolower tests for UTF-8 locale

2016-10-20 Thread Krzysztof Parzyszek via cfe-commits
kparzysz updated this revision to Diff 75292.
kparzysz added a comment.

Unxfail these tests on Linux.


Repository:
  rL LLVM

https://reviews.llvm.org/D25811

Files:
  
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
  
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
  
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
  
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp


Index: 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
===
--- 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
+++ 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -35,7 +34,7 @@
 std::string in("\xFA A\x07.a1");
 
 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + 
in.size());
-assert(in[0] == '\xDA');
+assert(in[0] == '\xFA');
 assert(in[1] == ' ');
 assert(in[2] == 'A');
 assert(in[3] == '\x07');
Index: 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
===
--- 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
+++ 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -39,7 +38,7 @@
 assert(f.toupper('a') == 'A');
 assert(f.toupper('1') == '1');
 assert(f.toupper('\xDA') == '\xDA');
-assert(f.toupper('\xFA') == '\xDA');
+assert(f.toupper('\xFA') == '\xFA');
 }
 }
 {
Index: 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
===
--- 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
+++ 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -35,7 +34,7 @@
 std::string in("\xDA A\x07.a1");
 
 assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + 
in.size());
-assert(in[0] == '\xFA');
+assert(in[0] == '\xDA');
 assert(in[1] == ' ');
 assert(in[2] == 'a');
 assert(in[3] == '\x07');
Index: 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
===
--- 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
+++ 
test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -38,7 +37,7 @@
 assert(f.tolower('.') == '.');
 assert(f.tolower('a') == 'a');
 assert(f.tolower('1') == '1');
-assert(f.tolower('\xDA') == '\xFA');
+assert(f.tolower('\xDA') == '\xDA');
 assert(f.tolower('\xFA') == '\xFA');
 }
 }


Index: test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
===
--- test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
+++ test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
@@ -17,7 +17,6 @@
 
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
-// XFAIL: linux
 
 #include 
 #include 
@@ -35,7 +34,7 @@
 std::string in("\xFA A\x07.a1");
 
 assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
-assert(in[0] == '\xDA');
+assert(in[0] == '\xFA');
 assert(in[1] == ' ');
 assert(in[2] == 'A');
 assert(in[3] == '\x07');
Index: test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
==

[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

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

LGTM




Comment at: lib/Sema/SemaExprCXX.cpp:6287
+Context.hasSameUnqualifiedType(DestructedType,
+   ObjectType->getPointeeType())) {
+  Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)

You can elide the curly braces.


Repository:
  rL LLVM

https://reviews.llvm.org/D25817



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


[PATCH] D25769: [clang-tidy] Simplify modernize-use-default

2016-10-20 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added inline comments.



Comment at: test/clang-tidy/modernize-use-default-copy.cpp:85
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default'
+  // CHECK-FIXES: /* don't delete */  = default;
   int Field;

malcolm.parsons wrote:
> I don't know why cleanup removes this comment, but there are format units 
> tests that check that it does.
This is intended behavior of `cleanup`. Generally, if a deleted code results in 
a redundant token around it, comments between the redundant token and its 
previous/next token (ignoring the deleted code) are considered belonging to the 
deleted code. Considering how a normal developer writes code, this would be 
correct most of the time IMO. 


https://reviews.llvm.org/D25769



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


r284729 - Clean up alignment hacks now that MSVC 2013 and GCC 4.7 are gone.

2016-10-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 20 08:52:26 2016
New Revision: 284729

URL: http://llvm.org/viewvc/llvm-project?rev=284729&view=rev
Log:
Clean up alignment hacks now that MSVC 2013 and GCC 4.7 are gone.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/TemplateBase.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/TemplateDeduction.h

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=284729&r1=284728&r2=284729&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Oct 20 08:52:26 2016
@@ -56,7 +56,7 @@ namespace clang {
 
 /// Stmt - This represents one statement.
 ///
-class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt {
+class alignas(void *) Stmt {
 public:
   enum StmtClass {
 NoStmtClass = 0,

Modified: cfe/trunk/include/clang/AST/TemplateBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateBase.h?rev=284729&r1=284728&r2=284729&view=diff
==
--- cfe/trunk/include/clang/AST/TemplateBase.h (original)
+++ cfe/trunk/include/clang/AST/TemplateBase.h Thu Oct 20 08:52:26 2016
@@ -607,7 +607,7 @@ public:
 /// as such, doesn't contain the array of TemplateArgumentLoc itself,
 /// but expects the containing object to also provide storage for
 /// that.
-struct LLVM_ALIGNAS(LLVM_PTR_SIZE) ASTTemplateKWAndArgsInfo {
+struct alignas(void *) ASTTemplateKWAndArgsInfo {
   /// \brief The source location of the left angle bracket ('<').
   SourceLocation LAngleLoc;
 

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=284729&r1=284728&r2=284729&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu Oct 20 08:52:26 2016
@@ -1417,15 +1417,12 @@ struct DeclaratorChunk {
 unsigned TypeQuals : 5;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
-union {
-  void *Aligner;
-  char Mem[sizeof(CXXScopeSpec)];
-} ScopeMem;
+alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
 CXXScopeSpec &Scope() {
-  return *reinterpret_cast(ScopeMem.Mem);
+  return *reinterpret_cast(ScopeMem);
 }
 const CXXScopeSpec &Scope() const {
-  return *reinterpret_cast(ScopeMem.Mem);
+  return *reinterpret_cast(ScopeMem);
 }
 void destroy() {
   Scope().~CXXScopeSpec();
@@ -1580,7 +1577,7 @@ struct DeclaratorChunk {
 I.EndLoc= Loc;
 I.Mem.TypeQuals = TypeQuals;
 I.Mem.AttrList  = nullptr;
-new (I.Mem.ScopeMem.Mem) CXXScopeSpec(SS);
+new (I.Mem.ScopeMem) CXXScopeSpec(SS);
 return I;
   }
 

Modified: cfe/trunk/include/clang/Sema/TemplateDeduction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TemplateDeduction.h?rev=284729&r1=284728&r2=284729&view=diff
==
--- cfe/trunk/include/clang/Sema/TemplateDeduction.h (original)
+++ cfe/trunk/include/clang/Sema/TemplateDeduction.h Thu Oct 20 08:52:26 2016
@@ -199,10 +199,7 @@ struct DeductionFailureInfo {
   void *Data;
 
   /// \brief A diagnostic indicating why deduction failed.
-  union {
-void *Align;
-char Diagnostic[sizeof(PartialDiagnosticAt)];
-  };
+  alignas(PartialDiagnosticAt) char Diagnostic[sizeof(PartialDiagnosticAt)];
 
   /// \brief Retrieve the diagnostic which caused this deduction failure,
   /// if any.


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


[PATCH] D22712: Remove FileEntry copy-constructor

2016-10-20 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

@bkramer ?


https://reviews.llvm.org/D22712



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


r284730 - Retire llvm::alignOf in favor of C++11 alignof.

2016-10-20 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Oct 20 09:27:22 2016
New Revision: 284730

URL: http://llvm.org/viewvc/llvm-project?rev=284730&view=rev
Log:
Retire llvm::alignOf in favor of C++11 alignof.

No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ASTVector.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclGroup.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprObjC.cpp
cfe/trunk/lib/AST/NestedNameSpecifier.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtCXX.cpp
cfe/trunk/lib/AST/StmtObjC.cpp
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/AST/TemplateBase.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGCleanup.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/EHScopeStack.h
cfe/trunk/lib/Lex/MacroInfo.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PreprocessingRecord.cpp
cfe/trunk/lib/Sema/AttributeList.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp
cfe/trunk/lib/Sema/TypeLocBuilder.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284730&r1=284729&r2=284730&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Oct 20 09:27:22 2016
@@ -582,7 +582,7 @@ public:
 return BumpAlloc.Allocate(Size, Align);
   }
   template  T *Allocate(size_t Num = 1) const {
-return static_cast(Allocate(Num * sizeof(T), llvm::alignOf()));
+return static_cast(Allocate(Num * sizeof(T), alignof(T)));
   }
   void Deallocate(void *Ptr) const { }
   

Modified: cfe/trunk/include/clang/AST/ASTVector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTVector.h?rev=284730&r1=284729&r2=284730&view=diff
==
--- cfe/trunk/include/clang/AST/ASTVector.h (original)
+++ cfe/trunk/include/clang/AST/ASTVector.h Thu Oct 20 09:27:22 2016
@@ -380,7 +380,7 @@ void ASTVector::grow(const ASTContext
 NewCapacity = MinSize;
 
   // Allocate the memory from the ASTContext.
-  T *NewElts = new (C, llvm::alignOf()) T[NewCapacity];
+  T *NewElts = new (C, alignof(T)) T[NewCapacity];
 
   // Copy the elements over.
   if (Begin != End) {

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=284730&r1=284729&r2=284730&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Oct 20 09:27:22 2016
@@ -340,7 +340,7 @@ protected:
 
 public:
   Stmt(StmtClass SC) {
-static_assert(sizeof(*this) % llvm::AlignOf::Alignment == 0,
+static_assert(sizeof(*this) % alignof(void *) == 0,
   "Insufficient alignment!");
 StmtBits.sClass = SC;
 if (StatisticsEnabled) Stmt::addStmtClass(SC);

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=284730&r1=284729&r2=284730&view=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Thu Oct 20 09:27:22 2016
@@ -70,7 +70,7 @@ protected:
   : Stmt(SC), Kind(K), StartLoc(std::move(StartLoc)),
 EndLoc(std::move(EndLoc)), NumClauses(NumClauses),
 NumChildren(NumChildren),
-ClausesOffset(llvm::alignTo(sizeof(T), llvm::alignOf())) 
{}
+ClausesOffset(llvm::alignTo(sizeof(T), alignof(OMPClause *))) {}
 
   /// \brief Sets the list of variables for this clause.
   ///

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=284730&r1=284729&r2=284730&view=diff
==
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Thu Oct 20 09:27:22 2016
@@ -347,7 +347,7 @@ class ConcreteTypeLoc : public Base {
 
 public:
   unsigned getLocalDataAlignment() const

[PATCH] D25820: [Sema][Objective-C] Formatting warnings should see through Objective-C message sends

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



Comment at: test/SemaObjC/format-strings-objc.m:299
+  NSLog([self str: @"%@ %@"], @"name"); // expected-warning {{more '%' 
conversions than data arguments}}
+}
+

Can you add an example showing a positive use case as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D25820



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


Re: [PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-20 Thread David Blaikie via cfe-commits
If we issue a fixit we should recover as-if the code was written with the
fixit in. Does this code do that? (can we test it? I know we test some
fixits - not sure it's necessary/worthwhile to test them all, but maybe we
have a good idiom for testing that the recovery is correct)

On Thu, Oct 20, 2016 at 6:47 AM Aaron Ballman 
wrote:

> aaron.ballman accepted this revision.
> aaron.ballman added a reviewer: aaron.ballman.
> aaron.ballman added a comment.
> This revision is now accepted and ready to land.
>
> LGTM
>
>
>
> 
> Comment at: lib/Sema/SemaExprCXX.cpp:6287
> +Context.hasSameUnqualifiedType(DestructedType,
> +   ObjectType->getPointeeType()))
> {
> +  Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
> 
> You can elide the curly braces.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D25817
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22712: Remove FileEntry copy-constructor

2016-10-20 Thread Vedant Kumar via cfe-commits
vsk added a comment.

I believe gcc 4.7 and msvc 2013 are now unsupported (see e.g r284729).


https://reviews.llvm.org/D22712



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


[PATCH] D22712: Remove FileEntry copy-constructor

2016-10-20 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

i see, thanks. So do i understand correctly that we can proceed with this patch 
?


https://reviews.llvm.org/D22712



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


[libcxx] r284731 - Adding a missing constexpr test for reverse_iterator operator[].

2016-10-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Oct 20 09:57:34 2016
New Revision: 284731

URL: http://llvm.org/viewvc/llvm-project?rev=284731&view=rev
Log:
Adding a missing constexpr test for reverse_iterator operator[].

Modified:

libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp?rev=284731&r1=284730&r2=284731&view=diff
==
--- 
libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
 Thu Oct 20 09:57:34 2016
@@ -17,6 +17,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
 
 template 
@@ -35,4 +36,14 @@ int main()
 const char* s = "1234567890";
 test(random_access_iterator(s+5), 4, '1');
 test(s+5, 4, '1');
+
+#if TEST_STD_VER > 14
+{
+constexpr const char *p = "123456789";
+typedef std::reverse_iterator RI;
+constexpr RI it1 = std::make_reverse_iterator(p + 5);
+static_assert(it1[0] == '5', "");
+static_assert(it1[4] == '1', "");
+}
+#endif
 }


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


r284732 - [Format] Cleanup after replacing constructor body with = default

2016-10-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Oct 20 09:58:45 2016
New Revision: 284732

URL: http://llvm.org/viewvc/llvm-project?rev=284732&view=rev
Log:
[Format] Cleanup after replacing constructor body with = default

Summary:
Remove colon and commas after replacing constructor body with = default.
Fix annotation of TT_CtorInitializerColon when preceded by a comment.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=284732&r1=284731&r2=284732&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Oct 20 09:58:45 2016
@@ -1024,6 +1024,7 @@ public:
 cleanupLeft(Line->First, tok::comma, tok::r_paren);
 cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
 cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
   }
 }
 

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=284732&r1=284731&r2=284732&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Oct 20 09:58:45 2016
@@ -520,7 +520,8 @@ private:
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
+if (Tok->getPreviousNonComment()->isOneOf(tok::r_paren,
+  tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=284732&r1=284731&r2=284732&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Thu Oct 20 09:58:45 2016
@@ -151,6 +151,16 @@ TEST_F(CleanupTest, CtorInitializationSi
   EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) {
+  std::string Code = "class A {\nA() : =default; };";
+  std::string Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+
+  Code = "class A {\nA() : , =default; };";
+  Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+}
+
 TEST_F(CleanupTest, ListRedundantComma) {
   std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }";
   std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }";
@@ -239,6 +249,14 @@ TEST_F(CleanupTest, RemoveCommentsAround
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   EXPECT_EQ(Expected, cleanupAroundOffsets({17}, Code));
+
+  Code = "class A {\nA() // comment\n : ,,{} };";
+  Expected = "class A {\nA() // comment\n {} };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code));
+
+  Code = "class A {\nA() // comment\n : ,,=default; };";
+  Expected = "class A {\nA() // comment\n =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code));
 }
 
 TEST_F(CleanupTest, CtorInitializerInNamespace) {


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


[PATCH] D25768: [Format] Cleanup after replacing constructor body with = default

2016-10-20 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284732: [Format] Cleanup after replacing constructor body 
with = default (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25768?vs=75138&id=75299#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25768

Files:
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/CleanupTest.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -520,7 +520,8 @@
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
+if (Tok->getPreviousNonComment()->isOneOf(tok::r_paren,
+  tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1024,6 +1024,7 @@
 cleanupLeft(Line->First, tok::comma, tok::r_paren);
 cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
 cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
   }
 }
 
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -151,6 +151,16 @@
   EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) {
+  std::string Code = "class A {\nA() : =default; };";
+  std::string Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+
+  Code = "class A {\nA() : , =default; };";
+  Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+}
+
 TEST_F(CleanupTest, ListRedundantComma) {
   std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }";
   std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }";
@@ -239,6 +249,14 @@
   Code = "class A {\nA() : , // comment\n y(1),{} };";
   Expected = "class A {\nA() :  // comment\n y(1){} };";
   EXPECT_EQ(Expected, cleanupAroundOffsets({17}, Code));
+
+  Code = "class A {\nA() // comment\n : ,,{} };";
+  Expected = "class A {\nA() // comment\n {} };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code));
+
+  Code = "class A {\nA() // comment\n : ,,=default; };";
+  Expected = "class A {\nA() // comment\n =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code));
 }
 
 TEST_F(CleanupTest, CtorInitializerInNamespace) {


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -520,7 +520,8 @@
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
+if (Tok->getPreviousNonComment()->isOneOf(tok::r_paren,
+  tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -1024,6 +1024,7 @@
 cleanupLeft(Line->First, tok::comma, tok::r_paren);
 cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
 cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
+cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
   }
 }
 
Index: cfe/trunk/unittests/Format/CleanupTest.cpp
===
--- cfe/trunk/unittests/Format/CleanupTest.cpp
+++ cfe/trunk/unittests/Format/CleanupTest.cpp
@@ -151,6 +151,16 @@
   EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
 }
 
+TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) {
+  std::string Code = "class A {\nA() : =default; };";
+  std::string Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+
+  Code = "class A {\nA() : , =default; };";
+  Expected = "class A {\nA()  =default; };";
+  EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code));
+}
+
 TEST_F(CleanupT

Re: [PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-20 Thread Aaron Ballman via cfe-commits
On Thu, Oct 20, 2016 at 11:02 AM, David Blaikie  wrote:
> If we issue a fixit we should recover as-if the code was written with the
> fixit in. Does this code do that?

That's a good point; I don't think this patch does the fix.

> (can we test it? I know we test some
> fixits - not sure it's necessary/worthwhile to test them all, but maybe we
> have a good idiom for testing that the recovery is correct)

We have some fixit tests in the frontend. See test/FixIt/

~Aaron

>
> On Thu, Oct 20, 2016 at 6:47 AM Aaron Ballman 
> wrote:
>>
>> aaron.ballman accepted this revision.
>> aaron.ballman added a reviewer: aaron.ballman.
>> aaron.ballman added a comment.
>> This revision is now accepted and ready to land.
>>
>> LGTM
>>
>>
>>
>> 
>> Comment at: lib/Sema/SemaExprCXX.cpp:6287
>> +Context.hasSameUnqualifiedType(DestructedType,
>> +   ObjectType->getPointeeType()))
>> {
>> +  Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
>> 
>> You can elide the curly braces.
>>
>>
>> Repository:
>>   rL LLVM
>>
>> https://reviews.llvm.org/D25817
>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22712: Remove FileEntry copy-constructor

2016-10-20 Thread Benjamin Kramer via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

GCC 4.7 is dead. Go ahead if it compiles.


https://reviews.llvm.org/D22712



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


[PATCH] D25828: Implement part of P0031; adding `constexpr` to `move_iterator`

2016-10-20 Thread Marshall Clow via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: EricWF, lefticus, AntonBikineev.
mclow.lists added a subscriber: cfe-commits.

This just does the `move_iterator`  bits of http://wg21.link/P0031 - not any of 
the other parts.
This duplicates some (but not all) of the work that was done in 
https://reviews.llvm.org/D20915 and https://reviews.llvm.org/D22584.

Again, the whole reason for this is all the tests.


https://reviews.llvm.org/D25828

Files:
  include/iterator
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
  
test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp

Index: test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
===
--- test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
+++ test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
@@ -15,10 +15,13 @@
 //   requires HasAssign
 //   move_iterator&
 //   operator=(const move_iterator& u);
+//
+//  constexpr in C++17
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_iterators.h"
 
 template 
@@ -44,4 +47,14 @@
 test >(bidirectional_iterator(&d));
 test >(random_access_iterator(&d));
 test(&d);
+#if TEST_STD_VER > 14
+{
+using BaseIter= std::move_iterator;
+using DerivedIter = std::move_iterator;
+constexpr const Derived *p = nullptr;
+constexpr DerivedIter it1 = std::make_move_iterator(p);
+constexpr BaseIterit2 = (BaseIter{nullptr} = it1);
+static_assert(it2.base() == p, "");
+}
+#endif
 }
Index: test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
===
--- test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
+++ test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
@@ -12,6 +12,8 @@
 // move_iterator
 
 // reference operator*() const;
+//
+//  constexpr in C++17
 
 #include 
 #include 
@@ -19,6 +21,8 @@
 #include 
 #endif
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -58,4 +62,15 @@
 std::unique_ptr p(&i);
 test(&p, std::unique_ptr(&i));
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if TEST_STD_VER > 14
+{
+constexpr const char *p = "123456789";
+typedef std::move_iterator MI;
+constexpr MI it1 = std::make_move_iterator(p);
+constexpr MI it2 = std::make_move

[PATCH] D25828: Implement part of P0031; adding `constexpr` to `move_iterator`

2016-10-20 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.



Comment at: include/iterator:1559
 struct __libcpp_is_trivial_iterator
-   : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
-   
+: public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
+

These changes are just getting rid of tabs.


https://reviews.llvm.org/D25828



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


[clang-tools-extra] r284735 - [clang-tidy] Simplify modernize-use-default

2016-10-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Oct 20 10:31:34 2016
New Revision: 284735

URL: http://llvm.org/viewvc/llvm-project?rev=284735&view=rev
Log:
[clang-tidy] Simplify modernize-use-default

Summary:
clang-tidy now cleans up after replacements, so leave colon and comma
removal to that.

Reviewers: angelgarcia, alexfh, aaron.ballman, djasper, ioeric

Subscribers: djasper, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=284735&r1=284734&r2=284735&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Thu Oct 20 
10:31:34 2016
@@ -20,37 +20,6 @@ namespace modernize {
 
 static const char SpecialFunction[] = "SpecialFunction";
 
-/// \brief Finds the SourceLocation of the colon ':' before the initialization
-/// list in the definition of a constructor.
-static SourceLocation getColonLoc(const ASTContext *Context,
-  const CXXConstructorDecl *Ctor) {
-  // FIXME: First init is the first initialization that is going to be
-  // performed, no matter what was the real order in the source code. If the
-  // order of the inits is wrong in the code, it may result in a false 
negative.
-  SourceLocation FirstInit = (*Ctor->init_begin())->getSourceLocation();
-  SourceLocation LastArg =
-  Ctor->getParamDecl(Ctor->getNumParams() - 1)->getLocEnd();
-  // We need to find the colon between the ')' and the first initializer.
-  bool Invalid = false;
-  StringRef Text = Lexer::getSourceText(
-  CharSourceRange::getCharRange(LastArg, FirstInit),
-  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
-  if (Invalid)
-return SourceLocation();
-
-  size_t ColonPos = Text.rfind(':');
-  if (ColonPos == StringRef::npos)
-return SourceLocation();
-
-  Text = Text.drop_front(ColonPos + 1);
-  if (std::strspn(Text.data(), " \t\r\n") != Text.size()) {
-// If there are comments, preprocessor directives or anything, abort.
-return SourceLocation();
-  }
-  // FIXME: don't remove comments in the middle of the initializers.
-  return LastArg.getLocWithOffset(ColonPos);
-}
-
 /// \brief Finds all the named non-static fields of \p Record.
 static std::set
 getAllNamedFields(const CXXRecordDecl *Record) {
@@ -262,7 +231,6 @@ void UseDefaultCheck::registerMatchers(M
 
 void UseDefaultCheck::check(const MatchFinder::MatchResult &Result) {
   std::string SpecialFunctionName;
-  SourceLocation StartLoc, EndLoc;
 
   // Both CXXConstructorDecl and CXXDestructorDecl inherit from CXXMethodDecl.
   const auto *SpecialFunctionDecl =
@@ -280,15 +248,13 @@ void UseDefaultCheck::check(const MatchF
   if (!Body)
 return;
 
-  // Default locations.
-  StartLoc = Body->getLBracLoc();
-  EndLoc = Body->getRBracLoc();
-
   // If there are comments inside the body, don't do the change.
   if (!SpecialFunctionDecl->isCopyAssignmentOperator() &&
   !bodyEmpty(Result.Context, Body))
 return;
 
+  std::vector RemoveInitializers;
+
   if (const auto *Ctor = dyn_cast(SpecialFunctionDecl)) {
 if (Ctor->getNumParams() == 0) {
   SpecialFunctionName = "default constructor";
@@ -297,10 +263,9 @@ void UseDefaultCheck::check(const MatchF
 return;
   SpecialFunctionName = "copy constructor";
   // If there are constructor initializers, they must be removed.
-  if (Ctor->getNumCtorInitializers() != 0) {
-StartLoc = getColonLoc(Result.Context, Ctor);
-if (!StartLoc.isValid())
-  return;
+  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+RemoveInitializers.emplace_back(
+FixItHint::CreateRemoval(Init->getSourceRange()));
   }
 }
   } else if (isa(SpecialFunctionDecl)) {
@@ -313,8 +278,8 @@ void UseDefaultCheck::check(const MatchF
 
   diag(SpecialFunctionDecl->getLocStart(),
"use '= default' to define a trivial " + SpecialFunctionName)
-  << FixItHint::CreateReplacement(
-  CharSourceRange::getTokenRange(StartLoc, EndLoc), "= default;");
+  << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
+  << RemoveInitializers;
 }
 
 } // namespace modernize

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp?rev=284735&r1=284734&r2=284735&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-cop

[PATCH] D25769: [clang-tidy] Simplify modernize-use-default

2016-10-20 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284735: [clang-tidy] Simplify modernize-use-default 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25769?vs=75140&id=75307#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25769

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -20,37 +20,6 @@
 
 static const char SpecialFunction[] = "SpecialFunction";
 
-/// \brief Finds the SourceLocation of the colon ':' before the initialization
-/// list in the definition of a constructor.
-static SourceLocation getColonLoc(const ASTContext *Context,
-  const CXXConstructorDecl *Ctor) {
-  // FIXME: First init is the first initialization that is going to be
-  // performed, no matter what was the real order in the source code. If the
-  // order of the inits is wrong in the code, it may result in a false negative.
-  SourceLocation FirstInit = (*Ctor->init_begin())->getSourceLocation();
-  SourceLocation LastArg =
-  Ctor->getParamDecl(Ctor->getNumParams() - 1)->getLocEnd();
-  // We need to find the colon between the ')' and the first initializer.
-  bool Invalid = false;
-  StringRef Text = Lexer::getSourceText(
-  CharSourceRange::getCharRange(LastArg, FirstInit),
-  Context->getSourceManager(), Context->getLangOpts(), &Invalid);
-  if (Invalid)
-return SourceLocation();
-
-  size_t ColonPos = Text.rfind(':');
-  if (ColonPos == StringRef::npos)
-return SourceLocation();
-
-  Text = Text.drop_front(ColonPos + 1);
-  if (std::strspn(Text.data(), " \t\r\n") != Text.size()) {
-// If there are comments, preprocessor directives or anything, abort.
-return SourceLocation();
-  }
-  // FIXME: don't remove comments in the middle of the initializers.
-  return LastArg.getLocWithOffset(ColonPos);
-}
-
 /// \brief Finds all the named non-static fields of \p Record.
 static std::set
 getAllNamedFields(const CXXRecordDecl *Record) {
@@ -262,7 +231,6 @@
 
 void UseDefaultCheck::check(const MatchFinder::MatchResult &Result) {
   std::string SpecialFunctionName;
-  SourceLocation StartLoc, EndLoc;
 
   // Both CXXConstructorDecl and CXXDestructorDecl inherit from CXXMethodDecl.
   const auto *SpecialFunctionDecl =
@@ -280,27 +248,24 @@
   if (!Body)
 return;
 
-  // Default locations.
-  StartLoc = Body->getLBracLoc();
-  EndLoc = Body->getRBracLoc();
-
   // If there are comments inside the body, don't do the change.
   if (!SpecialFunctionDecl->isCopyAssignmentOperator() &&
   !bodyEmpty(Result.Context, Body))
 return;
 
+  std::vector RemoveInitializers;
+
   if (const auto *Ctor = dyn_cast(SpecialFunctionDecl)) {
 if (Ctor->getNumParams() == 0) {
   SpecialFunctionName = "default constructor";
 } else {
   if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor))
 return;
   SpecialFunctionName = "copy constructor";
   // If there are constructor initializers, they must be removed.
-  if (Ctor->getNumCtorInitializers() != 0) {
-StartLoc = getColonLoc(Result.Context, Ctor);
-if (!StartLoc.isValid())
-  return;
+  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+RemoveInitializers.emplace_back(
+FixItHint::CreateRemoval(Init->getSourceRange()));
   }
 }
   } else if (isa(SpecialFunctionDecl)) {
@@ -313,8 +278,8 @@
 
   diag(SpecialFunctionDecl->getLocStart(),
"use '= default' to define a trivial " + SpecialFunctionName)
-  << FixItHint::CreateReplacement(
-  CharSourceRange::getTokenRange(StartLoc, EndLoc), "= default;");
+  << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
+  << RemoveInitializers;
 }
 
 } // namespace modernize
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
@@ -8,7 +8,7 @@
 };
 OL::OL(const OL &Other) : Field(Other.Field) {}
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
-// CHECK-FIXES: OL::OL(const OL &Other) = default;
+// CHECK-FIXES: OL::OL(const OL &Other)  = default;
 OL &OL::operator=(const OL &Other) {
   Field = Other.Field;
   return *this;
@@ -20,7 +20,7 @@
 struct IL {
   IL(const IL &Other) : Field(Other.Field) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
-  // CHECK-FIXES: IL(cons

Re: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-20 Thread Ettore Speziale via cfe-commits
Hello guys,

>> Should we deprecate noduplicate then as convergent should cover both use 
>> cases for OpenCL I believe? As far as I understand noduplicate was added 
>> specifically for SPMD use cases...
> 
> noduplicate has different semantics than convergent. Although it is proposed 
> for SPMD originally, it could be used by non-SPMD programs to forbid 
> duplicate of functions. There may be applications using this attribute.
> 
> I would suggest to leave this question for future. Probably ask llvm-dev 
> first since the attribute is also in LLVM.

I just want to clarify why I withdraw the convergent patch I initially 
submitted some time ago. It has a problem when dealing with multiple modules. 
Consider the following example:

int foo(void) __attribute__((pure));

int bar(int x) {
  int y = foo();
  if (x)
return y;
  return 0;
}   

I’ve just marked foo with the pure attribute to mark the function readonly in 
LLVM IR. Given that IR, the IR sinking pass pushes the foo call site into the 
then branch:

; Function Attrs: nounwind readonly ssp uwtable
define i32 @bar(i32) #0 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %5, label %3

; :3   ; preds = %1
  %4 = tail call i32 @foo() #2
  br label %5

; :5   ; preds = %1, %3
  %6 = phi i32 [ %4, %3 ], [ 0, %1 ]
  ret i32 %6
}

; Function Attrs: nounwind readonly
declare i32 @foo() #1

This is kind of dangerous, as we do not know what is inside foo — i.e. it might 
contains a convergent call.

If I understand correctly, the CUDA guys solved the problem in two steps. At 
CodeGen time all the device function calls are marked convergent:

  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
// Conservatively, mark all functions and calls in CUDA as convergent
// (meaning, they may call an intrinsically convergent op, such as
// __syncthreads(), and so can't have certain optimizations applied around
// them).  LLVM will remove this attribute where it safely can.
FuncAttrs.addAttribute(llvm::Attribute::Convergent);

Then LLVM function attribute pass — lib/Transforms/IPO/FunctionAttrs.cpp — 
remove the unnecessary convergent attributes starting from the leaf nodes  — 
i.e. external calls.

Provide that intrinsics are correctly marked convergent only when needed, that 
allow to get rid of the unnecessary convergent attributes.

Since you are introducing an explicit convergent attribute it seems that OpenCL 
is requiring the developers to explicitly mark the functions that might contain 
convergent function calls with the convergent attribute. Am I understand 
correctly?

Thanks

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


[clang-tools-extra] r284737 - Use auto in for loop

2016-10-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Oct 20 10:40:34 2016
New Revision: 284737

URL: http://llvm.org/viewvc/llvm-project?rev=284737&view=rev
Log:
Use auto in for loop

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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=284737&r1=284736&r2=284737&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Thu Oct 20 
10:40:34 2016
@@ -263,7 +263,7 @@ void UseDefaultCheck::check(const MatchF
 return;
   SpecialFunctionName = "copy constructor";
   // If there are constructor initializers, they must be removed.
-  for (const CXXCtorInitializer *Init : Ctor->inits()) {
+  for (const auto *Init : Ctor->inits()) {
 RemoveInitializers.emplace_back(
 FixItHint::CreateRemoval(Init->getSourceRange()));
   }


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


[clang-tools-extra] r284742 - [clang-tidy] Add check 'readability-redundant-member-init'

2016-10-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Oct 20 11:08:03 2016
New Revision: 284742

URL: http://llvm.org/viewvc/llvm-project?rev=284742&view=rev
Log:
[clang-tidy] Add check 'readability-redundant-member-init'

Summary: The check emits a warning if a member-initializer calls the member's 
default constructor with no arguments.

Reviewers: sbenza, alexfh, aaron.ballman

Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, 
cfe-commits, beanz

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

Added:
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.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/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=284742&r1=284741&r2=284742&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Thu Oct 20 
11:08:03 2016
@@ -16,6 +16,7 @@ add_clang_library(clangTidyReadabilityMo
   NonConstParameterCheck.cpp
   ReadabilityTidyModule.cpp
   RedundantControlFlowCheck.cpp
+  RedundantMemberInitCheck.cpp
   RedundantStringCStrCheck.cpp
   RedundantSmartptrGetCheck.cpp
   RedundantStringInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=284742&r1=284741&r2=284742&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Thu Oct 20 11:08:03 2016
@@ -23,6 +23,7 @@
 #include "NamedParameterCheck.h"
 #include "NonConstParameterCheck.h"
 #include "RedundantControlFlowCheck.h"
+#include "RedundantMemberInitCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
 #include "RedundantStringInitCheck.h"
@@ -57,6 +58,8 @@ public:
 "readability-inconsistent-declaration-parameter-name");
 CheckFactories.registerCheck(
 "readability-misplaced-array-index");
+CheckFactories.registerCheck(
+"readability-redundant-member-init");
 CheckFactories.registerCheck(
 "readability-static-definition-in-anonymous-namespace");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp?rev=284742&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
Thu Oct 20 11:08:03 2016
@@ -0,0 +1,65 @@
+//===--- RedundantMemberInitCheck.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 "RedundantMemberInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "../utils/Matchers.h"
+#include 
+
+using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) {
+  auto Construct =
+  cxxConstructExpr(
+  hasDeclaration(cxxConstructorDecl(hasParent(
+  cxxRecordDecl(unless(isTriviallyDefaultConstructible()))
+  .bind("construct");
+
+  Finder->addMatcher(
+  cxxConstructorDecl(
+  unless(isDelegatingConstructor()),
+  ofClass(unless(
+  anyOf(isUnion(), ast_matchers::isTemplateInstantiation(,
+  forEachConstructorInitializer(
+  cxxCtorInitializer(isWritten(),
+ withInitializer(ignoringImplicit(Construct)),
+ unless(forField(hasType(isConstQualified()
+ 

[PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-10-20 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284742: [clang-tidy] Add check 
'readability-redundant-member-init' (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D24339?vs=74769&id=75311#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24339

Files:
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.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/readability-redundant-member-init.rst
  clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp
@@ -0,0 +1,181 @@
+// RUN: %check_clang_tidy %s readability-redundant-member-init %t
+
+struct S {
+  S() = default;
+  S(int i) : i(i) {}
+  int i = 1;
+};
+
+struct T {
+  T(int i = 1) : i(i) {}
+  int i;
+};
+
+struct U {
+  int i;
+};
+
+union V {
+  int i;
+  double f;
+};
+
+// Initializer calls default constructor
+struct F1 {
+  F1() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F1()  {}
+  S f;
+};
+
+// Initializer calls default constructor with default argument
+struct F2 {
+  F2() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F2()  {}
+  T f;
+};
+
+// Multiple redundant initializers for same constructor
+struct F3 {
+  F3() : f(), g(1), h() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: initializer for member 'h' is redundant
+  // CHECK-FIXES: F3() :  g(1) {}
+  S f, g, h;
+};
+
+// Templated class independent type
+template 
+struct F4 {
+  F4() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F4()  {}
+  S f;
+};
+F4 f4i;
+F4 f4s;
+
+// Base class
+struct F5 : S {
+  F5() : S() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'S' is redundant
+  // CHECK-FIXES: F5()  {}
+};
+
+// Constructor call requires cleanup
+struct Cleanup {
+  ~Cleanup() {}
+};
+
+struct UsesCleanup {
+  UsesCleanup(const Cleanup &c = Cleanup()) {}
+};
+
+struct F6 {
+  F6() : uc() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'uc' is redundant
+  // CHECK-FIXES: F6()  {}
+  UsesCleanup uc;
+};
+
+// Multiple inheritance
+struct F7 : S, T {
+  F7() : S(), T() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'S' is redundant
+  // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: initializer for base class 'T' is redundant
+  // CHECK-FIXES: F7()  {}
+};
+
+// Initializer not written
+struct NF1 {
+  NF1() {}
+  S f;
+};
+
+// Initializer doesn't call default constructor
+struct NF2 {
+  NF2() : f(1) {}
+  S f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF3 {
+  NF3() : f(1) {}
+  T f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF4 {
+  NF4() : f(2) {}
+  T f;
+};
+
+// Initializer is zero-initialization
+struct NF5 {
+  NF5() : i() {}
+  int i;
+};
+
+// Initializer is direct-initialization
+struct NF6 {
+  NF6() : i(1) {}
+  int i;
+};
+
+// Initializer is aggregate initialization of struct
+struct NF7 {
+  NF7() : f{} {}
+  U f;
+};
+
+// Initializer is zero-initialization of struct
+struct NF7b {
+  NF7b() : f() {}
+  U f;
+};
+
+// Initializer is aggregate initialization of array
+struct NF8 {
+  NF8() : f{} {}
+  int f[2];
+};
+
+struct NF9 {
+  NF9() : f{} {}
+  S f[2];
+};
+
+// Initializing member of union
+union NF10 {
+  NF10() : s() {}
+  int i;
+  S s;
+};
+
+// Templated class dependent type
+template 
+struct NF11 {
+  NF11() : f() {}
+  V f;
+};
+NF11 nf11i;
+NF11 nf11s;
+
+// Delegating constructor
+class NF12 {
+  NF12() = default;
+  NF12(int) : NF12() {}
+};
+
+// Const member
+struct NF13 {
+  NF13() : f() {}
+  const S f;
+};
+
+// Union member
+struct NF14 {
+  NF14() : f() {}
+  V f;
+};
Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.h
@@ -0,0 +1,36 @@
+//===--- RedundantMemberInitCheck.h

[PATCH] D20811: [analyzer] Model some library functions

2016-10-20 Thread Artem Dergachev via cfe-commits
NoQ marked 9 inline comments as done.
NoQ added a comment.

I thought to give it a pause to take a fresh look at how to arrange the 
macro-hints in the summaries.

Maybe something like that:

  CASE
ARGUMENT_CONDITION(ARG_NO(0), OutOfRange)
  RANGE('0', '9')
  RANGE('A', 'Z')
  RANGE('a', 'z')
  RANGE(128, 255)
END_ARGUMENT_CONDITION
RETURN_VALUE_CONDITION(WithinRange)
  SINGLE_VALUE(0)
END_RETURN_VALUE_CONDITION
  END_CASE




Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:547
+RANGE {
+  RET_VAL, RANGE_KIND(OutOfRange),
+  SET { POINT(0) }

dcoughlin wrote:
> NoQ wrote:
> > dcoughlin wrote:
> > > Is it ever the case that this final 'RANGE" constrains anything other 
> > > than the return value? If not, can 'RET_VAL' be elided?
> > Some summaries only have pre-conditions: "for this argument constraint, any 
> > return value is possible". We should also be able to support void 
> > functions, which have no return values.
> What does a postcondition on a void function mean in this context? Can you 
> refer to argument values? Such as "If the the function terminates then it 
> must have been the case that the first argument was in the rangy x..z even 
> though we didn't know that going in? Is this useful?
No, i don't think this is useful. There are just timeless immutable symbols 
about which we learn something new on every branch.

If the function doesn't terminate on certain pre-conditons, then we can model 
it by never mentioning these pre-conditions in any of the branches (we don't 
use this trick anywhere yet - all functions listed here shall terminate in all 
cases).

This would have been useful if we start referring to the heap shape (eg. "if 
the value behind the pointer passed as second argument to the call was in range 
[1,10] before the call, then it would be equal to 42 after the call"), but we 
don't do that yet.


https://reviews.llvm.org/D20811



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


RE: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-20 Thread Liu, Yaxun (Sam) via cfe-commits
+ Tom Matt

Thanks Ettore.
 
I think OpenCL is subject to the same issue, and noduplicate does not help 
either.

Basically if a function A directly or indirectly calls a convergent function 
e.g. barrier, function A itself must also be marked as convergent, otherwise 
optimization passes may transform a convergent call of A into multiple 
divergent calls of A.

That means if we only know the declaration of a function, we have to assume it 
is convergent since in its body it may call a convergent function.

I think probably OpenCL should take the same approach, i.e., mark all functions 
as convergent, then let Transforms/IPO/FunctionAttrs.cpp to remove unnecessary 
convergent attribute.

Sam

-Original Message-
From: Ettore Speziale [mailto:speziale.ett...@gmail.com] 
Sent: Thursday, October 20, 2016 11:42 AM
To: reviews+d25343+public+a10e9553b0fc8...@reviews.llvm.org; Liu, Yaxun (Sam) 

Cc: Ettore Speziale ; alexey.ba...@intel.com; 
anastasia.stul...@arm.com; aaron.ball...@gmail.com; Clang Commits 
; Sumner, Brian 
Subject: Re: [PATCH] D25343: [OpenCL] Mark group functions as convergent in 
opencl-c.h

Hello guys,

>> Should we deprecate noduplicate then as convergent should cover both use 
>> cases for OpenCL I believe? As far as I understand noduplicate was added 
>> specifically for SPMD use cases...
> 
> noduplicate has different semantics than convergent. Although it is proposed 
> for SPMD originally, it could be used by non-SPMD programs to forbid 
> duplicate of functions. There may be applications using this attribute.
> 
> I would suggest to leave this question for future. Probably ask llvm-dev 
> first since the attribute is also in LLVM.

I just want to clarify why I withdraw the convergent patch I initially 
submitted some time ago. It has a problem when dealing with multiple modules. 
Consider the following example:

int foo(void) __attribute__((pure));

int bar(int x) {
  int y = foo();
  if (x)
return y;
  return 0;
}   

I’ve just marked foo with the pure attribute to mark the function readonly in 
LLVM IR. Given that IR, the IR sinking pass pushes the foo call site into the 
then branch:

; Function Attrs: nounwind readonly ssp uwtable define i32 @bar(i32) #0 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %5, label %3

; :3   ; preds = %1
  %4 = tail call i32 @foo() #2
  br label %5

; :5   ; preds = %1, %3
  %6 = phi i32 [ %4, %3 ], [ 0, %1 ]
  ret i32 %6
}

; Function Attrs: nounwind readonly
declare i32 @foo() #1

This is kind of dangerous, as we do not know what is inside foo — i.e. it might 
contains a convergent call.

If I understand correctly, the CUDA guys solved the problem in two steps. At 
CodeGen time all the device function calls are marked convergent:

  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
// Conservatively, mark all functions and calls in CUDA as convergent
// (meaning, they may call an intrinsically convergent op, such as
// __syncthreads(), and so can't have certain optimizations applied around
// them).  LLVM will remove this attribute where it safely can.
FuncAttrs.addAttribute(llvm::Attribute::Convergent);

Then LLVM function attribute pass — lib/Transforms/IPO/FunctionAttrs.cpp — 
remove the unnecessary convergent attributes starting from the leaf nodes  — 
i.e. external calls.

Provide that intrinsics are correctly marked convergent only when needed, that 
allow to get rid of the unnecessary convergent attributes.

Since you are introducing an explicit convergent attribute it seems that OpenCL 
is requiring the developers to explicitly mark the functions that might contain 
convergent function calls with the convergent attribute. Am I understand 
correctly?

Thanks

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


[PATCH] D25777: [Sema][TreeTransform] Re-create DesignatedInitExpr when it has a field designator with a valid FieldDecl

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

The fact that this bug only arises when performing a *second* instantiation 
suggests that there's a deeper bug here, because template instantiation is not 
supposed to modify the pattern AST.  In this case, the basic problem is that, 
when the parser processes a designator, it only has an identifier, not a 
FieldDecl*, because it doesn't know what type is being initialized yet.  
SemaInit eventually resolves that identifier to a FieldDecl and needs to record 
that in the AST; typically the AST is treated as immutable, but in this case, 
instead of cloning the expression, Sema just modifies the field designator 
in-place.  That's not completely unreasonable, and it's definitely the most 
space-efficient solution for non-template code-building; but in template code, 
it does mean that we have to take care to not present the same unresolved field 
designator to Sema twice.

Fortunately, this is pretty easy: we just need to need to flag the expression 
as needing rebuilding when there isn't a resolved field in the field 
designator.  When there *is* a resolved field, we just need to map it using 
TransformDecl; the expression then only needs to be rebuilt if that fails or 
returns a different declaration.


Repository:
  rL LLVM

https://reviews.llvm.org/D25777



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


r284749 - [clang-cl] Fix test that shouldn't be running on non-x86

2016-10-20 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Thu Oct 20 12:41:08 2016
New Revision: 284749

URL: http://llvm.org/viewvc/llvm-project?rev=284749&view=rev
Log:
[clang-cl] Fix test that shouldn't be running on non-x86

The clang-cl test required x86-registered-target but it defaulted to the
host's triple and AArch64 still doesn't support COFF, so the test failed.

The triple was "aarch64-pc-windows-msvc18.0.0" with ObjectFormat equals
llvm::Triple::COFF, failing assertion:

Assertion `(TT.isOSBinFormatELF() || TT.isOSBinFormatMachO()) &&
  "Only expect Darwin and ELF targets"

in AArch64MCTargetDesc.cpp:78.

Making the test only run on Windows hosts obviously fixes the problem.

Modified:
cfe/trunk/test/Driver/cl-pch.c

Modified: cfe/trunk/test/Driver/cl-pch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch.c?rev=284749&r1=284748&r2=284749&view=diff
==
--- cfe/trunk/test/Driver/cl-pch.c (original)
+++ cfe/trunk/test/Driver/cl-pch.c Thu Oct 20 12:41:08 2016
@@ -1,4 +1,4 @@
-// REQUIRES: x86-registered-target
+// REQUIRES: system-windows
 //
 // RUN: rm -rf %t
 // RUN: mkdir %t


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


[PATCH] D20811: [analyzer] Model some library functions

2016-10-20 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D20811#575521, @NoQ wrote:

> I thought to give it a pause to take a fresh look at how to arrange the 
> macro-hints in the summaries.
>
> Maybe something like that:
>
>   CASE
> ARGUMENT_CONDITION(ARG_NO(0), OutOfRange)
>   RANGE('0', '9')
>   RANGE('A', 'Z')
>   RANGE('a', 'z')
>   RANGE(128, 255)
> END_ARGUMENT_CONDITION
> RETURN_VALUE_CONDITION(WithinRange)
>   SINGLE_VALUE(0)
> END_RETURN_VALUE_CONDITION
>   END_CASE
>   


Looks great to me!


https://reviews.llvm.org/D20811



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


[PATCH] D25063: [x86][inline-asm][AVX512][clang][PART-1] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.

2016-10-20 Thread Reid Kleckner via cfe-commits
rnk added inline comments.



Comment at: test/CodeGen/avx512-kconstraints-att_inline_asm.c:6
+void mask_Yk_i8(char msk){ 
+//CHECK: #APP 
+//CHECK: vpaddb %xmm1, %xmm0, %xmm1 {%k1}

The LLVM IR won't have #APP markers in it. Does this test really pass?


https://reviews.llvm.org/D25063



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


[PATCH] D24888: [clang-tidy] Use [[clang::suppress]] with cppcoreguidelines-pro-type-reinterpret-cast

2016-10-20 Thread Matthias Gehre via cfe-commits
mgehre added inline comments.



Comment at: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp:25
 
-  Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
+  std::vector Rules{"type", "type.1", 
"cppcoreguidelines-pro-type-reinterpret-cast"};
+  
Finder->addMatcher(cxxReinterpretCastExpr(unless(isSuppressed(Rules))).bind("cast"),
 this);

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > mgehre wrote:
> > > > aaron.ballman wrote:
> > > > > Hmm, it seems like this is boilerplate we are going to want for every 
> > > > > rule, and that it's pretty easy to not get this right (for instance, 
> > > > > if you change the way the check is spelled, you have to remember to 
> > > > > update this as well). Could this actually be handled more 
> > > > > transparently, by gathering this information when the check is 
> > > > > registered and exposing it to the check?
> > > > > 
> > > > > The checks would still need to use `unless(isSuppressed(Rules))` in 
> > > > > some form, but I am thinking that it would be more convenient if we 
> > > > > could do: 
> > > > > `Finder->addMatcher(cxxReinterpretCastExpr(unlessSuppressed(*this)).bind("cast"),
> > > > >  this);`
> > > > I see multiple ways on how to integrate that into clang-tidy:
> > > > 1) Add something like you proposed to each matcher of each check
> > > > 2) Change (or add overload of)
> > > > ```
> > > >  DiagnosticBuilder diag(SourceLocation Loc, StringRef Description,
> > > >  DiagnosticIDs::Level Level = 
> > > > DiagnosticIDs::Warning);
> > > > ```
> > > > to add a AST node as parameter and make the SourceLocation optional. 
> > > > Most checks anyhow
> > > > call this like diag(E->getLoc(), ""), and then they would do 
> > > > diag(E, "...").
> > > > Diag then would check from the that AST node upwards to see if it finds 
> > > > a matching [[suppress]] attribute
> > > > 
> > > > 3) Change the RecursiveASTVistor that drives the AST Matches to prune 
> > > > certain matchers from the list of to-be-evaluated matchers
> > > > for all AST subtrees that are below a certain [[suppress]] attribute. 
> > > > (This is based on how I image that the AST matchers work)
> > > Ideally, I would like to see this attribute used to suppress Clang 
> > > diagnostics as well, however. So while I think Option 2 is better suited 
> > > to that future direction, it's still not ideal because all instances of 
> > > diag() need to be updated to take advantage. Options 1 and 3 are 
> > > basically limited to clang-tidy use.
> > > 
> > > I wonder if there's a way to modify the diagnostic builder to 
> > > transparently handle this without requiring modifying all of the call 
> > > sites?
> > clang-tidy reports how many warnings were suppressed by NOLINT comments.
> > I'd expect the number of warnings suppressed by [[clang::suppress]] to be 
> > included in the count.
> > Handling suppressions in the matchers or visitors would prevent this.
> As would handling the suppression transparently within the diagnostic engine 
> itself.
If there is a way to turn a SourceLocation into a ASTNode, diag() could handle 
this transparently (do you know how?). I would still add an overload of diag  
that takes an AST node as a performance optimization, because I imagine that 
going from SourceLocation to ASTNode would be a costly operation.
I can prototype that approach, if you like.



Comment at: clang-tidy/cppcoreguidelines/Suppression.h:59
+ anyOf(hasAncestor(attributedStmt(hasSuppressAttr(Rules))),
+   hasAncestor(decl(hasAttrs(), hasSuppressAttr(Rules)
+  .matches(Node, Finder, Builder);

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > Why is the check for `hasAttrs` required?
> > > 
> > > Also, this use of `hasAncestor()` makes this expensive to use, and that 
> > > expense may be hidden from the caller. Is there a way to structure this 
> > > so that we don't need to walk the entire ancestor tree?
> > hasAttr() is needed here, because inside of hasSuppressAttr(), we call 
> > getAttrs() which would assert if hasAttr() is false.
> > I cannot push hasAttr() into hasSuppressAttr(), because hasSuppressAttr() 
> > is a template getting either Decl or AttributedStmt,
> > and AttributedStmt does not have an hasAttr() method.
> I believe that `getSpecificAttr` should be resilient to no attributes being 
> present (since it also has to handle the case there are no attributes of the 
> specific type, so no attributes at all is simply a degenerate case), and so 
> the check for `hasAttrs()` should be redundant.
Decl::getAttrs() will assert if called on a Decl where hasAttrs() is false, see
http://clang.llvm.org/doxygen/DeclBase_8cpp_source.html#l00741


https://reviews.llvm.org/D24888



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org

[PATCH] D22374: [analyzer] Copy and move constructors - ExprEngine extended for "almost trivial" copy and move constructors

2016-10-20 Thread Artem Dergachev via cfe-commits
NoQ added a reviewer: zaks.anna.
NoQ added a comment.

Ping!~ Did my idea sound completely wrong to you? :)

Does https://reviews.llvm.org/D25660 depend on this patch? And/or did you find 
another workaround?


https://reviews.llvm.org/D22374



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


[PATCH] D25012: [x86][inline-asm] Add support for curly brackets escape using "%" in extended inline asm.

2016-10-20 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D25012



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


r284753 - [c++1z] Teach composite pointer type computation how to compute the composite

2016-10-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 20 12:57:33 2016
New Revision: 284753

URL: http://llvm.org/viewvc/llvm-project?rev=284753&view=rev
Log:
[c++1z] Teach composite pointer type computation how to compute the composite
pointer type of two function pointers with different noexcept specifications.
While I'm here, also teach it how to merge dynamic exception specifications.

Added:
cfe/trunk/test/CXX/expr/p13.cpp
Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=284753&r1=284752&r2=284753&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Oct 20 12:57:33 2016
@@ -145,7 +145,8 @@ namespace clang {
 /// pointer-to-member conversion, or boolean conversion.
 ImplicitConversionKind Second : 8;
 
-/// Third - The third conversion can be a qualification conversion.
+/// Third - The third conversion can be a qualification conversion
+/// or a function conversion.
 ImplicitConversionKind Third : 8;
 
 /// \brief Whether this is the deprecated conversion of a

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284753&r1=284752&r2=284753&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 20 12:57:33 2016
@@ -8954,13 +8954,15 @@ public:
 ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
   QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
-bool *NonStandardCompositeType = nullptr);
+bool *NonStandardCompositeType = nullptr,
+bool ConvertArgs = true);
   QualType FindCompositePointerType(SourceLocation Loc,
 ExprResult &E1, ExprResult &E2,
-bool *NonStandardCompositeType = nullptr) {
+bool *NonStandardCompositeType = nullptr,
+bool ConvertArgs = true) {
 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
-QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp,
-  NonStandardCompositeType);
+QualType Composite = FindCompositePointerType(
+Loc, E1Tmp, E2Tmp, NonStandardCompositeType, ConvertArgs);
 E1 = E1Tmp;
 E2 = E2Tmp;
 return Composite;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=284753&r1=284752&r2=284753&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 20 12:57:33 2016
@@ -3610,16 +3610,6 @@ Sema::PerformImplicitConversion(Expr *Fr
 // Nothing else to do.
 break;
 
-  case ICK_Function_Conversion:
-// If both sides are functions (or pointers/references to them), there 
could
-// be incompatible exception declarations.
-if (CheckExceptionSpecCompatibility(From, ToType))
-  return ExprError();
-
-From = ImpCastExprToType(From, ToType, CK_NoOp,
- VK_RValue, /*BasePath=*/nullptr, CCK).get();
-break;
-
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion:
 if (ToType->isBooleanType()) {
@@ -3866,6 +3856,7 @@ Sema::PerformImplicitConversion(Expr *Fr
   case ICK_Lvalue_To_Rvalue:
   case ICK_Array_To_Pointer:
   case ICK_Function_To_Pointer:
+  case ICK_Function_Conversion:
   case ICK_Qualification:
   case ICK_Num_Conversion_Kinds:
   case ICK_C_Only_Conversion:
@@ -3878,6 +3869,16 @@ Sema::PerformImplicitConversion(Expr *Fr
 // Nothing to do.
 break;
 
+  case ICK_Function_Conversion:
+// If both sides are functions (or pointers/references to them), there 
could
+// be incompatible exception declarations.
+if (CheckExceptionSpecCompatibility(From, ToType))
+  return ExprError();
+
+From = ImpCastExprToType(From, ToType, CK_NoOp,
+ VK_RValue, /*BasePath=*/nullptr, CCK).get();
+break;
+
   case ICK_Qualification: {
 // The qualification keeps the category of the inner expression, unless the
 // target type isn't a reference.
@@ -5393,6 +5394,17 @@ QualType Sema::CXXCheckConditionalOperan
 if (LHS.get()->getObjectKind() == OK_BitField ||
 RHS.get()->getObjectKind() == OK_BitField)
   OK = OK_Bit

r284754 - Add more doxygen comments to emmintrin.h's intrinsics.

2016-10-20 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Oct 20 12:59:15 2016
New Revision: 284754

URL: http://llvm.org/viewvc/llvm-project?rev=284754&view=rev
Log:
Add more doxygen comments to emmintrin.h's intrinsics.

With this patch, 75% of the intrinsics in this file will be documented now. The 
patches for the rest of the intrisics in this file will be send out later.

The doxygen comments are automatically generated based on Sony's intrinsics 
document.

I got an OK from Eric Christopher to commit doxygen comments without prior code 
review upstream. This patch was internally reviewed by Yunzhong Gao.


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

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=284754&r1=284753&r2=284754&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Thu Oct 20 12:59:15 2016
@@ -49,6 +49,21 @@ typedef signed char __v16qs __attribute_
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("sse2")))
 
+/// \brief Adds lower double-precision values in both operands and returns the
+///sum in the lower 64 bits of the result. The upper 64 bits of the result
+///are copied from the upper double-precision value of the first operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VADDSD / ADDSD instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \param __b
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
+///sum of the lower 64 bits of both operands. The upper 64 bits are copied
+///from the upper 64 bits of the first source operand.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_add_sd(__m128d __a, __m128d __b)
 {
@@ -56,12 +71,41 @@ _mm_add_sd(__m128d __a, __m128d __b)
   return __a;
 }
 
+/// \brief Adds two 128-bit vectors of [2 x double].
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VADDPD / ADDPD instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \param __b
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \returns A 128-bit vector of [2 x double] containing the sums of both
+///operands.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_add_pd(__m128d __a, __m128d __b)
 {
   return (__m128d)((__v2df)__a + (__v2df)__b);
 }
 
+/// \brief Subtracts the lower double-precision value of the second operand
+///from the lower double-precision value of the first operand and returns
+///the difference in the lower 64 bits of the result. The upper 64 bits of
+///the result are copied from the upper double-precision value of the first
+///operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VSUBSD / SUBSD instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double] containing the minuend.
+/// \param __b
+///A 128-bit vector of [2 x double] containing the subtrahend.
+/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
+///difference of the lower 64 bits of both operands. The upper 64 bits are
+///copied from the upper 64 bits of the first source operand.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_sub_sd(__m128d __a, __m128d __b)
 {
@@ -69,12 +113,40 @@ _mm_sub_sd(__m128d __a, __m128d __b)
   return __a;
 }
 
+/// \brief Subtracts two 128-bit vectors of [2 x double].
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VSUBPD / SUBPD instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double] containing the minuend.
+/// \param __b
+///A 128-bit vector of [2 x double] containing the subtrahend.
+/// \returns A 128-bit vector of [2 x double] containing the differences 
between
+///both operands.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_sub_pd(__m128d __a, __m128d __b)
 {
   return (__m128d)((__v2df)__a - (__v2df)__b);
 }
 
+/// \brief Multiplies lower double-precision values in both operands and 
returns
+///the product in the lower 64 bits of the result. The upper 64 bits of the
+///result are copied from the upper double-precision value of the first
+///operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VMULSD / MULSD instruction.
+///
+/// \param __a
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \param __b
+///A 128-bit vector of [2 x double] containing one of the source operands.
+/// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
+///product of the lower 64 bits of both operands. The upper 64 bits are
+///  

[PATCH] D25813: [CodeGen] Devirtualize calls to methods marked final in a derived class

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

Looks great to me, thanks.


https://reviews.llvm.org/D25813



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


[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

2016-10-20 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

Ouch, i think i forgot about `OSNumber`, including tests.




Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:111
+  QualType ObjT = (IsCpp || IsObjC)
+  ? Obj->getType().getCanonicalType().getUnqualifiedType()
+  : Obj->getType();

zaks.anna wrote:
> Why do we need a case split here? Would calling 
> getCanonicalType().getUnqualifiedType() result in a wrong result for ObjC?
It'd result in a wrong result for `CFNumberRef`, which is a typedef we 
shouldn't remove (turning this into `struct __CFNumber *` would be ugly).

I'd probably rather avoid the case split by removing the `.getCanonicalType()` 
part, because rarely anybody makes typedefs for `NSNumber*` or `OSBoolean*` etc 
(such as in tests with the word "sugared").

Or i could descend down to the necessary typedef for C objects, discarding all 
user's typedefs but not library typedefs. But that'd be even more complicated 
and probably not very useful for such minor matter.


https://reviews.llvm.org/D25731



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


[PATCH] D25806: Module: correctly set the module file kind when emitting diagnostics for file_modified

2016-10-20 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 75326.
manmanren added a comment.

Thanks Richard for the testing case. It is also obvious from the testing case 
that we can have another diagnostic in flight when emitting 
err_fe_pch_file_modified.


https://reviews.llvm.org/D25806

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  lib/Serialization/ASTReader.cpp
  test/Modules/module-file-modified.c


Index: test/Modules/module-file-modified.c
===
--- test/Modules/module-file-modified.c
+++ test/Modules/module-file-modified.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'int foo = 0;' > %t/a.h
+// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap 
-o %t/m.pcm
+// RUN: echo 'int bar;' > %t/a.h
+// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm 
-fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file 
{{.*}} was built
+// REQUIRES: shell
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = 
moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
 
   // Print the import stack.
   if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
Index: include/clang/Basic/DiagnosticSerializationKinds.td
===
--- include/clang/Basic/DiagnosticSerializationKinds.td
+++ include/clang/Basic/DiagnosticSerializationKinds.td
@@ -21,6 +21,12 @@
 def err_fe_pch_file_modified : Error<
 "file '%0' has been modified since the precompiled header '%1' was built">,
 DefaultFatal;
+def err_fe_module_file_modified : Error<
+"file '%0' has been modified since the module file '%1' was built">,
+DefaultFatal;
+def err_fe_ast_file_modified : Error<
+"file '%0' has been modified since the AST file '%1' was built">,
+DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;
 def note_pch_required_by : Note<"'%0' required by '%1'">;


Index: test/Modules/module-file-modified.c
===
--- test/Modules/module-file-modified.c
+++ test/Modules/module-file-modified.c
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'int foo = 0;' > %t/a.h
+// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap -o %t/m.pcm
+// RUN: echo 'int bar;' > %t/a.h
+// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm -fmodule-map-file=%t/m.modulemap -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file {{.*}} was built
+// REQUIRES: shell
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
   return R;
 }
 
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
   // If this ID is bogus, just return an empty input file.
   if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
 
   // The top-level PCH is stale.
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
-  Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind);
+  if (DiagnosticKind == 0)
+Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+  else if (DiagnosticKind == 1)
+Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+  else
+Error(diag::err_fe_ast_file_modified, Filename, 

r284761 - [c++1z] Fix assertion failure when using the wrong number of bindings for a

2016-10-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Oct 20 13:29:25 2016
New Revision: 284761

URL: http://llvm.org/viewvc/llvm-project?rev=284761&view=rev
Log:
[c++1z] Fix assertion failure when using the wrong number of bindings for a
struct with unnamed bitfields.

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=284761&r1=284760&r2=284761&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Oct 20 13:29:25 2016
@@ -1279,7 +1279,9 @@ static bool checkMemberDecomposition(Sem
  DecompType.getQualifiers());
 
   auto DiagnoseBadNumberOfBindings = [&]() -> bool {
-unsigned NumFields = std::distance(RD->field_begin(), RD->field_end());
+unsigned NumFields =
+std::count_if(RD->field_begin(), RD->field_end(),
+  [](FieldDecl *FD) { return !FD->isUnnamedBitfield(); });
 assert(Bindings.size() != NumFields);
 S.Diag(Src->getLocation(), diag::err_decomp_decl_wrong_number_bindings)
 << DecompType << (unsigned)Bindings.size() << NumFields

Modified: cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp?rev=284761&r1=284760&r2=284761&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp Thu Oct 20 13:29:25 2016
@@ -47,4 +47,10 @@ void enclosing() {
   (void) [n] {}; // expected-error {{'n' in capture list does not name a 
variable}}
 }
 
+void bitfield() {
+  struct { int a : 3, : 4, b : 5; } a;
+  auto &[x, y] = a;
+  auto &[p, q, r] = a; // expected-error {{decomposes into 2 elements, but 3 
names were provided}}
+}
+
 // FIXME: by-value array copies


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


[PATCH] D25731: [analyzer] NumberObjectConversion: Support OSNumber and CFNumberRef.

2016-10-20 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp:149
  BugReporter &BR) const {
   MatchFinder F;
   Callback CB(this, BR, AM.getAnalysisDeclContext(D));

probably it would make sense to move "MatchFinder F;" to the line 276 (closer 
to the place where it's actually being used)(or maybe i'm missing smth ?) 


https://reviews.llvm.org/D25731



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


[PATCH] D25813: [CodeGen] Devirtualize calls to methods marked final in a derived class

2016-10-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284766: [CodeGen] Devirtualize calls to methods marked final 
in a derived class (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D25813?vs=75266&id=75331#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25813

Files:
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
  cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp

Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -2873,6 +2873,11 @@
   if (getLangOpts().AppleKext)
 return false;
 
+  // If the member function is marked 'final', we know that it can't be
+  // overridden and can therefore devirtualize it.
+  if (MD->hasAttr())
+return true;
+
   // If the most derived class is marked final, we know that no subclass can
   // override this member function and so we can devirtualize it. For example:
   //
@@ -2883,14 +2888,17 @@
   //   b->f();
   // }
   //
-  const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType();
-  if (MostDerivedClassDecl->hasAttr())
-return true;
+  if (const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType()) {
+if (BestDynamicDecl->hasAttr())
+  return true;
 
-  // If the member function is marked 'final', we know that it can't be
-  // overridden and can therefore devirtualize it.
-  if (MD->hasAttr())
-return true;
+// There may be a method corresponding to MD in a derived class. If that
+// method is marked final, we can devirtualize it.
+const CXXMethodDecl *DevirtualizedMethod =
+MD->getCorrespondingMethodInClass(BestDynamicDecl);
+if (DevirtualizedMethod->hasAttr())
+  return true;
+  }
 
   // Similarly, if the class itself is marked 'final' it can't be overridden
   // and we can therefore devirtualize the member function call.
Index: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
===
--- cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
@@ -16,9 +16,6 @@
   void f1() override {}
 };
 
-// PR13127 documents some missed devirtualization opportunities, including
-// devirt for methods marked 'final'. We can enable the checks marked 'PR13127'
-// if we implement this in the frontend.
 struct Derived3 : Base1 {
   void f1() override /* nofinal */ {}
 };
@@ -30,10 +27,10 @@
 // CHECK: [[UBSAN_TI_DERIVED1_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived1 to i8*
 // CHECK: [[UBSAN_TI_DERIVED2_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8*
 // CHECK: [[UBSAN_TI_DERIVED2_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8*
-// PR13127: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived3 to i8*
-// PR13127: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI5Base1 to i8*
-// PR13127: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
-// PR13127: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
+// CHECK: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived3 to i8*
+// CHECK: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI5Base1 to i8*
+// CHECK: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
+// CHECK: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
 
 // CHECK-LABEL: define void @_Z2t1v
 void t1() {
@@ -59,26 +56,26 @@
   // CHECK-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED2_2]] {{.*}}, i{{[0-9]+}} %[[D2_2]]
 }
 
-// PR13127-LABEL: define void @_Z2t4v
+// CHECK-LABEL: define void @_Z2t4v
 void t4() {
   Base1 p;
   Derived3 *badp = static_cast(&p); //< Check that &p isa Derived3.
-  // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived3* {{%[0-9]+}} to i{{[0-9]+}}, !nosanitize
-  // PR13127-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i{{[0-9]+}} %[[P1]]
+  // CHECK: %[[P1:[0-9]+]] = ptrtoint %struct.Derived3* {{%[0-9]+}} to i{{[0-9]+}}, !nosanitize
+  // CHECK-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i{{[0-9]+}} %[[P1]]
 
   static_cast(badp)->f1(); //< No devirt, test 'badp isa Base1'.
-  // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Base1* {{%[0-9]+}} to i{{[0-9]+}}, !nosanitize
-  // PR13127-NEXT: call v

r284766 - [CodeGen] Devirtualize calls to methods marked final in a derived class

2016-10-20 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Oct 20 13:44:14 2016
New Revision: 284766

URL: http://llvm.org/viewvc/llvm-project?rev=284766&view=rev
Log:
[CodeGen] Devirtualize calls to methods marked final in a derived class

If we see a virtual method call to Base::foo() but can infer that the
object is an instance of Derived, and that 'foo' is marked 'final' in
Derived, we can devirtualize the call to Derived::foo().

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

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=284766&r1=284765&r2=284766&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Oct 20 13:44:14 2016
@@ -2873,6 +2873,11 @@ CodeGenFunction::CanDevirtualizeMemberFu
   if (getLangOpts().AppleKext)
 return false;
 
+  // If the member function is marked 'final', we know that it can't be
+  // overridden and can therefore devirtualize it.
+  if (MD->hasAttr())
+return true;
+
   // If the most derived class is marked final, we know that no subclass can
   // override this member function and so we can devirtualize it. For example:
   //
@@ -2883,14 +2888,17 @@ CodeGenFunction::CanDevirtualizeMemberFu
   //   b->f();
   // }
   //
-  const CXXRecordDecl *MostDerivedClassDecl = Base->getBestDynamicClassType();
-  if (MostDerivedClassDecl->hasAttr())
-return true;
+  if (const CXXRecordDecl *BestDynamicDecl = Base->getBestDynamicClassType()) {
+if (BestDynamicDecl->hasAttr())
+  return true;
 
-  // If the member function is marked 'final', we know that it can't be
-  // overridden and can therefore devirtualize it.
-  if (MD->hasAttr())
-return true;
+// There may be a method corresponding to MD in a derived class. If that
+// method is marked final, we can devirtualize it.
+const CXXMethodDecl *DevirtualizedMethod =
+MD->getCorrespondingMethodInClass(BestDynamicDecl);
+if (DevirtualizedMethod->hasAttr())
+  return true;
+  }
 
   // Similarly, if the class itself is marked 'final' it can't be overridden
   // and we can therefore devirtualize the member function call.

Modified: 
cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp?rev=284766&r1=284765&r2=284766&view=diff
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp 
(original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp Thu 
Oct 20 13:44:14 2016
@@ -225,3 +225,19 @@ namespace Test9 {
 return -static_cast(*x);
   }
 }
+
+namespace Test10 {
+  struct A {
+virtual int f();
+  };
+
+  struct B : A {
+int f() final;
+  };
+
+  // CHECK-LABEL: define i32 @_ZN6Test101fEPNS_1BE
+  int f(B *b) {
+// CHECK: call i32 @_ZN6Test101B1fEv
+return static_cast(b)->f();
+  }
+}

Modified: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp?rev=284766&r1=284765&r2=284766&view=diff
==
--- cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Thu Oct 20 13:44:14 
2016
@@ -16,9 +16,6 @@ struct Derived2 final : Base1, Base2 {
   void f1() override {}
 };
 
-// PR13127 documents some missed devirtualization opportunities, including
-// devirt for methods marked 'final'. We can enable the checks marked 'PR13127'
-// if we implement this in the frontend.
 struct Derived3 : Base1 {
   void f1() override /* nofinal */ {}
 };
@@ -30,10 +27,10 @@ struct Derived4 final : Base1 {
 // CHECK: [[UBSAN_TI_DERIVED1_1:@[0-9]+]] = private unnamed_addr global {{.*}} 
i8* bitcast {{.*}} @_ZTI8Derived1 to i8*
 // CHECK: [[UBSAN_TI_DERIVED2_1:@[0-9]+]] = private unnamed_addr global {{.*}} 
i8* bitcast {{.*}} @_ZTI8Derived2 to i8*
 // CHECK: [[UBSAN_TI_DERIVED2_2:@[0-9]+]] = private unnamed_addr global {{.*}} 
i8* bitcast {{.*}} @_ZTI8Derived2 to i8*
-// PR13127: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} 
i8* bitcast {{.*}} @_ZTI8Derived3 to i8*
-// PR13127: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} 
i8* bitcast {{.*}} @_ZTI5Base1 to i8*
-// PR13127: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global 
{{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
-// PR13127: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global 
{{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8*
+// CHE

[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-20 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D24991#571056, @hiraditya wrote:

> Marshall suggests using macro as we discussed offline. For some reason the 
> reply does not appear here: 
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161010/173780.html


Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D24991



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


[PATCH] D25838: [Fuchsia] Support for additional architectures

2016-10-20 Thread Petr Hosek via cfe-commits
phosek created this revision.
phosek added a reviewer: rsmith.
phosek added a subscriber: cfe-commits.
phosek set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

Fuchsia also experimentally supports ARM32 architecture, add it to the list of 
supported targets.


Repository:
  rL LLVM

https://reviews.llvm.org/D25838

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8296,20 +8296,22 @@
   return new CloudABITargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 default:
   return new AArch64leTargetInfo(Triple, Opts);
 }
 
   case llvm::Triple::aarch64_be:
 switch (os) {
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
@@ -8330,6 +8332,8 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8366,6 +8370,8 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8296,20 +8296,22 @@
   return new CloudABITargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
-case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
 default:
   return new AArch64leTargetInfo(Triple, Opts);
 }
 
   case llvm::Triple::aarch64_be:
 switch (os) {
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::Linux:
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
@@ -8330,6 +8332,8 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
@@ -8366,6 +8370,8 @@
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
+case llvm::Triple::Fuchsia:
+  return new FuchsiaTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
 case llvm::Triple::OpenBSD:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25839: Removed unused function argument. NFC.

2016-10-20 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: jlebar.
tra added a subscriber: cfe-commits.

https://reviews.llvm.org/D25839

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8264,7 +8264,7 @@
   ProcessDeclAttributes(S, NewFD, D);
 
   if (getLangOpts().CUDA)
-maybeAddCUDAHostDeviceAttrs(S, NewFD, Previous);
+maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
 
   if (getLangOpts().OpenCL) {
 // OpenCL v1.1 s6.5: Using an address space qualifier in a function return
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -439,7 +439,7 @@
 // ForceCUDAHostDeviceDepth > 0 (corresponding to code within a
 //   #pragma clang force_cuda_host_device_begin/end
 // pair).
-void Sema::maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *NewD,
+void Sema::maybeAddCUDAHostDeviceAttrs(FunctionDecl *NewD,
const LookupResult &Previous) {
   assert(getLangOpts().CUDA && "Should only be called during CUDA 
compilation");
 
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -9443,7 +9443,7 @@
 
   /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
   /// depending on FD and the current compilation settings.
-  void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
+  void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
const LookupResult &Previous);
 
 public:


Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8264,7 +8264,7 @@
   ProcessDeclAttributes(S, NewFD, D);
 
   if (getLangOpts().CUDA)
-maybeAddCUDAHostDeviceAttrs(S, NewFD, Previous);
+maybeAddCUDAHostDeviceAttrs(NewFD, Previous);
 
   if (getLangOpts().OpenCL) {
 // OpenCL v1.1 s6.5: Using an address space qualifier in a function return
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -439,7 +439,7 @@
 // ForceCUDAHostDeviceDepth > 0 (corresponding to code within a
 //   #pragma clang force_cuda_host_device_begin/end
 // pair).
-void Sema::maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *NewD,
+void Sema::maybeAddCUDAHostDeviceAttrs(FunctionDecl *NewD,
const LookupResult &Previous) {
   assert(getLangOpts().CUDA && "Should only be called during CUDA compilation");
 
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -9443,7 +9443,7 @@
 
   /// May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD,
   /// depending on FD and the current compilation settings.
-  void maybeAddCUDAHostDeviceAttrs(Scope *S, FunctionDecl *FD,
+  void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD,
const LookupResult &Previous);
 
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25696: [Driver] Parse Debian version as integer when possible. NFC

2016-10-20 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D25696



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


[PATCH] D25842: [clang] Limit clang test to ARM only

2016-10-20 Thread Mandeep Singh Grang via cfe-commits
mgrang created this revision.
mgrang added reviewers: abdulras, honggyu.kim.
mgrang added a subscriber: cfe-commits.
mgrang added a project: clang-c.
Herald added subscribers: rengolin, aemerson.

Limit clang/test/Frontend/gnu-mcount.c to ARM only.


https://reviews.llvm.org/D25842

Files:
  test/Frontend/gnu-mcount.c


Index: test/Frontend/gnu-mcount.c
===
--- test/Frontend/gnu-mcount.c
+++ test/Frontend/gnu-mcount.c
@@ -1,3 +1,5 @@
+// REQUIRES: arm-registered-target
+
 // RUN: %clang -target armv7-unknown-none-eabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o 
- %s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI-MEABI-GNU
 // RUN: %clang -target aarch64-unknown-none-eabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI


Index: test/Frontend/gnu-mcount.c
===
--- test/Frontend/gnu-mcount.c
+++ test/Frontend/gnu-mcount.c
@@ -1,3 +1,5 @@
+// REQUIRES: arm-registered-target
+
 // RUN: %clang -target armv7-unknown-none-eabi -pg -S -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
 // RUN: %clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI-MEABI-GNU
 // RUN: %clang -target aarch64-unknown-none-eabi -pg -S -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25696: [Driver] Parse Debian version as integer when possible. NFC

2016-10-20 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review. I'll now look into updating the code for other distros 
to follow suit.


https://reviews.llvm.org/D25696



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


r284770 - [Driver] Parse Debian version as integer when possible. NFC

2016-10-20 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Oct 20 15:13:35 2016
New Revision: 284770

URL: http://llvm.org/viewvc/llvm-project?rev=284770&view=rev
Log:
[Driver] Parse Debian version as integer when possible. NFC

Replace the string matching for /etc/debian_version with split
integer/string matching algorithm. When the file contains 'major.minor'
version number, parse the major version as integer and use a switch
clause to match it. Otherwise, attempt 'codename/sid' matching using
a StringSwitch.

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=284770&r1=284769&r2=284770&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct 20 15:13:35 2016
@@ -3905,17 +3905,30 @@ static Distro DetectDistro(const Driver
   File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
-if (Data[0] == '5')
-  return DebianLenny;
-else if (Data.startswith("squeeze/sid") || Data[0] == '6')
-  return DebianSqueeze;
-else if (Data.startswith("wheezy/sid") || Data[0] == '7')
-  return DebianWheezy;
-else if (Data.startswith("jessie/sid") || Data[0] == '8')
-  return DebianJessie;
-else if (Data.startswith("stretch/sid") || Data[0] == '9')
-  return DebianStretch;
-return UnknownDistro;
+// Contents: < major.minor > or < codename/sid >
+int MajorVersion;
+if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
+  switch (MajorVersion) {
+  case 5:
+return DebianLenny;
+  case 6:
+return DebianSqueeze;
+  case 7:
+return DebianWheezy;
+  case 8:
+return DebianJessie;
+  case 9:
+return DebianStretch;
+  default:
+return UnknownDistro;
+  }
+}
+return llvm::StringSwitch(Data.split("\n").first)
+.Case("squeeze/sid", DebianSqueeze)
+.Case("wheezy/sid", DebianWheezy)
+.Case("jessie/sid", DebianJessie)
+.Case("stretch/sid", DebianStretch)
+.Default(UnknownDistro);
   }
 
   if (D.getVFS().exists("/etc/SuSE-release"))


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


[PATCH] D25819: [Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC

2016-10-20 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Very nice!

LGTM


https://reviews.llvm.org/D25819



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


[PATCH] D25696: [Driver] Parse Debian version as integer when possible. NFC

2016-10-20 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284770: [Driver] Parse Debian version as integer when 
possible. NFC (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25696?vs=75269&id=75345#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25696

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3905,17 +3905,30 @@
   File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
-if (Data[0] == '5')
-  return DebianLenny;
-else if (Data.startswith("squeeze/sid") || Data[0] == '6')
-  return DebianSqueeze;
-else if (Data.startswith("wheezy/sid") || Data[0] == '7')
-  return DebianWheezy;
-else if (Data.startswith("jessie/sid") || Data[0] == '8')
-  return DebianJessie;
-else if (Data.startswith("stretch/sid") || Data[0] == '9')
-  return DebianStretch;
-return UnknownDistro;
+// Contents: < major.minor > or < codename/sid >
+int MajorVersion;
+if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
+  switch (MajorVersion) {
+  case 5:
+return DebianLenny;
+  case 6:
+return DebianSqueeze;
+  case 7:
+return DebianWheezy;
+  case 8:
+return DebianJessie;
+  case 9:
+return DebianStretch;
+  default:
+return UnknownDistro;
+  }
+}
+return llvm::StringSwitch(Data.split("\n").first)
+.Case("squeeze/sid", DebianSqueeze)
+.Case("wheezy/sid", DebianWheezy)
+.Case("jessie/sid", DebianJessie)
+.Case("stretch/sid", DebianStretch)
+.Default(UnknownDistro);
   }
 
   if (D.getVFS().exists("/etc/SuSE-release"))


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3905,17 +3905,30 @@
   File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
-if (Data[0] == '5')
-  return DebianLenny;
-else if (Data.startswith("squeeze/sid") || Data[0] == '6')
-  return DebianSqueeze;
-else if (Data.startswith("wheezy/sid") || Data[0] == '7')
-  return DebianWheezy;
-else if (Data.startswith("jessie/sid") || Data[0] == '8')
-  return DebianJessie;
-else if (Data.startswith("stretch/sid") || Data[0] == '9')
-  return DebianStretch;
-return UnknownDistro;
+// Contents: < major.minor > or < codename/sid >
+int MajorVersion;
+if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
+  switch (MajorVersion) {
+  case 5:
+return DebianLenny;
+  case 6:
+return DebianSqueeze;
+  case 7:
+return DebianWheezy;
+  case 8:
+return DebianJessie;
+  case 9:
+return DebianStretch;
+  default:
+return UnknownDistro;
+  }
+}
+return llvm::StringSwitch(Data.split("\n").first)
+.Case("squeeze/sid", DebianSqueeze)
+.Case("wheezy/sid", DebianWheezy)
+.Case("jessie/sid", DebianJessie)
+.Case("stretch/sid", DebianStretch)
+.Default(UnknownDistro);
   }
 
   if (D.getVFS().exists("/etc/SuSE-release"))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25842: [clang] Limit clang test to ARM only

2016-10-20 Thread Renato Golin via cfe-commits
rengolin added inline comments.



Comment at: test/Frontend/gnu-mcount.c:1
+// REQUIRES: arm-registered-target
+

If you have ARM but not AArch64, this test will also fail. Can you use AND on 
REQUIRES?


https://reviews.llvm.org/D25842



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


[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-10-20 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jlebar, rsmith.
tra added a subscriber: cfe-commits.

Some functions and templates are treated as `__host__` `__device__` even when 
they don't have explicitly specified target attributes.
What's worse, this treatment may change depending on command line options 
(-fno-cuda-host-device-constexpr) or `#pragma clang force_cuda_host_device`.

Combined with strict checking for matching function target that comes with 
https://reviews.llvm.org/D25809, it makes it hard to write code which would 
explicitly instantiate or specialize some functions regardless of pragmas or 
command line options in effect.

This patch changes the way we match target attributes of base template vs 
attributes used in explicit instantiation or specialization so that only 
explicitly specified attributes are considered.


https://reviews.llvm.org/D25845

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/function-template-overload.cu

Index: test/SemaCUDA/function-template-overload.cu
===
--- test/SemaCUDA/function-template-overload.cu
+++ test/SemaCUDA/function-template-overload.cu
@@ -56,24 +56,51 @@
 template  __host__ __device__ HDType overload_h_d2(T a) { return HDType(); }
 template  __device__ DType overload_h_d2(T1 a) { T1 x; T2 y; return DType(); }
 
+// constexpr functions are implicitly HD, but explicit
+// instantiation/specialization must use target attributes as written.
+template  constexpr T overload_ce_implicit_hd(T a) { return a+1; }
+// expected-note@-1 3 {{candidate template ignored: target attributes do not match}}
+
+// These will not match the template.
+template __host__ __device__ int overload_ce_implicit_hd(int a);
+// expected-error@-1 {{explicit instantiation of 'overload_ce_implicit_hd' does not refer to a function template, variable template, member function, member class, or static data member}}
+template <> __host__ __device__ long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+template <> __host__ __device__ constexpr long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+
+// These should work.
+template __host__ int overload_ce_implicit_hd(int a);
+template <> __host__ long overload_ce_implicit_hd(long a);
+
+template float overload_ce_implicit_hd(float a);
+template <> float* overload_ce_implicit_hd(float *a);
+template <> constexpr double overload_ce_implicit_hd(double a) { return a + 3.0; };
+
 __host__ void hf() {
   overload_hd(13);
+  overload_ce_implicit_hd('h');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   HType h = overload_h_d(10);
   HType h2i = overload_h_d2(11);
   HType h2ii = overload_h_d2(12);
 
   // These should be implicitly instantiated from __host__ template returning HType.
-  DType d = overload_h_d(20); // expected-error {{no viable conversion from 'HType' to 'DType'}}
-  DType d2i = overload_h_d2(21); // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d = overload_h_d(20);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d2i = overload_h_d2(21);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
   DType d2ii = overload_h_d2(22); // expected-error {{no viable conversion from 'HType' to 'DType'}}
 }
 __device__ void df() {
   overload_hd(23);
+  overload_ce_implicit_hd('d');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   // These should be implicitly instantiated from __device__ template returning DType.
-  HType h = overload_h_d(10); // expected-error {{no viable conversion from 'DType' to 'HType'}}
-  HType h2i = overload_h_d2(11); // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h = overload_h_d(10);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h2i = overload_h_d2(11);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
   HType h2ii = overload_h_d2(12); // expected-error {{no viable conversion from 'DType' to 'HType'}}
 
   DType d = overload_h_d(20);
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7043,13 +7043,13 @@
 
   // Filter out matches that have different target.
   if (LangOpts.CUDA &&
-  IdentifyCUDATarget(Specialization) != IdentifyCUDATarget(FD)) {
+  IdentifyCUDATarget(Specialization, true) !=
+  IdentifyCUDATarget(FD, tr

[PATCH] D25844: [Sema][ObjC] Warn about implicitly autoreleasing indirect parameters that are captured by blocks

2016-10-20 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a subscriber: cfe-commits.

ARC implicitly marks indirect parameters passed to a function as autoreleasing 
and passing a block that captures those parameters to another function 
sometimes causes problems that are hard to debug.

For example, in the code below, a block capturing fillMeIn is passed to 
enumerateObjectsUsingBlock, in which an autorelease pool is pushed and popped 
before and after the block is invoked:

  void doStuff(NSString **fillMeIn) {
  [@[@"array"] enumerateObjectsUsingBlock:
^(id obj, NSUInteger idx, BOOL* stop) {
  *stop = YES;
  *fillMeIn = [@"wow" mutableCopy];
}
   ];
  }

The object assigned to *fillMeIn gets autoreleased inside the block, so it gets 
destructed when the autorelease pool is drained, and the program will crash if 
it tries to access the NSString returned in fillMeIn after doStuff returns.

To help the users figure out why the program is crashing, this patch adds a new 
warning "-Wblock-capture-autoreleasing" which warns about implicitly 
autoreleasing indirect parameters captured by blocks and suggests explicitly 
specifying ownership qualification.


https://reviews.llvm.org/D25844

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/arc.m


Index: test/SemaObjC/arc.m
===
--- test/SemaObjC/arc.m
+++ test/SemaObjC/arc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class 
-Wblock-capture-autoreleasing %s
 
 typedef unsigned long NSUInteger;
 typedef const void * CFTypeRef;
@@ -808,3 +808,10 @@
   TKAssertEqual(object, nil);
   TKAssertEqual(object, (id)nil);
 }
+
+void block_capture_autoreleasing(A * __autoreleasing *a, A **b) { // 
expected-note {{explicitly specify ownership qualification}}
+  ^{
+(void)*a;
+(void)*b; // expected-warning {{block captures indirect parameter 
implicitly qualified with __autoreleasing}}
+  }();
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -13473,6 +13473,20 @@
 }
 return false;
   }
+
+  // Warn about implicitly autoreleasing indirect parameters captured by 
blocks.
+  if (auto *PT = dyn_cast(CaptureType)) {
+QualType PointeeTy = PT->getPointeeType();
+if (isa(PointeeTy.getCanonicalType()) &&
+PointeeTy.getObjCLifetime() == Qualifiers::OCL_Autoreleasing &&
+!isa(PointeeTy)) {
+  if (BuildAndDiagnose) {
+S.Diag(Loc, diag::warn_block_capture_autoreleasing);
+S.Diag(Var->getLocation(), 
diag::note_explicit_ownership_qualification);
+  }
+}
+  }
+
   const bool HasBlocksAttr = Var->hasAttr();
   if (HasBlocksAttr || CaptureType->isReferenceType() ||
   (S.getLangOpts().OpenMP && S.IsOpenMPCapturedDecl(Var))) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5073,6 +5073,12 @@
 
 } // end "ARC and @properties" category
 
+def warn_block_capture_autoreleasing : Warning<
+  "block captures indirect parameter implicitly qualified with 
__autoreleasing">,
+  InGroup, DefaultIgnore;
+def note_explicit_ownership_qualification : Note<
+  "explicitly specify ownership qualification">;
+
 def err_arc_atomic_ownership : Error<
   "cannot perform atomic operation on a pointer to type %0: type has "
   "non-trivial ownership">;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -498,6 +498,7 @@
 def ARCRepeatedUseOfWeakMaybe : DiagGroup<"arc-maybe-repeated-use-of-weak">;
 def ARCRepeatedUseOfWeak : DiagGroup<"arc-repeated-use-of-weak",
  [ARCRepeatedUseOfWeakMaybe]>;
+def BlockCaptureAutoReleasing : DiagGroup<"block-capture-autoreleasing">;
 def ObjCBridge : DiagGroup<"bridge-cast">;
 
 def DeallocInCategory:DiagGroup<"dealloc-in-category">;


Index: test/SemaObjC/arc.m
===
--- test/SemaObjC/arc.m
+++ test/SemaObjC/arc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class -Wblock-capture-autoreleasing %s
 
 typede

r284774 - [Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC

2016-10-20 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Oct 20 15:45:40 2016
New Revision: 284774

URL: http://llvm.org/viewvc/llvm-project?rev=284774&view=rev
Log:
[Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC

Refactor the DetectDistro() function to take a single vfs::FileSystem
reference only, instead of Driver and llvm::Triple::ArchType.
The ArchType parameter was not used anyway, and Driver was only used to
obtain the VFS.

Aside to making the API simpler and more transparent, it makes it
easier to add unit tests for the function in the future -- since
the tests would need only to provide an appropriate VFS.

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=284774&r1=284773&r2=284774&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Oct 20 15:45:40 2016
@@ -3850,9 +3850,9 @@ static bool IsUbuntu(enum Distro Distro)
   return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
 }
 
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
   llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile("/etc/lsb-release");
+  VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3884,7 +3884,7 @@ static Distro DetectDistro(const Driver
   return Version;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/redhat-release");
+  File = VFS.getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@ static Distro DetectDistro(const Driver
 return UnknownDistro;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/debian_version");
+  File = VFS.getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 // Contents: < major.minor > or < codename/sid >
@@ -3931,13 +3931,13 @@ static Distro DetectDistro(const Driver
 .Default(UnknownDistro);
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
+  if (VFS.exists("/etc/SuSE-release"))
 return OpenSUSE;
 
-  if (D.getVFS().exists("/etc/exherbo-release"))
+  if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
 
-  if (D.getVFS().exists("/etc/arch-release"))
+  if (VFS.exists("/etc/arch-release"))
 return ArchLinux;
 
   return UnknownDistro;
@@ -4122,7 +4122,7 @@ Linux::Linux(const Driver &D, const llvm
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Distro Distro = DetectDistro(D, Arch);
+  Distro Distro = DetectDistro(D.getVFS());
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
 ExtraOpts.push_back("-z");
@@ -4326,7 +4326,7 @@ std::string Linux::getDynamicLinker(cons
   const llvm::Triple::ArchType Arch = getArch();
   const llvm::Triple &Triple = getTriple();
 
-  const enum Distro Distro = DetectDistro(getDriver(), Arch);
+  const enum Distro Distro = DetectDistro(getDriver().getVFS());
 
   if (Triple.isAndroid())
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";


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


[PATCH] D25819: [Driver] Refactor DetectDistro() parameters to take VFS ref only. NFC

2016-10-20 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284774: [Driver] Refactor DetectDistro() parameters to take 
VFS ref only. NFC (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25819?vs=75283&id=75350#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25819

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3850,9 +3850,9 @@
   return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
 }
 
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
   llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile("/etc/lsb-release");
+  VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3884,7 +3884,7 @@
   return Version;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/redhat-release");
+  File = VFS.getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@
 return UnknownDistro;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/debian_version");
+  File = VFS.getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 // Contents: < major.minor > or < codename/sid >
@@ -3931,13 +3931,13 @@
 .Default(UnknownDistro);
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
+  if (VFS.exists("/etc/SuSE-release"))
 return OpenSUSE;
 
-  if (D.getVFS().exists("/etc/exherbo-release"))
+  if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
 
-  if (D.getVFS().exists("/etc/arch-release"))
+  if (VFS.exists("/etc/arch-release"))
 return ArchLinux;
 
   return UnknownDistro;
@@ -4122,7 +4122,7 @@
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Distro Distro = DetectDistro(D, Arch);
+  Distro Distro = DetectDistro(D.getVFS());
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
 ExtraOpts.push_back("-z");
@@ -4326,7 +4326,7 @@
   const llvm::Triple::ArchType Arch = getArch();
   const llvm::Triple &Triple = getTriple();
 
-  const enum Distro Distro = DetectDistro(getDriver(), Arch);
+  const enum Distro Distro = DetectDistro(getDriver().getVFS());
 
   if (Triple.isAndroid())
 return Triple.isArch64Bit() ? "/system/bin/linker64" : 
"/system/bin/linker";


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3850,9 +3850,9 @@
   return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
 }
 
-static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(vfs::FileSystem &VFS) {
   llvm::ErrorOr> File =
-  D.getVFS().getBufferForFile("/etc/lsb-release");
+  VFS.getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3884,7 +3884,7 @@
   return Version;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/redhat-release");
+  File = VFS.getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3902,7 +3902,7 @@
 return UnknownDistro;
   }
 
-  File = D.getVFS().getBufferForFile("/etc/debian_version");
+  File = VFS.getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 // Contents: < major.minor > or < codename/sid >
@@ -3931,13 +3931,13 @@
 .Default(UnknownDistro);
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
+  if (VFS.exists("/etc/SuSE-release"))
 return OpenSUSE;
 
-  if (D.getVFS().exists("/etc/exherbo-release"))
+  if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
 
-  if (D.getVFS().exists("/etc/arch-release"))
+  if (VFS.exists("/etc/arch-release"))
 return ArchLinux;
 
   return UnknownDistro;
@@ -4122,7 +4122,7 @@
  GCCInstallation.getTriple().str() + "/bin")
.str());
 
-  Distro Distro = DetectDistro(D, Arch);
+  Distro Distro = DetectDistro(D.getVFS());
 
   if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
 ExtraOpts.push_back("-z");
@@ -4326,7 +4326,7 @@
   const llvm::Triple::ArchType Arch = getArch();
   const llvm::Triple &Triple = getTriple();
 
-  const enum Distro Distro = DetectDistro(getDriver(), Arch);
+  const enum Distro Distro = DetectDistro(getDriver().getVFS());
 
   if (Triple.isAndroid())
 return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
___
cfe-commits mailing list
c

[PATCH] D25258: [coroutines] Create allocation and deallocation sub-statements.

2016-10-20 Thread Gor Nishanov via cfe-commits
GorNishanov abandoned this revision.
GorNishanov added a comment.

I'll simplify and split it into super tiny microscopic patches to have a better 
chance of being reviewed.


https://reviews.llvm.org/D25258



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


r284777 - Fix off-by-one error in PPCaching.cpp token annotation assertion

2016-10-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Oct 20 15:53:20 2016
New Revision: 284777

URL: http://llvm.org/viewvc/llvm-project?rev=284777&view=rev
Log:
Fix off-by-one error in PPCaching.cpp token annotation assertion

This assert is intended to defend against backtracking into the middle
of a sequence of tokens that is being replaced with an annotation, but
it's OK if we backtrack to the exact position of the start of the
annotation sequence. Use a <= comparison instead of <.

Fixes PR25946

Added:
cfe/trunk/test/Parser/backtrack-off-by-one.cpp
Modified:
cfe/trunk/lib/Lex/PPCaching.cpp

Modified: cfe/trunk/lib/Lex/PPCaching.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPCaching.cpp?rev=284777&r1=284776&r2=284777&view=diff
==
--- cfe/trunk/lib/Lex/PPCaching.cpp (original)
+++ cfe/trunk/lib/Lex/PPCaching.cpp Thu Oct 20 15:53:20 2016
@@ -105,7 +105,7 @@ void Preprocessor::AnnotatePreviousCache
   for (CachedTokensTy::size_type i = CachedLexPos; i != 0; --i) {
 CachedTokensTy::iterator AnnotBegin = CachedTokens.begin() + i-1;
 if (AnnotBegin->getLocation() == Tok.getLocation()) {
-  assert((BacktrackPositions.empty() || BacktrackPositions.back() < i) &&
+  assert((BacktrackPositions.empty() || BacktrackPositions.back() <= i) &&
  "The backtrack pos points inside the annotated tokens!");
   // Replace the cached tokens with the single annotation token.
   if (i < CachedLexPos)

Added: cfe/trunk/test/Parser/backtrack-off-by-one.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/backtrack-off-by-one.cpp?rev=284777&view=auto
==
--- cfe/trunk/test/Parser/backtrack-off-by-one.cpp (added)
+++ cfe/trunk/test/Parser/backtrack-off-by-one.cpp Thu Oct 20 15:53:20 2016
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR25946
+// We had an off-by-one error in an assertion when annotating A below.  
Our
+// error recovery checks if A is a constructor declarator, and opens a
+// TentativeParsingAction. Then we attempt to annotate the token at the exact
+// position that we want to possibly backtrack to, and this used to crash.
+
+template  class A {};
+
+// expected-error@+1 {{expected '{' after base class list}}
+template  class B : T // not ',' or '{'
+// expected-error@+3 {{C++ requires a type specifier for all declarations}}
+// expected-error@+2 {{expected ';' after top level declarator}}
+// expected-error@+1 {{expected ';' after class}}
+A {
+};


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


r284778 - Revert r284753 "[c++1z] Teach composite pointer type computation how to compute the composite"

2016-10-20 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Oct 20 15:54:32 2016
New Revision: 284778

URL: http://llvm.org/viewvc/llvm-project?rev=284778&view=rev
Log:
Revert r284753 "[c++1z] Teach composite pointer type computation how to compute 
the composite"

It caused PR30749.

Removed:
cfe/trunk/test/CXX/expr/p13.cpp
Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=284778&r1=284777&r2=284778&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Thu Oct 20 15:54:32 2016
@@ -145,8 +145,7 @@ namespace clang {
 /// pointer-to-member conversion, or boolean conversion.
 ImplicitConversionKind Second : 8;
 
-/// Third - The third conversion can be a qualification conversion
-/// or a function conversion.
+/// Third - The third conversion can be a qualification conversion.
 ImplicitConversionKind Third : 8;
 
 /// \brief Whether this is the deprecated conversion of a

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284778&r1=284777&r2=284778&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct 20 15:54:32 2016
@@ -8954,15 +8954,13 @@ public:
 ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
   QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
-bool *NonStandardCompositeType = nullptr,
-bool ConvertArgs = true);
+bool *NonStandardCompositeType = nullptr);
   QualType FindCompositePointerType(SourceLocation Loc,
 ExprResult &E1, ExprResult &E2,
-bool *NonStandardCompositeType = nullptr,
-bool ConvertArgs = true) {
+bool *NonStandardCompositeType = nullptr) {
 Expr *E1Tmp = E1.get(), *E2Tmp = E2.get();
-QualType Composite = FindCompositePointerType(
-Loc, E1Tmp, E2Tmp, NonStandardCompositeType, ConvertArgs);
+QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp,
+  NonStandardCompositeType);
 E1 = E1Tmp;
 E2 = E2Tmp;
 return Composite;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=284778&r1=284777&r2=284778&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 20 15:54:32 2016
@@ -3610,6 +3610,16 @@ Sema::PerformImplicitConversion(Expr *Fr
 // Nothing else to do.
 break;
 
+  case ICK_Function_Conversion:
+// If both sides are functions (or pointers/references to them), there 
could
+// be incompatible exception declarations.
+if (CheckExceptionSpecCompatibility(From, ToType))
+  return ExprError();
+
+From = ImpCastExprToType(From, ToType, CK_NoOp,
+ VK_RValue, /*BasePath=*/nullptr, CCK).get();
+break;
+
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion:
 if (ToType->isBooleanType()) {
@@ -3856,7 +3866,6 @@ Sema::PerformImplicitConversion(Expr *Fr
   case ICK_Lvalue_To_Rvalue:
   case ICK_Array_To_Pointer:
   case ICK_Function_To_Pointer:
-  case ICK_Function_Conversion:
   case ICK_Qualification:
   case ICK_Num_Conversion_Kinds:
   case ICK_C_Only_Conversion:
@@ -3869,16 +3878,6 @@ Sema::PerformImplicitConversion(Expr *Fr
 // Nothing to do.
 break;
 
-  case ICK_Function_Conversion:
-// If both sides are functions (or pointers/references to them), there 
could
-// be incompatible exception declarations.
-if (CheckExceptionSpecCompatibility(From, ToType))
-  return ExprError();
-
-From = ImpCastExprToType(From, ToType, CK_NoOp,
- VK_RValue, /*BasePath=*/nullptr, CCK).get();
-break;
-
   case ICK_Qualification: {
 // The qualification keeps the category of the inner expression, unless the
 // target type isn't a reference.
@@ -5394,17 +5393,6 @@ QualType Sema::CXXCheckConditionalOperan
 if (LHS.get()->getObjectKind() == OK_BitField ||
 RHS.get()->getObjectKind() == OK_BitField)
   OK = OK_BitField;
-
-// If we have function pointer types, unify them anyway to unify their
-// exception specifications

[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-20 Thread Steve O'Brien via cfe-commits
elsteveogrande updated this revision to Diff 75351.
elsteveogrande added a comment.

Fixed an error.  A newline is sometimes not appended prior to this `#include`.

When returning from an included file which doesn't have a trailing newline, the 
#include is stuck at the end of some other line, i.e. the include's own `#` 
isn't the first character in the line.

Added a new line if needed like the other code just above it.  I copied+pasted 
the `moveTo` as well.


https://reviews.llvm.org/D25153

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/PreprocessorOutputOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrintPreprocessedOutput.cpp
  test/Preprocessor/dump_import.h
  test/Preprocessor/dump_import.m
  test/Preprocessor/dump_include.c
  test/Preprocessor/dump_include.h

Index: test/Preprocessor/dump_include.h
===
--- /dev/null
+++ test/Preprocessor/dump_include.h
@@ -0,0 +1,2 @@
+#pragma once
+#define DUMP_INCLUDE_TESTVAL 1
Index: test/Preprocessor/dump_include.c
===
--- /dev/null
+++ test/Preprocessor/dump_include.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -w -E -dI -isystem %S -imacros %S/dump_include.h %s -o - | FileCheck %s
+// CHECK: {{^}}#__include_macros "/{{([^/]+/)+}}dump_
+// CHECK: {{^}}#include 
+#include "dump_include.h"
+#include_next "dump_include.h"
Index: test/Preprocessor/dump_import.m
===
--- /dev/null
+++ test/Preprocessor/dump_import.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E -dI %s -o - | FileCheck %s
+// CHECK: {{^}}#import "dump_
+
+// See also `dump_include.c` which tests other inclusion cases with `-dI`.
+
+#import "dump_import.h"
Index: test/Preprocessor/dump_import.h
===
--- /dev/null
+++ test/Preprocessor/dump_import.h
@@ -0,0 +1 @@
+#define DUMP_IMPORT_TESTVAL 1
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===
--- lib/Frontend/PrintPreprocessedOutput.cpp
+++ lib/Frontend/PrintPreprocessedOutput.cpp
@@ -93,13 +93,16 @@
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool DumpIncludeDirectives;
   bool UseLineDirectives;
   bool IsFirstFileEntered;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
-   bool defines, bool UseLineDirectives)
+   bool defines, bool DumpIncludeDirectives,
+   bool UseLineDirectives)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
+DumpIncludeDirectives(DumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives) {
 CurLine = 0;
 CurFilename += "";
@@ -320,20 +323,20 @@
   StringRef SearchPath,
   StringRef RelativePath,
   const Module *Imported) {
-  // When preprocessing, turn implicit imports into @imports.
-  // FIXME: This is a stop-gap until a more comprehensive "preprocessing with
-  // modules" solution is introduced.
   if (Imported) {
+// When preprocessing, turn implicit imports into @imports.
+// FIXME: This is a stop-gap until a more comprehensive "preprocessing with
+// modules" solution is introduced.
 startNewLineIfNeeded();
 MoveToLine(HashLoc);
 if (PP.getLangOpts().ObjC2) {
   OS << "@import " << Imported->getFullModuleName() << ";"
  << " /* clang -E: implicit import for \"" << File->getName()
  << "\" */";
 } else {
-  // FIXME: Preseve whether this was a
-  // #include/#include_next/#include_macros/#import.
-  OS << "#include "
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
  << (IsAngled ? '<' : '"')
  << FileName
  << (IsAngled ? '>' : '"')
@@ -344,6 +347,20 @@
 // line immediately.
 EmittedTokensOnThisLine = true;
 startNewLineIfNeeded();
+  } else {
+// Not a module import; it's a more vanilla inclusion of some file using one
+// of: #include, #import, #include_next, #include_macros.
+if (DumpIncludeDirectives) {
+  startNewLineIfNeeded();
+  MoveToLine(HashLoc);
+  const std::string TokenText = PP.getSpelling(IncludeTok);
+  assert(!TokenText.empty());
+  OS << "#" << TokenText << " "
+ << (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"')
+ << " /* clang -E -dI */";
+  setEmittedDirectiveOnThisLine();
+  startNewLineIfNeeded();
+}
   }
 }
 
@@ -751,7 +768,8 @@
   PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments);
 
   PrintPP

Re: r284753 - [c++1z] Teach composite pointer type computation how to compute the composite

2016-10-20 Thread Hans Wennborg via cfe-commits
On Thu, Oct 20, 2016 at 10:57 AM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Oct 20 12:57:33 2016
> New Revision: 284753
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284753&view=rev
> Log:
> [c++1z] Teach composite pointer type computation how to compute the composite
> pointer type of two function pointers with different noexcept specifications.
> While I'm here, also teach it how to merge dynamic exception specifications.

This caused asserts to fire when building Chromium. I've filed PR30749
with a repro, and reverted in r284778.

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


  1   2   >