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

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



Comment at: llvm/tools/clang/test/CodeGenCXX/vtable-coverage-gen.cpp:3
+// RUN: FileCheck %s < %t 
+// CHECK: @_ZTV8Category = linkonce_odr unnamed_addr constant {{.*}}, comdat,
+

I'm not sure I understood the purpose of this test, but It looks like the 
vtable for Category is generated in the IR with linkonce_odr without your patch.


https://reviews.llvm.org/D27410



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


Re: r290084 - clang-format: Allow "single column" list layout even if that violates the

2016-12-19 Thread Tobias Grosser via cfe-commits
Hi Daniel,

this commit introduce an unnecessary string split, which does not seem
to be an intended result of the formatting style change this commit
introduced:

BEFORE:

#define SCOP_STAT(NAME, DESC)

llvm::Statistic RejectStatistics[] = {
SCOP_STAT(CFG, ""),
SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
SCOP_STAT(UndefCond, "Undefined branch condition"),
SCOP_STAT(NonSimpleMemoryAccess,
  "Compilated access semantics (volatile or atomic)"),
};

AFTER:

#define SCOP_STAT(NAME, DESC)

llvm::Statistic RejectStatistics[] = {
SCOP_STAT(CFG, ""),
SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
SCOP_STAT(UndefCond, "Undefined branch condition"),
SCOP_STAT(NonSimpleMemoryAccess, "Compilated access semantics
(volatile or "
 "atomic)"

As this worked before, this seems to be a regression.

Best,
Tobias

On Mon, Dec 19, 2016, at 08:26 AM, Daniel Jasper via cfe-commits wrote:
> Author: djasper
> Date: Mon Dec 19 01:26:11 2016
> New Revision: 290084
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=290084&view=rev
> Log:
> clang-format: Allow "single column" list layout even if that violates the
> column limit.
> 
> Single-column layout basically means that we format the list with one
> element per line. Not doing that when there is a column limit violation
> doesn't change the fact that there is an item that doesn't fit within
> the column limit.
> 
> Before (with a column limit of 30):
>   std::vector a = {
>   , ,
>   , ,
>   aa, ,
>   aaa};
> 
> After:
>   std::vector a = {
>   ,
>   ,
>   ,
>   ,
>   aa,
>   ,
>   aaa};
> 
> (and previously we would have formatted like "After" it wasn't for the
> one
> item that is too long)
> 
> Modified:
> cfe/trunk/lib/Format/FormatToken.cpp
> cfe/trunk/unittests/Format/FormatTest.cpp
> 
> Modified: cfe/trunk/lib/Format/FormatToken.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=290084&r1=290083&r2=290084&view=diff
> ==
> --- cfe/trunk/lib/Format/FormatToken.cpp (original)
> +++ cfe/trunk/lib/Format/FormatToken.cpp Mon Dec 19 01:26:11 2016
> @@ -273,7 +273,7 @@ void CommaSeparatedList::precomputeForma
>continue;
>  
>  // Ignore layouts that are bound to violate the column limit.
> -if (Format.TotalWidth > Style.ColumnLimit)
> +if (Format.TotalWidth > Style.ColumnLimit && Columns > 1)
>continue;
>  
>  Formats.push_back(Format);
> @@ -287,7 +287,7 @@ CommaSeparatedList::getColumnFormat(unsi
> I = Formats.rbegin(),
> E = Formats.rend();
> I != E; ++I) {
> -if (I->TotalWidth <= RemainingCharacters) {
> +if (I->TotalWidth <= RemainingCharacters || I->Columns == 1) {
>if (BestFormat && I->LineCount > BestFormat->LineCount)
>  break;
>BestFormat = &*I;
> 
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290084&r1=290083&r2=290084&view=diff
> ==
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 19 01:26:11 2016
> @@ -6779,6 +6779,18 @@ TEST_F(FormatTest, FormatsBracedListsInC
>"  1, 22, 333, , 5, 66,
>777,\n"
>"  1, 22, 333, , 5, 66,
>777,\n"
>"  1, 22, 333, , 5, 66,
>777});");
> +
> +  // Allow "single-column" layout even if that violates the column
> limit. There
> +  // isn't going to be a better way.
> +  verifyFormat("std::vector a = {\n"
> +   ",\n"
> +   ",\n"
> +   ",\n"
> +   ",\n"
> +   "aa,\n"
> +   ",\n"
> +   "aaa};",
> +   getLLVMStyleWithColumns(30));
>  }
>  
>  TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r290084 - clang-format: Allow "single column" list layout even if that violates the

2016-12-19 Thread Daniel Jasper via cfe-commits
Yeah, I just saw that when fixing polly format. I'll take a look.

On Mon, Dec 19, 2016 at 9:05 AM, Tobias Grosser  wrote:

> Hi Daniel,
>
> this commit introduce an unnecessary string split, which does not seem
> to be an intended result of the formatting style change this commit
> introduced:
>
> BEFORE:
>
> #define SCOP_STAT(NAME, DESC)
>
> llvm::Statistic RejectStatistics[] = {
> SCOP_STAT(CFG, ""),
> SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
> SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
> SCOP_STAT(UndefCond, "Undefined branch condition"),
> SCOP_STAT(NonSimpleMemoryAccess,
>   "Compilated access semantics (volatile or atomic)"),
> };
>
> AFTER:
>
> #define SCOP_STAT(NAME, DESC)
>
> llvm::Statistic RejectStatistics[] = {
> SCOP_STAT(CFG, ""),
> SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
> SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
> SCOP_STAT(UndefCond, "Undefined branch condition"),
> SCOP_STAT(NonSimpleMemoryAccess, "Compilated access semantics
> (volatile or "
>  "atomic)"
>
> As this worked before, this seems to be a regression.
>
> Best,
> Tobias
>
> On Mon, Dec 19, 2016, at 08:26 AM, Daniel Jasper via cfe-commits wrote:
> > Author: djasper
> > Date: Mon Dec 19 01:26:11 2016
> > New Revision: 290084
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=290084&view=rev
> > Log:
> > clang-format: Allow "single column" list layout even if that violates the
> > column limit.
> >
> > Single-column layout basically means that we format the list with one
> > element per line. Not doing that when there is a column limit violation
> > doesn't change the fact that there is an item that doesn't fit within
> > the column limit.
> >
> > Before (with a column limit of 30):
> >   std::vector a = {
> >   , ,
> >   , ,
> >   aa, ,
> >   aaa};
> >
> > After:
> >   std::vector a = {
> >   ,
> >   ,
> >   ,
> >   ,
> >   aa,
> >   ,
> >   aaa};
> >
> > (and previously we would have formatted like "After" it wasn't for the
> > one
> > item that is too long)
> >
> > Modified:
> > cfe/trunk/lib/Format/FormatToken.cpp
> > cfe/trunk/unittests/Format/FormatTest.cpp
> >
> > Modified: cfe/trunk/lib/Format/FormatToken.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/
> FormatToken.cpp?rev=290084&r1=290083&r2=290084&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Format/FormatToken.cpp (original)
> > +++ cfe/trunk/lib/Format/FormatToken.cpp Mon Dec 19 01:26:11 2016
> > @@ -273,7 +273,7 @@ void CommaSeparatedList::precomputeForma
> >continue;
> >
> >  // Ignore layouts that are bound to violate the column limit.
> > -if (Format.TotalWidth > Style.ColumnLimit)
> > +if (Format.TotalWidth > Style.ColumnLimit && Columns > 1)
> >continue;
> >
> >  Formats.push_back(Format);
> > @@ -287,7 +287,7 @@ CommaSeparatedList::getColumnFormat(unsi
> > I = Formats.rbegin(),
> > E = Formats.rend();
> > I != E; ++I) {
> > -if (I->TotalWidth <= RemainingCharacters) {
> > +if (I->TotalWidth <= RemainingCharacters || I->Columns == 1) {
> >if (BestFormat && I->LineCount > BestFormat->LineCount)
> >  break;
> >BestFormat = &*I;
> >
> > Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/
> Format/FormatTest.cpp?rev=290084&r1=290083&r2=290084&view=diff
> > 
> ==
> > --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> > +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 19 01:26:11 2016
> > @@ -6779,6 +6779,18 @@ TEST_F(FormatTest, FormatsBracedListsInC
> >"  1, 22, 333, , 5, 66,
> >777,\n"
> >"  1, 22, 333, , 5, 66,
> >777,\n"
> >"  1, 22, 333, , 5, 66,
> >777});");
> > +
> > +  // Allow "single-column" layout even if that violates the column
> > limit. There
> > +  // isn't going to be a better way.
> > +  verifyFormat("std::vector a = {\n"
> > +   ",\n"
> > +   ",\n"
> > +   ",\n"
> > +   ",\n"
> > +   "aa,\n"
> > +   ",\n"
> > +   "aaa};",
> > +   getLLVMStyleWithColumns(30));
> >  }
> >
> >  TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
> >
> >
> > ___

Re: r290084 - clang-format: Allow "single column" list layout even if that violates the

2016-12-19 Thread Tobias Grosser via cfe-commits
On Mon, Dec 19, 2016, at 09:07 AM, Daniel Jasper wrote:
> Yeah, I just saw that when fixing polly format. I'll take a look.

You then probably also saw the second issue:

-Type *Params[] = {PointerType::getUnqual(FunctionType::get(
-  Builder.getVoidTy(), Builder.getInt8PtrTy(),
false)),
-  Builder.getInt8PtrTy(), Builder.getInt32Ty(),
LongType,
-  LongType, LongType};
+Type *Params[] = {
+PointerType::getUnqual(FunctionType::get(Builder.getVoidTy(),
Builder.getInt8PtrTy(), false)),
+Builder.getInt8PtrTy(),
+Builder.getInt32Ty(),
+LongType,
+LongType,
+LongType};

The lines are now longer than 80 columns, whereas earlier we managed to
remain within 80 columns.

Btw. thank you for updating Polly.

Best,
Tobias

 
> On Mon, Dec 19, 2016 at 9:05 AM, Tobias Grosser 
> wrote:
> 
> > Hi Daniel,
> >
> > this commit introduce an unnecessary string split, which does not seem
> > to be an intended result of the formatting style change this commit
> > introduced:
> >
> > BEFORE:
> >
> > #define SCOP_STAT(NAME, DESC)
> >
> > llvm::Statistic RejectStatistics[] = {
> > SCOP_STAT(CFG, ""),
> > SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
> > SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
> > SCOP_STAT(UndefCond, "Undefined branch condition"),
> > SCOP_STAT(NonSimpleMemoryAccess,
> >   "Compilated access semantics (volatile or atomic)"),
> > };
> >
> > AFTER:
> >
> > #define SCOP_STAT(NAME, DESC)
> >
> > llvm::Statistic RejectStatistics[] = {
> > SCOP_STAT(CFG, ""),
> > SCOP_STAT(InvalidTerminator, "Unsupported terminator instruction"),
> > SCOP_STAT(IrreducibleRegion, "Irreducible loops"),
> > SCOP_STAT(UndefCond, "Undefined branch condition"),
> > SCOP_STAT(NonSimpleMemoryAccess, "Compilated access semantics
> > (volatile or "
> >  "atomic)"
> >
> > As this worked before, this seems to be a regression.
> >
> > Best,
> > Tobias
> >
> > On Mon, Dec 19, 2016, at 08:26 AM, Daniel Jasper via cfe-commits wrote:
> > > Author: djasper
> > > Date: Mon Dec 19 01:26:11 2016
> > > New Revision: 290084
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=290084&view=rev
> > > Log:
> > > clang-format: Allow "single column" list layout even if that violates the
> > > column limit.
> > >
> > > Single-column layout basically means that we format the list with one
> > > element per line. Not doing that when there is a column limit violation
> > > doesn't change the fact that there is an item that doesn't fit within
> > > the column limit.
> > >
> > > Before (with a column limit of 30):
> > >   std::vector a = {
> > >   , ,
> > >   , ,
> > >   aa, ,
> > >   aaa};
> > >
> > > After:
> > >   std::vector a = {
> > >   ,
> > >   ,
> > >   ,
> > >   ,
> > >   aa,
> > >   ,
> > >   aaa};
> > >
> > > (and previously we would have formatted like "After" it wasn't for the
> > > one
> > > item that is too long)
> > >
> > > Modified:
> > > cfe/trunk/lib/Format/FormatToken.cpp
> > > cfe/trunk/unittests/Format/FormatTest.cpp
> > >
> > > Modified: cfe/trunk/lib/Format/FormatToken.cpp
> > > URL:
> > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/
> > FormatToken.cpp?rev=290084&r1=290083&r2=290084&view=diff
> > > 
> > ==
> > > --- cfe/trunk/lib/Format/FormatToken.cpp (original)
> > > +++ cfe/trunk/lib/Format/FormatToken.cpp Mon Dec 19 01:26:11 2016
> > > @@ -273,7 +273,7 @@ void CommaSeparatedList::precomputeForma
> > >continue;
> > >
> > >  // Ignore layouts that are bound to violate the column limit.
> > > -if (Format.TotalWidth > Style.ColumnLimit)
> > > +if (Format.TotalWidth > Style.ColumnLimit && Columns > 1)
> > >continue;
> > >
> > >  Formats.push_back(Format);
> > > @@ -287,7 +287,7 @@ CommaSeparatedList::getColumnFormat(unsi
> > > I = Formats.rbegin(),
> > > E = Formats.rend();
> > > I != E; ++I) {
> > > -if (I->TotalWidth <= RemainingCharacters) {
> > > +if (I->TotalWidth <= RemainingCharacters || I->Columns == 1) {
> > >if (BestFormat && I->LineCount > BestFormat->LineCount)
> > >  break;
> > >BestFormat = &*I;
> > >
> > > Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> > > URL:
> > > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/
> > Format/FormatTest.cpp?rev=290084&r1=290083&r2=290084&view=diff
> > > 
> > ==
> > > --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> > > +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 19 01:26:1

r290090 - clang-format: Fix regression introduced in r290084.

2016-12-19 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 19 02:40:56 2016
New Revision: 290090

URL: http://llvm.org/viewvc/llvm-project?rev=290090&view=rev
Log:
clang-format: Fix regression introduced in r290084.

We still want to try in linewrap within single elements of a 1-column
list.

After:
  Type *Params[] = {PointerType::getUnqual(FunctionType::get(
Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
Builder.getInt8PtrTy(),
Builder.getInt32Ty(),
LongType,
LongType,
LongType};

Before:
  No line break in the first element, so column limit violation.

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

Modified: cfe/trunk/lib/Format/FormatToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.cpp?rev=290090&r1=290089&r2=290090&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.cpp (original)
+++ cfe/trunk/lib/Format/FormatToken.cpp Mon Dec 19 02:40:56 2016
@@ -92,6 +92,14 @@ unsigned CommaSeparatedList::formatAfter
 
   // Find the best ColumnFormat, i.e. the best number of columns to use.
   const ColumnFormat *Format = getColumnFormat(RemainingCodePoints);
+
+  // Formatting with 1 Column isn't really a column layout, so we don't need 
the
+  // special logic here. We can just avoid bin packing any of the parameters.
+  if (Format && Format->Columns == 1) {
+State.Stack.back().AvoidBinPacking = true;
+return 0;
+  }
+
   // If no ColumnFormat can be used, the braced list would generally be
   // bin-packed. Add a severe penalty to this so that column layouts are
   // preferred if possible.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290090&r1=290089&r2=290090&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 19 02:40:56 2016
@@ -6641,7 +6641,7 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
   "std::this_thread::sleep_for(\n"
   "std::chrono::nanoseconds{ std::chrono::seconds{ 1 } } / 5);",
   ExtraSpaces);
-  verifyFormat("std::vector aaa{\n"
+  verifyFormat("std::vector 
aa{\n"
"aaa,\n"
"aa,\n"
"a,\n"


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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-19 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a reviewer: ioeric.
klimek added a comment.

+eric, who has some experience llvm::Error'ing our interfaces :)
llvm::ErrorOr seems like the right approach here?


https://reviews.llvm.org/D27440



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


[PATCH] D27575: [libcxxabi] Introduce an externally threaded libc++abi variant (take-2)

2016-12-19 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

Ping.


https://reviews.llvm.org/D27575



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


[PATCH] D27576: [libcxx] libc++ changes necessary for the externally threaded libcxxabi variant

2016-12-19 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath added a comment.

Ping.


https://reviews.llvm.org/D27576



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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-19 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

`llvm::ErrorOr` carries `std::error_code`. If you want richer information (e.g. 
error_code + error message), `llvm::Expcted` and `llvm::Error` are your 
friends.

FYI, if you only need error_code + error_message in the returned error, there 
is also `llvm::StringError`. And if you want to carry even more information in 
the errors, you can implement `llvm::ErrorInfo`, which is what we are doing in 
libTooling replacements library: 
https://github.com/llvm-mirror/clang/blob/master/include/clang/Tooling/Core/Replacement.h#L150


https://reviews.llvm.org/D27440



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


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

2016-12-19 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 19 04:09:25 2016
New Revision: 290092

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

This reverts commit r290080 as it leads to many Clang crashes, e.g.:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814

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

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=290092&r1=290091&r2=290092&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Dec 19 04:09:25 2016
@@ -3140,77 +3140,6 @@ public:
   friend class ASTDeclWriter;
 };
 
-/// Represents a pack of using declarations that a single
-/// using-declarator pack-expanded into.
-///
-/// \code
-/// template struct X : T... {
-///   using T::operator()...;
-///   using T::operator T...;
-/// };
-/// \endcode
-///
-/// In the second case above, the UsingPackDecl will have the name
-/// 'operator T' (which contains an unexpanded pack), but the individual
-/// UsingDecls and UsingShadowDecls will have more reasonable names.
-class UsingPackDecl final
-: public NamedDecl, public Mergeable,
-  private llvm::TrailingObjects {
-  void anchor() override;
-
-  /// The UnresolvedUsingValueDecl or UnresolvedUsingTypenameDecl from
-  /// which this waas instantiated.
-  NamedDecl *InstantiatedFrom;
-
-  /// The number of using-declarations created by this pack expansion.
-  unsigned NumExpansions;
-
-  UsingPackDecl(DeclContext *DC, NamedDecl *InstantiatedFrom,
-ArrayRef UsingDecls)
-  : NamedDecl(UsingPack, DC,
-  InstantiatedFrom ? InstantiatedFrom->getLocation()
-   : SourceLocation(),
-  InstantiatedFrom ? InstantiatedFrom->getDeclName()
-   : DeclarationName()),
-InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
-std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
-getTrailingObjects());
-  }
-
-public:
-  /// Get the using declaration from which this was instantiated. This will
-  /// always be an UnresolvedUsingValueDecl or an UnresolvedUsingTypenameDecl
-  /// that is a pack expansion.
-  NamedDecl *getInstantiatedFromUsingDecl() { return InstantiatedFrom; }
-
-  /// Get the set of using declarations that this pack expanded into. Note that
-  /// some of these may still be unresolved.
-  ArrayRef expansions() const {
-return llvm::makeArrayRef(getTrailingObjects(), 
NumExpansions);
-  }
-
-  static UsingPackDecl *Create(ASTContext &C, DeclContext *DC,
-   NamedDecl *InstantiatedFrom,
-   ArrayRef UsingDecls);
-
-  static UsingPackDecl *CreateDeserialized(ASTContext &C, unsigned ID,
-   unsigned NumExpansions);
-
-  SourceRange getSourceRange() const override LLVM_READONLY {
-return InstantiatedFrom->getSourceRange();
-  }
-
-  UsingPackDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const UsingPackDecl *getCanonicalDecl() const { return getFirstDecl(); }
-
-  static bool classof(const Decl *D) { return classofKind(D->getKind()); }
-  static bool classofKind(Kind K) { return K == UsingPack; }
-
-  friend class ASTDeclReader;
-  friend class ASTDeclWriter;
-  friend TrailingObjects;
-};
-
 /// \brief Represents a dependent using declaration which was not marked with
 /// \c typename.
 ///
@@ -3229,9 +3158,6 @@ class UnresolvedUsingValueDecl : public
   /// \brief The source location of the 'using' keyword
   Sour

[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2016-12-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D27827#625438, @erik.pilkington wrote:

> I seem to remember that mapping from kernel versions to marketing versions 
> was tossed around as a potential alternative to Gestalt. I think that the 
> problem was Apple sometimes introduces (or reserves the right to introduce) 
> new SDKs in a patch release (ie, Z in X.Y.Z), which wouldn't necessary imply 
> a new kernel version, and would still need to be queried by @available. This 
> makes it impossible to use kernel version in the general case (Or at least I 
> think, it would be nice if someone internal to Apple could confirm this?). 
> This rules out using `sysctl()` and the like.


This sounds like a legitimate concern, I'll try to get some information about 
this.

> AFAIK this just leaves `Gestalt()` and Objective-C's `NSProcessInfo`, the 
> latter would mean pulling in the Objective-C runtime, which would be 
> unfortunate for C users (using the `__builtin_available` spelling). I don't 
> think `Gestalt()` is in any danger of actually being removed, so we might as 
> well use it. The only alternative I know of to those would be manually 
> parsing the `SystemVersion.plist` XML file, but I think that might cause 
> problems with sandboxed processes (right?). Any thoughts here would be much 
> appreciated, `Gestalt()` is by no means a perfect solution.

Sandboxed applications are allowed to read that PLIST file, since 
https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html
 states the applications are permitted to read files that are world readable in 
`/System`. I confirmed that with a test sandboxed app as well. It would seem 
that reading that PLIST file is a good solution if we can get access to the 
PLIST APIs from compiler-rt (+ we can always fallback to `Gestalt`/`sysctl` if 
something goes wrong).

> Compiler-rt does seem like a good place it put this, should I move the 
> runtime code there instead?

Yes, please.

Btw, compiler-rt already has code that checks which version of macOS it's 
running on 
(https://github.com/llvm-project/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_mac.cc#L410).
 It uses `sysctl` as well. I'm not sure if we can somehow refactor and reuse 
this code or not (since ours will be in builtins), but at least it's a good 
starting point.

> Thanks for taking a look!
> Erik


https://reviews.llvm.org/D27827



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


[PATCH] D27673: [clang-move] Only move used helper declarations.

2016-12-19 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: test/clang-move/move-used-helper-decls.cpp:1
+// RUN: mkdir -p %T/used-helper-decls
+// RUN: cp %S/Inputs/helper_decls_test*  %T/used-helper-decls/

Can you also add test cases where class members are treated as the same node in 
the graph?



Comment at: test/clang-move/move-used-helper-decls.cpp:9
+
+// CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h"
+// CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}}

It'd be really helpful if you can provide a brief comment on what you are 
testing for each test case. 



Comment at: test/clang-move/move-used-helper-decls.cpp:202
+
+// CHECK-OLD-FUN2-H-NOT: inline void Fun2() {}

Maybe also add a test case to move all symbols in the old file.


https://reviews.llvm.org/D27673



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


r290093 - [clang-format] revert an unintended change in r288493 and add a test case.

2016-12-19 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Dec 19 04:41:05 2016
New Revision: 290093

URL: http://llvm.org/viewvc/llvm-project?rev=290093&view=rev
Log:
[clang-format] revert an unintended change in r288493 and add a test case.

Modified:
cfe/trunk/lib/Format/Format.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=290093&r1=290092&r2=290093&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Dec 19 04:41:05 2016
@@ -1545,7 +1545,7 @@ bool checkAndConsumeDirectiveWithName(Le
   bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
  Tok.is(tok::raw_identifier) &&
  Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&
- tok::raw_identifier;
+ Tok.is(tok::raw_identifier);
   if (Matched)
 Lex.LexFromRawLexer(Tok);
   return Matched;

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=290093&r1=290092&r2=290093&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Mon Dec 19 04:41:05 2016
@@ -714,6 +714,19 @@ TEST_F(CleanUpReplacementsTest, IfNDefWi
   EXPECT_EQ(Expected, apply(Code, Replaces));
 }
 
+TEST_F(CleanUpReplacementsTest, FakeHeaderGuard) {
+  std::string Code = "// comment \n"
+ "#ifndef X\n"
+ "#define 1\n";
+  std::string Expected = "// comment \n"
+ "#include \n"
+ "#ifndef X\n"
+ "#define 1\n";
+  tooling::Replacements Replaces =
+  toReplacements({createInsertion("#include ")});
+  EXPECT_EQ(Expected, apply(Code, Replaces));
+}
+
 TEST_F(CleanUpReplacementsTest, HeaderGuardWithComment) {
   std::string Code = "// comment \n"
  "#ifndef X // comment\n"


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


Re: r288493 - [ClangFormat] Only insert #include into the #include block in the beginning of the file.

2016-12-19 Thread Eric Liu via cfe-commits
Hi Mehdi,

This is an unintended change. I've reverted this line and added a test case
for this in r290093.

Thanks,
Eric

On Fri, Dec 16, 2016 at 7:02 PM Mehdi Amini  wrote:

Hi Eric,

> On Dec 2, 2016, at 3:01 AM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>
> Author: ioeric
> Date: Fri Dec  2 05:01:43 2016
> New Revision: 288493
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288493&view=rev
> Log:
> [ClangFormat] Only insert #include into the #include block in the
beginning of the file.
>
> Summary:
> This avoid inserting #include into:
> - raw string literals containing #include.
> - #if block.
> - Special #include among declarations (e.g. functions).
>
> Reviewers: djasper
>
> Subscribers: cfe-commits, klimek
>
> Differential Revision: https://reviews.llvm.org/D26909
>
> Modified:
>cfe/trunk/include/clang/Format/Format.h
>cfe/trunk/lib/Format/Format.cpp
>cfe/trunk/unittests/Format/CleanupTest.cpp
>
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=288493&r1=288492&r2=288493&view=diff
>
==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Fri Dec  2 05:01:43 2016
> @@ -786,7 +786,14 @@ formatReplacements(StringRef Code, const
> /// This also supports inserting/deleting C++ #include directives:
> /// - If a replacement has offset UINT_MAX, length 0, and a replacement
text
> ///   that is an #include directive, this will insert the #include into
the
> -///   correct block in the \p Code.
> +///   correct block in the \p Code. When searching for points to insert
new
> +///   header, this ignores #include's after the #include block(s) in the
> +///   beginning of a file to avoid inserting headers into code sections
where
> +///   new #include's should not be added by default. These code sections
> +///   include:
> +/// - raw string literals (containing #include).
> +/// - #if blocks.
> +/// - Special #include's among declarations (e.g. functions).
> /// - If a replacement has offset UINT_MAX, length 1, and a replacement
text
> ///   that is the name of the header to be removed, the header will be
removed
> ///   from \p Code if it exists.
>
> Modified: cfe/trunk/lib/Format/Format.cpp
> URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=288493&r1=288492&r2=288493&view=diff
>
==
> --- cfe/trunk/lib/Format/Format.cpp (original)
> +++ cfe/trunk/lib/Format/Format.cpp Fri Dec  2 05:01:43 2016
> @@ -1514,10 +1514,23 @@ inline bool isHeaderDeletion(const tooli
>   return Replace.getOffset() == UINT_MAX && Replace.getLength() == 1;
> }
>
> -void skipComments(Lexer &Lex, Token &Tok) {
> -  while (Tok.is(tok::comment))
> -if (Lex.LexFromRawLexer(Tok))
> -  return;
> +// Returns the offset after skipping a sequence of tokens, matched by \p
> +// GetOffsetAfterSequence, from the start of the code.
> +// \p GetOffsetAfterSequence should be a function that matches a
sequence of
> +// tokens and returns an offset after the sequence.
> +unsigned getOffsetAfterTokenSequence(
> +StringRef FileName, StringRef Code, const FormatStyle &Style,
> +std::function
> +GetOffsetAfterSequense) {
> +  std::unique_ptr Env =
> +  Environment::CreateVirtualEnvironment(Code, FileName,
/*Ranges=*/{});
> +  const SourceManager &SourceMgr = Env->getSourceManager();
> +  Lexer Lex(Env->getFileID(), SourceMgr.getBuffer(Env->getFileID()),
SourceMgr,
> +getFormattingLangOpts(Style));
> +  Token Tok;
> +  // Get the first token.
> +  Lex.LexFromRawLexer(Tok);
> +  return GetOffsetAfterSequense(SourceMgr, Lex, Tok);
> }
>
> // Check if a sequence of tokens is like "# ". If
it is,
> @@ -1527,31 +1540,88 @@ bool checkAndConsumeDirectiveWithName(Le
>   bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&
>  Tok.is(tok::raw_identifier) &&
>  Tok.getRawIdentifier() == Name &&
!Lex.LexFromRawLexer(Tok) &&
> - Tok.is(tok::raw_identifier);
> + tok::raw_identifier;


Can you elaborate on this line change? I don’t get it. (It was flagged by
coverity).

Thanks,

—
Mehdi




>   if (Matched)
> Lex.LexFromRawLexer(Tok);
>   return Matched;
> }
>
> +void skipComments(Lexer &Lex, Token &Tok) {
> +  while (Tok.is(tok::comment))
> +if (Lex.LexFromRawLexer(Tok))
> +  return;
> +}
> +
> +// Returns the offset after header guard directives and any comments
> +// before/after header guards. If no header guard presents in the code,
this
> +// will returns the offset after skipping all comments from the start of
the
> +// code.
> unsigned getOffsetAfterHeaderGuardsAndComments(StringRef FileName,
>StringRef Code,
>   

Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-19 Thread Piotr Padlewski via cfe-commits
Firstly, please respond in phabricator if it is possible. When you send
email it doesn't appear in phabricator, it's probably a bug.

2016-12-19 8:00 GMT+01:00 Mads Ravn :

> Hi Piotr,
>
> Thank you for your detailed comments :)
>
> I would love some help with the other fixit. I have some notes on it at
> home. But my main catch is that is an implicit cast to boolean from
> str.compare(str) with maybe an ! in front of it. And I need to fix that to
> str.compare(str) == 0 or str.compare(str) != 0.
>
> Why fix it to something, that you will want to fix it again to str == str
and str != str?
I guess you just have to match parent of this expr is negation or anything,
bind negation to some name and then check if you matched to the negation or
not.


> Where should I put the warning in a static const global variable? Is it
> still in StringCompare.cpp or do we have a  joint files for these?
>
> Yep, StringCompare.cpp, just like in other checks.

> Best regards,
> Mads Ravn
>
> On Sun, Dec 18, 2016 at 11:26 PM Piotr Padlewski via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> Prazek added a comment.
>>
>> Do you need some help with implementing the other fixit, or you just need
>> some extra time? It seems to be almost the same as your second fixit
>>
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.cpp:69-70
>> +diag(Matched->getLocStart(),
>> + "do not use 'compare' to test equality of strings; "
>> + "use the string equality operator instead");
>> +
>> 
>> Take this warning to some static const global variable
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.cpp:71
>> + "use the string equality operator instead");
>> +
>> +  if (const auto *Matched = Result.Nodes.getNodeAs("match2")) {
>> 
>> match1 and match2 are in different matchers (passed to register matchers)?
>>
>> If so put return here after diag to finish control flow for this case.
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.cpp:81
>> +  auto Diag = diag(Matched->getLocStart(),
>> +   "do not use 'compare' to test equality of
>> strings; "
>> +   "use the string equality operator instead");
>> 
>> and use it here
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.h:10-11
>> +
>> +#ifndef STRING_COMPARE_CHECK_H
>> +#define STRING_COMPARE_CHECK_H
>> +
>> 
>> This should be much longer string. Do you know about ./add_new_check?
>>
>> Please make one similar to other checks
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.h:36
>> +
>> +#endif // STRING_COMPARE_CHECK_H
>> 
>> DITTO
>>
>>
>> 
>> Comment at: test/clang-tidy/misc-string-compare.cpp:35-40
>> +  if (str1.compare(str2)) {
>> +  }
>> +  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to
>> test equality of strings; use the string equality operator instead
>> [misc-string-compare]
>> +  if (!str1.compare(str2)) {
>> +  }
>> +  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: do not use 'compare' to
>> test equality of strings; use the string equality operator instead
>> [misc-string-compare]
>> 
>> Why this one doesn't have fixit hint?
>>
>>
>> 
>> Comment at: test/clang-tidy/misc-string-compare.cpp:70
>> +  }
>> +  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to
>> test equality of strings;
>> +  if (str3->compare(str2) == 0) {
>> 
>> no fixit?
>>
>>
>> https://reviews.llvm.org/D27210
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-19 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

The example of this kind of check is here:
https://reviews.llvm.org/D27806

I am not sure if it make sense to put it as clang warning.

After a little bit of thinking I guess name "typos" would be better, because I 
want to look for checks that are mostly typos (which are obvious btw) but it 
would make it more concrete.


https://reviews.llvm.org/D27815



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-12-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

This looks good to me. It would be nice if we could get rid of the 2nd 
`expected expression` error in `auto s0 = S1{[name=]() {}};`, but it can be 
done later.


https://reviews.llvm.org/D25206



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


r290094 - clang-format: Slightly tweak the behavior of <<-wrapping.

2016-12-19 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Dec 19 05:14:23 2016
New Revision: 290094

URL: http://llvm.org/viewvc/llvm-project?rev=290094&view=rev
Log:
clang-format: Slightly tweak the behavior of <<-wrapping.

Before:
  SomeLongLoggingStatementOrMacro() << "Some long text "
<< some_variable << "\n";

Before:
  SomeLongLoggingStatementOrMacro()
  << "Some long text " << some_variable << "\n";

Short logging statements are already special cased in a different part
of the code.

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=290094&r1=290093&r2=290094&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Dec 19 05:14:23 2016
@@ -460,7 +460,7 @@ unsigned ContinuationIndenter::addTokenO
   Penalty += State.NextToken->SplitPenalty;
 
   // Breaking before the first "<<" is generally not desirable if the LHS is
-  // short. Also always add the penalty if the LHS is split over mutliple lines
+  // short. Also always add the penalty if the LHS is split over multiple lines
   // to avoid unnecessary line breaks that just work around this penalty.
   if (NextNonComment->is(tok::lessless) &&
   State.Stack.back().FirstLessLess == 0 &&

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=290094&r1=290093&r2=290094&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Dec 19 05:14:23 2016
@@ -2007,8 +2007,13 @@ unsigned TokenAnnotator::splitPenalty(co
   if (Right.isOneOf(tok::lessless, tok::plus) && Left.isLabelString() &&
   (Right.NextOperator || Right.OperatorIndex != 1))
 return 25;
-  if (Right.is(tok::lessless))
-return 1; // Breaking at a << is really cheap.
+  if (Right.is(tok::lessless)) {
+// Breaking at a << is really cheap.
+if (!Left.is(tok::r_paren) || Right.OperatorIndex > 0)
+  // Slightly prefer to break before the first one in log-like statements.
+  return 2;
+return 1;
+  }
   if (Left.is(TT_ConditionalExpr))
 return prec::Conditional;
   prec::Level Level = Left.getPrecedence();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=290094&r1=290093&r2=290094&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Dec 19 05:14:23 2016
@@ -5092,6 +5092,9 @@ TEST_F(FormatTest, AlignsPipes) {
   " << \n"
   " << ;");
   verifyFormat(
+  "()\n"
+  "<<  << ;");
+  verifyFormat(
   "llvm::outs() << \"a\"\n"
   "\"b\"\n"
   " << 
\"c\";");


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


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

2016-12-19 Thread Renato Golin via cfe-commits
On 19 December 2016 at 11:28, Daniel Jasper via cfe-commits
 wrote:
> I have reverted this in r290092 as it was leading to Clang crashes on the
> bots and elsewhere, e.g.:
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814

Hi Daniel, Richard,

This is will red on our LNT bot, which started with this commit:

http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1354

and still has the same failures on the last build:

http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1360

this is one of the 5 different failures we have in all our bots...
After so many fix-patches and reverts, I'm not surprised we got into
this corner of mayhem.

I'd like to ask people a bit more care and worry about the bots.

Most of the time, reverting the whole patch and talking to the bot
owners is a much better strategy than push-fix a bunch of trail and
errors.

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


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

2016-12-19 Thread Daniel Jasper via cfe-commits
I don't understand. This *is* a revert of the whole patch.

On Mon, Dec 19, 2016 at 1:26 PM, Renato Golin 
wrote:

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


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

2016-12-19 Thread Renato Golin via cfe-commits
On 19 December 2016 at 12:27, Daniel Jasper  wrote:
> I don't understand. This *is* a revert of the whole patch.

My bad, your revert hadn't gone through:

http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1361

Now it's green.

Sorry, we're dealing with 4 different cluster-plucks today.

I hate Mondays.

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


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

2016-12-19 Thread Daniel Jasper via cfe-commits
Oh, I completely understand, I am doing the same here :)

On Mon, Dec 19, 2016 at 1:38 PM, Renato Golin 
wrote:

> On 19 December 2016 at 12:27, Daniel Jasper  wrote:
> > I don't understand. This *is* a revert of the whole patch.
>
> My bad, your revert hadn't gone through:
>
> http://lab.llvm.org:8011/builders/clang-native-arm-lnt/builds/1361
>
> Now it's green.
>
> Sorry, we're dealing with 4 different cluster-plucks today.
>
> I hate Mondays.
>
> --renato
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-12-19 Thread Renato Golin via cfe-commits
On 19 December 2016 at 12:39, Daniel Jasper  wrote:
> Oh, I completely understand, I am doing the same here :)

Btw, this also happened:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/582

It seems Clang lost the ability to find the libstdc++:

CMake Error at cmake/modules/CheckCompilerVersion.cmake:38 (message):
  Host Clang must be able to find libstdc++4.8 or newer!

Your revert did fix the issue:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/587

So when this comes back, it needs to also fix this problem.

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


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

2016-12-19 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, cfe-commits, yaxunl.

https://reviews.llvm.org/D27917

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


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


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

[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

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

In https://reviews.llvm.org/D27440#626415, @ioeric wrote:

> `llvm::ErrorOr` carries `std::error_code`. If you want richer information 
> (e.g. error_code + error message), `llvm::Expcted` and `llvm::Error` are 
> your friends.
>
> FYI, if you only need error_code + error_message in the returned error, there 
> is also `llvm::StringError`. And if you want to carry even more information 
> in the errors, you can implement `llvm::ErrorInfo`, which is what we are 
> doing in libTooling replacements library: 
> https://github.com/llvm-mirror/clang/blob/master/include/clang/Tooling/Core/Replacement.h#L150


Thanks, I'll check these out! Btw, I noticed that the clang-format tests are 
non-Windows due to path assumptions. Is this a lost cause, or just something no 
one's bothered to look into yet?


https://reviews.llvm.org/D27440



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


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-19 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D27440#626477, @amaiorano wrote:

> In https://reviews.llvm.org/D27440#626415, @ioeric wrote:
>
> > `llvm::ErrorOr` carries `std::error_code`. If you want richer information 
> > (e.g. error_code + error message), `llvm::Expcted` and `llvm::Error` are 
> > your friends.
> >
> > FYI, if you only need error_code + error_message in the returned error, 
> > there is also `llvm::StringError`. And if you want to carry even more 
> > information in the errors, you can implement `llvm::ErrorInfo`, which is 
> > what we are doing in libTooling replacements library: 
> > https://github.com/llvm-mirror/clang/blob/master/include/clang/Tooling/Core/Replacement.h#L150
>
>
> Thanks, I'll check these out! Btw, I noticed that the clang-format tests are 
> non-Windows due to path assumptions. Is this a lost cause, or just something 
> no one's bothered to look into yet?


No one's bothered looking into it yet.


https://reviews.llvm.org/D27440



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


[PATCH] D22507: Clang-tidy - Enum misuse check

2016-12-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

A few more notes, all fine for a follow up.




Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:202
+
+  const auto *LhsExpr = Result.Nodes.getNodeAs("lhsExpr");
+  const auto *RhsExpr = Result.Nodes.getNodeAs("rhsExpr");

Looks like you're doing exactly same thing twice for lhs and rhs. Pull this out 
to a function. Fine for a follow up.



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:212-213
+  RhsDecExpr ? dyn_cast(RhsDecExpr->getDecl()) : nullptr;
+  bool LhsVar = !LhsConstant;
+  bool RhsVar = !RhsConstant;
+

There's not much value in these variables.



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:215-219
+  int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec);
+  ValueRange VR(EnumDec);
+  int EnumLen = enumLength(EnumDec);
+  if (!isPossiblyBitMask(NonPowOfTwoCounter, EnumLen, VR, EnumDec))
+return;

This code doesn't need the lhs/rhs variable declared above it. Move it up.



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:220-227
+  // Report left hand side parameter if neccessary.
+  if (LhsVar) {
+diag(EnumDec->getInnerLocStart(), BitmaskVarErrorMessage);
+diag(LhsExpr->getExprLoc(), BitmaskNoteMessage, DiagnosticIDs::Note);
+  } else if (isNonPowerOf2NorNullLiteral(LhsConstant)) {
+diag(LhsConstant->getSourceRange().getBegin(), BitmaskErrorMessage);
+diag(LhsExpr->getExprLoc(), BitmaskNoteMessage, DiagnosticIDs::Note);

This code can be pulled to a function / method to avoid repeating it twice 
(starting from the `  const auto *LhsExpr = 
Result.Nodes.getNodeAs("lhsExpr");` part).



Comment at: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst:31
+
+===
+

alexfh wrote:
> This notation is used to make the previous line a heading. Doesn't seem to be 
> the case here. See http://llvm.org/docs/SphinxQuickstartTemplate.html for 
> some examples. Please also try to build your docs to check for obvious issues.
This is not done yet.


https://reviews.llvm.org/D22507



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


[PATCH] D22507: Clang-tidy - Enum misuse check

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



Comment at: clang-tidy/misc/SuspiciousEnumUsageCheck.cpp:31
+"enum type seems like a bitmask (contains mostly "
+"power-of-2 literals) but some literal(s) are not a power-of-2";
+

Please drop the `(s)` from the diagnostic. The phrase "but some literal are 
not" is incorrect. Alternatively, you could use the `%plural` diagnostic 
modifier (see `note_constexpr_baa_value_insufficient_alignment` in 
DiagnosticASTKinds.td for an example usage).


https://reviews.llvm.org/D22507



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


[PATCH] D22910: Add support for CXXOperatorCallExpr in Expr::HasSideEffects

2016-12-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D22910#601083, @Abpostelnicu wrote:

> Can someone please show me an example on how to write a test for this patch?


You could test this with anything that diagnoses side effects in an unevaluated 
context (look for `warn_side_effects_unevaluated_context` diagnostics), such as 
use as the operand to `sizeof`.


https://reviews.llvm.org/D22910



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


[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

2016-12-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 81950.
arphaman marked an inline comment as done.
arphaman added a comment.

The updated patch renames the attribute to 
`loads_format_specifier_value_using_key` and addresses Aaron's comments


Repository:
  rL LLVM

https://reviews.llvm.org/D27165

Files:
  include/clang/Analysis/Analyses/FormatString.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/Analysis/PrintfFormatString.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-format_arg.c
  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
@@ -302,3 +302,21 @@
 }
 
 @end
+
+@interface FormatDynamicKeyArg
+
+- (NSString *)load:(NSString *)key __attribute__((loads_format_specifier_value_using_key(1)));
+
+@end
+
+void testFormatDynamicKeyArg(FormatDynamicKeyArg *m) {
+  // Don't warn when the key has no formatting specifiers
+  NSLog([m load:@"key"], @"foo");
+  NSLog([m load:@""]);
+
+  // Warn normally when the key has formatting specifiers
+  NSLog([m load:@"correct %d"], 2);
+  NSLog([m load:@"warn %d"], "off"); // expected-warning {{format specifies type 'int' but the argument has type 'char *'}}
+  NSLog([m load:@"%@ %@"], @"name"); // expected-warning {{more '%' conversions than data arguments}}
+  NSLog([m load:@"Warn again %@"], @"name", @"void"); // expected-warning {{data argument not used by format string}}
+}
Index: test/Sema/attr-format_arg.c
===
--- test/Sema/attr-format_arg.c
+++ test/Sema/attr-format_arg.c
@@ -11,3 +11,19 @@
   printf(f("%d"), 123);
   printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
 }
+
+const char *loadFormattingValue(const char *key) __attribute__((loads_format_specifier_value_using_key(1)));
+
+void testFormatDynamicKeyArg() {
+  // Don't warn when the key has no formatting specifiers
+  printf(loadFormattingValue("key"), "foo");
+
+  // Warn normally when the key has formatting specifiers
+  printf(loadFormattingValue("%d"), 123);
+  printf(loadFormattingValue("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
+}
+
+const char *formatKeyArgError1(const char *format)
+  __attribute__((loads_format_specifier_value_using_key("foo")));  // expected-error{{'loads_format_specifier_value_using_key' attribute requires parameter 1 to be an integer constant}}
+const char *formatKeyArgError2(const char *format)
+  __attribute__((loads_format_specifier_value_using_key(0)));  // expected-error{{'loads_format_specifier_value_using_key' attribute parameter 1 is out of bounds}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2748,13 +2748,14 @@
  Attr.getAttributeSpellingListIndex()));
 }
 
-/// Handle __attribute__((format_arg((idx attribute based on
-/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
-static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+/// Checks a format_arg or loads_format_specifier_value_using_key attribute
+/// and returns true if it has any errors.
+static bool checkFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr,
+   llvm::APSInt &Val) {
   Expr *IdxExpr = Attr.getArgAsExpr(0);
   uint64_t Idx;
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
-return;
+return true;
 
   // Make sure the format string is really a string.
   QualType Ty = getFunctionOrMethodParamType(D, Idx);
@@ -2767,7 +2768,7 @@
 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
 << "a string type" << IdxExpr->getSourceRange()
 << getFunctionOrMethodParamRange(D, 0);
-return;
+return true;
   }
   Ty = getFunctionOrMethodResultType(D);
   if (!isNSStringType(Ty, S.Context) &&
@@ -2777,20 +2778,38 @@
 S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
 << (NotNSStringTy ? "string type" : "NSString")
 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
-return;
+return true;
   }
 
   // We cannot use the Idx returned from checkFunctionOrMethodParameterIndex
   // because that has corrected for the implicit this parameter, and is zero-
   // based.  The attribute expects what the user wrote explicitly.
-  llvm::APSInt Val;
   IdxExpr->EvaluateAsInt(Val, S.Context);
+  return false;
+}
 
+/// Handle __attribute__((format_arg((idx attribute based on
+/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
+static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  llvm::APSInt Val;
+  if (checkFormatArgAttr(S, D, Attr, Val))
+return;
   D->addAttr(::new (S.Context)
  

[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

2016-12-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/Attr.td:862
+def FormatDynamicKeyArg : InheritableAttr {
+  let Spellings = [GCC<"format_dynamic_key_arg">];
+  let Args = [IntArgument<"FormatIdx">];

aaron.ballman wrote:
> Does GCC support this attribute as well? If not, this should use the GNU 
> spelling instead of the GCC one. Also, should this have a C++11 spelling in 
> the clang namespace?
> 
> The name doesn't really convey much about what the attribute is doing, mostly 
> because it doesn't seem obvious what "key" means.
> 
> It seems that the crux of what this attribute says is that the attributed 
> function accepts a string argument of a format specifier and returns the same 
> format specifier. Perhaps `returns_format_specifier` is a better name?
> Does GCC support this attribute as well? If not, this should use the GNU 
> spelling instead of the GCC one. 

No, it doesn't. Thanks for pointing that out, I fixed it.

> Also, should this have a C++11 spelling in the clang namespace?

I don't know, is that required for new attributes? I don't need the C++11 
spelling personally, and I don't know if there is anyone else who's interested 
in this attribute.  

> The name doesn't really convey much about what the attribute is doing, mostly 
> because it doesn't seem obvious what "key" means.
> 
> It seems that the crux of what this attribute says is that the attributed 
> function accepts a string argument of a format specifier and returns the same 
> format specifier. Perhaps returns_format_specifier is a better name?

You're right, the name should convey the intended meaning better. I switched to 
`loads_format_specifier_value_using_key`, how does that sound?
I think it sounds better than just `returns_format_specifier` because I would 
like to see this attribute used only for a particular kind of function. This 
kind of function should load the value at runtime using the key from a 
platform-specific file/database that might also be accessible at compile-time. 
It shouldn't be used for functions that might just modify the given key, which, 
IMO, `returns_format_specifier` can imply.


Repository:
  rL LLVM

https://reviews.llvm.org/D27165



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


[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

2016-12-19 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 81952.
arphaman added a comment.

Update to fix a test failure.


Repository:
  rL LLVM

https://reviews.llvm.org/D27165

Files:
  include/clang/Analysis/Analyses/FormatString.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/Analysis/PrintfFormatString.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-format_arg.c
  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
@@ -302,3 +302,21 @@
 }
 
 @end
+
+@interface FormatDynamicKeyArg
+
+- (NSString *)load:(NSString *)key __attribute__((loads_format_specifier_value_using_key(1)));
+
+@end
+
+void testFormatDynamicKeyArg(FormatDynamicKeyArg *m) {
+  // Don't warn when the key has no formatting specifiers
+  NSLog([m load:@"key"], @"foo");
+  NSLog([m load:@""]);
+
+  // Warn normally when the key has formatting specifiers
+  NSLog([m load:@"correct %d"], 2);
+  NSLog([m load:@"warn %d"], "off"); // expected-warning {{format specifies type 'int' but the argument has type 'char *'}}
+  NSLog([m load:@"%@ %@"], @"name"); // expected-warning {{more '%' conversions than data arguments}}
+  NSLog([m load:@"Warn again %@"], @"name", @"void"); // expected-warning {{data argument not used by format string}}
+}
Index: test/Sema/attr-format_arg.c
===
--- test/Sema/attr-format_arg.c
+++ test/Sema/attr-format_arg.c
@@ -11,3 +11,19 @@
   printf(f("%d"), 123);
   printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
 }
+
+const char *loadFormattingValue(const char *key) __attribute__((loads_format_specifier_value_using_key(1)));
+
+void testFormatDynamicKeyArg() {
+  // Don't warn when the key has no formatting specifiers
+  printf(loadFormattingValue("key"), "foo");
+
+  // Warn normally when the key has formatting specifiers
+  printf(loadFormattingValue("%d"), 123);
+  printf(loadFormattingValue("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
+}
+
+const char *formatKeyArgError1(const char *format)
+  __attribute__((loads_format_specifier_value_using_key("foo")));  // expected-error{{'loads_format_specifier_value_using_key' attribute requires parameter 1 to be an integer constant}}
+const char *formatKeyArgError2(const char *format)
+  __attribute__((loads_format_specifier_value_using_key(0)));  // expected-error{{'loads_format_specifier_value_using_key' attribute parameter 1 is out of bounds}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2748,13 +2748,14 @@
  Attr.getAttributeSpellingListIndex()));
 }
 
-/// Handle __attribute__((format_arg((idx attribute based on
-/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
-static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+/// Checks a format_arg or loads_format_specifier_value_using_key attribute
+/// and returns true if it has any errors.
+static bool checkFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr,
+   llvm::APSInt &Val) {
   Expr *IdxExpr = Attr.getArgAsExpr(0);
   uint64_t Idx;
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
-return;
+return true;
 
   // Make sure the format string is really a string.
   QualType Ty = getFunctionOrMethodParamType(D, Idx);
@@ -2767,7 +2768,7 @@
 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
 << "a string type" << IdxExpr->getSourceRange()
 << getFunctionOrMethodParamRange(D, 0);
-return;
+return true;
   }
   Ty = getFunctionOrMethodResultType(D);
   if (!isNSStringType(Ty, S.Context) &&
@@ -2777,20 +2778,38 @@
 S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
 << (NotNSStringTy ? "string type" : "NSString")
 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
-return;
+return true;
   }
 
   // We cannot use the Idx returned from checkFunctionOrMethodParameterIndex
   // because that has corrected for the implicit this parameter, and is zero-
   // based.  The attribute expects what the user wrote explicitly.
-  llvm::APSInt Val;
   IdxExpr->EvaluateAsInt(Val, S.Context);
+  return false;
+}
 
+/// Handle __attribute__((format_arg((idx attribute based on
+/// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
+static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  llvm::APSInt Val;
+  if (checkFormatArgAttr(S, D, Attr, Val))
+return;
   D->addAttr(::new (S.Context)
  FormatArgAttr(Attr.getRange(), S.Context, Val.getZExtValue(),
Attr.getAttributeSpellingListIndex()));

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

2016-12-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaType.cpp:1505
+  S.getLangOpts().OpenCLVersion < 120 &&
+  !S.getOpenCLOptions().cl_khr_fp64) {
+S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)

Please update with clang ToT since OpenCLOptions has interface changes.


https://reviews.llvm.org/D27917



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


r290110 - [ARM] Add missing -backend-option for -arm-execute-only

2016-12-19 Thread Prakhar Bahuguna via cfe-commits
Author: prakhar
Date: Mon Dec 19 09:43:33 2016
New Revision: 290110

URL: http://llvm.org/viewvc/llvm-project?rev=290110&view=rev
Log:
[ARM] Add missing -backend-option for -arm-execute-only

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-execute-only.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290110&r1=290109&r2=290110&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 19 09:43:33 2016
@@ -1158,6 +1158,7 @@ static void getARMTargetFeatures(const T
   D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << 
B->getAsString(Args);
   }
 
+  CmdArgs.push_back("-backend-option");
   CmdArgs.push_back("-arm-execute-only");
 }
   }

Modified: cfe/trunk/test/Driver/arm-execute-only.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-execute-only.c?rev=290110&r1=290109&r2=290110&view=diff
==
--- cfe/trunk/test/Driver/arm-execute-only.c (original)
+++ cfe/trunk/test/Driver/arm-execute-only.c Mon Dec 19 09:43:33 2016
@@ -91,8 +91,8 @@
 // RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
 
 //
-// CHECK-NO-EXECUTE-ONLY-NOT: "-arm-execute-only"
-// CHECK-EXECUTE-ONLY: "-arm-execute-only"
+// CHECK-NO-EXECUTE-ONLY-NOT: "-backend-option" "-arm-execute-only"
+// CHECK-EXECUTE-ONLY: "-backend-option" "-arm-execute-only"
 
 // CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for 
the thumbv6m sub-architecture
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be 
specified with '-mno-movt'


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


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

2016-12-19 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud updated this revision to Diff 81953.
aaboud marked 3 inline comments as done.
aaboud added a comment.

Addressed comments by Reid and David.


https://reviews.llvm.org/D27641

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/Inputs/debug-info-file-checksum.c
  test/CodeGen/debug-info-file-checksum.c

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -442,6 +442,10 @@
   /// Remap a given path with the current debug prefix map
   std::string remapDIPath(StringRef) const;
 
+  /// Get the file checksum debug info for input file ID.
+  llvm::DIFile::ChecksumKind getChecksum(FileID FID,
+ SmallString<32> &Checksum) const;
+
   /// Get the file debug info descriptor for the input location.
   llvm::DIFile *getOrCreateFile(SourceLocation Loc);
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -41,6 +41,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
 using namespace clang;
 using namespace clang::CodeGen;
@@ -320,19 +321,46 @@
   return StringRef();
 }
 
+llvm::DIFile::ChecksumKind
+CGDebugInfo::getChecksum(FileID FID, SmallString<32> &Checksum) const {
+  Checksum.clear();
+
+  if (!CGM.getCodeGenOpts().EmitCodeView)
+return llvm::DIFile::CSK_None;
+
+  SourceManager &SM = CGM.getContext().getSourceManager();
+  bool Invalid;
+  llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid);
+  if (Invalid)
+return llvm::DIFile::CSK_None;
+
+  llvm::MD5 Hash;
+  llvm::MD5::MD5Result Result;
+
+  Hash.update(MemBuffer->getBuffer());
+  Hash.final(Result);
+
+  Hash.stringifyResult(Result, Checksum);
+  return llvm::DIFile::CSK_MD5;
+}
+
 llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
   if (!Loc.isValid())
 // If Location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getFile()->getChecksumKind(),
+   TheCU->getFile()->getChecksum());
 
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
   if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
 // If the location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getFile()->getChecksumKind(),
+   TheCU->getFile()->getChecksum());
 
   // Cache the results.
   const char *fname = PLoc.getFilename();
@@ -344,16 +372,22 @@
   return cast(V);
   }
 
+  SmallString<32> Checksum;
+  llvm::DIFile::ChecksumKind CSKind = getChecksum(SM.getFileID(Loc), Checksum);
+
   llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
-remapDIPath(getCurrentDirname()));
+remapDIPath(getCurrentDirname()),
+CSKind, Checksum);
 
   DIFileCache[fname].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
- remapDIPath(TheCU->getDirectory()));
+ remapDIPath(TheCU->getDirectory()),
+ TheCU->getFile()->getChecksumKind(),
+ TheCU->getFile()->getChecksum());
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
@@ -396,6 +430,8 @@
 }
 
 void CGDebugInfo::CreateCompileUnit() {
+  SmallString<32> Checksum;
+  llvm::DIFile::ChecksumKind CSKind = llvm::DIFile::CSK_None;
 
   // Should we be asking the SourceManager for the main file name, instead of
   // accepting it as an argument? This just causes the main file name to
@@ -422,6 +458,7 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+CSKind = getChecksum(SM.getMainFileID(), Checksum);
   }
 
   llvm::dwarf::SourceLanguage LangTag;
@@ -467,7 +504,8 @@
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
   LangTag, DBuilder.createFile(remapDIPath(MainFileName),
-remapDIPath(getCurrentDirname())),
+   remapDIPath(getCurrentDirname()), CSKind,
+   Checksum),
   Producer, LO.O

[PATCH] D26454: Implement no_sanitize_address for global vars

2016-12-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D26454#609578, @dougk wrote:

> Suppression of sanitizing is necessary if the variable is magically a 
> memory-mapped device I/O address.
>  The linker can arrange for this to be the case using fancy scripts, or even 
> just as simple as a section attribute that requires that you take up exactly 
> a certain number of bytes in the section.
>  There was some thought that any non-default section should preclude 
> sanitization, but Kostya said that, no, it would make sense to require 
> explicit no-sanitize.  I (mistakenly) took that to mean "just do it", for 
> which I apologize.


Thank you for the explanation, but I'm still wondering if this applies to only 
`address` sanitization, or to others as well, such as `memory` or `thread`. The 
fact that the declarative information in Attr.td is incorrect now is a concern. 
We can either address that concern by making the conflict go away for all 
sanitizer strings (which may not be sensible), or by making some complex 
changes to the way subject lists work (which may be more work than it's worth). 
The point to having a single `no_sanitize` attribute was so that we didn't need 
to add a new attribute every time we came up with a new sanitizer, but it was 
understood that this works because all of the sanitizers apply to the same 
constructs. This change breaks that assumption so that now one of the sanitizer 
strings diverges from all the rest, and I would like to avoid that.


https://reviews.llvm.org/D26454



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


[PATCH] D27920: [find-all-symbols] Index partial template specializations.

2016-12-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added subscribers: bkramer, cfe-commits.

Fix no std::function index.


https://reviews.llvm.org/D27920

Files:
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp


Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -229,6 +229,28 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, DontIgnoreTemplatePartialSpecialization) {
+  static const char Code[] = R"(
+  template class Class; // undefined
+  template
+  class Class {
+  };
+
+  template void f() {};
+  template<> void f() {};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("Class", SymbolInfo::SymbolKind::Class, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+  Symbol =
+  SymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName, 7, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+  Symbol =
+  SymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName, 8, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 TEST_F(FindAllSymbolsTest, FunctionSymbols) {
   static const char Code[] = R"(
   namespace na {
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -32,6 +32,18 @@
   return false;
 }
 
+AST_POLYMORPHIC_MATCHER(isFullySpecialized,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl,
+CXXRecordDecl)) {
+  if (Node.getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
+bool is_partial_specialization =
+llvm::isa(Node) ||
+llvm::isa(Node);
+return !is_partial_specialization;
+  }
+  return false;
+}
+
 std::vector GetContexts(const NamedDecl *ND) {
   std::vector Contexts;
   for (const auto *Context = ND->getDeclContext(); Context;
@@ -126,8 +138,7 @@
   auto CCMatcher =
   allOf(HasNSOrTUCtxMatcher, unless(IsInSpecialization),
 unless(ast_matchers::isTemplateInstantiation()),
-unless(isInstantiated()), 
unless(classTemplateSpecializationDecl()),
-unless(isExplicitTemplateSpecialization()));
+unless(isInstantiated()), unless(isFullySpecialized()));
 
   // Matchers specific to code in extern "C" {...}.
   auto ExternCMatcher = hasDeclContext(linkageSpecDecl());
@@ -156,8 +167,7 @@
 
   // Matchers for C++ record declarations.
   auto CxxRecordDecl =
-  cxxRecordDecl(CommonFilter, CCMatcher, isDefinition(),
-unless(isExplicitTemplateSpecialization()));
+  cxxRecordDecl(CommonFilter, CCMatcher, isDefinition());
   MatchFinder->addMatcher(CxxRecordDecl.bind("decl"), this);
 
   // Matchers for function declarations.


Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -229,6 +229,28 @@
   EXPECT_TRUE(hasSymbol(Symbol));
 }
 
+TEST_F(FindAllSymbolsTest, DontIgnoreTemplatePartialSpecialization) {
+  static const char Code[] = R"(
+  template class Class; // undefined
+  template
+  class Class {
+  };
+
+  template void f() {};
+  template<> void f() {};
+  )";
+  runFindAllSymbols(Code);
+  SymbolInfo Symbol =
+  SymbolInfo("Class", SymbolInfo::SymbolKind::Class, HeaderName, 4, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+  Symbol =
+  SymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName, 7, {});
+  EXPECT_TRUE(hasSymbol(Symbol));
+  Symbol =
+  SymbolInfo("f", SymbolInfo::SymbolKind::Function, HeaderName, 8, {});
+  EXPECT_FALSE(hasSymbol(Symbol));
+}
+
 TEST_F(FindAllSymbolsTest, FunctionSymbols) {
   static const char Code[] = R"(
   namespace na {
Index: include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -32,6 +32,18 @@
   return false;
 }
 
+AST_POLYMORPHIC_MATCHER(isFullySpecialized,
+AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl,
+CXXRecordDecl)) {
+  if (Node.getTemplateSpecializationKind() == TSK_ExplicitSpecialization) {
+bool is_partial_specialization =
+llvm::isa(Node) ||
+llvm::isa(Node);
+return !is_partial_specialization;
+  }
+  return false;
+}
+
 std::vec

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

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

Rebase to current trunk


https://reviews.llvm.org/D23325

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

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

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

2016-12-19 Thread David Blaikie via cfe-commits
On Thu, Dec 15, 2016 at 2:18 PM Sean Callanan via Phabricator via
cfe-commits  wrote:

> spyffe updated this revision to Diff 81661.
> spyffe marked 2 inline comments as done.
> spyffe added a comment.
> Herald added a subscriber: jgosnell.
>
> Applied Vassil and Vedant's comments.  I will commit this soon.
>

Was this change approved/accepted by anyone? "commit if no one has
objections in " isn't generally how LLVM project changes are
reviewed/committed.


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D27180
>
> Files:
>   test/Import/clang-flags/Inputs/S.c
>   test/Import/clang-flags/test.c
>   test/Import/empty-struct/Inputs/S.c
>   test/Import/empty-struct/test.c
>   test/Import/error-in-expression/Inputs/S.c
>   test/Import/error-in-expression/test.c
>   test/Import/error-in-import/Inputs/S.c
>   test/Import/error-in-import/test.c
>   test/Import/missing-import/test.c
>   tools/CMakeLists.txt
>   tools/clang-import-test/CMakeLists.txt
>   tools/clang-import-test/clang-import-test.cpp
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D27763: Debug Info: Modified DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. (Clang part)

2016-12-19 Thread David Blaikie via cfe-commits
Was this change approved by anyone? Generally once it's sent for review,
you should wait until it's approved before committing (the assumption
being, if you sent it for review it's because it needed review)

On Wed, Dec 14, 2016 at 12:49 PM Amjad Aboud via Phabricator via
cfe-commits  wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL289701: [DebugInfo] Changed
> DIBuilder::createCompileUnit() to take DIFile instead of… (authored by
> aaboud).
>
> Changed prior to commit:
>   https://reviews.llvm.org/D27763?vs=81397&id=81438#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D27763
>
> Files:
>   cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
>
> Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> ===
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> @@ -466,7 +466,8 @@
>// Create new compile unit.
>// FIXME - Eliminate TheCU.
>TheCU = DBuilder.createCompileUnit(
> -  LangTag, remapDIPath(MainFileName),
> remapDIPath(getCurrentDirname()),
> +  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
> +remapDIPath(getCurrentDirname())),
>Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags,
> RuntimeVers,
>CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
>CGM.getCodeGenOpts().SplitDwarfInlining);
> @@ -1977,10 +1978,11 @@
>  // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
>  uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
>  llvm::DIBuilder DIB(CGM.getModule());
> -DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
> -  Mod.getPath(), TheCU->getProducer(), true,
> -  StringRef(), 0, Mod.getASTFile(),
> -  llvm::DICompileUnit::FullDebug, Signature);
> +DIB.createCompileUnit(TheCU->getSourceLanguage(),
> +  DIB.createFile(Mod.getModuleName(),
> Mod.getPath()),
> +  TheCU->getProducer(), true, StringRef(), 0,
> +  Mod.getASTFile(),
> llvm::DICompileUnit::FullDebug,
> +  Signature);
>  DIB.finalize();
>}
>llvm::DIModule *Parent =
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290113 - [libclang] Revert part of r290025, "Remove the 'extern "C"' blocks from the implementation files."

2016-12-19 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Dec 19 10:50:43 2016
New Revision: 290113

URL: http://llvm.org/viewvc/llvm-project?rev=290113&view=rev
Log:
[libclang] Revert part of r290025, "Remove the 'extern "C"' blocks from the 
implementation files."

mingw32-ld complains missing symbols in exports,

  Cannot export clang_findIncludesInFileWithBlock: symbol not defined
  Cannot export clang_findReferencesInFileWithBlock: symbol not defined
  Cannot export clang_visitChildrenWithBlock: symbol not defined

They are excluded conditionally in header along has_blocks.

We should do either;

  1. Exclude also function bodies conditionally, and introduce "optional" 
exporter.
  2. Give dummy function bodies for them.
  3. Implement functions w/o blocks.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexHigh.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=290113&r1=290112&r2=290113&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Dec 19 10:50:43 2016
@@ -4120,6 +4120,8 @@ static SourceLocation getLocationFromExp
   return E->getLocStart();
 }
 
