Re: r303630 - Allow to use vfs::FileSystem for file accesses inside ASTUnit.

2017-05-24 Thread Ilya Biryukov via cfe-commits
We test it in clangd (https://reviews.llvm.org/D33416).
Logically, it's  a single change, split into two part: for cfe and
clang-tools-extra.

On Wed, May 24, 2017 at 1:48 AM, Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

> Any specific reason why this doesn't contain a testcase?
>
> On Tue, May 23, 2017 at 4:37 AM, Ilya Biryukov via cfe-commits
>  wrote:
> > Author: ibiryukov
> > Date: Tue May 23 06:37:52 2017
> > New Revision: 303630
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=303630&view=rev
> > Log:
> > Allow to use vfs::FileSystem for file accesses inside ASTUnit.
> >
> > Reviewers: bkramer, krasimir, arphaman, akyrtzi
> >
> > Reviewed By: bkramer
> >
> > Subscribers: klimek, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D33397
> >
> > Modified:
> > cfe/trunk/include/clang/Frontend/ASTUnit.h
> > cfe/trunk/include/clang/Frontend/CompilerInvocation.h
> > cfe/trunk/lib/Frontend/ASTUnit.cpp
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> >
> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Frontend/ASTUnit.h?rev=303630&r1=303629&r2=303630&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 23 06:37:52 2017
> > @@ -59,6 +59,10 @@ class TargetInfo;
> >  class FrontendAction;
> >  class ASTDeserializationListener;
> >
> > +namespace vfs {
> > +class FileSystem;
> > +}
> > +
> >  /// \brief Utility class for loading a ASTContext from an AST file.
> >  ///
> >  class ASTUnit : public ModuleLoader {
> > @@ -420,7 +424,8 @@ private:
> >explicit ASTUnit(bool MainFileIsAST);
> >
> >bool Parse(std::shared_ptr PCHContainerOps,
> > - std::unique_ptr OverrideMainBuffer);
> > + std::unique_ptr OverrideMainBuffer,
> > + IntrusiveRefCntPtr VFS);
> >
> >struct ComputedPreamble {
> >  llvm::MemoryBuffer *Buffer;
> > @@ -434,11 +439,13 @@ private:
> >PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
> >};
> >ComputedPreamble ComputePreamble(CompilerInvocation &Invocation,
> > -   unsigned MaxLines);
> > +   unsigned MaxLines,
> > +   IntrusiveRefCntPtr
> VFS);
> >
> >std::unique_ptr getMainBufferWithPrecompiledPr
> eamble(
> >std::shared_ptr PCHContainerOps,
> > -  const CompilerInvocation &PreambleInvocationIn, bool AllowRebuild
> = true,
> > +  const CompilerInvocation &PreambleInvocationIn,
> > +  IntrusiveRefCntPtr VFS, bool AllowRebuild =
> true,
> >unsigned MaxLines = 0);
> >void RealizeTopLevelDeclsFromPreamble();
> >
> > @@ -731,11 +738,17 @@ private:
> >/// of this translation unit should be precompiled, to improve the
> performance
> >/// of reparsing. Set to zero to disable preambles.
> >///
> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
> Note that
> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
> so in order
> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
> be an
> > +  /// overlay over RealFileSystem).
> > +  ///
> >/// \returns \c true if a catastrophic failure occurred (which means
> that the
> >/// \c ASTUnit itself is invalid), or \c false otherwise.
> >bool LoadFromCompilerInvocation(
> >std::shared_ptr PCHContainerOps,
> > -  unsigned PrecompilePreambleAfterNParses);
> > +  unsigned PrecompilePreambleAfterNParses,
> > +  IntrusiveRefCntPtr VFS);
> >
> >  public:
> >
> > @@ -826,6 +839,11 @@ public:
> >/// (e.g. because the PCH could not be loaded), this accepts the
> ASTUnit
> >/// mainly to allow the caller to see the diagnostics.
> >///
> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
> Note that
> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
> so in order
> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
> be an
> > +  /// overlay over RealFileSystem). RealFileSystem will be used if \p
> VFS is nullptr.
> > +  ///
> >// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the
> ASTUnit, we
> >// shouldn't need to specify them at construction time.
> >static ASTUnit *LoadFromCommandLine(
> > @@ -842,15 +860,23 @@ public:
> >bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies
> = false,
> >bool UserFilesAreVolatile = false, bool ForSerialization = false,
> >llvm::Optional ModuleFormat = llvm::None,
> > -  std::unique_ptr *ErrAST = nullptr);
> > +  std::unique_ptr *ErrAST = nullptr,
> > +  IntrusiveRefCntPtr VFS = nullptr);
> >
> >/// \brief Reparse the source files using the same command-line
> options that
> > 

[PATCH] D33483: [OpenCL] reserve_id_t cannot be used as argument to kernel function

2017-05-24 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D33483

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/invalid-pipes-cl2.0.cl


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,6 +3,11 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+
+kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
+}
+
 void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of 
reference type}}
 }
 void test2(pipe p) {// expected-error {{missing actual type specifier for 
pipe}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7917,10 +7917,7 @@
   if (PT->isImageType())
 return PtrKernelParam;
 
-  if (PT->isBooleanType())
-return InvalidKernelParam;
-
-  if (PT->isEventT())
+  if (PT->isBooleanType() || PT->isEventT() || PT->isReserveIDT())
 return InvalidKernelParam;
 
   // OpenCL extension spec v1.2 s9.5:


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,6 +3,11 @@
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+
+kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
+}
+
 void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of reference type}}
 }
 void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7917,10 +7917,7 @@
   if (PT->isImageType())
 return PtrKernelParam;
 
-  if (PT->isBooleanType())
-return InvalidKernelParam;
-
-  if (PT->isEventT())
+  if (PT->isBooleanType() || PT->isEventT() || PT->isReserveIDT())
 return InvalidKernelParam;
 
   // OpenCL extension spec v1.2 s9.5:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100053.
Typz added a comment.

Fix SFS_Empty & SFS_Inline merging of empty function when 
BraceWrapping.AfterFunction, and add missing test


https://reviews.llvm.org/D33447

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6006,6 +6006,36 @@
getLLVMStyleWithColumns(23));
 }
 
+TEST_F(FormatTest, PullEmptyFunctionDefinitionsIntoSingleLine) {
+  FormatStyle MergeEmptyOnly = getLLVMStyle();
+  MergeEmptyOnly.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeEmptyOnly);
+  verifyFormat("class C {\n"
+   "  int f() {\n"
+			   "return 42;\n"
+			   "  }\n"
+   "};",
+   MergeEmptyOnly);
+  verifyFormat("int f() {}",
+   MergeEmptyOnly);
+  verifyFormat("int f() {\n"
+   "  return 42;\n"
+   "}",
+   MergeEmptyOnly);
+
+  // Also verify behavior when BraceWrapping.AfterFunction = true
+  MergeEmptyOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
+  MergeEmptyOnly.BraceWrapping.AfterFunction = true;
+  verifyFormat("int f() {}", MergeEmptyOnly);
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeEmptyOnly);
+}
+
 TEST_F(FormatTest, PullInlineFunctionDefinitionsIntoSingleLine) {
   FormatStyle MergeInlineOnly = getLLVMStyle();
   MergeInlineOnly.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
@@ -6017,6 +6047,104 @@
"  return 42;\n"
"}",
MergeInlineOnly);
+
+  // SFS_Inline implies SFS_Empty
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeInlineOnly);
+  verifyFormat("int f() {}",
+   MergeInlineOnly);
+
+  // Also verify behavior when BraceWrapping.AfterFunction = true
+  MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
+  MergeInlineOnly.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "  int f() { return 42; }\n"
+   "};",
+   MergeInlineOnly);
+  verifyFormat("int f()\n"
+			   "{\n"
+   "  return 42;\n"
+   "}",
+   MergeInlineOnly);
+
+  // SFS_Inline implies SFS_Empty
+  verifyFormat("int f() {}", MergeInlineOnly);
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeInlineOnly);
+}
+
+TEST_F(FormatTest, AllowEmptyFunctionBodyOnASingleLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  Style.AllowEmptyFunctionBodyOnASingleLine = true;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.ColumnLimit = 40;
+
+  verifyFormat("int f()\n"
+   "{}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+   "  return 42;\n"
+   "}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+   "  // some comment\n"
+   "}",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("int f() {}", Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+			   "  return 0;\n"
+			   "}",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
+  verifyFormat("class Foo {\n"
+			   "  int f() {}\n"
+			   "};\n",
+   Style);
+verifyFormat("class Foo {\n"
+			   "  int f() { return 0; }\n"
+			   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+			   "  int aa(int bb)\n"
+			   "  {}\n"
+			   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+			   "  int aa(int bb)\n"
+			   "  {\n"
+			   "return 0;\n"
+			   "  }\n"
+			   "};\n",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("int f() {}",
+   Style);
+  verifyFormat("int f() { return 0; }",
+   Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{}",
+   Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{\n"
+			   "  return 0;\n"
+			   "}",
+   Style);
 }
 
 TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
@@ -8670,6 +8798,7 @@
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOn

[PATCH] D33416: [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/clangd/ClangdTests.cpp:298
+  const auto SourceContents =
+  R"cpp(
+#include "foo.h"

Move this to the previous line.



Comment at: unittests/clangd/ClangdTests.cpp:336
+  const auto SourceContents =
+  R"cpp(
+#include "foo.h"

Move this to the previous line.


https://reviews.llvm.org/D33416



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


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Does anything speak against making this behavior happen with 
AllowShortFunctionsOnASingleLine = SFS_Empty and 
MergeEmptyOnly.BraceWrapping.AfterFunction = true? I mean without the extra 
style option?




Comment at: unittests/Format/FormatTest.cpp:6067
+  verifyFormat("int f()\n"
+  "{\n"
+   "  return 42;\n"

indent


https://reviews.llvm.org/D33447



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


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D33447#763045, @djasper wrote:

> Does anything speak against making this behavior happen with 
> AllowShortFunctionsOnASingleLine = SFS_Empty and 
> MergeEmptyOnly.BraceWrapping.AfterFunction = true? I mean without the extra 
> style option?


That is fine with me (with `AllowShortFunctionsOnASingleLine >= SFS_Empty` 
condition), but I see two things:

- it does not match the "OnASingleLine" part of that option's name, since in 
that case we get the function definition on one line, and the body on the next 
line
- some (existing) coding style may use `BraceWrapping.AfterFunction` and 
`AllowShortFunctionsOnASingleLine` (for exemple Mozilla), but may not want to 
change the behavior when the function cannot be merged on a single line


https://reviews.llvm.org/D33447



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


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100060.
Typz added a comment.

fix indent


https://reviews.llvm.org/D33447

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6006,6 +6006,36 @@
getLLVMStyleWithColumns(23));
 }
 
+TEST_F(FormatTest, PullEmptyFunctionDefinitionsIntoSingleLine) {
+  FormatStyle MergeEmptyOnly = getLLVMStyle();
+  MergeEmptyOnly.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeEmptyOnly);
+  verifyFormat("class C {\n"
+   "  int f() {\n"
+			   "return 42;\n"
+			   "  }\n"
+   "};",
+   MergeEmptyOnly);
+  verifyFormat("int f() {}",
+   MergeEmptyOnly);
+  verifyFormat("int f() {\n"
+   "  return 42;\n"
+   "}",
+   MergeEmptyOnly);
+
+  // Also verify behavior when BraceWrapping.AfterFunction = true
+  MergeEmptyOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
+  MergeEmptyOnly.BraceWrapping.AfterFunction = true;
+  verifyFormat("int f() {}", MergeEmptyOnly);
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeEmptyOnly);
+}
+
 TEST_F(FormatTest, PullInlineFunctionDefinitionsIntoSingleLine) {
   FormatStyle MergeInlineOnly = getLLVMStyle();
   MergeInlineOnly.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
@@ -6017,6 +6047,104 @@
"  return 42;\n"
"}",
MergeInlineOnly);
+
+  // SFS_Inline implies SFS_Empty
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeInlineOnly);
+  verifyFormat("int f() {}",
+   MergeInlineOnly);
+
+  // Also verify behavior when BraceWrapping.AfterFunction = true
+  MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
+  MergeInlineOnly.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "  int f() { return 42; }\n"
+   "};",
+   MergeInlineOnly);
+  verifyFormat("int f()\n"
+   "{\n"
+   "  return 42;\n"
+   "}",
+   MergeInlineOnly);
+
+  // SFS_Inline implies SFS_Empty
+  verifyFormat("int f() {}", MergeInlineOnly);
+  verifyFormat("class C {\n"
+   "  int f() {}\n"
+   "};",
+   MergeInlineOnly);
+}
+
+TEST_F(FormatTest, AllowEmptyFunctionBodyOnASingleLine) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  Style.AllowEmptyFunctionBodyOnASingleLine = true;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.ColumnLimit = 40;
+
+  verifyFormat("int f()\n"
+   "{}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+   "  return 42;\n"
+   "}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+   "  // some comment\n"
+   "}",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+  verifyFormat("int f() {}", Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{}",
+   Style);
+  verifyFormat("int f()\n"
+			   "{\n"
+			   "  return 0;\n"
+			   "}",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
+  verifyFormat("class Foo {\n"
+			   "  int f() {}\n"
+			   "};\n",
+   Style);
+verifyFormat("class Foo {\n"
+			   "  int f() { return 0; }\n"
+			   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+			   "  int aa(int bb)\n"
+			   "  {}\n"
+			   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+			   "  int aa(int bb)\n"
+			   "  {\n"
+			   "return 0;\n"
+			   "  }\n"
+			   "};\n",
+   Style);
+
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  verifyFormat("int f() {}",
+   Style);
+  verifyFormat("int f() { return 0; }",
+   Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{}",
+   Style);
+  verifyFormat("int aa(int bb)\n"
+			   "{\n"
+			   "  return 0;\n"
+			   "}",
+   Style);
 }
 
 TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
@@ -8670,6 +8798,7 @@
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
+  CHECK_PARSE_BOOL(AllowEmptyFunctionBodyOnASingleLine);
   CHECK_PARSE_BOOL(

[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

As it currently stands, I am really not happy with the configuration space that 
this opens up. If we can't make the configuration of existing flags, what's the 
coding style encourages this behavior?


https://reviews.llvm.org/D33447



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


[PATCH] D32479: clang-format: Introduce BreakConstructorInitializers option

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good. Thank you!




Comment at: lib/Format/ContinuationIndenter.cpp:196
+   FormatStyle::BCIS_AfterColonAndComma) &&
+  (State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
+   getColumnLimit(State) ||

Typz wrote:
> djasper wrote:
> > Typz wrote:
> > > djasper wrote:
> > > > Typz wrote:
> > > > > Typz wrote:
> > > > > > djasper wrote:
> > > > > > > Why can you drop the "+2" here?
> > > > > > > 
> > > > > > > Also, I'd like to structure this so we have to duplicate less of 
> > > > > > > the logic. But I am not really sure it's possible.
> > > > > > the +2 here was needed to keep identifiers aligned when breaking 
> > > > > > after colon but before the command (e.g. the 4th combination, not 
> > > > > > defined anymore):
> > > > > > 
> > > > > >   Foo() :
> > > > > >   field(1)
> > > > > > , field(2)
> > > > > I can avoid some duplication like this,m but i am not convinced it 
> > > > > helps :
> > > > > 
> > > > >   const FormatToken &ColonToken =
> > > > >   Style.BreakConstructorInitializers != 
> > > > > FormatStyle::BCIS_AfterColon
> > > > > ? Current : Previous;
> > > > >   if (ColonToken.is(TT_CtorInitializerColon) &&
> > > > >   (State.Column + State.Line->Last->TotalLength - 
> > > > > ColonToken.TotalLength +
> > > > >(Style.BreakConstructorInitializers !=
> > > > > FormatStyle::BCIS_AfterColon ? 2 : 0) >
> > > > >getColumnLimit(State) ||
> > > > >State.Stack.back().BreakBeforeParameter) &&
> > > > >   (Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All 
> > > > > ||
> > > > >Style.BreakConstructorInitializers != 
> > > > > FormatStyle::BCIS_BeforeColon ||
> > > > >Style.ColumnLimit != 0))
> > > > > return true;
> > > > > 
> > > > > what do you think?
> > > > The +2 here has nothing todo with how the things are aligned. This is 
> > > > about whether the entire constructor with initializer fits on one line. 
> > > > Can you try out (or even add tests) for cases where the entire 
> > > > constructor is 80 and 81 columns long?
> > > > 
> > > > I think I like the condensed version a bit better, but yeah, it's not 
> > > > beautiful either ;).
> > > My mistake, I read to quickly and talked about another +2 I removed from 
> > > an earlier patch.
> > > 
> > > As far as I understand it, this +2 accounts for the the "upcoming" space 
> > > and colon, when checking if breaking _before_ the colon (e.g. before it 
> > > was added to the line).
> > > 
> > > Since this case is trying to break _after_ the colon, the space and colon 
> > > have already been added to line (i.e. removed the column limit).
> > > 
> > > The tests are already included (and I have just double-checked: 
> > > `Constructor() : Initializer(FitsOnTheLine) {}` is indeed 45 characters) :
> > > 
> > >   verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}",
> > >getStyleWithColumns(Style, 45));
> > >   verifyFormat("Constructor() :\n"
> > >"Initializer(FitsOnTheLine) {}",
> > >getStyleWithColumns(Style, 44));
> > >   verifyFormat("Constructor() :\n"
> > >"Initializer(FitsOnTheLine) {}",
> > >getStyleWithColumns(Style, 43));
> > Ah, right. So as we are on the next token, State.Column will already 
> > include the +2. However, I think we should change that and make this always:
> > 
> >   State.Column + State.Line->Last->TotalLength - Previous.TotalLength > 
> > getColumnLimit(State)
> > 
> > I think this should automatically add the "+2" or actually +1 should we go 
> > forward with your patch to not have a space before the colon at some point.
> Seems to work indeed, looking much better!
> I had some trouble deciphering this when making my initial patch, and did not 
> take the chance/risk to try to improve the 'regular' case.
Yeah, not surprising. This code isn't exactly nice or easy to understand or 
well-commented :-(. Sorry about that.


https://reviews.llvm.org/D32479



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


r303734 - Fix 'set but not used' [-Wunused-but-set-variable] warning

2017-05-24 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Wed May 24 05:38:09 2017
New Revision: 303734

URL: http://llvm.org/viewvc/llvm-project?rev=303734&view=rev
Log:
Fix 'set but not used' [-Wunused-but-set-variable] warning

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

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=303734&r1=303733&r2=303734&view=diff
==
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed May 24 05:38:09 2017
@@ -563,7 +563,6 @@ NumericLiteralParser::NumericLiteralPars
   // Parse the suffix.  At this point we can classify whether we have an FP or
   // integer constant.
   bool isFPConstant = isFloatingLiteral();
-  const char *ImaginarySuffixLoc = nullptr;
 
   // Loop over all of the characters of the suffix.  If we see something bad,
   // we break out of the loop.
@@ -657,7 +656,6 @@ NumericLiteralParser::NumericLiteralPars
 case 'J':
   if (isImaginary) break;   // Cannot be repeated.
   isImaginary = true;
-  ImaginarySuffixLoc = s;
   continue;  // Success.
 }
 // If we reached here, there was an error or a ud-suffix.


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


[PATCH] D33173: Modify test to look for patterns in stderr as well

2017-05-24 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303735: Modify test so that it looks for patterns in stderr 
as well (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D33173?vs=98928&id=100062#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33173

Files:
  clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
@@ -1,11 +1,11 @@
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | 
FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: error reading '{{.*}}.nonexistent.cpp' 
[clang-diagnostic-error]
-// CHECK2: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
-// CHECK3: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
+// CHECK2: error: unknown argument: '-fan-unknown-option'
+// CHECK3: error: unknown argument: '-fan-unknown-option'
 
 // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' 
changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
 // CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' 
changes value


Index: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
@@ -1,11 +1,11 @@
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: error reading '{{.*}}.nonexistent.cpp' [clang-diagnostic-error]
-// CHECK2: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
-// CHECK3: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
+// CHECK2: error: unknown argument: '-fan-unknown-option'
+// CHECK3: error: unknown argument: '-fan-unknown-option'
 
 // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
 // CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r303735 - Modify test so that it looks for patterns in stderr as well

2017-05-24 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed May 24 05:50:56 2017
New Revision: 303735

URL: http://llvm.org/viewvc/llvm-project?rev=303735&view=rev
Log:
Modify test so that it looks for patterns in stderr as well

With the change https://reviews.llvm.org/D33013 driver will not build
compilation object if command line is invalid, in particular, if
unrecognized option is provided. In such cases it will prints diagnostics
on stderr. The test 'clang-tidy/diagnostic.cpp' checks reaction on
unrecognized option and will fail when D33013 is applied because it checks
only stdout for test patterns and expects the name of diagnostic category
prepared by clang-tidy. With this change the test makes more general check
and must work in either case.

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp?rev=303735&r1=303734&r2=303735&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp Wed May 24 05:50:56 
2017
@@ -1,11 +1,11 @@
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | 
FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' 
%s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 
-implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy 
-checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s 
-- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 
-implicit-check-not='{{warning:|error:}}' %s
 // RUN: clang-tidy 
-checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- 
-DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 
-implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: error reading '{{.*}}.nonexistent.cpp' 
[clang-diagnostic-error]
-// CHECK2: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
-// CHECK3: error: unknown argument: '-fan-unknown-option' 
[clang-diagnostic-error]
+// CHECK2: error: unknown argument: '-fan-unknown-option'
+// CHECK3: error: unknown argument: '-fan-unknown-option'
 
 // CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' 
changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
 // CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' 
changes value


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


[PATCH] D33416: [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-24 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 100065.
ilya-biryukov added a comment.

Minor refactoring to address @krasimir's comments


https://reviews.llvm.org/D33416

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/ClangdUnitStore.h
  unittests/CMakeLists.txt
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- /dev/null
+++ unittests/clangd/ClangdTests.cpp
@@ -0,0 +1,364 @@
+//===-- ClangdTes.cpp - Change namespace unit tests ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangdServer.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Config/config.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Regex.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace vfs {
+
+/// An implementation of vfs::FileSystem that only allows access to
+/// files and folders inside a set of whitelisted directories.
+///
+/// FIXME(ibiryukov): should it also emulate access to parents of whitelisted
+/// directories with only whitelisted contents?
+class FilteredFileSystem : public vfs::FileSystem {
+public:
+  /// The paths inside \p WhitelistedDirs should be absolute
+  FilteredFileSystem(std::vector WhitelistedDirs,
+ IntrusiveRefCntPtr InnerFS)
+  : WhitelistedDirs(std::move(WhitelistedDirs)), InnerFS(InnerFS) {
+assert(std::all_of(WhitelistedDirs.begin(), WhitelistedDirs.end(),
+   [](const std::string &Path) -> bool {
+ return llvm::sys::path::is_absolute(Path);
+   }) &&
+   "Not all WhitelistedDirs are absolute");
+  }
+
+  virtual llvm::ErrorOr status(const Twine &Path) {
+if (!isInsideWhitelistedDir(Path))
+  return llvm::errc::no_such_file_or_directory;
+return InnerFS->status(Path);
+  }
+
+  virtual llvm::ErrorOr>
+  openFileForRead(const Twine &Path) {
+if (!isInsideWhitelistedDir(Path))
+  return llvm::errc::no_such_file_or_directory;
+return InnerFS->openFileForRead(Path);
+  }
+
+  llvm::ErrorOr>
+  getBufferForFile(const Twine &Name, int64_t FileSize = -1,
+   bool RequiresNullTerminator = true,
+   bool IsVolatile = false) {
+if (!isInsideWhitelistedDir(Name))
+  return llvm::errc::no_such_file_or_directory;
+return InnerFS->getBufferForFile(Name, FileSize, RequiresNullTerminator,
+ IsVolatile);
+  }
+
+  virtual directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) {
+if (!isInsideWhitelistedDir(Dir)) {
+  EC = llvm::errc::no_such_file_or_directory;
+  return directory_iterator();
+}
+return InnerFS->dir_begin(Dir, EC);
+  }
+
+  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) {
+return InnerFS->setCurrentWorkingDirectory(Path);
+  }
+
+  virtual llvm::ErrorOr getCurrentWorkingDirectory() const {
+return InnerFS->getCurrentWorkingDirectory();
+  }
+
+  bool exists(const Twine &Path) {
+if (!isInsideWhitelistedDir(Path))
+  return false;
+return InnerFS->exists(Path);
+  }
+
+  std::error_code makeAbsolute(SmallVectorImpl &Path) const {
+return InnerFS->makeAbsolute(Path);
+  }
+
+private:
+  bool isInsideWhitelistedDir(const Twine &InputPath) const {
+SmallString<128> Path;
+InputPath.toVector(Path);
+
+if (makeAbsolute(Path))
+  return false;
+
+for (const auto &Dir : WhitelistedDirs) {
+  if (Path.startswith(Dir))
+return true;
+}
+return false;
+  }
+
+  std::vector WhitelistedDirs;
+  IntrusiveRefCntPtr InnerFS;
+};
+
+/// Create a vfs::FileSystem that has access only to temporary directories
+/// (obtained by calling system_temp_directory).
+IntrusiveRefCntPtr getTempOnlyFS() {
+  llvm::SmallString<128> TmpDir1;
+  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, TmpDir1);
+  llvm::SmallString<128> TmpDir2;
+  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/true, TmpDir2);
+
+  std::vector TmpDirs;
+  TmpDirs.push_back(TmpDir1.str());
+  if (TmpDir2 != TmpDir2)
+TmpDirs.push_back(TmpDir2.str());
+  return new vfs::FilteredFileSystem(std::move(TmpDirs),
+ vfs::getRealFileSystem());
+}
+} // namespace vfs
+
+namespace clangd {
+namespace {
+
+class ErrorCheckingDiagConsumer : public DiagnosticsConsumer {
+public:
+  void onDiagnosticsReady(PathRef File,
+  std::ve

[PATCH] D33489: [OpenCL] Added regression test on invalid vector initialization.

2017-05-24 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

This patch increases code coverage.


https://reviews.llvm.org/D33489

Files:
  test/SemaOpenCL/vector_literals_invalid.cl


Index: test/SemaOpenCL/vector_literals_invalid.cl
===
--- test/SemaOpenCL/vector_literals_invalid.cl
+++ test/SemaOpenCL/vector_literals_invalid.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s 
+// RUN: %clang_cc1 -verify %s
 
 typedef __attribute__(( ext_vector_type(4) ))  float float4;
 typedef __attribute__(( ext_vector_type(4) ))  int int4;
@@ -10,4 +10,5 @@
   int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}}
   ((float4)(1.0f))++; // expected-error{{cannot increment value of type 
'float4'}}
   int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with 
an expression of incompatible type 'float4'}}
+  ((int4)(0)).x = 8; // expected-error{{expression is not assignable}}
 }


