[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-05-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 100382.
baloghadamsoftware added a comment.

Ignoring bad_alloc.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ExceptionEscapeCheck.cpp
  clang-tidy/misc/ExceptionEscapeCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-exception-escape.rst
  test/clang-tidy/misc-exception-escape.cpp

Index: test/clang-tidy/misc-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-exception-escape.cpp
@@ -0,0 +1,256 @@
+// RUN: %check_clang_tidy %s misc-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: misc-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: misc-exception-escape.EnabledFunctions, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1; 
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1; 
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' throws
+  implicit_int_thrower();
+}
+
+void indirect_explicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 

[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-05-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Herald added a subscriber: yaxunl.

Pipes are now the size of pointers rather than the size of the type that they 
contain.

Patch by Simon Perretta!


https://reviews.llvm.org/D33597

Files:
  lib/AST/ASTContext.cpp
  test/Index/pipe-size.cl


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(0);
+Align = Target->getPointerAlign(0);
   }
 
   }


Index: test/Index/pipe-size.cl
===
--- /dev/null
+++ test/Index/pipe-size.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+}
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(0);
+Align = Target->getPointerAlign(0);
   }
 
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33598: [libclang] [OpenCL] Expose CIndex functions for typedef and address space

2017-05-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.

Expose the following functions:
clang_getTypedefName
clang_getAddressSpace

Patch by Simon Perretta!


https://reviews.llvm.org/D33598

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_type.py
  include/clang-c/Index.h
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -147,6 +147,7 @@
 clang_findReferencesInFileWithBlock
 clang_formatDiagnostic
 clang_free
+clang_getAddressSpace
 clang_getAllSkippedRanges
 clang_getArgType
 clang_getArrayElementType
@@ -259,6 +260,7 @@
 clang_getTypeKindSpelling
 clang_getTypeSpelling
 clang_getTypedefDeclUnderlyingType
+clang_getTypedefName
 clang_hashCursor
 clang_indexLoc_getCXSourceLocation
 clang_indexLoc_getFileLocation
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/AddressSpaces.h"
 #include "clang/Frontend/ASTUnit.h"
 
 using namespace clang;
@@ -394,6 +395,27 @@
   return T.isLocalRestrictQualified();
 }
 
+unsigned clang_getAddressSpace(CXType CT) {
+  QualType T = GetQualType(CT);
+
+  // For non language-specific address space, use separate helper function.
+  if (T.getAddressSpace() >= LangAS::Count) {
+  return T.getQualifiers().getAddressSpaceAttributePrintValue();
+  }
+  return T.getAddressSpace();
+}
+
+CXString clang_getTypedefName(CXType CT) {
+  QualType T = GetQualType(CT);
+  const TypedefType *TT = T->getAs();
+  if (TT) {
+TypedefNameDecl *TD = TT->getDecl();
+if (TD)
+  return cxstring::createDup(TD->getNameAsString().c_str());
+  }
+  return cxstring::createEmpty();
+}
+
 CXType clang_getPointeeType(CXType CT) {
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3404,6 +3404,16 @@
 CINDEX_LINKAGE unsigned clang_isRestrictQualifiedType(CXType T);
 
 /**
+ * \brief Returns the address space of the given type.
+ */
+CINDEX_LINKAGE unsigned clang_getAddressSpace(CXType T);
+
+/**
+ * \brief Returns the typedef name of the given type.
+ */
+CINDEX_LINKAGE CXString clang_getTypedefName(CXType CT);
+
+/**
  * \brief For pointer types, returns the type of the pointee.
  */
 CINDEX_LINKAGE CXType clang_getPointeeType(CXType T);
Index: bindings/python/tests/cindex/test_type.py
===
--- bindings/python/tests/cindex/test_type.py
+++ bindings/python/tests/cindex/test_type.py
@@ -37,37 +37,44 @@
 assert not fields[0].type.is_const_qualified()
 assert fields[0].type.kind == TypeKind.INT
 assert fields[0].type.get_canonical().kind == TypeKind.INT
+assert fields[0].type.get_typedef_name() == ''
 
 assert fields[1].spelling == 'b'
 assert not fields[1].type.is_const_qualified()
 assert fields[1].type.kind == TypeKind.TYPEDEF
 assert fields[1].type.get_canonical().kind == TypeKind.INT
 assert fields[1].type.get_declaration().spelling == 'I'
+assert fields[1].type.get_typedef_name() == 'I'
 
 assert fields[2].spelling == 'c'
 assert not fields[2].type.is_const_qualified()
 assert fields[2].type.kind == TypeKind.LONG
 assert fields[2].type.get_canonical().kind == TypeKind.LONG
+assert fields[2].type.get_typedef_name() == ''
 
 assert fields[3].spelling == 'd'
 assert not fields[3].type.is_const_qualified()
 assert fields[3].type.kind == TypeKind.ULONG
 assert fields[3].type.get_canonical().kind == TypeKind.ULONG
+assert fields[3].type.get_typedef_name() == ''
 
 assert fields[4].spelling == 'e'
 assert not fields[4].type.is_const_qualified()
 assert fields[4].type.kind == TypeKind.LONG
 assert fields[4].type.get_canonical().kind == TypeKind.LONG
+assert fields[4].type.get_typedef_name() == ''
 
 assert fields[5].spelling == 'f'
 assert fields[5].type.is_const_qualified()
 assert fields[5].type.kind == TypeKind.INT
 assert fields[5].type.get_canonical().kind == TypeKind.INT
+assert fields[5].type.get_typedef_name() == ''
 
 assert fields[6].spelling == 'g'
 assert not fields[6].type.is_const_qualified()
 assert fields[6].type.kind == TypeKind.POINTER
 assert fields[6].type.get_pointee().kind == TypeKind.INT
+assert fields[6].type.get_typedef_name() == ''
 
 assert fields[7].spelling == 'h'
 assert not fields[7].type.is_const_qualified()
@@ -75,6 +82,7 @@
 assert fields[7].type.get_pointee().kind == TypeKind.POINTER
 assert 

[clang-tools-extra] r303993 - [clangd] Attempt to fix tests failing on Windows

2017-05-26 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 26 09:34:34 2017
New Revision: 303993

URL: http://llvm.org/viewvc/llvm-project?rev=303993=rev
Log:
[clangd] Attempt to fix tests failing on Windows

Modified:
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=303993=303992=303993=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Fri May 26 
09:34:34 2017
@@ -184,21 +184,27 @@ public:
 };
 
 /// Replaces all patterns of the form 0x123abc with spaces
-void replacePtrsInDump(std::string ) {
+std::string replacePtrsInDump(std::string const ) {
   llvm::Regex RE("0x[0-9a-fA-F]+");
   llvm::SmallVector Matches;
-  while (RE.match(Dump, )) {
+  llvm::StringRef Pending = Dump;
+
+  std::string Result;
+  while (RE.match(Pending, )) {
 assert(Matches.size() == 1 && "Exactly one match expected");
-auto MatchPos = Matches[0].data() - Dump.data();
-std::fill(Dump.begin() + MatchPos,
-  Dump.begin() + MatchPos + Matches[0].size(), ' ');
+auto MatchPos = Matches[0].data() - Pending.data();
+
+Result += Pending.take_front(MatchPos);
+Pending = Pending.drop_front(MatchPos + Matches[0].size());
   }
+  Result += Pending;
+
+  return Result;
 }
 
 std::string dumpASTWithoutMemoryLocs(ClangdServer , PathRef File) {
-  auto Dump = Server.dumpAST(File);
-  replacePtrsInDump(Dump);
-  return Dump;
+  auto DumpWithMemLocs = Server.dumpAST(File);
+  return replacePtrsInDump(DumpWithMemLocs);
 }
 
 template 


___
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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In https://reviews.llvm.org/D32478#765548, @Typz wrote:

> In https://reviews.llvm.org/D32478#765537, @djasper wrote:
>
> > In all honesty, I think this style isn't thought out well enough. It really 
> > is a special case for only "=" and "return" and even there, it has many 
> > cases where it simply doesn't make sense. And then you have cases like this:
> >
> >   bool = aa //
> >   ==  //
> >   && c;
> >   
> >
> > Where the syntactic structure is lost entirely.
>
>
> It is not lost, extra indent for 'virtual' parenthesis is still there:
>
>   bool a = aa   //
> ==  //
> && c;


Ah, right, I was thinking about something else (commas where we don't add extra 
indentation. Anyhow, I don't think what you are writing is what clang-format 
produces. How could it indent relative to the "&&" when placing the "=="? It 
doesn't know how far to unindent at that point, I think.

> 
> 
>> On top of that it has runtime downsides for all clang-format users because 
>> ParenState gets larger and more costly compare. As such, I am against moving 
>> forward with this. Can you remind me again, which coding style suggests this 
>> format?
> 
> This is just a single extra bit (and there are still less than 16 such bits), 
> so it does change the size of ParenState. As for the compare cost, I think it 
> is within reach of the compiler's optimization, but it may indeed have a 
> slight impact.




https://reviews.llvm.org/D32478



___
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-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D31745



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

Nop, it's formatted like this:

  bool a = aa   //
==  //
&& c;
  
  bool a = aa //
==    //
   + c;


https://reviews.llvm.org/D32478



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

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

> I think it's just wrong that WebKit inherits this. The style guide explicitly 
> says that this is wrong:
>
>   MyOtherClass::MyOtherClass() : MySuperClass() {}


I think this exemple applies to constructors only.
Looking at webkit code, there are many shortl functions which are indeed 
formatted on a single line (at least 22097 occurences, actually)

> So I still think we can make this work with the existing options without 
> regressing a behavior that anyone is relying on.


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] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-05-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/AST/ASTContext.cpp:1942
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(0);
+Align = Target->getPointerAlign(0);

pipe is in global address space. shouldn't it be

```
Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
```
the same with align.


https://reviews.llvm.org/D33597



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100384.
Typz added a comment.

fix style


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,103 @@
 
   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);
+
+  // 

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

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

In https://reviews.llvm.org/D32478#765642, @Typz wrote:

> Nop, it's formatted like this:
>
>   bool a = aa   //
> ==  //
> && c;
>   
>   bool a = aa //
> ==    //
>+ c;
>   
>
> The current way to format operators is not affected: the indentation is done 
> as "usual", then they are unindented by the operator width to keep the 
> alignment...


Ah damn. Didn't think about the precedences. What I wanted was for the highest 
level to have a one char operator, e.g.

  bool a = aa //
 <<    //
 | c;

However, you example is also interesting

In https://reviews.llvm.org/D32478#765548, @Typz wrote:

> In https://reviews.llvm.org/D32478#765537, @djasper wrote:
>
> > In all honesty, I think this style isn't thought out well enough. It really 
> > is a special case for only "=" and "return" and even there, it has many 
> > cases where it simply doesn't make sense. And then you have cases like this:
> >
> >   bool = aa //
> >   ==  //
> >   && c;
> >   
> >
> > Where the syntactic structure is lost entirely.
>
>
> It is not lost, extra indent for 'virtual' parenthesis is still there:
>
>   bool a = aa   //
> ==  //
> && c;
>   
>
> > On top of that it has runtime downsides for all clang-format users because 
> > ParenState gets larger and more costly compare. As such, I am against 
> > moving forward with this. Can you remind me again, which coding style 
> > suggests this format?
>
> This is just a single extra bit (and there are still less than 16 such bits), 
> so it does change the size of ParenState. As for the compare cost, I think it 
> is within reach of the compiler's optimization, but it may indeed have a 
> slight impact.


I would still be interested in a coding style that recommends this format.


https://reviews.llvm.org/D32478



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D32478#765537, @djasper wrote:

> In all honesty, I think this style isn't thought out well enough. It really 
> is a special case for only "=" and "return" and even there, it has many cases 
> where it simply doesn't make sense. And then you have cases like this:
>
>   bool = aa //
>   ==  //
>   && c;
>   
>
> Where the syntactic structure is lost entirely.




  bool a = aa   //
==  //
&& c;

> On top of that it has runtime downsides for all clang-format users because 
> ParenState gets larger and more costly compare. As such, I am against moving 
> forward with this. Can you remind me again, which coding style suggests this 
> format?

This is just a single extra bit (and there are still less than 16 such bits), 
so it does change the size of ParenState. As for the compare cost, I think it 
is within reach of the compiler's optimization, but it may indeed have a slight 
impact.


https://reviews.llvm.org/D32478



___
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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Lets try this the other way around. I am not ok with introducing an additional 
top-level option for this. It simply isn't important enough. So find a way for 
the existing style flags to support what you need and not regress existing 
users. If that can't be done, I am also ok with adding another value into 
BraceWrapping (which you suggested at some point, I think).


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] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D33353



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I actually don't know how, but it still manages somehow : I rebuilt this exact 
patch to ensure I gave you the correct output.
And the same behavior can be seen in the test cases, where the operator with 
highest precedence is aligned with the equal sign.


https://reviews.llvm.org/D32478



___
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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In https://reviews.llvm.org/D32478#765583, @Typz wrote:

> I actually don't know how, but it still manages somehow : I rebuilt this 
> exact patch to ensure I gave you the correct output.
>  And the same behavior can be seen in the test cases, where the operator with 
> highest precedence is aligned with the equal sign.


So, it's formatting like this?

  bool a = aa   //
==  //
&& c;
  
  auto a = aa//
 ==  //
 + c;

While that's interesting and I'd like to figure out how it actually works, I 
also think it's really weird to indent the inner "==" differently based on the 
kind of operator around it. The existing way to format these operators is nice 
and consistent here with always adding a multiple of four spaces.


https://reviews.llvm.org/D32478



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


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

2017-05-26 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Fri May 26 08:30:26 2017
New Revision: 303986

URL: http://llvm.org/viewvc/llvm-project?rev=303986=rev
Log:
[OpenCL] An error shall occur if any scalar operand has greater rank than the 
type of the vector element

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: cfe-commits, bader, yaxunl

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

Added:
cfe/trunk/test/SemaOpenCL/arithmetic-conversions.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/cond.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303986=303985=303986=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 26 08:30:26 
2017
@@ -8314,6 +8314,9 @@ def err_opencl_bitfields : Error<
   "bit-fields are not supported in OpenCL">;
 def err_opencl_vla : Error<
   "variable length arrays are not supported in OpenCL">;
+def err_opencl_scalar_type_rank_greater_than_vector_type : Error<
+"scalar operand type has greater rank than the type of the vector "
+"element. (%0 and %1)">;
 def err_bad_kernel_param_type : Error<
   "%0 cannot be used as the type of a kernel parameter">;
 def err_record_with_pointers_kernel_param : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303986=303985=303986=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 26 08:30:26 2017
@@ -8074,28 +8074,38 @@ QualType Sema::InvalidLogicalVectorOpera
 /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except
 /// for float->int.
 ///
+/// OpenCL V2.0 6.2.6.p2:
+/// An error shall occur if any scalar operand type has greater rank
+/// than the type of the vector element.
+///
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema , ExprResult *scalar,
  QualType scalarTy,
  QualType vectorEltTy,
- QualType vectorTy) {
+ QualType vectorTy,
+ unsigned ) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_Invalid;
   
   if (vectorEltTy->isIntegralType(S.Context)) {
-if (!scalarTy->isIntegralType(S.Context))
+if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
+(scalarTy->isIntegerType() &&
+ S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
+  DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
   return true;
-if (S.getLangOpts().OpenCL &&
-S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0)
+}
+if (!scalarTy->isIntegralType(S.Context))
   return true;
 scalarCast = CK_IntegralCast;
   } else if (vectorEltTy->isRealFloatingType()) {
 if (scalarTy->isRealFloatingType()) {
   if (S.getLangOpts().OpenCL &&
-  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0)
+  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) {
+DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
 return true;
+  }
   scalarCast = CK_FloatingCast;
 }
 else if (scalarTy->isIntegralType(S.Context))
@@ -8341,10 +8351,12 @@ QualType Sema::CheckVectorOperands(ExprR
 
   // If there's a vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  unsigned DiagID = diag::err_typecheck_vector_not_convertable;
   if (!RHSVecType) {
 if (isa(LHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, , RHSType,
-LHSVecType->getElementType(), LHSType))
+LHSVecType->getElementType(), LHSType,
+DiagID))
 return LHSType;
 } else {
   if (!tryGCCVectorConvertAndSplat(*this, , ))
@@ -8355,7 +8367,7 @@ QualType Sema::CheckVectorOperands(ExprR
 if (isa(RHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : ),
 LHSType, RHSVecType->getElementType(),
-RHSType))
+RHSType, DiagID))
 return RHSType;
 } else {
   if (LHS.get()->getValueKind() == VK_LValue ||
@@ -8431,7 +8443,7 @@ QualType Sema::CheckVectorOperands(ExprR
   }
 
   // 

[PATCH] D33592: [OpenCL] Test on half immediate support.

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

https://reviews.llvm.org/D33592

Files:
  test/CodeGenOpenCL/half.cl


Index: test/CodeGenOpenCL/half.cl
===
--- test/CodeGenOpenCL/half.cl
+++ test/CodeGenOpenCL/half.cl
@@ -21,3 +21,20 @@
 {
   return ++x;
 }
+
+__attribute__((overloadable)) int min(int, int);
+__attribute__((overloadable)) half min(half, half);
+__attribute__((overloadable)) float min(float, float);
+
+__kernel void foo( __global half* buf, __global float* buf2 )
+{
+buf[0] = min( buf[0], 1.5h );
+// CHECK: half 0xH3E00
+buf[0] = min( buf2[0], 1.5f );
+// CHECK: float 1.50e+00
+
+const half one = 1.;
+buf[1] = min( buf[1], one );
+// CHECK: half 0xH3EAB
+}
+


Index: test/CodeGenOpenCL/half.cl
===
--- test/CodeGenOpenCL/half.cl
+++ test/CodeGenOpenCL/half.cl
@@ -21,3 +21,20 @@
 {
   return ++x;
 }
+
+__attribute__((overloadable)) int min(int, int);
+__attribute__((overloadable)) half min(half, half);
+__attribute__((overloadable)) float min(float, float);
+
+__kernel void foo( __global half* buf, __global float* buf2 )
+{
+buf[0] = min( buf[0], 1.5h );
+// CHECK: half 0xH3E00
+buf[0] = min( buf2[0], 1.5f );
+// CHECK: float 1.50e+00
+
+const half one = 1.;
+buf[1] = min( buf[1], one );
+// CHECK: half 0xH3EAB
+}
+
___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100393.
Typz added a comment.

update mozilla style to use empty function blocks


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);
+  

[PATCH] D33509: [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies

2017-05-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D33509



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

LGTM but I can't speak for the area where you added `#include ` and 
killed off the `_NEWLIB_VERSION` check
Seems in order based on 
https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
Maybe make a note of the minimum newlib version supported somewhere?

Others may have more specific thoughts on the diff.


https://reviews.llvm.org/D33082



___
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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

In all honesty, I think this style isn't thought out well enough. It really is 
a special case for only "=" and "return" and even there, it has many cases 
where it simply doesn't make sense. And then you have cases like this:

  bool = aa //
  ==  //
  && c;

Where the syntactic structure is lost entirely.

On top of that it has runtime downsides for all clang-format users because 
ParenState gets larger and more costly compare. As such, I am against moving 
forward with this. Can you remind me again, which coding style suggests this 
format?




Comment at: unittests/Format/FormatTest.cpp:2619
+  "sizeof(int16_t) // DWARF ARange version number\n"
+  "  + sizeof(int32_t) // Offset of CU in the .debug_info section\n"
+  "  + sizeof(int8_t)  // Pointer Size (in bytes)\n"

I think this is wrong and we should not indent like this.


https://reviews.llvm.org/D32478



___
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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I don't understand. WebKit style would not set AllowShortFunctionsOnASingleLine 
and so the behavior there wouldn't change, I presume?


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] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-26 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

Looks like this causes the build bot to fail on SystemZ:
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/8741

error: 'error' diagnostics expected but not seen:

  File 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/SemaOpenCL/arithmetic-conversions.cl
 Line 7: scalar operand type has greater rank than the type of the vector 
element. ('float2' (vector of 2 'float' values) and 'double')
  File 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/SemaOpenCL/arithmetic-conversions.cl
 Line 9: scalar operand type has greater rank than the type of the vector 
element. ('double' and 'float2' (vector of 2 'float' values))

error: 'warning' diagnostics seen but not expected:

  File 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/SemaOpenCL/arithmetic-conversions.cl
 Line 7: double precision constant requires cl_khr_fp64, casting to single 
precision
  File 
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/tools/clang/test/SemaOpenCL/arithmetic-conversions.cl
 Line 9: double precision constant requires cl_khr_fp64, casting to single 
precision


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] D31830: Emit invariant.group.barrier when using union field

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