+extern "C" {
+
 unsigned clang_visitChildren(CXCursor parent,
  CXCursorVisitor visitor,
  CXClientData client_data) {
@@ -5383,6 +5385,8 @@ CXSourceLocation clang_getCursorLocation
   return cxloc::translateSourceLocation(getCursorContext(C), Loc);
 }
 
+} // end extern "C"
+
 CXCursor cxcursor::getCursor(CXTranslationUnit TU, SourceLocation SLoc) {
   assert(TU);
 

Modified: cfe/trunk/tools/libclang/CIndexHigh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexHigh.cpp?rev=290113&r1=290112&r2=290113&view=diff
==
--- cfe/trunk/tools/libclang/CIndexHigh.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexHigh.cpp Mon Dec 19 10:50:43 2016
@@ -407,6 +407,8 @@ static bool findIncludesInFile(CXTransla
 // libclang public APIs.
 
//===--===//
 
+extern "C" {
+
 CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
 CXCursorAndRangeVisitor visitor) {
   LogRef Log = Logger::make(__func__);
@@ -532,3 +534,4 @@ CXResult clang_findIncludesInFileWithBlo
   return clang_findIncludesInFile(TU, file, visitor);
 }
 
+} // end: extern "C"


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


Re: [PATCH] D27683: Prepare PrettyStackTrace for LLDB adoption

2016-12-19 Thread David Blaikie via cfe-commits
Test coverage?

On Tue, Dec 13, 2016 at 2:39 PM Sean Callanan via Phabricator via
cfe-commits  wrote:

> spyffe retitled this revision from "Fix the linkage for
> __crashtracer_info__" to "Prepare PrettyStackTrace for LLDB adoption".
> spyffe updated the summary for this revision.
> spyffe updated this revision to Diff 81304.
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D27683
>
> Files:
>   include/llvm/Support/PrettyStackTrace.h
>   lib/Support/PrettyStackTrace.cpp
>
>
> Index: lib/Support/PrettyStackTrace.cpp
> ===
> --- lib/Support/PrettyStackTrace.cpp
> +++ lib/Support/PrettyStackTrace.cpp
> @@ -89,7 +89,7 @@
>  = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
>  }
>  #elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
> -static const char *__crashreporter_info__ = 0;
> +extern "C" const char *__crashreporter_info__
> __attribute__((visibility("hidden"))) = 0;
>  asm(".desc ___crashreporter_info__, 0x10");
>  #endif
>
> @@ -145,6 +145,28 @@
>OS << Str << "\n";
>  }
>
> +PrettyStackTraceFormat::PrettyStackTraceFormat(const char *format, ...) {
> +  va_list ap;
> +
> +  va_start(ap, format);
> +  const int size_or_error = vsnprintf(nullptr, 0, format, ap);
> +  va_end(ap);
> +
> +  if (size_or_error < 0) {
> +return;
> +  }
> +
> +  const int size = size_or_error + 1; // '\0'
> +
> +  Str.resize(size);
> +
> +  va_start(ap, format);
> +  vsnprintf(Str.data(), size, format, ap);
> +  va_end(ap);
> +}
> +
> +void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str <<
> "\n"; }
> +
>  void PrettyStackTraceProgram::print(raw_ostream &OS) const {
>OS << "Program arguments: ";
>// Print the argument list.
> Index: include/llvm/Support/PrettyStackTrace.h
> ===
> --- include/llvm/Support/PrettyStackTrace.h
> +++ include/llvm/Support/PrettyStackTrace.h
> @@ -16,6 +16,7 @@
>  #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
>  #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
>
> +#include "llvm/ADT/SmallVector.h"
>  #include "llvm/Support/Compiler.h"
>
>  namespace llvm {
> @@ -55,6 +56,16 @@
>  void print(raw_ostream &OS) const override;
>};
>
> +  /// PrettyStackTraceFormat - This object prints a string (which may use
> +  /// printf-style formatting but should not contain newlines) to the
> stream
> +  /// as the stack trace when a crash occurs.
> +  class PrettyStackTraceFormat : public PrettyStackTraceEntry {
> +llvm::SmallVector Str;
> +  public:
> +PrettyStackTraceFormat(const char *format, ...);
> +void print(raw_ostream &OS) const override;
> +  };
> +
>/// PrettyStackTraceProgram - This object prints a specified program
> arguments
>/// to the stream as the stack trace when a crash occurs.
>class PrettyStackTraceProgram : public PrettyStackTraceEntry {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D27763: Debug Info: Modified DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. (Clang part)

2016-12-19 Thread Aboud, Amjad via cfe-commits
It was approved by Reid.
This patch had two parts, he did not stamp the change in Clang, but he did 
stamp the change for LLVM.
https://reviews.llvm.org/D27762

I assumed that this means a green light to commit.
Did I misinterpret the rules?

Thanks,
Amjad

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Monday, December 19, 2016 19:00
To: reviews+d27763+public+4530ee00cad28...@reviews.llvm.org; Amjad Aboud via 
Phabricator ; Aboud, Amjad ; 
r...@google.com
Cc: cfe-commits@lists.llvm.org
Subject: Re: [PATCH] D27763: Debug Info: Modified 
DIBuilder::createCompileUnit() to take DIFile instead of FileName and 
Directory. (Clang part)

Was this change approved by anyone? Generally once it's sent for review, you 
should wait until it's approved before committing (the assumption being, if you 
sent it for review it's because it needed review)

On Wed, Dec 14, 2016 at 12:49 PM Amjad Aboud via Phabricator via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289701: [DebugInfo] Changed DIBuilder::createCompileUnit() 
to take DIFile instead of… (authored by aaboud).

Changed prior to commit:
  https://reviews.llvm.org/D27763?vs=81397&id=81438#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27763

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp


Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -466,7 +466,8 @@
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
+  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
+remapDIPath(getCurrentDirname())),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
@@ -1977,10 +1978,11 @@
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
-DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+DIB.createCompileUnit(TheCU->getSourceLanguage(),
+  DIB.createFile(Mod.getModuleName(), Mod.getPath()),
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-19 Thread Firat Kasmis via Phabricator via cfe-commits
firolino updated this revision to Diff 81964.
firolino added a comment.

Added support for new test cases:

  int S::*mdpa1[2] = {&S::a, &S::a}, var1 = 0;
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration statement can be split
  // CHECK-FIXES: {{^}}int S::*mdpa1[2] = {&S::a, &S::a};
  // CHECK-FIXES: {{^}}int var1 = 0;
  
  int S :: * * mdpa2[2] = {&p, &pp2}, var2 = 0;
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration statement can be split
  // CHECK-FIXES: {{^}}int S :: * * mdpa2[2] = {&p, &pp2};
  // CHECK-FIXES: {{^}}int var2 = 0;
  
  void (S::*mdfp1)() = &S::f, (S::*mdfp2)() = &S::f;
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration statement can be split
  // CHECK-FIXES: {{^}}void (S::*mdfp1)() = &S::f;
  // CHECK-FIXES: {{^}}void (S::*mdfp2)() = &S::f;
  
  void (S::*mdfpa1[2])() = {&S::f, &S::f}, (S::*mdfpa2)() = &S::f;
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration statement can be split
  // CHECK-FIXES: {{^}}void (S::*mdfpa1[2])() = {&S::f, &S::f};
  // CHECK-FIXES: {{^}}void (S::*mdfpa2)() = &S::f;
  
  void (S::**mdfpa3[2])() = {&mdfpa1[0], &mdfpa1[1]}, (S::*mdfpa4)() = &S::f;
  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration statement can be split
  // CHECK-FIXES: {{^}}void (S::**mdfpa3[2])() = {&mdfpa1[0], 
&mdfpa1[1]};
  // CHECK-FIXES: {{^}}void (S::*mdfpa4)() = &S::f;


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,142 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = &empty, * long3 = ∅
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = ∅
+// CHECK-FIXES: {{^}}long * long3 = ∅
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+/* *& */ int /* *& */ ** /* *& */ pp,*xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}/* *& */ int /* *& */ ** /* *& */ pp;
+// CHECK-FIXES: {{^}}int *xx;
+
+unsigned int uint1 = 0,uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+const int * const cpc = &dontTouchC, simple = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int * const cpc = &dontTouchC;
+// CHECK-FIXES: {{^}}const int simple = 0;
+
+double darray1[] = {}, darray2[] = {1,	2},dv1 = 3,dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^