Index: test/SemaOpenCL/vector_literals_invalid.cl
===
--- test/SemaOpenCL/vector_literals_invalid.cl
+++ test/SemaOpenCL/vector_literals_invalid.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s 
+// RUN: %clang_cc1 -verify %s
 
 typedef __attribute__(( ext_vector_type(4) ))  float float4;
 typedef __attribute__(( ext_vector_type(4) ))  int int4;
@@ -10,4 +10,5 @@
   int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}}
   ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}}
   int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with an expression of incompatible type 'float4'}}
+  ((int4)(0)).x = 8; // expected-error{{expression is not assignable}}
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r303737 - __cxa_demangle: Fix constructor cv qualifier handling

2017-05-24 Thread Tamas Berghammer via cfe-commits
Author: tberghammer
Date: Wed May 24 06:21:34 2017
New Revision: 303737

URL: http://llvm.org/viewvc/llvm-project?rev=303737&view=rev
Log:
__cxa_demangle: Fix constructor cv qualifier handling

Summary:
Previously if we parsed a constructor then we set parsed_ctor_dtor_cv
to true and never reseted it. This causes issue when a template argument
references a constructor (e.g. type of lambda defined inside a
constructor) as we will have the parsed_ctor_dtor_cv flag set what will
cause issues when parsing later arguments.

Reviewers: EricWF, compnerd

Subscribers: cfe-commits

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

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=303737&r1=303736&r2=303737&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed May 24 06:21:34 2017
@@ -4571,6 +4571,8 @@ parse_encoding(const char* first, const
 save_value sb(db.tag_templates);
 if (db.encoding_depth > 1)
 db.tag_templates = true;
+save_value 
sp(db.parsed_ctor_dtor_cv);
+db.parsed_ctor_dtor_cv = false;
 switch (*first)
 {
 case 'G':

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=303737&r1=303736&r2=303737&view=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Wed May 24 06:21:34 2017
@@ -29500,6 +29500,7 @@ const char* cases[][2] =
 {"_ZZ2f6vE1b", "f6()::b"},
 {"_ZNV3$_35test9Ev", "$_3::test9() volatile"},
 {"_ZN5Test8I3$_2EC1ES0_", "Test8<$_2>::Test8($_2)"},
+{"_Z3fooIZN3BarC1EvE3$_0EvT_", "void 
foo(Bar::Bar()::$_0)"},
 {"_ZGVZN1N1gEvE1a", "guard variable for N::g()::a"},
 {"_ZplRK1YRA100_P1X", "operator+(Y const&, X* (&) [100])"},
 {"_Z1fno", "f(__int128, unsigned __int128)"},


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


[PATCH] D33385: __cxa_demangle: Fix constructor cv qualifier handling

2017-05-24 Thread Tamas Berghammer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303737: __cxa_demangle: Fix constructor cv qualifier 
handling (authored by tberghammer).

Changed prior to commit:
  https://reviews.llvm.org/D33385?vs=99694&id=100067#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33385

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


Index: libcxxabi/trunk/test/test_demangle.pass.cpp
===
--- libcxxabi/trunk/test/test_demangle.pass.cpp
+++ libcxxabi/trunk/test/test_demangle.pass.cpp
@@ -29500,6 +29500,7 @@
 {"_ZZ2f6vE1b", "f6()::b"},
 {"_ZNV3$_35test9Ev", "$_3::test9() volatile"},
 {"_ZN5Test8I3$_2EC1ES0_", "Test8<$_2>::Test8($_2)"},
+{"_Z3fooIZN3BarC1EvE3$_0EvT_", "void 
foo(Bar::Bar()::$_0)"},
 {"_ZGVZN1N1gEvE1a", "guard variable for N::g()::a"},
 {"_ZplRK1YRA100_P1X", "operator+(Y const&, X* (&) [100])"},
 {"_Z1fno", "f(__int128, unsigned __int128)"},
Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -4571,6 +4571,8 @@
 save_value sb(db.tag_templates);
 if (db.encoding_depth > 1)
 db.tag_templates = true;
+save_value 
sp(db.parsed_ctor_dtor_cv);
+db.parsed_ctor_dtor_cv = false;
 switch (*first)
 {
 case 'G':


Index: libcxxabi/trunk/test/test_demangle.pass.cpp
===
--- libcxxabi/trunk/test/test_demangle.pass.cpp
+++ libcxxabi/trunk/test/test_demangle.pass.cpp
@@ -29500,6 +29500,7 @@
 {"_ZZ2f6vE1b", "f6()::b"},
 {"_ZNV3$_35test9Ev", "$_3::test9() volatile"},
 {"_ZN5Test8I3$_2EC1ES0_", "Test8<$_2>::Test8($_2)"},
+{"_Z3fooIZN3BarC1EvE3$_0EvT_", "void foo(Bar::Bar()::$_0)"},
 {"_ZGVZN1N1gEvE1a", "guard variable for N::g()::a"},
 {"_ZplRK1YRA100_P1X", "operator+(Y const&, X* (&) [100])"},
 {"_Z1fno", "f(__int128, unsigned __int128)"},
Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -4571,6 +4571,8 @@
 save_value sb(db.tag_templates);
 if (db.encoding_depth > 1)
 db.tag_templates = true;
+save_value sp(db.parsed_ctor_dtor_cv);
+db.parsed_ctor_dtor_cv = false;
 switch (*first)
 {
 case 'G':
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Facebook's HHVM seems to use this for empty constructors: 
https://github.com/facebook/hhvm/blob/master/hphp/doc/coding-conventions.md
This is also done systematically in Qt and QtCreator code.

Personally, I don't care if this is an option or not; but I fear it would break 
existing styles.


https://reviews.llvm.org/D33447



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


r303739 - clang-format: Introduce BreakConstructorInitializers option

2017-05-24 Thread Francois Ferrand via cfe-commits
Author: typz
Date: Wed May 24 06:36:58 2017
New Revision: 303739

URL: http://llvm.org/viewvc/llvm-project?rev=303739&view=rev
Log:
clang-format: Introduce BreakConstructorInitializers option

Summary:
This option replaces the BreakConstructorInitializersBeforeComma option with an 
enum, thus introducing a mode where the colon stays on the same line as 
constructor declaration:

  // When it fits on line:
  Constructor() : initializer1(), initializer2() {}

  // When it does not fit:
  Constructor() :
  initializer1(), initializer2()
  {}

  // When ConstructorInitializerAllOnOneLineOrOnePerLine = true:
  Constructor() :
  initializer1(),
  initializer2()
  {}

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=303739&r1=303738&r2=303739&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed May 24 06:36:58 2017
@@ -710,16 +710,35 @@ struct FormatStyle {
   /// \endcode
   bool BreakBeforeTernaryOperators;
 
-  /// \brief Always break constructor initializers before commas and align
-  /// the commas with the colon.
-  /// \code
-  ///true:  false:
-  ///SomeClass::Constructor()   vs. SomeClass::Constructor() : 
a(a),
-  ///: a(a)   b(b),
-  ///, b(b)   c(c) {}
-  ///, c(c) {}
-  /// \endcode
-  bool BreakConstructorInitializersBeforeComma;
+  /// \brief Different ways to break initializers.
+  enum BreakConstructorInitializersStyle
+  {
+/// Break constructor initializers before the colon and after the commas.
+/// \code
+/// Constructor()
+/// : initializer1(),
+///   initializer2()
+/// \endcode
+BCIS_BeforeColon,
+/// Break constructor initializers before the colon and commas, and align
+/// the commas with the colon.
+/// \code
+/// Constructor()
+/// : initializer1()
+/// , initializer2()
+/// \endcode
+BCIS_BeforeComma,
+/// Break constructor initializers after the colon and commas.
+/// \code
+/// Constructor() :
+/// initializer1(),
+/// initializer2()
+/// \endcode
+BCIS_AfterColon
+  };
+
+  /// \brief The constructor initializers style to use..
+  BreakConstructorInitializersStyle BreakConstructorInitializers;
 
   /// \brief Break after each annotation on a field in Java files.
   /// \code{.java}
@@ -1390,8 +1409,7 @@ struct FormatStyle {
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
-   BreakConstructorInitializersBeforeComma ==
-   R.BreakConstructorInitializersBeforeComma &&
+   BreakConstructorInitializers == R.BreakConstructorInitializers &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations 
&&
BreakStringLiterals == R.BreakStringLiterals &&
ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas 
&&

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=303739&r1=303738&r2=303739&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Wed May 24 06:36:58 2017
@@ -54,13 +54,14 @@ static bool startsNextParameter(const Fo
 const FormatStyle &Style) {
   const FormatToken &Previous = *Current.Previous;
   if (Current.is(TT_CtorInitializerComma) &&
-  Style.BreakConstructorInitializersBeforeComma)
+  Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeComma)
 return true;
   return Previous.is(tok::comma) && !Current.isTrailingComment() &&
  ((Previous.isNot(TT_CtorInitializerComma) ||
-  !Style.BreakConstructorInitializersBeforeComma) &&
+   Style.BreakConstructorInitializers !=
+   FormatStyle::BCIS_BeforeComma) &&
   (Previous.isNot(TT_InheritanceComma) ||
-  !Style.BreakBeforeInheritanceComma));
+   !Style.BreakBeforeInheritanceComma));
 }
 
 ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
@@ -178,13 +179

[PATCH] D32479: clang-format: Introduce BreakConstructorInitializers option

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303739: clang-format: Introduce BreakConstructorInitializers 
option (authored by Typz).

Changed prior to commit:
  https://reviews.llvm.org/D32479?vs=99887&id=100068#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32479

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -710,16 +710,35 @@
   /// \endcode
   bool BreakBeforeTernaryOperators;
 
-  /// \brief Always break constructor initializers before commas and align
-  /// the commas with the colon.
-  /// \code
-  ///true:  false:
-  ///SomeClass::Constructor()   vs. SomeClass::Constructor() : a(a),
-  ///: a(a)   b(b),
-  ///, b(b)   c(c) {}
-  ///, c(c) {}
-  /// \endcode
-  bool BreakConstructorInitializersBeforeComma;
+  /// \brief Different ways to break initializers.
+  enum BreakConstructorInitializersStyle
+  {
+/// Break constructor initializers before the colon and after the commas.
+/// \code
+/// Constructor()
+/// : initializer1(),
+///   initializer2()
+/// \endcode
+BCIS_BeforeColon,
+/// Break constructor initializers before the colon and commas, and align
+/// the commas with the colon.
+/// \code
+/// Constructor()
+/// : initializer1()
+/// , initializer2()
+/// \endcode
+BCIS_BeforeComma,
+/// Break constructor initializers after the colon and commas.
+/// \code
+/// Constructor() :
+/// initializer1(),
+/// initializer2()
+/// \endcode
+BCIS_AfterColon
+  };
+
+  /// \brief The constructor initializers style to use..
+  BreakConstructorInitializersStyle BreakConstructorInitializers;
 
   /// \brief Break after each annotation on a field in Java files.
   /// \code{.java}
@@ -1390,8 +1409,7 @@
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
-   BreakConstructorInitializersBeforeComma ==
-   R.BreakConstructorInitializersBeforeComma &&
+   BreakConstructorInitializers == R.BreakConstructorInitializers &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
BreakStringLiterals == R.BreakStringLiterals &&
ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -54,13 +54,14 @@
 const FormatStyle &Style) {
   const FormatToken &Previous = *Current.Previous;
   if (Current.is(TT_CtorInitializerComma) &&
-  Style.BreakConstructorInitializersBeforeComma)
+  Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeComma)
 return true;
   return Previous.is(tok::comma) && !Current.isTrailingComment() &&
  ((Previous.isNot(TT_CtorInitializerComma) ||
-  !Style.BreakConstructorInitializersBeforeComma) &&
+   Style.BreakConstructorInitializers !=
+   FormatStyle::BCIS_BeforeComma) &&
   (Previous.isNot(TT_InheritanceComma) ||
-  !Style.BreakBeforeInheritanceComma));
+   !Style.BreakBeforeInheritanceComma));
 }
 
 ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
@@ -178,13 +179,20 @@
   getLengthToMatchingParen(Previous) + State.Column - 1 >
   getColumnLimit(State))
 return true;