Comment at: lib/CodeGen/CGExpr.cpp:3517
+CGM.getCodeGenOpts().StrictVTablePointers &&
+CGM.getCodeGenOpts().OptimizationLevel > 0)
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),

Prazek wrote:
> rjmccall wrote:
> > Prazek wrote:
> > > rjmccall wrote:
> > > > Prazek wrote:
> > > > > rjmccall wrote:
> > > > > > Checking for v-table pointers recursively isn't really that 
> > > > > > difficult, but if you really don't want to do that, please at least 
> > > > > > check for non-POD-ness or something so that this isn't kicking in 
> > > > > > for literally every struct type.
> > > > > ok, I am also planning to fix this in the later patch, because the 
> > > > > same problem arise when comparing 2 pointers to dynamic classe. 
> > > > > I would like to have a bit in CXXRecordDecl to remember if it has any 
> > > > > vptr inside that would calculate durring the construction. 
> > > > > My biggest fear is that if I won't cache it then it will be very slow.
> > > > We could repeat this work from scratch on every single union field 
> > > > access done by IRGen and it would still be way, way faster than doing 
> > > > anything extra on every record definition in the program.  The latter 
> > > > is done orders of magnitude more frequently than the former.
> > > This is a good point, and actually I don't need to check if class holds 
> > > any vptrs for the example I refered (comparing 2 pointers).
> > > Hovewer I still need to do it when someone casts pointer to class holding 
> > > vptrs to something that doesn't hold vptrs, and any pointer casts are 
> > > much more frequent than Record declarations.
> > What are you planning to do if someone casts to a pointer to incomplete 
> > type?
> > 
> > I am concerned that what these problems are really telling us is that this 
> > representation is not very good.
> In this case we also need to add the barrier. I might be wrong, but I think 
> this in general should be pretty rare and even more rare if it would limit 
> the devirtualization. 
> For example cases like: 
> 
>   Derived *d;
>   (Base*)d;
> 
> will not limit devirtualization if Derived is complete type (because base 
> will be also).
> 
> The other thing is that with my recent patches, adding more barriers will not 
> limit any memory optimizations.
You don't need the .getTypePtr() here.



Comment at: lib/CodeGen/CGExpr.cpp:3530
+  return false;
+}
+

You need to recurse into base classes (to check their fields), and if you write 
this to take a QualType you won't have to eagerly extract RD below.


https://reviews.llvm.org/D31830



___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> Ah damn. Didn't think about the precedences. What I wanted was for the 
> highest level to have a one char operator, e.g.
> 
>   bool a = aa //
>  <<    //
>  | c;
>

Almost, but not quite:

  bool a = aa   //
<<  //
 | c;

i.e. the identifiers is indented by 4 characters, then the operator is 
'unindented.

> I would still be interested in a coding style that recommends this format.

We are using this at our compagny, but this is neither public nor open source.
I am sure I saw this style somewhere else, but I cannot remember where...
(This is also the style recommended for webkit's when returning booleans : 
https://webkit.org/code-style-guidelines/#indentation-wrap-bool-op, but 
probably because the continuation indent is 4...
and I am not sure this guide in Boost's Spirit library counts either: 
http://www.boost.org/doc/libs/1_56_0/libs/spirit/doc/html/spirit/notes/style_guide.html
 )


https://reviews.llvm.org/D32478



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


r303996 - Revert "[OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element"

2017-05-26 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Fri May 26 10:32:45 2017
New Revision: 303996

URL: http://llvm.org/viewvc/llvm-project?rev=303996=rev
Log:
Revert "[OpenCL] An error shall occur if any scalar operand has greater rank 
than the type of the vector element"

This reverts commit r303986 as it broke all ARM and AArch64 buildbots...

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-39vma/builds/7007
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/6705
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/7509
etc.

Removed:
cfe/trunk/test/SemaOpenCL/arithmetic-conversions.cl
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaOpenCL/cond.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303996=303995=303996=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 26 10:32:45 
2017
@@ -8314,9 +8314,6 @@ def err_opencl_bitfields : Error<
   "bit-fields are not supported in OpenCL">;
 def err_opencl_vla : Error<
   "variable length arrays are not supported in OpenCL">;
-def err_opencl_scalar_type_rank_greater_than_vector_type : Error<
-"scalar operand type has greater rank than the type of the vector "
-"element. (%0 and %1)">;
 def err_bad_kernel_param_type : Error<
   "%0 cannot be used as the type of a kernel parameter">;
 def err_record_with_pointers_kernel_param : Error<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303996=303995=303996=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 26 10:32:45 2017
@@ -8074,38 +8074,28 @@ QualType Sema::InvalidLogicalVectorOpera
 /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except
 /// for float->int.
 ///
-/// OpenCL V2.0 6.2.6.p2:
-/// An error shall occur if any scalar operand type has greater rank
-/// than the type of the vector element.
-///
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema , ExprResult *scalar,
  QualType scalarTy,
  QualType vectorEltTy,
- QualType vectorTy,
- unsigned ) {
+ QualType vectorTy) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_Invalid;
   
   if (vectorEltTy->isIntegralType(S.Context)) {
-if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
-(scalarTy->isIntegerType() &&
- S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
-  DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
-  return true;
-}
 if (!scalarTy->isIntegralType(S.Context))
   return true;
+if (S.getLangOpts().OpenCL &&
+S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0)
+  return true;
 scalarCast = CK_IntegralCast;
   } else if (vectorEltTy->isRealFloatingType()) {
 if (scalarTy->isRealFloatingType()) {
   if (S.getLangOpts().OpenCL &&
-  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) {
-DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
+  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0)
 return true;
-  }
   scalarCast = CK_FloatingCast;
 }
 else if (scalarTy->isIntegralType(S.Context))
@@ -8351,12 +8341,10 @@ QualType Sema::CheckVectorOperands(ExprR
 
   // If there's a vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
-  unsigned DiagID = diag::err_typecheck_vector_not_convertable;
   if (!RHSVecType) {
 if (isa(LHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, , RHSType,
-LHSVecType->getElementType(), LHSType,
-DiagID))
+LHSVecType->getElementType(), LHSType))
 return LHSType;
 } else {
   if (!tryGCCVectorConvertAndSplat(*this, , ))
@@ -8367,7 +8355,7 @@ QualType Sema::CheckVectorOperands(ExprR
 if (isa(RHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : ),
 LHSType, RHSVecType->getElementType(),
-RHSType, DiagID))
+RHSType))
 return RHSType;
 } else {
   

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

2017-05-26 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

This issue probably can be fixed by setting SPIR target architecture or just 
enabling cl_khr_fp64 extension.
Unfortunately, I can't check it today.
Could you revert Egor's commit, please?


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] D33447: clang-format: add option to merge empty function body

2017-05-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: include/clang/Format/Format.h:644
+/// This option is used only if the opening brace of the function has
+/// already
+/// been wrapped, i.e. the `AfterFunction` brace wrapping mode is set, and

Reflow the comment.




Comment at: include/clang/Format/Format.h:654
+///
+bool AllowEmptyFunctionBody;
 /// \brief Wrap before ``catch``.

I think the name probably isn't very intuitive. Maybe invert it and call it 
"SplitEmptyFunctionBody"?



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

indent. Here and elsewhere.


https://reviews.llvm.org/D33447



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


Re: [PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

2017-05-26 Thread Richard Smith via cfe-commits
This definitely looks like a GCC bug.

On 26 May 2017 1:34 am, "David Abdurachmanov via Phabricator via
cfe-commits"  wrote:

davidlt added a comment.

This happens with recent GCC 7.1.1 (updated yesterday) and if compiled in
C++1z mode.

  FAILED: /home/davidlt/root_patch_check/a/slc7_ppc64le_gcc700/
external/gcc/7.0.0-njopjo2/bin/g++   -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Iinterpreter/llvm/src/lib/Transforms/Instrumentation
-I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation
-Iinterpreter/llvm/src/include -I/home/davidlt/root_patch_
check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-
6.09.04/interpreter/llvm/src/include -D__ROOFIT_NOBANNER
-Wno-implicit-fallthrough -Wno-noexcept-type -pipe   -Wshadow -Wall -W
-Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++1z
-fvisibility=hidden -fPIC -fvisibility-inlines-hidden -w -Werror=date-time
-std=c++1z -ffunction-sections -fdata-sections -O2 -DNDEBUG
-fno-exceptions -fno-rtti -MD -MT interpreter/llvm/src/lib/
Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
-MF interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/
LLVMInstrumentation.dir/PGOInstrumentation.cpp.o.d -o
interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/
LLVMInstrumentation.dir/PGOInstrumentation.cpp.o -c
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/
Instrumentation/PGOInstrumentation.cpp
  /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/
Instrumentation/PGOInstrumentation.cpp: In constructor '{anonymous}::
PGOInstrumentationUseLegacyPass::PGOInstrumentationUseLegacyPas
s(std::string)':
  /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/
Instrumentation/PGOInstrumentation.cpp:155:25: error:
'llvm::cl::opt::opt(const
llvm::cl::opt&) [with DataType =
std::basic_string; bool ExternalStorage = false; ParserClass =
llvm::cl::parser]' is private within this context
 ProfileFileName = PGOTestProfileFile;
   ^~
  In file included from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/Support/Options.h:41:0,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/LLVMContext.h:19,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/Metadata.h:26,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/TrackingMDRef.h:17,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/DebugLoc.h:18,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/Instruction.h:20,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/BasicBlock.h:19,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/Function.h:24,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/IR/PassManager.h:44,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/Transforms/PGOInstrumentation.h:17,
   from /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/
Instrumentation/PGOInstrumentation.cpp:51:
  /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_
gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/
include/llvm/Support/CommandLine.h:1296:3: note: declared private here
 opt(const opt &) = delete;
 ^~~


This is wrong. We have a "public:" on the previous line! But I think this
is just GCC's diagnostic being screwed up and what it's trying to say is
that it selected a deleted function.

But this function is the wrong overload resolution result; the operator
std::string from the base class should be selected.

  /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_

r304006 - Update MS mangling EBNF, NFC

2017-05-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri May 26 12:11:10 2017
New Revision: 304006

URL: http://llvm.org/viewvc/llvm-project?rev=304006=rev
Log:
Update MS mangling EBNF, NFC

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=304006=304005=304006=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Fri May 26 12:11:10 2017
@@ -1689,6 +1689,8 @@ void MicrosoftCXXNameMangler::mangleType
   // ::= _N # bool
   // _O # 
   // ::= _T # __float80 (Intel)
+  // ::= _S # char16_t
+  // ::= _U # char32_t
   // ::= _W # wchar_t
   // ::= _Z # __float80 (Digital Mars)
   switch (T->getKind()) {


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


[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@vsk: I would include your fuzzing test in this patch. Simply put it somewhere 
under `test/libcxx/containers/unordered`.


https://reviews.llvm.org/D33588



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D33082#765644, @martell wrote:

> LGTM but I can't speak for the area where you added `#include ` and 
> killed off the `_NEWLIB_VERSION` check
>  Seems in order based on 
> https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
>  Maybe make a note of the minimum newlib version supported somewhere?


I removed the section you're referring to because it's unneeded. `<__locale>` 
does the exact same `#include` dance. and `` includes `<__locale>`.
It should not have an affect on functionality.


https://reviews.llvm.org/D33082



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


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

2017-05-26 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In https://reviews.llvm.org/D33353#765783, @bader wrote:

> Could you revert Egor's commit, please?


I see Renato Golin has already reverted the commit, thanks ...


https://reviews.llvm.org/D33353



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


r304000 - Adding a const overload of DesignatedInitExpr::getDesignator().

2017-05-26 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 26 10:55:52 2017
New Revision: 304000

URL: http://llvm.org/viewvc/llvm-project?rev=304000=rev
Log:
Adding a const overload of DesignatedInitExpr::getDesignator().

Modified:
cfe/trunk/include/clang/AST/Expr.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=304000=303999=304000=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Fri May 26 10:55:52 2017
@@ -4284,6 +4284,9 @@ public:
   }
 
   Designator *getDesignator(unsigned Idx) { return ()[Idx]; }
+  const Designator *getDesignator(unsigned Idx) const {
+return ()[Idx];
+  }
 
   void setDesignators(const ASTContext , const Designator *Desigs,
   unsigned NumDesigs);


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


[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-05-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D33588#765768, @mclow.lists wrote:

> I can reproduce this, but I'd rather figure out why we're calling 
> `__next_hash_pow2(0)` or `(1)` before deciding how to fix it.


It looks like we hit the UB while attempting to shrink a hash table during a 
rehash. If the current bucket count is a power of two, we try and find a 
smaller bucket count (also a power of two) large enough to accommodate all 
entries in the table.

The argument passed in to next_hash_pow2 from hash_table::rehash is `__n = 
size_t(ceil(float(size()) / max_load_factor()))`. I think `__n = 0` if the 
table is empty. And `__n = 1` when the maximum load factor is (roughly) equal 
to the table's size.

As an alternate fix, it might be worth considering changing the rehashing 
algorithm. But I'd like to start with a more conservative fix for the UB issue, 
at least initially.


https://reviews.llvm.org/D33588



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


[PATCH] D33437: Emit available_externally vtables opportunistically

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



Comment at: include/clang/AST/VTableBuilder.h:160
+   "GlobalDecl can be created only from virtual function");
+if (getKind() == CK_FunctionPointer)
+  return GlobalDecl(getFunctionDecl());

Please use an exhaustive switch.  You can put llvm_unreachable in the other 
cases.



Comment at: lib/CodeGen/CGVTables.cpp:905
+else
+  OpportunisticVTables.push_back(RD);
 

I would add a CGM.shouldOpportunisticallyEmitVTables() that can just check the 
optimization level, and then you can use that to avoid even collecting v-tables 
like this if you don't need to.



Comment at: lib/CodeGen/CodeGenModule.cpp:1377
 
+void CodeGenModule::EmitVTablesOpportunistically() {
+  // Only emit speculated vtables with optimizations.

It's worth adding a header comment to this explaining that it runs after 
EmitDeferred() and therefore is not allowed to create new references to things 
that need to be emitted lazily.


https://reviews.llvm.org/D33437



___
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 target-features for arm/thumb triples.

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

I'll hold off merging this patch until https://reviews.llvm.org/D33436 lands, 
which fixes a problem with mixed ARM/Thumb codegen


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] D33447: clang-format: add option to merge empty function body

2017-05-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100420.
Typz marked 2 inline comments as done.
Typz added a comment.

fix indent & rename option to SplitEmptyFunctionBody


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,35 @@
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 +6046,101 @@
"  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, SplitEmptyFunctionBody) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.BraceWrapping.SplitEmptyFunctionBody = false;
+  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) {
@@ -8715,6 +8839,7 @@
   

Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-26 Thread Tim Northover via cfe-commits
On 24 May 2017 at 17:54, Richard Smith  wrote:
> Yikes :-( Maybe libc++ *should* have that extension then. It sounds like
> we'll silently get the wrong value for any attempt at std::complex /
> _Complex interop right now:

That sounds like a pretty good idea whatever we decide to do about the literals.

But we do need to sort out what we're going to do here. I quite like
the approach you suggested, and think it's an improvement worth
putting in for gnu++ modes regardless.

So the remaining question is what we should do for the
standards-compliant C++ modes. We seem to have 3 plausible options:

1. Bar it everywhere. It's an extension.
2. Bar it for C++14 onwards, where the standard provides literals.
3. Allow it everywhere.

Although 2 would be the most conservative option (it maintains all
existing behaviour), it's my least favourite for the added complexity
and quirkiness.

My original inclination is to go with Marshall and pick 1, but it's a
very weak preference and I know I tend to be a bit user-hostile in
these situations.

So, how do we resolve this. Does anyone else have opinions?

Tim.
___
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-26 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 100412.
Typz added a comment.

move option to BraceWrapping


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, AllowEmptyFunctionBody) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.BraceWrapping.AllowEmptyFunctionBody = 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) {
@@ -8712,6 +8840,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterObjCDeclaration);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterStruct);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterUnion);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, 