Re: [PATCH] D27763: Debug Info: Modified DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory. (Clang part)

2016-12-19 Thread David Blaikie via cfe-commits
Ah, sure - no worries. Good to mention/link to the other change, etc, in
the future. (if the changes on the clang side are trivial enough to not
need review, may not need to send them out for review either - or could
include them as an addendum to the llvm change ("oh, and here's what it
looks like in terms of client (clang) changes" sort of thing) - either in
comments, as a link to a review that doesn't have other subscribers (so it
doesn't go to cfe-commits), or as an attached patch to the llvm review, etc)

On Mon, Dec 19, 2016 at 9:05 AM Aboud, Amjad  wrote:

> It was approved by Reid.
>
> This patch had two parts, he did not stamp the change in Clang, but he did
> stamp the change for LLVM.
>
> https://reviews.llvm.org/D27762
>
>
>
> I assumed that this means a green light to commit.
>
> Did I misinterpret the rules?
>
>
>
> Thanks,
>
> Amjad
>
>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Monday, December 19, 2016 19:00
> *To:* reviews+d27763+public+4530ee00cad28...@reviews.llvm.org; Amjad
> Aboud via Phabricator ; Aboud, Amjad <
> amjad.ab...@intel.com>; r...@google.com
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: [PATCH] D27763: Debug Info: Modified
> DIBuilder::createCompileUnit() to take DIFile instead of FileName and
> Directory. (Clang part)
>
>
>
> Was this change approved by anyone? Generally once it's sent for review,
> you should wait until it's approved before committing (the assumption
> being, if you sent it for review it's because it needed review)
>
>
>
> On Wed, Dec 14, 2016 at 12:49 PM Amjad Aboud via Phabricator via
> cfe-commits  wrote:
>
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL289701: [DebugInfo] Changed
> DIBuilder::createCompileUnit() to take DIFile instead of… (authored by
> aaboud).
>
> Changed prior to commit:
>   https://reviews.llvm.org/D27763?vs=81397&id=81438#toc
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D27763
>
> Files:
>   cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
>
> Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> ===
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> @@ -466,7 +466,8 @@
>// Create new compile unit.
>// FIXME - Eliminate TheCU.
>TheCU = DBuilder.createCompileUnit(
> -  LangTag, remapDIPath(MainFileName),
> remapDIPath(getCurrentDirname()),
> +  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
> +remapDIPath(getCurrentDirname())),
>Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags,
> RuntimeVers,
>CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
>CGM.getCodeGenOpts().SplitDwarfInlining);
> @@ -1977,10 +1978,11 @@
>  // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
>  uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
>  llvm::DIBuilder DIB(CGM.getModule());
> -DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
> -  Mod.getPath(), TheCU->getProducer(), true,
> -  StringRef(), 0, Mod.getASTFile(),
> -  llvm::DICompileUnit::FullDebug, Signature);
> +DIB.createCompileUnit(TheCU->getSourceLanguage(),
> +  DIB.createFile(Mod.getModuleName(),
> Mod.getPath()),
> +  TheCU->getProducer(), true, StringRef(), 0,
> +  Mod.getASTFile(),
> llvm::DICompileUnit::FullDebug,
> +  Signature);
>  DIB.finalize();
>}
>llvm::DIModule *Parent =
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
> -
> Intel Israel (74) Limited
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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



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