-  if (Current.is(TT_CtorInitializerColon) &&
-  (State.Column + State.Line->Last->TotalLength - Current.TotalLength + 2 >
+
+  const FormatToken &BreakConstructorInitializersToken =
+  Style.BreakConstructorInitializers == FormatStyle::BCIS_AfterColon
+  ? Previous
+  : Current;
+  if (BreakConstructorInitializersToken.is(TT_CtorInitializerColon) &&
+  (State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
getColumnLimit(State) ||
State.Stack.back().BreakBeforeParameter) &&
-  ((Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All) ||
-   Style.BreakConstructorInitializersBeforeComma || Style.ColumnLimit != 0))
+  (Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All ||
+   Style.BreakConstructorInitializers != FormatStyl

[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

But that style specifically says that it is only done if the initializer list 
is wrapped:
https://github.com/facebook/hhvm/blob/master/hphp/doc/coding-conventions.md#constructor-initializer-lists

I.e. we would do the right thing for that style if we would set 
BraceWrapping.AfterFunction to true and AllowShortFunctionsOnASingleLine to 
SFS_Empty and it would then format:

  Constructor() {}
  Constructor() //
  : initializer(..)
  {}


https://reviews.llvm.org/D33447



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


[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

clang-format already has logic to detect semicolon-less macro invocations an in 
fact this already does behave as I would expect. What are you fixing?


https://reviews.llvm.org/D33440



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


r303741 - Method loadFromCommandLine should be able to report errors

2017-05-24 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed May 24 06:57:37 2017
New Revision: 303741

URL: http://llvm.org/viewvc/llvm-project?rev=303741&view=rev
Log:
Method loadFromCommandLine should be able to report errors

Now FixedCompilationDatabase::loadFromCommandLine has no means to report
which error occurred if it fails to create compilation object. This is
a block for implementing D33013, because after that change driver will
refuse to create compilation if command line contains erroneous options.

This change adds additional argument to loadFromCommandLine, which is
assigned error message text if compilation object was not created. This is
the same way as other methods of CompilationDatabase report failure.

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

Modified:
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=303741&r1=303740&r2=303741&view=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Wed May 24 06:57:37 
2017
@@ -176,10 +176,11 @@ public:
   /// the number of arguments before "--", if "--" was found in the argument
   /// list.
   /// \param Argv Points to the command line arguments.
+  /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
-   const char *const *Argv,
-   Twine Directory = ".");
+  static std::unique_ptr loadFromCommandLine(
+  int &Argc, const char *const *Argv, std::string &ErrorMsg,
+  Twine Directory = ".");
 
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.

Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=303741&r1=303740&r2=303741&view=diff
==
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Wed May 24 
06:57:37 2017
@@ -52,6 +52,8 @@ std::unique_ptr clan
   TheDriver.setCheckInputsExist(false);
 
   std::unique_ptr C(TheDriver.BuildCompilation(Args));
+  if (!C)
+return nullptr;
 
   // Just print the cc1 options if -### was present.
   if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {

Modified: cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CommonOptionsParser.cpp?rev=303741&r1=303740&r2=303741&view=diff
==
--- cfe/trunk/lib/Tooling/CommonOptionsParser.cpp (original)
+++ cfe/trunk/lib/Tooling/CommonOptionsParser.cpp Wed May 24 06:57:37 2017
@@ -116,7 +116,11 @@ CommonOptionsParser::CommonOptionsParser
 
   cl::HideUnrelatedOptions(Category);
 
-  Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, 
argv));
+  std::string ErrorMessage;
+  Compilations =
+  FixedCompilationDatabase::loadFromCommandLine(argc, argv, ErrorMessage);
+  if (!Compilations && !ErrorMessage.empty())
+llvm::errs() << ErrorMessage;
   cl::ParseCommandLineOptions(argc, argv, Overview);
   cl::PrintOptionValues();
 
@@ -125,7 +129,6 @@ CommonOptionsParser::CommonOptionsParser
   SourcePathList.empty())
 return;
   if (!Compilations) {
-std::string ErrorMessage;
 if (!BuildPath.empty()) {
   Compilations =
   CompilationDatabase::autoDetectFromDirectory(BuildPath, 
ErrorMessage);

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=303741&r1=303740&r2=303741&view=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed May 24 06:57:37 2017
@@ -27,6 +27,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 using namespace clang;
@@ -150,23 +151,21 @@ private:
 // options.
 class UnusedInputDiagConsumer : public DiagnosticConsumer {
 public:
-  UnusedInputDiagConsumer

[PATCH] D33272: Method loadFromCommandLine should be able to report errors

2017-05-24 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303741: Method loadFromCommandLine should be able to report 
errors (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D33272?vs=99919&id=100069#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33272

Files:
  cfe/trunk/include/clang/Tooling/CompilationDatabase.h
  cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
  cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
  cfe/trunk/lib/Tooling/CompilationDatabase.cpp
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Index: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
===
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h
@@ -176,10 +176,11 @@
   /// the number of arguments before "--", if "--" was found in the argument
   /// list.
   /// \param Argv Points to the command line arguments.
+  /// \param ErrorMsg Contains error text if the function returns null pointer.
   /// \param Directory The base directory used in the FixedCompilationDatabase.
-  static FixedCompilationDatabase *loadFromCommandLine(int &Argc,
-   const char *const *Argv,
-   Twine Directory = ".");
+  static std::unique_ptr loadFromCommandLine(
+  int &Argc, const char *const *Argv, std::string &ErrorMsg,
+  Twine Directory = ".");
 
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
Index: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
===
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -52,6 +52,8 @@
   TheDriver.setCheckInputsExist(false);
 
   std::unique_ptr C(TheDriver.BuildCompilation(Args));
+  if (!C)
+return nullptr;
 
   // Just print the cc1 options if -### was present.
   if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {
Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -260,6 +260,8 @@
   Driver->setCheckInputsExist(false);
   const std::unique_ptr Compilation(
   Driver->BuildCompilation(llvm::makeArrayRef(Argv)));
+  if (!Compilation)
+return false;
   const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
   &Diagnostics, Compilation.get());
   if (!CC1Args) {
Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 using namespace clang;
@@ -150,23 +151,21 @@
 // options.
 class UnusedInputDiagConsumer : public DiagnosticConsumer {
 public:
-  UnusedInputDiagConsumer() : Other(nullptr) {}
-
-  // Useful for debugging, chain diagnostics to another consumer after
-  // recording for our own purposes.
-  UnusedInputDiagConsumer(DiagnosticConsumer *Other) : Other(Other) {}
+  UnusedInputDiagConsumer(DiagnosticConsumer &Other) : Other(Other) {}
 
   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
 const Diagnostic &Info) override {
 if (Info.getID() == clang::diag::warn_drv_input_file_unused) {
   // Arg 1 for this diagnostic is the option that didn't get used.
   UnusedInputs.push_back(Info.getArgStdStr(0));
+} else if (DiagLevel >= DiagnosticsEngine::Error) {
+  // If driver failed to create compilation object, show the diagnostics
+  // to user.
+  Other.HandleDiagnostic(DiagLevel, Info);
 }
-if (Other)
-  Other->HandleDiagnostic(DiagLevel, Info);
   }
 
-  DiagnosticConsumer *Other;
+  DiagnosticConsumer &Other;
   SmallVector UnusedInputs;
 };
 
@@ -205,9 +204,12 @@
 ///  \li false if \c Args cannot be used for compilation jobs (e.g.
 ///  contains an option like -E or -version).
 static bool stripPositionalArgs(std::vector Args,
-std::vector &Result) {
+std::vector &Result,
+std::string &ErrorMsg) {
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  UnusedInputDiagConsumer DiagClient;
+  llvm::raw_string_ostream Output(ErrorMsg);
+  TextDiagnosticPrinter DiagnosticPrinter(Output, &*DiagOpts);
+  UnusedInputDiagConsumer DiagClient(DiagnosticPrinter);
   DiagnosticsEngine Diagnostics(
   IntrusiveRefCntPtr(new DiagnosticIDs()),
   &*DiagOpts, &Diag

[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Without this patch, macros with no trailing semicolon _in the body of a 
function_ are not handled properly, so I get:

  int foo(int a, int b) {
Q_UNUSED(a) return b;
  }
  
  class Foo {
void bar(int a, int b) { Q_UNUSED(a) Q_UNUSED(b) }
  }


https://reviews.llvm.org/D33440



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


[PATCH] D33470: [clang-tidy] Add misc-default-numerics

2017-05-24 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: docs/clang-tidy/checks/misc-default-numerics.rst:11
+Consider scenario:
+1. Have `typedef long long BigInt` in source code
+2. Use `std::numeric_limits::min()`

Eugene.Zelenko wrote:
> May be code-block will be better?
Right, I was looking for something like an inline code block, but I guess I 
will just change it to code block with comments


https://reviews.llvm.org/D33470



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


[PATCH] D33470: [clang-tidy] Add misc-default-numerics

2017-05-24 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 100070.
Prazek added a comment.

- fixed docs


https://reviews.llvm.org/D33470

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefaultNumericsCheck.cpp
  clang-tidy/misc/DefaultNumericsCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-default-numerics.rst
  test/clang-tidy/misc-default-numerics.cpp

Index: test/clang-tidy/misc-default-numerics.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-default-numerics.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s misc-default-numerics %t
+
+namespace std {
+
+template 
+struct numeric_limit {
+  static T min() { return T(); }
+  static T max() { return T(); }
+};
+
+template <>
+struct numeric_limit {
+  static int min() { return -1; }
+  static int max() { return 1; }
+};
+
+} // namespace std
+
+class MyType {};
+template 
+class MyTemplate {};
+
+void test() {
+  auto x = std::numeric_limit::min();
+
+  auto y = std::numeric_limit::min();
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: called std::numeric_limit method on not specialized type
+
+  auto z = std::numeric_limit>::max();
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: called std::numeric_limit method on not specialized type
+}
+
+template 
+void fun() {
+  auto x = std::numeric_limit::min();
+}
+
+void testTemplate() {
+  fun();
+  // FIXME: This should generate warning with backtrace.
+  fun;
+}
Index: docs/clang-tidy/checks/misc-default-numerics.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-default-numerics.rst
@@ -0,0 +1,24 @@
+.. title:: clang-tidy - misc-default-numerics
+
+misc-default-numerics
+=
+
+This check flags usages of ``std::numeric_limits::{min,max}()`` for
+unspecialized types. It is dangerous because returns T(), which might is rarely
+minimum or maximum for this type.
+
+Consider scenario:
+.. code-block:: c++
+
+  // 1. Have a:
+  typedef long long BigInt
+
+  // 2. Use
+  std::numeric_limits::min()
+
+
+  // 3. Replace the BigInt typedef with class implementing BigIntegers
+  class BigInt { ;;; };
+
+  // 4. Your code compiles silently and you a few years later you find an
+  // of by 9223372036854775808 error.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -75,6 +75,7 @@
misc-assert-side-effect
misc-bool-pointer-implicit-conversion
misc-dangling-handle
+   misc-default-numerics
misc-definitions-in-headers
misc-fold-init-type
misc-forward-declaration-namespace
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -71,7 +71,11 @@
   `_ check
 
   Allow custom memory management functions to be considered as well.
-  
+
+- New `misc-default-numerics
+  `_ check
+  Finds uses of ``std::numeric_limit`` for unspecialized types
+
 - New `misc-forwarding-reference-overload
   `_ check
 
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -14,6 +14,7 @@
 #include "AssertSideEffectCheck.h"
 #include "BoolPointerImplicitConversionCheck.h"
 #include "DanglingHandleCheck.h"
+#include "DefaultNumericsCheck.h"
 #include "DefinitionsInHeadersCheck.h"
 #include "FoldInitTypeCheck.h"
 #include "ForwardDeclarationNamespaceCheck.h"
@@ -66,6 +67,7 @@
 CheckFactories.registerCheck("misc-argument-comment");
 CheckFactories.registerCheck(
 "misc-assert-side-effect");
+CheckFactories.registerCheck("misc-default-numerics");
 CheckFactories.registerCheck(
 "misc-forwarding-reference-overload");
 CheckFactories.registerCheck("misc-misplaced-const");
Index: clang-tidy/misc/DefaultNumericsCheck.h
===
--- /dev/null
+++ clang-tidy/misc/DefaultNumericsCheck.h
@@ -0,0 +1,37 @@
+//===--- DefaultNumericsCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DEFAULT_NUMERICS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_DEFAULT_NUMERICS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+names

[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I am fine with "removing" the options: I only fear it would incorrectly affect 
existing users/styles, which would possibly end up in the patch being 
reverted...
I could not find the info in Mozilla coding style, but looking at the code it 
seems it should be done indeed, but with an extra space in between, like this:

  void foo()
  { }

So if you tell me it's fine I will go ahead and replace the option with the 
`BraceWrapping.AfterFunction && AllowShortFunctionsOnASingleLine >= SFS_Empty` 
condition.


https://reviews.llvm.org/D33447



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


r303742 - [clang-format] Remove unused using directive, NFC

2017-05-24 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Wed May 24 07:15:42 2017
New Revision: 303742

URL: http://llvm.org/viewvc/llvm-project?rev=303742&view=rev
Log:
[clang-format] Remove unused using directive, NFC

Modified:
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=303742&r1=303741&r2=303742&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Wed May 24 07:15:42 2017
@@ -20,7 +20,6 @@
 #define DEBUG_TYPE "format-test"
 
 using clang::tooling::ReplacementTest;
-using clang::tooling::toReplacements;
 
 namespace clang {
 namespace format {


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


[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I don't. Only if they start out to be on the same line. As long as I start with:

  class C {
void foo(int a, int b) {
  Q_UNUSED(a)
  Q_UNUSED(a)
  return b;
}
  };

clang-format leaves this alone. That's good enough I think and we don't want to 
add more special handling for macro-DSLs than strictly necessary.


https://reviews.llvm.org/D33440



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


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

No, I don't think it should be done this way and neither Facebook nor Mozilla 
coding styles say you should.

Mozilla style has an explicit example:

  int TinyFunction() { return mVar; }

Facebook style has an explicit example:

  MyClass::MyClass(uint64_t idx) : m_idx(idx) {}

Moving the "{}" to the next line is only ok if the complete 
function/constructor definition (up to and including the "}") does not fit on 
one line.


https://reviews.llvm.org/D33447



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


[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Digging back, it seem the issue was that I had this code:

  void foo(..) { Q_UNUSED(a) Q_UNUSED(b) }

which got wrapped because the line was too long:

  void foo(..) {
Q_UNUSED(a) Q_UNUSED(b)
  }

I definitely understand your concern about introduceing special handling for 
some specific/hard-coded macro-DSLs, but would it be acceptable to add a 
configuration option to specify a list of such macros? e.g. a StatementMacros 
option, similar to the ForEachMacros option?

That would allow:

- Systematically reformatting the first example
- If  such a code is reformatted, ensure the 2 macros are not on the same line


https://reviews.llvm.org/D33440



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


[PATCH] D33416: [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

Looks good. Make sure to watch the windows buildbots after submitting.


https://reviews.llvm.org/D33416



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


[PATCH] D33328: [CodeGen] Pessimize aliasing for union members (and may-alias) objects

2017-05-24 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:1436
+if (BaseInfo.getMayAlias())
+  TBAAInfo = CGM.getTBAAInfo(getContext().CharTy);
 llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,

rjmccall wrote:
> kparzysz wrote:
> > rjmccall wrote:
> > > Hmm.  Should we be constructing a struct-path TBAA at all if the base may 
> > > alias, as opposed to just using 'char'?
> > I did that and got a verifier error: "Old-style TBAA is no longer allowed, 
> > use struct-path TBAA instead. fatal error: error in backend: Broken 
> > function found, compilation aborted!"
> Oh, I haven't been paying enough attention to LLVM's TBAA changes.  It looks 
> like they've canonicalized on always using the struct-access-style TBAA 
> metadata, which is fine; the point is that we should be using whatever tag we 
> would use for dereferencing a simple char*, which I believe just means 
> passing true for ConvertTypeToTag to DecorateInstructionWithTBAA .
With that change I'm getting another error:

```
Access type node must be a valid scalar type
  store <4 x double> %call2, <4 x double>* %b, align 32, !tbaa !8
!8 = !{!9, !9, i64 0}
!9 = !{!4, !4, i64 0}
fatal error: error in backend: Broken function found, compilation aborted!
```



Repository:
  rL LLVM

https://reviews.llvm.org/D33328



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


[PATCH] D33440: clang-format: properly handle Q_UNUSED and QT_REQUIRE_VERSION

2017-05-24 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I generally would not be opposed to such a patch. However, note that this might 
be hard to get right. We had significant performance problems in the past with 
ForEachMacros as we used to match every single identifier against the regex 
stored in there. For for loops you can somewhat get out of that and you might 
be able to do the same thing here, but I am not entirely sure. In contrast, the 
added value is actually not very large. clang-format is merely not able to 
automatically fix something to your liking and it's very easy to make the code 
right and have clang-format keep it that way.


https://reviews.llvm.org/D33440



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


[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Right, I was not clear enough: this is indeed done only if everything does not 
fit on one line.

There is an exemple in facebook's coding style:

  MyClass::MyClass(const Class* cls, const Func* func, const Class* ctx)
: m_cls(cls)
, m_func(func)
, m_ctx(ctx)
, m_isMyConditionMet(false)
  {}

And this happens (with the extra space) in the same kind of situation in 
Mozilla's code:

  
nsSameProcessAsyncMessageBase::nsSameProcessAsyncMessageBase(JS::RootingContext*
 aRootingCx,
   
JS::Handle aCpows)
: mRootingCx(aRootingCx)
, mCpows(aRootingCx, aCpows)
  { }


https://reviews.llvm.org/D33447



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


[PATCH] D33493: Speed up preamble loading, reduce global completion cache calls

2017-05-24 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

On Windows loading preamble and caching global completion takes a while.
This is the way to improve it.
Please comment if I misuse something.


https://reviews.llvm.org/D33493

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -455,7 +455,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1126,6 +1126,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+FIDsCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1476,6 +1478,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1626,7 +1630,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2061,7 +2064,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
+  PreambleTopLevelHashValue != CompletionCacheTopLevelHashValue)
 CacheCodeCompletionResults();
 
   // We now need to clear out the completion info related to this translation
@@ -2531,8 +2534,7 @@
 
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
@@ -2540,11 +2542,17 @@
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
+FileID FID;
+SourceLocation FileLoc;
+auto ItFileID = FIDsCache.find(SD.Filename);
+if (ItFileID == FIDsCache.end()) {
   FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  FIDsCache.insert(std::make_pair(SD.Filename, FileLoc));
+} else {
+  FileLoc = ItFileID->second;
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -181,6 +181,8 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  std::map FIDsCache;
+
 public:
   class PreambleData {
 const FileEntry *File;


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -455,7 +455,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1126,6 +1126,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+FIDsCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1476,6 +1478,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1626,7 +1630,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2061,7 +2064,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
+  PreambleTopLevelHashValue != CompletionCacheTopLevelHas

[PATCH] D33493: Speed up preamble loading, reduce global completion cache calls

2017-05-24 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 100075.
yvvan added a comment.

fix member variable name, add comments


https://reviews.llvm.org/D33493

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -455,7 +455,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1126,6 +1126,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+SrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1476,6 +1478,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1626,7 +1630,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2061,7 +2064,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
+  PreambleTopLevelHashValue != CompletionCacheTopLevelHashValue)
 CacheCodeCompletionResults();
 
   // We now need to clear out the completion info related to this translation
@@ -2531,8 +2534,7 @@
 
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic &SD : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
@@ -2540,11 +2542,17 @@
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
+FileID FID;
+SourceLocation FileLoc;
+auto ItFileID = SrcLocCache.find(SD.Filename);
+if (ItFileID == SrcLocCache.end()) {
   FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  SrcLocCache.insert(std::make_pair(SD.Filename, FileLoc));
+} else {
+  FileLoc = ItFileID->second;
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -181,6 +181,12 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading
+  std::map SrcLocCache;
+
 public:
   class PreambleData {
 const FileEntry *File;


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -455,7 +455,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1126,6 +1126,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+SrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1476,6 +1478,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1626,7 +1630,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2061,7 +2064,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHas

[PATCH] D33447: clang-format: add option to merge empty function body

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Merging empty blocks is not allowed in webkit style: 
https://webkit.org/code-style-guidelines/#punctuation-member-init

So it seems changing the behavior would actually fix mozilla style and break 
webkit style (as integrated in clang-format).


https://reviews.llvm.org/D33447



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


[PATCH] D33493: Speed up preamble loading, reduce global completion cache calls

2017-05-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Please post the patch with full context `git diff -U`.


https://reviews.llvm.org/D33493



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


r303748 - [coroutines] [NFC] Add tests for return_void, unhandled_exception and promise dtor

2017-05-24 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Wed May 24 09:19:48 2017
New Revision: 303748

URL: http://llvm.org/viewvc/llvm-project?rev=303748&view=rev
Log:
[coroutines] [NFC] Add tests for return_void, unhandled_exception and promise 
dtor

Summary:
* Test that coroutine promise destructor is called.
* Test that we call return_void on fallthrough
* Test that we call unhandled exception in a try catch surrounding the body

Reviewers: EricWF, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CodeGenCoroutines/Inputs/
cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp
cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp

Added: cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h?rev=303748&view=auto
==
--- cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h (added)
+++ cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h Wed May 24 09:19:48 2017
@@ -0,0 +1,80 @@
+#pragma once
+
+namespace std { namespace experimental { inline namespace coroutines_v1 {
+
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *addr) noexcept {
+coroutine_handle me;
+me.ptr = addr;
+return me;
+  }
+  void operator()() { resume(); }
+  void *address() const { return ptr; }
+  void resume() const { __builtin_coro_resume(ptr); }
+  void destroy() const { __builtin_coro_destroy(ptr); }
+  bool done() const { return __builtin_coro_done(ptr); }
+  coroutine_handle &operator=(decltype(nullptr)) {
+ptr = nullptr;
+return *this;
+  }
+  coroutine_handle(decltype(nullptr)) : ptr(nullptr) {}
+  coroutine_handle() : ptr(nullptr) {}
+//  void reset() { ptr = nullptr; } // add to P0057?
+  explicit operator bool() const { return ptr; }
+
+protected:
+  void *ptr;
+};
+
+template  struct coroutine_handle : coroutine_handle<> {
+  using coroutine_handle<>::operator=;
+
+  static coroutine_handle from_address(void *addr) noexcept {
+coroutine_handle me;
+me.ptr = addr;
+return me;
+  }
+
+  Promise &promise() const {
+return *reinterpret_cast(
+__builtin_coro_promise(ptr, alignof(Promise), false));
+  }
+  static coroutine_handle from_promise(Promise &promise) {
+coroutine_handle p;
+p.ptr = __builtin_coro_promise(&promise, alignof(Promise), true);
+return p;
+  }
+};
+
+  template 
+  bool operator==(coroutine_handle<_PromiseT> const& _Left,
+coroutine_handle<_PromiseT> const& _Right) noexcept
+  {
+return _Left.address() == _Right.address();
+  }
+
+  template 
+  bool operator!=(coroutine_handle<_PromiseT> const& _Left,
+coroutine_handle<_PromiseT> const& _Right) noexcept
+  {
+return !(_Left == _Right);
+  }
+
+struct suspend_always {
+  bool await_ready() { return false; }
+  void await_suspend(coroutine_handle<>) {}
+  void await_resume() {}
+};
+struct suspend_never {
+  bool await_ready() { return true; }
+  void await_suspend(coroutine_handle<>) {}
+  void await_resume() {}
+};
+
+}}}

Added: cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp?rev=303748&view=auto
==
--- cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp (added)
+++ cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp Wed May 24 09:19:48 
2017
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts 
-triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm -o - %s -fexceptions 
-fcxx-exceptions -disable-llvm-passes | FileCheck %s
+// -triple=x86_64-unknown-linux-gnu
+
+#include "Inputs/coroutine.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct coro_t {
+  void* p;
+  ~coro_t();
+  struct promise_type {
+coro_t get_return_object();
+coro::suspend_never initial_suspend();
+coro::suspend_never final_suspend();
+void return_void();
+promise_type();
+~promise_type();
+void unhandled_exception();
+  };
+};
+
+struct Cleanup { ~Cleanup(); };
+void may_throw();
+
+coro_t f() {
+  Cleanup cleanup;
+  may_throw();
+  co_return;
+}
+
+// CHECK-LABEL: define void @"\01?f@@YA?AUcoro_t@@XZ"(
+// CHECK:  %gro.active = alloca i1
+// CHECK:  store i1 false, i1* %gro.active
+
+// CHECK:  invoke %"struct.coro_t::promise_type"* 
@"\01??0promise_type@coro_t@@QEAA@XZ"(
+// CHECK:  invoke void 
@"\01?get_return_object@promise_type@coro_t@@QEAA?AU2@XZ"(
+// CHECK:  store i1 true, i1* %gro.active
+
+// CHECK:  %[[IS_ACTIVE:.+]] = load i1, i1* %gro.active
+// CHECK:  br i

[PATCH] D33479: [coroutines] [NFC] Add tests for return_void, unhandled_exception and promise dtor

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303748: [coroutines] [NFC] Add tests for return_void, 
unhandled_exception and promise… (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D33479?vs=100034&id=100084#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33479

Files:
  cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
  cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
  cfe/trunk/test/CodeGenCoroutines/coro-ret-void.cpp
  cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp

Index: cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
===
--- cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
+++ cfe/trunk/test/CodeGenCoroutines/coro-promise-dtor.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+// -triple=x86_64-unknown-linux-gnu
+
+#include "Inputs/coroutine.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct coro_t {
+  void* p;
+  ~coro_t();
+  struct promise_type {
+coro_t get_return_object();
+coro::suspend_never initial_suspend();
+coro::suspend_never final_suspend();
+void return_void();
+promise_type();
+~promise_type();
+void unhandled_exception();
+  };
+};
+
+struct Cleanup { ~Cleanup(); };
+void may_throw();
+
+coro_t f() {
+  Cleanup cleanup;
+  may_throw();
+  co_return;
+}
+
+// CHECK-LABEL: define void @"\01?f@@YA?AUcoro_t@@XZ"(
+// CHECK:  %gro.active = alloca i1
+// CHECK:  store i1 false, i1* %gro.active
+
+// CHECK:  invoke %"struct.coro_t::promise_type"* @"\01??0promise_type@coro_t@@QEAA@XZ"(
+// CHECK:  invoke void @"\01?get_return_object@promise_type@coro_t@@QEAA?AU2@XZ"(
+// CHECK:  store i1 true, i1* %gro.active
+
+// CHECK:  %[[IS_ACTIVE:.+]] = load i1, i1* %gro.active
+// CHECK:  br i1 %[[IS_ACTIVE]], label %[[CLEANUP1:.+]], label
+
+// CHECK: [[CLEANUP1]]:
+// CHECK:  %[[NRVO:.+]] = load i1, i1* %nrvo
+// CHECK:  br i1 %[[NRVO]], label %{{.+}}, label %[[DTOR:.+]]
+
+// CHECK: [[DTOR]]:
+// CHECK:  call void @"\01??_Dcoro_t@@QEAAXXZ"(
Index: cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
===
--- cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
+++ cfe/trunk/test/CodeGenCoroutines/Inputs/coroutine.h
@@ -0,0 +1,80 @@
+#pragma once
+
+namespace std { namespace experimental { inline namespace coroutines_v1 {
+
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *addr) noexcept {
+coroutine_handle me;
+me.ptr = addr;
+return me;
+  }
+  void operator()() { resume(); }
+  void *address() const { return ptr; }
+  void resume() const { __builtin_coro_resume(ptr); }
+  void destroy() const { __builtin_coro_destroy(ptr); }
+  bool done() const { return __builtin_coro_done(ptr); }
+  coroutine_handle &operator=(decltype(nullptr)) {
+ptr = nullptr;
+return *this;
+  }
+  coroutine_handle(decltype(nullptr)) : ptr(nullptr) {}
+  coroutine_handle() : ptr(nullptr) {}
+//  void reset() { ptr = nullptr; } // add to P0057?
+  explicit operator bool() const { return ptr; }
+
+protected:
+  void *ptr;
+};
+
+template  struct coroutine_handle : coroutine_handle<> {
+  using coroutine_handle<>::operator=;
+
+  static coroutine_handle from_address(void *addr) noexcept {
+coroutine_handle me;
+me.ptr = addr;
+return me;
+  }
+
+  Promise &promise() const {
+return *reinterpret_cast(
+__builtin_coro_promise(ptr, alignof(Promise), false));
+  }
+  static coroutine_handle from_promise(Promise &promise) {
+coroutine_handle p;
+p.ptr = __builtin_coro_promise(&promise, alignof(Promise), true);
+return p;
+  }
+};
+
+  template 
+  bool operator==(coroutine_handle<_PromiseT> const& _Left,
+coroutine_handle<_PromiseT> const& _Right) noexcept
+  {
+return _Left.address() == _Right.address();
+  }
+
+  template 
+  bool operator!=(coroutine_handle<_PromiseT> const& _Left,
+coroutine_handle<_PromiseT> const& _Right) noexcept
+  {
+return !(_Left == _Right);
+  }
+
+struct suspend_always {
+  bool await_ready() { return false; }
+  void await_suspend(coroutine_handle<>) {}
+  void await_resume() {}
+};
+struct suspend_never {
+  bool await_ready() { return true; }
+  void await_suspend(coroutine_handle<>) {}
+  void await_resume() {}
+};
+
+}}}
Index: cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp
===
--- cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp
+++ cfe/trunk/test/CodeGenCoroutines/coro-unhandled-exception.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -std=c++14 -fcorou

r303751 - [index] The references to explicit class properties should be recorded

2017-05-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 24 09:23:40 2017
New Revision: 303751

URL: http://llvm.org/viewvc/llvm-project?rev=303751&view=rev
Log:
[index] The references to explicit class properties should be recorded

rdar://32376363

Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=303751&r1=303750&r2=303751&view=diff
==
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Wed May 24 09:23:40 2017
@@ -254,6 +254,18 @@ public:
   SymbolRoleSet Roles = getRolesForRef(E, Relations);
   return IndexCtx.handleReference(E->getExplicitProperty(), 
E->getLocation(),
   Parent, ParentDC, Roles, Relations, E);
+} else if (const ObjCMethodDecl *Getter = E->getImplicitPropertyGetter()) {
+  // Class properties that are explicitly defined using @property
+  // declarations are represented implicitly as there is no ivar for class
+  // properties.
+  if (Getter->isClassMethod()) {
+if (const auto *PD = Getter->getCanonicalDecl()->findPropertyDecl()) {
+  SmallVector Relations;
+  SymbolRoleSet Roles = getRolesForRef(E, Relations);
+  return IndexCtx.handleReference(PD, E->getLocation(), Parent,
+  ParentDC, Roles, Relations, E);
+}
+  }
 }
 
 // No need to do a handleReference for the objc method, because there will

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=303751&r1=303750&r2=303751&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Wed May 24 09:23:40 2017
@@ -397,8 +397,17 @@ struct Separate separateE;
 void classReceivers() {
   ClassReceivers.p1 = 0;
 // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-2]]:18 | instance-property/ObjC | p1 | 
c:objc(cs)ClassReceivers(cpy)p1 |  | Ref,Writ,RelCont | rel: 1
+// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
+// CHECK: [[@LINE-4]]:18 | class-method/ObjC | setP1: | 
c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | 
Ref,Call,Impl,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
   (void)ClassReceivers.p1;
 // CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-2]]:24 | instance-property/ObjC | p1 | 
c:objc(cs)ClassReceivers(cpy)p1 |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
+// CHECK: [[@LINE-4]]:24 | class-method/ObjC | p1 | 
c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | 
Ref,Call,Impl,RelCall,RelCont | rel: 1
+// CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
+
   ClassReceivers.implicit = 0;
 // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
   (void)ClassReceivers.implicit;


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


r303752 - [coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type

2017-05-24 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Wed May 24 09:34:19 2017
New Revision: 303752

URL: http://llvm.org/viewvc/llvm-project?rev=303752&view=rev
Log:
[coroutines] Improved diagnostics when unhandled_exception is missing in the 
promise_type

Summary: Now we helpfully provide a note pointing at the promise_type in 
question.

Reviewers: EricWF, GorNishanov

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
cfe/trunk/test/SemaCXX/coroutines.cpp

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=303752&r1=303751&r2=303752&view=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed May 24 09:34:19 2017
@@ -120,8 +120,7 @@ static QualType lookupPromiseType(Sema &
   return PromiseType;
 }
 
-/// Look up the std::coroutine_traits<...>::promise_type for the given
-/// function type.
+/// Look up the std::experimental::coroutine_handle.
 static QualType lookupCoroutineHandleType(Sema &S, QualType PromiseType,
   SourceLocation Loc) {
   if (PromiseType.isNull())
@@ -729,8 +728,7 @@ void Sema::CheckCompletedCoroutineBody(F
   }
 
   if (isa(Body)) {
-// FIXME(EricWF): Nothing todo. the body is already a transformed coroutine
-// body statement.
+// Nothing todo. the body is already a transformed coroutine body 
statement.
 return;
   }
 
@@ -1030,6 +1028,8 @@ bool CoroutineStmtBuilder::makeOnExcepti
 : diag::
   
warn_coroutine_promise_unhandled_exception_required_with_exceptions;
 S.Diag(Loc, DiagID) << PromiseRecordDecl;
+S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
+<< PromiseRecordDecl;
 return !RequireUnhandledException;
   }
 

Modified: cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp?rev=303752&r1=303751&r2=303752&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp Wed May 24 
09:34:19 2017
@@ -16,7 +16,11 @@
 using std::experimental::suspend_always;
 using std::experimental::suspend_never;
 
+#ifndef DISABLE_WARNING
+struct promise_void { // expected-note {{defined here}}
+#else
 struct promise_void {
+#endif
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();

Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=303752&r1=303751&r2=303752&view=diff
==
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed May 24 09:34:19 2017
@@ -540,7 +540,7 @@ coro bad_implicit_return_dependent(T)
 }
 template coro bad_implicit_return_dependent(bad_promise_6); // 
expected-note {{in instantiation}}
 
-struct bad_promise_7 {
+struct bad_promise_7 { // expected-note 2 {{defined here}}
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();


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


[PATCH] D33481: [coroutines] Improved diagnostics when unhandled_exception is missing in the promise_type

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303752: [coroutines] Improved diagnostics when 
unhandled_exception is missing in the… (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D33481?vs=100037&id=100086#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33481

Files:
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  cfe/trunk/test/SemaCXX/coroutines.cpp


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -540,7 +540,7 @@
 }
 template coro bad_implicit_return_dependent(bad_promise_6); // 
expected-note {{in instantiation}}
 
-struct bad_promise_7 {
+struct bad_promise_7 { // expected-note 2 {{defined here}}
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
Index: cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
===
--- cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
+++ cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
@@ -16,7 +16,11 @@
 using std::experimental::suspend_always;
 using std::experimental::suspend_never;
 
+#ifndef DISABLE_WARNING
+struct promise_void { // expected-note {{defined here}}
+#else
 struct promise_void {
+#endif
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -120,8 +120,7 @@
   return PromiseType;
 }
 
-/// Look up the std::coroutine_traits<...>::promise_type for the given
-/// function type.
+/// Look up the std::experimental::coroutine_handle.
 static QualType lookupCoroutineHandleType(Sema &S, QualType PromiseType,
   SourceLocation Loc) {
   if (PromiseType.isNull())
@@ -729,8 +728,7 @@
   }
 
   if (isa(Body)) {
-// FIXME(EricWF): Nothing todo. the body is already a transformed coroutine
-// body statement.
+// Nothing todo. the body is already a transformed coroutine body 
statement.
 return;
   }
 
@@ -1030,6 +1028,8 @@
 : diag::
   
warn_coroutine_promise_unhandled_exception_required_with_exceptions;
 S.Diag(Loc, DiagID) << PromiseRecordDecl;
+S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
+<< PromiseRecordDecl;
 return !RequireUnhandledException;
   }
 


Index: cfe/trunk/test/SemaCXX/coroutines.cpp
===
--- cfe/trunk/test/SemaCXX/coroutines.cpp
+++ cfe/trunk/test/SemaCXX/coroutines.cpp
@@ -540,7 +540,7 @@
 }
 template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
 
-struct bad_promise_7 {
+struct bad_promise_7 { // expected-note 2 {{defined here}}
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
Index: cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
===
--- cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
+++ cfe/trunk/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
@@ -16,7 +16,11 @@
 using std::experimental::suspend_always;
 using std::experimental::suspend_never;
 
+#ifndef DISABLE_WARNING
+struct promise_void { // expected-note {{defined here}}
+#else
 struct promise_void {
+#endif
   void get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -120,8 +120,7 @@
   return PromiseType;
 }
 
-/// Look up the std::coroutine_traits<...>::promise_type for the given
-/// function type.
+/// Look up the std::experimental::coroutine_handle.
 static QualType lookupCoroutineHandleType(Sema &S, QualType PromiseType,
   SourceLocation Loc) {
   if (PromiseType.isNull())
@@ -729,8 +728,7 @@
   }
 
   if (isa(Body)) {
-// FIXME(EricWF): Nothing todo. the body is already a transformed coroutine
-// body statement.
+// Nothing todo. the body is already a transformed coroutine body statement.
 return;
   }
 
@@ -1030,6 +1028,8 @@
 : diag::
   warn_coroutine_promise_unhandled_exception_required_with_exceptions;
 S.Diag(Loc, DiagID) << PromiseRecordDecl;
+S.Diag(PromiseRecordDecl->getLocation(), diag::note_defined_here)
+<< PromiseRecordDecl;
 return !RequireUnhandledException;
   }

[PATCH] D33497: clang-tidy check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Bryce Liu via Phabricator via cfe-commits
brycel created this revision.
Herald added a subscriber: mgorny.

Add a clang-tidy check for using __func__/__FUNCTION__ inside lambdas. This 
evaluates to the string `operator()`, which is almost never useful and almost 
certainly not what the author intended.


https://reviews.llvm.org/D33497

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  test/clang-tidy/misc-lambda-function-name.cpp

Index: test/clang-tidy/misc-lambda-function-name.cpp
===
--- test/clang-tidy/misc-lambda-function-name.cpp
+++ test/clang-tidy/misc-lambda-function-name.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s misc-lambda-function-name %t
+
+void Positives() {
+  [] { __func__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { __FUNCTION__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+}
+
+void Negatives() {
+  __func__;
+  __FUNCTION__;
+}
Index: docs/clang-tidy/checks/misc-lambda-function-name.rst
===
--- docs/clang-tidy/checks/misc-lambda-function-name.rst
+++ docs/clang-tidy/checks/misc-lambda-function-name.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - misc-lambda-function-name
+
+misc-lambda-function-name
+=
+
+Checks for attempts to get the name of a function from within a lambda
+expression. The name of a lambda is always something like ``operator()``, which
+is almost never what was intended.
+
+Example:
+
+.. code-block:: c++
+
+  void FancyFunction() {
+[] { printf("Called from %s\n", __func__); }();
+[] { printf("Now called from %s\n", __FUNCTION__); }();
+  }
+
+Output::
+
+  Called from operator()
+  Now called from operator()
+
+Likely intended output::
+
+  Called from FancyFunction
+  Now called from FancyFunction
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -82,6 +82,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-lambda-function-name
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tidy/misc/MiscTidyModule.cpp
@@ -21,6 +21,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncorrectRoundings.h"
 #include "InefficientAlgorithmCheck.h"
+#include "LambdaFunctionNameCheck.h"
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MisplacedConstCheck.h"
@@ -68,6 +69,8 @@
 "misc-assert-side-effect");
 CheckFactories.registerCheck(
 "misc-forwarding-reference-overload");
+CheckFactories.registerCheck(
+"misc-lambda-function-name");
 CheckFactories.registerCheck("misc-misplaced-const");
 CheckFactories.registerCheck(
 "misc-unconventional-assign-operator");
Index: clang-tidy/misc/LambdaFunctionNameCheck.h
===
--- clang-tidy/misc/LambdaFunctionNameCheck.h
+++ clang-tidy/misc/LambdaFunctionNameCheck.h
@@ -0,0 +1,37 @@
+//===--- LambdaFunctionNameCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_LAMBDA_FUNCTION_NAME_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_LAMBDA_FUNCTION_NAME_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Detect when __func__ or __FUNCTION__ is being used from within a lambda. In
+/// that context, those expressions expand to the name of the call operator
+/// (i.e., `operator()`).
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-lambda-function-name.html
+class LambdaFunctionNameCheck : public ClangTidyCheck {
+public:
+  LambdaFunctionNameCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_m

r303753 - Generalize two diagnostic messages to take function name as parameter.

2017-05-24 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Wed May 24 09:45:57 2017
New Revision: 303753

URL: http://llvm.org/viewvc/llvm-project?rev=303753&view=rev
Log:
Generalize two diagnostic messages to take function name as parameter.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303753&r1=303752&r2=303753&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 09:45:57 
2017
@@ -8012,10 +8012,10 @@ def err_block_on_nonlocal : Error<
 def err_block_on_vm : Error<
   "__block attribute not allowed on declaration with a variably modified 
type">;
 
-def err_shufflevector_non_vector : Error<
-  "first two arguments to __builtin_shufflevector must be vectors">;
-def err_shufflevector_incompatible_vector : Error<
-  "first two arguments to __builtin_shufflevector must have the same type">;
+def err_vec_builtin_non_vector : Error<
+ "first two arguments to %0 must be vectors">;
+def err_vec_builtin_incompatible_vector : Error<
+  "first two arguments to %0 must have the same type">;
 def err_shufflevector_nonconstant_argument : Error<
   "index for __builtin_shufflevector must be a constant integer">;
 def err_shufflevector_argument_too_large : Error<

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=303753&r1=303752&r2=303753&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed May 24 09:45:57 2017
@@ -3914,7 +3914,8 @@ ExprResult Sema::SemaBuiltinShuffleVecto
 
 if (!LHSType->isVectorType() || !RHSType->isVectorType())
   return ExprError(Diag(TheCall->getLocStart(),
-diag::err_shufflevector_non_vector)
+diag::err_vec_builtin_non_vector)
+   << TheCall->getDirectCallee()
<< SourceRange(TheCall->getArg(0)->getLocStart(),
   TheCall->getArg(1)->getLocEnd()));
 
@@ -3928,12 +3929,14 @@ ExprResult Sema::SemaBuiltinShuffleVecto
   if (!RHSType->hasIntegerRepresentation() ||
   RHSType->getAs()->getNumElements() != numElements)
 return ExprError(Diag(TheCall->getLocStart(),
-  diag::err_shufflevector_incompatible_vector)
+  diag::err_vec_builtin_incompatible_vector)
+ << TheCall->getDirectCallee()
  << SourceRange(TheCall->getArg(1)->getLocStart(),
 TheCall->getArg(1)->getLocEnd()));
 } else if (!Context.hasSameUnqualifiedType(LHSType, RHSType)) {
   return ExprError(Diag(TheCall->getLocStart(),
-diag::err_shufflevector_incompatible_vector)
+diag::err_vec_builtin_incompatible_vector)
+   << TheCall->getDirectCallee()
<< SourceRange(TheCall->getArg(0)->getLocStart(),
   TheCall->getArg(1)->getLocEnd()));
 } else if (numElements != numResElements) {


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


r303756 - Driver must return non-zero code on errors in command line

2017-05-24 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed May 24 09:57:17 2017
New Revision: 303756

URL: http://llvm.org/viewvc/llvm-project?rev=303756&view=rev
Log:
Driver must return non-zero code on errors in command line

This is recommit of r302775, reverted in r302777 due to a fail in
clang-tidy. Original mesage is below.

Now if clang driver is given wrong arguments, in some cases it
continues execution and returns zero code. This change fixes this
behavior.

The fix revealed some errors in clang test set.

File test/Driver/gfortran.f90 added in r118203 checks forwarding
gfortran flags to GCC. Now driver reports error on this file, because
the option -working-directory implemented in clang differs from the
option with the same name implemented in gfortran, in clang the option
requires argument, in gfortran does not.

In the file test/Driver/arm-darwin-builtin.c clang is called with
options -fbuiltin-strcat and -fbuiltin-strcpy. These option were removed
in r191435 and now clang reports error on this test.

File arm-default-build-attributes.s uses option -verify, which is not
supported by driver, it is cc1 option.

Similarly, the file split-debug.h uses options -fmodules-embed-all-files
and -fmodule-format=obj, which are not supported by driver.

Other revealed errors are mainly mistypes.

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

Removed:
cfe/trunk/test/Driver/arm-darwin-builtin.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/aarch64-cpus.c
cfe/trunk/test/Driver/amdgpu-features.c
cfe/trunk/test/Driver/arm-default-build-attributes.s
cfe/trunk/test/Driver/cl-outputs.c
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Driver/cuda-external-tools.cu
cfe/trunk/test/Driver/debug-options.c
cfe/trunk/test/Driver/gfortran.f90
cfe/trunk/test/Driver/split-debug.h
cfe/trunk/test/Driver/unknown-arg.c
cfe/trunk/test/Index/index-attrs.c
cfe/trunk/test/Index/index-attrs.cpp
cfe/trunk/tools/driver/driver.cpp
cfe/trunk/unittests/Driver/ToolChainTest.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=303756&r1=303755&r2=303756&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed May 24 09:57:17 2017
@@ -598,6 +598,8 @@ Compilation *Driver::BuildCompilation(Ar
   bool CCCPrintPhases;
 
   InputArgList Args = ParseArgStrings(ArgList.slice(1));
+  if (Diags.hasErrorOccurred())
+return nullptr;
 
   // Silence driver warnings if requested
   Diags.setIgnoreAllWarnings(Args.hasArg(options::OPT_w));

Modified: cfe/trunk/test/Driver/aarch64-cpus.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-cpus.c?rev=303756&r1=303755&r2=303756&view=diff
==
--- cfe/trunk/test/Driver/aarch64-cpus.c (original)
+++ cfe/trunk/test/Driver/aarch64-cpus.c Wed May 24 09:57:17 2017
@@ -11,7 +11,7 @@
 // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-GENERIC %s
 // RUN: %clang -target arm64 -mcpu=generic -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-GENERIC %s
 // RUN: %clang -target arm64 -mlittle-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-GENERIC %s
-// RUN: %clang -target arm64 -mlittle-endian -mcpu-generic -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-GENERIC %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=generic -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-GENERIC %s
 
 // ARM64-GENERIC: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"
 

Modified: cfe/trunk/test/Driver/amdgpu-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-features.c?rev=303756&r1=303755&r2=303756&view=diff
==
--- cfe/trunk/test/Driver/amdgpu-features.c (original)
+++ cfe/trunk/test/Driver/amdgpu-features.c Wed May 24 09:57:17 2017
@@ -1,7 +1,7 @@
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=0.0 %s -o 2>&1 \
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=0.0 %s -o - 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-0-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-0-0: the clang compiler does not support 
'-mamdgpu-debugger-abi=0.0'
 
-// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o 2>&1 \
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=kaveri 
-mamdgpu-debugger-abi=1.0 %s -o - 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MAMDGPU-DEBUGGER-ABI-1-0 %s
 // CHECK-MAMDGPU-DEBUGGER-ABI-1-0: "-target-feature" 
"+amdgpu-debugger-insert-nops" "-target-feature" 
"+amdgpu-debugger-reserve-regs" "-target-feature" 
"+amdgpu-debugger-emit-prologue"

Removed: cfe/trunk/test/Driv

[PATCH] D33013: Driver must return non-zero code on errors in command line

2017-05-24 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303756: Driver must return non-zero code on errors in 
command line (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D33013?vs=99273&id=100090#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33013

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/aarch64-cpus.c
  cfe/trunk/test/Driver/amdgpu-features.c
  cfe/trunk/test/Driver/arm-darwin-builtin.c
  cfe/trunk/test/Driver/arm-default-build-attributes.s
  cfe/trunk/test/Driver/cl-outputs.c
  cfe/trunk/test/Driver/clang_f_opts.c
  cfe/trunk/test/Driver/cuda-external-tools.cu
  cfe/trunk/test/Driver/debug-options.c
  cfe/trunk/test/Driver/gfortran.f90
  cfe/trunk/test/Driver/split-debug.h
  cfe/trunk/test/Driver/unknown-arg.c
  cfe/trunk/test/Index/index-attrs.c
  cfe/trunk/test/Index/index-attrs.cpp
  cfe/trunk/tools/driver/driver.cpp
  cfe/trunk/unittests/Driver/ToolChainTest.cpp

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -598,6 +598,8 @@
   bool CCCPrintPhases;
 
   InputArgList Args = ParseArgStrings(ArgList.slice(1));
+  if (Diags.hasErrorOccurred())
+return nullptr;
 
   // Silence driver warnings if requested
   Diags.setIgnoreAllWarnings(Args.hasArg(options::OPT_w));
Index: cfe/trunk/unittests/Driver/ToolChainTest.cpp
===
--- cfe/trunk/unittests/Driver/ToolChainTest.cpp
+++ cfe/trunk/unittests/Driver/ToolChainTest.cpp
@@ -60,6 +60,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(
   {"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
+  EXPECT_TRUE(C);
 
   std::string S;
   {
@@ -99,6 +100,7 @@
 
   std::unique_ptr C(TheDriver.BuildCompilation(
   {"-fsyntax-only", "--gcc-toolchain=", "foo.cpp"}));
+  EXPECT_TRUE(C);
 
   std::string S;
   {
@@ -128,15 +130,24 @@
 
   Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
   InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
   Driver CXXDriver("/home/test/bin/clang++", "arm-linux-gnueabi", Diags,
InMemoryFileSystem);
+  CXXDriver.setCheckInputsExist(false);
   Driver CLDriver("/home/test/bin/clang-cl", "arm-linux-gnueabi", Diags,
   InMemoryFileSystem);
+  CLDriver.setCheckInputsExist(false);
 
-  std::unique_ptr CC(CCDriver.BuildCompilation({"foo.cpp"}));
-  std::unique_ptr CXX(CXXDriver.BuildCompilation({"foo.cpp"}));
-  std::unique_ptr CL(CLDriver.BuildCompilation({"foo.cpp"}));
-
+  std::unique_ptr CC(CCDriver.BuildCompilation(
+  { "/home/test/bin/clang", "foo.cpp"}));
+  std::unique_ptr CXX(CXXDriver.BuildCompilation(
+  { "/home/test/bin/clang++", "foo.cpp"}));
+  std::unique_ptr CL(CLDriver.BuildCompilation(
+  { "/home/test/bin/clang-cl", "foo.cpp"}));
+
+  EXPECT_TRUE(CC);
+  EXPECT_TRUE(CXX);
+  EXPECT_TRUE(CL);
   EXPECT_TRUE(CCDriver.CCCIsCC());
   EXPECT_TRUE(CXXDriver.CCCIsCXX());
   EXPECT_TRUE(CLDriver.IsCLMode());
Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -454,40 +454,41 @@
   SetBackdoorDriverOutputsFromEnvVars(TheDriver);
 
   std::unique_ptr C(TheDriver.BuildCompilation(argv));
-  int Res = 0;
-  SmallVector, 4> FailingCommands;
-  if (C.get())
+  int Res = 1;
+  if (C.get()) {
+SmallVector, 4> FailingCommands;
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
-  // Force a crash to test the diagnostics.
-  if (TheDriver.GenReproducer) {
-Diags.Report(diag::err_drv_force_crash)
+// Force a crash to test the diagnostics.
+if (TheDriver.GenReproducer) {
+  Diags.Report(diag::err_drv_force_crash)
 << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
 
-// Pretend that every command failed.
-FailingCommands.clear();
-for (const auto &J : C->getJobs())
-  if (const Command *C = dyn_cast(&J))
-FailingCommands.push_back(std::make_pair(-1, C));
-  }
-
-  for (const auto &P : FailingCommands) {
-int CommandRes = P.first;
-const Command *FailingCommand = P.second;
-if (!Res)
-  Res = CommandRes;
-
-// If result status is < 0, then the driver command signalled an error.
-// If result status is 70, then the driver command reported a fatal error.
-// On Windows, abort will return an exit code of 3.  In these cases,
-// generate additional diagnostic information if possible.
-bool DiagnoseCrash = CommandRes < 0 || CommandRes == 70;
+  // Pretend that every command failed.
+  FailingCommands.clear();
+  for (const auto &J : C->getJobs())
+if (const Command *C = dyn_cast(&J))
+  FailingCommands.push_back(std::make_pair(-1, C));
+}
+
+for (const auto &P : FailingCommands) {
+ 

[PATCH] D33406: PR28129 expand vector oparation to an IR constant.

2017-05-24 Thread Dinar Temirbulatov via Phabricator via cfe-commits
dtemirbulatov updated this revision to Diff 100089.
dtemirbulatov added a comment.

add _mm256_cmp_pd double version
add comments in lib/CodeGen/CGBuiltin.cpp
replaced 0xf to _CMP_TRUE_UQ in avx-builtins.c


https://reviews.llvm.org/D33406

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx-builtins.c


Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -1427,3 +1427,15 @@
  // CHECK: extractelement <8 x float> %{{.*}}, i32 0
  return _mm256_cvtss_f32(__a);
 }
+
+__m256 test_mm256_cmp_ps_true(__m256 a, __m256 b) {
+ // CHECK-LABEL: @test_mm256_cmp_ps_true
+ // CHECK: store <8 x float>  getType()->getVectorNumElements(),
+   llvm::Constant::getAllOnesValue(Builder.getInt32Ty()));
+ return Builder.CreateBitCast(Vec, Ops[0]->getType());
+  }
   ID = Intrinsic::x86_avx_cmp_ps_256;
   break;
 case X86::BI__builtin_ia32_cmppd:
   ID = Intrinsic::x86_sse2_cmp_pd;
   break;
 case X86::BI__builtin_ia32_cmppd256:
+  // _CMP_TRUE_UQ would produce -1,-1... vector on any input
+  if (CC == 0xf) {
+ Value *Vec = 
Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(),
+   llvm::Constant::getAllOnesValue(Builder.getInt64Ty()));
+ return Builder.CreateBitCast(Vec, Ops[0]->getType());
+  }
   ID = Intrinsic::x86_avx_cmp_pd_256;
   break;
 }


Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -1427,3 +1427,15 @@
  // CHECK: extractelement <8 x float> %{{.*}}, i32 0
  return _mm256_cvtss_f32(__a);
 }
+
+__m256 test_mm256_cmp_ps_true(__m256 a, __m256 b) {
+ // CHECK-LABEL: @test_mm256_cmp_ps_true
+ // CHECK: store <8 x float>  getType()->getVectorNumElements(),
+   llvm::Constant::getAllOnesValue(Builder.getInt32Ty()));
+ return Builder.CreateBitCast(Vec, Ops[0]->getType());
+  }
   ID = Intrinsic::x86_avx_cmp_ps_256;
   break;
 case X86::BI__builtin_ia32_cmppd:
   ID = Intrinsic::x86_sse2_cmp_pd;
   break;
 case X86::BI__builtin_ia32_cmppd256:
+  // _CMP_TRUE_UQ would produce -1,-1... vector on any input
+  if (CC == 0xf) {
+ Value *Vec = Builder.CreateVectorSplat(Ops[0]->getType()->getVectorNumElements(),
+   llvm::Constant::getAllOnesValue(Builder.getInt64Ty()));
+ return Builder.CreateBitCast(Vec, Ops[0]->getType());
+  }
   ID = Intrinsic::x86_avx_cmp_pd_256;
   break;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33406: PR28129 expand vector oparation to an IR constant.

2017-05-24 Thread Dinar Temirbulatov via Phabricator via cfe-commits
dtemirbulatov added a comment.

> Should we handle the 'pd256' version the same way?
> How about the 0xb ('false') constant? It should produce a zero here?
> Can or should we deal with the signalling versions (0x1b, 0x1f) too?

hm looks like 0xb(_CMP_FALSE_OQ) is ordered, so it is not possible and 0x1b or 
0x1f might emit a signal.




Comment at: lib/CodeGen/CGBuiltin.cpp:7932
   break;
 case X86::BI__builtin_ia32_cmppd256:
   ID = Intrinsic::x86_avx_cmp_pd_256;

spatel wrote:
> 1. Should we handle the 'pd256' version the same way?
> 2. How about the 0xb ('false') constant? It should produce a zero here?
> 3. Can or should we deal with the signalling versions (0x1b, 0x1f) too?
> 
hm looks like 0xb(_CMP_FALSE_OQ) is ordered, so it is not possible and 0x1b or 
0x1f might emit a signal.


https://reviews.llvm.org/D33406



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


r303760 - [PowerPC] Implement vec_xxpermdi builtin.

2017-05-24 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Wed May 24 10:13:32 2017
New Revision: 303760

URL: http://llvm.org/viewvc/llvm-project?rev=303760&view=rev
Log:
[PowerPC] Implement vec_xxpermdi builtin.

The vec_xxpermdi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33053

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins-ppc-error.c
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=303760&r1=303759&r2=303760&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Wed May 24 10:13:32 2017
@@ -420,6 +420,8 @@ BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4
 BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")
 BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
 
+BUILTIN(__builtin_vsx_xxpermdi, "v.", "t")
+
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
 BUILTIN(__builtin_tend, "UiUIi", "")

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303760&r1=303759&r2=303760&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 10:13:32 
2017
@@ -8016,6 +8016,9 @@ def err_vec_builtin_non_vector : Error<
  "first two arguments to %0 must be vectors">;
 def err_vec_builtin_incompatible_vector : Error<
   "first two arguments to %0 must have the same type">;
+def err_vsx_builtin_nonconstant_argument : Error<
+  "argument %0 to %1 must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)">;
+
 def err_shufflevector_nonconstant_argument : Error<
   "index for __builtin_shufflevector must be a constant integer">;
 def err_shufflevector_argument_too_large : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303760&r1=303759&r2=303760&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed May 24 10:13:32 2017
@@ -10124,6 +10124,7 @@ private:
   bool SemaBuiltinVAStartARM(CallExpr *Call);
   bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
   bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
+  bool SemaBuiltinVSX(CallExpr *TheCall);
   bool SemaBuiltinOSLogFormat(CallExpr *TheCall);
 
 public:

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=303760&r1=303759&r2=303760&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed May 24 10:13:32 2017
@@ -8442,6 +8442,39 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
   return Builder.CreateCall(F, Ops);
 }
   }
+
+  case PPC::BI__builtin_vsx_xxpermdi: {
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI && "Third arg must be constant integer!");
+
+unsigned Index = ArgCI->getZExtValue();
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 2));
+Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 2));
+
+// Element zero comes from the first input vector and element one comes 
from
+// the second. The element indices within each vector are numbered in big
+// endian order so the shuffle mask must be adjusted for this on little
+// endian platforms (i.e. index is complemented and source vector 
reversed).
+unsigned ElemIdx0;
+unsigned ElemIdx1;
+if (getTarget().isLittleEndian()) {
+  ElemIdx0 = (~Index & 1) + 2;
+  ElemIdx1 = (~Index & 2) >> 1;
+} else { // BigEndian
+  ElemIdx0 = (Index & 2) >> 1;
+  ElemIdx1 = 2 + (Index & 1);
+}
+
+Constant *ShuffleElts[2] = {ConstantInt::get(Int32Ty, ElemIdx0),
+ConstantInt::get(Int32Ty, ElemIdx1)};
+Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
+
+Value *ShuffleCall =
+Builder.CreateShuffleVector(Ops[0], Ops[1], ShuffleMask);
+QualType BIRetType = E->getType();
+auto RetTy = ConvertType(BIRetType);
+return Builder.CreateBitCast(Shu

[PATCH] D33053: [PowerPC] Implement vec_xxpermdi builtin.

2017-05-24 Thread Tony Jiang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jtony marked 2 inline comments as done.
Closed by commit rL303760: [PowerPC] Implement vec_xxpermdi builtin. (authored 
by jtony).

Changed prior to commit:
  https://reviews.llvm.org/D33053?vs=99966&id=100093#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33053

Files:
  cfe/trunk/include/clang/Basic/BuiltinsPPC.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/altivec.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGen/builtins-ppc-error.c
  cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -1696,6 +1696,8 @@
   case PPC::BI__builtin_tabortdci:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+  case PPC::BI__builtin_vsx_xxpermdi:
+return SemaBuiltinVSX(TheCall);
   }
   return SemaBuiltinConstantArgRange(TheCall, i, l, u);
 }
@@ -3892,6 +3894,65 @@
   return false;
 }
 
+// Customized Sema Checking for VSX builtins that have the following signature:
+// vector [...] builtinName(vector [...], vector [...], const int);
+// Which takes the same type of vectors (any legal vector type) for the first
+// two arguments and takes compile time constant for the third argument.
+// Example builtins are :
+// vector double vec_xxpermdi(vector double, vector double, int);
+// vector short vec_xxsldwi(vector short, vector short, int);
+bool Sema::SemaBuiltinVSX(CallExpr *TheCall) {
+  unsigned ExpectedNumArgs = 3;
+  if (TheCall->getNumArgs() < ExpectedNumArgs)
+return Diag(TheCall->getLocEnd(),
+diag::err_typecheck_call_too_few_args_at_least)
+   << 0 /*function call*/ <<  ExpectedNumArgs << TheCall->getNumArgs()
+   << TheCall->getSourceRange();
+
+  if (TheCall->getNumArgs() > ExpectedNumArgs)
+return Diag(TheCall->getLocEnd(),
+diag::err_typecheck_call_too_many_args_at_most)
+   << 0 /*function call*/ << ExpectedNumArgs << TheCall->getNumArgs()
+   << TheCall->getSourceRange();
+
+  // Check the third argument is a compile time constant
+  llvm::APSInt Value;
+  if(!TheCall->getArg(2)->isIntegerConstantExpr(Value, Context))
+return Diag(TheCall->getLocStart(),
+diag::err_vsx_builtin_nonconstant_argument)
+   << 3 /* argument index */ << TheCall->getDirectCallee()
+   << SourceRange(TheCall->getArg(2)->getLocStart(),
+  TheCall->getArg(2)->getLocEnd());
+
+  QualType Arg1Ty = TheCall->getArg(0)->getType();
+  QualType Arg2Ty = TheCall->getArg(1)->getType();
+
+  // Check the type of argument 1 and argument 2 are vectors.
+  SourceLocation BuiltinLoc = TheCall->getLocStart();
+  if ((!Arg1Ty->isVectorType() && !Arg1Ty->isDependentType()) ||
+  (!Arg2Ty->isVectorType() && !Arg2Ty->isDependentType())) {
+return Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
+   << TheCall->getDirectCallee()
+   << SourceRange(TheCall->getArg(0)->getLocStart(),
+  TheCall->getArg(1)->getLocEnd());
+  }
+
+  // Check the first two arguments are the same type.
+  if (!Context.hasSameUnqualifiedType(Arg1Ty, Arg2Ty)) {
+return Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
+   << TheCall->getDirectCallee()
+   << SourceRange(TheCall->getArg(0)->getLocStart(),
+  TheCall->getArg(1)->getLocEnd());
+  }
+
+  // When default clang type checking is turned off and the customized type
+  // checking is used, the returning type of the function must be explicitly
+  // set. Otherwise it is _Bool by default.
+  TheCall->setType(Arg1Ty);
+
+  return false;
+}
+
 /// SemaBuiltinShuffleVector - Handle __builtin_shufflevector.
 // This is declared to take (...), so we have to check everything.
 ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
Index: cfe/trunk/lib/Headers/altivec.h
===
--- cfe/trunk/lib/Headers/altivec.h
+++ cfe/trunk/lib/Headers/altivec.h
@@ -12156,6 +12156,10 @@
 
 #endif
 
+#ifdef __VSX__
+#define vec_xxpermdi __builtin_vsx_xxpermdi
+#endif
+
 /* vec_xor */
 
 #define __builtin_altivec_vxor vec_xor
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -8442,6 +8442,39 @@
   return Builder.CreateCall(F, Ops);
 }
   }
+
+  case PPC::BI__builtin_vsx_xxpermdi: {
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI && "Third arg must be constant integer!");
+
+unsigned Index = ArgCI->getZExtValue();
+Ops[0

r303761 - Warn about uses of `@available` that can't suppress the

2017-05-24 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed May 24 10:15:29 2017
New Revision: 303761

URL: http://llvm.org/viewvc/llvm-project?rev=303761&view=rev
Log:
Warn about uses of `@available` that can't suppress the
-Wunguarded-availability warnings

rdar://32306520

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Parser/objc-available.m
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 10:15:29 
2017
@@ -2886,6 +2886,10 @@ def warn_partial_message : Warning<"%0 i
 def warn_partial_fwdclass_message : Warning<
 "%0 may be partial because the receiver type is unknown">,
 InGroup, DefaultIgnore;
+def warn_at_available_unchecked_use : Warning<
+  "%select{@available|__builtin_available}0 does not guard availability here; "
+  "use if (%select{@available|__builtin_available}0) instead">,
+  InGroup>;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed May 24 10:15:29 2017
@@ -7284,6 +7284,12 @@ public:
 return true;
   }
 
+  bool VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+SemaRef.Diag(E->getLocStart(), diag::warn_at_available_unchecked_use)
+<< (!SemaRef.getLangOpts().ObjC1);
+return true;
+  }
+
   bool VisitTypeLoc(TypeLoc Ty);
 };
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed May 24 10:15:29 2017
@@ -15762,6 +15762,13 @@ ExprResult Sema::ActOnObjCAvailabilityCh
   if (Spec != AvailSpecs.end())
 Version = Spec->getVersion();
 
+  // The use of `@available` in the enclosing function should be analyzed to
+  // warn when it's used inappropriately (i.e. not if(@available)).
+  if (getCurFunctionOrMethodDecl())
+getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
+  else if (getCurBlock() || getCurLambda())
+getCurFunction()->HasPotentialAvailabilityViolations = true;
+
   return new (Context)
   ObjCAvailabilityCheckExpr(Version, AtLoc, RParen, Context.BoolTy);
 }

Modified: cfe/trunk/test/Parser/objc-available.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/objc-available.m?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/test/Parser/objc-available.m (original)
+++ cfe/trunk/test/Parser/objc-available.m Wed May 24 10:15:29 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -triple 
x86_64-apple-macosx10.10.0 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability 
-Wno-unsupported-availability-guard -triple x86_64-apple-macosx10.10.0 -verify 
%s
 
 void f() {
 

Modified: cfe/trunk/test/SemaObjC/unguarded-availability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability.m?rev=303761&r1=303760&r2=303761&view=diff
==
--- cfe/trunk/test/SemaObjC/unguarded-availability.m (original)
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m Wed May 24 10:15:29 2017
@@ -10,7 +10,7 @@ int func_10_11() AVAILABLE_10_11; // exp
 #ifdef OBJCPP
 // expected-note@+2 6 {{marked partial here}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 6 {{'func_10_12' has been 
explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been 
explicitly marked partial here}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -155,6 +155,16 @@ void test_at(Subscriptable *x) {
   id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only 
available on macOS 10.12 or newer}} expected-note{{@available}}
 }
 
+void uncheckAtAvailable() {
+  if (@available(macOS 10.12, *) || 0) // expected-warning {{@available does 
not guard availability here; use if (@available) instead}}
+func_10_12(); // expected-warning {{'func_10_12' is only available on 
macOS 10.12 or newer}}

[PATCH] D33450: Warn about uses of `@available` that can't suppress the -Wunguarded-availability warnings

2017-05-24 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303761: Warn about uses of `@available` that can't suppress 
the (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D33450?vs=99948&id=100094#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33450

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Parser/objc-available.m
  cfe/trunk/test/SemaObjC/unguarded-availability.m


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2886,6 +2886,10 @@
 def warn_partial_fwdclass_message : Warning<
 "%0 may be partial because the receiver type is unknown">,
 InGroup, DefaultIgnore;
+def warn_at_available_unchecked_use : Warning<
+  "%select{@available|__builtin_available}0 does not guard availability here; "
+  "use if (%select{@available|__builtin_available}0) instead">,
+  InGroup>;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<
Index: cfe/trunk/test/Parser/objc-available.m
===
--- cfe/trunk/test/Parser/objc-available.m
+++ cfe/trunk/test/Parser/objc-available.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -triple 
x86_64-apple-macosx10.10.0 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability 
-Wno-unsupported-availability-guard -triple x86_64-apple-macosx10.10.0 -verify 
%s
 
 void f() {
 
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -10,7 +10,7 @@
 #ifdef OBJCPP
 // expected-note@+2 6 {{marked partial here}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 6 {{'func_10_12' has been 
explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been 
explicitly marked partial here}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -155,6 +155,16 @@
   id y = x[42]; // expected-warning{{'objectAtIndexedSubscript:' is only 
available on macOS 10.12 or newer}} expected-note{{@available}}
 }
 
+void uncheckAtAvailable() {
+  if (@available(macOS 10.12, *) || 0) // expected-warning {{@available does 
not guard availability here; use if (@available) instead}}
+func_10_12(); // expected-warning {{'func_10_12' is only available on 
macOS 10.12 or newer}}
+  // expected-note@-1 {{enclose 'func_10_12' in an @available check to silence 
this warning}}
+}
+
+void justAtAvailable() {
+  int availability = @available(macOS 10.12, *); // expected-warning 
{{@available does not guard availability here; use if (@available) instead}}
+}
+
 #ifdef OBJCPP
 
 int f(char) AVAILABLE_10_12;
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -7284,6 +7284,12 @@
 return true;
   }
 
+  bool VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+SemaRef.Diag(E->getLocStart(), diag::warn_at_available_unchecked_use)
+<< (!SemaRef.getLangOpts().ObjC1);
+return true;
+  }
+
   bool VisitTypeLoc(TypeLoc Ty);
 };
 
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -15762,6 +15762,13 @@
   if (Spec != AvailSpecs.end())
 Version = Spec->getVersion();
 
+  // The use of `@available` in the enclosing function should be analyzed to
+  // warn when it's used inappropriately (i.e. not if(@available)).
+  if (getCurFunctionOrMethodDecl())
+getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
+  else if (getCurBlock() || getCurLambda())
+getCurFunction()->HasPotentialAvailabilityViolations = true;
+
   return new (Context)
   ObjCAvailabilityCheckExpr(Version, AtLoc, RParen, Context.BoolTy);
 }


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2886,6 +2886,10 @@
 def warn_partial_fwdclass_message : Warning<
 "%0 may be partial because the receiver type is unknown">,
 InGroup, DefaultIgnore;
+def warn_at_available_unchecked_use : Warning<
+  "%select{@available|__builtin_available}0 does not guard availability here; "
+  "use if (%select{@available|__builtin_available}0) instead">,
+  InGroup>;
 
 // Thread Safety Attributes
 def warn_invalid_capability_name : Warning<
Index: cfe/trunk/

[PATCH] D33497: clang-tidy check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

1. What about `__PRETTY_FUNCTION__` ?
2. Consider following generic error handling macro:

(ThrowException is some template function)

  #undef STR
  #define STR(a) XSTR(a)
  
  #define ThrowExceptionHelper(CLASS, fmt, ...) ThrowException(__FILE__ 
":" STR(__LINE__) ": %s: " fmt, __PRETTY_FUNCTION__, ##__VA_ARGS__)
  #endif

Which is called like `if(somethig) ThrowException(std::exception, "%s", "bar");`
Even though the function name may be useless, file/line info is still there and 
is(?) correct.
Perhaps there should not be a warning in such a case?


https://reviews.llvm.org/D33497



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-05-24 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100095.
Typz added a comment.

add new value to AlignOperands to support this mode.
fix some corner cases.


https://reviews.llvm.org/D32478

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/ContinuationIndenter.h
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -102,7 +102,7 @@
   verifyFormat("var x = a() in\n"
".aa.aa;");
   FormatStyle Style = getGoogleJSStyleWithColumns(80);
-  Style.AlignOperands = true;
+  Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("var x = a() in\n"
".aa.aa;",
Style);
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2503,6 +2503,9 @@
"  > c) {\n"
"}",
Style);
+  verifyFormat("return a\n"
+   "   && bbb;",
+   Style);
   verifyFormat("return (a)\n"
"   // comment\n"
"   + b;",
@@ -2531,11 +2534,104 @@
 
   Style.ColumnLimit = 60;
   verifyFormat("zz\n"
-   "= b\n"
+   "= \n"
"  >> (aa);",
Style);
 }
 
+TEST_F(FormatTest, ExpressionIndentationStrictAlign) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  Style.AlignOperands = FormatStyle::OAS_StrictAlign;
+
+  verifyFormat(
+  "bool value = a\n"
+  "   + a\n"
+  "   + a\n"
+  "  == a\n"
+  " * b\n"
+  " + b\n"
+  "  && a\n"
+  " * a\n"
+  " > c;",
+  Style);
+  verifyFormat("if (a\n"
+   "* \n"
+   "+ aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "+ \n"
+   "  * aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "== \n"
+   "   * aa\n"
+   "   + bbb) {\n}",
+   Style);
+  verifyFormat("if () {\n"
+   "} else if (a\n"
+   "   && b // break\n"
+   "  > c) {\n"
+   "}",
+   Style);
+  verifyFormat("return a\n"
+   "&& bbb;",
+   Style);
+  verifyFormat("return (a)\n"
+   "   // comment\n"
+   " + b;",
+   Style);
+  verifyFormat(
+  "int aa = aa\n"
+  "   * bbb\n"
+  "   + cc;",
+  Style);
+
+  verifyFormat("a\n"
+   "=  + ;",
+   Style);
+
+  verifyFormat("return boost::fusion::at_c<0>().second\n"
+   "== boost::fusion::at_c<1>().second;",
+   Style);
+
+  Style.ColumnLimit = 60;
+  verifyFormat("z\n"
+   "= \n"
+   "   >> (aa);",
+   Style);
+
+  // Forced by co

[PATCH] D33498: [coroutines] Make generic lambda coroutines work

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D33498



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


[PATCH] D33498: [coroutines] Make generic lambda coroutines work

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.
Herald added a subscriber: EricWF.

1. Coroutine cannot be constexpr (added a check in SemaLambda.cpp not to mark 
coroutine as constexpr)
2. TransformCoroutineBodyStmt should transform ResultDecl and ReturnStmt


https://reviews.llvm.org/D33498

Files:
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-lambda.cpp


Index: test/CodeGenCoroutines/coro-lambda.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-lambda.cpp
@@ -0,0 +1,58 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function 
template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu 
-emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | 
FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+template  struct coroutine_handle : coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Task {
+  struct promise_type {
+Task get_return_object();
+void return_void() {}
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  auto SyncAwait(_AwrT &&A) {
+  if (!A.await_ready()) {
+auto AwaitAsync = [&]() -> Task {
+  try { (void)(co_await A); } catch (...) {}
+};
+Task t = AwaitAsync();
+  }
+  return A.await_resume();
+}
+
+void f() {
+  suspend_always test;
+  SyncAwait(test);
+}
+
+// Verify that we synthesized the coroutine for a lambda inside SyncAwait
+// CHECK-LABEL: define linkonce_odr void 
@_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
+//   CHECK: alloca %"struct.Task::promise_type"
+//   CHECK: call token @llvm.coro.id(
+//   CHECK: call i8 @llvm.coro.suspend(
+//   CHECK: call i1 @llvm.coro.end(
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6945,6 +6945,19 @@
 if (DeallocRes.isInvalid())
   return StmtError();
 Builder.Deallocate = DeallocRes.get();
+
+assert(S->getResultDecl() && "ResultDecl must already be built");
+StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
+if (ResultDecl.isInvalid())
+  return StmtError();
+Builder.ResultDecl = ResultDecl.get();
+
+if (auto *ReturnStmt = S->getReturnStmt()) {
+  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
+  if (Res.isInvalid())
+return StmtError();
+  Builder.ReturnStmt = Res.get();
+}
   }
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1591,6 +1591,7 @@
   // its constexpr-ness, supressing diagnostics while doing so.
   if (getLangOpts().CPlusPlus1z && !CallOperator->isInvalidDecl() &&
   !CallOperator->isConstexpr() &&
+  !isa(CallOperator->getBody()) &&
   !Class->getDeclContext()->isDependentContext()) {
 TentativeAnalysisScope DiagnosticScopeGuard(*this);
 CallOperator->setConstexpr(


Index: test/CodeGenCoroutines/coro-lambda.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-lambda.cpp
@@ -0,0 +1,58 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+template  struct coroutine_handle : coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Task {
+  struct promise_type {
+Task get_return_object();
+void return_void() {}
+suspend_always initial_suspen

[PATCH] D33499: [PPC] First approximation of PPC32/Darwin ABI info

2017-05-24 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz created this revision.

Use the default implementation of EmitVAArg instead of the SVR4 one.  This is 
meant to address PR33108.

This is really just a scaffold.  I don't know what exactly needs to be 
implemented for Darwin.

The motivating testcase:

  void foo() {
__builtin_va_list va;
__builtin_va_arg(va, int);
  }

Compiling with `clang -target powerpc-unknown-macosx -S test.c` results in a 
crash.


Repository:
  rL LLVM

https://reviews.llvm.org/D33499

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4181,6 +4181,70 @@
   return false;
 }
 
+namespace {
+/// PPC32_Darwin_ABIInfo - The 32-bit PowerPC Darwin ABI information.
+class PPC32_Darwin_ABIInfo : public DefaultABIInfo {
+public:
+  PPC32_Darwin_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+};
+
+class PPC32DarwinTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  PPC32DarwinTargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(new PPC32_Darwin_ABIInfo(CGT)) {}
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+// This is recovered from gcc output.
+return 1; // r1 is the dedicated stack pointer
+  }
+
+  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override;
+};
+}
+
+// Copied from PP32TargetCodeGenInfo.
+bool
+PPC32DarwinTargetCodeGenInfo::initDwarfEHRegSizeTable(
+  CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const {
+  // This is calculated from the LLVM and GCC tables and verified
+  // against gcc output.  AFAIK all ABIs use the same encoding.
+
+  CodeGen::CGBuilderTy &Builder = CGF.Builder;
+
+  llvm::IntegerType *i8 = CGF.Int8Ty;
+  llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
+  llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
+  llvm::Value *Sixteen8 = llvm::ConstantInt::get(i8, 16);
+
+  // 0-31: r0-31, the 4-byte general-purpose registers
+  AssignToArrayRange(Builder, Address, Four8, 0, 31);
+
+  // 32-63: fp0-31, the 8-byte floating-point registers
+  AssignToArrayRange(Builder, Address, Eight8, 32, 63);
+
+  // 64-76 are various 4-byte special-purpose registers:
+  // 64: mq
+  // 65: lr
+  // 66: ctr
+  // 67: ap
+  // 68-75 cr0-7
+  // 76: xer
+  AssignToArrayRange(Builder, Address, Four8, 64, 76);
+
+  // 77-108: v0-31, the 16-byte vector registers
+  AssignToArrayRange(Builder, Address, Sixteen8, 77, 108);
+
+  // 109: vrsave
+  // 110: vscr
+  // 111: spe_acc
+  // 112: spefscr
+  // 113: sfp
+  AssignToArrayRange(Builder, Address, Four8, 109, 113);
+
+  return false;
+}
+
 // PowerPC-64
 
 namespace {
@@ -8488,6 +8552,8 @@
   }
 
   case llvm::Triple::ppc:
+if (Triple.isOSDarwin())
+  return SetCGInfo(new PPC32DarwinTargetCodeGenInfo(Types));
 return SetCGInfo(
 new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft"));
   case llvm::Triple::ppc64:


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4181,6 +4181,70 @@
   return false;
 }
 
+namespace {
+/// PPC32_Darwin_ABIInfo - The 32-bit PowerPC Darwin ABI information.
+class PPC32_Darwin_ABIInfo : public DefaultABIInfo {
+public:
+  PPC32_Darwin_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+};
+
+class PPC32DarwinTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  PPC32DarwinTargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(new PPC32_Darwin_ABIInfo(CGT)) {}
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+// This is recovered from gcc output.
+return 1; // r1 is the dedicated stack pointer
+  }
+
+  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override;
+};
+}
+
+// Copied from PP32TargetCodeGenInfo.
+bool
+PPC32DarwinTargetCodeGenInfo::initDwarfEHRegSizeTable(
+  CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const {
+  // This is calculated from the LLVM and GCC tables and verified
+  // against gcc output.  AFAIK all ABIs use the same encoding.
+
+  CodeGen::CGBuilderTy &Builder = CGF.Builder;
+
+  llvm::IntegerType *i8 = CGF.Int8Ty;
+  llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
+  llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
+  llvm::Value *Sixteen8 = llvm::ConstantInt::get(i8, 16);
+
+  // 0-31: r0-31, the 4-byte general-purpose registers
+  AssignToArrayRange(Builder, Address, Four8, 0, 31);
+
+  // 32-63: fp0-31, the 8-byte floating-point registers
+  AssignToArrayRange(Builder, Address, Eight8, 32, 63);
+
+  // 64-76 are various 4-byte special-purpose registers:
+  // 64: mq
+  // 65: lr
+  // 66: ctr
+  // 67: ap
+  // 68-75 cr0-7
+  // 76: xer
+  AssignToArrayRange(Builder, Address, Four8, 64, 76);
+
+  // 7

r303764 - [coroutines] Make generic lambda coroutines work

2017-05-24 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Wed May 24 10:44:57 2017
New Revision: 303764

URL: http://llvm.org/viewvc/llvm-project?rev=303764&view=rev
Log:
[coroutines] Make generic lambda coroutines work

Summary:
1. Coroutine cannot be constexpr (added a check in SemaLambda.cpp not to mark 
coroutine as constexpr)
2. TransformCoroutineBodyStmt should transform ResultDecl and ReturnStmt

Reviewers: rsmith, GorNishanov

Reviewed By: GorNishanov

Subscribers: EricWF, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=303764&r1=303763&r2=303764&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Wed May 24 10:44:57 2017
@@ -1591,6 +1591,7 @@ ExprResult Sema::BuildLambdaExpr(SourceL
   // its constexpr-ness, supressing diagnostics while doing so.
   if (getLangOpts().CPlusPlus1z && !CallOperator->isInvalidDecl() &&
   !CallOperator->isConstexpr() &&
+  !isa(CallOperator->getBody()) &&
   !Class->getDeclContext()->isDependentContext()) {
 TentativeAnalysisScope DiagnosticScopeGuard(*this);
 CallOperator->setConstexpr(

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=303764&r1=303763&r2=303764&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Wed May 24 10:44:57 2017
@@ -6945,6 +6945,19 @@ TreeTransform::TransformCorouti
 if (DeallocRes.isInvalid())
   return StmtError();
 Builder.Deallocate = DeallocRes.get();
+
+assert(S->getResultDecl() && "ResultDecl must already be built");
+StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
+if (ResultDecl.isInvalid())
+  return StmtError();
+Builder.ResultDecl = ResultDecl.get();
+
+if (auto *ReturnStmt = S->getReturnStmt()) {
+  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
+  if (Res.isInvalid())
+return StmtError();
+  Builder.ReturnStmt = Res.get();
+}
   }
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);

Added: cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp?rev=303764&view=auto
==
--- cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp (added)
+++ cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp Wed May 24 10:44:57 2017
@@ -0,0 +1,58 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function 
template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu 
-emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | 
FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+template  struct coroutine_handle : coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Task {
+  struct promise_type {
+Task get_return_object();
+void return_void() {}
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  auto SyncAwait(_AwrT &&A) {
+  if (!A.await_ready()) {
+auto AwaitAsync = [&]() -> Task {
+  try { (void)(co_await A); } catch (...) {}
+};
+Task t = AwaitAsync();
+  }
+  return A.await_resume();
+}
+
+void f() {
+  suspend_always test;
+  SyncAwait(test);
+}
+
+// Verify that we synthesized the coroutine for a lambda inside SyncAwait
+// CHECK-LABEL: define linkonce_odr void 
@_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
+//   CHECK: alloca %"struct.Task::promise_type"
+//   CHECK: call token @llvm.coro.id(
+//   CHECK: call i8 @llvm.coro.suspend(
+//   CHECK: call i1 @llvm.coro.end(


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


[PATCH] D33498: [coroutines] Make generic lambda coroutines work

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303764: [coroutines] Make generic lambda coroutines work 
(authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D33498?vs=100097&id=100102#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33498

Files:
  cfe/trunk/lib/Sema/SemaLambda.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp


Index: cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
===
--- cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
+++ cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
@@ -0,0 +1,58 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function 
template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu 
-emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | 
FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+template  struct coroutine_handle : coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Task {
+  struct promise_type {
+Task get_return_object();
+void return_void() {}
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+template  auto SyncAwait(_AwrT &&A) {
+  if (!A.await_ready()) {
+auto AwaitAsync = [&]() -> Task {
+  try { (void)(co_await A); } catch (...) {}
+};
+Task t = AwaitAsync();
+  }
+  return A.await_resume();
+}
+
+void f() {
+  suspend_always test;
+  SyncAwait(test);
+}
+
+// Verify that we synthesized the coroutine for a lambda inside SyncAwait
+// CHECK-LABEL: define linkonce_odr void 
@_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
+//   CHECK: alloca %"struct.Task::promise_type"
+//   CHECK: call token @llvm.coro.id(
+//   CHECK: call i8 @llvm.coro.suspend(
+//   CHECK: call i1 @llvm.coro.end(
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -6945,6 +6945,19 @@
 if (DeallocRes.isInvalid())
   return StmtError();
 Builder.Deallocate = DeallocRes.get();
+
+assert(S->getResultDecl() && "ResultDecl must already be built");
+StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
+if (ResultDecl.isInvalid())
+  return StmtError();
+Builder.ResultDecl = ResultDecl.get();
+
+if (auto *ReturnStmt = S->getReturnStmt()) {
+  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
+  if (Res.isInvalid())
+return StmtError();
+  Builder.ReturnStmt = Res.get();
+}
   }
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
Index: cfe/trunk/lib/Sema/SemaLambda.cpp
===
--- cfe/trunk/lib/Sema/SemaLambda.cpp
+++ cfe/trunk/lib/Sema/SemaLambda.cpp
@@ -1591,6 +1591,7 @@
   // its constexpr-ness, supressing diagnostics while doing so.
   if (getLangOpts().CPlusPlus1z && !CallOperator->isInvalidDecl() &&
   !CallOperator->isConstexpr() &&
+  !isa(CallOperator->getBody()) &&
   !Class->getDeclContext()->isDependentContext()) {
 TentativeAnalysisScope DiagnosticScopeGuard(*this);
 CallOperator->setConstexpr(


Index: cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
===
--- cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
+++ cfe/trunk/test/CodeGenCoroutines/coro-lambda.cpp
@@ -0,0 +1,58 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template  struct coroutine_handle;
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+template  struct coroutine_handle : coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcep

[PATCH] D33497: clang-tidy check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Bryce Liu via Phabricator via cfe-commits
brycel added a comment.

In https://reviews.llvm.org/D33497#763307, @lebedev.ri wrote:

> 1. What about `__PRETTY_FUNCTION__` ?


`__PRETTY_FUNCTION__` is a little more useful, it at least tells you which 
function the lambda is defined in:

  #include 
  
  int main() {
auto f = [] {
  printf("__func__: %s\n", __func__);
  printf("__FUNCTION__: %s\n", __FUNCTION__);
  printf("__PRETTY_FUNCTION__: %s\n", __PRETTY_FUNCTION__);
};
f();
  }

results in the output:

  __func__: operator()
  __FUNCTION__: operator()
  __PRETTY_FUNCTION__: auto main()::(anonymous class)::operator()() const

I think `__PRETTY_FUNCTION__` inside a lambda is useful enough not to warn 
about.

> 2. Consider following generic error handling macro: (ThrowException is some 
> template function) ``` #undef STR #define STR(a) XSTR(a)
> 
>   #define ThrowExceptionHelper(CLASS, fmt, ...) 
> ThrowException(__FILE__ ":" STR(__LINE__) ": %s: " fmt, 
> __PRETTY_FUNCTION__, ##__VA_ARGS__) #endif ``` Which is called like 
> `if(somethig) ThrowException(std::exception, "%s", "bar");` Even though the 
> function name may be useless, file/line info is still there and is(?) 
> correct. Perhaps there should not be a warning in such a case?

That's a good point. I'll look into suppressing the warning if we're in a macro 
definition where `__FILE__` and `__LINE__` are both used. It may suppress some 
warnings that would be legitimate (such as if `__FILE__`/`__LINE__` are written 
but not actually output anywhere), but in those cases it's probably impossible 
to figure out the author's intention.


https://reviews.llvm.org/D33497



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


[PATCH] D33499: [PPC] First approximation of PPC32/Darwin ABI info

2017-05-24 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz updated this revision to Diff 100105.
kparzysz added a comment.

Add implementation of EmitVAArg and explicitly call emitVoidPtrVAArg in it.


Repository:
  rL LLVM

https://reviews.llvm.org/D33499

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4181,6 +4181,82 @@
   return false;
 }
 
+namespace {
+/// PPC32_Darwin_ABIInfo - The 32-bit PowerPC Darwin ABI information.
+class PPC32_Darwin_ABIInfo : public DefaultABIInfo {
+public:
+  PPC32_Darwin_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override;
+};
+
+class PPC32DarwinTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  PPC32DarwinTargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(new PPC32_Darwin_ABIInfo(CGT)) {}
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+// This is recovered from gcc output.
+return 1; // r1 is the dedicated stack pointer
+  }
+
+  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override;
+};
+}
+
+Address PPC32_Darwin_ABIInfo::EmitVAArg(CodeGenFunction &CGF,
+Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect=*/ false,
+  getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(4),
+  /*AllowHigherAlign=*/ true);
+}
+
+// Copied from PP32TargetCodeGenInfo.
+bool
+PPC32DarwinTargetCodeGenInfo::initDwarfEHRegSizeTable(
+  CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const {
+  // This is calculated from the LLVM and GCC tables and verified
+  // against gcc output.  AFAIK all ABIs use the same encoding.
+
+  CodeGen::CGBuilderTy &Builder = CGF.Builder;
+
+  llvm::IntegerType *i8 = CGF.Int8Ty;
+  llvm::Value *Four8 = llvm::ConstantInt::get(i8, 4);
+  llvm::Value *Eight8 = llvm::ConstantInt::get(i8, 8);
+  llvm::Value *Sixteen8 = llvm::ConstantInt::get(i8, 16);
+
+  // 0-31: r0-31, the 4-byte general-purpose registers
+  AssignToArrayRange(Builder, Address, Four8, 0, 31);
+
+  // 32-63: fp0-31, the 8-byte floating-point registers
+  AssignToArrayRange(Builder, Address, Eight8, 32, 63);
+
+  // 64-76 are various 4-byte special-purpose registers:
+  // 64: mq
+  // 65: lr
+  // 66: ctr
+  // 67: ap
+  // 68-75 cr0-7
+  // 76: xer
+  AssignToArrayRange(Builder, Address, Four8, 64, 76);
+
+  // 77-108: v0-31, the 16-byte vector registers
+  AssignToArrayRange(Builder, Address, Sixteen8, 77, 108);
+
+  // 109: vrsave
+  // 110: vscr
+  // 111: spe_acc
+  // 112: spefscr
+  // 113: sfp
+  AssignToArrayRange(Builder, Address, Four8, 109, 113);
+
+  return false;
+}
+
 // PowerPC-64
 
 namespace {
@@ -8488,6 +8564,8 @@
   }
 
   case llvm::Triple::ppc:
+if (Triple.isOSDarwin())
+  return SetCGInfo(new PPC32DarwinTargetCodeGenInfo(Types));
 return SetCGInfo(
 new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft"));
   case llvm::Triple::ppc64:


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4181,6 +4181,82 @@
   return false;
 }
 
+namespace {
+/// PPC32_Darwin_ABIInfo - The 32-bit PowerPC Darwin ABI information.
+class PPC32_Darwin_ABIInfo : public DefaultABIInfo {
+public:
+  PPC32_Darwin_ABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override;
+};
+
+class PPC32DarwinTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  PPC32DarwinTargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(new PPC32_Darwin_ABIInfo(CGT)) {}
+
+  int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
+// This is recovered from gcc output.
+return 1; // r1 is the dedicated stack pointer
+  }
+
+  bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override;
+};
+}
+
+Address PPC32_Darwin_ABIInfo::EmitVAArg(CodeGenFunction &CGF,
+Address VAListAddr,
+QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect=*/ false,
+  getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(4),
+  /*AllowHigherAlign=*/ true);
+}
+
+// Copied from PP32TargetCodeGenInfo.
+bool
+PPC32DarwinTargetCodeGenInfo::initDwarfEHRegSizeTable(
+  CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const {
+  // 

r303766 - [PowerPC] Implement vec_xxsldwi builtin.

2017-05-24 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Wed May 24 10:54:13 2017
New Revision: 303766

URL: http://llvm.org/viewvc/llvm-project?rev=303766&view=rev
Log:
[PowerPC] Implement vec_xxsldwi builtin.

The vec_xxsldwi builtin is missing from altivec.h. This has been requested by
developers working on libvpx for VP9 support for Google.

The patch fixes PR: https://bugs.llvm.org/show_bug.cgi?id=32653
Differential Revision: https://reviews.llvm.org/D33236

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins-ppc-error.c
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=303766&r1=303765&r2=303766&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Wed May 24 10:54:13 2017
@@ -421,6 +421,7 @@ BUILTIN(__builtin_vsx_insertword, "V16Uc
 BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
 
 BUILTIN(__builtin_vsx_xxpermdi, "v.", "t")
+BUILTIN(__builtin_vsx_xxsldwi, "v.", "t")
 
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=303766&r1=303765&r2=303766&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed May 24 10:54:13 2017
@@ -8475,6 +8475,47 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
 auto RetTy = ConvertType(BIRetType);
 return Builder.CreateBitCast(ShuffleCall, RetTy);
   }
+
+  case PPC::BI__builtin_vsx_xxsldwi: {
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI && "Third argument must be a compile time constant");
+unsigned Index = ArgCI->getZExtValue() & 0x3;
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 4));
+Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int32Ty, 4));
+
+// Create a shuffle mask
+unsigned ElemIdx0;
+unsigned ElemIdx1;
+unsigned ElemIdx2;
+unsigned ElemIdx3;
+if (getTarget().isLittleEndian()) {
+  // Little endian element N comes from element 8+N-Index of the
+  // concatenated wide vector (of course, using modulo arithmetic on
+  // the total number of elements).
+  ElemIdx0 = (8 - Index) % 8;
+  ElemIdx1 = (9 - Index) % 8;
+  ElemIdx2 = (10 - Index) % 8;
+  ElemIdx3 = (11 - Index) % 8;
+} else {
+  // Big endian ElemIdx = Index + N
+  ElemIdx0 = Index;
+  ElemIdx1 = Index + 1;
+  ElemIdx2 = Index + 2;
+  ElemIdx3 = Index + 3;
+}
+
+Constant *ShuffleElts[4] = {ConstantInt::get(Int32Ty, ElemIdx0),
+ConstantInt::get(Int32Ty, ElemIdx1),
+ConstantInt::get(Int32Ty, ElemIdx2),
+ConstantInt::get(Int32Ty, ElemIdx3)};
+
+Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
+Value *ShuffleCall =
+Builder.CreateShuffleVector(Ops[0], Ops[1], ShuffleMask);
+QualType BIRetType = E->getType();
+auto RetTy = ConvertType(BIRetType);
+return Builder.CreateBitCast(ShuffleCall, RetTy);
+  }
   }
 }
 

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=303766&r1=303765&r2=303766&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Wed May 24 10:54:13 2017
@@ -12158,6 +12158,7 @@ static __inline__ void __ATTRS_o_ai vec_
 
 #ifdef __VSX__
 #define vec_xxpermdi __builtin_vsx_xxpermdi