[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-05-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I can reproduce this, but I'd rather figure out why we're calling 
`__next_hash_pow2(0)` or `(1)` before deciding how to fix it.


https://reviews.llvm.org/D33588



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


[PATCH] D33525: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-05-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

In https://reviews.llvm.org/D33525#766050, @timshen wrote:

> In https://reviews.llvm.org/D33525#764251, @chandlerc wrote:
>
> > (focusing on the LLVM side of this review for now)
> >
> > Can you add an LLVM-based test? Can you add this to 
> > `lib/Passes/PassRegistry.def`?
>
>
> Talked offline. Given the fact that BitcodeWriter (and possibly assembly 
> writer?) is not registered either, it seems to be a larger issue that's out 
> of the scope of this patch.


While *generic* testing is out of scope, I think you need at least *some* 
testing of this in this patch. It can be an option directly in the `llvm-lto` 
tool or a direct option in the `opt` tool itself, but we shouldn't add a bunch 
of code to LLVM that can only ever be exercised by using some other tool.


https://reviews.llvm.org/D33525



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


r304033 - Resubmit r303861.

2017-05-26 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Fri May 26 16:08:20 2017
New Revision: 304033

URL: http://llvm.org/viewvc/llvm-project?rev=304033=rev
Log:
Resubmit r303861.

[AMDGPU] add __builtin_amdgcn_s_getpc

Patch by Tim Corringham

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=304033=304032=304033=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Fri May 26 16:08:20 2017
@@ -36,6 +36,7 @@ BUILTIN(__builtin_amdgcn_workitem_id_z,
 // Instruction builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_s_getreg, "UiIi", "n")
+BUILTIN(__builtin_amdgcn_s_getpc, "LUi", "n")
 BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=304033=304032=304033=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Fri May 26 16:08:20 2017
@@ -481,6 +481,13 @@ void test_fmed3_f32(global float* out, f
   *out = __builtin_amdgcn_fmed3f(a, b, c);
 }
 
+// CHECK-LABEL: @test_s_getpc
+// CHECK: call i64 @llvm.amdgcn.s.getpc()
+void test_s_getpc(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_getpc();
+}
+
 // CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }


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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-05-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 100475.
vsk edited the summary of this revision.
vsk added a comment.

Ping.


https://reviews.llvm.org/D33305

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Basic/Sanitizers.def
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pointer-overflow.m
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -3,27 +3,27 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-undefined-trap-on-error -fsanitize=undefined-trap %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
-// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute|function),?){18}"}}
-// CHECK-UNDEFINED-TRAP: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound"
-// CHECK-UNDEFINED-TRAP2: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift-base,shift-exponent,unreachable,vla-bound"
+// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute|function),?){19}"}}
+// CHECK-UNDEFINED-TRAP: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound"
+// CHECK-UNDEFINED-TRAP2: "-fsanitize-trap=alignment,array-bounds,bool,enum,float-cast-overflow,float-divide-by-zero,function,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,unreachable,vla-bound"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
-// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){19}"}}
+// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|vptr|object-size|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){20}"}}
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN
-// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
+// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
 // RUN: %clang -target i386-unknown-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-OPENBSD
-// CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
+// CHECK-UNDEFINED-OPENBSD: 

[PATCH] D33606: [Sema] Fix a crash-on-invalid when a template parameter list has a class definition or non-reference class type

2017-05-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

Currently clang crashes with an assertion failure in SemaAccess.cpp ("Assertion 
failed: (Access == AS_private || Access == AS_protected)") when compiling the 
following invalid code:

  class C0 {
  public:
template) {}
S0 *m;
  
template
void foo1();
  };
  
  C1 *x;

This seems to happen because:

- The definition of struct S0 is parsed as part of the template parameters list 
because of the missing closing angle bracket.
- Sema adds struct S0 to class C0's scope. But if struct S0 is introduced in a 
template parameter list, it should add the struct to the enclosing scope (the 
file scope), just like it would add class C1 to the file scope.
- It looks up S0 in C0's scope and then checks its access specifier when 
LookupResult is destructed. The assertion fails because S0's access specifier 
is not set (it's AS_none).

To fix the crash, I made changes in Sema::ActOnTag to check whether it's 
parsing a template parameter list and, if it is, move S0 to the correct scope. 
Also, the TagDecl is marked as invalid if the class is defined in a template 
parameter list. Note that test/SemaCXX/PR16677.cpp loses one error diagnostic 
because of this change.

rdar://problem/31783961
rdar://problem/19570630


https://reviews.llvm.org/D33606

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCXX/PR16677.cpp
  test/SemaCXX/invalid-template-params.cpp

Index: test/SemaCXX/invalid-template-params.cpp
===
--- /dev/null
+++ test/SemaCXX/invalid-template-params.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template class Foo {
+  template' in template-parameter-list}}
+   // expected-warning@-2 {{declaration does not declare anything}}
+};
+
+Foo::UBar g1; // expected-error {{no type named 'UBar' in 'Foo'}}
+
+class C0 {
+public:
+  template' in template-parameter-list}}
+// expected-warning@-3 {{declaration does not declare anything}}
+  C0() : m(new S0) {} // expected-error {{expected '(' for function-style cast or type construction}}
+   // expected-error@-1 {{expected expression}}
+  S0 *m; // expected-error {{expected member name or ';' after declaration specifiers}}
+};
Index: test/SemaCXX/PR16677.cpp
===
--- test/SemaCXX/PR16677.cpp
+++ test/SemaCXX/PR16677.cpp
@@ -10,7 +10,6 @@
 template { // expected-error{{'Derived' cannot be defined in a type specifier}}
   Class_With_Destructor member;
-}; // expected-error{{a non-type template parameter cannot have type 'class Derived'}}
-   // expected-error@-1{{expected ',' or '>' in template-parameter-list}}
-   // expected-warning@-2{{declaration does not declare anything}}
+}; // expected-error{{expected ',' or '>' in template-parameter-list}}
+   // expected-warning@-1{{declaration does not declare anything}}
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -8609,7 +8609,8 @@
 /*ModulePrivateLoc=*/SourceLocation(),
 MultiTemplateParamsArg(), Owned, IsDependent,
 SourceLocation(), false, TypeResult(),
-/*IsTypeSpecifier*/false);
+/*IsTypeSpecifier*/false,
+/*IsTemplateParamOrArg*/false);
   assert(!IsDependent && "explicit instantiation of dependent name not yet handled");
 
   if (!TagD)
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -13409,7 +13409,8 @@
   /*ScopedEnumKWLoc=*/SourceLocation(),
   /*ScopedEnumUsesClassTag=*/false,
   /*UnderlyingType=*/TypeResult(),
-  /*IsTypeSpecifier=*/false);
+  /*IsTypeSpecifier=*/false,
+  /*IsTemplateParamOrArg=*/false);
 }
 
 NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13035,7 +13035,8 @@
  SourceLocation ScopedEnumKWLoc,
  bool ScopedEnumUsesClassTag,
  TypeResult UnderlyingType,
- bool IsTypeSpecifier, SkipBodyInfo *SkipBody) {
+ bool IsTypeSpecifier, bool IsTemplateParamOrArg,
+ SkipBodyInfo *SkipBody) {
   // If this is not a definition, it must have a name.
   IdentifierInfo *OrigName = 

[PATCH] D33605: Provide an acccessor to get the Args of a ToolChain

2017-05-26 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

What's stopping anyone from removing this method as dead code?


Repository:
  rL LLVM

https://reviews.llvm.org/D33605



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


Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Arnold Schwaighofer via cfe-commits
No, my change should have no effect on LLVM CodeGen. I don’t see how a change 
to clang’s CodeGen i.e different module that cannot affect an llvm test using 
llc. This API is only used by swift calling convention lowering.

> On May 26, 2017, at 2:33 PM, Evgenii Stepanov  
> wrote:
> 
> I've got the same failure locally w/o MSan, in a regular
> release+assertions build on linux x86_64.
> 
> On Fri, May 26, 2017 at 2:15 PM, Vitaly Buka via cfe-commits
>  wrote:
>> Could this be the patch
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio
>> 
>> FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818)
>>  TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll'
>> FAILED 
>> Script:
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=armv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE
>> --check-prefix=ARM-ENABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=armv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE
>> --check-prefix=ARM-DISABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=thumbv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE
>> --check-prefix=THUMB-ENABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=thumbv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE
>> --check-prefix=THUMB-DISABLE
>> --
>> Exit Code: 1
>> 
>> Command Output (stderr):
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10:
>> error: expected string not found in input
>> ; CHECK: bl
>> ^
>> :375:7: note: scanning from here
>> vldr s0, LCPI12_0
>>  ^
>> :377:2: note: possible intended match here
>> bx lr
>> ^
>> 
>> 
>> 
>> On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits
>>  wrote:
>>> 
>>> Author: arnolds
>>> Date: Fri May 26 13:11:54 2017
>>> New Revision: 304017
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev
>>> Log:
>>> CodeGen: Define Swift's legal vector types for AArch64, ARM
>>> 
>>> rdar://32401301
>>> 
>>> Modified:
>>>cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>>cfe/trunk/test/CodeGen/64bit-swiftcall.c
>>>cfe/trunk/test/CodeGen/arm-swiftcall.c
>>> 
>>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
>>> @@ -4821,6 +4821,9 @@ private:
>>>   bool isSwiftErrorInRegister() const override {
>>> return true;
>>>   }
>>> +
>>> +  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
>>> + unsigned elts) const override;
>>> };
>>> 
>>> class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
>>> @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
>>>   return 

Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Evgenii Stepanov via cfe-commits
But I do not even have this change in my local checkout. Must be something else.

On Fri, May 26, 2017 at 2:33 PM, Evgenii Stepanov
 wrote:
> I've got the same failure locally w/o MSan, in a regular
> release+assertions build on linux x86_64.
>
> On Fri, May 26, 2017 at 2:15 PM, Vitaly Buka via cfe-commits
>  wrote:
>> Could this be the patch
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio
>>
>> FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818)
>>  TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll'
>> FAILED 
>> Script:
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=armv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE
>> --check-prefix=ARM-ENABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=armv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE
>> --check-prefix=ARM-DISABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=thumbv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE
>> --check-prefix=THUMB-ENABLE
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
>> -mtriple=thumbv7-apple-ios   |
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
>> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE
>> --check-prefix=THUMB-DISABLE
>> --
>> Exit Code: 1
>>
>> Command Output (stderr):
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10:
>> error: expected string not found in input
>> ; CHECK: bl
>>  ^
>> :375:7: note: scanning from here
>>  vldr s0, LCPI12_0
>>   ^
>> :377:2: note: possible intended match here
>>  bx lr
>>  ^
>>
>>
>>
>> On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits
>>  wrote:
>>>
>>> Author: arnolds
>>> Date: Fri May 26 13:11:54 2017
>>> New Revision: 304017
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev
>>> Log:
>>> CodeGen: Define Swift's legal vector types for AArch64, ARM
>>>
>>> rdar://32401301
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>> cfe/trunk/test/CodeGen/64bit-swiftcall.c
>>> cfe/trunk/test/CodeGen/arm-swiftcall.c
>>>
>>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
>>> @@ -4821,6 +4821,9 @@ private:
>>>bool isSwiftErrorInRegister() const override {
>>>  return true;
>>>}
>>> +
>>> +  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
>>> + unsigned elts) const override;
>>>  };
>>>
>>>  class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
>>> @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
>>>return false;
>>>  }
>>>
>>> +bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize,
>>> +   

[PATCH] D32817: [CMake] Build runtimes for Fuchsia targets

2017-05-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 100482.

Repository:
  rL LLVM

https://reviews.llvm.org/D32817