Do these require a literal suffix to avoid conversion?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:62
+  auto *UnaryOp = dyn_cast(E);
+  if (UnaryOp && UnaryOp->getOpcode() == UO_Plus) {
+return UnaryOp->getSubExpr();

Elide braces.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:70
+  auto *InitList = dyn_cast(E);
+  if (InitList && InitList->getNumInits() == 1) {
+return InitList->getInit(0);

Elide braces.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:77-78
+static bool sameValue(const Expr *E1, const Expr *E2) {
+  E1 = ignoreUnaryPlus(getInitializer(E1->IgnoreImpCasts()));
+  E2 = ignoreUnaryPlus(getInitializer(E2->IgnoreImpCasts()));
+

Do you also want to ignore paren expressions?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:80
+
+  if (isZero(E1) && isZero(E2)) {
+return true;

Elide braces (same elsewhere).



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:103
+return cast(E1)->getDecl() == 
cast(E2)->getDecl();
+  default:
+break;

Perhaps character and string literals as well?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:106
+  }
+  return false;
+}

Hoist this into the `default` case and put an `llvm_unreachable()` instead?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:119
+
+AST_MATCHER(FieldDecl, hasInClassInitializer) {
+  return Node.hasInClassInitializer();

This would be useful as a public matcher, I think. Fine to do in a follow-up 
patch if you prefer.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:123
+
+void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
+  auto Init =

This check should not register matchers for C++ < 11.



Comment at: docs/clang-tidy/checks/modernize-use-default-member-init.rst:6
+
+This check converts a default constructor's member initializers into default
+member initializers. Other member initializers that match the default

You should mention that the check does nothing in versions older than C++11.



Comment at: docs/clang-tidy/checks/modernize-use-default-member-init.rst:30
+.. note::
+  Only converts member initializers for built-in types, enums and pointers.
+  The `readability-redundant-member-init` check will remove redundant member

"enums, and pointers", because Oxford commas are the best commas. ;-)


https://reviews.llvm.org/D26750



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


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

2016-12-19 Thread Vassil Vassilev via cfe-commits

On 19/12/16 17:55, David Blaikie wrote:



On Thu, Dec 15, 2016 at 2:18 PM Sean Callanan via Phabricator via 
cfe-commits > wrote:


spyffe updated this revision to Diff 81661.
spyffe marked 2 inline comments as done.
spyffe added a comment.
Herald added a subscriber: jgosnell.

Applied Vassil and Vedant's comments.  I will commit this soon.


Was this change approved/accepted by anyone? "commit if no one has 
objections in " isn't generally how LLVM project changes 
are reviewed/committed.
I could have greenlit this (as I personally pinged Sean on this patch. I 
need some of it to make progress on the libInterpreter part) :(




Repository:
  rL LLVM

https://reviews.llvm.org/D27180

Files:
  test/Import/clang-flags/Inputs/S.c
  test/Import/clang-flags/test.c
  test/Import/empty-struct/Inputs/S.c
  test/Import/empty-struct/test.c
  test/Import/error-in-expression/Inputs/S.c
  test/Import/error-in-expression/test.c
  test/Import/error-in-import/Inputs/S.c
  test/Import/error-in-import/test.c
  test/Import/missing-import/test.c
  tools/CMakeLists.txt
  tools/clang-import-test/CMakeLists.txt
  tools/clang-import-test/clang-import-test.cpp

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



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


[PATCH] D21298: [Clang-tidy] delete null check

2016-12-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, with one nit. You should wait for @alexfh to sign off before committing 
though, since he requested changes.




Comment at: clang-tidy/readability/DeleteNullPointerCheck.cpp:53
+  "'if' statement is unnecessary; deleting null pointer has no effect");
+  if (IfWithDelete->getElse()) {
+return;

Elide the braces.


https://reviews.llvm.org/D21298



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


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

2016-12-19 Thread Aaron Ballman via cfe-commits
On Fri, Dec 16, 2016 at 7:00 AM, Attila Török via Phabricator
 wrote:
> torokati44 added a comment.
>
> I see this has been reverted in r281612, but I can no longer access the build 
> log serving as a reason linked in the message: 
> https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg35386.html
> We have a few false-positive warnings that (I think) would be silenced by 
> this change. I'm just wondering if something like this, if not this, could be 
> included anyway? Not critical of course, it just would be nice.

This patch was reapplied in r281632:

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160912/170772.html

Do you still have false positives even with that applied?

Thanks!

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


[PATCH] D26454: Implement no_sanitize_address for global vars

2016-12-19 Thread Douglas Katzman via Phabricator via cfe-commits
dougk added a comment.

I think it probably works to have the attribute appertain to any sanitizer.  I 
did not know that it did, so I conservatively assumed that it didn't.  I'll go 
ahead and make things consistent, and confirm that it dtrt.


https://reviews.llvm.org/D26454



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


Re: [PATCH] D27683: Prepare PrettyStackTrace for LLDB adoption

2016-12-19 Thread Sean Callanan via cfe-commits
That would require making LLDB crash and collecting the relevant crash log data 
out of the user's own logs.  This isn't impossible – but additionally the 
generation of that log is asynchronous and you don't quite know when it'll land.
Would you be all right with a more restricted macOS-only unit test where we 
check that __crashreporter_info__ contains what we think it does?  That won't 
check end-to-end but at least it'll give us some confidence that things are 
sane.

Sean

> On Dec 19, 2016, at 9:01 AM, David Blaikie  wrote:
> 
> Test coverage?
> 
> On Tue, Dec 13, 2016 at 2:39 PM Sean Callanan via Phabricator via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> spyffe retitled this revision from "Fix the linkage for __crashtracer_info__" 
> to "Prepare PrettyStackTrace for LLDB adoption".
> spyffe updated the summary for this revision.
> spyffe updated this revision to Diff 81304.
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D27683 
> 
> Files:
>   include/llvm/Support/PrettyStackTrace.h
>   lib/Support/PrettyStackTrace.cpp
> 
> 
> Index: lib/Support/PrettyStackTrace.cpp
> ===
> --- lib/Support/PrettyStackTrace.cpp
> +++ lib/Support/PrettyStackTrace.cpp
> @@ -89,7 +89,7 @@
>  = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
>  }
>  #elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO
> -static const char *__crashreporter_info__ = 0;
> +extern "C" const char *__crashreporter_info__ 
> __attribute__((visibility("hidden"))) = 0;
>  asm(".desc ___crashreporter_info__, 0x10");
>  #endif
> 
> @@ -145,6 +145,28 @@
>OS << Str << "\n";
>  }
> 
> +PrettyStackTraceFormat::PrettyStackTraceFormat(const char *format, ...) {
> +  va_list ap;
> +
> +  va_start(ap, format);
> +  const int size_or_error = vsnprintf(nullptr, 0, format, ap);
> +  va_end(ap);
> +
> +  if (size_or_error < 0) {
> +return;
> +  }
> +
> +  const int size = size_or_error + 1; // '\0'
> +
> +  Str.resize(size);
> +
> +  va_start(ap, format);
> +  vsnprintf(Str.data(), size, format, ap);
> +  va_end(ap);
> +}
> +
> +void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str << 
> "\n"; }
> +
>  void PrettyStackTraceProgram::print(raw_ostream &OS) const {
>OS << "Program arguments: ";
>// Print the argument list.
> Index: include/llvm/Support/PrettyStackTrace.h
> ===
> --- include/llvm/Support/PrettyStackTrace.h
> +++ include/llvm/Support/PrettyStackTrace.h
> @@ -16,6 +16,7 @@
>  #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H
>  #define LLVM_SUPPORT_PRETTYSTACKTRACE_H
> 
> +#include "llvm/ADT/SmallVector.h"
>  #include "llvm/Support/Compiler.h"
> 
>  namespace llvm {
> @@ -55,6 +56,16 @@
>  void print(raw_ostream &OS) const override;
>};
> 
> +  /// PrettyStackTraceFormat - This object prints a string (which may use
> +  /// printf-style formatting but should not contain newlines) to the stream
> +  /// as the stack trace when a crash occurs.
> +  class PrettyStackTraceFormat : public PrettyStackTraceEntry {
> +llvm::SmallVector Str;
> +  public:
> +PrettyStackTraceFormat(const char *format, ...);
> +void print(raw_ostream &OS) const override;
> +  };
> +
>/// PrettyStackTraceProgram - This object prints a specified program 
> arguments
>/// to the stream as the stack trace when a crash occurs.
>class PrettyStackTraceProgram : public PrettyStackTraceEntry {
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 

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


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

2016-12-19 Thread Sean Callanan via cfe-commits
David,

thanks for keeping an eye on this and sorry for the breach of process.
Would having Vassil approve the changelist (https://reviews.llvm.org/D27180 
) be appropriate?
Let's say if he has any concerns or can't get to it by tomorrow, we revert my 
patches since they're pretty self-contained.

Sean

> On Dec 19, 2016, at 8:55 AM, David Blaikie  wrote:
> 
> 
> 
> On Thu, Dec 15, 2016 at 2:18 PM Sean Callanan via Phabricator via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> spyffe updated this revision to Diff 81661.
> spyffe marked 2 inline comments as done.
> spyffe added a comment.
> Herald added a subscriber: jgosnell.
> 
> Applied Vassil and Vedant's comments.  I will commit this soon.
> 
> Was this change approved/accepted by anyone? "commit if no one has objections 
> in " isn't generally how LLVM project changes are 
> reviewed/committed.
>  
> 
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D27180 
> 
> Files:
>   test/Import/clang-flags/Inputs/S.c
>   test/Import/clang-flags/test.c
>   test/Import/empty-struct/Inputs/S.c
>   test/Import/empty-struct/test.c
>   test/Import/error-in-expression/Inputs/S.c
>   test/Import/error-in-expression/test.c
>   test/Import/error-in-import/Inputs/S.c
>   test/Import/error-in-import/test.c
>   test/Import/missing-import/test.c
>   tools/CMakeLists.txt
>   tools/clang-import-test/CMakeLists.txt
>   tools/clang-import-test/clang-import-test.cpp
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

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



Comment at: clang-tidy/obvious/InvalidRangeCheck.cpp:20-36
+"std::for_each; std::find; std::find_if; std::find_end; "
+"std::find_first_of; std::adjacent_find; std::count; std::count_if;"
+"std::mismatch; std::equal; std::search; std::copy; "
+"std::copy_backward; std::swap_ranges; std::transform; std::replace"
+"std::replace_if; std::replace_copy; std::replace_copy_if; std::fill; "
+"std::fill_n; std::generate; std::generate_n; std::remove; std::remove_if"
+"std::remove_copy; std::remove_copy_if; std::unique; std::unique_copy;"

Prazek wrote:
> Prazek wrote:
> > sbarzowski wrote:
> > > Prazek wrote:
> > > > sbarzowski wrote:
> > > > > I would go with one per line. It will be much more diff-friendly this 
> > > > > way.  And also much easier to add stuff in the middle and maybe keep 
> > > > > it sorted. 
> > > > I don't expect this list to change in any way in the future, and it 
> > > > already take more than 20 lines. I don't want to put about 80 lines 
> > > > only to define the names
> > > Ok, I don't think it's important enough to argue about it if it was your 
> > > deliberate decision.
> > > 
> > > But I still think your argument is invalid :-). If anything that calls 
> > > for putting it in a separate file.
> > By moving it to another file I would expose it to other checks, which is 
> > not my intention.
> > I also want to keep this simple and short, and by making this list less 
> > readable (which is not something that some next developer should care 
> > about) I make the whole file more readable, because it is shorter.
> ok I think I will remove the list and instead will check if the name starts 
> with std::, because if someone calls std::.
You should check if the canonical name starts with `::std::`, otherwise you may 
run into issues with:
```
namespace my {
namespace std {
 // bad code goes here
}
}
```


https://reviews.llvm.org/D27806



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


r290120 - Make a few OpenMP tests "C++11 clean."

2016-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Dec 19 11:58:09 2016
New Revision: 290120

URL: http://llvm.org/viewvc/llvm-project?rev=290120&view=rev
Log:
Make a few OpenMP tests "C++11 clean."

Reviewed by abataev (in D27794)


Modified:
cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
cfe/trunk/test/CodeGenCXX/destructors.cpp
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/partial-destruction.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
cfe/trunk/test/Parser/backtrack-off-by-one.cpp
cfe/trunk/test/SemaCXX/copy-assignment.cpp

Modified: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp?rev=290120&r1=290119&r2=290120&view=diff
==
--- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp Mon Dec 19 11:58:09 2016
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s 
-check-prefixes=CHECK,CHECKv03
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++11 | FileCheck %s 
-check-prefixes=CHECK,CHECKv11
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
@@ -48,7 +49,8 @@ typedef struct {
 TEST(struct_1);
 // CHECK-LABEL: define {{.*}} @return_struct_1()
 // CHECK:   [[RET:%.*]] = alloca [[REC:%.*]], align 4
-// CHECK:   @llvm.memset
+// CHECKv03:   @llvm.memset
+// CHECKv11:   @llvm.memcpy
 // CHECK:   [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x 
i8\], i8, \[1 x i8\], float, float }]]*
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 0
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align 4

Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=290120&r1=290119&r2=290120&view=diff
==
--- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructors.cpp Mon Dec 19 11:58:09 2016
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns > 
%t
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++03 > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
-// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
-// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns -std=c++11 > %t2
-// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v03 --input-file=%t %s
+// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v03 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++11 > %t2
+// RUN: FileCheck --check-prefix=CHECK1--input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK2v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK3--input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v11 --input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK6--input-file=%t2 %s
 // REQUIRES: asserts
 
 struct A {
@@ -98,6 +103,12 @@ namespace test0 {
 // CHECK2: invoke void @_ZN5test04BaseD2Ev
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
+// In C++11, the destructors are often known not to throw.
+// CHECK2v11-LABEL: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK2v11-LABEL: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) 
unnamed_addr
+// CHECK2v11: call void @_ZN5test06MemberD1Ev
+// CHECK2v11: call void @_ZN5test04BaseD2Ev
+
   struct B : Base, virtual VBase {
 Member M;
 ~B();
@@ -111,6 +122,10 @@ namespace test0 {
 // CHECK2: invoke void @_ZN5test04BaseD2Ev
 // CHECK2:   unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
 
+// CHECK2v11-LABEL: define void @_ZN5test01BD2Ev(%"stru

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D27815#626440, @Prazek wrote:

> The example of this kind of check is here:
>  https://reviews.llvm.org/D27806
>
> I am not sure if it make sense to put it as clang warning.
>
> After a little bit of thinking I guess name "typos" would be better, because 
> I want to look for checks that are mostly typos (which are obvious btw) but 
> it would make it more concrete.


When I hear "typo", I think "misspelling" and wonder how it differs from the 
typo correction that clang frontend has. I've usually heard of what your linked 
review covers as a "thinko" (https://en.wiktionary.org/wiki/thinko) because you 
made a logical mistake rather than a misspelling, but that's a pretty awful 
name for the module. ;-)

Perhaps "mistake-", "oops-", "derp-" or something along those lines (well, 
maybe not "derp")?


https://reviews.llvm.org/D27815



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


r290121 - Undo accidental comit

2016-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Dec 19 12:00:45 2016
New Revision: 290121

URL: http://llvm.org/viewvc/llvm-project?rev=290121&view=rev
Log:
Undo accidental comit

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
cfe/trunk/test/CodeGenCXX/destructors.cpp
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp
cfe/trunk/test/CodeGenCXX/partial-destruction.cpp
cfe/trunk/test/CodeGenCXX/stack-reuse-miscompile.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp
cfe/trunk/test/Parser/backtrack-off-by-one.cpp
cfe/trunk/test/SemaCXX/copy-assignment.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=290121&r1=290120&r2=290121&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Dec 19 12:00:45 2016
@@ -1570,6 +1570,8 @@ void CompilerInvocation::setLangDefaults
   break;
 case IK_CXX:
 case IK_PreprocessedCXX:
+  LangStd = LangStandard::lang_gnucxx11; // PTR
+  break;
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
   LangStd = LangStandard::lang_gnucxx98;

Modified: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp?rev=290121&r1=290120&r2=290121&view=diff
==
--- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp Mon Dec 19 12:00:45 2016
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s 
-check-prefixes=CHECK,CHECKv03
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++11 | FileCheck %s 
-check-prefixes=CHECK,CHECKv11
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
@@ -49,8 +48,7 @@ typedef struct {
 TEST(struct_1);
 // CHECK-LABEL: define {{.*}} @return_struct_1()
 // CHECK:   [[RET:%.*]] = alloca [[REC:%.*]], align 4
-// CHECKv03:   @llvm.memset
-// CHECKv11:   @llvm.memcpy
+// CHECK:   @llvm.memset
 // CHECK:   [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x 
i8\], i8, \[1 x i8\], float, float }]]*
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 0
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align 4

Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=290121&r1=290120&r2=290121&view=diff
==
--- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructors.cpp Mon Dec 19 12:00:45 2016
@@ -1,16 +1,11 @@
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++03 > %t
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns > 
%t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK3 --input-file=%t %s
-// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v03 --input-file=%t %s
-// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v03 --input-file=%t %s
-// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-mconstructor-aliases -fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns 
-std=c++11 > %t2
-// RUN: FileCheck --check-prefix=CHECK1--input-file=%t2 %s
-// RUN: FileCheck --check-prefix=CHECK2v11 --input-file=%t2 %s
-// RUN: FileCheck --check-prefix=CHECK3--input-file=%t2 %s
-// RUN: FileCheck --check-prefixes=CHECK4,CHECK4v11 --input-file=%t2 %s
-// RUN: FileCheck --check-prefixes=CHECK5,CHECK5v11 --input-file=%t2 %s
-// RUN: FileCheck --check-prefix=CHECK6--input-file=%t2 %s
+// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t %s
+// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - 
-fcxx-exceptions -fexceptions -O1 -disable-llvm-optzns -std=c++11 > %t2
+// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t2 %s
 // REQUIRES: asserts
 
 struct A {
@@ -103,12 +98,6 @@ namesp

[PATCH] D26964: Handle more declarations in DeclContextPrinter to fix -print-decl-contexts crashes

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

Testing is in line with the existing testing.
It is not great, but at the same time is a development/debugging tool right?


Repository:
  rL LLVM

https://reviews.llvm.org/D26964



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


r290125 - Revert another accidental bit

2016-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Dec 19 12:20:19 2016
New Revision: 290125

URL: http://llvm.org/viewvc/llvm-project?rev=290125&view=rev
Log:
Revert another accidental bit

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

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=290125&r1=290124&r2=290125&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Dec 19 12:20:19 2016
@@ -1570,8 +1570,6 @@ void CompilerInvocation::setLangDefaults
   break;
 case IK_CXX:
 case IK_PreprocessedCXX:
-  LangStd = LangStandard::lang_gnucxx11; // PTR
-  break;
 case IK_ObjCXX:
 case IK_PreprocessedObjCXX:
   LangStd = LangStandard::lang_gnucxx98;


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


[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D27569



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


r290128 - Make a few OpenMP tests "C++11 clean."

2016-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Dec 19 12:43:26 2016
New Revision: 290128

URL: http://llvm.org/viewvc/llvm-project?rev=290128&view=rev
Log:
Make a few OpenMP tests "C++11 clean."

This time trying to commit just the relevant 3 tests!
Reviewed by abataev (in D27794)


Modified:
cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_collapse_messages.cpp

Modified: cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp?rev=290128&r1=290127&r2=290128&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_collapse_messages.cpp Mon Dec 19 
12:43:26 2016
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++98
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++11
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,6 +55,9 @@ T tmain(T argc, S **argv) { //expected-n
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 
for loops after '#pragma omp teams distribute', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+6 2 {{non-constexpr function 'foobool' cannot be used}}
+#endif
 // expected-error@+4 2 {{directive '#pragma omp teams distribute' cannot 
contain more than one 'collapse' clause}}
 // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
 // expected-error@+2 2 {{expression is not an integral constant expression}}
@@ -62,7 +70,11 @@ T tmain(T argc, S **argv) { //expected-n
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-error@+5 2 {{integral constant expression must have integral or 
unscoped enumeration type}}
+#else
+// expected-error@+3 2 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected 
')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
@@ -110,11 +122,17 @@ int main(int argc, char **argv) {
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for 
loops after '#pragma omp teams distribute', but found only 1}}
 
+#if __cplusplus >= 201103L
+// expected-note@+3 {{non-constexpr function 'foobool' cannot be used}}
+#endif
 #pragma omp target
 #pragma omp teams distribute collapse (foobool(1) > 0 ? 1 : 2) // 
expected-error {{expression is not an integral constant expression}}
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
+#if __cplusplus >= 201103L
+// expected-note@+6 {{non-constexpr function 'foobool' cannot be used}}
+#endif
 // expected-error@+4 {{expression is not an integral constant expression}}
 // expected-error@+3 2 {{directive '#pragma omp teams distribute' cannot 
contain more than one 'collapse' clause}}
 // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