+#define vec_xxsldwi __builtin_vsx_xxsldwi
 #endif
 
 /* vec_xor */

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=303766&r1=303765&r2=303766&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed May 24 10:54:13 2017
@@ -1697,6 +1697,7 @@ bool Sema::CheckPPCBuiltinFunctionCall(u
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
   case PPC::BI__builtin_vsx_xxpermdi:
+  case PPC::BI__builtin_vsx_xxsldwi:
 return SemaBuiltinVSX(TheCall);
   }
   return SemaBuiltinConstantArgRange(TheCall, i, l, u);

Modified: cfe/trunk/test/CodeGen/builtins-ppc-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-error.c?rev=303766&r1=303765&r2=303766&view=diff

[PATCH] D33497: clang-tidy check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D33497#763376, @brycel wrote:

> In https://reviews.llvm.org/D33497#763307, @lebedev.ri wrote:
>
> > 1. What about `__PRETTY_FUNCTION__` ?
>
>
> I think `__PRETTY_FUNCTION__` inside a lambda is useful enough not to warn 
> about.


Then that should be checked by the test

>> 2. Consider following generic error handling macro: (ThrowException is some 
>> template function)
> 
> That's a good point. I'll look into suppressing the warning if we're in a 
> macro definition where `__FILE__` and `__LINE__` are both used. It may 
> suppress some warnings that would be legitimate (such as if 
> `__FILE__`/`__LINE__` are written but not actually output anywhere), but in 
> those cases it's probably impossible to figure out the author's intention.