Files:
  cmake/caches/Fuchsia-stage2.cmake
  cmake/caches/Fuchsia.cmake


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,8 +38,12 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+if(FUCHSIA_x86_64_SYSROOT)
+  list(APPEND EXTRA_ARGS -DFUCHSIA_x86_64_SYSROOT=${FUCHSIA_x86_64_SYSROOT})
+endif()
+
+if(FUCHSIA_aarch64_SYSROOT)
+  list(APPEND EXTRA_ARGS -DFUCHSIA_aarch64_SYSROOT=${FUCHSIA_aarch64_SYSROOT})
 endif()
 
 # Setup the bootstrap build.
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -27,11 +27,31 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(LLVM_BUILTIN_TARGETS 
"default;x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+set(BUILTINS_x86_64-unknown-fuchsia_CMAKE_SYSROOT ${FUCHSIA_x86_64_SYSROOT} 
CACHE PATH "")
+set(BUILTINS_x86_64-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-unknown-fuchsia_CMAKE_SYSROOT ${FUCHSIA_aarch64_SYSROOT} 
CACHE PATH "")
+set(BUILTINS_aarch64-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+set(LLVM_RUNTIME_TARGETS 
"default;x86_64-unknown-fuchsia;aarch64-unknown-fuchsia" CACHE STRING "")
+
+set(RUNTIMES_x86_64-unknown-fuchsia_CMAKE_SYSROOT ${FUCHSIA_x86_64_SYSROOT} 
CACHE PATH "")
+set(RUNTIMES_x86_64-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(RUNTIMES_x86_64-unknown-fuchsia_UNIX 1 CACHE BOOL "")
+set(RUNTIMES_x86_64-unknown-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+set(RUNTIMES_x86_64-unknown-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_x86_64-unknown-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_x86_64-unknown-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL 
"")
+set(RUNTIMES_x86_64-unknown-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
+
+set(RUNTIMES_aarch64-unknown-fuchsia_CMAKE_SYSROOT ${FUCHSIA_aarch64_SYSROOT} 
CACHE PATH "")
+set(RUNTIMES_aarch64-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(RUNTIMES_aarch64-unknown-fuchsia_UNIX 1 CACHE BOOL "")
+set(RUNTIMES_aarch64-unknown-fuchsia_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
+set(RUNTIMES_aarch64-unknown-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL 
"")
+set(RUNTIMES_aarch64-unknown-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL 
"")
+set(RUNTIMES_aarch64-unknown-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL 
"")
+set(RUNTIMES_aarch64-unknown-fuchsia_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 
 # Setup toolchain.
 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
@@ -61,8 +81,7 @@
   LTO
   clang-format
   clang-headers
-  builtins-x86_64-fuchsia-none
-  builtins-aarch64-fuchsia-none
+  builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")


Index: cmake/caches/Fuchsia.cmake
===
--- cmake/caches/Fuchsia.cmake
+++ cmake/caches/Fuchsia.cmake
@@ -38,8 +38,12 @@
   install-distribution
   clang CACHE STRING "")
 
-if(FUCHSIA_SYSROOT)
-  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+if(FUCHSIA_x86_64_SYSROOT)
+  list(APPEND EXTRA_ARGS -DFUCHSIA_x86_64_SYSROOT=${FUCHSIA_x86_64_SYSROOT})
+endif()
+
+if(FUCHSIA_aarch64_SYSROOT)
+  list(APPEND EXTRA_ARGS -DFUCHSIA_aarch64_SYSROOT=${FUCHSIA_aarch64_SYSROOT})
 endif()
 
 # Setup the bootstrap build.
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -27,11 +27,31 @@
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
 
-set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
-set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia 

[PATCH] D33610: Stop asserting on constexpr explicit MS constructor calls.

2017-05-26 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
Herald added a subscriber: mcrosier.

When trying to switch to C++14 by default, some extra expressions become 
constexpr and this is one case we can't handle.

Technically I believe weakening the assert would be enough to fix the problem, 
but defaulted default constructors are extremely close to being allowed through 
which would lead to incorrect code (all of isDefaulted, isTrivial and hasFields 
contribute to the exclusion, as well as the fact that unions don't have default 
constructors). So I decided to explicitly check that we are dealing with a 
copy/move before executing that block.


https://reviews.llvm.org/D33610

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/constructor-direct-call.cpp


Index: clang/test/CodeGenCXX/constructor-direct-call.cpp
===
--- clang/test/CodeGenCXX/constructor-direct-call.cpp
+++ clang/test/CodeGenCXX/constructor-direct-call.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s 
-emit-llvm -o - -std=gnu++11| FileCheck %s
 
 class Test1 {
 public:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4184,18 +4184,27 @@
 
   CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data());
 
+  const CXXMethodDecl *MD = dyn_cast(Callee);
+  bool IsCopyOrMove = MD && MD->isCopyAssignmentOperator();
+  IsCopyOrMove |= MD && MD->isMoveAssignmentOperator();
+
+  // We support explicit constructor calls as an MS extension. These can be
+  // constexpr by C++11 rules.
+  auto CD = dyn_cast_or_null(MD);
+  IsCopyOrMove |= CD && CD->isCopyConstructor();
+  IsCopyOrMove |= CD && CD->isMoveConstructor();
+
   // For a trivial copy or move assignment, perform an APValue copy. This is
   // essential for unions, where the operations performed by the assignment
   // operator cannot be represented as statements.
   //
   // Skip this for non-union classes with no fields; in that case, the 
defaulted
   // copy/move does not actually read the object.
-  const CXXMethodDecl *MD = dyn_cast(Callee);
-  if (MD && MD->isDefaulted() &&
+  if (MD && MD->isDefaulted() && IsCopyOrMove &&
   (MD->getParent()->isUnion() ||
(MD->isTrivial() && hasFields(MD->getParent() {
-assert(This &&
-   (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()));
+assert(This);
+
 LValue RHS;
 RHS.setFrom(Info.Ctx, ArgValues[0]);
 APValue RHSValue;


Index: clang/test/CodeGenCXX/constructor-direct-call.cpp
===
--- clang/test/CodeGenCXX/constructor-direct-call.cpp
+++ clang/test/CodeGenCXX/constructor-direct-call.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - -std=gnu++11| FileCheck %s
 
 class Test1 {
 public:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4184,18 +4184,27 @@
 
   CallStackFrame Frame(Info, CallLoc, Callee, This, ArgValues.data());
 
+  const CXXMethodDecl *MD = dyn_cast(Callee);
+  bool IsCopyOrMove = MD && MD->isCopyAssignmentOperator();
+  IsCopyOrMove |= MD && MD->isMoveAssignmentOperator();
+
+  // We support explicit constructor calls as an MS extension. These can be
+  // constexpr by C++11 rules.
+  auto CD = dyn_cast_or_null(MD);
+  IsCopyOrMove |= CD && CD->isCopyConstructor();
+  IsCopyOrMove |= CD && CD->isMoveConstructor();
+
   // For a trivial copy or move assignment, perform an APValue copy. This is
   // essential for unions, where the operations performed by the assignment
   // operator cannot be represented as statements.
   //
   // Skip this for non-union classes with no fields; in that case, the defaulted
   // copy/move does not actually read the object.
-  const CXXMethodDecl *MD = dyn_cast(Callee);
-  if (MD && MD->isDefaulted() &&
+  if (MD && MD->isDefaulted() && IsCopyOrMove &&
   (MD->getParent()->isUnion() ||
(MD->isTrivial() && hasFields(MD->getParent() {
-assert(This &&
-   (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()));
+assert(This);
+
 LValue RHS;
 RHS.setFrom(Info.Ctx, ArgValues[0]);
 APValue RHSValue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33526: Fix spurious Wunused-lambda-capture warning

2017-05-26 Thread Yi Kong via Phabricator via cfe-commits
kongyi added inline comments.



Comment at: lib/Sema/SemaLambda.cpp:1524-1526
+  if (!CurContext->isDependentContext() && !IsImplicit)
+if ((IsGenericLambda && !From.isNonODRUsed()) ||
+(!IsGenericLambda && !From.isODRUsed()))

malcolm.parsons wrote:
> Should generic lambdas and lambdas in a dependent context be treated the same?
> 
> Is a lambda inside a generic lambda in a dependent context?
Generic lambdas are essentially templated lambdas. For diagnosing unused 
captures, they can be treated as the same. However we are not generating 
diagnoses within dependent contexts right now (L1524), so this is not really 
related to this fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D33526



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


Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Evgenii Stepanov via cfe-commits
I've got the same failure locally w/o MSan, in a regular
release+assertions build on linux x86_64.

On Fri, May 26, 2017 at 2:15 PM, Vitaly Buka via cfe-commits
 wrote:
> Could this be the patch
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio
>
> FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818)
>  TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll'
> FAILED 
> Script:
> --
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
> -mtriple=armv7-apple-ios   |
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> --check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE
> --check-prefix=ARM-ENABLE
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
> -mtriple=armv7-apple-ios   |
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> --check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE
> --check-prefix=ARM-DISABLE
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> -o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
> -mtriple=thumbv7-apple-ios   |
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE
> --check-prefix=THUMB-ENABLE
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> -o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
> -mtriple=thumbv7-apple-ios   |
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
> --check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE
> --check-prefix=THUMB-DISABLE
> --
> Exit Code: 1
>
> Command Output (stderr):
> --
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10:
> error: expected string not found in input
> ; CHECK: bl
>  ^
> :375:7: note: scanning from here
>  vldr s0, LCPI12_0
>   ^
> :377:2: note: possible intended match here
>  bx lr
>  ^
>
>
>
> On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits
>  wrote:
>>
>> Author: arnolds
>> Date: Fri May 26 13:11:54 2017
>> New Revision: 304017
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev
>> Log:
>> CodeGen: Define Swift's legal vector types for AArch64, ARM
>>
>> rdar://32401301
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> cfe/trunk/test/CodeGen/64bit-swiftcall.c
>> cfe/trunk/test/CodeGen/arm-swiftcall.c
>>
>> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
>> @@ -4821,6 +4821,9 @@ private:
>>bool isSwiftErrorInRegister() const override {
>>  return true;
>>}
>> +
>> +  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
>> + unsigned elts) const override;
>>  };
>>
>>  class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
>> @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
>>return false;
>>  }
>>
>> +bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize,
>> +   llvm::Type *eltTy,
>> +   unsigned elts) const {
>> +  if (!llvm::isPowerOf2_32(elts))
>> +return false;
>> +  if (totalSize.getQuantity() != 8 &&
>> +  (totalSize.getQuantity() != 16 || elts == 1))
>> +return false;
>> + 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D29877#765968, @EricWF wrote:

> I think this patch still gets the following case wrong:
>
>   // foo.h
>   constexpr struct {
> template  void operator()(T) {} // emits unused template warning
>   } foo;
>


What specifically do you think is wrong here? There is an unused internal 
linkage function template here. If we want to warn on unused internal linkage 
templates declared in headers, we should warn on this one.

Note that any use of `foo` here from an inline function would result in ODR 
violations (because you get a different `foo` in each translation unit), so 
it's probably at least a bad idea to do that. We could suppress this warning 
for unused internal linkage templates declared in headers, or maybe move that 
to a separate warning flag; can you point us at some code that does this in 
practice and isn't wrong?


https://reviews.llvm.org/D29877



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


[PATCH] D33509: [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies

2017-05-26 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

I do not have commit access yet, so I cannot commit this patch myself. Can you 
please check it in for me?


https://reviews.llvm.org/D33509



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D29877#766196, @EricWF wrote:

> No. But I can point you to `range-v3` which uses this pattern and I think the 
> idiom is somewhat appealing, but that's orthogonal to Clang diagnosing it.


I found this:

https://github.com/ericniebler/range-v3/blob/a4829172c0d6c43687ba213c54f430202efd7497/include/range/v3/view/zip_with.hpp#L44

This code is wrong, and creates ODR violations on lines 190 and 200.

It seems to me that the warning is firing on dangerous / broken code (yay!) but 
the warning is not sufficient to explain *why* the code is broken (boo!). It 
also seems to me that the reason why we flag up this code is not really related 
to the reason why this code is broken, and we should probably have a separate 
diagnostic for using an internal linkage entity from within an entity to which 
the ODR applies that is defined within a header. If we had such a diagnostic, 
it would seem reasonable to limit this warning to only apply to code that is 
*not* in a header file -- but see PR22712 for a case where even that is not 
quite enough.


https://reviews.llvm.org/D29877



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


[PATCH] D33616: [MS] Fix _bittest* intrinsics for values bigger than 31

2017-05-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.

These intrinsics are supposed to select to BT, BTS, etc instructions.
Those instructions actually perform a bitwise array indexing memory
operation that LLVM doesn't currently expose.  This change implements
the shifting and array indexing in plain C.

Fixes PR33188

If we ever fix PR19164, then the array indexing should be pattern
matched to BT and BTS memory instructions as appropriate.


https://reviews.llvm.org/D33616

Files:
  clang/lib/Headers/intrin.h


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -342,68 +342,92 @@
 
\**/
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   return (*_BitBase >> _BitPos) & 1;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandcomplement(long *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase ^ (1 << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandreset(long *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase & ~(1 << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandset(long *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase | (1 << _BitPos);
   return _Res;
 }
 #if defined(__arm__) || defined(__aarch64__)
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE);
   return (_PrevVal >> _BitPos) & 1;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _interlockedbittestandset_nf(long volatile *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELAXED);
   return (_PrevVal >> _BitPos) & 1;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _interlockedbittestandset_rel(long volatile *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELEASE);
   return (_PrevVal >> _BitPos) & 1;
 }
 #endif
 #ifdef __x86_64__
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest64(__int64 const *_BitBase, __int64 _BitPos) {
+  _BitBase += (_BitPos / 64);
+  _BitPos %= 64;
   return (*_BitBase >> _BitPos) & 1;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandcomplement64(__int64 *_BitBase, __int64 _BitPos) {
+  _BitBase += (_BitPos / 64);
+  _BitPos %= 64;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase ^ (1ll << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandreset64(__int64 *_BitBase, __int64 _BitPos) {
+  _BitBase += (_BitPos / 64);
+  _BitPos %= 64;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase & ~(1ll << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandset64(__int64 *_BitBase, __int64 _BitPos) {
+  _BitBase += (_BitPos / 64);
+  _BitPos %= 64;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase | (1ll << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _interlockedbittestandset64(__int64 volatile *_BitBase, __int64 _BitPos) {
+  _BitBase += (_BitPos / 64);
+  _BitPos %= 64;
   long long _PrevVal =
   __atomic_fetch_or(_BitBase, 1ll << _BitPos, __ATOMIC_SEQ_CST);
   return (_PrevVal >> _BitPos) & 1;


Index: clang/lib/Headers/intrin.h
===
--- clang/lib/Headers/intrin.h
+++ clang/lib/Headers/intrin.h
@@ -342,68 +342,92 @@
 \**/
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittest(long const *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   return (*_BitBase >> _BitPos) & 1;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandcomplement(long *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase ^ (1 << _BitPos);
   return _Res;
 }
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _bittestandreset(long *_BitBase, long _BitPos) {
+  _BitBase += (_BitPos / 32);
+  _BitPos %= 32;
   unsigned char _Res = (*_BitBase >> _BitPos) & 1;
   *_BitBase = *_BitBase 

[PATCH] D30538: Add documentation for -fno-strict-aliasing

2017-05-26 Thread Simon Byrne via Phabricator via cfe-commits
simonbyrne updated this revision to Diff 100430.
simonbyrne added a comment.

Fix capitalisation.


https://reviews.llvm.org/D30538

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1098,6 +1098,14 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -f[no-]strict-aliasing
+
+   Enables/disables the strict aliasing assumption, which assumes that
+   objects of different types do not share the same location in memory.
+
+   NOTE: Unlike gcc, clang does not allow "type-punning" by writing and
+   reading from different union members without `-fno-strict-aliasing`
+   enabled.
 
 .. option:: -fstrict-vtable-pointers
 


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -1098,6 +1098,14 @@
the behavior of sanitizers in the ``cfi`` group to allow checking
of cross-DSO virtual and indirect calls.
 
+.. option:: -f[no-]strict-aliasing
+
+   Enables/disables the strict aliasing assumption, which assumes that
+   objects of different types do not share the same location in memory.
+
+   NOTE: Unlike gcc, clang does not allow "type-punning" by writing and
+   reading from different union members without `-fno-strict-aliasing`
+   enabled.
 
 .. option:: -fstrict-vtable-pointers
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33525: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-05-26 Thread Tim Shen via Phabricator via cfe-commits
timshen marked an inline comment as done.
timshen added a comment.

In https://reviews.llvm.org/D33525#764251, @chandlerc wrote:

> (focusing on the LLVM side of this review for now)
>
> Can you add an LLVM-based test? Can you add this to 
> `lib/Passes/PassRegistry.def`?


Talked offline. Given the fact that BitcodeWriter (and possibly assembly 
writer?) is not registered either, it seems to be a larger issue that's out of 
the scope of this patch.


https://reviews.llvm.org/D33525



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


Re: r304012 - Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86

2017-05-26 Thread Martell Malone via cfe-commits
Thanks Reid for looking at this today

On Fri, May 26, 2017 at 6:38 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Fri May 26 12:38:15 2017
> New Revision: 304012
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304012=rev
> Log:
> Enable __float128 for mingw for GCC compatibility and define
> __SIZEOF_FLOAT128__ on x86
>
> GCC defines __FLOAT128__ on Power and __SIZEOF_FLOAT128__ on x86. We're
> just following the inconsistency for now so users have some way to test.
>
> Effectively merges this patch as requested by Martell Malone:
> https://github.com/Alexpux/MINGW-packages/blob/master/
> mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Sema/128bitfloat.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/
> Targets.cpp?rev=304012=304011=304012=diff
> 
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Fri May 26 12:38:15 2017
> @@ -4644,7 +4644,9 @@ static void addMinGWDefines(const LangOp
>  class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
>  public:
>MinGWX86_32TargetInfo(const llvm::Triple , const TargetOptions
> )
> -  : WindowsX86_32TargetInfo(Triple, Opts) {}
> +  : WindowsX86_32TargetInfo(Triple, Opts) {
> +HasFloat128 = true;
> +  }
>void getTargetDefines(const LangOptions ,
>  MacroBuilder ) const override {
>  WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
> @@ -4936,6 +4938,7 @@ public:
>  // with x86 FP ops. Weird.
>  LongDoubleWidth = LongDoubleAlign = 128;
>  LongDoubleFormat = ::APFloat::x87DoubleExtended();
> +HasFloat128 = true;
>}
>
>void getTargetDefines(const LangOptions ,
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/InitPreprocessor.cpp?rev=304012=304011=304012=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri May 26 12:38:15 2017
> @@ -750,6 +750,8 @@ static void InitializePredefinedMacros(c
> TI.getTypeWidth(TI.getWIntType()), TI, Builder);
>if (TI.hasInt128Type())
>  DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder);
> +  if (TI.hasFloat128Type())
> +DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder);
>
>DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder);
>DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder);
>
> Modified: cfe/trunk/test/Sema/128bitfloat.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/
> 128bitfloat.cpp?rev=304012=304011=304012=diff
> 
> ==
> --- cfe/trunk/test/Sema/128bitfloat.cpp (original)
> +++ cfe/trunk/test/Sema/128bitfloat.cpp Fri May 26 12:38:15 2017
> @@ -1,7 +1,11 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
> -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
> +// RUN: %clang_cc1 -verify -std=gnu++11 %s
> +// RUN: %clang_cc1 -verify -std=c++11 %s
> +// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s
> +// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
> +// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
> +// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
>
> -#ifdef __FLOAT128__
> +#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
>  __float128 f;
>  template struct __is_floating_point_helper {};
>  template<> struct __is_floating_point_helper<__float128> {};
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-26 Thread Richard Smith via cfe-commits
On 26 May 2017 at 10:34, Tim Northover via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 24 May 2017 at 17:54, Richard Smith  wrote:
> > Yikes :-( Maybe libc++ *should* have that extension then. It sounds like
> > we'll silently get the wrong value for any attempt at std::complex /
> > _Complex interop right now:
>
> That sounds like a pretty good idea whatever we decide to do about the
> literals.
>
> But we do need to sort out what we're going to do here. I quite like
> the approach you suggested, and think it's an improvement worth
> putting in for gnu++ modes regardless.
>
> So the remaining question is what we should do for the
> standards-compliant C++ modes. We seem to have 3 plausible options:
>
> 1. Bar it everywhere. It's an extension.
> 2. Bar it for C++14 onwards, where the standard provides literals.
> 3. Allow it everywhere.
>
> Although 2 would be the most conservative option (it maintains all
> existing behaviour), it's my least favourite for the added complexity
> and quirkiness.
>
> My original inclination is to go with Marshall and pick 1, but it's a
> very weak preference and I know I tend to be a bit user-hostile in
> these situations.
>
> So, how do we resolve this. Does anyone else have opinions?


Generally I'd also side towards 1, but in this instance that would mean
we're removing a conforming extension that prior versions of clang
supported in C++98 and C++11 modes, with no way to get the extension back
other than turning on the full set of (non-conforming) GNU extensions.

I quite like the approach we take to MS extensions: we have two separate
flags for the conforming and non-conforming extensions. For GNU extensions,
we generally do the same, where the conforming extensions are enabled by
default (with no way to turn them off other than -pedantic-errors or
-Werror=gnu!) and the non-conforming extension controlled by -std=gnu* vs
-std=c* ("GNU mode"). (In the longer term, I'd like to replicate the MS
pattern for the GNU extensions, with -fgnu-extensions controlling the
conforming extensions and -fgnu-compatibility controlling the
non-conforming extensions.)

If we generally think that distinction is a good thing, then (because this
is a conforming extension) consistency weakly suggests that it should not
be controlled by GNU mode. But I don't find that argument decisive; the
important thing is that we don't enable non-conforming extensions by
default in non-GNU (and non-MS-compat) modes, not that GNU mode consists of
/only/ non-conforming extensions.

Given that we probably want to retain a way to enable this outside GNU
mode, if we go for 1, then we would want a separate flag to enable it, and
then the difference between 1 and 3 is whether it's a -f flag or a -W flag.
The latter is our normal choice for such conforming extensions.


Looking at the

  std::complex x = 1.0if;

case again, I think there's another problem here: we support an implicit
conversion from _Complex float to float in C++ (without even a warning).
This conversion is valid in C, but at least GCC disallows it in its C++
mode. We should probably at least warn on that.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304012 - Enable __float128 for mingw for GCC compatibility and define __SIZEOF_FLOAT128__ on x86

2017-05-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri May 26 12:38:15 2017
New Revision: 304012

URL: http://llvm.org/viewvc/llvm-project?rev=304012=rev
Log:
Enable __float128 for mingw for GCC compatibility and define 
__SIZEOF_FLOAT128__ on x86

GCC defines __FLOAT128__ on Power and __SIZEOF_FLOAT128__ on x86. We're
just following the inconsistency for now so users have some way to test.

Effectively merges this patch as requested by Martell Malone:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-clang/0107-enable-__float128-for-X86-MinGW.patch

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Sema/128bitfloat.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304012=304011=304012=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 26 12:38:15 2017
@@ -4644,7 +4644,9 @@ static void addMinGWDefines(const LangOp
 class MinGWX86_32TargetInfo : public WindowsX86_32TargetInfo {
 public:
   MinGWX86_32TargetInfo(const llvm::Triple , const TargetOptions )
-  : WindowsX86_32TargetInfo(Triple, Opts) {}
+  : WindowsX86_32TargetInfo(Triple, Opts) {
+HasFloat128 = true;
+  }
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
@@ -4936,6 +4938,7 @@ public:
 // with x86 FP ops. Weird.
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = ::APFloat::x87DoubleExtended();
+HasFloat128 = true;
   }
 
   void getTargetDefines(const LangOptions ,

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=304012=304011=304012=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri May 26 12:38:15 2017
@@ -750,6 +750,8 @@ static void InitializePredefinedMacros(c
TI.getTypeWidth(TI.getWIntType()), TI, Builder);
   if (TI.hasInt128Type())
 DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder);
+  if (TI.hasFloat128Type())
+DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder);
 
   DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder);
   DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder);

Modified: cfe/trunk/test/Sema/128bitfloat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/128bitfloat.cpp?rev=304012=304011=304012=diff
==
--- cfe/trunk/test/Sema/128bitfloat.cpp (original)
+++ cfe/trunk/test/Sema/128bitfloat.cpp Fri May 26 12:38:15 2017
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -verify -std=gnu++11 %s
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple powerpc64-linux -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
 
-#ifdef __FLOAT128__
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
 __float128 f;
 template struct __is_floating_point_helper {};
 template<> struct __is_floating_point_helper<__float128> {};


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


r304013 - Only define __SIZEOF_FLOAT128__ on x86 as intended in r304012

2017-05-26 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri May 26 12:48:01 2017
New Revision: 304013

URL: http://llvm.org/viewvc/llvm-project?rev=304013=rev
Log:
Only define __SIZEOF_FLOAT128__ on x86 as intended in r304012

GCC only defines it on x86.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=304013=304012=304013=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May 26 12:48:01 2017
@@ -4165,6 +4165,9 @@ void X86TargetInfo::getTargetDefines(con
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (HasFloat128)
+Builder.defineMacro("__SIZEOF_FLOAT128__", "16");
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=304013=304012=304013=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Fri May 26 12:48:01 2017
@@ -750,8 +750,6 @@ static void InitializePredefinedMacros(c
TI.getTypeWidth(TI.getWIntType()), TI, Builder);
   if (TI.hasInt128Type())
 DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder);
-  if (TI.hasFloat128Type())
-DefineTypeSizeof("__SIZEOF_FLOAT128__", 128, TI, Builder);
 
   DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder);
   DefineFmt("__INTMAX", TI.getIntMaxType(), TI, Builder);


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


[PATCH] D30538: Add documentation for -fno-strict-aliasing

2017-05-26 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.

LGTM, though it would be nice if we implemented gcc's extension for this at 
some point... ;)


https://reviews.llvm.org/D30538



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


[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

> ! In https://reviews.llvm.org/D33082#765898, @EricWF wrote:
>  I removed the section you're referring to because it's unneeded. 
> `<__locale>` does the exact same `#include` dance. and `` includes 
> `<__locale>`.
>  It should not have an affect on functionality.

It that case it just ignore my previous comment. LGTM


https://reviews.llvm.org/D33082



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


r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Arnold Schwaighofer via cfe-commits
Author: arnolds
Date: Fri May 26 13:11:54 2017
New Revision: 304017

URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev
Log:
CodeGen: Define Swift's legal vector types for AArch64, ARM

rdar://32401301

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/64bit-swiftcall.c
cfe/trunk/test/CodeGen/arm-swiftcall.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=304017=304016=304017=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
@@ -4821,6 +4821,9 @@ private:
   bool isSwiftErrorInRegister() const override {
 return true;
   }
+
+  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
+ unsigned elts) const override;
 };
 
 class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
@@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
   return false;
 }
 
+bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize,
+   llvm::Type *eltTy,
+   unsigned elts) const {
+  if (!llvm::isPowerOf2_32(elts))
+return false;
+  if (totalSize.getQuantity() != 8 &&
+  (totalSize.getQuantity() != 16 || elts == 1))
+return false;
+  return true;
+}
+
 bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
   // Homogeneous aggregates for AAPCS64 must have base types of a floating
   // point type or a short-vector type. This is the same as the 32-bit ABI,
@@ -5382,6 +5396,8 @@ private:
   bool isSwiftErrorInRegister() const override {
 return true;
   }
+  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
+ unsigned elts) const override;
 };
 
 class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
@@ -5894,6 +5910,20 @@ bool ARMABIInfo::isIllegalVectorType(Qua
   return false;
 }
 
+bool ARMABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize,
+   llvm::Type *eltTy,
+   unsigned numElts) const {
+  if (!llvm::isPowerOf2_32(numElts))
+return false;
+  unsigned size = getDataLayout().getTypeStoreSizeInBits(eltTy);
+  if (size > 64)
+return false;
+  if (vectorSize.getQuantity() != 8 &&
+  (vectorSize.getQuantity() != 16 || numElts == 1))
+return false;
+  return true;
+}
+
 bool ARMABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
   // Homogeneous aggregates for AAPCS-VFP must have base types of float,
   // double, or 64-bit or 128-bit vectors.

Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=304017=304016=304017=diff
==
--- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original)
+++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Fri May 26 13:11:54 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm 
-o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o 
- %s | FileCheck %s --check-prefix=ARM64
 
 // REQUIRES: aarch64-registered-target,x86-registered-target
 
@@ -60,6 +61,7 @@ SWIFTCALL void context_error_2(short s,
 /** LOWERING */
 /*/
 
+typedef float float3 __attribute__((ext_vector_type(3)));
 typedef float float4 __attribute__((ext_vector_type(4)));
 typedef float float8 __attribute__((ext_vector_type(8)));
 typedef double double2 __attribute__((ext_vector_type(2)));
@@ -1005,3 +1007,10 @@ struct {
 TEST(union_het_vecint)
 // CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias 
sret
 // CHECK: define swiftcc void @take_union_het_vecint([[UNION]]*
+
+typedef struct {
+  float3 f3;
+} struct_v1f3;
+TEST(struct_v1f3)
+// ARM64-LABEL: define swiftcc { <2 x float>, float } @return_struct_v1f3()
+// ARM64-LABEL: define swiftcc void @take_struct_v1f3(<2 x float>, float)

Modified: cfe/trunk/test/CodeGen/arm-swiftcall.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-swiftcall.c?rev=304017=304016=304017=diff
==
--- cfe/trunk/test/CodeGen/arm-swiftcall.c (original)
+++ cfe/trunk/test/CodeGen/arm-swiftcall.c Fri May 26 13:11:54 2017
@@ -57,6 +57,7 @@ SWIFTCALL void context_error_2(short s,
 /** LOWERING */
 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I think this patch still gets the following case wrong:

  // foo.h
  constexpr struct {
template  void operator()(T) {} // emits unused template warning
  } foo;


https://reviews.llvm.org/D29877



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


r304025 - [scan-build] Patch to scan-build tool to support "--target=" flag

2017-05-26 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri May 26 14:25:32 2017
New Revision: 304025

URL: http://llvm.org/viewvc/llvm-project?rev=304025=rev
Log:
[scan-build] Patch to scan-build tool to support "--target=" flag

The scan-build script provided by clang can be used to detect defects in
code in the compile time. However, we discovered that the
"--target=" flag in clang is not properly handled by this script,
which results in failures when analyzing projects that have used this
flag in their makefile.

This single line of change allows scan-build script to properly handle
the "--target=" flag.

Patch by Haowei Wu

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

Modified:
cfe/trunk/tools/scan-build/libexec/ccc-analyzer

Modified: cfe/trunk/tools/scan-build/libexec/ccc-analyzer
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/libexec/ccc-analyzer?rev=304025=304024=304025=diff
==
--- cfe/trunk/tools/scan-build/libexec/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/libexec/ccc-analyzer Fri May 26 14:25:32 2017
@@ -385,7 +385,8 @@ my %CompilerLinkerOptionMap = (
   '-target' => 1,
   '-v' => 0,
   '-mmacosx-version-min' => 0, # This is really a 1 argument, but always has 
'='
-  '-miphoneos-version-min' => 0 # This is really a 1 argument, but always has 
'='
+  '-miphoneos-version-min' => 0, # This is really a 1 argument, but always has 
'='
+  '--target' => 0
 );
 
 my %IgnoredOptionMap = (


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


[PATCH] D33263: [scan-build] Patch to scan-build tool to support "--target=" flag

2017-05-26 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304025: [scan-build] Patch to scan-build tool to support 
"--target=" flag (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D33263?vs=99219=100450#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33263

Files:
  cfe/trunk/tools/scan-build/libexec/ccc-analyzer


Index: cfe/trunk/tools/scan-build/libexec/ccc-analyzer
===
--- cfe/trunk/tools/scan-build/libexec/ccc-analyzer
+++ cfe/trunk/tools/scan-build/libexec/ccc-analyzer
@@ -385,7 +385,8 @@
   '-target' => 1,
   '-v' => 0,
   '-mmacosx-version-min' => 0, # This is really a 1 argument, but always has 
'='
-  '-miphoneos-version-min' => 0 # This is really a 1 argument, but always has 
'='
+  '-miphoneos-version-min' => 0, # This is really a 1 argument, but always has 
'='
+  '--target' => 0
 );
 
 my %IgnoredOptionMap = (


Index: cfe/trunk/tools/scan-build/libexec/ccc-analyzer
===
--- cfe/trunk/tools/scan-build/libexec/ccc-analyzer
+++ cfe/trunk/tools/scan-build/libexec/ccc-analyzer
@@ -385,7 +385,8 @@
   '-target' => 1,
   '-v' => 0,
   '-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '='
-  '-miphoneos-version-min' => 0 # This is really a 1 argument, but always has '='
+  '-miphoneos-version-min' => 0, # This is really a 1 argument, but always has '='
+  '--target' => 0
 );
 
 my %IgnoredOptionMap = (
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r304026 - [libcxxabi] iconv is not needed for mingw-w64

2017-05-26 Thread Martell Malone via cfe-commits
Author: martell
Date: Fri May 26 14:39:39 2017
New Revision: 304026

URL: http://llvm.org/viewvc/llvm-project?rev=304026=rev
Log:
[libcxxabi] iconv is not needed for mingw-w64

Modified:
libcxxabi/trunk/cmake/config-ix.cmake

Modified: libcxxabi/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=304026=304025=304026=diff
==
--- libcxxabi/trunk/cmake/config-ix.cmake (original)
+++ libcxxabi/trunk/cmake/config-ix.cmake Fri May 26 14:39:39 2017
@@ -36,7 +36,7 @@ if (LIBCXXABI_HAS_NODEFAULTLIBS_FLAG)
   set(MINGW_RUNTIME gcc_s gcc)
 endif()
 set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt 
advapi32
-shell32 user32 kernel32 iconv mingw32 ${MINGW_RUNTIME}
+shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
 moldname mingwex msvcrt)
 list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
   endif()


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


r304028 - Make helper functions static. NFC.

2017-05-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 26 15:08:24 2017
New Revision: 304028

URL: http://llvm.org/viewvc/llvm-project?rev=304028=rev
Log:
Make helper functions static. NFC.

Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/Frontend/TextDiagnostic.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=304028=304027=304028=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Fri May 26 15:08:24 2017
@@ -448,8 +448,8 @@ const Attr *Decl::getDefiningAttr() cons
   return nullptr;
 }
 
-StringRef getRealizedPlatform(const AvailabilityAttr *A,
-  const ASTContext ) {
+static StringRef getRealizedPlatform(const AvailabilityAttr *A,
+ const ASTContext ) {
   // Check if this is an App Extension "platform", and if so chop off
   // the suffix for matching with the actual platform.
   StringRef RealizedPlatform = A->getPlatform()->getName();

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=304028=304027=304028=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri May 26 15:08:24 2017
@@ -1243,10 +1243,10 @@ static void emitReductionListCopy(
 ///local = local @ remote
 ///  else
 ///local = remote
-llvm::Value *emitReduceScratchpadFunction(CodeGenModule ,
-  ArrayRef Privates,
-  QualType ReductionArrayTy,
-  llvm::Value *ReduceFn) {
+static llvm::Value *
+emitReduceScratchpadFunction(CodeGenModule ,
+ ArrayRef Privates,
+ QualType ReductionArrayTy, llvm::Value *ReduceFn) 
{
   auto  = CGM.getContext();
   auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);
 
@@ -1372,9 +1372,9 @@ llvm::Value *emitReduceScratchpadFunctio
 ///  for elem in Reduce List:
 ///scratchpad[elem_id][index] = elem
 ///
-llvm::Value *emitCopyToScratchpad(CodeGenModule ,
-  ArrayRef Privates,
-  QualType ReductionArrayTy) {
+static llvm::Value *emitCopyToScratchpad(CodeGenModule ,
+ ArrayRef Privates,
+ QualType ReductionArrayTy) {
 
   auto  = CGM.getContext();
   auto Int32Ty = C.getIntTypeForBitwidth(32, /* Signed */ true);

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=304028=304027=304028=diff
==
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Fri May 26 15:08:24 2017
@@ -945,9 +945,9 @@ findLinesForRange(const CharSourceRange
 
 /// Add as much of range B into range A as possible without exceeding a maximum
 /// size of MaxRange. Ranges are inclusive.
-std::pair maybeAddRange(std::pair A,
-std::pair B,
-unsigned MaxRange) {
+static std::pair
+maybeAddRange(std::pair A, std::pair B,
+  unsigned MaxRange) {
   // If A is already the maximum size, we're done.
   unsigned Slack = MaxRange - (A.second - A.first + 1);
   if (Slack == 0)

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=304028=304027=304028=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri May 26 15:08:24 2017
@@ -238,7 +238,7 @@ static typename std::enable_ifhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304030 - Remove unused diagnostics. NFC.

2017-05-26 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri May 26 15:14:12 2017
New Revision: 304030

URL: http://llvm.org/viewvc/llvm-project?rev=304030=rev
Log:
Remove unused diagnostics. NFC.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304030=304029=304030=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 26 15:14:12 
2017
@@ -1557,8 +1557,6 @@ def note_member_synthesized_at : Note<
   "in implicit %select{default constructor|copy constructor|move constructor|"
   "copy assignment operator|move assignment operator|destructor}0 for %1 "
   "first required here">;
-def note_inhctor_synthesized_at : Note<
-  "inherited constructor for %0 first required here">;
 def err_missing_default_ctor : Error<
   "%select{constructor for %1 must explicitly initialize the|"
   "implicit default constructor for %1 must explicitly initialize the|"
@@ -8909,8 +8907,6 @@ def note_equivalent_internal_linkage_dec
 
 def note_redefinition_modules_same_file : Note<
"'%0' included multiple times, additional include site in header from 
module '%1'">;
-def note_redefinition_modules_same_file_modulemap : Note<
-   "consider adding '%0' as part of '%1' definition">;
 def note_redefinition_include_same_file : Note<
"'%0' included multiple times, additional include site here">;
 }


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


[PATCH] D33525: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-05-26 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 100462.
timshen added a comment.

Change the test case.


https://reviews.llvm.org/D33525

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thin_link_bitcode.c
  llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp

Index: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
===
--- llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -7,13 +7,11 @@
 //
 //===--===//
 //
-// This pass prepares a module containing type metadata for ThinLTO by splitting
-// it into regular and thin LTO parts if possible, and writing both parts to
-// a multi-module bitcode file. Modules that do not contain type metadata are
-// written unmodified as a single module.
+// Pass implementation.
 //
 //===--===//
 
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Analysis/BasicAliasAnalysis.h"
 #include "llvm/Analysis/ModuleSummaryAnalysis.h"
 #include "llvm/Analysis/ProfileSummaryInfo.h"
@@ -436,3 +434,15 @@
 raw_ostream *ThinLinkOS) {
   return new WriteThinLTOBitcode(Str, ThinLinkOS);
 }
+
+PreservedAnalyses
+llvm::ThinLTOBitcodeWriterPass::run(Module , ModuleAnalysisManager ) {
+  FunctionAnalysisManager  =
+  AM.getResult(M).getManager();
+  writeThinLTOBitcode(OS, ThinLinkOS,
+  [](Function ) -> AAResults & {
+return FAM.getResult(F);
+  },
+  M, (M));
+  return PreservedAnalyses::all();
+}
Index: llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
===
--- /dev/null
+++ llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
@@ -0,0 +1,39 @@
+//===- ThinLTOBitcodeWriter.h - Bitcode writing pass for ThinLTO --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This pass prepares a module containing type metadata for ThinLTO by splitting
+// it into regular and thin LTO parts if possible, and writing both parts to
+// a multi-module bitcode file. Modules that do not contain type metadata are
+// written unmodified as a single module.
+//
+//===--===//
+
+#ifndef LLVM_TRANSFORMS_IPO_THINLTOBITCODEWRITER_H
+#define LLVM_TRANSFORMS_IPO_THINLTOBITCODEWRITER_H
+
+#include 
+#include 
+
+namespace llvm {
+
+class ThinLTOBitcodeWriterPass
+: public PassInfoMixin {
+  raw_ostream 
+  raw_ostream *ThinLinkOS;
+
+public:
+  ThinLTOBitcodeWriterPass(raw_ostream , raw_ostream *ThinLinkOS)
+  : OS(OS), ThinLinkOS(ThinLinkOS) {}
+
+  PreservedAnalyses run(Module , ModuleAnalysisManager );
+};
+
+} // namespace llvm
+
+#endif
Index: clang/test/CodeGen/thin_link_bitcode.c
===
--- clang/test/CodeGen/thin_link_bitcode.c
+++ clang/test/CodeGen/thin_link_bitcode.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s
 // RUN: llvm-bcanalyzer -dump %t | FileCheck %s
 // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG
+// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager -fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited  %s
+// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s
+// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s --check-prefix=NO_DEBUG
 int main (void) {
   return 0;
 }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,7 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -898,16 +899,32 @@
   // create that pass manager here and use it as needed below.
   legacy::PassManager CodeGenPasses;
   bool NeedCodeGen = false;
+  Optional ThinLinkOS;
 
   // Append any output we need to the pass manager.
   switch (Action) {
   case Backend_EmitNothing:
 break;
 
   case Backend_EmitBC:
-MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
- 

[PATCH] D33588: Fix two sources of UB in __next_hash_pow2 (from __hash_table)

2017-05-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 100461.
vsk edited the summary of this revision.
vsk added a comment.

Thanks @EricWF for pointing me to the right place to add a test. I've tried to 
follow the style used by the existing tests. PTAL.


https://reviews.llvm.org/D33588

Files:
  include/__hash_table
  test/libcxx/containers/unord/next_pow2.pass.cpp


Index: test/libcxx/containers/unord/next_pow2.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/next_pow2.pass.cpp
@@ -0,0 +1,80 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_hash_pow2(size_t n);
+
+// If n <= 1, return n. If n is a power of 2, return n.
+// Otherwise, return the next power of 2.
+
+#include <__hash_table>
+#include 
+#include 
+
+#include 
+
+bool
+is_power_of_two(unsigned long n)
+{
+return __builtin_popcount(n) == 1;
+}
+
+void
+test_next_pow2()
+{
+assert(!is_power_of_two(0));
+assert(is_power_of_two(1));
+assert(is_power_of_two(2));
+assert(!is_power_of_two(3));
+
+assert(std::__next_hash_pow2(0) == 0);
+assert(std::__next_hash_pow2(1) == 1);
+
+for (std::size_t n = 2; n < (sizeof(std::size_t) * 8 - 1); ++n)
+{
+std::size_t pow2 = 1ULL << n;
+assert(std::__next_hash_pow2(pow2) == pow2);
+}
+
+for (std::size_t n : {3, 7, 9, 15, 127, 129})
+{
+std::size_t npow2 = std::__next_hash_pow2(n);
+assert(is_power_of_two(npow2) && npow2 > n);
+}
+}
+
+// Note: this is only really useful when run with -fsanitize=undefined.
+void
+fuzz_unordered_map_reserve(unsigned num_inserts,
+   unsigned num_reserve1,
+   unsigned num_reserve2)
+{
+std::unordered_map m;
+m.reserve(num_reserve1);
+for (unsigned I = 0; I < num_inserts; ++I) m[I] = 0;
+m.reserve(num_reserve2);
+assert(m.bucket_count() >= num_reserve2);
+}
+
+int main()
+{
+test_next_pow2();
+
+for (unsigned num_inserts = 0; num_inserts <= 64; ++num_inserts)
+for (unsigned num_reserve1 = 1; num_reserve1 <= 64; ++num_reserve1)
+for (unsigned num_reserve2 = 1; num_reserve2 <= 64; ++num_reserve2)
+fuzz_unordered_map_reserve(num_inserts, num_reserve1, 
num_reserve2);
+
+return 0;
+}
Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -136,7 +136,7 @@
 size_t
 __next_hash_pow2(size_t __n)
 {
-return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
+return (__n > 1) ? (size_t(1) << (std::numeric_limits::digits - 
__clz(__n-1))) : __n;
 }
 
 


Index: test/libcxx/containers/unord/next_pow2.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/next_pow2.pass.cpp
@@ -0,0 +1,80 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_hash_pow2(size_t n);
+
+// If n <= 1, return n. If n is a power of 2, return n.
+// Otherwise, return the next power of 2.
+
+#include <__hash_table>
+#include 
+#include 
+
+#include 
+
+bool
+is_power_of_two(unsigned long n)
+{
+return __builtin_popcount(n) == 1;
+}
+
+void
+test_next_pow2()
+{
+assert(!is_power_of_two(0));
+assert(is_power_of_two(1));
+assert(is_power_of_two(2));
+assert(!is_power_of_two(3));
+
+assert(std::__next_hash_pow2(0) == 0);
+assert(std::__next_hash_pow2(1) == 1);
+
+for (std::size_t n = 2; n < (sizeof(std::size_t) * 8 - 1); ++n)
+{
+std::size_t pow2 = 1ULL << n;
+assert(std::__next_hash_pow2(pow2) == pow2);
+}
+
+for (std::size_t n : {3, 7, 9, 15, 127, 129})
+{
+std::size_t npow2 = std::__next_hash_pow2(n);
+assert(is_power_of_two(npow2) && npow2 > n);
+}
+}
+
+// Note: this is only really useful when run with -fsanitize=undefined.
+void
+fuzz_unordered_map_reserve(unsigned num_inserts,
+   unsigned num_reserve1,
+   unsigned num_reserve2)
+{
+std::unordered_map m;
+m.reserve(num_reserve1);
+for 

[PATCH] D33620: [CodeGenCXX] do not default to dllimport storage for mingw-w64

2017-05-26 Thread Martell Malone via Phabricator via cfe-commits
martell created this revision.

GNU frontends don't have options like `/MT`, `/MD` etc so it makes little sense.
This fixes a few link error regressions with libc++ and libc++abi


Repository:
  rL LLVM

https://reviews.llvm.org/D33620

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/runtime-dllstorage.cpp


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA 
-check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA 
-check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck 
%s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec 
-fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix 
CHECK-STATIC-IA
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2169,7 +2169,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  !getCodeGenOpts().LTOVisibilityPublicStd &&
+  !getTriple().isWindowsGNUEnvironment()) {
 const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
 if (!FD || FD->hasAttr()) {
   F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -12,7 +12,7 @@
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
 
-// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
+// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2169,7 +2169,8 @@
   F->setCallingConv(getRuntimeCC());
 
   if (!Local && getTriple().isOSBinFormatCOFF() &&
-  !getCodeGenOpts().LTOVisibilityPublicStd) {
+  

[PATCH] D33525: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-05-26 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:913-914
+std::error_code EC;
+ThinLinkOS.emplace(CodeGenOpts.ThinLinkBitcodeFile, EC,
+   llvm::sys::fs::F_None);
+if (EC) {

The clang side of this should probably be a separate review on cfe-commits, but 
one drive-by coment.

I find this usage of emplace much harder to read than:

  ThinLinkOS.reset(raw_fd_ostream(CodeGenOpts.ThinLinkBitcodeFile, EC,
  llvm::sys::fs::F_None));

Unless we just can't do the above for some reason (it won't compile =[) I would 
prefer it.



Comment at: llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h:31-32
+public:
+  ThinLTOBitcodeWriterPass(raw_ostream , raw_ostream *ThinLinkOS)
+  : OS(OS), ThinLinkOS(ThinLinkOS) {}
+

Move (or add) a comment about this API to thea header? Notably, under what 
circumstances can `ThinLinkOS` be null? What happens if it is?



Comment at: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp:9-12
 //
-// This pass prepares a module containing type metadata for ThinLTO by 
splitting
-// it into regular and thin LTO parts if possible, and writing both parts to
-// a multi-module bitcode file. Modules that do not contain type metadata are
-// written unmodified as a single module.
+// Pass implementation.
 //
 
//===--===//

Can just omit the added section I suspect.



Comment at: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp:443
+  writeThinLTOBitcode(OS, ThinLinkOS,
+  [](Function ) -> AAResults & {
+return FAM.getResult(F);

Are we unable to deduce the return type here?



Comment at: llvm/test/Transforms/ThinLTOBitcodeWriter/new-pm.ll:1
+; RUN: opt -passes='lto' -debug-pass-manager -thinlto-bc 
-thin-link-bitcode-file=%t2 -o %t %s 2>&1 | FileCheck %s --check-prefix=DEBUG_PM
+; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=BITCODE

Why run any passes here? 



Comment at: llvm/tools/opt/NewPMDriver.h:61
+ bool EmitSummaryIndex, bool EmitModuleHash,
+ Optional ThinLTOBC);
 }

Why an optional pointer? Maybe just allow the pointer to be null if there isn't 
a thin link output file?



Comment at: llvm/tools/opt/opt.cpp:534
+if (OutputThinLTOBC)
+  ThinLTOBC.emplace(ThinLinkOut.get());
+if (!runPassPipeline(argv[0], *M, TM.get(), Out.get(), PassPipeline, OK, 
VK,

Maybe unnecessary based on the above comment, but generally I would just assign 
rather than using emplace.



Comment at: llvm/tools/opt/opt.cpp:541-542
+
+if (ThinLinkOut)
+  ThinLinkOut->keep();
+

We do `Out->keep()` in `runPassPipeline`, why not do this there as well?


https://reviews.llvm.org/D33525



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


[PATCH] D33538: [coroutines] Support "coroutines" feature in module map requires clause

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Even after fixing the libc++ guards, the header still emits a #warning when 
it's processed when coroutines are unavailable.

It seems like a useful feature test to have available. I'll commit shortly.


https://reviews.llvm.org/D33538



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


r304054 - [coroutines] Support "coroutines" feature in module map requires clause

2017-05-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May 26 21:46:17 2017
New Revision: 304054

URL: http://llvm.org/viewvc/llvm-project?rev=304054=rev
Log:
[coroutines] Support "coroutines" feature in module map requires clause

Summary: In order for libc++ to add `` to its module 
map, there has to be a feature that can be used to detect if coroutines support 
is enabled in Clang. 

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h

cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
cfe/trunk/test/Modules/requires-coroutines.mm
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=304054=304053=304054=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Fri May 26 21:46:17 2017
@@ -413,6 +413,9 @@ altivec
 blocks
   The "blocks" language feature is available.
 
+coroutines
+  Support for the coroutines TS is available.
+
 cplusplus
   C++ support is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=304054=304053=304054=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Fri May 26 21:46:17 2017
@@ -64,6 +64,7 @@ static bool hasFeature(StringRef Feature
   bool HasFeature = llvm::StringSwitch(Feature)
 .Case("altivec", LangOpts.AltiVec)
 .Case("blocks", LangOpts.Blocks)
+.Case("coroutines", LangOpts.CoroutinesTS)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
 .Case("freestanding", LangOpts.Freestanding)

Added: 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h?rev=304054=auto
==
--- 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h 
Fri May 26 21:46:17 2017
@@ -0,0 +1,3 @@
+#ifndef __cpp_coroutines
+#error coroutines must be enabled
+#endif

Added: 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h?rev=304054=auto
==
--- 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
 Fri May 26 21:46:17 2017
@@ -0,0 +1,3 @@
+#ifdef __cpp_coroutines
+#error coroutines must NOT be enabled
+#endif

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=304054=304053=304054=diff
==
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map 
(original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Fri May 
26 21:46:17 2017
@@ -22,7 +22,14 @@ framework module DependsOnModule {
   explicit module CustomReq2 {
 requires custom_req2
   }
-
+  explicit module Coroutines {
+requires coroutines
+header "coroutines.h"
+  }
+  explicit module NotCoroutines {
+requires !coroutines
+header "not_coroutines.h"
+  }
   explicit framework module SubFramework {
 umbrella header "SubFramework.h"
 

Added: cfe/trunk/test/Modules/requires-coroutines.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires-coroutines.mm?rev=304054=auto
==
--- cfe/trunk/test/Modules/requires-coroutines.mm (added)
+++ cfe/trunk/test/Modules/requires-coroutines.mm Fri May 26 21:46:17 2017
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -F %S/Inputs %s -verify
+// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -F %S/Inputs %s -verify -fcoroutines-ts -DCOROUTINES
+
+
+#ifdef COROUTINES
+@import DependsOnModule.Coroutines;
+@import 

[PATCH] D33509: [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies

2017-05-26 Thread George Rokos via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304056: [OpenMP] Create COMDAT group for OpenMP offload 
registration code to avoid… (authored by grokos).

Changed prior to commit:
  https://reviews.llvm.org/D33509?vs=100134=100518#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33509

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/OpenMP/target_codegen.cpp
  cfe/trunk/test/OpenMP/target_codegen_registration.cpp
  cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
  cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_num_threads_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_codegen_registration.cpp
  cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: cfe/trunk/test/OpenMP/target_codegen_registration.cpp
===
--- cfe/trunk/test/OpenMP/target_codegen_registration.cpp
+++ cfe/trunk/test/OpenMP/target_codegen_registration.cpp
@@ -36,6 +36,8 @@
 
 // TCHECK:[[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
 
+// CHECK-DAG: $[[REGFN:\.omp_offloading\..+]] = comdat
+
 // CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
 // CHECK-DAG: [[A2:@.+]] = global [[SA]]
 // CHECK-DAG: [[B1:@.+]] = global [[SB]]
@@ -153,15 +155,15 @@
 // CHECK: [[ENTEND:@.+]] = external constant [[ENTTY]]
 // CHECK: [[DEVBEGIN:@.+]] = external constant i8
 // CHECK: [[DEVEND:@.+]] = external constant i8
-// CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] [{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }]
-// CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }
+// CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] [{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }], comdat($[[REGFN]])
+// CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // We have 4 initializers, one for the 500 priority, another one for 501, or more for the default priority, and the last one for the offloading registration function.
 // CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [
 // CHECK-SAME: { i32, void ()*, i8* } { i32 500, void ()* [[P500:@[^,]+]], i8* null },
 // CHECK-SAME: { i32, void ()*, i8* } { i32 501, void ()* [[P501:@[^,]+]], i8* null },
 // CHECK-SAME: { i32, void ()*, i8* } { i32 65535, void ()* [[PMAX:@[^,]+]], i8* null },
-// CHECK-SAME: { i32, void ()*, i8* } { i32 0, void ()* bitcast (void (i8*)* [[REGFN:@.+]] to void ()*), i8* null }]
+// CHECK-SAME: { i32, void ()*, i8* } { i32 0, void ()* bitcast (void (i8*)* @[[REGFN]] to void ()*), i8* bitcast (void (i8*)* @[[REGFN]] to i8*) }]
 
 // CHECK-NTARGET: @llvm.global_ctors = appending global [3   x { i32, void ()*, i8* }] [
 
@@ -364,14 +366,16 @@
 
 // Check registration and unregistration
 
-//CHECK: define internal void [[UNREGFN:@.+]](i8*)
+//CHECK: define internal void @[[UNREGFN:.+]](i8*)
+//CHECK-SAME: comdat($[[REGFN]]) {
 //CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
 //CHECK: ret void
 //CHECK: declare i32 @__tgt_unregister_lib([[DSCTY]]*)
 
-//CHECK: define internal void [[REGFN]](i8*)
+//CHECK: define linkonce hidden void @[[REGFN]](i8*)
+//CHECK-SAME: comdat {
 //CHECK: call i32 @__tgt_register_lib([[DSCTY]]* [[DESC]])
-//CHECK: call i32 @__cxa_atexit(void (i8*)* [[UNREGFN]], i8* bitcast ([[DSCTY]]* [[DESC]] to i8*),
+//CHECK: call i32 @__cxa_atexit(void (i8*)* @[[UNREGFN]], i8* bitcast ([[DSCTY]]* [[DESC]] to i8*),
 //CHECK: ret void
 //CHECK: declare i32 @__tgt_register_lib([[DSCTY]]*)
 
@@ -407,31 +411,31 @@
 
 // Check metadata is properly generated:
 // CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 193, i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 243, i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 259, i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 265, i32 {{[0-9]+}}}
-// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EE3fooEv", i32 276, 

r304057 - Revert "[coroutines] Support "coroutines" feature in module map requires clause"

2017-05-26 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May 26 22:04:51 2017
New Revision: 304057

URL: http://llvm.org/viewvc/llvm-project?rev=304057=rev
Log:
Revert "[coroutines] Support "coroutines" feature in module map requires clause"

This reverts commit r304054.

Removed:
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h

cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
cfe/trunk/test/Modules/requires-coroutines.mm
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=304057=304056=304057=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Fri May 26 22:04:51 2017
@@ -413,9 +413,6 @@ altivec
 blocks
   The "blocks" language feature is available.
 
-coroutines
-  Support for the coroutines TS is available.
-
 cplusplus
   C++ support is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=304057=304056=304057=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Fri May 26 22:04:51 2017
@@ -64,7 +64,6 @@ static bool hasFeature(StringRef Feature
   bool HasFeature = llvm::StringSwitch(Feature)
 .Case("altivec", LangOpts.AltiVec)
 .Case("blocks", LangOpts.Blocks)
-.Case("coroutines", LangOpts.CoroutinesTS)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
 .Case("freestanding", LangOpts.Freestanding)

Removed: 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h?rev=304056=auto
==
--- 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h 
(original)
+++ 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/coroutines.h 
(removed)
@@ -1,3 +0,0 @@
-#ifndef __cpp_coroutines
-#error coroutines must be enabled
-#endif

Removed: 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h?rev=304056=auto
==
--- 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
 (original)
+++ 
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/Headers/not_coroutines.h
 (removed)
@@ -1,3 +0,0 @@
-#ifdef __cpp_coroutines
-#error coroutines must NOT be enabled
-#endif

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=304057=304056=304057=diff
==
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map 
(original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Fri May 
26 22:04:51 2017
@@ -22,14 +22,7 @@ framework module DependsOnModule {
   explicit module CustomReq2 {
 requires custom_req2
   }
-  explicit module Coroutines {
-requires coroutines
-header "coroutines.h"
-  }
-  explicit module NotCoroutines {
-requires !coroutines
-header "not_coroutines.h"
-  }
+
   explicit framework module SubFramework {
 umbrella header "SubFramework.h"
 

Removed: cfe/trunk/test/Modules/requires-coroutines.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires-coroutines.mm?rev=304056=auto
==
--- cfe/trunk/test/Modules/requires-coroutines.mm (original)
+++ cfe/trunk/test/Modules/requires-coroutines.mm (removed)
@@ -1,12 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -F %S/Inputs %s -verify
-// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules 
-fimplicit-module-maps -F %S/Inputs %s -verify -fcoroutines-ts -DCOROUTINES
-
-
-#ifdef COROUTINES
-@import DependsOnModule.Coroutines;
-@import DependsOnModule.NotCoroutines; // expected-error {{module 
'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}}
-#else
-@import DependsOnModule.NotCoroutines;
-@import DependsOnModule.Coroutines; // expected-error {{module 
'DependsOnModule.Coroutines' requires feature 

[PATCH] D33509: [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies

2017-05-26 Thread George Rokos via Phabricator via cfe-commits
grokos added a comment.

I committed the patch. Thanks for submitting it!


Repository:
  rL LLVM

https://reviews.llvm.org/D33509



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


r304056 - [OpenMP] Create COMDAT group for OpenMP offload registration code to avoid multiple copies

2017-05-26 Thread George Rokos via cfe-commits
Author: grokos
Date: Fri May 26 22:03:13 2017
New Revision: 304056

URL: http://llvm.org/viewvc/llvm-project?rev=304056=rev
Log:
[OpenMP] Create COMDAT group for OpenMP offload registration code to avoid 
multiple copies

Thanks to Sergey Dmitriev for submitting the patch.

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_parallel_if_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen_registration.cpp
cfe/trunk/test/OpenMP/target_teams_num_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_thread_limit_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=304056=304055=304056=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri May 26 22:03:13 2017
@@ -2903,6 +2903,19 @@ CGOpenMPRuntime::createOffloadingBinaryD
  Desc);
 CGM.getCXXABI().registerGlobalDtor(CGF, RegUnregVar, UnRegFn, Desc);
   });
+  if (CGM.supportsCOMDAT()) {
+// It is sufficient to call registration function only once, so create a
+// COMDAT group for registration/unregistration functions and associated
+// data. That would reduce startup time and code size. Registration
+// function serves as a COMDAT group key.
+auto ComdatKey = M.getOrInsertComdat(RegFn->getName());
+RegFn->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
+RegFn->setVisibility(llvm::GlobalValue::HiddenVisibility);
+RegFn->setComdat(ComdatKey);
+UnRegFn->setComdat(ComdatKey);
+DeviceImages->setComdat(ComdatKey);
+Desc->setComdat(ComdatKey);
+  }
   return RegFn;
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=304056=304055=304056=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 26 22:03:13 2017
@@ -400,8 +400,11 @@ void CodeGenModule::Release() {
   }
   if (OpenMPRuntime)
 if (llvm::Function *OpenMPRegistrationFunction =
-OpenMPRuntime->emitRegistrationFunction())
-  AddGlobalCtor(OpenMPRegistrationFunction, 0);
+OpenMPRuntime->emitRegistrationFunction()) {
+  auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
+OpenMPRegistrationFunction : nullptr;
+  AddGlobalCtor(OpenMPRegistrationFunction, 0, ComdatKey);
+}
   if (PGOReader) {
 getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
 if (PGOStats.hasDiagnostics())

Modified: cfe/trunk/test/OpenMP/target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=304056=304055=304056=diff
==
--- cfe/trunk/test/OpenMP/target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen.cpp Fri May 26 22:03:13 2017
@@ -28,6 +28,8 @@
 
 // TCHECK: [[ENTTY:%.+]] = type { i8*, i8*, i{{32|64}}, i32, i32 }
 
+// CHECK-DAG: $[[REGFN:\.omp_offloading\..+]] = comdat
+
 // We have 8 target regions, but only 7 that actually will generate offloading
 // code, only 6 will have mapped arguments, and only 4 have all-constant map
 // sizes.
@@ -64,11 +66,11 @@
 // CHECK: [[ENTEND:@.+]] = external constant [[ENTTY]]
 // CHECK: [[DEVBEGIN:@.+]] = external constant i8
 // CHECK: [[DEVEND:@.+]] = external constant i8
-// CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] 
[{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* 
[[ENTEND]] }]
-// CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* 
getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, 
i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }
+// CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] 
[{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* 
[[ENTEND]] }], comdat($[[REGFN]])
+// CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* 
getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, 
i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, 

Re: [PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

2017-05-26 Thread David Abdurachmanov via cfe-commits
Just reminder that this is in C++1z (C++17) mode, which I doubt is being widely 
used at this point.

I was a change a few months ago that caused it, but cannot recall exact commit 
in GCC.

david

> On 26 May 2017, at 10:43, Chandler Carruth  wrote:
> 
> I kind of think this may be a GCC bug. It is quite strange that no one else 
> has reported it, and that you're only seeing it in this context. We have many 
> std::string flags and they are used in this way pretty commonly.
> 
> I'm not seeing this with any other GCC-hosted build bot either, including a 
> PPC one here: http://lab.llvm.org:8011/builders/clang-ppc64le-linux 
> 
> On Fri, May 26, 2017 at 1:34 AM David Abdurachmanov via Phabricator 
> > wrote:
> davidlt added a comment.
> 
> This happens with recent GCC 7.1.1 (updated yesterday) and if compiled in 
> C++1z mode.
> 
>   FAILED: 
> /home/davidlt/root_patch_check/a/slc7_ppc64le_gcc700/external/gcc/7.0.0-njopjo2/bin/g++
>-DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -Iinterpreter/llvm/src/lib/Transforms/Instrumentation 
> -I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation
>  -Iinterpreter/llvm/src/include 
> -I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include
>  -D__ROOFIT_NOBANNER -Wno-implicit-fallthrough -Wno-noexcept-type -pipe   
> -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread 
> -std=c++1z -fvisibility=hidden -fPIC -fvisibility-inlines-hidden -w 
> -Werror=date-time -std=c++1z -ffunction-sections -fdata-sections -O2 -DNDEBUG 
>-fno-exceptions -fno-rtti -MD -MT 
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
>  -MF 
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o.d
>  -o 
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
>  -c 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
>   
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:
>  In constructor 
> '{anonymous}::PGOInstrumentationUseLegacyPass::PGOInstrumentationUseLegacyPass(std::string)':
>   
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:155:25:
>  error: 'llvm::cl::opt::opt(const 
> llvm::cl::opt&) [with DataType = 
> std::basic_string; bool ExternalStorage = false; ParserClass = 
> llvm::cl::parser]' is private within this context
>  ProfileFileName = PGOTestProfileFile;
>^~
>   In file included from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Support/Options.h:41:0,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/LLVMContext.h:19,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Metadata.h:26,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/TrackingMDRef.h:17,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/DebugLoc.h:18,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Instruction.h:20,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/BasicBlock.h:19,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Function.h:24,
>from 
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/PassManager.h:44,
>from 
> 

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

2017-05-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303977: [clangd] Allow to use vfs::FileSystem for file 
accesses. (authored by ibiryukov).

Changed prior to commit:
  https://reviews.llvm.org/D33416?vs=100262=100389#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33416

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/ClangdUnitStore.h
  clang-tools-extra/trunk/unittests/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/clangd/ClangdUnit.h
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.h
+++ clang-tools-extra/trunk/clangd/ClangdUnit.h
@@ -10,8 +10,8 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDUNIT_H
 
-#include "Protocol.h"
 #include "Path.h"
+#include "Protocol.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include 
@@ -24,6 +24,10 @@
 class ASTUnit;
 class PCHContainerOperations;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace tooling {
 struct CompileCommand;
 }
@@ -42,16 +46,19 @@
 public:
   ClangdUnit(PathRef FileName, StringRef Contents,
  std::shared_ptr PCHs,
- std::vector Commands);
+ std::vector Commands,
+ IntrusiveRefCntPtr VFS);
 
   /// Reparse with new contents.
-  void reparse(StringRef Contents);
+  void reparse(StringRef Contents, IntrusiveRefCntPtr VFS);
 
   /// Get code completions at a specified \p Line and \p Column in \p File.
   ///
   /// This function is thread-safe and returns completion items that own the
   /// data they contain.
-  std::vector codeComplete(StringRef Contents, Position Pos);
+  std::vector
+  codeComplete(StringRef Contents, Position Pos,
+   IntrusiveRefCntPtr VFS);
   /// Returns diagnostics and corresponding FixIts for each diagnostic that are
   /// located in the current file.
   std::vector getLocalDiagnostics() const;
Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -11,14 +11,16 @@
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Tooling/CompilationDatabase.h"
 
 using namespace clang::clangd;
 using namespace clang;
 
 ClangdUnit::ClangdUnit(PathRef FileName, StringRef Contents,
std::shared_ptr PCHs,
-   std::vector Commands)
+   std::vector Commands,
+   IntrusiveRefCntPtr VFS)
 : FileName(FileName), PCHs(PCHs) {
   assert(!Commands.empty() && "No compile commands provided");
 
@@ -48,18 +50,24 @@
   /*PrecompilePreambleAfterNParses=*/1, /*TUKind=*/TU_Prefix,
   /*CacheCodeCompletionResults=*/true,
   /*IncludeBriefCommentsInCodeCompletion=*/true,
-  /*AllowPCHWithCompilerErrors=*/true));
+  /*AllowPCHWithCompilerErrors=*/true,
+  /*SkipFunctionBodies=*/false,
+  /*UserFilesAreVolatile=*/false, /*ForSerialization=*/false,
+  /*ModuleFormat=*/llvm::None,
+  /*ErrAST=*/nullptr, VFS));
+  assert(Unit && "Unit wasn't created");
 }
 
-void ClangdUnit::reparse(StringRef Contents) {
+void ClangdUnit::reparse(StringRef Contents,
+ IntrusiveRefCntPtr VFS) {
   // Do a reparse if this wasn't the first parse.
   // FIXME: This might have the wrong working directory if it changed in the
   // meantime.
   ASTUnit::RemappedFile RemappedSource(
   FileName,
   llvm::MemoryBuffer::getMemBufferCopy(Contents, FileName).release());
 
-  Unit->Reparse(PCHs, RemappedSource);
+  Unit->Reparse(PCHs, RemappedSource, VFS);
 }
 
 namespace {
@@ -146,8 +154,9 @@
 };
 } // namespace
 
-std::vector ClangdUnit::codeComplete(StringRef Contents,
- Position Pos) {
+std::vector
+ClangdUnit::codeComplete(StringRef Contents, Position Pos,
+ IntrusiveRefCntPtr VFS) {
   CodeCompleteOptions CCO;
   CCO.IncludeBriefComments = 1;
   // This is where code completion stores dirty buffers. Need to free after
@@ -163,17 +172,19 @@
   FileName,
   llvm::MemoryBuffer::getMemBufferCopy(Contents, FileName).release());
 
+  IntrusiveRefCntPtr FileMgr(
+  new FileManager(Unit->getFileSystemOpts(), VFS));
   IntrusiveRefCntPtr SourceMgr(
-  new SourceManager(*DiagEngine, Unit->getFileManager()));
+  new SourceManager(*DiagEngine, 

[clang-tools-extra] r303977 - [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-26 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri May 26 07:26:51 2017
New Revision: 303977

URL: http://llvm.org/viewvc/llvm-project?rev=303977=rev
Log:
[clangd] Allow to use vfs::FileSystem for file accesses.

Summary:
Custom vfs::FileSystem is currently used for unit tests.
This revision depends on https://reviews.llvm.org/D33397.

Reviewers: bkramer, krasimir

Reviewed By: bkramer, krasimir

Subscribers: klimek, cfe-commits, mgorny

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

Added:
clang-tools-extra/trunk/unittests/clangd/
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/ClangdUnitStore.h
clang-tools-extra/trunk/unittests/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=303977=303976=303977=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri May 26 07:26:51 2017
@@ -199,6 +199,7 @@ ClangdLSPServer::ClangdLSPServer(JSONOut
 : Out(Out),
   Server(llvm::make_unique(),
  llvm::make_unique(*this),
+ llvm::make_unique(),
  RunSynchronously) {}
 
 void ClangdLSPServer::run(std::istream ) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=303977=303976=303977=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Fri May 26 07:26:51 2017
@@ -58,6 +58,10 @@ Position clangd::offsetToPosition(String
   return {Lines, Cols};
 }
 
+IntrusiveRefCntPtr RealFileSystemProvider::getFileSystem() {
+  return vfs::getRealFileSystem();
+}
+
 ClangdScheduler::ClangdScheduler(bool RunSynchronously)
 : RunSynchronously(RunSynchronously) {
   if (RunSynchronously) {
@@ -135,8 +139,10 @@ void ClangdScheduler::addToEnd(std::func
 
 ClangdServer::ClangdServer(std::unique_ptr CDB,
std::unique_ptr DiagConsumer,
+   std::unique_ptr FSProvider,
bool RunSynchronously)
 : CDB(std::move(CDB)), DiagConsumer(std::move(DiagConsumer)),
+  FSProvider(std::move(FSProvider)),
   PCHs(std::make_shared()),
   WorkScheduler(RunSynchronously) {}
 
@@ -150,10 +156,11 @@ void ClangdServer::addDocument(PathRef F
 
 assert(FileContents.Draft &&
"No contents inside a file that was scheduled for reparse");
-Units.runOnUnit(
-FileStr, *FileContents.Draft, *CDB, PCHs, [&](ClangdUnit const ) {
-  DiagConsumer->onDiagnosticsReady(FileStr, 
Unit.getLocalDiagnostics());
-});
+Units.runOnUnit(FileStr, *FileContents.Draft, *CDB, PCHs,
+FSProvider->getFileSystem(), [&](ClangdUnit const ) {
+  DiagConsumer->onDiagnosticsReady(
+  FileStr, Unit.getLocalDiagnostics());
+});
   });
 }
 
@@ -168,15 +175,22 @@ void ClangdServer::removeDocument(PathRe
   });
 }
 
+void ClangdServer::forceReparse(PathRef File) {
+  // The addDocument schedules the reparse even if the contents of the file
+  // never changed, so we just call it here.
+  addDocument(File, getDocument(File));
+}
+
 std::vector ClangdServer::codeComplete(PathRef File,
Position Pos) {
   auto FileContents = DraftMgr.getDraft(File);
   assert(FileContents.Draft && "codeComplete is called for non-added 
document");
 
   std::vector Result;
+  auto VFS = FSProvider->getFileSystem();
   Units.runOnUnitWithoutReparse(
-  File, *FileContents.Draft, *CDB, PCHs, [&](ClangdUnit ) {
-Result = Unit.codeComplete(*FileContents.Draft, Pos);
+  File, *FileContents.Draft, *CDB, PCHs, VFS, [&](ClangdUnit ) {
+Result = Unit.codeComplete(*FileContents.Draft, Pos, VFS);
   });
   return Result;
 }

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=303977=303976=303977=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Fri May 26 07:26:51 2017
@@ -50,6 +50,17 @@ public:
   std::vector Diagnostics) = 0;
 };
 
+class 

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

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

Webkit inherits AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All from 
LLVM style, so merging the options would introduce these explicitely-forbidden 
empty blocks.
But the empty blocks should actually be used in code following Mozilla or Qt 
style.


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-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I think it's just wrong that WebKit inherits this. The style guide explicitly 
says that this is wrong:

  MyOtherClass::MyOtherClass() : MySuperClass() {}

So I still think we can make this work with the existing options without 
regressing a behavior that anyone is relying on.


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] D33592: [OpenCL] Test on half immediate support.

2017-05-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D33592



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


Re: [clang-tools-extra] r303977 - [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-26 Thread Vedant Kumar via cfe-commits
Hi Ilya,

The unit test introduced by this commit hits an assertion failure on our bots. 
Could you please take a look at the issue?

lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-expensive/6733 


I see:

[ RUN  ] ClangdVFSTest.Reparse

Assertion failed: (Unit && "Unit wasn't created"), function ClangdUnit, file 
/Users/buildslave/jenkins/sharedspace/clang-stage1-cmake-RA_workspace/llvm/tools/clang/tools/extra/clangd/ClangdUnit.cpp,
 line 58.

0  ClangdTests  0x000102fec2f8 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  ClangdTests  0x000102fec9e6 SignalHandler(int) + 454
2  libsystem_platform.dylib 0x7fff97ed352a _sigtramp + 26
3  libsystem_platform.dylib 00 _sigtramp + 1746062064
4  libsystem_c.dylib0x7fff97d776df abort + 129
5  libsystem_c.dylib0x7fff97d3edd8 basename + 0
6  ClangdTests  0x0001030c95dd 
clang::clangd::ClangdUnit::ClangdUnit(llvm::StringRef, llvm::StringRef, 
std::__1::shared_ptr, 
std::__1::vector, 
llvm::IntrusiveRefCntPtr) + 1837
7  ClangdTests  0x0001030c824f 
std::__1::__function::__func, void ()>::operator()() + 975
8  ClangdTests  0x0001030c6e03 void* 
std::__1::__thread_proxy
 >(void*) + 579
9  libsystem_pthread.dylib  0x7fff8e26099d _pthread_body + 131
10 libsystem_pthread.dylib  0x7fff8e26091a _pthread_body + 0
11 libsystem_pthread.dylib  0x7fff8e25e351 thread_start + 13


FAIL: Extra Tools Unit Tests :: 
clangd/ClangdTests/ClangdVFSTest.ReparseOnHeaderChange (13778 of 37955)
 TEST 'Extra Tools Unit Tests :: 
clangd/ClangdTests/ClangdVFSTest.ReparseOnHeaderChange' FAILED 

Note: Google Test filter = ClangdVFSTest.ReparseOnHeaderChange
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from ClangdVFSTest
[ RUN  ] ClangdVFSTest.ReparseOnHeaderChange

Assertion failed: (Unit && "Unit wasn't created"), function ClangdUnit, file 
/Users/buildslave/jenkins/sharedspace/clang-stage1-cmake-RA_workspace/llvm/tools/clang/tools/extra/clangd/ClangdUnit.cpp,
 line 58.

0  ClangdTests  0x0001005b72f8 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  ClangdTests  0x0001005b79e6 SignalHandler(int) + 454
2  libsystem_platform.dylib 0x7fff97ed352a _sigtramp + 26
3  libsystem_platform.dylib 00 _sigtramp + 1746062064
4  libsystem_c.dylib0x7fff97d776df abort + 129
5  libsystem_c.dylib0x7fff97d3edd8 basename + 0
6  ClangdTests  0x0001006945dd 
clang::clangd::ClangdUnit::ClangdUnit(llvm::StringRef, llvm::StringRef, 
std::__1::shared_ptr, 
std::__1::vector, 
llvm::IntrusiveRefCntPtr) + 1837
7  ClangdTests  0x00010069324f 
std::__1::__function::__func, void ()>::operator()() + 975
8  ClangdTests  0x000100691e03 void* 
std::__1::__thread_proxy
 >(void*) + 579
9  libsystem_pthread.dylib  0x7fff8e26099d _pthread_body + 131
10 libsystem_pthread.dylib  0x7fff8e26091a _pthread_body + 0
11 libsystem_pthread.dylib  0x7fff8e25e351 thread_start + 13

thanks,
vedant

> On May 26, 2017, at 5:26 AM, Ilya Biryukov via cfe-commits 
>  wrote:
> 
> Author: ibiryukov
> Date: Fri May 26 07:26:51 2017
> New Revision: 303977
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=303977=rev
> Log:
> [clangd] Allow to use vfs::FileSystem for file accesses.
> 
> Summary:
> Custom vfs::FileSystem is currently used for unit tests.
> This revision depends on https://reviews.llvm.org/D33397.
> 
> Reviewers: bkramer, krasimir
> 
> Reviewed By: bkramer, krasimir
> 
> Subscribers: klimek, cfe-commits, mgorny
> 
> Differential Revision: https://reviews.llvm.org/D33416
> 
> Added:
>clang-tools-extra/trunk/unittests/clangd/
>clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
>clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> Modified:
>clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
>clang-tools-extra/trunk/clangd/ClangdServer.cpp
>clang-tools-extra/trunk/clangd/ClangdServer.h
>clang-tools-extra/trunk/clangd/ClangdUnit.cpp
>

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D29877#766176, @rsmith wrote:

> In https://reviews.llvm.org/D29877#765968, @EricWF wrote:
>
> > I think this patch still gets the following case wrong:
> >
> >   // foo.h
> >   constexpr struct {
> > template  void operator()(T) {} // emits unused template 
> > warning
> >   } foo;
> >
>
>
> What specifically do you think is wrong here? There is an unused internal 
> linkage function template here. If we want to warn on unused internal linkage 
> templates declared in headers, we should warn on this one.


I was confused about the linkage initially. My mistake. Should adding `inline` 
here change that?

> Note that any use of `foo` here from an inline function would result in ODR 
> violations (because you get a different `foo` in each translation unit), so 
> it's probably at least a bad idea to do that. We could suppress this warning 
> for unused internal linkage templates declared in headers, or maybe move that 
> to a separate warning flag; can you point us at some code that does this in 
> practice and isn't wrong?

No. But I can point you to `range-v3` which uses this pattern and I think the 
idiom is somewhat appealing, but that's orthogonal to Clang diagnosing it.


https://reviews.llvm.org/D29877



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


[PATCH] D33525: [ThinLTO] Migrate ThinLTOBitcodeWriter to the new PM.

2017-05-26 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 100488.
timshen added a comment.

Add opt support and llvm test.


https://reviews.llvm.org/D33525

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thin_link_bitcode.c
  llvm/include/llvm/Transforms/IPO/ThinLTOBitcodeWriter.h
  llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
  llvm/test/Transforms/ThinLTOBitcodeWriter/new-pm.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -529,12 +529,19 @@
 // The user has asked to use the new pass manager and provided a pipeline
 // string. Hand off the rest of the functionality to the new code for that
 // layer.
-return runPassPipeline(argv[0], *M, TM.get(), Out.get(),
-   PassPipeline, OK, VK, PreserveAssemblyUseListOrder,
-   PreserveBitcodeUseListOrder, EmitSummaryIndex,
-   EmitModuleHash)
-   ? 0
-   : 1;
+Optional ThinLTOBC;
+if (OutputThinLTOBC)
+  ThinLTOBC.emplace(ThinLinkOut.get());
+if (!runPassPipeline(argv[0], *M, TM.get(), Out.get(), PassPipeline, OK, VK,
+ PreserveAssemblyUseListOrder,
+ PreserveBitcodeUseListOrder, EmitSummaryIndex,
+ EmitModuleHash, ThinLTOBC))
+  return 1;
+
+if (ThinLinkOut)
+  ThinLinkOut->keep();
+
+return 0;
   }
 
   // Create a PassManager to hold and optimize the collection of passes we are
Index: llvm/tools/opt/NewPMDriver.h
===
--- llvm/tools/opt/NewPMDriver.h
+++ llvm/tools/opt/NewPMDriver.h
@@ -21,6 +21,8 @@
 #ifndef LLVM_TOOLS_OPT_NEWPMDRIVER_H
 #define LLVM_TOOLS_OPT_NEWPMDRIVER_H
 
+#include 
+
 namespace llvm {
 class StringRef;
 class LLVMContext;
@@ -47,13 +49,16 @@
 /// inclusion of the new pass manager headers and the old headers into the same
 /// file. It's interface is consequentially somewhat ad-hoc, but will go away
 /// when the transition finishes.
-bool runPassPipeline(StringRef Arg0, Module ,
- TargetMachine *TM, tool_output_file *Out,
- StringRef PassPipeline, opt_tool::OutputKind OK,
- opt_tool::VerifierKind VK,
+///
+/// ThinLTOBC indicates whether to use ThinLTO's bitcode writer, and if so,
+/// the optional link file path.
+bool runPassPipeline(StringRef Arg0, Module , TargetMachine *TM,
+ tool_output_file *Out, StringRef PassPipeline,
+ opt_tool::OutputKind OK, opt_tool::VerifierKind VK,
  bool ShouldPreserveAssemblyUseListOrder,
  bool ShouldPreserveBitcodeUseListOrder,
- bool EmitSummaryIndex, bool EmitModuleHash);
+ bool EmitSummaryIndex, bool EmitModuleHash,
+ Optional ThinLTOBC);
 }
 
 #endif
Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 
 using namespace llvm;
@@ -47,13 +48,13 @@
 "pipeline for handling managed aliasing queries"),
cl::Hidden);
 
-bool llvm::runPassPipeline(StringRef Arg0, Module ,
-   TargetMachine *TM, tool_output_file *Out,
-   StringRef PassPipeline, OutputKind OK,
-   VerifierKind VK,
+bool llvm::runPassPipeline(StringRef Arg0, Module , TargetMachine *TM,
+   tool_output_file *Out, StringRef PassPipeline,
+   OutputKind OK, VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
bool ShouldPreserveBitcodeUseListOrder,
-   bool EmitSummaryIndex, bool EmitModuleHash) {
+   bool EmitSummaryIndex, bool EmitModuleHash,
+   Optional ThinLTOBC) {
   PassBuilder PB(TM);
 
   // Specially handle the alias analysis manager so that we can register
@@ -101,8 +102,12 @@
 PrintModulePass(Out->os(), "", ShouldPreserveAssemblyUseListOrder));
 break;
   case OK_OutputBitcode:
-MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder,
-  EmitSummaryIndex, EmitModuleHash));
+if (ThinLTOBC)
+  MPM.addPass(ThinLTOBitcodeWriterPass(
+  Out->os(), *ThinLTOBC ? &(*ThinLTOBC)->os() : nullptr));
+else
+  

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D29877#766196, @EricWF wrote:

> In https://reviews.llvm.org/D29877#766176, @rsmith wrote:
>
> > In https://reviews.llvm.org/D29877#765968, @EricWF wrote:
> >
> > > I think this patch still gets the following case wrong:
> > >
> > >   // foo.h
> > >   constexpr struct {
> > > template  void operator()(T) {} // emits unused template 
> > > warning
> > >   } foo;
> > >
> >
> >
> > What specifically do you think is wrong here? There is an unused internal 
> > linkage function template here. If we want to warn on unused internal 
> > linkage templates declared in headers, we should warn on this one.
>
>
> I was confused about the linkage initially. My mistake. Should adding 
> `inline` here change that?


No, it does not. Unnamed classes and their members can never have external 
linkage.

> 
> 
>> Note that any use of `foo` here from an inline function would result in ODR 
>> violations (because you get a different `foo` in each translation unit), so 
>> it's probably at least a bad idea to do that. We could suppress this warning 
>> for unused internal linkage templates declared in headers, or maybe move 
>> that to a separate warning flag; can you point us at some code that does 
>> this in practice and isn't wrong?
> 
> No. But I can point you to `range-v3` which uses this pattern and I think the 
> idiom is somewhat appealing, but that's orthogonal to Clang diagnosing it.

It seems like simply naming the type avoids the linkage problems. I feel silly 
now.


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-05-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/clang/Basic/DiagnosticGroups.td:631
 // UnusedParameter, (matches GCC's behavior)
+// UnusedTemplate, (clean-up libc++ before enabling)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)

Is libc++ not clean for this? I just ran the libc++ tests with 
-Wunused-template and didn't see any errors.


https://reviews.llvm.org/D29877



___
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 target-features for arm/thumb triples.

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

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

> I'll hold off merging this patch until https://reviews.llvm.org/D33436 lands, 
> which fixes a problem with mixed ARM/Thumb codegen


OK. Commit at will :)

-eric


https://reviews.llvm.org/D33448



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


Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Vitaly Buka via cfe-commits
Could this be the patch
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio

FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818)
 TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll'
FAILED 
Script:
--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=armv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE
--check-prefix=ARM-ENABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=armv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE
--check-prefix=ARM-DISABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=thumbv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE
--check-prefix=THUMB-ENABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=thumbv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE
--check-prefix=THUMB-DISABLE
--
Exit Code: 1

Command Output (stderr):
--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10:
error: expected string not found in input
; CHECK: bl
 ^
:375:7: note: scanning from here
 vldr s0, LCPI12_0
  ^
:377:2: note: possible intended match here
 bx lr
 ^



On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arnolds
> Date: Fri May 26 13:11:54 2017
> New Revision: 304017
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304017=rev
> Log:
> CodeGen: Define Swift's legal vector types for AArch64, ARM
>
> rdar://32401301
>
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> cfe/trunk/test/CodeGen/64bit-swiftcall.c
> cfe/trunk/test/CodeGen/arm-swiftcall.c
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> TargetInfo.cpp?rev=304017=304016=304017=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
> @@ -4821,6 +4821,9 @@ private:
>bool isSwiftErrorInRegister() const override {
>  return true;
>}
> +
> +  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
> + unsigned elts) const override;
>  };
>
>  class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
> @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
>return false;
>  }
>
> +bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize,
> +   llvm::Type *eltTy,
> +   unsigned elts) const {
> +  if (!llvm::isPowerOf2_32(elts))
> +return false;
> +  if (totalSize.getQuantity() != 8 &&
> +  (totalSize.getQuantity() != 16 || elts == 1))
> +return false;
> +  return true;
> +}
> +
>  bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
>// Homogeneous aggregates for AAPCS64 must have base types of a floating
>// point type or a short-vector type. This is the same as the 32-bit
> ABI,
> @@ -5382,6 +5396,8 @@ private:
>bool isSwiftErrorInRegister() const override {
>  

[PATCH] D33537: [clang-tidy] Exception Escape Checker

2017-05-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 100369.
baloghadamsoftware added a comment.

Docs fixed according to the comments.


https://reviews.llvm.org/D33537

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ExceptionEscapeCheck.cpp
  clang-tidy/misc/ExceptionEscapeCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-exception-escape.rst
  test/clang-tidy/misc-exception-escape.cpp

Index: test/clang-tidy/misc-exception-escape.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-exception-escape.cpp
@@ -0,0 +1,245 @@
+// RUN: %check_clang_tidy %s misc-exception-escape %t -- -extra-arg=-std=c++11 -config="{CheckOptions: [{key: misc-exception-escape.IgnoredExceptions, value: 'ignored1,ignored2'}, {key: misc-exception-escape.EnabledFunctions, value: 'enabled1,enabled2,enabled3'}]}" --
+
+struct throwing_destructor {
+  ~throwing_destructor() {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function '~throwing_destructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_constructor {
+  throwing_move_constructor(throwing_move_constructor&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'throwing_move_constructor' throws
+throw 1;
+  }
+};
+
+struct throwing_move_assignment {
+  throwing_move_assignment& operator=(throwing_move_assignment&&) {
+// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: function 'operator=' throws
+throw 1;
+  }
+};
+
+void throwing_noexcept() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_noexcept' throws
+  throw 1;
+}
+
+void throwing_throw_nothing() throw() {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throwing_throw_nothing' throws
+  throw 1;
+}
+
+void throw_and_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch' throws
+  try {
+throw 1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_some() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_catch_some' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  }
+}
+
+void throw_and_catch_each() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_each' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(double &) {
+  }
+}
+
+void throw_and_catch_all() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_and_catch_all' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(...) {
+  }
+}
+
+void throw_and_rethrow() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_and_rethrow' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw;
+  }
+}
+
+void throw_catch_throw() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_throw' throws
+  try {
+throw 1;
+  } catch(int &) {
+throw 2;
+  }
+}
+
+void throw_catch_rethrow_the_rest() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'throw_catch_rethrow_the_rest' throws
+  try {
+throw 1;
+throw 1.1;
+  } catch(int &) {
+  } catch(...) {
+throw;
+  }
+}
+
+class base {};
+class derived: public base {};
+
+void throw_derived_catch_base() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'throw_derived_catch_base' throws
+  try {
+throw derived();
+  } catch(base &) {
+  }
+}
+
+void try_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_try' throws
+  try {
+try {
+  throw 1;
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void bad_try_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_try_nested_try' throws
+  try {
+throw 1;
+try {
+  throw 1.1;
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void try_nested_catch() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'try_nested_catch' throws
+  try {
+try {
+  throw 1;
+} catch(int &) {
+  throw 1.1;
+}
+  } catch(double &) {
+  }
+}
+
+void catch_nested_try() noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: function 'catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1; 
+} catch(int &) {
+}
+  }
+}
+
+void bad_catch_nested_try() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_catch_nested_try' throws
+  try {
+throw 1;
+  } catch(int &) {
+try {
+  throw 1.1; 
+} catch(int &) {
+}
+  } catch(double &) {
+  }
+}
+
+void implicit_int_thrower() {
+  throw 1;
+}
+
+void explicit_int_thrower() throw(int);
+
+void indirect_implicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'indirect_implicit' throws
+  implicit_int_thrower();
+}
+
+void indirect_explicit() noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 

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

2017-05-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 100371.
fhahn added a comment.

Updated the comment, thanks for the reviewing this patch!


https://reviews.llvm.org/D33448

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-long-calls.c
  test/CodeGen/arm-no-movt.c
  test/CodeGen/arm-target-features.c
  test/CodeGen/arm-thumb-mode-target-feature.c

Index: test/CodeGen/arm-thumb-mode-target-feature.c
===
--- /dev/null
+++ test/CodeGen/arm-thumb-mode-target-feature.c
@@ -0,0 +1,33 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang_cc1 -triple thumbv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix THUMB %s
+// RUN: %clang -target armv7-linux-gnueabihf -mthumb -S -emit-llvm -o - %s | FileCheck --check-prefix THUMB-CLANG %s
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+// RUN: %clang_cc1 -triple armv7eb-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix ARM %s
+
+void t1() {}
+
+ __attribute__((target("no-thumb-mode")))
+void t2() {}
+
+ __attribute__((target("thumb-mode")))
+void t3() {}
+
+// THUMB: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
+// THUMB: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+//
+// THUMB-CLANG: void @t1() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t2() [[NoThumbAttr:#[0-7]]]
+// THUMB-CLANG: void @t3() [[ThumbAttr:#[0-7]]]
+// THUMB-CLANG: attributes [[ThumbAttr]] = { {{.*}} "target-features"="{{.*}}+thumb-mode
+// THUMB-CLANG: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="{{.*}}-thumb-mode
+
+// ARM: void @t1() [[NoThumbAtr:#[0-7]]]
+// ARM: void @t2() [[NoThumbAttr:#[0-7]]]
+// ARM: void @t3() [[ThumbAttr:#[0-7]]]
+// ARM: attributes [[NoThumbAttr]] = { {{.*}} "target-features"="-thumb-mode"
+// ARM: attributes [[ThumbAttr]] = { {{.*}} "target-features"="+thumb-mode"
Index: test/CodeGen/arm-target-features.c
===
--- test/CodeGen/arm-target-features.c
+++ test/CodeGen/arm-target-features.c
@@ -1,65 +1,63 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+dsp,+neon,+vfp3"
-
-
-// RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
-// CHECK-VFP3-FP16: "target-features"="+dsp,+fp16,+neon,+vfp3"
+// CHECK-VFP3: "target-features"="+dsp,+neon,+thumb-mode
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+dsp,+neon,+vfp4"
+// CHECK-VFP4: "target-features"="+dsp,+neon,+thumb-mode,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4"
+// CHECK-VFP4-DIV: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+thumb-mode,+vfp4"
 
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV-ARM
+// CHECK-VFP4-DIV-ARM: "target-features"="+dsp,+hwdiv,+hwdiv-arm,+neon,+vfp4,-thumb-mode"
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a32 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a35 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s 

[PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

2017-05-26 Thread David Abdurachmanov via Phabricator via cfe-commits
davidlt added a comment.

This happens with recent GCC 7.1.1 (updated yesterday) and if compiled in C++1z 
mode.

  FAILED: 
/home/davidlt/root_patch_check/a/slc7_ppc64le_gcc700/external/gcc/7.0.0-njopjo2/bin/g++
   -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Iinterpreter/llvm/src/lib/Transforms/Instrumentation 
-I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation
 -Iinterpreter/llvm/src/include 
-I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include
 -D__ROOFIT_NOBANNER -Wno-implicit-fallthrough -Wno-noexcept-type -pipe   
-Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread -std=c++1z 
-fvisibility=hidden -fPIC -fvisibility-inlines-hidden -w -Werror=date-time 
-std=c++1z -ffunction-sections -fdata-sections -O2 -DNDEBUG-fno-exceptions 
-fno-rtti -MD -MT 
interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
 -MF 
interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o.d
 -o 
interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
 -c 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:
 In constructor 
'{anonymous}::PGOInstrumentationUseLegacyPass::PGOInstrumentationUseLegacyPass(std::string)':
  
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:155:25:
 error: 'llvm::cl::opt::opt(const 
llvm::cl::opt&) [with DataType = 
std::basic_string; bool ExternalStorage = false; ParserClass = 
llvm::cl::parser]' is private within this context
 ProfileFileName = PGOTestProfileFile;
   ^~
  In file included from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Support/Options.h:41:0,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/LLVMContext.h:19,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Metadata.h:26,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/TrackingMDRef.h:17,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/DebugLoc.h:18,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Instruction.h:20,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/BasicBlock.h:19,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Function.h:24,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/PassManager.h:44,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Transforms/PGOInstrumentation.h:17,
   from 
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:51:
  
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Support/CommandLine.h:1296:3:
 note: declared private here
 opt(const opt &) = delete;
 ^~~
  
/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:155:25:
 error: use of deleted function 'llvm::cl::opt::opt(const llvm::cl::opt&) 
[with DataType = std::basic_string; bool ExternalStorage = false; 
ParserClass = llvm::cl::parser]'
 ProfileFileName = PGOTestProfileFile;
   

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

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

In https://reviews.llvm.org/D32478#759347, @Typz wrote:

> In https://reviews.llvm.org/D32478#758258, @djasper wrote:
>
> > When you say "this doesn't happen in tests", do you mean this never happens 
> > when there are parentheses around the expression?
>
>
> By 'test' I meant 'conditional construct' : it happens when there are 
> parentheses around the expression, but it does not happen when these 
> parentheses are the parentheses from a `if (...)`


Are you sure? From reading the code, it seems that this happens exactly after 
"=" and "return". What's the behavior for function calls?

  function(aaa //
  + b);

Or for expressions with just parens?

  int a = (aa //
  + bb);

What if doing this would violate the ContinuationIndentWidth?

  T t = a //
  && b;




Comment at: lib/Format/ContinuationIndenter.cpp:759
+return State.Stack.back().Indent - Current.Tok.getLength()
+- Current.SpacesRequiredBefore;
   if (State.Stack.back().Indent == State.FirstIndent && PreviousNonComment &&

Fix style.



Comment at: lib/Format/ContinuationIndenter.cpp:949
+ Previous->is(tok::kw_return)))
+  NewParenState.UnindentOperator = true;
 

I am not yet convinced you need a new flag in ParenState here. I guess you need 
it because the operators can have varying length and so you cannot just change 
LastSpace here?


https://reviews.llvm.org/D32478



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


Re: [PATCH] D33467: Fix LLVM build errors if necent build of GCC 7 is used

2017-05-26 Thread Chandler Carruth via cfe-commits
I kind of think this may be a GCC bug. It is quite strange that no one else
has reported it, and that you're only seeing it in this context. We have
many std::string flags and they are used in this way pretty commonly.

I'm not seeing this with any other GCC-hosted build bot either, including a
PPC one here: http://lab.llvm.org:8011/builders/clang-ppc64le-linux

On Fri, May 26, 2017 at 1:34 AM David Abdurachmanov via Phabricator <
revi...@reviews.llvm.org> wrote:

> davidlt added a comment.
>
> This happens with recent GCC 7.1.1 (updated yesterday) and if compiled in
> C++1z mode.
>
>   FAILED:
> /home/davidlt/root_patch_check/a/slc7_ppc64le_gcc700/external/gcc/7.0.0-njopjo2/bin/g++
>  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Iinterpreter/llvm/src/lib/Transforms/Instrumentation
> -I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation
> -Iinterpreter/llvm/src/include
> -I/home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include
> -D__ROOFIT_NOBANNER -Wno-implicit-fallthrough -Wno-noexcept-type -pipe
>  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -fPIC -pthread
> -std=c++1z -fvisibility=hidden -fPIC -fvisibility-inlines-hidden -w
> -Werror=date-time -std=c++1z -ffunction-sections -fdata-sections -O2
> -DNDEBUG-fno-exceptions -fno-rtti -MD -MT
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
> -MF
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o.d
> -o
> interpreter/llvm/src/lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/PGOInstrumentation.cpp.o
> -c
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
>
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:
> In constructor
> '{anonymous}::PGOInstrumentationUseLegacyPass::PGOInstrumentationUseLegacyPass(std::string)':
>
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:155:25:
> error: 'llvm::cl::opt::opt(const
> llvm::cl::opt&) [with DataType =
> std::basic_string; bool ExternalStorage = false; ParserClass =
> llvm::cl::parser]' is private within this context
>  ProfileFileName = PGOTestProfileFile;
>^~
>   In file included from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Support/Options.h:41:0,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/LLVMContext.h:19,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Metadata.h:26,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/TrackingMDRef.h:17,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/DebugLoc.h:18,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Instruction.h:20,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/BasicBlock.h:19,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/Function.h:24,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/IR/PassManager.h:44,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Transforms/PGOInstrumentation.h:17,
>from
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:51:
>
> /home/davidlt/root_patch_check/a/BUILD/slc7_ppc64le_gcc700/lcg/root/6.09.04/root-6.09.04/interpreter/llvm/src/include/llvm/Support/CommandLine.h:1296:3:
> note: declared private here
>  opt(const opt &) = 

  1   2   >