@@ -128,7 +146,11 @@ int main(int argc, char **argv) {
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-error@+5 {{integral constant expression must have integral or 
unscoped enumeration type}}
+#else
+// expected-error@+3 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute collapse (argv[1]=2) // expected-error {{expected 
')'}} expected-note {{to match this '('}}
   for (int i = 4; i < 12; i++)

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp?rev=290128&r1=290127&r2=290128&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_collapse_messages.cpp 
Mon Dec 19 12:43:26 2016
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++98
+// RUN: %clang_cc1 -verify -fopenmp %s -std=c++11
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,6 +55,9 @@ T tmain(T argc, S **argv) { //expected-n

[PATCH] D26544: [PPC] support for arithmetic builtins in the FE

2016-12-19 Thread Ehsan Amiri via Phabricator via cfe-commits
amehsan closed this revision.
amehsan added a comment.

https://reviews.llvm.org/rL287872


https://reviews.llvm.org/D26544



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


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

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

Sorry for being late :(




Comment at: cfe/trunk/tools/clang-import-test/clang-import-test.cpp:99
+llvm::errs() << LineString << '\n';
+std::string Space(LocColumn, ' ');
+llvm::errs() << Space.c_str() << '\n';

I still think `indent()` method is more evident here and it doesn't require 
memory allocation.



Comment at: cfe/trunk/tools/clang-import-test/clang-import-test.cpp:125
+if (!Invalid) {
+  llvm::errs() << Ref.str() << '\n';
+}

No `str()` is needed here, `raw_ostream` works well even with non 
null-terminated StringRefs.



Comment at: cfe/trunk/tools/clang-import-test/clang-import-test.cpp:303
+  for (auto I : Imports) {
+  llvm::Expected> ImportCI = Parse(I, 
{});
+  if (auto E = ImportCI.takeError()) {

Broken indentation.


Repository:
  rL LLVM

https://reviews.llvm.org/D27180



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


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

2016-12-19 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: llvm/tools/clang/test/CodeGenCXX/vtable-coverage-gen.cpp:3
+// RUN: FileCheck %s < %t 
+// CHECK: @_ZTV8Category = linkonce_odr unnamed_addr constant {{.*}}, comdat,
+

ahatanak wrote:
> I'm not sure I understood the purpose of this test, but It looks like the 
> vtable for Category is generated in the IR with linkonce_odr without your 
> patch.
Yes, I'm seeing the same thing and am also confused. I can reproduce the build 
failure without using any vtables. To me this suggests the problem could be 
elsewhere. Here is a minimal reproducer:

```
struct Base {
  static const Base *get();
};

struct Derived : public Base {};

const Base *Base::get() {
  static Derived d;
  return &d;
}

int main() { return 0; }
```


https://reviews.llvm.org/D27410



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


[PATCH] D27794: Make some diagnostic tests C++11 clean

2016-12-19 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: rnk.
probinson updated this revision to Diff 81977.
probinson added a comment.

Remove the OpenMP tests from this review (committed in r290128).

+rnk who added test/Parser/backtrack-off-by-one.cpp originally.


https://reviews.llvm.org/D27794

Files:
  test/FixIt/fixit.cpp
  test/Parser/backtrack-off-by-one.cpp
  test/SemaCXX/copy-assignment.cpp

Index: test/SemaCXX/copy-assignment.cpp
===
--- test/SemaCXX/copy-assignment.cpp
+++ test/SemaCXX/copy-assignment.cpp
@@ -1,12 +1,22 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{candidate constructor}}
+// expected-note@+2 {{passing argument to parameter here}}
+#endif
 struct A {
 };
 
 struct ConvertibleToA {
   operator A();
 };
 
 struct ConvertibleToConstA {
+#if __cplusplus >= 201103L
+// expected-note@+2 {{candidate function}}
+#endif
   operator const A();
 };
 
@@ -69,6 +79,9 @@
   na = a;
   na = constA;
   na = convertibleToA;
+#if __cplusplus >= 201103L
+// expected-error@+2 {{no viable conversion}}
+#endif
   na = convertibleToConstA;
   na += a; // expected-error{{no viable overloaded '+='}}
 
Index: test/Parser/backtrack-off-by-one.cpp
===
--- test/Parser/backtrack-off-by-one.cpp
+++ test/Parser/backtrack-off-by-one.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -std=c++98
+// RUN: %clang_cc1 -verify %s -std=c++11
 
 // PR25946
 // We had an off-by-one error in an assertion when annotating A below.  Our
@@ -10,8 +12,10 @@
 
 // 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}}
+#if __cplusplus < 201103L
+// expected-error@+4 {{expected ';' after top level declarator}}
+#endif
+// expected-error@+2 {{C++ requires a type specifier for all declarations}}
 // expected-error@+1 {{expected ';' after class}}
 A {
 };
Index: test/FixIt/fixit.cpp
===
--- test/FixIt/fixit.cpp
+++ test/FixIt/fixit.cpp
@@ -1,8 +1,12 @@
-// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++98 %s
+// RUN: cp %s %t-98
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++98 %t-98
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++98 %t-98
 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
-// RUN: cp %s %t
-// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++11 %s
+// RUN: cp %s %t-11
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++11 %t-11
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++11 %t-11
 
 /* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
@@ -21,7 +25,10 @@
 
 template struct CT { template struct Inner; }; // expected-note{{previous use is here}}
 
+// In C++11 this gets 'expected unqualified-id' which fixit can't fix.
+#if __cplusplus < 201103L
 CT<10 >> 2> ct; // expected-warning{{require parentheses}}
+#endif
 
 class C3 {
 public:
@@ -41,7 +48,11 @@
 };
 
 class B : public A {
+#if __cplusplus >= 201103L
+  A::foo; // expected-error{{ISO C++11 does not allow access declarations}}
+#else
   A::foo; // expected-warning{{access declarations are deprecated}}
+#endif
 };
 
 void f() throw(); // expected-note{{previous}}
@@ -285,8 +296,10 @@
 void (*p)() = &t;
 (void)(&t==p); // expected-error {{use '> ='}}
 (void)(&t>=p); // expected-error {{use '> >'}}
+#if __cplusplus < 201103L
 (void)(&t>>=p); // expected-error {{use '> >'}}
 (Shr)&t>>>=p; // expected-error {{use '> >'}}
+#endif
 
 // FIXME: We correct this to '&t > >= p;' not '&t >>= p;'
 //(Shr)&t>>=p;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290130 - Reverting r290004, r290006, r290010 pending review.

2016-12-19 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Mon Dec 19 13:15:43 2016
New Revision: 290130

URL: http://llvm.org/viewvc/llvm-project?rev=290130&view=rev
Log:
Reverting r290004, r290006, r290010 pending review.

Removed:
cfe/trunk/test/Import/
cfe/trunk/tools/clang-import-test/
Modified:
cfe/trunk/test/CMakeLists.txt
cfe/trunk/tools/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=290130&r1=290129&r2=290130&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Mon Dec 19 13:15:43 2016
@@ -39,7 +39,6 @@ list(APPEND CLANG_TEST_DEPS
   c-index-test diagtool
   clang-tblgen
   clang-offload-bundler
-  clang-import-test
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: cfe/trunk/tools/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CMakeLists.txt?rev=290130&r1=290129&r2=290130&view=diff
==
--- cfe/trunk/tools/CMakeLists.txt (original)
+++ cfe/trunk/tools/CMakeLists.txt Mon Dec 19 13:15:43 2016
@@ -5,7 +5,6 @@ add_clang_subdirectory(driver)
 add_clang_subdirectory(clang-format)
 add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
-add_clang_subdirectory(clang-import-test)
 add_clang_subdirectory(clang-offload-bundler)
 
 add_clang_subdirectory(c-index-test)


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


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

2016-12-19 Thread Sean Callanan via cfe-commits
Reverted by 290130.  I have new comments from Aleksei in 
https://reviews.llvm.org/D27180 .  I'll apply 
those and update the patch. 

Sean

> On Dec 19, 2016, at 9:48 AM, Sean Callanan  wrote:
> 
> David,
> 
> thanks for keeping an eye on this and sorry for the breach of process.
> Would having Vassil approve the changelist (https://reviews.llvm.org/D27180 
> ) be appropriate?
> Let's say if he has any concerns or can't get to it by tomorrow, we revert my 
> patches since they're pretty self-contained.
> 
> Sean
> 
>> On Dec 19, 2016, at 8:55 AM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Thu, Dec 15, 2016 at 2:18 PM Sean Callanan via Phabricator via 
>> cfe-commits mailto:cfe-commits@lists.llvm.org>> 
>> wrote:
>> spyffe updated this revision to Diff 81661.
>> spyffe marked 2 inline comments as done.
>> spyffe added a comment.
>> Herald added a subscriber: jgosnell.
>> 
>> Applied Vassil and Vedant's comments.  I will commit this soon.
>> 
>> Was this change approved/accepted by anyone? "commit if no one has 
>> objections in " isn't generally how LLVM project changes are 
>> reviewed/committed.
>>  
>> 
>> 
>> Repository:
>>   rL LLVM
>> 
>> https://reviews.llvm.org/D27180 
>> 
>> Files:
>>   test/Import/clang-flags/Inputs/S.c
>>   test/Import/clang-flags/test.c
>>   test/Import/empty-struct/Inputs/S.c
>>   test/Import/empty-struct/test.c
>>   test/Import/error-in-expression/Inputs/S.c
>>   test/Import/error-in-expression/test.c
>>   test/Import/error-in-import/Inputs/S.c
>>   test/Import/error-in-import/test.c
>>   test/Import/missing-import/test.c
>>   tools/CMakeLists.txt
>>   tools/clang-import-test/CMakeLists.txt
>>   tools/clang-import-test/clang-import-test.cpp
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org 
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
>> 

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


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

2016-12-19 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: llvm/tools/clang/test/CodeGenCXX/vtable-coverage-gen.cpp:3
+// RUN: FileCheck %s < %t 
+// CHECK: @_ZTV8Category = linkonce_odr unnamed_addr constant {{.*}}, comdat,
+

vsk wrote:
> ahatanak wrote:
> > I'm not sure I understood the purpose of this test, but It looks like the 
> > vtable for Category is generated in the IR with linkonce_odr without your 
> > patch.
> Yes, I'm seeing the same thing and am also confused. I can reproduce the 
> build failure without using any vtables. To me this suggests the problem 
> could be elsewhere. Here is a minimal reproducer:
> 
> ```
> struct Base {
>   static const Base *get();
> };
> 
> struct Derived : public Base {};
> 
> const Base *Base::get() {
>   static Derived d;
>   return &d;
> }
> 
> int main() { return 0; }
> ```
^ Please ignore my last comment, I made a mistake while trying to compile your 
reproducer. When I used a proper compile command, I could not reproduce the 
build failure on Darwin/MachO (-fprofile-instr-generate -fcoverage-mapping).


https://reviews.llvm.org/D27410



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


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

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

Remove 'else' after return.
Remove 'return' on void type.


https://reviews.llvm.org/D27872

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

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

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

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



Comment at: include/clang/AST/Decl.h:2388
+  /// its alignment is smaller than the alignment of its field type.
+  bool isPackedField(const ASTContext& context) const;
+

Should be `&Context` instead of `& context`.



Comment at: include/clang/AST/Expr.h:412
 
+  /// States that this object is ordinary, packed field or bitfield
   bool isOrdinaryOrBitFieldObject() const {

bit-field instead of bitfield (we're starting to standardize on the spelling 
used by the standards).



Comment at: include/clang/AST/Expr.h:432
   ///
-  /// In C++, whether a gl-value refers to a bitfield is essentially
+  /// In C++, whether a glvalue refers to a itfield is essentially
   /// an aspect of the value-kind type system.

typo: bit-field.



Comment at: include/clang/AST/Expr.h:440
+  ///
+  /// Like bitfields, we model glvalues referring to packed fields as
+  /// an aspect of the object kind type system.

s/bitfields/bit-fields



Comment at: include/clang/Basic/Specifiers.h:126
 
+/// A packed-field is a field on a C or C++ packed record.
+OK_PackedField,

Remove the hyphen from packed-field.



Comment at: lib/Sema/SemaInit.cpp:4459
+if (RefRelationship == Sema::Ref_Compatible)
+{
+  if (Initializer->refersToPackedField()) {

Move the brace to the preceding line.


https://reviews.llvm.org/D23325



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


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

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

Remove more 'else' after return.


https://reviews.llvm.org/D27872

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

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

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

2016-12-19 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added inline comments.



Comment at: lib/Driver/Tools.cpp:2211
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef fname = A->getValue();
+if (!llvm::sys::fs::exists(fname))

"fname" -> "FName", "FileName", etc, or any name that starts with a capital 
letter


https://reviews.llvm.org/D27832



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


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

2016-12-19 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons marked 9 inline comments as done.
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:77-78
+static bool sameValue(const Expr *E1, const Expr *E2) {
+  E1 = ignoreUnaryPlus(getInitializer(E1->IgnoreImpCasts()));
+  E2 = ignoreUnaryPlus(getInitializer(E2->IgnoreImpCasts()));
+

aaron.ballman wrote:
> Do you also want to ignore paren expressions?
Maybe. 
Am I reimplementing some existing clang function here?



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:123
+
+void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
+  auto Init =

aaron.ballman wrote:
> This check should not register matchers for C++ < 11.
I always forget to add a condition here; maybe add_new_check.py could remind me.


https://reviews.llvm.org/D26750



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


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

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



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:77-78
+static bool sameValue(const Expr *E1, const Expr *E2) {
+  E1 = ignoreUnaryPlus(getInitializer(E1->IgnoreImpCasts()));
+  E2 = ignoreUnaryPlus(getInitializer(E2->IgnoreImpCasts()));
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > Do you also want to ignore paren expressions?
> Maybe. 
> Am I reimplementing some existing clang function here?
You can use `IgnoreParenImpCasts()` instead.


https://reviews.llvm.org/D26750



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


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

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



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:77-78
+static bool sameValue(const Expr *E1, const Expr *E2) {
+  E1 = ignoreUnaryPlus(getInitializer(E1->IgnoreImpCasts()));
+  E2 = ignoreUnaryPlus(getInitializer(E2->IgnoreImpCasts()));
+

aaron.ballman wrote:
> malcolm.parsons wrote:
> > aaron.ballman wrote:
> > > Do you also want to ignore paren expressions?
> > Maybe. 
> > Am I reimplementing some existing clang function here?
> You can use `IgnoreParenImpCasts()` instead.
I mean is sameValue() implemented elsewhere?


https://reviews.llvm.org/D26750



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


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

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



Comment at: clang-tidy/modernize/UseDefaultMemberInitCheck.cpp:77-78
+static bool sameValue(const Expr *E1, const Expr *E2) {
+  E1 = ignoreUnaryPlus(getInitializer(E1->IgnoreImpCasts()));
+  E2 = ignoreUnaryPlus(getInitializer(E2->IgnoreImpCasts()));
+

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > Do you also want to ignore paren expressions?
> > > Maybe. 
> > > Am I reimplementing some existing clang function here?
> > You can use `IgnoreParenImpCasts()` instead.
> I mean is sameValue() implemented elsewhere?
Not in a general form in Clang, at least that I am aware of.


https://reviews.llvm.org/D26750



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

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



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:22
+
+const internal::VariadicDynCastAllOfMatcher tagDecl;
+

We may want to consider adding this to ASTMatchers.h at some point (can be done 
in a future patch).



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:25
+static bool isWhitespaceExceptNL(unsigned char C);
+static std::string removeMultiLineComments(std::string Str);
+static std::string getCurrentLineIndent(SourceLocation Loc,

This should accept by `const std::string &`.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:32
+  // Matches all non-single declaration within a compound statement {...}.
+  // Unless, the variable declaration is a object definition directly after
+  // a tag declaration (e.g. struct, class etc.):

is a object -> is an object



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:34
+  // a tag declaration (e.g. struct, class etc.):
+  // class A { } Object1, Object2;  <-- won't be matched
+  Finder->addMatcher(

Why do we not want to match this?



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:44
+  const auto *DeclStatement = Result.Nodes.getNodeAs("declstmt");
+  if (DeclStatement == nullptr)
+return;

No need to compare against nullptr explicitly (I think we have a clang-tidy 
check that will warn on this, in fact).



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:53
+  const LangOptions &LangOpts = getLangOpts();
+  const auto DeclGroup = DeclStatement->getDeclGroup();
+

Please don't use `auto` as the type is not spelled out explicitly in the 
initialization. Same elsewhere, though it is fine with `diag()` and in for loop 
initializers.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:61
+  DeclStmtStart,
+  "declaration statement can be split up into single line declarations");
+

This reads a bit awkwardly since it doesn't explain why the code is 
problematic. Perhaps: "multiple declarations should be split into individual 
declarations to improve readability" or something like that?



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:67
+  for (auto It = DeclGroup.begin() + 1; It != DeclGroup.end(); ++It) {
+
+const auto NameLocation = dyn_cast(*It)->getLocation();

No need for the newline.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:81
+
+  // Check for pre-processor directive and add appropriate newline
+  if (AnyTokenBetweenCommaAndVarName.front() == '#')

Missing a full stop at the end of the sentence. Also, no hyphen in 
preprocessor, and it should be "add an appropriate".



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:83
+  if (AnyTokenBetweenCommaAndVarName.front() == '#')
+AnyTokenBetweenCommaAndVarName.insert(0, "\n");
+

Will this (and the below `\n`) be converted into a CRLF automatically on 
platforms where that is the newline character sequence in the source?



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:87
+   << FixItHint::CreateReplacement(AfterCommaToVarNameRange,
+   "\n" + CurrentIndent +
+   UserWrittenType + " " +

This should probably use a `Twine` to avoid a bunch of copies.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:101
+  QualType Type;
+  if (const auto *FirstVar = dyn_cast(*FirstVarIt)) {
+Location = FirstVar->getLocation();

You can drop the `const` from the `dyn_cast`, here and elsewhere.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:107
+Type = FirstVar->getTypeSourceInfo()->getType();
+while (Type->isLValueReferenceType()) {
+  Type = Type->getPointeeType();

Why references and not pointers? Perhaps this needs a comment.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:131
+  Type->isFunctionPointerType() || Type->isFunctionProtoType()) {
+Pos = UserWrittenType.find_first_of("&*(");
+if (Pos != std::string::npos) { // might be hidden behind typedef etc.

You may want to include tests for pathological code, like:
```
int *(i), (*j), (((k)));
```



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:132
+Pos = UserWrittenType.find_first_of("&*(");
+if (Pos != std::string::npos) { // might be hidden behind typedef etc.
+  UserWrittenType.erase(Pos);

`m` should be c

[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

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



Comment at: include/clang/Basic/Attr.td:862
+def FormatDynamicKeyArg : InheritableAttr {
+  let Spellings = [GCC<"format_dynamic_key_arg">];
+  let Args = [IntArgument<"FormatIdx">];

arphaman wrote:
> aaron.ballman wrote:
> > Does GCC support this attribute as well? If not, this should use the GNU 
> > spelling instead of the GCC one. Also, should this have a C++11 spelling in 
> > the clang namespace?
> > 
> > The name doesn't really convey much about what the attribute is doing, 
> > mostly because it doesn't seem obvious what "key" means.
> > 
> > It seems that the crux of what this attribute says is that the attributed 
> > function accepts a string argument of a format specifier and returns the 
> > same format specifier. Perhaps `returns_format_specifier` is a better name?
> > Does GCC support this attribute as well? If not, this should use the GNU 
> > spelling instead of the GCC one. 
> 
> No, it doesn't. Thanks for pointing that out, I fixed it.
> 
> > Also, should this have a C++11 spelling in the clang namespace?
> 
> I don't know, is that required for new attributes? I don't need the C++11 
> spelling personally, and I don't know if there is anyone else who's 
> interested in this attribute.  
> 
> > The name doesn't really convey much about what the attribute is doing, 
> > mostly because it doesn't seem obvious what "key" means.
> > 
> > It seems that the crux of what this attribute says is that the attributed 
> > function accepts a string argument of a format specifier and returns the 
> > same format specifier. Perhaps returns_format_specifier is a better name?
> 
> You're right, the name should convey the intended meaning better. I switched 
> to `loads_format_specifier_value_using_key`, how does that sound?
> I think it sounds better than just `returns_format_specifier` because I would 
> like to see this attribute used only for a particular kind of function. This 
> kind of function should load the value at runtime using the key from a 
> platform-specific file/database that might also be accessible at 
> compile-time. It shouldn't be used for functions that might just modify the 
> given key, which, IMO, `returns_format_specifier` can imply.
>> Also, should this have a C++11 spelling in the clang namespace?
> I don't know, is that required for new attributes? I don't need the C++11 
> spelling personally, and I don't know if there is anyone else who's 
> interested in this attribute.

It's not required, but not everyone likes GNU-style attributes, so having 
something a bit less awful is a kindness.

>> The name doesn't really convey much about what the attribute is doing, 
>> mostly because it doesn't seem obvious what "key" means.
>> It seems that the crux of what this attribute says is that the attributed 
>> function accepts a string argument of a format specifier and returns the 
>> same format specifier. Perhaps returns_format_specifier is a better name?
>You're right, the name should convey the intended meaning better. I switched 
>to loads_format_specifier_value_using_key, how does that sound?
> I think it sounds better than just returns_format_specifier because I would 
> like to see this attribute used only for a particular kind of function. This 
> kind of function should load the value at runtime using the key from a 
> platform-specific file/database that might also be accessible at 
> compile-time. It shouldn't be used for functions that might just modify the 
> given key, which, IMO, returns_format_specifier can imply.

It's a bit wordy, but I think it's better than the original name.



Comment at: include/clang/Basic/AttrDocs.td:1759
+function accepts a key string that corresponds to some external ``printf`` or
+``scanf``-like format string value, loads the value that corresponds to the
+given key and returns that value.

value -> specifier (same below).



Comment at: include/clang/Basic/AttrDocs.td:1766
+specifiers found in the key string.
+  }];
+}

Given that this is uses novel terminology like "key string", I think an example 
would be useful to add.

The docs should also mention that this attribute accepts an argument, and that 
the argument is 1-based instead of 0-based (I can't count how many times that's 
tripped me up).



Comment at: lib/Sema/SemaChecking.cpp:4408
+static void CheckFormatString(
+Sema &S, const FormatStringLiteral *FExpr, const Expr *OrigFormatExpr,
+ArrayRef Args, bool HasVAListArg, unsigned format_idx,

I think the original formatting was easier to read.



Comment at: lib/Sema/SemaChecking.cpp:4418
 // True string literals are then checked by CheckFormatString.
-static StringLiteralCheckType
-checkFormatStringExpr(Sema &S, const Expr *E, ArrayRef Args,
-  bool HasVAListArg, unsigned format_idx,
-  unsigned fir

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

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

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

In C++11, a destructor without an explicit exception-spec gets an implicit 
exception-spec.
If the dtor has a body, the implicit exception-spec permits throwing exactly 
the set of types thrown by anything the dtor calls.  If the dtor doesn't have a 
body, use what would be the default dtor's body to determine the implicit 
exception-spec.  If there are no calls, the implicit exception-spec is nothrow.


https://reviews.llvm.org/D27936

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

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

r290132 - Add fix-it notes to the nullability consistency warning.

2016-12-19 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Mon Dec 19 14:58:20 2016
New Revision: 290132

URL: http://llvm.org/viewvc/llvm-project?rev=290132&view=rev
Log:
Add fix-it notes to the nullability consistency warning.

This is especially important for arrays, since no one knows the proper
syntax for putting qualifiers in arrays.

nullability.h:3:26: warning: array parameter is missing a nullability type 
specifier (_Nonnull, _Nullable, or _Null_unspecified)
void arrayParameter(int x[]);
 ^
nullability.h:3:26: note: insert '_Nullable' if the array parameter may be 
null
void arrayParameter(int x[]);
 ^
  _Nullable
nullability.h:3:26: note: insert '_Nonnull' if the array parameter should 
never be null
void arrayParameter(int x[]);
 ^
  _Nonnull

rdar://problem/29524992

Added:
cfe/trunk/test/FixIt/Inputs/
cfe/trunk/test/FixIt/Inputs/nullability.h
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/FixIt/nullability.mm
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-1.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-2.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-3.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-4.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-5.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-6.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-7.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-8.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-arrays.h

cfe/trunk/test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
cfe/trunk/test/SemaObjCXX/Inputs/nullability-pragmas-1.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=290132&r1=290131&r2=290132&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Dec 19 14:58:20 
2016
@@ -8770,6 +8770,10 @@ def warn_nullability_missing_array : War
   "array parameter is missing a nullability type specifier (_Nonnull, "
   "_Nullable, or _Null_unspecified)">,
   InGroup;
+def note_nullability_fix_it : Note<
+  "insert '%select{_Nonnull|_Nullable|_Null_unspecified}0' if the "
+  "%select{pointer|block pointer|member pointer|array parameter}1 "
+  "%select{should never be null|may be null|should not declare nullability}0">;
 
 def warn_nullability_inferred_on_nested_type : Warning<
   "inferring '_Nonnull' for pointer type within %select{array|reference}0 is "

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=290132&r1=290131&r2=290132&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Dec 19 14:58:20 2016
@@ -3441,6 +3441,57 @@ static FileID getNullabilityCompleteness
   return file;
 }
 
+/// Creates a fix-it to insert a C-style nullability keyword at \p pointerLoc,
+/// taking into account whitespace before and after.
+static FixItHint fixItNullability(Sema &S, SourceLocation PointerLoc,
+  NullabilityKind Nullability) {
+  assert(PointerLoc.isValid());
+
+  SmallString<32> InsertionTextBuf{" "};
+  InsertionTextBuf += getNullabilitySpelling(Nullability);
+  InsertionTextBuf += " ";
+  StringRef InsertionText = InsertionTextBuf.str();
+
+  SourceLocation FixItLoc = S.getLocForEndOfToken(PointerLoc);
+  if (const char *NextChar = S.SourceMgr.getCharacterData(FixItLoc)) {
+if (isWhitespace(*NextChar)) {
+  InsertionText = InsertionText.drop_back();
+} else if (NextChar[-1] == '[') {
+  if (NextChar[0] == ']')
+InsertionText = InsertionText.drop_back().drop_front();
+  else
+InsertionText = InsertionText.drop_front();
+} else if (!isIdentifierBody(NextChar[0], /*allow dollar*/true) &&
+   !isIdentifierBody(NextChar[-1], /*allow dollar*/true)) {
+  InsertionText = InsertionText.drop_back().drop_front();
+}
+  }
+
+  return FixItHint::CreateInsertion(FixItLoc, InsertionText);
+}
+
+static void emitNullabilityConsistencyWarning(Sema &S,
+  SimplePointerKind PointerKind,
+  SourceLocation PointerLoc) {
+  assert(PointerLoc.isValid());
+
+  if (PointerKind == SimplePointerKind::Array) {
+S.Diag(PointerLoc, diag::warn_nullability_missing_array);
+  } else {
+S.Diag(PointerLoc, diag::warn_nullability_missing)
+  << static_cast(Pointe

[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-19 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose accepted this revision.
jordan_rose added a reviewer: jordan_rose.
jordan_rose added a comment.
This revision is now accepted and ready to land.

Doug was okay with the idea and I trust Alex and Akira would have caught any 
major problems. Committed in r290132.


Repository:
  rL LLVM

https://reviews.llvm.org/D27837



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


Re: [libcxx] r289963 - [CMake] Put headers relative to clang

2016-12-19 Thread Chris Bieneman via cfe-commits
Sorry I didn't reply to this email over the weekend. I did push a fix in 
r290052. My weekend was just a bit nuts, so I didn't take the time to reply 
here.

The bot went green after that fix. If there are other issues please let me know.

-Chris

> On Dec 16, 2016, at 5:58 PM, Evgenii Stepanov  
> wrote:
> 
> FTR,
> 
> buildbot logs:
> 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/2585/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio
> 
> External project cmake error log:
> 
> CMake Error at include/CMakeLists.txt:15 (file):
>  file COPY cannot make directory "/include/c++/v1/.": No such file or
>  directory
> 
> 
> On Fri, Dec 16, 2016 at 5:56 PM, Evgenii Stepanov
>  wrote:
>> Hi,
>> 
>> this is using LLVM_BINARY_DIR when NOT LIBCXX_USING_INSTALLED_LLVM.
>> 
>> HandleOutOfTreeLLVM.cmake defines LLVM_BINARY_DIR only when
>> LIBCXX_USING_INSTALLED_LLVM. Is it supposed to come from the user
>> cmake arguments?
>> 
>> This broke sanitizer tests on Linux (check-tsan, check-msan). See
>> add_custom_libcxx() in compiler-rt cmake scripts.
>> 
>> On Fri, Dec 16, 2016 at 9:30 AM, Chris Bieneman via cfe-commits
>>  wrote:
>>> Author: cbieneman
>>> Date: Fri Dec 16 11:30:51 2016
>>> New Revision: 289963
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=289963&view=rev
>>> Log:
>>> [CMake] Put headers relative to clang
>>> 
>>> When libcxx isn't building with an installed LLVM we copy the libcxx 
>>> headers into the LLVM build directory so that a clang in that build tree 
>>> can find the headers relative to itself.
>>> 
>>> This is only important in situations where you don't have headers installed 
>>> under /, which is common these days on Darwin.
>>> 
>>> Modified:
>>>libcxx/trunk/include/CMakeLists.txt
>>> 
>>> Modified: libcxx/trunk/include/CMakeLists.txt
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=289963&r1=289962&r2=289963&view=diff
>>> ==
>>> --- libcxx/trunk/include/CMakeLists.txt (original)
>>> +++ libcxx/trunk/include/CMakeLists.txt Fri Dec 16 11:30:51 2016
>>> @@ -10,18 +10,14 @@ set(LIBCXX_HEADER_PATTERN
>>>   ${LIBCXX_SUPPORT_HEADER_PATTERN}
>>>   )
>>> 
>>> -if (LIBCXX_STANDALONE_BUILD)
>>> -  set(LIBCXX_BUILD_ROOT "${LIBCXX_BINARY_DIR}")
>>> -else()
>>> -  set(LIBCXX_BUILD_ROOT "${LLVM_BINARY_DIR}")
>>> +if(NOT LIBCXX_USING_INSTALLED_LLVM)
>>> +  file(COPY .
>>> +DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
>>> +FILES_MATCHING
>>> +${LIBCXX_HEADER_PATTERN}
>>> +)
>>> endif()
>>> 
>>> -file(COPY .
>>> -  DESTINATION "${LIBCXX_BUILD_ROOT}/include/c++/v1"
>>> -  FILES_MATCHING
>>> -  ${LIBCXX_HEADER_PATTERN}
>>> -)
>>> -
>>> if (LIBCXX_INSTALL_HEADERS)
>>>   install(DIRECTORY .
>>> DESTINATION include/c++/v1
>>> 
>>> 
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


r290134 - [ASTReader] Sort RawComments before merging

2016-12-19 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Dec 19 15:06:06 2016
New Revision: 290134

URL: http://llvm.org/viewvc/llvm-project?rev=290134&view=rev
Log:
[ASTReader] Sort RawComments before merging

`RawComments` are sorted by comparing underlying `SourceLocation`'s. This is
done by comparing `FileID` and `Offset`; when the `FileID` is the same it means
the locations are within the same TU and the `Offset` is used.

FileID, from the source code: "A mostly-opaque identifier, where 0 is
"invalid", >0 is this module, and <-1 is something loaded from another
module.". That said, when de-serializing SourceLocations, FileID's from
RawComments loaded from other modules get negative IDs where previously they
were positive. This makes imported RawComments unsorted, leading to a wrong
merge with other comments from the current TU. Fix that by sorting RawComments
properly after de-serialization and before merge.

This fixes an assertion in `ASTContext::getRawCommentForDeclNoCache`,
which fires only in a debug build of clang.

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

rdar://problem/29287314

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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=290134&r1=290133&r2=290134&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Dec 19 15:06:06 2016
@@ -8471,6 +8471,10 @@ void ASTReader::ReadComments() {
   }
 }
   NextCursor:
+// De-serialized SourceLocations get negative FileIDs for other modules,
+// potentially invalidating the original order. Sort it again.
+std::sort(Comments.begin(), Comments.end(),
+  BeforeThanCompare(SourceMgr));
 Context.Comments.addDeserializedComments(Comments);
   }
 }


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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2016-12-19 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated the summary for this revision.
tigerleapgorge updated this revision to Diff 81987.
tigerleapgorge added a comment.

Update Lit patch #11 to match latest Clang behavior
2 minor changes in this update

1. Back out test/CodeGenCXX/mangle-unnamed.cpp   because it has already been 
fixed.

2. Modified test/CodeGenCXX/static-init.cpp to match latest IR.

Also, this patch contained full context diff while the previous one does not.
Previous revision: svn diff
This revision svn diff --diff-cmd=diff -x -U99

Also reorder summery for the tests to be in the order of the patch.


https://reviews.llvm.org/D24812

Files:
  test/CodeGenCXX/arm.cpp
  test/CodeGenCXX/debug-info-class.cpp
  test/CodeGenCXX/eh-aggregate-copy-destroy.cpp
  test/CodeGenCXX/exceptions.cpp
  test/CodeGenCXX/goto.cpp
  test/CodeGenCXX/linetable-cleanup.cpp
  test/CodeGenCXX/lpad-linetable.cpp
  test/CodeGenCXX/mangle-unnamed.cpp
  test/CodeGenCXX/static-init.cpp
  test/CodeGenCXX/value-init.cpp
  test/CodeGenCXX/volatile-1.cpp
  test/CodeGenCXX/volatile.cpp
  test/Index/comment-cplus-decls.cpp
  test/OpenMP/atomic_codegen.cpp
  test/OpenMP/threadprivate_codegen.cpp
  test/PCH/macro-undef.cpp

Index: test/PCH/macro-undef.cpp
===
--- test/PCH/macro-undef.cpp
+++ test/PCH/macro-undef.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -275,7 +275,7 @@
 // CHECK:  {{.*}}[[ARR_LOOP]]{{.*}}
 // CHECK-NEXT: [[ARR_ELEMENTPAST:%.*]] = phi [[S1]]* [ [[ARR_CUR]], {{.*}} ], [ [[ARR_ELEMENT:%.*]], {{.*}} ]
 // CHECK-NEXT: [[ARR_ELEMENT:%.*]] = getelementptr inbounds [[S1]], [[S1]]* [[ARR_ELEMENTPAST]], i{{.*}} -1
-// CHECK-NEXT: invoke {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]])
+// CHECK-NEXT: {{call|invoke}} {{.*}} [[S1_DTOR]]([[S1]]* [[ARR_ELEMENT]])
 // CHECK:  [[ARR_DONE:%.*]] = icmp eq [[S1]]* [[ARR_ELEMENT]], [[ARR_BEGIN]]
 // CHECK-NEXT: br i1 [[ARR_DONE]], label %[[ARR_EXIT:.*]], label %[[ARR_LOOP]]
 // CHECK:  {{.*}}[[ARR_EXIT]]{{.*}}
Index: test/OpenMP/atomic_codegen.cpp
===
--- test/OpenMP/atomic_codegen.cpp
+++ test/OpenMP/atomic_codegen.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -x c++ -emit-llvm -std=c++11 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=TERM_DEBUG
 // expected-no-diagnostics
 
@@ -21,14 +23,15 @@
   // CHECK: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]])
   // CHECK: [[SCALAR_VAL:%.+]] = load atomic i32, i32* [[SCALAR_ADDR]] monotonic
   // CHECK: store i32 [[SCALAR_VAL]], i32* @b
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK98: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK11: call void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
 #pragma omp atomic read
   b = St().get();
   // CHECK-DAG: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]])
   // CHECK-DAG: [[SCALAR_ADDR:%.+]] = invoke dereferenceable(4) i32* @_ZN2St3getEv(%struct.St* [[TEMP_ST_ADDR]])
   // CHECK-DAG: [[B_VAL:%.+]] = load i32, i32* @b
   // CHECK: store atomic i32 [[B_VAL]], i32* [[SCALAR_ADDR]] monotonic
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+  // CHECK: {{invoke|call}} void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
 #pragma omp atomic write
   St().get() = b;
   // CHECK: invoke void @_ZN2StC1Ev(%struct.St* [[TEMP_ST_ADDR:%.+]])
@@ -46,7 +49,7 @@
   // CHECK: [[COND:%.+]] = extractvalue { i32, i1 } [[RES]], 1
   // CHECK: br i1 [[COND]], label %[[OMP_DONE:.+]], label %[[OMP_UPDATE]]
   // CHECK: [[OMP_DONE]]
-  // CHECK: invoke void @_ZN2StD1Ev(%struct.St* [[TEMP_ST_ADDR]])
+

r290135 - [Format] Remove dead code.

2016-12-19 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Dec 19 15:10:50 2016
New Revision: 290135

URL: http://llvm.org/viewvc/llvm-project?rev=290135&view=rev
Log:
[Format] Remove dead code.

No functionality change.

Modified:
cfe/trunk/lib/Format/Encoding.h
cfe/trunk/lib/Format/TokenAnalyzer.h
cfe/trunk/lib/Format/WhitespaceManager.cpp
cfe/trunk/lib/Format/WhitespaceManager.h

Modified: cfe/trunk/lib/Format/Encoding.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Encoding.h?rev=290135&r1=290134&r2=290135&view=diff
==
--- cfe/trunk/lib/Format/Encoding.h (original)
+++ cfe/trunk/lib/Format/Encoding.h Mon Dec 19 15:10:50 2016
@@ -40,26 +40,6 @@ inline Encoding detectEncoding(StringRef
   return Encoding_Unknown;
 }
 
-inline unsigned getCodePointCountUTF8(StringRef Text) {
-  unsigned CodePoints = 0;
-  for (size_t i = 0, e = Text.size(); i < e;
-   i += llvm::getNumBytesForUTF8(Text[i])) {
-++CodePoints;
-  }
-  return CodePoints;
-}
-
-/// \brief Gets the number of code points in the Text using the specified
-/// Encoding.
-inline unsigned getCodePointCount(StringRef Text, Encoding Encoding) {
-  switch (Encoding) {
-  case Encoding_UTF8:
-return getCodePointCountUTF8(Text);
-  default:
-return Text.size();
-  }
-}
-
 /// \brief Returns the number of columns required to display the \p Text on a
 /// generic Unicode-capable terminal. Text is assumed to use the specified
 /// \p Encoding.

Modified: cfe/trunk/lib/Format/TokenAnalyzer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnalyzer.h?rev=290135&r1=290134&r2=290135&view=diff
==
--- cfe/trunk/lib/Format/TokenAnalyzer.h (original)
+++ cfe/trunk/lib/Format/TokenAnalyzer.h Mon Dec 19 15:10:50 2016
@@ -55,15 +55,12 @@ public:
 
   FileID getFileID() const { return ID; }
 
-  StringRef getFileName() const { return FileName; }
-
   ArrayRef getCharRanges() const { return CharRanges; }
 
   const SourceManager &getSourceManager() const { return SM; }
 
 private:
   FileID ID;
-  StringRef FileName;
   SmallVector CharRanges;
   SourceManager &SM;
 

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=290135&r1=290134&r2=290135&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Mon Dec 19 15:10:50 2016
@@ -42,11 +42,6 @@ WhitespaceManager::Change::Change(
   TokenLength(0), PreviousEndOfTokenColumn(0), EscapedNewlineColumn(0),
   StartOfBlockComment(nullptr), IndentationOffset(0) {}
 
-void WhitespaceManager::reset() {
-  Changes.clear();
-  Replaces.clear();
-}
-
 void WhitespaceManager::replaceWhitespace(FormatToken &Tok, unsigned Newlines,
   unsigned IndentLevel, unsigned 
Spaces,
   unsigned StartOfTokenColumn,

Modified: cfe/trunk/lib/Format/WhitespaceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.h?rev=290135&r1=290134&r2=290135&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.h (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.h Mon Dec 19 15:10:50 2016
@@ -41,9 +41,6 @@ public:
 bool UseCRLF)
   : SourceMgr(SourceMgr), Style(Style), UseCRLF(UseCRLF) {}
 
-  /// \brief Prepares the \c WhitespaceManager for another run.
-  void reset();
-
   /// \brief Replaces the whitespace in front of \p Tok. Only call once for
   /// each \c AnnotatedToken.
   void replaceWhitespace(FormatToken &Tok, unsigned Newlines,


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


Re: r289754 - [c++1z] Permit constant evaluation of a call through a function pointer whose

2016-12-19 Thread Mike Aizatsky via cfe-commits
Richard,

Clang crashes for me on this code while doing "check-all". This change
seems to introduce the assert. Can you take a look?

BTW I'm not sure why bots are green. Do we build libcxx with bootstrap
compiler?


FAIL: libc++ ::
std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp
(34988 of 39764)
 TEST 'libc++ ::
std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp'
FAILED 
Command: ['/usr/local/google/home/aizatsky/out/llvm/bootstrap/bin/clang++',
'-o',
'/usr/local/google/home/aizatsky/out/llvm/default/projects/libcxx/test/std/experimental/string.view/string.view.find/Output/find
_last_of_pointer_size_size.pass.cpp.o', '-x', 'c++',
'/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/std/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp',
'-c',
'-v', '-Werror=thread-safety', '-std=c++1z', '-include',
'/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support/nasty_macros.hpp',
'-nostdinc++', '-I/usr/local/google/home/aizatsky/src/llvm/proj
ects/libcxx/include', '-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
'-D__STDC_CONSTANT_MACROS',
'-I/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support',
'-DLIBCXX_FILESYSTEM_STATIC_TEST_R
OOT="/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/std/experimental/filesystem/Inputs/static_test_env"',
'-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="/usr/local/google/home/aizatsky/out/llvm/default/
projects/libcxx/test/filesystem/Output/dynamic_env"',
'-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="/usr/bin/python2.7
/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support/filesystem_dynamic_test_h
elper.py"', '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra',
'-Werror', '-Wshadow', '-Wshadow', '-Wno-unused-command-line-argument',
'-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extension
s', '-Wno-user-defined-literals', '-Wno-sign-compare',
'-Wno-unused-variable', '-Wno-unused-parameter',
'-Wno-unused-local-typedef', '-c']
Exit Code: 254
Standard Error:
--
clang version 4.0.0 (trunk 290130) (llvm/trunk 290127)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/aizatsky/out/llvm/bootstrap/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
 "/usr/local/google/home/aizatsky/out/llvm/bootstrap/bin/clang-3.8" -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name find_last_of_pointer_size_size.pass.cpp -mrelocation
-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -coverage-not
es-file
/usr/local/google/home/aizatsky/out/llvm/default/projects/libcxx/test/std/experimental/string.view/string.view.find/Output/find_last_of_pointer_size_size.pass.cpp.gcno
-nostdinc++ -resource-dir /usr/loc
al/google/home/aizatsky/out/llvm/bootstrap/bin/../lib/clang/4.0.0 -include
/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support/nasty_macros.hpp
-I /usr/local/google/home/aizatsky/src/llvm/proj
ects/libcxx/include -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D
__STDC_CONSTANT_MACROS -I
/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support -D
"LIBCXX_FILESYSTEM_STATIC_TEST_ROOT=\"/us
r/local/google/home/aizatsky/src/llvm/projects/libcxx/test/std/experimental/filesystem/Inputs/static_test_env\""
-D
"LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT=\"/usr/local/google/home/aizatsky/out/llvm/default/projec
ts/libcxx/test/filesystem/Output/dynamic_env\"" -D
"LIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER=\"/usr/bin/python2.7
/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/test/support/filesystem_dynamic_test_helpe
r.py\"" -D _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -internal-isystem
/usr/local/include -internal-isystem
/usr/local/google/home/aizatsky/out/llvm/bootstrap/bin/../lib/clang/4.0.0/include
-internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -Werror=thread-safety -Wall -Wextra
-Wer

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

2016-12-19 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 81991.
spyffe marked 3 inline comments as done.
spyffe added a comment.

Applied Aleksei's comments, and integrated all the CMakeFiles fixes required to 
make the bots happy.


Repository:
  rL LLVM

https://reviews.llvm.org/D27180

Files:
  test/CMakeLists.txt
  test/Import/clang-flags/Inputs/S.c
  test/Import/clang-flags/test.c
  test/Import/empty-struct/Inputs/S.c
  test/Import/empty-struct/test.c
  test/Import/error-in-expression/Inputs/S.c
  test/Import/error-in-expression/test.c
  test/Import/error-in-import/Inputs/S.c
  test/Import/error-in-import/test.c
  test/Import/missing-import/test.c
  tools/CMakeLists.txt
  tools/clang-import-test/CMakeLists.txt
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -0,0 +1,319 @@
+//===-- import-test.cpp - ASTImporter/ExternalASTSource testbed ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+
+using namespace clang;
+
+static llvm::cl::opt Expression(
+"expression", llvm::cl::Required,
+llvm::cl::desc("Path to a file containing the expression to parse"));
+
+static llvm::cl::list
+Imports("import", llvm::cl::ZeroOrMore,
+llvm::cl::desc("Path to a file containing declarations to import"));
+
+static llvm::cl::list
+ClangArgs("Xcc", llvm::cl::ZeroOrMore,
+  llvm::cl::desc("Argument to pass to the CompilerInvocation"),
+  llvm::cl::CommaSeparated);
+
+namespace init_convenience {
+class TestDiagnosticConsumer : public DiagnosticConsumer {
+private:
+  std::unique_ptr Passthrough;
+  const LangOptions *LangOpts = nullptr;
+
+public:
+  TestDiagnosticConsumer()
+  : Passthrough(llvm::make_unique()) {}
+
+  virtual void BeginSourceFile(const LangOptions &LangOpts,
+   const Preprocessor *PP = nullptr) override {
+this->LangOpts = &LangOpts;
+return Passthrough->BeginSourceFile(LangOpts, PP);
+  }
+
+  virtual void EndSourceFile() override {
+this->LangOpts = nullptr;
+Passthrough->EndSourceFile();
+  }
+
+  virtual bool IncludeInDiagnosticCounts() const override {
+return Passthrough->IncludeInDiagnosticCounts();
+  }
+
+private:
+  static void PrintSourceForLocation(const SourceLocation &Loc,
+ SourceManager &SM) {
+const char *LocData = SM.getCharacterData(Loc, /*Invalid=*/nullptr);
+unsigned LocColumn =
+SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
+FileID FID = SM.getFileID(Loc);
+llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+
+assert(LocData >= Buffer->getBufferStart() &&
+   LocData < Buffer->getBufferEnd());
+
+const char *LineBegin = LocData - LocColumn;
+
+assert(LineBegin >= Buffer->getBufferStart());
+
+const char *LineEnd = nullptr;
+
+for (LineEnd = LineBegin; *LineEnd != '\n' && *LineEnd != '\r' &&
+  LineEnd < Buffer->getBufferEnd();
+ ++LineEnd)
+  ;
+
+llvm::StringRef LineString(LineBegin, LineEnd - LineBegin);
+
+llvm::errs() << LineString << '\n';
+llvm::errs().indent(LocColumn);
+llvm::errs() << '^';
+  }
+
+  virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+if (Info.hasSourceManager() && LangOpts) {
+  SourceManager &SM = Info.getSourceManager();
+
+  if (Info.getLocation().isValid()) {
+Info.getLocation().print(llvm::errs(), SM);
+llvm::errs() << ": ";
+  }
+
+  SmallString<16> DiagText;
+  Info.FormatDiagnostic(DiagText);
+  llvm::errs() << DiagText << '\n';
+
+  if (Info.getLocation().isValid()) {
+PrintSourceForLocation(Info.getLocation(), SM);
+  }
+
+  for (const CharSourceRange &Range : Info.getRanges()) {
+bool Invalid = 

[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11

2016-12-19 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: rjmccall.
probinson added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

The test conjures up and returns a temp which has a struct type, and the struct 
has some empty/padding bytes in the middle.  In C++03 these are handled as 
zero, so the code uses 'llvm.memset' to initialize the temp.
In C++11, the padding is handled as undef, so the code uses 'llvm.memcpy' 
instead, making the test fail.

I've made the test run twice, once per dialect, and check for the appropriate 
intrinsic.
It doesn't look like this is the point of the test, though,. so maybe 
hard-coding the dialect would be preferable.


https://reviews.llvm.org/D27955

Files:
  test/CodeGenCXX/arm-swiftcall.cpp


Index: test/CodeGenCXX/arm-swiftcall.cpp
===
--- test/CodeGenCXX/arm-swiftcall.cpp
+++ test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s 
-check-prefixes=CHECK,CHECKv03
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++11 | FileCheck %s 
-check-prefixes=CHECK,CHECKv11
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
@@ -48,7 +49,8 @@
 TEST(struct_1);
 // CHECK-LABEL: define {{.*}} @return_struct_1()
 // CHECK:   [[RET:%.*]] = alloca [[REC:%.*]], align 4
-// CHECK:   @llvm.memset
+// CHECKv03:   @llvm.memset
+// CHECKv11:   @llvm.memcpy
 // CHECK:   [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x 
i8\], i8, \[1 x i8\], float, float }]]*
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* 
[[CAST_TMP]], i32 0, i32 0
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align 4


Index: test/CodeGenCXX/arm-swiftcall.cpp
===
--- test/CodeGenCXX/arm-swiftcall.cpp
+++ test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK,CHECKv03
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++11 | FileCheck %s -check-prefixes=CHECK,CHECKv11
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
@@ -48,7 +49,8 @@
 TEST(struct_1);
 // CHECK-LABEL: define {{.*}} @return_struct_1()
 // CHECK:   [[RET:%.*]] = alloca [[REC:%.*]], align 4
-// CHECK:   @llvm.memset
+// CHECKv03:   @llvm.memset
+// CHECKv11:   @llvm.memcpy
 // CHECK:   [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ i32, \[2 x i8\], i8, \[1 x i8\], float, float }]]*
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align 4
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290140 - [analyzer] Add sink after construction of temporary with no-return destructor.

2016-12-19 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Dec 19 16:23:22 2016
New Revision: 290140

URL: http://llvm.org/viewvc/llvm-project?rev=290140&view=rev
Log:
[analyzer] Add sink after construction of temporary with no-return destructor.

The analyzer's CFG currently doesn't have nodes for calls to temporary
destructors. This causes the analyzer to explore infeasible paths in which
a no-return destructor would have stopped exploration and so results in false
positives when no-return destructors are used to implement assertions.

To mitigate these false positives, this patch stops generates a sink after
evaluating a constructor on a temporary object that has a no-return destructor.
This results in a loss of coverage because the time at which the destructor is
called may be after the time of construction (especially for lifetime-extended
temporaries).

This addresses PR15599.

rdar://problem/29131566

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp?rev=290140&r1=290139&r2=290140&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp Mon Dec 19 16:23:22 2016
@@ -346,6 +346,30 @@ void ExprEngine::VisitCXXConstructExpr(c
   defaultEvalCall(Bldr, *I, *Call);
   }
 
+  // If the CFG was contructed without elements for temporary destructors
+  // and the just-called constructor created a temporary object then
+  // stop exploration if the temporary object has a noreturn constructor.
+  // This can lose coverage because the destructor, if it were present
+  // in the CFG, would be called at the end of the full expression or
+  // later (for life-time extended temporaries) -- but avoids infeasible
+  // paths when no-return temporary destructors are used for assertions.
+  const AnalysisDeclContext *ADC = LCtx->getAnalysisDeclContext();
+  if (!ADC->getCFGBuildOptions().AddTemporaryDtors) {
+  const MemRegion *Target = Call->getCXXThisVal().getAsRegion();
+  if (Target && isa(Target) &&
+  Call->getDecl()->getParent()->isAnyDestructorNoReturn()) {
+
+  for (ExplodedNode *N : DstEvaluated) {
+Bldr.generateSink(CE, N, N->getState());
+  }
+
+  // There is no need to run the PostCall and PostStmtchecker
+  // callbacks because we just generated sinks on all nodes in th
+  // frontier.
+  return;
+}
+ }
+
   ExplodedNodeSet DstPostCall;
   getCheckerManager().runCheckersForPostCall(DstPostCall, DstEvaluated,
  *Call, *this);

Modified: cfe/trunk/test/Analysis/temporaries.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temporaries.cpp?rev=290140&r1=290139&r2=290140&view=diff
==
--- cfe/trunk/test/Analysis/temporaries.cpp (original)
+++ cfe/trunk/test/Analysis/temporaries.cpp Mon Dec 19 16:23:22 2016
@@ -413,6 +413,32 @@ namespace destructors {
   value ? DefaultParam(42) : DefaultParam(42);
 }
   }
+#else // !TEMPORARY_DTORS
+
+// Test for fallback logic that conservatively stops exploration after
+// executing a temporary constructor for a class with a no-return destructor
+// when temporary destructors are not enabled in the CFG.
+
+  struct CtorWithNoReturnDtor {
+CtorWithNoReturnDtor() = default;
+
+~CtorWithNoReturnDtor() __attribute__((noreturn));
+  };
+
+  void testDefaultContructorWithNoReturnDtor() {
+CtorWithNoReturnDtor();
+clang_analyzer_warnIfReached();  // no-warning
+  }
+
+  void testLifeExtensionWithNoReturnDtor() {
+const CtorWithNoReturnDtor &c = CtorWithNoReturnDtor();
+
+// This represents an (expected) loss of coverage, since the destructor
+// of the lifetime-exended temporary is executed at at the end of
+// scope.
+clang_analyzer_warnIfReached();  // no-warning
+  }
+
 #endif // TEMPORARY_DTORS
 }
 


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


[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11

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

Yes, I think being more specific about the dialect would be better.


https://reviews.llvm.org/D27955



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


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

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

In this test, the allocas for the temps come out in a different order depending 
on whether the dialect is C++03 or C++11.  To avoid depending on the default 
dialect, I forced it to C++03.

I am concerned, though, because the commentary says there should be no lifetime 
intrinsics.  While that was true in Clang 3.8, it is no longer true in Clang 
3.9, regardless of dialect.  However, the test does not actually verify that 
there are no lifetime intrinsics.

Is it still true that there should be no lifetime intrinsics?  If so, then 
there is a bug that the test has failed to detect.  If not, then the comment 
should be updated.


https://reviews.llvm.org/D27956

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


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


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


r290141 - Don't try to emit nullability fix-its within/around macros.

2016-12-19 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Mon Dec 19 16:35:24 2016
New Revision: 290141

URL: http://llvm.org/viewvc/llvm-project?rev=290141&view=rev
Log:
Don't try to emit nullability fix-its within/around macros.

The newly-added notes from r290132 are too noisy even when the fix-it
is valid. For the existing warning from r286521, it's probably the
right decision 95% of the time to put the change outside the macro if
the array is outside the macro and inside otherwise, but I don't want
to overthink it right now.

Caught by the ASan bot!

More rdar://problem/29524992

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/FixIt/Inputs/nullability.h
cfe/trunk/test/FixIt/nullability.mm

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=290141&r1=290140&r2=290141&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Dec 19 16:35:24 2016
@@ -3443,31 +3443,39 @@ static FileID getNullabilityCompleteness
 
 /// Creates a fix-it to insert a C-style nullability keyword at \p pointerLoc,
 /// taking into account whitespace before and after.
-static FixItHint fixItNullability(Sema &S, SourceLocation PointerLoc,
-  NullabilityKind Nullability) {
+static void fixItNullability(Sema &S, DiagnosticBuilder &Diag,
+ SourceLocation PointerLoc,
+ NullabilityKind Nullability) {
   assert(PointerLoc.isValid());
+  if (PointerLoc.isMacroID())
+return;
+
+  SourceLocation FixItLoc = S.getLocForEndOfToken(PointerLoc);
+  if (!FixItLoc.isValid() || FixItLoc == PointerLoc)
+return;
+
+  const char *NextChar = S.SourceMgr.getCharacterData(FixItLoc);
+  if (!NextChar)
+return;
 
   SmallString<32> InsertionTextBuf{" "};
   InsertionTextBuf += getNullabilitySpelling(Nullability);
   InsertionTextBuf += " ";
   StringRef InsertionText = InsertionTextBuf.str();
 
-  SourceLocation FixItLoc = S.getLocForEndOfToken(PointerLoc);
-  if (const char *NextChar = S.SourceMgr.getCharacterData(FixItLoc)) {
-if (isWhitespace(*NextChar)) {
-  InsertionText = InsertionText.drop_back();
-} else if (NextChar[-1] == '[') {
-  if (NextChar[0] == ']')
-InsertionText = InsertionText.drop_back().drop_front();
-  else
-InsertionText = InsertionText.drop_front();
-} else if (!isIdentifierBody(NextChar[0], /*allow dollar*/true) &&
-   !isIdentifierBody(NextChar[-1], /*allow dollar*/true)) {
+  if (isWhitespace(*NextChar)) {
+InsertionText = InsertionText.drop_back();
+  } else if (NextChar[-1] == '[') {
+if (NextChar[0] == ']')
   InsertionText = InsertionText.drop_back().drop_front();
-}
+else
+  InsertionText = InsertionText.drop_front();
+  } else if (!isIdentifierBody(NextChar[0], /*allow dollar*/true) &&
+ !isIdentifierBody(NextChar[-1], /*allow dollar*/true)) {
+InsertionText = InsertionText.drop_back().drop_front();
   }
 
-  return FixItHint::CreateInsertion(FixItLoc, InsertionText);
+  Diag << FixItHint::CreateInsertion(FixItLoc, InsertionText);
 }
 
 static void emitNullabilityConsistencyWarning(Sema &S,
@@ -3482,11 +3490,14 @@ static void emitNullabilityConsistencyWa
   << static_cast(PointerKind);
   }
 
+  if (PointerLoc.isMacroID())
+return;
+
   auto addFixIt = [&](NullabilityKind Nullability) {
-S.Diag(PointerLoc, diag::note_nullability_fix_it)
-  << static_cast(Nullability)
-  << static_cast(PointerKind)
-  << fixItNullability(S, PointerLoc, Nullability);
+auto Diag = S.Diag(PointerLoc, diag::note_nullability_fix_it);
+Diag << static_cast(Nullability);
+Diag << static_cast(PointerKind);
+fixItNullability(S, Diag, PointerLoc, Nullability);
   };
   addFixIt(NullabilityKind::Nullable);
   addFixIt(NullabilityKind::NonNull);
@@ -3888,9 +3899,10 @@ static TypeSourceInfo *GetFullTypeForDec
   if (pointerLoc.isValid() &&
   complainAboutInferringWithinChunk !=
 PointerWrappingDeclaratorKind::None) {
-S.Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type)
-  << static_cast(complainAboutInferringWithinChunk)
-  << fixItNullability(S, pointerLoc, NullabilityKind::NonNull);
+auto Diag =
+S.Diag(pointerLoc, diag::warn_nullability_inferred_on_nested_type);
+Diag << static_cast(complainAboutInferringWithinChunk);
+fixItNullability(S, Diag, pointerLoc, NullabilityKind::NonNull);
   }
 
   if (inferNullabilityInnerOnly)

Modified: cfe/trunk/test/FixIt/Inputs/nullability.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/Inputs/nullability.h?rev=290141&r1=290140&r2=290141&view=diff
==
--- cfe/trunk/test/FixIt/Inputs/nullability.h (original)
+++ cfe/trunk/test/

[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11

2016-12-19 Thread Paul Robinson via Phabricator via cfe-commits
probinson updated this revision to Diff 82021.
probinson added a comment.

Force C++03 on this test, to make it insensitive to future changes in the 
default dialect.


https://reviews.llvm.org/D27955

Files:
  test/CodeGenCXX/arm-swiftcall.cpp


Index: test/CodeGenCXX/arm-swiftcall.cpp
===
--- test/CodeGenCXX/arm-swiftcall.cpp
+++ test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.


Index: test/CodeGenCXX/arm-swiftcall.cpp
===
--- test/CodeGenCXX/arm-swiftcall.cpp
+++ test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27769: Update MSVC compat docs about debug info.

2016-12-19 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r289712


https://reviews.llvm.org/D27769



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


r290143 - [analyzer] Add checker modeling gtest APIs.

2016-12-19 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Dec 19 16:50:31 2016
New Revision: 290143

URL: http://llvm.org/viewvc/llvm-project?rev=290143&view=rev
Log:
[analyzer] Add checker modeling gtest APIs.

gtest is a widely-used unit-testing API. It provides macros for unit test
assertions:

  ASSERT_TRUE(p != nullptr);

that expand into an if statement that constructs an object representing
the result of the assertion and returns when the assertion is false:

  if (AssertionResult gtest_ar_ = AssertionResult(p == nullptr))
  ;
  else
return ...;

Unfortunately, the analyzer does not model the effect of the constructor
precisely because (1) the copy constructor implementation is missing from the
the header (so it can't be inlined) and (2) the boolean-argument constructor
is constructed into a temporary (so the analyzer decides not to inline it since
it doesn't reliably call temporary destructors right now).

This results in false positives because the analyzer does not realize that the
the assertion must hold along the non-return path.

This commit addresses the false positives by explicitly modeling the effects
of the two un-inlined constructors on the AssertionResult state.

I've added a new package, "apiModeling", for these kinds of checkers that
model APIs but don't emit any diagnostics. I envision all the checkers in
this package always being on by default.

This addresses the false positives reported in PR30936.

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

rdar://problem/22705813

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
cfe/trunk/test/Analysis/gtest.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/test/Driver/analyzer-target-enabled-checkers.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=290143&r1=290142&r2=290143&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Dec 19 
16:50:31 2016
@@ -79,6 +79,13 @@ def LocalizabilityOptIn : Package<"local
 def MPI : Package<"mpi">, InPackage;
 
 def LLVM : Package<"llvm">;
+
+// The APIModeling package is for checkers that model APIs and don't perform
+// any diagnostics. These checkers are always turned on; this package is
+// intended for API modeling that is not controlled by the the target triple.
+def APIModeling : Package<"apiModeling">, Hidden;
+def GoogleAPIModeling : Package<"google">, InPackage;
+
 def Debug : Package<"debug">;
 
 def CloneDetectionAlpha : Package<"clone">, InPackage, Hidden;
@@ -643,6 +650,17 @@ def LLVMConventionsChecker : Checker<"Co
   HelpText<"Check code for LLVM codebase conventions">,
   DescFile<"LLVMConventionsChecker.cpp">;
 
+
+
+//===--===//
+// Checkers modeling Google APIs.
+//===--===//
+
+def GTestChecker : Checker<"GTest">,
+  InPackage,
+  HelpText<"Model gtest assertion APIs">,
+  DescFile<"GTestChecker.cpp">;
+
 
//===--===//
 // Debugging checkers (for analyzer development).
 
//===--===//

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=290143&r1=290142&r2=290143&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 19 16:50:31 2016
@@ -4263,6 +4263,7 @@ void Clang::ConstructJob(Compilation &C,
 // Add default argument set.
 if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
   CmdArgs.push_back("-analyzer-checker=core");
+  CmdArgs.push_back("-analyzer-checker=apiModeling");
 
 if (!IsWindowsMSVC) {
   CmdArgs.push_back("-analyzer-checker=unix");

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=290143&r1=290142&r2=290143&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Dec 19 16:50:31 
2016
@@ -37,6 +37,7 @@ add_clang_library(clangStaticAnalyzerChe
   ExprInspectionChecker.cpp
   FixedAddressChecker.cpp
   GenericTaintChecker.cpp
+  GTestChecker.cpp
   IdenticalExprChecker.cpp
   IvarInvalidationChecker.cpp
   LLVMConventionsChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Ch

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

2016-12-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D24969



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


[PATCH] D27478: Make ASTContext::getDeclAlign return the correct alignment for FunctionDecls

2016-12-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D27478



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


[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11

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

LGTM, thanks!


https://reviews.llvm.org/D27955



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


[PATCH] D27955: Make CodeGenCXX/arm-swiftcall.cpp tolerate C++11

2016-12-19 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL290145: Make another test insensitive to the default C++ 
dialect. (authored by probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27955?vs=82021&id=82028#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27955

Files:
  cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp


Index: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
===
--- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
+++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.


Index: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
===
--- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
+++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s -Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290145 - Make another test insensitive to the default C++ dialect.

2016-12-19 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Mon Dec 19 17:32:10 2016
New Revision: 290145

URL: http://llvm.org/viewvc/llvm-project?rev=290145&view=rev
Log:
Make another test insensitive to the default C++ dialect.

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

Modified:
cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp

Modified: cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp?rev=290145&r1=290144&r2=290145&view=diff
==
--- cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/arm-swiftcall.cpp Mon Dec 19 17:32:10 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -o - %s 
-Wno-return-type-c-linkage -std=c++03 | FileCheck %s -check-prefixes=CHECK
 
 // This isn't really testing anything ARM-specific; it's just a convenient
 // 32-bit platform.


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


[PATCH] D26546: [PPC] Add vec_insert4b/vec_extract4b to altivec.h

2016-12-19 Thread Sean Fertile via Phabricator via cfe-commits
sfertile updated this revision to Diff 82031.
sfertile marked 6 inline comments as done.
sfertile added a comment.

Updated to swap the arguments when generating the intrinsic. Updated a number 
of the comments, and added some tests with the index out of range.


Repository:
  rL LLVM

https://reviews.llvm.org/D26546

Files:
  include/clang/Basic/BuiltinsPPC.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-error.c
  test/CodeGen/builtins-ppc-extractword-error.c
  test/CodeGen/builtins-ppc-insertword-error.c
  test/CodeGen/builtins-ppc-p9vector.c

Index: test/CodeGen/builtins-ppc-p9vector.c
===
--- test/CodeGen/builtins-ppc-p9vector.c
+++ test/CodeGen/builtins-ppc-p9vector.c
@@ -1166,17 +1166,52 @@
 // CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
 // CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
 // CHECK-BE-NEXT: ret <4 x float>
-// CHECK-LE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
-// CHECK-LE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
-// CHECK-LE-NEXT: ret <4 x float>
+// CHECK: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
+// CHECK: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
+// CHECK-NEXT: ret <4 x float>
   return vec_extract_fp32_from_shorth(vusa);
 }
 vector float test115(void) {
 // CHECK-BE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
 // CHECK-BE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
 // CHECK-BE-NEXT: ret <4 x float>
-// CHECK-LE: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
-// CHECK-LE: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
-// CHECK-LE-NEXT: ret <4 x float>
+// CHECK: shufflevector <8 x i16> {{.+}}, <8 x i16> {{.+}}, <8 x i32> 
+// CHECK: @llvm.ppc.vsx.xvcvhpsp(<8 x i16> {{.+}})
+// CHECK-NEXT: ret <4 x float>
   return vec_extract_fp32_from_shortl(vusa);
 }
+vector unsigned char test116(void) {
+// CHECK-BE: [[T1:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxinsertw(<4 x i32> {{.+}}, <2 x i64> {{.+}}, i32 7)
+// CHECK-BE-NEXT: bitcast <4 x i32> [[T1]] to <16 x i8>
+// CHECK: [[T1:%.+]] = shufflevector <2 x i64> {{.+}}, <2 x i64> {{.+}}, <2 x i32> 
+// CHECK-NEXT: [[T2:%.+]] =  bitcast <2 x i64> [[T1]] to <4 x i32>
+// CHECK-NEXT: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxinsertw(<4 x i32> [[T2]], <2 x i64> {{.+}}, i32 5)
+// CHECK-NEXT: bitcast <4 x i32> [[T3]] to <16 x i8>
+  return vec_insert4b(vuia, vuca, 7);
+}
+vector unsigned char test117(void) {
+// CHECK-BE: [[T1:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxinsertw(<4 x i32> {{.+}}, <2 x i64> {{.+}}, i32 12)
+// CHECK-BE-NEXT: bitcast <4 x i32> [[T1]] to <16 x i8>
+// CHECK: [[T1:%.+]] = shufflevector <2 x i64> {{.+}}, <2 x i64> {{.+}}, <2 x i32> 
+// CHECK-NEXT: [[T2:%.+]] =  bitcast <2 x i64> [[T1]] to <4 x i32>
+// CHECK-NEXT: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxinsertw(<4 x i32> [[T2]], <2 x i64> {{.+}}, i32 0)
+// CHECK-NEXT: bitcast <4 x i32> [[T3]] to <16 x i8>
+  return vec_insert4b(vuia, vuca, 13);
+}
+vector unsigned long long test118(void) {
+// CHECK-BE: call <2 x i64> @llvm.ppc.vsx.xxextractuw(<2 x i64> {{.+}}, i32 11)
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: [[T1:%.+]] = call <2 x i64> @llvm.ppc.vsx.xxextractuw(<2 x i64> {{.+}}, i32 1)
+// CHECK-NEXT: shufflevector <2 x i64> [[T1]], <2 x i64> [[T1]], <2 x i32> 
+// CHECK-NEXT: ret <2 x i64>
+  return vec_extract4b(vuca, 11);
+}
+vector unsigned long long test119(void) {
+// CHECK-BE: call <2 x i64> @llvm.ppc.vsx.xxextractuw(<2 x i64> {{.+}}, i32 0)
+// CHECK-BE-NEXT: ret <2 x i64>
+// CHECK: [[T1:%.+]] = call <2 x i64> @llvm.ppc.vsx.xxextractuw(<2 x i64> {{.+}}, i32 12)
+// CHECK-NEXT: shufflevector <2 x i64> [[T1]], <2 x i64> [[T1]], <2 x i32> 
+// CHECK-NEXT: ret <2 x i64>
+  return vec_extract4b(vuca, -5);
+}
+
Index: test/CodeGen/builtins-ppc-insertword-error.c
===
--- /dev/null
+++ test/CodeGen/builtins-ppc-insertword-error.c
@@ -0,0 +1,16 @@
+// REQUIRES: powerpc-registered-target
+// XFAIL: powerpc
+
+// RUN: %clang -faltivec -target powerpc64le-unknown-unknown -mcpu=power8 \
+// RUN: -Wall -Werror -c %s
+
+// RUN: %clang -faltivec -target powerpc64-unknown-unknown -mcpu=power8 \
+// RUN: -Wall -Werror -c %s
+
+// expect to fail  with diagnostic: "cannot compile this builtin function yet"
+extern vector signed int vsi;
+extern vector unsigned char vuc;
+
+vector  unsigned char testInsertWord(void) {
+  return __builtin_vsx_insertword(vsi, vuc, 0);
+}
Index: test/CodeGen/builtins-ppc-extractword-error.c
===
--- /dev/null
+++ test/CodeGen/builtins-ppc-extractword-error.c
@@ -0,0 +1,15 @@
+// REQUIRES: powerpc-registered-target
+// XFAIL: powerpc
+
+// RUN: %clang -faltivec -target powerpc64le-unknown-unknown  -mcpu=power8 \
+// RUN: -Wall -Wextra -c %s
+// RUN: %clang -faltivec -target powerpc64-unknown-unknown  -mcpu=power8 \
+// RUN: -W

  1   2   >