Makes sense


https://reviews.llvm.org/D33497



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


Re: r303712 - Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

2017-05-24 Thread Aaron Ballman via cfe-commits
On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits
 wrote:
> Author: akirtzidis
> Date: Tue May 23 19:46:27 2017
> New Revision: 303712
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303712&view=rev
> Log:
> Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods 
> and properties as well
>
> This is an initial commit to allow using it with constant expressions, a 
> follow-up commit will enable full support for it in ObjC methods.
>
> Added:
> cfe/trunk/test/SemaObjC/diagnose_if.m
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017
> @@ -149,6 +149,9 @@ class ExprArgument  class FunctionArgument : 
> Argument
> opt,
>
> fake>;
> +class NamedArgument : Argument +  
> opt,
> +  
> fake>;
>  class TypeArgument : Argument;
>  class UnsignedArgument : Argument;
>  class VariadicUnsignedArgument : Argument;
> @@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {
>
>  def DiagnoseIf : InheritableAttr {
>let Spellings = [GNU<"diagnose_if">];
> -  let Subjects = SubjectList<[Function]>;
> +  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
>let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
>EnumArgument<"DiagnosticType",
> "DiagnosticType",
> ["error", "warning"],
> ["DT_Error", "DT_Warning"]>,
>BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
> -  FunctionArgument<"Parent", 0, /*fake*/ 1>];
> +  NamedArgument<"Parent", 0, /*fake*/ 1>];
>let DuplicatesAllowedWhileMerging = 1;
>let LateParsed = 1;
>let AdditionalMembers = [{
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 19:46:27 
> 2017
> @@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War
>"|types and namespaces"
>"|Objective-C interfaces"
>"|methods and properties"
> +  "|functions, methods and properties"

functions, methods, and properties (inserting the Oxford comma).

>"|struct or union"
>"|struct, union or class"
>"|types"
>
> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
> +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017
> @@ -915,6 +915,7 @@ enum AttributeDeclKind {
>ExpectedTypeOrNamespace,
>ExpectedObjectiveCInterface,
>ExpectedMethodOrProperty,
> +  ExpectedFunctionOrMethodOrProperty,
>ExpectedStructOrUnion,
>ExpectedStructOrUnionOrClass,
>ExpectedType,
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 19:46:27 2017
> @@ -2727,7 +2727,7 @@ public:
>/// of a function.
>///
>/// Returns true if any errors were emitted.
> -  bool diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,
> +  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
>   SourceLocation Loc);
>
>/// Returns whether the given function's address can be taken or not,
>
> Modified: cfe/trunk/lib/Lex/PPMa

[PATCH] D33448: [CodeGen] Add thumb-mode to function target-features for arm/thumb triples.

2017-05-24 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In https://reviews.llvm.org/D33448#762410, @echristo wrote:

> I probably would have added this as a feature in ARMTargetInfo similar to 
> CRC/soft-float/etc.
>
> Thoughts?


Do you mean ARMTargetMachine::getSubtargetImpl 
(https://github.com/llvm-mirror/llvm/blob/master/lib/Target/ARM/ARMTargetMachine.cpp#L305)
 ?

It seems like that function is only used by llc (and not llvm-as for example) 
and at that stage it is too late to add thumb-mode, because llc operates on a 
single module with a single target triple.


https://reviews.llvm.org/D33448



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


r303768 - [OPENMP] Allow value of thread local variables in target regions.

2017-05-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed May 24 11:00:02 2017
New Revision: 303768

URL: http://llvm.org/viewvc/llvm-project?rev=303768&view=rev
Log:
[OPENMP] Allow value of thread local variables in target regions.

If the variable is marked as TLS variable and target device does not
support TLS, the error is emitted for the variable even if it is not
used in target regions. Patch fixes this and allows to use the values of
the TLS variables in target regions.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=303768&r1=303767&r2=303768&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed May 24 11:00:02 2017
@@ -6516,7 +6516,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
diag::err_thread_non_global)
 << DeclSpec::getSpecifierName(TSCS);
 else if (!Context.getTargetInfo().isTLSSupported()) {
-  if (getLangOpts().CUDA) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
 // Postpone error emission until we've collected attributes required to
 // figure out whether it's a host or device variable and whether the
 // error should be ignored.
@@ -6578,8 +6578,11 @@ NamedDecl *Sema::ActOnVariableDeclarator
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
-  if (getLangOpts().CUDA) {
-if (EmitTLSUnsupportedError && DeclAttrsMatchCUDAMode(getLangOpts(), 
NewVD))
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+if (EmitTLSUnsupportedError &&
+((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) 
||
+ (getLangOpts().OpenMPIsDevice &&
+  NewVD->hasAttr(
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static

Modified: cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp?rev=303768&r1=303767&r2=303768&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp Wed May 24 11:00:02 2017
@@ -9,12 +9,14 @@
 #define HEADER
 
 // Check that the execution mode of all 6 target regions is set to Generic 
Mode.
-// CHECK-DAG: {{@__omp_offloading_.+l98}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l175}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l284}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l321}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l339}}_exec_mode = weak constant i8 1
-// CHECK-DAG: {{@__omp_offloading_.+l304}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l100}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l177}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l287}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l324}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l342}}_exec_mode = weak constant i8 1
+// CHECK-DAG: {{@__omp_offloading_.+l307}}_exec_mode = weak constant i8 1
+
+__thread int id;
 
 template
 struct TT{
@@ -31,7 +33,7 @@ int foo(int n) {
   double cn[5][n];
   TT d;
 
-  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l98}}_worker()
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l100}}_worker()
   // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
   // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
   // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
@@ -62,7 +64,7 @@ int foo(int n) {
   // CHECK: [[EXIT]]
   // CHECK: ret void
 
-  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l98]]()
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l100]]()
   // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
   // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
   // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
@@ -104,7 +106,7 @@ int foo(int n) {
   {
   }
 
-  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l175}}_worker()
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l177}}_worker()
   // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8,
   // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*,
   // CHECK: store i8* null, i8** [[OMP_WORK_FN]],
@@ -135,7 +137,7 @@ int foo(int n) {
   // CHECK: [[EXIT]]
   // CHECK: ret void
 
-  // CHECK: define {{.*}}void 
[[T2:@__omp_offloading_.+foo.+l175]](i[[SZ:32|64]] [[ARG1:%[a-zA-Z_]+]])
+  // CHECK: define {{.*}}void 
[[

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-24 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D32671#762840, @mpark wrote:

> @CaseyCarter: Do these changes pass with the current version?
>  Also, have you seen the tests in 
> `test/libcxx/utilities/variant/variant.variant`?
>  If yes, do those tests and the ones in this diff overlap at all?
>  Curious as to how we should merge them.


Disclaimer: I know nothing about the libc++ , and I didn't realize 
there were tests in the libcxx tree for variant.

These tests technically "pass" with the current version since they do nothing 
when testing libc++ - they're currently only enabled when testing the MSVC 
standard library. I hadn't bothered to try them with libc++ variant before, but 
when I do they all pass except for triviality_test of copy/move assignment with 
`NoCopy` as an alternative. Those results indicate to me that you already 
implement fine-grained SMF triviality, and the discrepancy with `NoCopy` is 
probably due to the lack of LWG2904.

Taking a look at the libcxx tree tests:

- There are SMF sfinae tests in these for (what is now) standard behavior that 
should be moved into the std tree tests.
- Your `test_XXX_basic` tests are effectively testing the same behavior as 
these but with "is `constexpr`" as a proxy for "is trivial", and using more 
demonstrative code whereas mine only tests traits.

I think I'd like to integrate those tests into the std tree, if that's ok with 
you.


https://reviews.llvm.org/D32671



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


[PATCH] D33356: [Nios2] Changes in frontend to support Nios2 LLVM target

2017-05-24 Thread Mateusz Belicki via Phabricator via cfe-commits
belickim updated this revision to Diff 100111.
belickim added a comment.

I implemented changes suggested by Joerg.

In previous version there was also an additional macro with CPU name that I 
removed. It was not documented anywhere and is not even used by GCC. So there 
seems to be no prior usages, that would support its existence. The presence of 
that macro in previous version of the patch was an oversight.


https://reviews.llvm.org/D33356

Files:
  include/clang/Basic/BuiltinsNios2.def
  include/clang/Basic/TargetBuiltins.h
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains/CommonArgs.cpp

Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -215,6 +215,21 @@
   return "";
 }
 
+static std::string getNios2TargetCPU(const ArgList &Args) {
+  Arg *A = Args.getLastArg(options::OPT_mcpu_EQ);
+  if (A == nullptr)
+A = Args.getLastArg(options::OPT_march_EQ);
+
+  if (A) {
+const char *name = A->getValue();
+return llvm::StringSwitch(name)
+.Case("r1", "nios2r1")
+.Case("r2", "nios2r2")
+.Default(name);
+  }
+  return "";
+}
+
 static std::string getLanaiTargetCPU(const ArgList &Args) {
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 return A->getValue();
@@ -267,6 +282,10 @@
   return A->getValue();
 return "";
 
+  case llvm::Triple::nios2: {
+return getNios2TargetCPU(Args);
+  }
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7604,6 +7604,148 @@
   }
 };
 
+class Nios2TargetInfo : public TargetInfo {
+  void setDataLayout() {
+if (BigEndian) {
+  resetDataLayout("E-p:32:32:32-i8:8:32-i16:16:32-n32");
+} else {
+  resetDataLayout("e-p:32:32:32-i8:8:32-i16:16:32-n32");
+}
+  }
+
+  static const Builtin::Info BuiltinInfo[];
+  std::string CPU;
+  std::string ABI;
+
+public:
+  Nios2TargetInfo(const llvm::Triple &triple, const TargetOptions &opts)
+  : TargetInfo(triple), CPU(opts.CPU), ABI(opts.ABI) {
+SizeType = UnsignedInt;
+PtrDiffType = SignedInt;
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+setDataLayout();
+  }
+
+  StringRef getABI() const override { return ABI; }
+  bool setABI(const std::string &Name) override {
+if ((Name == "o32") || (Name == "eabi")) {
+  ABI = Name;
+  return true;
+}
+return false;
+  }
+
+  bool setCPU(const std::string &Name) override {
+if ((Name == "nios2r1") || (Name == "nios2r2")) {
+  CPU = Name;
+  return true;
+}
+return false;
+  }
+
+  void getTargetDefines(const LangOptions &Opts,
+MacroBuilder &Builder) const override {
+DefineStd(Builder, "nios2", Opts);
+DefineStd(Builder, "NIOS2", Opts);
+
+Builder.defineMacro("__nios2");
+Builder.defineMacro("__NIOS2");
+Builder.defineMacro("__nios2__");
+Builder.defineMacro("__NIOS2__");
+  }
+
+  ArrayRef getTargetBuiltins() const override {
+return llvm::makeArrayRef(BuiltinInfo, clang::Nios2::LastTSBuiltin -
+   Builtin::FirstTSBuiltin);
+  }
+
+  bool isFeatureSupportedByCPU(StringRef Feature, StringRef CPU) const {
+const bool isR2 = CPU == "nios2r2";
+return llvm::StringSwitch(Feature)
+.Case("nios2r2mandatory", isR2)
+.Case("nios2r2bmx", isR2)
+.Case("nios2r2mpx", isR2)
+.Case("nios2r2cdx", isR2)
+.Default(false);
+  }
+
+  bool initFeatureMap(llvm::StringMap &Features,
+  DiagnosticsEngine &Diags, StringRef CPU,
+  const std::vector &FeatureVec) const override {
+static const char *allFeatures[] = {
+  "nios2r2mandatory", "nios2r2bmx", "nios2r2mpx", "nios2r2cdx"
+};
+for (const char *feature : allFeatures) {
+Features[feature] = isFeatureSupportedByCPU(feature, CPU);
+}
+return true;
+  }
+
+  bool hasFeature(StringRef Feature) const override {
+  return isFeatureSupportedByCPU(Feature, CPU);
+  }
+
+  BuiltinVaListKind getBuiltinVaListKind() const override {
+return TargetInfo::VoidPtrBuiltinVaList;
+  }
+
+  ArrayRef getGCCRegNames() const override {
+static const char *const GCCRegNames[] = {
+// CPU register names
+// Must match second column of GCCRegAliases
+"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+"r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20",
+"r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30",
+"r31",
+// Floating point register names
+"ctl0", "ctl1", "ctl2", "ctl3", "ctl4", "ctl5", "ctl6", "ctl7", "ctl8",
+"ctl9", "ctl10", "ctl11", "ctl12", "ctl13", "ctl14", "ctl15"};
+ 

[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.

2017-05-24 Thread Simon Schroeder via Phabricator via cfe-commits
schroedersi added a comment.

Ping :)


https://reviews.llvm.org/D30946



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


[PATCH] D33406: PR28129 expand vector oparation to an IR constant.

2017-05-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added subscribers: scanon, andrew.w.kaylor.
spatel added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:7932
   break;
 case X86::BI__builtin_ia32_cmppd256:
   ID = Intrinsic::x86_avx_cmp_pd_256;

dtemirbulatov wrote:
> spatel wrote:
> > 1. Should we handle the 'pd256' version the same way?
> > 2. How about the 0xb ('false') constant? It should produce a zero here?
> > 3. Can or should we deal with the signalling versions (0x1b, 0x1f) too?
> > 
> hm looks like 0xb(_CMP_FALSE_OQ) is ordered, so it is not possible and 0x1b 
> or 0x1f might emit a signal.
I didn't follow this reasoning. 

1. The 0xB compare predicate will return 'false' (all zeros) no matter what the 
inputs are. "Ordered" in this definition is irrelevant; just like "unordered" 
is irrelevant for predicate 0xF (TRUE_UQ). 

It's probably helpful to run the program attached to PR28110 ( 
https://bugs.llvm.org/show_bug.cgi?id=28110 ) to confirm or deny if these 
predicates behave like you expect.

2. Another possibly misleading wording: "non-signaling" does not actually mean 
non-signaling for all values. It means "non-signaling for QNAN, but still 
signaling for SNAN". Therefore, I think we're changing SNAN behavior by folding 
*any* of these preds to constant values. We should've asked this first: is that 
fold allowed in the default FPENV state that we assume that clang is operating 
in? ( cc'ing @andrew.w.kaylor and @scanon for advice)


https://reviews.llvm.org/D33406



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


Re: r303712 - Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

2017-05-24 Thread Argyrios Kyrtzidis via cfe-commits

> On May 24, 2017, at 8:59 AM, Aaron Ballman  wrote:
> 
> On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>> Author: akirtzidis
>> Date: Tue May 23 19:46:27 2017
>> New Revision: 303712
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=303712&view=rev
>> Log:
>> Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods 
>> and properties as well
>> 
>> This is an initial commit to allow using it with constant expressions, a 
>> follow-up commit will enable full support for it in ObjC methods.
>> 
>> Added:
>>cfe/trunk/test/SemaObjC/diagnose_if.m
>> Modified:
>>cfe/trunk/include/clang/Basic/Attr.td
>>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>cfe/trunk/include/clang/Sema/AttributeList.h
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>cfe/trunk/lib/Sema/SemaExpr.cpp
>>cfe/trunk/lib/Sema/SemaOverload.cpp
>>cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>> 
>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> +++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017
>> @@ -149,6 +149,9 @@ class ExprArgument> class FunctionArgument : 
>> Argument>   
>> opt,
>>   
>> fake>;
>> +class NamedArgument : Argument> +  
>> opt,
>> +  
>> fake>;
>> class TypeArgument : Argument;
>> class UnsignedArgument : Argument;
>> class VariadicUnsignedArgument : Argument;
>> @@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {
>> 
>> def DiagnoseIf : InheritableAttr {
>>   let Spellings = [GNU<"diagnose_if">];
>> -  let Subjects = SubjectList<[Function]>;
>> +  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
>>   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
>>   EnumArgument<"DiagnosticType",
>>"DiagnosticType",
>>["error", "warning"],
>>["DT_Error", "DT_Warning"]>,
>>   BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
>> -  FunctionArgument<"Parent", 0, /*fake*/ 1>];
>> +  NamedArgument<"Parent", 0, /*fake*/ 1>];
>>   let DuplicatesAllowedWhileMerging = 1;
>>   let LateParsed = 1;
>>   let AdditionalMembers = [{
>> 
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 19:46:27 
>> 2017
>> @@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War
>>   "|types and namespaces"
>>   "|Objective-C interfaces"
>>   "|methods and properties"
>> +  "|functions, methods and properties"
> 
> functions, methods, and properties (inserting the Oxford comma).

Ok.

> 
>>   "|struct or union"
>>   "|struct, union or class"
>>   "|types"
>> 
>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017
>> @@ -915,6 +915,7 @@ enum AttributeDeclKind {
>>   ExpectedTypeOrNamespace,
>>   ExpectedObjectiveCInterface,
>>   ExpectedMethodOrProperty,
>> +  ExpectedFunctionOrMethodOrProperty,
>>   ExpectedStructOrUnion,
>>   ExpectedStructOrUnionOrClass,
>>   ExpectedType,
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 19:46:27 2017
>> @@ -2727,7 +2727,7 @@ public:
>>   /// of a function.
>>   ///
>>   /// Returns true if any errors were emitted.
>> -  bool diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,
>> +  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
>>  

Re: r303712 - Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

2017-05-24 Thread Aaron Ballman via cfe-commits
On Wed, May 24, 2017 at 1:05 PM, Argyrios Kyrtzidis  wrote:
>
>> On May 24, 2017, at 8:59 AM, Aaron Ballman  wrote:
>>
>> On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits
>>  wrote:
>>> Author: akirtzidis
>>> Date: Tue May 23 19:46:27 2017
>>> New Revision: 303712
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=303712&view=rev
>>> Log:
>>> Enhance the 'diagnose_if' attribute so that we can apply it for ObjC 
>>> methods and properties as well
>>>
>>> This is an initial commit to allow using it with constant expressions, a 
>>> follow-up commit will enable full support for it in ObjC methods.
>>>
>>> Added:
>>>cfe/trunk/test/SemaObjC/diagnose_if.m
>>> Modified:
>>>cfe/trunk/include/clang/Basic/Attr.td
>>>cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>>cfe/trunk/include/clang/Sema/AttributeList.h
>>>cfe/trunk/include/clang/Sema/Sema.h
>>>cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>>cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>>cfe/trunk/lib/Sema/SemaExpr.cpp
>>>cfe/trunk/lib/Sema/SemaOverload.cpp
>>>cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>>> +++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017
>>> @@ -149,6 +149,9 @@ class ExprArgument>> class FunctionArgument : 
>>> Argument>>   
>>> opt,
>>>   
>>> fake>;
>>> +class NamedArgument : 
>>> Argument>> +  
>>> opt,
>>> +  
>>> fake>;
>>> class TypeArgument : Argument;
>>> class UnsignedArgument : Argument;
>>> class VariadicUnsignedArgument : Argument;
>>> @@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {
>>>
>>> def DiagnoseIf : InheritableAttr {
>>>   let Spellings = [GNU<"diagnose_if">];
>>> -  let Subjects = SubjectList<[Function]>;
>>> +  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
>>>   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
>>>   EnumArgument<"DiagnosticType",
>>>"DiagnosticType",
>>>["error", "warning"],
>>>["DT_Error", "DT_Warning"]>,
>>>   BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
>>> -  FunctionArgument<"Parent", 0, /*fake*/ 1>];
>>> +  NamedArgument<"Parent", 0, /*fake*/ 1>];
>>>   let DuplicatesAllowedWhileMerging = 1;
>>>   let LateParsed = 1;
>>>   let AdditionalMembers = [{
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 
>>> 19:46:27 2017
>>> @@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War
>>>   "|types and namespaces"
>>>   "|Objective-C interfaces"
>>>   "|methods and properties"
>>> +  "|functions, methods and properties"
>>
>> functions, methods, and properties (inserting the Oxford comma).
>
> Ok.
>
>>
>>>   "|struct or union"
>>>   "|struct, union or class"
>>>   "|types"
>>>
>>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017
>>> @@ -915,6 +915,7 @@ enum AttributeDeclKind {
>>>   ExpectedTypeOrNamespace,
>>>   ExpectedObjectiveCInterface,
>>>   ExpectedMethodOrProperty,
>>> +  ExpectedFunctionOrMethodOrProperty,
>>>   ExpectedStructOrUnion,
>>>   ExpectedStructOrUnionOrClass,
>>>   ExpectedType,
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 19:46:27 2017
>>> @@ -2727,7 +2727,7 @@ public:
>>>   /// of a function.
>>>   ///
>>>   /// Returns true if any errors were emitted.
>>> -  bool di

[PATCH] D33497: clang-tidy check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


https://reviews.llvm.org/D33497



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


[PATCH] D33470: [clang-tidy] Add misc-default-numerics

2017-05-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/DefaultNumericsCheck.cpp:37
+void DefaultNumericsCheck::check(const MatchFinder::MatchResult &Result) {
+
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("call");

Can remove the spurious newline.



Comment at: clang-tidy/misc/DefaultNumericsCheck.cpp:41
+  diag(MatchedDecl->getLocStart(),
+   "called std::numeric_limit method on not specialized type");
+}

This diagnostic doesn't tell the user what's wrong with their code. I think 
something along these lines might be better:

`'std::numeric_limits::%select{max|min}0' called with type %1; no such 
specialization exists, so the default value for that type is returned`



Comment at: clang-tidy/misc/DefaultNumericsCheck.h:20
+/// This check flags usages of ``std::numeric_limits::{min,max}()`` for
+/// unspecialized types. It is dangerous because returns T(), which might is
+/// rarely minimum or maximum for this type.

because returns -> because it returns



Comment at: docs/clang-tidy/checks/misc-default-numerics.rst:7
+This check flags usages of ``std::numeric_limits::{min,max}()`` for
+unspecialized types. It is dangerous because returns T(), which might is rarely
+minimum or maximum for this type.

because returns... -> because the calls return ''T()'' in this case, which is 
unlikely to represent the minimum or maximum value for the type.



Comment at: docs/clang-tidy/checks/misc-default-numerics.rst:19
+
+
+  // 3. Replace the BigInt typedef with class implementing BigIntegers

Remove spurious newline



Comment at: docs/clang-tidy/checks/misc-default-numerics.rst:24
+  // 4. Your code compiles silently and you a few years later you find an
+  // of by 9223372036854775808 error.

Is this meant to say "off by X error"? I think a better wording would be that 
the code continues to compile, but the call to `min()` returns `BigInt{}`, or 
something more explicit.


https://reviews.llvm.org/D33470



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


Re: r303712 - Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

2017-05-24 Thread Argyrios Kyrtzidis via cfe-commits

> On May 24, 2017, at 10:12 AM, Aaron Ballman  wrote:
> 
> On Wed, May 24, 2017 at 1:05 PM, Argyrios Kyrtzidis  > wrote:
>> 
>>> On May 24, 2017, at 8:59 AM, Aaron Ballman  wrote:
>>> 
>>> On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits
>>>  wrote:
 Author: akirtzidis
 Date: Tue May 23 19:46:27 2017
 New Revision: 303712
 
 URL: http://llvm.org/viewvc/llvm-project?rev=303712&view=rev
 Log:
 Enhance the 'diagnose_if' attribute so that we can apply it for ObjC 
 methods and properties as well
 
 This is an initial commit to allow using it with constant expressions, a 
 follow-up commit will enable full support for it in ObjC methods.
 
 Added:
   cfe/trunk/test/SemaObjC/diagnose_if.m
 Modified:
   cfe/trunk/include/clang/Basic/Attr.td
   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
   cfe/trunk/include/clang/Sema/AttributeList.h
   cfe/trunk/include/clang/Sema/Sema.h
   cfe/trunk/lib/Lex/PPMacroExpansion.cpp
   cfe/trunk/lib/Sema/SemaDeclAttr.cpp
   cfe/trunk/lib/Sema/SemaExpr.cpp
   cfe/trunk/lib/Sema/SemaOverload.cpp
   cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
 
 Modified: cfe/trunk/include/clang/Basic/Attr.td
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff
 ==
 --- cfe/trunk/include/clang/Basic/Attr.td (original)
 +++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017
 @@ -149,6 +149,9 @@ class ExprArgument>>> class FunctionArgument : 
 Argument>>>  
 opt,
  
 fake>;
 +class NamedArgument : 
 Argument>>> +  
 opt,
 +  
 fake>;
 class TypeArgument : Argument;
 class UnsignedArgument : Argument;
 class VariadicUnsignedArgument : Argument;
 @@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {
 
 def DiagnoseIf : InheritableAttr {
  let Spellings = [GNU<"diagnose_if">];
 -  let Subjects = SubjectList<[Function]>;
 +  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
  let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
  EnumArgument<"DiagnosticType",
   "DiagnosticType",
   ["error", "warning"],
   ["DT_Error", "DT_Warning"]>,
  BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
 -  FunctionArgument<"Parent", 0, /*fake*/ 1>];
 +  NamedArgument<"Parent", 0, /*fake*/ 1>];
  let DuplicatesAllowedWhileMerging = 1;
  let LateParsed = 1;
  let AdditionalMembers = [{
 
 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff
 ==
 --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
 +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 
 19:46:27 2017
 @@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War
  "|types and namespaces"
  "|Objective-C interfaces"
  "|methods and properties"
 +  "|functions, methods and properties"
>>> 
>>> functions, methods, and properties (inserting the Oxford comma).
>> 
>> Ok.
>> 
>>> 
  "|struct or union"
  "|struct, union or class"
  "|types"
 
 Modified: cfe/trunk/include/clang/Sema/AttributeList.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff
 ==
 --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
 +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017
 @@ -915,6 +915,7 @@ enum AttributeDeclKind {
  ExpectedTypeOrNamespace,
  ExpectedObjectiveCInterface,
  ExpectedMethodOrProperty,
 +  ExpectedFunctionOrMethodOrProperty,
  ExpectedStructOrUnion,
  ExpectedStructOrUnionOrClass,
  ExpectedType,
 
 Modified: cfe/trunk/include/clang/Sema/Sema.h
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff
 ==
 --- cfe/trunk/include/clang/Sema/Sema.h (original)
 +++ cfe/trunk/incl

[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 100131.
jroelofs added a comment.

implement feedback


https://reviews.llvm.org/D33259

Files:
  cmake/caches/BaremetalARM.cmake
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/BareMetal.cpp
  lib/Driver/ToolChains/BareMetal.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/Inputs/baremetal_arm/include/c++/5.0.0/.keep
  test/Driver/Inputs/baremetal_arm/include/c++/6.0.0/.keep
  test/Driver/Inputs/baremetal_arm/include/c++/v1/.keep
  test/Driver/baremetal.cpp

Index: test/Driver/baremetal.cpp
===
--- /dev/null
+++ test/Driver/baremetal.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -T semihosted.lds \
+// RUN: -L some/directory/user/asked/for \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
+// CHECK-V6M-C: "[[PREFIX_DIR:.*]]/bin/clang" "-cc1" "-triple" "thumbv6m-none--eabi"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]/lib/clang/[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]/include/c++/v1"
+// CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]/include"
+// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-V6M-C-NEXT: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]/lib/clang/[[VERSION]]/lib/baremetal"
+// CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome/directory/user/asked/for"
+// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -nostdlibinc -nobuiltininc \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: -nostdinc \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
+// CHECK-V6M-LIBINC-NOT: "-internal-isystem"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
+// CHECK-V6M-DEFAULTCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-DEFAULTCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX %s
+// CHECK-V6M-LIBCXX-NOT: "-internal-isystem" "{{[^"]+}}/include/c++/{{[^v].*}}"
+// CHECK-V6M-LIBCXX: "-internal-isystem" "{{[^"]+}}/include/c++/v1"
+// CHECK-V6M-LIBCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -stdlib=libstdc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBSTDCXX %s
+// CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" "{{[^"]+}}/include/c++/v1"
+// CHECK-V6M-LIBSTDCXX: "-internal-isystem" "{{[^"]+}}/include/c++/6.0.0"
+// CHECK-V6M-LIBSTDCXX: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBSTDCXX-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
+// CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
+// CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -nodefaultlibs \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
+// CHECK-V6M-NDL: "[[PREFIX_DIR:.*]]/bin/ld.lld" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-NDL-SAME: "-L[[PREFIX_DIR]]/lib/clang/{{.*}}/lib/baremetal" "-o" "{{.*}}.o"
+
+// RUN: %clangxx -target arm-none-eabi -v 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
+// CHECK-THREAD-MODEL: Thread model: single
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Lin

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-24 Thread Michael Park via Phabricator via cfe-commits
mpark added a comment.

Yes, you're right that fine-grained SMF triviality is implemented but LWG 2904 
is not yet.
I would love it if you can integrate the currently `libcxx` tests into `std` 
tests!

Thank you :)


https://reviews.llvm.org/D32671



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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-05-24 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked 2 inline comments as done.
jroelofs added inline comments.



Comment at: lib/Driver/ToolChains/BareMetal.cpp:110
+  SmallString<128> Dir(SysRoot);
+  llvm::sys::path::append(Dir, "include", "c++", "v1");
+  return Dir.str();

compnerd wrote:
> Is this layout consistent between libc++ and libstdc++?
Damn, no it's not.



Comment at: lib/Driver/ToolChains/BareMetal.cpp:130-133
+if (Value == "libc++")
+  return ToolChain::CST_Libcxx;
+else if (Value == "libstdc++")
+  return ToolChain::CST_Libstdcxx;

compnerd wrote:
> Use `StringSwitch`?
`StringSwitch` isn't great when you want to error out of the default case. That 
being said, this whole function is unnecessary: I can just defer to the base 
class' implementation, which does almost the same thing.



Comment at: lib/Driver/ToolChains/BareMetal.h:39
+  bool isPICDefaultForced() const override { return false; }
+  bool SupportsProfiling() const override { return true; }
+  bool SupportsObjCGC() const override { return false; }

compnerd wrote:
> Is the profiler support in compiler-rt sufficiently standalone to build it 
> for baremetal?
IIRC, there was a test case that wanted this on for one of the arm-none-eabi 
triples. This is when my patches were against 4.0. After rebasing to trunk, I 
think that particular test is gone (split up into separate ones, I guess?).

I'll leave it off for now until someone confirms it is actually supported.



Comment at: lib/Driver/ToolChains/Linux.cpp:379
-/*static*/
-Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
-  const GCCVersion BadVersion = {VersionText.str(), -1, -1, -1, "", "", ""};

Noticed that this was in the wrong place, and also, surprisingly, that it was 
incorrectly qualified.


https://reviews.llvm.org/D33259



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


[PATCH] D33448: [CodeGen] Add thumb-mode to function target-features for arm/thumb triples.

2017-05-24 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D33448#763411, @fhahn wrote:

> In https://reviews.llvm.org/D33448#762410, @echristo wrote:
>
> > I probably would have added this as a feature in ARMTargetInfo similar to 
> > CRC/soft-float/etc.
> >
> > Thoughts?
>
>
> Do you mean ARMTargetMachine::getSubtargetImpl 
> (https://github.com/llvm-mirror/llvm/blob/master/lib/Target/ARM/ARMTargetMachine.cpp#L305)
>  ?
>
> It seems like that function is only used by llc (and not llvm-as for example) 
> and at that stage it is too late to add thumb-mode, because llc operates on a 
> single module with a single target triple.


No, I meant somewhere around here: 
https://github.com/llvm-mirror/clang/blob/master/lib/Basic/Targets.cpp#L5058 to 
define it and then in CGCall.cpp it'll get added along with the other 
target-features.

I think that'll enable you to handle -mthumb and -target in a fairly unified 
way?


https://reviews.llvm.org/D33448



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


[PATCH] D33507: [coroutines] Add support for coroutines with non-scalar parameters

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

Simple types like int are handled by LLVM Coroutines just fine.
But for non-scalar parameters we need to create copies of those parameters in 
the coroutine frame and make all uses of those parameters to refer to parameter 
copies.


https://reviews.llvm.org/D33507

Files:
  lib/CodeGen/CGCoroutine.cpp
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-params.cpp

Index: test/CodeGenCoroutines/coro-params.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-params.cpp
@@ -0,0 +1,95 @@
+// Verifies that parameters are copied with move constructors
+// Verifies that parameter copies are destroyed
+// Vefifies that parameter copies are used in the body of the coroutine
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -disable-llvm-passes -fexceptions | FileCheck %s
+
+namespace std::experimental {
+template  struct coroutine_traits;
+
+template  struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template  struct std::experimental::coroutine_traits {
+  struct promise_type {
+void get_return_object() noexcept;
+suspend_always initial_suspend() noexcept;
+suspend_always final_suspend() noexcept;
+void return_void() noexcept;
+promise_type();
+~promise_type() noexcept;
+void unhandled_exception() noexcept;
+  };
+};
+
+// TODO: Not supported yet
+struct CopyOnly {
+  int val;
+  CopyOnly(const CopyOnly&) noexcept;
+  CopyOnly(CopyOnly&&) = delete;
+  ~CopyOnly();
+};
+
+struct MoveOnly {
+  int val;
+  MoveOnly(const MoveOnly&) = delete;
+  MoveOnly(MoveOnly&&) noexcept;
+  ~MoveOnly();
+};
+
+struct MoveAndCopy {
+  int val;
+  MoveAndCopy(const MoveAndCopy&)noexcept;
+  MoveAndCopy(MoveAndCopy&&) noexcept;
+  ~MoveAndCopy();
+};
+
+void consume(int,int,int) noexcept;
+
+// TODO: Add support for CopyOnly params
+// CHECK: define void @_Z1fi8MoveOnly11MoveAndCopy(i32 %val, %struct.MoveOnly* %[[MoParam:.+]], %struct.MoveAndCopy* %[[McParam:.+]]) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*
+void f(int val, MoveOnly moParam, MoveAndCopy mcParam) {
+  // CHECK: %[[MoCopy:.+]] = alloca %struct.MoveOnly
+  // CHECK: %[[McCopy:.+]] = alloca %struct.MoveAndCopy
+  // CHECK: store i32 %val, i32* %[[ValAddr:.+]]
+
+  // CHECK: call i8* @llvm.coro.begin(
+  // CHECK-NEXT: call void @_ZN8MoveOnlyC1EOS_(%struct.MoveOnly* %[[MoCopy]], %struct.MoveOnly* dereferenceable(4) %[[MoParam]])
+  // CHECK-NEXT: call void @_ZN11MoveAndCopyC1EOS_(%struct.MoveAndCopy* %[[McCopy]], %struct.MoveAndCopy* dereferenceable(4) %[[McParam]]) #
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_typeC1Ev(
+
+  // CHECK: call void @_ZN14suspend_always12await_resumeEv(
+  // CHECK: %[[IntParam:.+]] = load i32, i32* %val.addr
+  // CHECK: %[[MoGep:.+]] = getelementptr inbounds %struct.MoveOnly, %struct.MoveOnly* %[[MoCopy]], i32 0, i32 0
+  // CHECK: %[[MoVal:.+]] = load i32, i32* %[[MoGep]]
+  // CHECK: %[[McGep:.+]] =  getelementptr inbounds %struct.MoveAndCopy, %struct.MoveAndCopy* %[[McCopy]], i32 0, i32 0
+  // CHECK: %[[McVal:.+]] = load i32, i32* %[[McGep]]
+  // CHECK: call void @_Z7consumeiii(i32 %[[IntParam]], i32 %[[MoVal]], i32 %[[McVal]])
+
+  consume(val, moParam.val, mcParam.val);
+  co_return;
+
+  // Skip to final suspend:
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_type13final_suspendEv(
+  // CHECK: call void @_ZN14suspend_always12await_resumeEv(
+
+  // Destroy promise, then parameter copies:
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_typeD1Ev(%"struct.std::experimental::coroutine_traits::promise_type"* %__promise) #2
+  // CHECK-NEXT: call void @_ZN11MoveAndCopyD1Ev(%struct.MoveAndCopy* %[[McCopy]])
+  // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]]
+  // CHECK-NEXT: call i8* @llvm.coro.free(
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -1160,8 +1160,68 @@
   return true;
 }
 
+// Create a static_cast\(expr).
+static Expr *castForMoving(Sema &S, Expr *E, QualType T = QualType()) {
+  if (T.isNull())
+T = E->getType();
+  QualType TargetType = S.BuildReferenceType(
+  T, /*SpelledAsLValue*/ false, SourceLocation(), DeclarationName());
+  SourceLocation ExprLoc = E->getLocStart

Re: r303712 - Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods and properties as well

2017-05-24 Thread Aaron Ballman via cfe-commits
On Wed, May 24, 2017 at 1:37 PM, Argyrios Kyrtzidis  wrote:
>
> On May 24, 2017, at 10:12 AM, Aaron Ballman  wrote:
>
> On Wed, May 24, 2017 at 1:05 PM, Argyrios Kyrtzidis 
> wrote:
>
>
> On May 24, 2017, at 8:59 AM, Aaron Ballman  wrote:
>
> On Tue, May 23, 2017 at 8:46 PM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>
> Author: akirtzidis
> Date: Tue May 23 19:46:27 2017
> New Revision: 303712
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303712&view=rev
> Log:
> Enhance the 'diagnose_if' attribute so that we can apply it for ObjC methods
> and properties as well
>
> This is an initial commit to allow using it with constant expressions, a
> follow-up commit will enable full support for it in ObjC methods.
>
> Added:
>   cfe/trunk/test/SemaObjC/diagnose_if.m
> Modified:
>   cfe/trunk/include/clang/Basic/Attr.td
>   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>   cfe/trunk/include/clang/Sema/AttributeList.h
>   cfe/trunk/include/clang/Sema/Sema.h
>   cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>   cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>   cfe/trunk/lib/Sema/SemaExpr.cpp
>   cfe/trunk/lib/Sema/SemaOverload.cpp
>   cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue May 23 19:46:27 2017
> @@ -149,6 +149,9 @@ class ExprArgument class FunctionArgument :
> Argument
> opt,
>
> fake>;
> +class NamedArgument :
> Argument +
> opt,
> +
> fake>;
> class TypeArgument : Argument;
> class UnsignedArgument : Argument;
> class VariadicUnsignedArgument : Argument;
> @@ -1819,14 +1822,14 @@ def Unavailable : InheritableAttr {
>
> def DiagnoseIf : InheritableAttr {
>  let Spellings = [GNU<"diagnose_if">];
> -  let Subjects = SubjectList<[Function]>;
> +  let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
>  let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
>  EnumArgument<"DiagnosticType",
>   "DiagnosticType",
>   ["error", "warning"],
>   ["DT_Error", "DT_Warning"]>,
>  BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
> -  FunctionArgument<"Parent", 0, /*fake*/ 1>];
> +  NamedArgument<"Parent", 0, /*fake*/ 1>];
>  let DuplicatesAllowedWhileMerging = 1;
>  let LateParsed = 1;
>  let AdditionalMembers = [{
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 23 19:46:27
> 2017
> @@ -2771,6 +2771,7 @@ def warn_attribute_wrong_decl_type : War
>  "|types and namespaces"
>  "|Objective-C interfaces"
>  "|methods and properties"
> +  "|functions, methods and properties"
>
>
> functions, methods, and properties (inserting the Oxford comma).
>
>
> Ok.
>
>
>  "|struct or union"
>  "|struct, union or class"
>  "|types"
>
> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
> +++ cfe/trunk/include/clang/Sema/AttributeList.h Tue May 23 19:46:27 2017
> @@ -915,6 +915,7 @@ enum AttributeDeclKind {
>  ExpectedTypeOrNamespace,
>  ExpectedObjectiveCInterface,
>  ExpectedMethodOrProperty,
> +  ExpectedFunctionOrMethodOrProperty,
>  ExpectedStructOrUnion,
>  ExpectedStructOrUnionOrClass,
>  ExpectedType,
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=303712&r1=303711&r2=303712&view=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue May 23 19:46:27 2017
> @@ -2727,7 +2727,7 @@ public:
>  /// of a function.
>  ///
>  /// Returns true if any errors were emitted.
> -  bool diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,
> +  bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
> SourceLocation Loc);
>
>  /// Returns whether the given function's address can be taken or not,
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=303712&r1=30371

Re: r303630 - Allow to use vfs::FileSystem for file accesses inside ASTUnit.

2017-05-24 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, May 24, 2017 at 12:18 AM, Ilya Biryukov  wrote:
> We test it in clangd (https://reviews.llvm.org/D33416).
> Logically, it's  a single change, split into two part: for cfe and
> clang-tools-extra.

I see, thanks!

>
> On Wed, May 24, 2017 at 1:48 AM, Bruno Cardoso Lopes
>  wrote:
>>
>> Any specific reason why this doesn't contain a testcase?
>>
>> On Tue, May 23, 2017 at 4:37 AM, Ilya Biryukov via cfe-commits
>>  wrote:
>> > Author: ibiryukov
>> > Date: Tue May 23 06:37:52 2017
>> > New Revision: 303630
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=303630&view=rev
>> > Log:
>> > Allow to use vfs::FileSystem for file accesses inside ASTUnit.
>> >
>> > Reviewers: bkramer, krasimir, arphaman, akyrtzi
>> >
>> > Reviewed By: bkramer
>> >
>> > Subscribers: klimek, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D33397
>> >
>> > Modified:
>> > cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > cfe/trunk/include/clang/Frontend/CompilerInvocation.h
>> > cfe/trunk/lib/Frontend/ASTUnit.cpp
>> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=303630&r1=303629&r2=303630&view=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
>> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 23 06:37:52 2017
>> > @@ -59,6 +59,10 @@ class TargetInfo;
>> >  class FrontendAction;
>> >  class ASTDeserializationListener;
>> >
>> > +namespace vfs {
>> > +class FileSystem;
>> > +}
>> > +
>> >  /// \brief Utility class for loading a ASTContext from an AST file.
>> >  ///
>> >  class ASTUnit : public ModuleLoader {
>> > @@ -420,7 +424,8 @@ private:
>> >explicit ASTUnit(bool MainFileIsAST);
>> >
>> >bool Parse(std::shared_ptr PCHContainerOps,
>> > - std::unique_ptr OverrideMainBuffer);
>> > + std::unique_ptr OverrideMainBuffer,
>> > + IntrusiveRefCntPtr VFS);
>> >
>> >struct ComputedPreamble {
>> >  llvm::MemoryBuffer *Buffer;
>> > @@ -434,11 +439,13 @@ private:
>> >PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
>> >};
>> >ComputedPreamble ComputePreamble(CompilerInvocation &Invocation,
>> > -   unsigned MaxLines);
>> > +   unsigned MaxLines,
>> > +   IntrusiveRefCntPtr
>> > VFS);
>> >
>> >std::unique_ptr
>> > getMainBufferWithPrecompiledPreamble(
>> >std::shared_ptr PCHContainerOps,
>> > -  const CompilerInvocation &PreambleInvocationIn, bool AllowRebuild
>> > = true,
>> > +  const CompilerInvocation &PreambleInvocationIn,
>> > +  IntrusiveRefCntPtr VFS, bool AllowRebuild =
>> > true,
>> >unsigned MaxLines = 0);
>> >void RealizeTopLevelDeclsFromPreamble();
>> >
>> > @@ -731,11 +738,17 @@ private:
>> >/// of this translation unit should be precompiled, to improve the
>> > performance
>> >/// of reparsing. Set to zero to disable preambles.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem).
>> > +  ///
>> >/// \returns \c true if a catastrophic failure occurred (which means
>> > that the
>> >/// \c ASTUnit itself is invalid), or \c false otherwise.
>> >bool LoadFromCompilerInvocation(
>> >std::shared_ptr PCHContainerOps,
>> > -  unsigned PrecompilePreambleAfterNParses);
>> > +  unsigned PrecompilePreambleAfterNParses,
>> > +  IntrusiveRefCntPtr VFS);
>> >
>> >  public:
>> >
>> > @@ -826,6 +839,11 @@ public:
>> >/// (e.g. because the PCH could not be loaded), this accepts the
>> > ASTUnit
>> >/// mainly to allow the caller to see the diagnostics.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem). RealFileSystem will be used if \p
>> > VFS is nullptr.
>> > +  ///
>> >// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the
>> > ASTUnit, we
>> >// shouldn't need to specify them at construction time.
>> >static ASTUnit *LoadFromCommandLine(
>> > @@ -842,15 +860,23 @@ public:
>> >bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies
>> > = false,
>> >bool UserFilesAreVolatile = false, bool ForSerialization = false,
>> >llvm::Optional ModuleFormat = llvm::None,
>> > -  std::un

r303786 - Fix one test case faiulre in commit 303766.

2017-05-24 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Wed May 24 13:12:11 2017
New Revision: 303786

URL: http://llvm.org/viewvc/llvm-project?rev=303786&view=rev
Log:
Fix one test case faiulre in commit 303766.

It is clean when I build boostrap and run make checkall on my machine, I guess
it could be I only build bootstrap with assert, while the buildbots may build
without asserts, which could cause the difference.

Modified:
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-vsx.c?rev=303786&r1=303785&r2=303786&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-vsx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-vsx.c Wed May 24 13:12:11 2017
@@ -1793,13 +1793,13 @@ vector int xxpermdi_should_not_assert(ve
 vector double xxsldwi_should_not_assert(vector double a, vector double b) {
   return vec_xxsldwi(a, b, 0);
 // CHECK-LABEL: xxsldwi_should_not_assert
-// CHECK:  bitcast <2 x double> %0 to <4 x i32>
-// CHECK-NEXT:  bitcast <2 x double> %1 to <4 x i32>
-// CHECK-NEXT:  shufflevector <4 x i32> %2, <4 x i32> %3, <4 x i32> 
-// CHECK-NEXT:  bitcast <4 x i32> %4 to <2 x double>
+// CHECK:  bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
+// CHECK-NEXT:  bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
+// CHECK-NEXT:  shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 
x i32> 
+// CHECK-NEXT:  bitcast <4 x i32> %{{[0-9]+}} to <2 x double>
 
-// CHECK-LE:  bitcast <2 x double> %0 to <4 x i32>
-// CHECK-NEXT-LE:  bitcast <2 x double> %1 to <4 x i32>
-// CHECK-NEXT-LE:  shufflevector <4 x i32> %2, <4 x i32> %3, <4 x i32> 
-// CHECK-NEXT-LE:  bitcast <4 x i32> %4 to <2 x double>
+// CHECK-LE:  bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
+// CHECK-NEXT-LE:  bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
+// CHECK-NEXT-LE:  shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, 
<4 x i32> 
+// CHECK-NEXT-LE:  bitcast <4 x i32> %{{[0-9]+}} to <2 x double>
 }


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


[PATCH] D33328: [CodeGen] Pessimize aliasing for union members (and may-alias) objects

2017-05-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:1436
+if (BaseInfo.getMayAlias())
+  TBAAInfo = CGM.getTBAAInfo(getContext().CharTy);
 llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,

kparzysz wrote:
> rjmccall wrote:
> > kparzysz wrote:
> > > rjmccall wrote:
> > > > Hmm.  Should we be constructing a struct-path TBAA at all if the base 
> > > > may alias, as opposed to just using 'char'?
> > > I did that and got a verifier error: "Old-style TBAA is no longer 
> > > allowed, use struct-path TBAA instead. fatal error: error in backend: 
> > > Broken function found, compilation aborted!"
> > Oh, I haven't been paying enough attention to LLVM's TBAA changes.  It 
> > looks like they've canonicalized on always using the struct-access-style 
> > TBAA metadata, which is fine; the point is that we should be using whatever 
> > tag we would use for dereferencing a simple char*, which I believe just 
> > means passing true for ConvertTypeToTag to DecorateInstructionWithTBAA .
> With that change I'm getting another error:
> 
> ```
> Access type node must be a valid scalar type
>   store <4 x double> %call2, <4 x double>* %b, align 32, !tbaa !8
> !8 = !{!9, !9, i64 0}
> !9 = !{!4, !4, i64 0}
> fatal error: error in backend: Broken function found, compilation aborted!
> ```
> 
Sorry, I see now that what I said was unclear.  If you do this, you need to 
pass the result of getTBAAInfo(CharTy) down as the argument to 
DecorateInstructionWithTBAA instead of building of a TBAA struct tag.


Repository:
  rL LLVM

https://reviews.llvm.org/D33328



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


r303789 - Address follow-up feedback for r303712

2017-05-24 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Wed May 24 13:35:01 2017
New Revision: 303789

URL: http://llvm.org/viewvc/llvm-project?rev=303789&view=rev
Log:
Address follow-up feedback for r303712

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303789&r1=303788&r2=303789&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 24 13:35:01 
2017
@@ -2771,7 +2771,7 @@ def warn_attribute_wrong_decl_type : War
   "|types and namespaces"
   "|Objective-C interfaces"
   "|methods and properties"
-  "|functions, methods and properties"
+  "|functions, methods, and properties"
   "|struct or union"
   "|struct, union or class"
   "|types"

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=303789&r1=303788&r2=303789&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed May 24 13:35:01 2017
@@ -1038,7 +1038,7 @@ static void handleDiagnoseIfAttr(Sema &S
   }
 
   bool ArgDependent = false;
-  if (auto *FD = dyn_cast(D))
+  if (const auto *FD = dyn_cast(D))
 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
   D->addAttr(::new (S.Context) DiagnoseIfAttr(
   Attr.getRange(), S.Context, Cond, Msg, DiagType, ArgDependent, 
cast(D),

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303789&r1=303788&r2=303789&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed May 24 13:35:01 2017
@@ -370,15 +370,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *
 
   auto getReferencedObjCProp = [](const NamedDecl *D) ->
   const ObjCPropertyDecl * {
-if (auto *MD = dyn_cast(D))
+if (const auto *MD = dyn_cast(D))
   return MD->findPropertyDecl();
 return nullptr;
   };
-  if (auto *ObjCPDecl = getReferencedObjCProp(D)) {
+  if (const ObjCPropertyDecl *ObjCPDecl = getReferencedObjCProp(D)) {
 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
   return true;
-  } else {
-if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc))
+  } else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
   return true;
   }
 


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


[PATCH] D33304: [WIP][clang-tidy] Add a new module Android and a new check for file descriptors.

2017-05-24 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It's also necessary to mention new checks group in docs/clang-tidy/index.rst.


Repository:
  rL LLVM

https://reviews.llvm.org/D33304



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


[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL

2017-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12449
   // function declaration is going to be treated as an error.
-  if (Diags.getDiagnosticLevel(diag_id, Loc) >= DiagnosticsEngine::Error) {
+  if (!getLangOpts().OpenCL &&
+  Diags.getDiagnosticLevel(diag_id, Loc) >= DiagnosticsEngine::Error) {

echuraev wrote:
> Anastasia wrote:
> > This way prevents the typo corrections completely for OpenCL which is not 
> > very desirable. I was just wondering could we prevent adding the invalid 
> > builtin function identifiers instead to the correction candidate list.
> > 
> > Like when `work_group_reserve_read_pipe` was first parsed it shouldn't have 
> > been added to the list of valid function identifiers to appear in the 
> > corrections of  'work_group_reserve_write_pipe'. I am guessing the 
> > identifier might be added when builtins are initialized...
> Yes, sorry, I didn't think about it. I investigated the question how can I 
> remove invalid functions from correction candidate list. But I have a problem 
> and I hope that you will be able to help me.
> 
> I found that the correction is added in function `void 
> TypoCorrectionConsumer::addName` (in file //SemaLookup.cpp//) which called 
> from loop in function `std::unique_ptr 
> Sema::makeTypoCorrectionConsumer`. The loop you can see below:
> 
> ```
> // For unqualified lookup, look through all of the names that we have   
> // seen in this translation unit.   
> // FIXME: Re-add the ability to skip very unlikely potential corrections.   
> for (const auto &I : Context.Idents)
>   Consumer->FoundName(I.getKey());
> ```
> 
> But the map `Context.Idents` already contains names of implicit functions. 
> So, I found that names of functions were added to this dictionary during 
> parsing AST. After calling `ConsumeToken()` function in `void 
> Parser::ParseDeclarationSpecifiers` (in file //ParseDecl.cpp//) implicit 
> functions were added to the dictionary. But in this function I'm not able to 
> check is the OpenCL function implicit declared or not. 
> 
> As a result I tried to remove names of implicit functions before calling 
> `CorrectTypo`. But unfortunately, we don't have an API for removing items 
> from `Context.Idents`. So, I don't know the good way for fixing these 
> diagnostic messages. Could you help me please? Do you have any suggestions?
> 
> Thank you in advance!
> 
Thanks for looking at this!

It seems like we are adding the identifiers to the map too early. So we could:
(a) postpose adding items into `Context.Idents` to `Sema`.
(b) extend `IdentifierTable` interface to support removing items (although it 
might not align well with the general concept).

Although (b) feels more natural way conceptually, it might require bigger 
changes than (a).

Both need discussion in `cfe-dev` to continue, so it should be addressed in 
isolation. If you undo the last change, I am happy to approve the review.


https://reviews.llvm.org/D31745



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


[PATCH] D33328: [CodeGen] Pessimize aliasing for union members (and may-alias) objects

2017-05-24 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz updated this revision to Diff 100142.
kparzysz added a comment.

Pass char TBAA directly to DecorateInstructionWithTBAA and pass true for 
ConvertTypeToTag in such cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D33328

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/union-tbaa1.c
  test/CodeGenCXX/union-tbaa2.cpp

Index: test/CodeGenCXX/union-tbaa2.cpp
===
--- /dev/null
+++ test/CodeGenCXX/union-tbaa2.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -O2 -std=c++11 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Testcase from llvm.org/PR32056
+
+extern "C" int printf (const char *__restrict __format, ...);
+
+typedef double __m256d __attribute__((__vector_size__(32)));
+
+static __inline __m256d __attribute__((__always_inline__, __nodebug__,
+   __target__("avx")))
+_mm256_setr_pd(double __a, double __b, double __c, double __d) {
+  return (__m256d){ __a, __b, __c, __d };
+}
+
+struct A {
+  A () {
+// Check that the TBAA information generated for the stores to the
+// union members is based on the omnipotent char.
+// CHECK: store <4 x double>
+// CHECK: tbaa ![[OCPATH:[0-9]+]]
+// CHECK: store <4 x double>
+// CHECK: tbaa ![[OCPATH]]
+// CHECK: call
+a = _mm256_setr_pd(0.0, 1.0, 2.0, 3.0);
+b = _mm256_setr_pd(4.0, 5.0, 6.0, 7.0);
+  }
+
+  const double *begin() { return c; }
+  const double *end() { return c+8; }
+
+  union {
+struct { __m256d a, b; };
+double c[8];
+  };
+};
+
+int main(int argc, char *argv[]) {
+  A a;
+  for (double value : a)
+printf("%f ", value);
+  return 0;
+}
+
+// CHECK-DAG: ![[CHAR:[0-9]+]] = !{!"omnipotent char"
+// CHECK-DAG: ![[OCPATH]] = !{![[CHAR]], ![[CHAR]], i64 0}
Index: test/CodeGen/union-tbaa1.c
===
--- /dev/null
+++ test/CodeGen/union-tbaa1.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple hexagon-unknown-elf -O2 -emit-llvm -o - | FileCheck %s
+
+typedef union __attribute__((aligned(4))) {
+  unsigned short uh[2];
+  unsigned uw;
+} vect32;
+
+void bar(vect32 p[][2]);
+
+// CHECK-LABEL: define void @fred
+void fred(unsigned Num, int Vec[2], int *Index, int Arr[4][2]) {
+  vect32 Tmp[4][2];
+// Generate tbaa for the load of Index:
+// CHECK: load i32, i32* %Index{{.*}}tbaa
+// But no tbaa for the two stores:
+// CHECK: %uw[[UW1:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW1]]
+// CHECK: tbaa ![[OCPATH:[0-9]+]]
+// There will be a load after the store, and it will use tbaa. Make sure
+// the check-not above doesn't find it:
+// CHECK: load
+  Tmp[*Index][0].uw = Arr[*Index][0] * Num;
+// CHECK: %uw[[UW2:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW2]]
+// CHECK: tbaa ![[OCPATH]]
+  Tmp[*Index][1].uw = Arr[*Index][1] * Num;
+// Same here, don't generate tbaa for the loads:
+// CHECK: %uh[[UH1:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX1:[0-9]*]] = getelementptr{{.*}}%uh[[UH1]]
+// CHECK: load i16, i16* %arrayidx[[AX1]]
+// CHECK: tbaa ![[OCPATH]]
+// CHECK: store
+  Vec[0] = Tmp[*Index][0].uh[1];
+// CHECK: %uh[[UH2:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX2:[0-9]*]] = getelementptr{{.*}}%uh[[UH2]]
+// CHECK: load i16, i16* %arrayidx[[AX2]]
+// CHECK: tbaa ![[OCPATH]]
+// CHECK: store
+  Vec[1] = Tmp[*Index][1].uh[1];
+  bar(Tmp);
+}
+
+// CHECK-DAG: ![[CHAR:[0-9]+]] = !{!"omnipotent char"
+// CHECK-DAG: ![[OCPATH]] = !{![[CHAR]], ![[CHAR]], i64 0}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1432,11 +1432,12 @@
 Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
   }
   if (TBAAInfo) {
-llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
-  TBAAOffset);
-if (TBAAPath)
-  CGM.DecorateInstructionWithTBAA(Load, TBAAPath,
-  false /*ConvertTypeToTag*/);
+bool MayAlias = BaseInfo.getMayAlias();
+llvm::MDNode *TBAA = MayAlias
+? CGM.getTBAAInfo(getContext().CharTy)
+: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset);
+if (TBAA)
+  CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias);
   }
 
   if (EmitScalarRangeCheck(Load, Ty, Loc)) {
@@ -1522,11 +1523,12 @@
 Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
   }
   if (TBAAInfo) {
-llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
-  TBAAOffset);
-if (TBAAPath)
-  CGM.DecorateInstructionWithTBAA(Store, TBAAPath,
-  false /*ConvertTypeToTag*/);
+bool MayAlias = BaseInfo.getMayAlias();
+llvm::MDNode *TBAA = MayAlias
+? CGM.getTBAAInfo(getContext

[PATCH] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-24 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8307
   "variable length arrays are not supported in OpenCL">;
+def err_scalar_type_rank_greater_than_vector_type : Error<
+"scalar operand type has greater rank than the type of the vector "

Since it's OpenCL specific rule, could we rename:
  err_scalar_type_rank_greater_than_vector_type -> 
err_opencl_scalar_type_rank_greater_than_vector_type



Comment at: lib/Sema/SemaExpr.cpp:8344
   // the vector element type and splat.
+  unsigned DeclID = 0;
   if (!RHSVecType) {

Could we initialize this with `diag::err_typecheck_vector_not_convertable` and 
then just use default return with empty QualType at the end of the function 
instead of adding an extra one in lines 8369-8374?


https://reviews.llvm.org/D33353



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


[PATCH] D33483: [OpenCL] reserve_id_t cannot be used as argument to kernel function

2017-05-24 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! Btw the same applies to the program scope declaration (s6.9.p), but could 
be done as a separate change.


https://reviews.llvm.org/D33483



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


[PATCH] D33489: [OpenCL] Added regression test on invalid vector initialization.

2017-05-24 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!


https://reviews.llvm.org/D33489



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


r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed May 24 14:31:19 2017
New Revision: 303798

URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
Log:
For Microsoft compatibility, set fno_operator_names

There's a Microsoft header in the Windows SDK which won't 
compile with clang because it uses an operator name (and) 
as a field name. This patch allows that file to compile by 
setting the option which disables operator names. 
The header which doesn't compile  C:/Program Files (x86)/
Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40: 
error: expected member name or ';' after declaration specifiers

  /* [case()] */ NODERESTRICTION or;
   ~~~ ^

   1 error generated.

Contributed for Melanie Blower

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19 2017
@@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);
 
-  if (Args.hasArg(OPT_fno_operator_names))
+  if (Args.hasArg(OPT_fno_operator_names) || 
Args.hasArg(OPT_fms_compatibility))
 Opts.CXXOperatorNames = 0;
 
   if (Args.hasArg(OPT_fcuda_is_device))

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19 2017
@@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
 #define identifier_weird(x) __identifier(x
 int k = identifier_weird(if)); // expected-error {{use of undeclared 
identifier 'if'}}
 
-// This is a bit weird, but the alternative tokens aren't keywords, and this
-// behavior matches MSVC. FIXME: Consider supporting this anyway.
-extern int __identifier(and) r; // expected-error {{cannot convert '&&' token 
to an identifier}}
+// 'and' is not an operator name with Microsoft compatibility.
+extern int __identifier(and) r; // expected-error {{expected ';' after top 
level declarator}}
 
 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
@@ -355,7 +354,6 @@ void TestProperty() {
   ++sp.V11;
 }
 
-//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
 #define and foo
 
 struct __declspec(uuid("---C000-0046")) 
__declspec(novtable) IUnknown {};

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
+// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility
 
 #ifndef OPERATOR_NAMES
 //expected-error@+3 {{token is not a valid binary operator in a preprocessor 
subexpression}}
@@ -29,3 +30,14 @@
 #ifdef and
 #warning and is defined
 #endif
+
+#ifdef TESTWIN
+// For cl compatibility, fno-operator-names is enabled by default.
+int and;
+int bitand;
+int bitor;
+int compl;
+int not;
+int or;
+int xor;
+#endif


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


Re: r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Nico Weber via cfe-commits
Was this reviewed somewhere?

Please make it so that this emits a warning. We want clang-cl to warn on
invalid code (and in system headers warnings are suppressed).

On Wed, May 24, 2017 at 3:31 PM, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Wed May 24 14:31:19 2017
> New Revision: 303798
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
> Log:
> For Microsoft compatibility, set fno_operator_names
>
> There's a Microsoft header in the Windows SDK which won't
> compile with clang because it uses an operator name (and)
> as a field name. This patch allows that file to compile by
> setting the option which disables operator names.
> The header which doesn't compile  C:/Program Files (x86)/
> Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40:
> error: expected member name or ';' after declaration specifiers
>
>   /* [case()] */ NODERESTRICTION or;
>~~~ ^
>
>1 error generated.
>
> Contributed for Melanie Blower
>
> Differential Revision:https://reviews.llvm.org/D33505
>
> Modified:
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19 2017
> @@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
>Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords,
> OPT_fno_gnu_keywords,
>Opts.GNUKeywords);
>
> -  if (Args.hasArg(OPT_fno_operator_names))
> +  if (Args.hasArg(OPT_fno_operator_names) || Args.hasArg(OPT_fms_
> compatibility))
>  Opts.CXXOperatorNames = 0;
>
>if (Args.hasArg(OPT_fcuda_is_device))
>
> Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/
> MicrosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
> 
> ==
> --- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
> +++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19 2017
> @@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
>  #define identifier_weird(x) __identifier(x
>  int k = identifier_weird(if)); // expected-error {{use of undeclared
> identifier 'if'}}
>
> -// This is a bit weird, but the alternative tokens aren't keywords, and
> this
> -// behavior matches MSVC. FIXME: Consider supporting this anyway.
> -extern int __identifier(and) r; // expected-error {{cannot convert '&&'
> token to an identifier}}
> +// 'and' is not an operator name with Microsoft compatibility.
> +extern int __identifier(and) r; // expected-error {{expected ';' after
> top level declarator}}
>
>  void f() {
>__identifier(() // expected-error {{cannot convert '(' token to an
> identifier}}
> @@ -355,7 +354,6 @@ void TestProperty() {
>++sp.V11;
>  }
>
> -//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro
> name}}
>  #define and foo
>
>  struct __declspec(uuid("---C000-0046"))
> __declspec(novtable) IUnknown {};
>
> Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Preprocessor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
> 
> ==
> --- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
> +++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19
> 2017
> @@ -1,5 +1,6 @@
>  // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
>  // RUN: %clang_cc1 %s -E -verify -fno-operator-names
> +// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility
>
>  #ifndef OPERATOR_NAMES
>  //expected-error@+3 {{token is not a valid binary operator in a
> preprocessor subexpression}}
> @@ -29,3 +30,14 @@
>  #ifdef and
>  #warning and is defined
>  #endif
> +
> +#ifdef TESTWIN
> +// For cl compatibility, fno-operator-names is enabled by default.
> +int and;
> +int bitand;
> +int bitor;
> +int compl;
> +int not;
> +int or;
> +int xor;
> +#endif
>
>
> ___
> 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: r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Nico Weber via cfe-commits
Reviewed here: https://reviews.llvm.org/D33505

Still, please make this warn.

On Wed, May 24, 2017 at 3:42 PM, Nico Weber  wrote:

> Was this reviewed somewhere?
>
> Please make it so that this emits a warning. We want clang-cl to warn on
> invalid code (and in system headers warnings are suppressed).
>
> On Wed, May 24, 2017 at 3:31 PM, Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: erichkeane
>> Date: Wed May 24 14:31:19 2017
>> New Revision: 303798
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
>> Log:
>> For Microsoft compatibility, set fno_operator_names
>>
>> There's a Microsoft header in the Windows SDK which won't
>> compile with clang because it uses an operator name (and)
>> as a field name. This patch allows that file to compile by
>> setting the option which disables operator names.
>> The header which doesn't compile  C:/Program Files (x86)/
>> Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40:
>> error: expected member name or ';' after declaration specifiers
>>
>>   /* [case()] */ NODERESTRICTION or;
>>~~~ ^
>>
>>1 error generated.
>>
>> Contributed for Melanie Blower
>>
>> Differential Revision:https://reviews.llvm.org/D33505
>>
>> Modified:
>> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>> cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
>>
>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/
>> CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19
>> 2017
>> @@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
>>Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords,
>> OPT_fno_gnu_keywords,
>>Opts.GNUKeywords);
>>
>> -  if (Args.hasArg(OPT_fno_operator_names))
>> +  if (Args.hasArg(OPT_fno_operator_names) ||
>> Args.hasArg(OPT_fms_compatibility))
>>  Opts.CXXOperatorNames = 0;
>>
>>if (Args.hasArg(OPT_fcuda_is_device))
>>
>> Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/Mi
>> crosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
>> +++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19
>> 2017
>> @@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
>>  #define identifier_weird(x) __identifier(x
>>  int k = identifier_weird(if)); // expected-error {{use of undeclared
>> identifier 'if'}}
>>
>> -// This is a bit weird, but the alternative tokens aren't keywords, and
>> this
>> -// behavior matches MSVC. FIXME: Consider supporting this anyway.
>> -extern int __identifier(and) r; // expected-error {{cannot convert '&&'
>> token to an identifier}}
>> +// 'and' is not an operator name with Microsoft compatibility.
>> +extern int __identifier(and) r; // expected-error {{expected ';' after
>> top level declarator}}
>>
>>  void f() {
>>__identifier(() // expected-error {{cannot convert '(' token to an
>> identifier}}
>> @@ -355,7 +354,6 @@ void TestProperty() {
>>++sp.V11;
>>  }
>>
>> -//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro
>> name}}
>>  #define and foo
>>
>>  struct __declspec(uuid("---C000-0046"))
>> __declspec(novtable) IUnknown {};
>>
>> Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preproces
>> sor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
>> +++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19
>> 2017
>> @@ -1,5 +1,6 @@
>>  // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
>>  // RUN: %clang_cc1 %s -E -verify -fno-operator-names
>> +// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility
>>
>>  #ifndef OPERATOR_NAMES
>>  //expected-error@+3 {{token is not a valid binary operator in a
>> preprocessor subexpression}}
>> @@ -29,3 +30,14 @@
>>  #ifdef and
>>  #warning and is defined
>>  #endif
>> +
>> +#ifdef TESTWIN
>> +// For cl compatibility, fno-operator-names is enabled by default.
>> +int and;
>> +int bitand;
>> +int bitor;
>> +int compl;
>> +int not;
>> +int or;
>> +int xor;
>> +#endif
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
_

RE: r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Keane, Erich via cfe-commits
Adding Melanie, the author of the patch.

From: tha...@google.com [mailto:tha...@google.com] On Behalf Of Nico Weber
Sent: Wednesday, May 24, 2017 12:43 PM
To: Keane, Erich 
Cc: cfe-commits ; rnk 
Subject: Re: r303798 - For Microsoft compatibility, set fno_operator_names

Reviewed here: https://reviews.llvm.org/D33505

Still, please make this warn.

On Wed, May 24, 2017 at 3:42 PM, Nico Weber 
mailto:tha...@google.com>> wrote:
Was this reviewed somewhere?

Please make it so that this emits a warning. We want clang-cl to warn on 
invalid code (and in system headers warnings are suppressed).

On Wed, May 24, 2017 at 3:31 PM, Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Wed May 24 14:31:19 2017
New Revision: 303798

URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
Log:
For Microsoft compatibility, set fno_operator_names

There's a Microsoft header in the Windows SDK which won't
compile with clang because it uses an operator name (and)
as a field name. This patch allows that file to compile by
setting the option which disables operator names.
The header which doesn't compile  C:/Program Files (x86)/
Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40:
error: expected member name or ';' after declaration specifiers

  /* [case()] */ NODERESTRICTION or;
   ~~~ ^

   1 error generated.

Contributed for Melanie Blower

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19 2017
@@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);

-  if (Args.hasArg(OPT_fno_operator_names))
+  if (Args.hasArg(OPT_fno_operator_names) || 
Args.hasArg(OPT_fms_compatibility))
 Opts.CXXOperatorNames = 0;

   if (Args.hasArg(OPT_fcuda_is_device))

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19 2017
@@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
 #define identifier_weird(x) __identifier(x
 int k = identifier_weird(if)); // expected-error {{use of undeclared 
identifier 'if'}}

-// This is a bit weird, but the alternative tokens aren't keywords, and this
-// behavior matches MSVC. FIXME: Consider supporting this anyway.
-extern int __identifier(and) r; // expected-error {{cannot convert '&&' token 
to an identifier}}
+// 'and' is not an operator name with Microsoft compatibility.
+extern int __identifier(and) r; // expected-error {{expected ';' after top 
level declarator}}

 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
@@ -355,7 +354,6 @@ void TestProperty() {
   ++sp.V11;
 }

-//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
 #define and foo

 struct __declspec(uuid("---C000-0046")) 
__declspec(novtable) IUnknown {};

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
+// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility

 #ifndef OPERATOR_NAMES
 //expected-error@+3 {{token is not a valid binary operator in a preprocessor 
subexpression}}
@@ -29,3 +30,14 @@
 #ifdef and
 #warning and is defined
 #endif
+
+#ifdef TESTWIN
+// For cl compatibility, fno-operator-names is enabled by default.
+int and;
+int bitand;
+int bitor;
+int compl;
+int not;
+int or;
+int xor;
+#endif


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



[PATCH] D33497: [clang-tidy] check for __func__/__FUNCTION__ in lambdas

2017-05-24 Thread Bryce Liu via Phabricator via cfe-commits
brycel updated this revision to Diff 100149.
brycel added a comment.
Herald added a subscriber: xazax.hun.

Addressed the following review comments:

- Added a test to make sure we don't warn on __PRETTY_FUNCTION__
- Suppressed warnings when in a macro that also uses __FILE__ and __LINE__
- Updated docs/ReleaseNotes.rst.


https://reviews.llvm.org/D33497

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/LambdaFunctionNameCheck.cpp
  clang-tidy/misc/LambdaFunctionNameCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-lambda-function-name.rst
  test/clang-tidy/misc-lambda-function-name.cpp

Index: test/clang-tidy/misc-lambda-function-name.cpp
===
--- test/clang-tidy/misc-lambda-function-name.cpp
+++ test/clang-tidy/misc-lambda-function-name.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s misc-lambda-function-name %t
+
+void Foo(const char* a, const char* b, int c) {}
+
+#define FUNC_MACRO Foo(__func__, "", 0)
+#define FUNCTION_MACRO Foo(__FUNCTION__, "", 0)
+#define EMBED_IN_ANOTHER_MACRO1 FUNC_MACRO
+
+void Positives() {
+  [] { __func__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { __FUNCTION__; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNC_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { FUNCTION_MACRO; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+  [] { EMBED_IN_ANOTHER_MACRO1; }();
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [misc-lambda-function-name]
+}
+
+#define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
+#define FUNCTION_MACRO_WITH_FILE_AND_LINE Foo(__FUNCTION__, __FILE__, __LINE__)
+#define EMBED_IN_ANOTHER_MACRO2 FUNC_MACRO_WITH_FILE_AND_LINE
+
+void Negatives() {
+  __func__;
+  __FUNCTION__;
+
+  // __PRETTY_FUNCTION__ should not trigger a warning because its value is
+  // actually potentially useful.
+  __PRETTY_FUNCTION__;
+  [] { __PRETTY_FUNCTION__; }();
+
+  // Don't warn if __func__/__FUNCTION is used inside a macro that also uses
+  // __FILE__ and __LINE__, on the assumption that __FILE__ and __LINE__ will
+  // be useful even if __func__/__FUNCTION__ is not.
+  [] { FUNC_MACRO_WITH_FILE_AND_LINE; }();
+  [] { FUNCTION_MACRO_WITH_FILE_AND_LINE; }();
+  [] { EMBED_IN_ANOTHER_MACRO2; }();
+}
Index: docs/clang-tidy/checks/misc-lambda-function-name.rst
===
--- docs/clang-tidy/checks/misc-lambda-function-name.rst
+++ docs/clang-tidy/checks/misc-lambda-function-name.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - misc-lambda-function-name
+
+misc-lambda-function-name
+=
+
+Checks for attempts to get the name of a function from within a lambda
+expression. The name of a lambda is always something like ``operator()``, which
+is almost never what was intended.
+
+Example:
+
+.. code-block:: c++
+
+  void FancyFunction() {
+[] { printf("Called from %s\n", __func__); }();
+[] { printf("Now called from %s\n", __FUNCTION__); }();
+  }
+
+Output::
+
+  Called from operator()
+  Now called from operator()
+
+Likely intended output::
+
+  Called from FancyFunction
+  Now called from FancyFunction
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -82,6 +82,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-lambda-function-name
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -77,6 +77,11 @@
 
   Finds perfect forwarding constructors that can unintentionally hide copy or move constructors.
 
+- New `misc-lambda-function-name
+	`_ check
+
+	Finds uses of __func__ or __FUNCTION__ inside lambdas.
+
 - N

RE: r303798 - For Microsoft compatibility, set fno_operator_names

2017-05-24 Thread Blower, Melanie via cfe-commits
Thanks for the feedback, working on it…

From: Keane, Erich
Sent: Wednesday, May 24, 2017 3:47 PM
To: Nico Weber ; Blower, Melanie 
Cc: cfe-commits ; rnk 
Subject: RE: r303798 - For Microsoft compatibility, set fno_operator_names

Adding Melanie, the author of the patch.

From: tha...@google.com [mailto:tha...@google.com] On 
Behalf Of Nico Weber
Sent: Wednesday, May 24, 2017 12:43 PM
To: Keane, Erich mailto:erich.ke...@intel.com>>
Cc: cfe-commits 
mailto:cfe-commits@lists.llvm.org>>; rnk 
mailto:r...@chromium.org>>
Subject: Re: r303798 - For Microsoft compatibility, set fno_operator_names

Reviewed here: https://reviews.llvm.org/D33505

Still, please make this warn.

On Wed, May 24, 2017 at 3:42 PM, Nico Weber 
mailto:tha...@google.com>> wrote:
Was this reviewed somewhere?

Please make it so that this emits a warning. We want clang-cl to warn on 
invalid code (and in system headers warnings are suppressed).

On Wed, May 24, 2017 at 3:31 PM, Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Wed May 24 14:31:19 2017
New Revision: 303798

URL: http://llvm.org/viewvc/llvm-project?rev=303798&view=rev
Log:
For Microsoft compatibility, set fno_operator_names

There's a Microsoft header in the Windows SDK which won't
compile with clang because it uses an operator name (and)
as a field name. This patch allows that file to compile by
setting the option which disables operator names.
The header which doesn't compile  C:/Program Files (x86)/
Windows Kits/10/include/10.0.14393.0/um\Query.h:259:40:
error: expected member name or ';' after declaration specifiers

  /* [case()] */ NODERESTRICTION or;
   ~~~ ^

   1 error generated.

Contributed for Melanie Blower

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 24 14:31:19 2017
@@ -1882,7 +1882,7 @@ static void ParseLangArgs(LangOptions &O
   Opts.GNUKeywords = Args.hasFlag(OPT_fgnu_keywords, OPT_fno_gnu_keywords,
   Opts.GNUKeywords);

-  if (Args.hasArg(OPT_fno_operator_names))
+  if (Args.hasArg(OPT_fno_operator_names) || 
Args.hasArg(OPT_fms_compatibility))
 Opts.CXXOperatorNames = 0;

   if (Args.hasArg(OPT_fcuda_is_device))

Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Wed May 24 14:31:19 2017
@@ -261,9 +261,8 @@ int __identifier(else} = __identifier(fo
 #define identifier_weird(x) __identifier(x
 int k = identifier_weird(if)); // expected-error {{use of undeclared 
identifier 'if'}}

-// This is a bit weird, but the alternative tokens aren't keywords, and this
-// behavior matches MSVC. FIXME: Consider supporting this anyway.
-extern int __identifier(and) r; // expected-error {{cannot convert '&&' token 
to an identifier}}
+// 'and' is not an operator name with Microsoft compatibility.
+extern int __identifier(and) r; // expected-error {{expected ';' after top 
level declarator}}

 void f() {
   __identifier(() // expected-error {{cannot convert '(' token to an 
identifier}}
@@ -355,7 +354,6 @@ void TestProperty() {
   ++sp.V11;
 }

-//expected-warning@+1 {{C++ operator 'and' (aka '&&') used as a macro name}}
 #define and foo

 struct __declspec(uuid("---C000-0046")) 
__declspec(novtable) IUnknown {};

Modified: cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp?rev=303798&r1=303797&r2=303798&view=diff
==
--- cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp (original)
+++ cfe/trunk/test/Preprocessor/cxx_oper_keyword.cpp Wed May 24 14:31:19 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
+// RUN: %clang_cc1 %s-verify -DTESTWIN -fms-compatibility

 #ifndef OPERATOR_NAMES
 //expected-error@+3 {{token is not a valid binary operator in a preprocessor 
subexpression}}
@@ -29,3 +30,14 @@
 #ifdef and
 #warning and is defined
 #endif
+
+#ifdef TESTWIN
+// For cl compatibility, fno-operator-

[PATCH] D33507: [coroutines] Add support for coroutines with non-scalar parameters

2017-05-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D33507



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


  1   2   >