[PATCH] D28296: [ObjC] The declarator for a block literal should be a definition

2017-01-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D28296



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


[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

2017-01-05 Thread don hinton via Phabricator via cfe-commits
hintonda abandoned this revision.
hintonda added a comment.

Unable to test change here, so have included fix directly in 
https://reviews.llvm.org/D20428.


https://reviews.llvm.org/D28258



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


[PATCH] D20428: Tracking exception specification source locations

2017-01-05 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 83346.
hintonda added a comment.

- Fix compile errors.
- When noexcept expr is invalid, set NoexceptType to EST_BasicNoexcept


https://reviews.llvm.org/D20428

Files:
  include/clang/AST/Decl.h
  include/clang/AST/TypeLoc.h
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  unittests/AST/SourceLocationTest.cpp

Index: unittests/AST/SourceLocationTest.cpp
===
--- unittests/AST/SourceLocationTest.cpp
+++ unittests/AST/SourceLocationTest.cpp
@@ -670,5 +670,72 @@
   Language::Lang_CXX11));
 }
 
+class ExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const TypeLoc ) override {
+auto T =
+  Node.getUnqualifiedLoc().castAs();
+assert(!T.isNull());
+return T.getExceptionSpecRange();
+  }
+};
+
+class ParmVarExceptionSpecRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const ParmVarDecl ) override {
+if (const TypeSourceInfo *TSI = Node.getTypeSourceInfo()) {
+  TypeLoc TL = TSI->getTypeLoc();
+  if (TL.getType()->isPointerType()) {
+TL = TL.getNextTypeLoc().IgnoreParens();
+if (auto FPTL = TL.getAs()) {
+  return FPTL.getExceptionSpecRange();
+}
+  }
+}
+return SourceRange();
+  }
+};
+
+TEST(FunctionDecl, ExceptionSpecifications) {
+  ExceptionSpecRangeVerifier Verifier;
+
+  Verifier.expectRange(1, 10, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f() throw();\n", loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 34);
+  EXPECT_TRUE(Verifier.match("void f() throw(void(void) throw());\n",
+ loc(functionType(;
+
+  Verifier.expectRange(1, 10, 1, 19);
+  std::vector Args;
+  Args.push_back("-fms-extensions");
+  EXPECT_TRUE(Verifier.match("void f() throw(...);\n", loc(functionType()),
+ Args, Language::Lang_CXX));
+
+  Verifier.expectRange(1, 10, 1, 10);
+  EXPECT_TRUE(Verifier.match("void f() noexcept;\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 24);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(false);\n", loc(functionType()),
+ Language::Lang_CXX11));
+
+  Verifier.expectRange(1, 10, 1, 32);
+  EXPECT_TRUE(Verifier.match("void f() noexcept(noexcept(1+1));\n",
+ loc(functionType()), Language::Lang_CXX11));
+
+  ParmVarExceptionSpecRangeVerifier Verifier2;
+  Verifier2.expectRange(1, 25, 1, 31);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) throw());\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType();
+
+  Verifier2.expectRange(1, 25, 1, 38);
+  EXPECT_TRUE(Verifier2.match("void g(void (*fp)(void) noexcept(true));\n",
+  parmVarDecl(hasType(pointerType(pointee(
+  parenType(innerType(functionType())),
+  Language::Lang_CXX11));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -629,6 +629,7 @@
   Record.AddSourceLocation(TL.getLocalRangeBegin());
   Record.AddSourceLocation(TL.getLParenLoc());
   Record.AddSourceLocation(TL.getRParenLoc());
+  Record.AddSourceRange(TL.getExceptionSpecRange());
   Record.AddSourceLocation(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
 Record.AddDeclRef(TL.getParam(i));
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -5990,6 +5990,8 @@
   TL.setLocalRangeBegin(ReadSourceLocation());
   TL.setLParenLoc(ReadSourceLocation());
   TL.setRParenLoc(ReadSourceLocation());
+  TL.setExceptionSpecRange(SourceRange(Reader->ReadSourceLocation(*F, Record, Idx),
+   Reader->ReadSourceLocation(*F, Record, Idx)));
   TL.setLocalRangeEnd(ReadSourceLocation());
   for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
 TL.setParam(i, Reader->ReadDeclAs(*F, Record, Idx));
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -5023,6 +5023,7 @@
   NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
   NewTL.setLParenLoc(TL.getLParenLoc());
   NewTL.setRParenLoc(TL.getRParenLoc());
+  NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
   NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
   for (unsigned i = 0, e = NewTL.getNumParams(); 

Re: r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Eric Christopher via cfe-commits
Thanks!

-eric

On Thu, Jan 5, 2017 at 6:38 PM Saleem Abdulrasool 
wrote:

> SVN r291208
>
> On Thu, Jan 5, 2017 at 6:30 PM, Eric Christopher 
> wrote:
>
> Ok, thanks. I agree that it's a problem. I'm definitely open for testing
> ideas here. There are a few other things in the
> TargetOptions/MCTargetOptions area that are already problematic to test.
>
> -eric
>
> On Thu, Jan 5, 2017 at 6:27 PM Saleem Abdulrasool 
> wrote:
>
> This was certainly the problem that I had.  The test really needs a way to
> check that the field was set.  As you state, this is a problematic area.
> The backend already has a test to ensure that the paths are honored, but, I
> didn't see any way to actually ensure that it was getting sent to the
> backend otherwise.
>
> The module itself doesnt encode the search path, nor is the information in
> the command line.  I can see the argument that the test itself doesn't add
> much value especially with the backend side testing that the processing of
> the inclusion does occur correctly.  I'll go ahead and remove the test
> (which already has ended up being a pain to test).
>
> On Thu, Jan 5, 2017 at 6:11 PM, Eric Christopher 
> wrote:
>
> Hi Saleem,
>
> Love that you wanted to add a test for it, but I'd really prefer that you
> not engage the backend here in order to do it. You can verify some of it
> from the backend and just that the module is correct via the front end if
> you'd like. Ensuring the paths are correct is a bit of a sticky problem,
> but this is an API boundary that we just have problems with.
>
> TL;DR: Would you mind splitting this test into front end and back end
> tests and avoid using the backend in clang's test harness?
>
> Thanks!
>
> -eric
>
> On Thu, Jan 5, 2017 at 8:13 AM Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: compnerd
> Date: Thu Jan  5 10:02:32 2017
> New Revision: 291123
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
> Log:
> CodeGen: plumb header search down to the IAS
>
> inline assembly may use the `.include` directive to include other
> content into the file.  Without the integrated assembler, the `-I` group
> gets passed to the assembler.  Emulate this by collecting the header
> search paths and passing them to the IAS.
>
> Resolves PR24811!
>
> Added:
> cfe/trunk/test/CodeGen/include/
> cfe/trunk/test/CodeGen/include/function.x
> cfe/trunk/test/CodeGen/include/module.x
> cfe/trunk/test/CodeGen/inline-asm-inclusion.c
> Modified:
> cfe/trunk/include/clang/CodeGen/BackendUtil.h
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
> +++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
> @@ -21,6 +21,7 @@ namespace llvm {
>
>  namespace clang {
>class DiagnosticsEngine;
> +  class HeaderSearchOptions;
>class CodeGenOptions;
>class TargetOptions;
>class LangOptions;
> @@ -34,7 +35,8 @@ namespace clang {
>  Backend_EmitObj///< Emit native object files
>};
>
> -  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions
> ,
> +  void EmitBackendOutput(DiagnosticsEngine , const
> HeaderSearchOptions &,
> + const CodeGenOptions ,
>   const TargetOptions , const LangOptions
> ,
>   const llvm::DataLayout , llvm::Module *M,
>   BackendAction Action,
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
> @@ -14,6 +14,7 @@
>  #include "clang/Frontend/CodeGenOptions.h"
>  #include "clang/Frontend/FrontendDiagnostic.h"
>  #include "clang/Frontend/Utils.h"
> +#include "clang/Lex/HeaderSearchOptions.h"
>  #include "llvm/ADT/SmallSet.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/StringSwitch.h"
> @@ -32,6 +33,7 @@
>  #include "llvm/IR/ModuleSummaryIndex.h"
>  #include "llvm/IR/Verifier.h"
>  #include "llvm/LTO/LTOBackend.h"
> +#include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/SubtargetFeature.h"
>  #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
>  #include "llvm/Passes/PassBuilder.h"
> @@ -61,6 +63,7 @@ namespace {
>
>  class EmitAssemblyHelper {
>DiagnosticsEngine 
> +  const 

Re: [libcxx] r291192 - config_elast: fix typo (NFC)

2017-01-05 Thread David Majnemer via cfe-commits
On Thu, Jan 5, 2017 at 3:25 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Jan  5 17:25:44 2017
> New Revision: 291192
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291192=rev
> Log:
> config_elast: fix typo (NFC)
>
> Missed the original typo which was duplicated.  NFC.
>
> Modified:
> libcxx/trunk/src/include/config_elast.h
>
> Modified: libcxx/trunk/src/include/config_elast.h
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/
> include/config_elast.h?rev=291192=291191=291192=diff
> 
> ==
> --- libcxx/trunk/src/include/config_elast.h (original)
> +++ libcxx/trunk/src/include/config_elast.h Thu Jan  5 17:25:44 2017
> @@ -30,7 +30,7 @@
>  // No _LIBCPP_ELAST needed on Apple
>  #elif defined(__sun__)
>  #define _LIBCPP_ELAST ESTALE
> -#elif defined(_LIBCPP_MSCVRT)
> +#elif defined(_LIBCPP_MSVCRT)
>  #define _LIBCPP_ELAST _sys_nerr
>

Isn't ELAST supposed to point to a valid error number? Shouldn't this
be _sys_nerr-1?


>  #else
>  // Warn here so that the person doing the libcxx port has an easier time:
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-01-05 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai updated this revision to Diff 83339.
xiangzhai added a comment.

Hi Anna,

Thanks for your review!

I resubmit the patch with context, please check is it correct, thanks a lot!
And I add testcase: test/Analysis/gmalloc.c


Repository:
  rL LLVM

https://reviews.llvm.org/D28348

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/gmalloc.c

Index: test/Analysis/gmalloc.c
===
--- test/Analysis/gmalloc.c
+++ test/Analysis/gmalloc.c
@@ -0,0 +1,191 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+typedef void* gpointer;
+typedef const void *gconstpointer;
+typedef unsigned long gsize;
+typedef unsigned int guint;
+
+gpointer g_malloc(gsize n_bytes);
+gpointer g_malloc0(gsize n_bytes);
+gpointer g_realloc(gpointer mem, gsize n_bytes);
+gpointer g_try_malloc(gsize n_bytes);
+gpointer g_try_malloc0(gsize n_bytes);
+gpointer g_try_realloc(gpointer mem, gsize n_bytes);
+gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+void g_free(gpointer mem);
+gpointer g_memdup(gconstpointer mem, guint byte_size);
+
+static const gsize n_bytes = 1024;
+
+void f1() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g2); // g2 Double-free
+  g_free(g3);
+  g3 = g_memdup(g3, n_bytes); // g3 Use-after-free
+  // g4 Memory-leak
+  // g5 Memory-leak
+  // g6 Memory-leak
+  // g7 Memory-leak
+  // g8 Memory-leak
+}
+
+void f2() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g3);
+  g3 = g_memdup(g3, n_bytes); // g3 Use-after-free
+}
+
+void f3() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g3);
+  // g4 Memory-leak
+  // g5 Memory-leak
+  // g6 Memory-leak
+  // g7 Memory-leak
+  // g8 Memory-leak
+}
+
+void f4() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g3);
+  g_free(g4);
+  // g5 Memory-leak
+  // g6 Memory-leak
+  // g7 Memory-leak
+  // g8 Memory-leak
+}
+
+void f5() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  

Re: r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
SVN r291208

On Thu, Jan 5, 2017 at 6:30 PM, Eric Christopher  wrote:

> Ok, thanks. I agree that it's a problem. I'm definitely open for testing
> ideas here. There are a few other things in the
> TargetOptions/MCTargetOptions area that are already problematic to test.
>
> -eric
>
> On Thu, Jan 5, 2017 at 6:27 PM Saleem Abdulrasool 
> wrote:
>
>> This was certainly the problem that I had.  The test really needs a way
>> to check that the field was set.  As you state, this is a problematic
>> area.  The backend already has a test to ensure that the paths are honored,
>> but, I didn't see any way to actually ensure that it was getting sent to
>> the backend otherwise.
>>
>> The module itself doesnt encode the search path, nor is the information
>> in the command line.  I can see the argument that the test itself doesn't
>> add much value especially with the backend side testing that the processing
>> of the inclusion does occur correctly.  I'll go ahead and remove the test
>> (which already has ended up being a pain to test).
>>
>> On Thu, Jan 5, 2017 at 6:11 PM, Eric Christopher 
>> wrote:
>>
>> Hi Saleem,
>>
>> Love that you wanted to add a test for it, but I'd really prefer that you
>> not engage the backend here in order to do it. You can verify some of it
>> from the backend and just that the module is correct via the front end if
>> you'd like. Ensuring the paths are correct is a bit of a sticky problem,
>> but this is an API boundary that we just have problems with.
>>
>> TL;DR: Would you mind splitting this test into front end and back end
>> tests and avoid using the backend in clang's test harness?
>>
>> Thanks!
>>
>> -eric
>>
>> On Thu, Jan 5, 2017 at 8:13 AM Saleem Abdulrasool via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: compnerd
>> Date: Thu Jan  5 10:02:32 2017
>> New Revision: 291123
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
>> Log:
>> CodeGen: plumb header search down to the IAS
>>
>> inline assembly may use the `.include` directive to include other
>> content into the file.  Without the integrated assembler, the `-I` group
>> gets passed to the assembler.  Emulate this by collecting the header
>> search paths and passing them to the IAS.
>>
>> Resolves PR24811!
>>
>> Added:
>> cfe/trunk/test/CodeGen/include/
>> cfe/trunk/test/CodeGen/include/function.x
>> cfe/trunk/test/CodeGen/include/module.x
>> cfe/trunk/test/CodeGen/inline-asm-inclusion.c
>> Modified:
>> cfe/trunk/include/clang/CodeGen/BackendUtil.h
>> cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>>
>> Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
>> +++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32
>> 2017
>> @@ -21,6 +21,7 @@ namespace llvm {
>>
>>  namespace clang {
>>class DiagnosticsEngine;
>> +  class HeaderSearchOptions;
>>class CodeGenOptions;
>>class TargetOptions;
>>class LangOptions;
>> @@ -34,7 +35,8 @@ namespace clang {
>>  Backend_EmitObj///< Emit native object files
>>};
>>
>> -  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions
>> ,
>> +  void EmitBackendOutput(DiagnosticsEngine , const
>> HeaderSearchOptions &,
>> + const CodeGenOptions ,
>>   const TargetOptions , const LangOptions
>> ,
>>   const llvm::DataLayout , llvm::Module *M,
>>   BackendAction Action,
>>
>> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>> BackendUtil.cpp?rev=291123=291122=291123=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
>> @@ -14,6 +14,7 @@
>>  #include "clang/Frontend/CodeGenOptions.h"
>>  #include "clang/Frontend/FrontendDiagnostic.h"
>>  #include "clang/Frontend/Utils.h"
>> +#include "clang/Lex/HeaderSearchOptions.h"
>>  #include "llvm/ADT/SmallSet.h"
>>  #include "llvm/ADT/StringExtras.h"
>>  #include "llvm/ADT/StringSwitch.h"
>> @@ -32,6 +33,7 @@
>>  #include "llvm/IR/ModuleSummaryIndex.h"
>>  #include "llvm/IR/Verifier.h"
>>  #include "llvm/LTO/LTOBackend.h"
>> +#include "llvm/MC/MCAsmInfo.h"
>>  #include "llvm/MC/SubtargetFeature.h"
>>  #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
>>  #include "llvm/Passes/PassBuilder.h"
>> @@ -61,6 +63,7 @@ namespace {
>>
>>  class EmitAssemblyHelper {
>>DiagnosticsEngine 
>> +  

r291208 - CodeGen: address post commit review comments for r291123

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 20:27:40 2017
New Revision: 291208

URL: http://llvm.org/viewvc/llvm-project?rev=291208=rev
Log:
CodeGen: address post commit review comments for r291123

This test would force the execution of the backend.  However, the
backend already has a test for this.  Effectively, this was trying to
test that an API call was made properly.  We do not have a good way to
really test this.  The test itself tested very little.

Addresses post-commit review comments from Eric Christopher.

Removed:
cfe/trunk/test/CodeGen/include/function.x
cfe/trunk/test/CodeGen/include/module.x
cfe/trunk/test/CodeGen/inline-asm-inclusion.c

Removed: cfe/trunk/test/CodeGen/include/function.x
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/include/function.x?rev=291207=auto
==
--- cfe/trunk/test/CodeGen/include/function.x (original)
+++ cfe/trunk/test/CodeGen/include/function.x (removed)
@@ -1 +0,0 @@
-FUNCTION = 1

Removed: cfe/trunk/test/CodeGen/include/module.x
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/include/module.x?rev=291207=auto
==
--- cfe/trunk/test/CodeGen/include/module.x (original)
+++ cfe/trunk/test/CodeGen/include/module.x (removed)
@@ -1 +0,0 @@
-MODULE = 1

Removed: cfe/trunk/test/CodeGen/inline-asm-inclusion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-inclusion.c?rev=291207=auto
==
--- cfe/trunk/test/CodeGen/inline-asm-inclusion.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-inclusion.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -triple i686--- -I %p/include -S -o - %s | FileCheck %s
-// REQUIRES: x86-registered-target
-
-__asm__(".include \"module.x\"");
-void function(void) {
-  __asm__(".include \"function.x\"");
-}
-
-// CHECK: MODULE = 1
-// CHECK: FUNCTION = 1
-


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


Re: r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Eric Christopher via cfe-commits
Ok, thanks. I agree that it's a problem. I'm definitely open for testing
ideas here. There are a few other things in the
TargetOptions/MCTargetOptions area that are already problematic to test.

-eric

On Thu, Jan 5, 2017 at 6:27 PM Saleem Abdulrasool 
wrote:

> This was certainly the problem that I had.  The test really needs a way to
> check that the field was set.  As you state, this is a problematic area.
> The backend already has a test to ensure that the paths are honored, but, I
> didn't see any way to actually ensure that it was getting sent to the
> backend otherwise.
>
> The module itself doesnt encode the search path, nor is the information in
> the command line.  I can see the argument that the test itself doesn't add
> much value especially with the backend side testing that the processing of
> the inclusion does occur correctly.  I'll go ahead and remove the test
> (which already has ended up being a pain to test).
>
> On Thu, Jan 5, 2017 at 6:11 PM, Eric Christopher 
> wrote:
>
> Hi Saleem,
>
> Love that you wanted to add a test for it, but I'd really prefer that you
> not engage the backend here in order to do it. You can verify some of it
> from the backend and just that the module is correct via the front end if
> you'd like. Ensuring the paths are correct is a bit of a sticky problem,
> but this is an API boundary that we just have problems with.
>
> TL;DR: Would you mind splitting this test into front end and back end
> tests and avoid using the backend in clang's test harness?
>
> Thanks!
>
> -eric
>
> On Thu, Jan 5, 2017 at 8:13 AM Saleem Abdulrasool via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: compnerd
> Date: Thu Jan  5 10:02:32 2017
> New Revision: 291123
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
> Log:
> CodeGen: plumb header search down to the IAS
>
> inline assembly may use the `.include` directive to include other
> content into the file.  Without the integrated assembler, the `-I` group
> gets passed to the assembler.  Emulate this by collecting the header
> search paths and passing them to the IAS.
>
> Resolves PR24811!
>
> Added:
> cfe/trunk/test/CodeGen/include/
> cfe/trunk/test/CodeGen/include/function.x
> cfe/trunk/test/CodeGen/include/module.x
> cfe/trunk/test/CodeGen/inline-asm-inclusion.c
> Modified:
> cfe/trunk/include/clang/CodeGen/BackendUtil.h
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
> +++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
> @@ -21,6 +21,7 @@ namespace llvm {
>
>  namespace clang {
>class DiagnosticsEngine;
> +  class HeaderSearchOptions;
>class CodeGenOptions;
>class TargetOptions;
>class LangOptions;
> @@ -34,7 +35,8 @@ namespace clang {
>  Backend_EmitObj///< Emit native object files
>};
>
> -  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions
> ,
> +  void EmitBackendOutput(DiagnosticsEngine , const
> HeaderSearchOptions &,
> + const CodeGenOptions ,
>   const TargetOptions , const LangOptions
> ,
>   const llvm::DataLayout , llvm::Module *M,
>   BackendAction Action,
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
> @@ -14,6 +14,7 @@
>  #include "clang/Frontend/CodeGenOptions.h"
>  #include "clang/Frontend/FrontendDiagnostic.h"
>  #include "clang/Frontend/Utils.h"
> +#include "clang/Lex/HeaderSearchOptions.h"
>  #include "llvm/ADT/SmallSet.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/StringSwitch.h"
> @@ -32,6 +33,7 @@
>  #include "llvm/IR/ModuleSummaryIndex.h"
>  #include "llvm/IR/Verifier.h"
>  #include "llvm/LTO/LTOBackend.h"
> +#include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/SubtargetFeature.h"
>  #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
>  #include "llvm/Passes/PassBuilder.h"
> @@ -61,6 +63,7 @@ namespace {
>
>  class EmitAssemblyHelper {
>DiagnosticsEngine 
> +  const HeaderSearchOptions 
>const CodeGenOptions 
>const clang::TargetOptions 
>const LangOptions 
> @@ -100,11 +103,14 @@ private:
>   raw_pwrite_stream );
>
>  public:
> -  

Re: r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Eric Christopher via cfe-commits
Hi Saleem,

Love that you wanted to add a test for it, but I'd really prefer that you
not engage the backend here in order to do it. You can verify some of it
from the backend and just that the module is correct via the front end if
you'd like. Ensuring the paths are correct is a bit of a sticky problem,
but this is an API boundary that we just have problems with.

TL;DR: Would you mind splitting this test into front end and back end tests
and avoid using the backend in clang's test harness?

Thanks!

-eric

On Thu, Jan 5, 2017 at 8:13 AM Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Jan  5 10:02:32 2017
> New Revision: 291123
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
> Log:
> CodeGen: plumb header search down to the IAS
>
> inline assembly may use the `.include` directive to include other
> content into the file.  Without the integrated assembler, the `-I` group
> gets passed to the assembler.  Emulate this by collecting the header
> search paths and passing them to the IAS.
>
> Resolves PR24811!
>
> Added:
> cfe/trunk/test/CodeGen/include/
> cfe/trunk/test/CodeGen/include/function.x
> cfe/trunk/test/CodeGen/include/module.x
> cfe/trunk/test/CodeGen/inline-asm-inclusion.c
> Modified:
> cfe/trunk/include/clang/CodeGen/BackendUtil.h
> cfe/trunk/lib/CodeGen/BackendUtil.cpp
> cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
> +++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
> @@ -21,6 +21,7 @@ namespace llvm {
>
>  namespace clang {
>class DiagnosticsEngine;
> +  class HeaderSearchOptions;
>class CodeGenOptions;
>class TargetOptions;
>class LangOptions;
> @@ -34,7 +35,8 @@ namespace clang {
>  Backend_EmitObj///< Emit native object files
>};
>
> -  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions
> ,
> +  void EmitBackendOutput(DiagnosticsEngine , const
> HeaderSearchOptions &,
> + const CodeGenOptions ,
>   const TargetOptions , const LangOptions
> ,
>   const llvm::DataLayout , llvm::Module *M,
>   BackendAction Action,
>
> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123=291122=291123=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
> @@ -14,6 +14,7 @@
>  #include "clang/Frontend/CodeGenOptions.h"
>  #include "clang/Frontend/FrontendDiagnostic.h"
>  #include "clang/Frontend/Utils.h"
> +#include "clang/Lex/HeaderSearchOptions.h"
>  #include "llvm/ADT/SmallSet.h"
>  #include "llvm/ADT/StringExtras.h"
>  #include "llvm/ADT/StringSwitch.h"
> @@ -32,6 +33,7 @@
>  #include "llvm/IR/ModuleSummaryIndex.h"
>  #include "llvm/IR/Verifier.h"
>  #include "llvm/LTO/LTOBackend.h"
> +#include "llvm/MC/MCAsmInfo.h"
>  #include "llvm/MC/SubtargetFeature.h"
>  #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
>  #include "llvm/Passes/PassBuilder.h"
> @@ -61,6 +63,7 @@ namespace {
>
>  class EmitAssemblyHelper {
>DiagnosticsEngine 
> +  const HeaderSearchOptions 
>const CodeGenOptions 
>const clang::TargetOptions 
>const LangOptions 
> @@ -100,11 +103,14 @@ private:
>   raw_pwrite_stream );
>
>  public:
> -  EmitAssemblyHelper(DiagnosticsEngine &_Diags, const CodeGenOptions
> ,
> +  EmitAssemblyHelper(DiagnosticsEngine &_Diags,
> + const HeaderSearchOptions ,
> + const CodeGenOptions ,
>   const clang::TargetOptions ,
>   const LangOptions , Module *M)
> -  : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts),
> LangOpts(LOpts),
> -TheModule(M), CodeGenerationTime("codegen", "Code Generation
> Time") {}
> +  : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
> +TargetOpts(TOpts), LangOpts(LOpts), TheModule(M),
> +CodeGenerationTime("codegen", "Code Generation Time") {}
>
>~EmitAssemblyHelper() {
>  if (CodeGenOpts.DisableFree)
> @@ -584,12 +590,18 @@ void EmitAssemblyHelper::CreateTargetMac
>Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
>Options.MCOptions.MCIncrementalLinkerCompatible =
>CodeGenOpts.IncrementalLinkerCompatible;
> -  Options.MCOptions.MCPIECopyRelocations =
> -  CodeGenOpts.PIECopyRelocations;
> +  

[clang-tools-extra] r291203 - Fixes for Clang API change

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 19:09:06 2017
New Revision: 291203

URL: http://llvm.org/viewvc/llvm-project?rev=291203=rev
Log:
Fixes for Clang API change

Modified:
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
clang-tools-extra/trunk/modularize/ModularizeUtilities.h

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=291203=291202=291203=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Thu Jan  5 
19:09:06 2017
@@ -44,25 +44,22 @@ public:
 ModularizeUtilities::ModularizeUtilities(std::vector ,
  llvm::StringRef Prefix,
  llvm::StringRef ProblemFilesListPath)
-  : InputFilePaths(InputPaths),
-HeaderPrefix(Prefix),
-ProblemFilesPath(ProblemFilesListPath),
-HasModuleMap(false),
-MissingHeaderCount(0),
-// Init clang stuff needed for loading the module map and preprocessing.
-LangOpts(new LangOptions()), DiagIDs(new DiagnosticIDs()),
-DiagnosticOpts(new DiagnosticOptions()),
-DC(llvm::errs(), DiagnosticOpts.get()),
-Diagnostics(
-new DiagnosticsEngine(DiagIDs, DiagnosticOpts.get(), , false)),
-TargetOpts(new ModuleMapTargetOptions()),
-Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)),
-FileMgr(new FileManager(FileSystemOpts)),
-SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)),
-HeaderSearchOpts(new HeaderSearchOptions()),
-HeaderInfo(new HeaderSearch(HeaderSearchOpts, *SourceMgr, *Diagnostics,
-*LangOpts, Target.get())) {
-}
+: InputFilePaths(InputPaths), HeaderPrefix(Prefix),
+  ProblemFilesPath(ProblemFilesListPath), HasModuleMap(false),
+  MissingHeaderCount(0),
+  // Init clang stuff needed for loading the module map and preprocessing.
+  LangOpts(new LangOptions()), DiagIDs(new DiagnosticIDs()),
+  DiagnosticOpts(new DiagnosticOptions()),
+  DC(llvm::errs(), DiagnosticOpts.get()),
+  Diagnostics(
+  new DiagnosticsEngine(DiagIDs, DiagnosticOpts.get(), , false)),
+  TargetOpts(new ModuleMapTargetOptions()),
+  Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)),
+  FileMgr(new FileManager(FileSystemOpts)),
+  SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)),
+  HeaderInfo(new HeaderSearch(std::make_shared(),
+  *SourceMgr, *Diagnostics, *LangOpts,
+  Target.get())) {}
 
 // Create instance of ModularizeUtilities, to simplify setting up
 // subordinate objects.

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.h?rev=291203=291202=291203=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.h (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.h Thu Jan  5 
19:09:06 2017
@@ -214,8 +214,6 @@ public:
   llvm::IntrusiveRefCntPtr FileMgr;
   /// Source manager.
   llvm::IntrusiveRefCntPtr SourceMgr;
-  /// Options controlling the \#include directive.
-  llvm::IntrusiveRefCntPtr HeaderSearchOpts;
   /// Header search manager.
   std::unique_ptr HeaderInfo;
   // The loaded module map objects.


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


r291202 - shared_ptrify (from InclusiveRefCntPtr) HeaderSearchOptions

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 19:04:46 2017
New Revision: 291202

URL: http://llvm.org/viewvc/llvm-project?rev=291202=rev
Log:
shared_ptrify (from InclusiveRefCntPtr) HeaderSearchOptions

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=291202=291201=291202=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jan  5 19:04:46 2017
@@ -89,7 +89,7 @@ private:
   std::shared_ptr   PP;
   IntrusiveRefCntPtr  Ctx;
   std::shared_ptr  TargetOpts;
-  IntrusiveRefCntPtr HSOpts;
+  std::shared_ptrHSOpts;
   IntrusiveRefCntPtr Reader;
   bool HadModuleLoaderFatalFailure;
 

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291202=291201=291202=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 19:04:46 2017
@@ -288,6 +288,9 @@ public:
   const HeaderSearchOptions () const {
 return Invocation->getHeaderSearchOpts();
   }
+  std::shared_ptr getHeaderSearchOptsPtr() const {
+return Invocation->getHeaderSearchOptsPtr();
+  }
 
   LangOptions () {
 return *Invocation->getLangOpts();

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=291202=291201=291202=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Thu Jan  5 19:04:46 
2017
@@ -65,7 +65,7 @@ public:
   IntrusiveRefCntPtr DiagnosticOpts;
 
   /// Options controlling the \#include directive.
-  IntrusiveRefCntPtr HeaderSearchOpts;
+  std::shared_ptr HeaderSearchOpts;
 
   /// Options controlling the preprocessor (aside from \#include handling).
   std::shared_ptr PreprocessorOpts;
@@ -89,6 +89,9 @@ public:
   const HeaderSearchOptions () const {
 return *HeaderSearchOpts;
   }
+  std::shared_ptr getHeaderSearchOptsPtr() const {
+return HeaderSearchOpts;
+  }
 
   std::shared_ptr getPreprocessorOptsPtr() {
 return PreprocessorOpts;

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=291202=291201=291202=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Thu Jan  5 19:04:46 2017
@@ -147,7 +147,7 @@ class HeaderSearch {
   };
 
   /// \brief Header-search options used to initialize this header search.
-  IntrusiveRefCntPtr HSOpts;
+  std::shared_ptr HSOpts;
 
   DiagnosticsEngine 
   FileManager 
@@ -248,7 +248,7 @@ class HeaderSearch {
   friend class DirectoryLookup;
   
 public:
-  HeaderSearch(IntrusiveRefCntPtr HSOpts,
+  HeaderSearch(std::shared_ptr HSOpts,
SourceManager , DiagnosticsEngine ,
const LangOptions , const TargetInfo *Target);
   ~HeaderSearch();

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=291202=291201=291202=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Thu Jan  5 19:04:46 2017
@@ -44,7 +44,7 @@ namespace frontend {
 
 /// HeaderSearchOptions - Helper class for storing options related to the
 /// initialization of the HeaderSearch object.
-class HeaderSearchOptions : public RefCountedBase {
+class HeaderSearchOptions {
 public:
   struct Entry {
 std::string Path;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291202=291201=291202=diff
==
--- 

[PATCH] D28387: [tsan] Do not report errors in __destroy_helper_block_

2017-01-05 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna created this revision.
zaks.anna added a reviewer: kubabrecka.
zaks.anna added a subscriber: cfe-commits.

There is a synchronization point between the reference count of a block 
dropping to zero and it's destruction, which TSan does not observe. Do not 
report errors in the compiler-emitted block destroy method and everything 
called from it.

This is similar to https://reviews.llvm.org/D25857


https://reviews.llvm.org/D28387

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m


Index: test/CodeGen/sanitize-thread-no-checking-at-run-time.m
===
--- test/CodeGen/sanitize-thread-no-checking-at-run-time.m
+++ test/CodeGen/sanitize-thread-no-checking-at-run-time.m
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o 
- %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks 
-emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+
+// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
 
 __attribute__((objc_root_class))
 @interface NSObject
@@ -26,9 +28,14 @@
 }
 @end
 
-// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
-
 // TSAN: initialize{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: dealloc{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: cxx_destruct{{.*}}) [[ATTR:#[0-9]+]]
+
+void test2(id x) {
+  extern void test2_helper(id (^)(void));
+  test2_helper(^{ return x; });
+// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+}
+
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} 
"sanitize_thread_no_checking_at_run_time" {{.*}} }
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -705,6 +705,11 @@
   return false;
 }
 
+static void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn) {
+  Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
+  Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+}
+
 void CodeGenFunction::StartFunction(GlobalDecl GD,
 QualType RetTy,
 llvm::Function *Fn,
@@ -748,16 +753,19 @@
 Fn->addFnAttr(llvm::Attribute::SafeStack);
 
   // Ignore TSan memory acesses from within ObjC/ObjC++ dealloc, initialize,
-  // .cxx_destruct and all of their calees at run time.
+  // .cxx_destruct, __destroy_helper_block_ and all of their calees at run 
time.
   if (SanOpts.has(SanitizerKind::Thread)) {
 if (const auto *OMD = dyn_cast_or_null(D)) {
   IdentifierInfo *II = OMD->getSelector().getIdentifierInfoForSlot(0);
   if (OMD->getMethodFamily() == OMF_dealloc ||
   OMD->getMethodFamily() == OMF_initialize ||
   (OMD->getSelector().isUnarySelector() && 
II->isStr(".cxx_destruct"))) {
-Fn->addFnAttr("sanitize_thread_no_checking_at_run_time");
-Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
+markAsIgnoreThreadCheckingAtRuntime(Fn);
   }
+} else if (const auto *FD = dyn_cast_or_null(D)) {
+  IdentifierInfo *II = FD->getIdentifier();
+  if (II && II->isStr("__destroy_helper_block_"))
+markAsIgnoreThreadCheckingAtRuntime(Fn);
 }
   }
 


Index: test/CodeGen/sanitize-thread-no-checking-at-run-time.m
===
--- test/CodeGen/sanitize-thread-no-checking-at-run-time.m
+++ test/CodeGen/sanitize-thread-no-checking-at-run-time.m
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -x objective-c++ -fblocks -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+
+// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
 
 __attribute__((objc_root_class))
 @interface NSObject
@@ -26,9 +28,14 @@
 }
 @end
 
-// WITHOUT-NOT: "sanitize_thread_no_checking_at_run_time"
-
 // TSAN: initialize{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: dealloc{{.*}}) [[ATTR:#[0-9]+]]
 // TSAN: cxx_destruct{{.*}}) [[ATTR:#[0-9]+]]
+
+void test2(id x) {
+  extern void test2_helper(id (^)(void));
+  test2_helper(^{ return x; });
+// TSAN: define internal void @__destroy_helper_block_(i8*) [[ATTR:#[0-9]+]]
+}
+
 // TSAN: attributes [[ATTR]] = { noinline nounwind {{.*}} 

[PATCH] D28383: build: add a heuristic to determine the C++ ABI

2017-01-05 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D28383#637570, @majnemer wrote:

> Why isn't this equivalent to `_MSC_VER` ?


It might also be nice for clang to define some macro to indicate which C++ ABI 
is in use.

All that said, I think it makes sense to encode this in libc++ 
include/__config_site because you don't want people to build libc++ for the MS 
ABI and then try to use it with a mingw triple. It'd be nice if we could 
diagnose that at compile time instead of link time.


Repository:
  rL LLVM

https://reviews.llvm.org/D28383



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


[PATCH] D28212: typeinfo: provide a partial implementation for Win32

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd set the repository for this revision to rL LLVM.
compnerd updated this revision to Diff 83326.

Repository:
  rL LLVM

https://reviews.llvm.org/D28212

Files:
  include/typeinfo
  src/typeinfo.cpp

Index: src/typeinfo.cpp
===
--- src/typeinfo.cpp
+++ src/typeinfo.cpp
@@ -15,6 +15,45 @@
 
 #include "typeinfo"
 
+#if defined(_LIBCPP_HAS_MS_ABI_TYPEINFO)
+#include 
+
+const char *std::type_info::__name(std::type_info::__data *__data) {
+  // TODO(compnerd) cache demangled &__data.__decorated_name[1]
+  return &__data->__decorated_name[1];
+}
+
+size_t std::type_info::__hash(const std::type_info::__data *__data) {
+#if defined(_WIN64)
+  static constexpr const size_t fnv_offset_basis = 14695981039346656037ull;
+  static constexpr const size_t fnv_prime = 10995116282110ull;
+#else
+  static constexpr const size_t fnv_offset_basis = 2166136261ull;
+  static constexpr const size_t fnv_prime = 16777619ull;
+#endif
+
+  size_t value = fnv_offset_basis;
+  for (const char *c = &__data->__decorated_name[1]; *c; ++c) {
+value ^= static_cast(static_cast(*c));
+value *= fnv_prime;
+  }
+
+#if defined(_WIN64)
+  value ^= value >> 32;
+#endif
+
+  return value;
+}
+
+int std::type_info::__compare(const std::type_info::__data* __lhs,
+  const std::type_info::__data* __rhs)
+{
+  if (__lhs == __rhs)
+return 0;
+  return strcmp(&__lhs->__decorated_name[1], &__rhs->__decorated_name[1]);
+}
+#endif
+
 #if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
 std::type_info::~type_info()
 {
Index: include/typeinfo
===
--- include/typeinfo
+++ include/typeinfo
@@ -69,11 +69,15 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_ABI_MS)
+#define _LIBCPP_HAS_MS_ABI_TYPEINFO
+#else
 #if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
 #define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
 #else
 #define _LIBCPP_HAS_UNIQUE_TYPEINFO
 #endif
+#endif
 
 namespace std  // purposefully not using versioning namespace
 {
@@ -89,7 +93,21 @@
 { return __builtin_strcmp(name(), __arg.name()); }
 #endif
 
+#if defined(_LIBCPP_HAS_MS_ABI_TYPEINFO)
+  mutable struct __data {
+const char *__undecorated_name;
+const char __decorated_name[1];
+  } __data;
+
+  static const char *__name(const type_info::__data *__data);
+  static size_t __hash(const type_info:__data *__data);
+  static int compare(const type_info::__data* __lhs,
+ const type_info::__data* __rhs);
+#endif
+
 protected:
+#if defined(_LIBCPP_HAS_MS_ABI_TYPEINFO)
+#else
 #if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 // A const char* with the non-unique RTTI bit possibly set.
 uintptr_t __type_name;
@@ -102,10 +120,28 @@
 _LIBCPP_INLINE_VISIBILITY
 type_info(const char* __n) : __type_name(__n) {}
 #endif
+#endif
 
 public:
 virtual ~type_info();
 
+#if defined(_LIBCPP_HAS_MS_ABI_TYPEINFO)
+_LIBCPP_INLINE_VISIBILITY
+const char *name() const _NOEXCEPT
+{ return __name(&__data); }
+
+_LIBCPP_INLINE_VISIBILITY
+bool before(const type_info& __arg) const _NOEXCEPT
+{ return __compre(&__data, &__arg.__data) < 0; }
+
+_LIBCPP_INLINE_VISIBILITY
+size_t hash_code() const _NOEXCEPT
+{ return __hash(&__data); }
+
+_LIBCPP_INLINE_VISIBILITY
+bool operator==(const type_info& __arg) const _NOEXCEPT
+{ return compare(&__data, &__arg.__data) == 0; }
+#else
 #if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 _LIBCPP_INLINE_VISIBILITY
 const char* name() const _NOEXCEPT
@@ -162,6 +198,7 @@
 bool operator==(const type_info& __arg) const _NOEXCEPT
 { return __type_name == __arg.__type_name; }
 #endif
+#endif
 
 _LIBCPP_INLINE_VISIBILITY
 bool operator!=(const type_info& __arg) const _NOEXCEPT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 83325.
hamzasood added a comment.

Improved the code slightly.
Sorry for the spam everyone, this is definitely the one.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,16 +10809,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10843,33 +10837,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1155,6 +1155,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
@@ -1163,19 +1170,12 @@
   llvm::opt::ArgStringList ) const override;
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const override;
+  llvm::opt::ArgStringList ) const override;
 
-  bool getWindowsSDKDir(std::string , int ,
-std::string ,
-std::string ) const;
   bool getWindowsSDKLibraryPath(std::string ) const;
   /// \brief Check if Universal CRT should be used if available
-  bool useUniversalCRT(std::string ) const;
-  bool getUniversalCRTSdkDir(std::string , std::string ) const;
+  bool useUniversalCRT() const;
   bool getUniversalCRTLibraryPath(std::string ) const;
-  bool getVisualStudioInstallDir(std::string ) const;
-  bool getVisualStudioBinariesFolder(const char *clangProgramPath,
- std::string ) const;
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
@@ -1196,7 +1196,11 @@
 
   Tool *buildLinker() const override;
   Tool *buildAssembler() const override;
+
 private:
+  std::string VCToolChainPath;
+  bool IsVS2017OrNewer;
+
   VersionTuple getMSVCVersionFromTriple() const;
   VersionTuple 

[PATCH] D28383: build: add a heuristic to determine the C++ ABI

2017-01-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D28383#637570, @majnemer wrote:

> Why isn't this equivalent to `_MSC_VER` ?


You can have scenarios where you're targeting the Itanium ABI but still have 
`_MSC_VER` defined, e.g.

  % clang -target i686-windows-itanium -fmsc-version=1900 -E -dM - < /dev/null 
| grep _MSC_VER
  #define _MSC_VER 1900


Repository:
  rL LLVM

https://reviews.llvm.org/D28383



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


[PATCH] D28383: build: add a heuristic to determine the C++ ABI

2017-01-05 Thread David Majnemer via Phabricator via cfe-commits
majnemer added a comment.

Why isn't this equivalent to `_MSC_VER` ?


Repository:
  rL LLVM

https://reviews.llvm.org/D28383



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


[PATCH] D28385: Add a cc1 option to force disabling lifetime-markers emission from clang

2017-01-05 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini created this revision.
mehdi_amini added reviewers: chandlerc, rsmith.
mehdi_amini added a subscriber: cfe-commits.

This intended as a debugging/development flag only.


https://reviews.llvm.org/D28385

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CodeGenOptions.def
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/lifetime2.c


Index: clang/test/CodeGen/lifetime2.c
===
--- clang/test/CodeGen/lifetime2.c
+++ clang/test/CodeGen/lifetime2.c
@@ -1,4 +1,6 @@
 // RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s 
-check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \
+// RUN:   | FileCheck %s -check-prefixes=CHECK,O0
 // RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s 
-check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -521,6 +521,7 @@
 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
+  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
   Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -42,6 +42,9 @@
 /// markers.
 static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
   const LangOptions ) {
+  if (CGOpts.DisableLifetimeMarkers)
+return false;
+
   // Asan uses markers for use-after-scope checks.
   if (CGOpts.SanitizeAddressUseAfterScope)
 return true;
Index: clang/include/clang/Frontend/CodeGenOptions.def
===
--- clang/include/clang/Frontend/CodeGenOptions.def
+++ clang/include/clang/Frontend/CodeGenOptions.def
@@ -52,6 +52,7 @@
 CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get
  ///< the pristine IR generated by the
  ///< frontend.
+CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -167,6 +167,9 @@
"frontend by not running any LLVM passes at all">;
 def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
   Alias;
+def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">,
+  HelpText<"Disable lifetime-markers emission even when optimizations are "
+   "enabled">;
 def disable_red_zone : Flag<["-"], "disable-red-zone">,
   HelpText<"Do not emit code that uses the red zone.">;
 def dwarf_column_info : Flag<["-"], "dwarf-column-info">,


Index: clang/test/CodeGen/lifetime2.c
===
--- clang/test/CodeGen/lifetime2.c
+++ clang/test/CodeGen/lifetime2.c
@@ -1,4 +1,6 @@
 // RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O2 -Xclang -disable-lifetime-markers %s \
+// RUN:   | FileCheck %s -check-prefixes=CHECK,O0
 // RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -521,6 +521,7 @@
 Opts.EmitLLVMUseLists = A->getOption().getID() == OPT_emit_llvm_uselists;
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
+  Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
   Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -42,6 +42,9 @@
 /// markers.
 static bool 

[PATCH] D28258: [Sema] Handle invalid noexcept expressions correctly.

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

Looks OK. Is it possible to add a test case for this without 
https://reviews.llvm.org/D20428? If not, this is small enough that rolling it 
into https://reviews.llvm.org/D20428 (so it can be committed with its testcase) 
would make sense.


https://reviews.llvm.org/D28258



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


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 83318.
hamzasood added a comment.

- Re-implemented the PATH searching behaviour (thanks @amccarth for pointing 
that out)
- Updated the base revision.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,16 +10809,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10843,33 +10837,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1155,6 +1155,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
@@ -1163,19 +1170,12 @@
   llvm::opt::ArgStringList ) const override;
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const override;
+  llvm::opt::ArgStringList ) const override;
 
-  bool getWindowsSDKDir(std::string , int ,
-std::string ,
-std::string ) const;
   bool getWindowsSDKLibraryPath(std::string ) const;
   /// \brief Check if Universal CRT should be used if available
-  bool useUniversalCRT(std::string ) const;
-  bool getUniversalCRTSdkDir(std::string , std::string ) const;
+  bool useUniversalCRT() const;
   bool getUniversalCRTLibraryPath(std::string ) const;
-  bool getVisualStudioInstallDir(std::string ) const;
-  bool getVisualStudioBinariesFolder(const char *clangProgramPath,
- std::string ) const;
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
@@ -1196,7 +1196,11 @@
 
   Tool *buildLinker() const override;
   Tool *buildAssembler() const override;
+
 private:
+  std::string VCToolChainPath;
+  bool IsVS2017OrNewer;
+
   VersionTuple 

[libcxx] r291192 - config_elast: fix typo (NFC)

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 17:25:44 2017
New Revision: 291192

URL: http://llvm.org/viewvc/llvm-project?rev=291192=rev
Log:
config_elast: fix typo (NFC)

Missed the original typo which was duplicated.  NFC.

Modified:
libcxx/trunk/src/include/config_elast.h

Modified: libcxx/trunk/src/include/config_elast.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/include/config_elast.h?rev=291192=291191=291192=diff
==
--- libcxx/trunk/src/include/config_elast.h (original)
+++ libcxx/trunk/src/include/config_elast.h Thu Jan  5 17:25:44 2017
@@ -30,7 +30,7 @@
 // No _LIBCPP_ELAST needed on Apple
 #elif defined(__sun__)
 #define _LIBCPP_ELAST ESTALE
-#elif defined(_LIBCPP_MSCVRT)
+#elif defined(_LIBCPP_MSVCRT)
 #define _LIBCPP_ELAST _sys_nerr
 #else
 // Warn here so that the person doing the libcxx port has an easier time:


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


r291191 - Fix bug where types other than 'cv auto', 'cv auto &', and 'cv auto &&' could

2017-01-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan  5 17:12:16 2017
New Revision: 291191

URL: http://llvm.org/viewvc/llvm-project?rev=291191=rev
Log:
Fix bug where types other than 'cv auto', 'cv auto &', and 'cv auto &&' could
incorrectly be deduced from an initializer list in pathological cases.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=291191=291190=291191=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Jan  5 17:12:16 2017
@@ -4127,6 +4127,12 @@ Sema::DeduceAutoType(TypeLoc Type, Expr
 
   InitListExpr *InitList = dyn_cast(Init);
   if (InitList) {
+// Notionally, we substitute std::initializer_list for 'auto' and deduce
+// against that. Such deduction only succeeds if removing cv-qualifiers and
+// references results in std::initializer_list.
+if (!Type.getType().getNonReferenceType()->getAs())
+  return DAR_Failed;
+
 for (unsigned i = 0, e = InitList->getNumInits(); i < e; ++i) {
   if (DeduceTemplateArgumentsFromCallArgument(
   *this, TemplateParamsSt.get(), TemplArg, InitList->getInit(i),

Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=291191=291190=291191=diff
==
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Thu Jan  5 
17:12:16 2017
@@ -337,3 +337,13 @@ namespace update_rbrace_loc_crash {
 Explode([](int) {});
   }
 }
+
+namespace no_conversion_after_auto_list_deduction {
+  // We used to deduce 'auto' == 'std::initializer_list' here, and then
+  // incorrectly accept the declaration of 'x'.
+  struct X { using T = std::initializer_list X::*; operator T(); };
+  auto X::*x = { X() }; // expected-error {{from initializer list}}
+
+  struct Y { using T = std::initializer_list(*)(); operator T(); };
+  auto (*y)() = { Y() }; // expected-error {{from initializer list}}
+}


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


[PATCH] D28383: build: add a heuristic to determine the C++ ABI

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: EricWF, mclow.lists, smeenai, kastiglione.
compnerd added subscribers: cfe-commits, rnk.
compnerd set the repository for this revision to rL LLVM.
Herald added a subscriber: mgorny.

We need to have a more principled method to detect the C++ ABI we are
targeting.  Add a heuristic to determine that and pass it to the build.


Repository:
  rL LLVM

https://reviews.llvm.org/D28383

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in


Index: include/__config_site.in
===
--- include/__config_site.in
+++ include/__config_site.in
@@ -22,5 +22,6 @@
 #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#cmakedefine _LIBCPP_USES_MS_ABI
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -33,6 +33,12 @@
 #define _LIBCPP_ABI_VERSION 1
 #endif
 
+#if defined(_LIBCPP_USES_MS_ABI)
+#define _LIBCPP_ABI_MS
+#else
+#define _LIBCPP_ABI_IA
+#endif
+
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
 // Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -522,6 +522,17 @@
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API 
_LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
+# Indicate the ABI that we are targeting.  If the c++abi library is none and we
+# are building for windows, assume that we want the Microsoft C++ ABI.  Note
+# that MinGW uses the itanium ABI and still reports as WIN32 under CMake.  If 
we
+# are targeting the itanium ABI, then we must have one of the itanium ABI
+# support libraries (libc++abi, libsupc++, or libcxxrt).  Windows itanium and
+# MinGW both will use one of those to provide the support routines which
+# differentiates it from MS ABI.
+if(WIN32 AND NOT MINGW AND "${LIBCXX_CXX_ABI}" STREQUAL "none")
+  config_define_if(TRUE _LIBCPP_USES_MS_ABI)
+endif()
+
 # By default libc++ on Windows expects to use a shared library, which requires
 # the headers to use DLL import/export semantics. However when building a
 # static library only we modify the headers to disable DLL import/export.


Index: include/__config_site.in
===
--- include/__config_site.in
+++ include/__config_site.in
@@ -22,5 +22,6 @@
 #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#cmakedefine _LIBCPP_USES_MS_ABI
 
 #endif // _LIBCPP_CONFIG_SITE
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -33,6 +33,12 @@
 #define _LIBCPP_ABI_VERSION 1
 #endif
 
+#if defined(_LIBCPP_USES_MS_ABI)
+#define _LIBCPP_ABI_MS
+#else
+#define _LIBCPP_ABI_IA
+#endif
+
 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
 // Change short string representation so that string data starts at offset 0,
 // improving its alignment in some cases.
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -522,6 +522,17 @@
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
 
+# Indicate the ABI that we are targeting.  If the c++abi library is none and we
+# are building for windows, assume that we want the Microsoft C++ ABI.  Note
+# that MinGW uses the itanium ABI and still reports as WIN32 under CMake.  If we
+# are targeting the itanium ABI, then we must have one of the itanium ABI
+# support libraries (libc++abi, libsupc++, or libcxxrt).  Windows itanium and
+# MinGW both will use one of those to provide the support routines which
+# differentiates it from MS ABI.
+if(WIN32 AND NOT MINGW AND "${LIBCXX_CXX_ABI}" STREQUAL "none")
+  config_define_if(TRUE _LIBCPP_USES_MS_ABI)
+endif()
+
 # By default libc++ on Windows expects to use a shared library, which requires
 # the headers to use DLL import/export semantics. However when building a
 # static library only we modify the headers to disable DLL import/export.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2017-01-05 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

@EricWF ok to commit?


https://reviews.llvm.org/D27429



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


r291190 - Add missing "original call argument has same type as deduced parameter type"

2017-01-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan  5 17:02:44 2017
New Revision: 291190

URL: http://llvm.org/viewvc/llvm-project?rev=291190=rev
Log:
Add missing "original call argument has same type as deduced parameter type"
check for deductions from elements of a braced-init-list.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291190=291189=291190=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan  5 17:02:44 
2017
@@ -3377,8 +3377,10 @@ def note_addrof_ovl_candidate_disabled_b
 "candidate function made ineligible by enable_if">;
 def note_ovl_candidate_deduced_mismatch : Note<
 "candidate template ignored: deduced type "
-"%diff{$ of %ordinal0 parameter does not match adjusted type $ of argument"
-"|of %ordinal0 parameter does not match adjusted type of argument}1,2%3">;
+"%diff{$ of %select{|element of }4%ordinal0 parameter does not match "
+"adjusted type $ of %select{|element of }4argument"
+"|of %select{|element of }4%ordinal0 parameter does not match "
+"adjusted type of %select{|element of }4argument}1,2%3">;
 def note_ovl_candidate_non_deduced_mismatch : Note<
 "candidate template ignored: could not match %diff{$ against $|types}0,1">;
 // This note is needed because the above note would sometimes print two

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=291190=291189=291190=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan  5 17:02:44 2017
@@ -6564,6 +6564,10 @@ public:
 /// \brief After substituting deduced template arguments, a dependent
 /// parameter type did not match the corresponding argument.
 TDK_DeducedMismatch,
+/// \brief After substituting deduced template arguments, an element of
+/// a dependent parameter type did not match the corresponding element
+/// of the corresponding argument (when deducing from an initializer list).
+TDK_DeducedMismatchNested,
 /// \brief A non-depnedent component of the parameter did not match the
 /// corresponding component of the argument.
 TDK_NonDeducedMismatch,
@@ -6602,13 +6606,14 @@ public:
   /// brief A function argument from which we performed template argument
   // deduction for a call.
   struct OriginalCallArg {
-OriginalCallArg(QualType OriginalParamType,
-unsigned ArgIdx,
-QualType OriginalArgType)
-  : OriginalParamType(OriginalParamType), ArgIdx(ArgIdx),
-OriginalArgType(OriginalArgType) { }
+OriginalCallArg(QualType OriginalParamType, bool DecomposedParam,
+unsigned ArgIdx, QualType OriginalArgType)
+: OriginalParamType(OriginalParamType),
+  DecomposedParam(DecomposedParam), ArgIdx(ArgIdx),
+  OriginalArgType(OriginalArgType) {}
 
 QualType OriginalParamType;
+bool DecomposedParam;
 unsigned ArgIdx;
 QualType OriginalArgType;
   };

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=291190=291189=291190=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jan  5 17:02:44 2017
@@ -604,7 +604,8 @@ clang::MakeDeductionFailureInfo(ASTConte
 Result.Data = Info.Param.getOpaqueValue();
 break;
 
-  case Sema::TDK_DeducedMismatch: {
+  case Sema::TDK_DeducedMismatch:
+  case Sema::TDK_DeducedMismatchNested: {
 // FIXME: Should allocate from normal heap so that we can free this later.
 auto *Saved = new (Context) DFIDeducedMismatchArgs;
 Saved->FirstArg = Info.FirstArg;
@@ -664,6 +665,7 @@ void DeductionFailureInfo::Destroy() {
   case Sema::TDK_Inconsistent:
   case Sema::TDK_Underqualified:
   case Sema::TDK_DeducedMismatch:
+  case Sema::TDK_DeducedMismatchNested:
   case Sema::TDK_NonDeducedMismatch:
 // FIXME: Destroy the data?
 Data = nullptr;
@@ -699,6 +701,7 @@ TemplateParameter DeductionFailureInfo::
   case Sema::TDK_TooFewArguments:
   case Sema::TDK_SubstitutionFailure:
   case Sema::TDK_DeducedMismatch:
+  case Sema::TDK_DeducedMismatchNested:
   case Sema::TDK_NonDeducedMismatch:
   case Sema::TDK_CUDATargetMismatch:
 return TemplateParameter();
@@ -735,6 +738,7 @@ 

Re: r291179 - Add vec_insert4b and vec_extract4b functions to altivec.h

2017-01-05 Thread Sean Fertile via cfe-commits
 
Sorry about that I've removed the  2 tests causing the issue for now.
 
Sean
 
- Original message -From: Evgenii Stepanov To: Sean Fertile/Toronto/IBM@IBMCACc: cfe-commits Subject: Re: r291179 - Add vec_insert4b and vec_extract4b functions to altivec.hDate: Thu, Jan 5, 2017 5:16 PM 
Tests on linux/x86_64 are failing with:fatal error: error in backend: Cannot select: intrinsic %llvm.ppc.vsx.xxinsertwOn Thu, Jan 5, 2017 at 1:43 PM, Sean Fertile via cfe-commits wrote:> Author: sfertile> Date: Thu Jan  5 15:43:30 2017> New Revision: 291179>> URL: http://llvm.org/viewvc/llvm-project?rev=291179=rev> Log:> Add vec_insert4b and vec_extract4b functions to altivec.h>> Add builtins for the functions and custom codegen mapping the builtins to their> corresponding intrinsics and handling the endian related swapping.>> https://reviews.llvm.org/D26546>> Added:>     cfe/trunk/test/CodeGen/builtins-ppc-error.c>     cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c>     cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c> Modified:>     cfe/trunk/include/clang/Basic/BuiltinsPPC.def>     cfe/trunk/lib/CodeGen/CGBuiltin.cpp>     cfe/trunk/lib/Headers/altivec.h>     cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c>> Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=291179=291178=291179=diff> ==> --- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)> +++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Jan  5 15:43:30 2017> @@ -417,6 +417,9 @@ BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us>  BUILTIN(__builtin_vsx_xvtstdcdp, "V2ULLiV2dIi", "")>  BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4fIi", "")>> +BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")> +BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")> +>  // HTM builtins>  BUILTIN(__builtin_tbegin, "UiUIi", "")>  BUILTIN(__builtin_tend, "UiUIi", "")>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=291179=291178=291179=diff> ==> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jan  5 15:43:30 2017> @@ -35,6 +35,11 @@ using namespace clang;>  using namespace CodeGen;>  using namespace llvm;>> +static> +int64_t clamp(int64_t Value, int64_t Low, int64_t High) {> +  return std::min(High, std::max(Low, Value));> +}> +>  /// getBuiltinLibFunction - Given a builtin id for a function like>  /// "__builtin_fabsf", return a Function* for "fabsf".>  llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,> @@ -8191,6 +8196,85 @@ Value *CodeGenFunction::EmitPPCBuiltinEx>      llvm_unreachable("Unknown FMA operation");>      return nullptr; // Suppress no-return warning>    }> +> +  case PPC::BI__builtin_vsx_insertword: {> +    llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxinsertw);> +> +    // Third argument is a compile time constant int. It must be clamped to> +    // to the range [0, 12].> +    ConstantInt *ArgCI = dyn_cast(Ops[2]);> +    assert(ArgCI &&> +           "Third arg to xxinsertw intrinsic must be constant integer");> +    const int64_t MaxIndex = 12;> +    int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);> +> +    // The builtin semantics don't exactly match the xxinsertw instructions> +    // semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the> +    // word from the first argument, and inserts it in the second argument. The> +    // instruction extracts the word from its second input register and inserts> +    // it into its first input register, so swap the first and second arguments.> +    std::swap(Ops[0], Ops[1]);> +> +    // Need to cast the second argument from a vector of unsigned int to a> +    // vector of long long.> +    Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 2));> +> +    if (getTarget().isLittleEndian()) {> +      // Create a shuffle mask of (1, 0)> +      Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),> +                                   ConstantInt::get(Int32Ty, 0)> +                                 };> +      Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);> +> +      // Reverse the double words in the vector we will extract from.> +      Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 2));> +      Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], ShuffleMask);> +> +      // Reverse the index.> +      Index = MaxIndex - Index;> +    }> +> +    // Intrinsic expects the first arg to be a vector of int.> +    Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 4));> +    Ops[2] = ConstantInt::getSigned(Int32Ty, Index);> +  

r291188 - Remove the ppc insertword/extractword expected fail tests.

2017-01-05 Thread Sean Fertile via cfe-commits
Author: sfertile
Date: Thu Jan  5 16:54:34 2017
New Revision: 291188

URL: http://llvm.org/viewvc/llvm-project?rev=291188=rev
Log:
Remove the ppc insertword/extractword expected fail tests.

Removed:
cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c
cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c

Removed: cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c?rev=291187=auto
==
--- cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c (removed)
@@ -1,15 +0,0 @@
-// REQUIRES: powerpc-registered-target
-// XFAIL: powerpc
-
-// RUN: %clang -faltivec -target powerpc64le-unknown-unknown  -mcpu=power8 \
-// RUN: -Wall -Wextra -c %s
-// RUN: %clang -faltivec -target powerpc64-unknown-unknown  -mcpu=power8 \
-// RUN: -Wall -Wextra -c %s
-
-// Expect the compile to fail with "cannot compile this builtin function yet"
-extern vector signed int vsi;
-extern vector unsigned char vuc;
-
-vector unsigned long long testExtractWord(void) {
-  return  __builtin_vsx_extractuword(vuc, 12);
-}

Removed: cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c?rev=291187=auto
==
--- cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c (removed)
@@ -1,16 +0,0 @@
-// REQUIRES: powerpc-registered-target
-// XFAIL: powerpc
-
-// RUN: %clang -faltivec -target powerpc64le-unknown-unknown -mcpu=power8 \
-// RUN: -Wall -Werror -c %s
-
-// RUN: %clang -faltivec -target powerpc64-unknown-unknown -mcpu=power8 \
-// RUN: -Wall -Werror -c %s
-
-// expect to fail  with diagnostic: "cannot compile this builtin function yet"
-extern vector signed int vsi;
-extern vector unsigned char vuc;
-
-vector  unsigned char testInsertWord(void) {
-  return __builtin_vsx_insertword(vsi, vuc, 0);
-}


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


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

2017-01-05 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added inline comments.



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

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > firolino wrote:
> > > > aaron.ballman wrote:
> > > > > firolino wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > firolino wrote:
> > > > > > > > > > firolino wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > firolino wrote:
> > > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > to
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } Object1, 
> > > > > > > > > > > > > Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > or
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > class A { 
> > > > > > > > > > > > > } 
> > > > > > > > > > > > > Object1, 
> > > > > > > > > > > > > Object2;
> > > > > > > > > > > > > ``` 
> > > > > > > > > > > > > I might consider adding support for it. Moreover, 
> > > > > > > > > > > > > this kind of definition is usually seen globally and 
> > > > > > > > > > > > > I don't know how to handle globals yet. See 
> > > > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > > > I think this should be handled. It can be handled in 
> > > > > > > > > > > > either of the forms you show, or by saying:
> > > > > > > > > > > > ```
> > > > > > > > > > > > A Object1;
> > > > > > > > > > > > A Object2;
> > > > > > > > > > > > ```
> > > > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > > > 
> > > > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > > > separate patch once we figure out the declaration 
> > > > > > > > > > > > grouping.
> > > > > > > > > > > OK. I will try to split the object definition from the 
> > > > > > > > > > > class definition, as you have suggested. Thus, I can kick 
> > > > > > > > > > > out the tagDecl-matcher as well. If there is no easy way 
> > > > > > > > > > > to do this, it will be reported anyway but without a 
> > > > > > > > > > > fixit.
> > > > > > > > > > > 
> > > > > > > > > > > Note for me: Update documentation!
> > > > > > > > > > What about
> > > > > > > > > > ```
> > > > > > > > > > struct S {
> > > > > > > > > > } S1;
> > > > > > > > > > ```
> > > > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > > > ```
> > > > > > > > > struct {
> > > > > > > > > } nn1, nn2;
> > > > > > > > > ```
> > > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > > To be more precise: Warn and provide a fixit for `struct S {} 
> > > > > > > > S1`. Only warn for `struct {} nn1, nn2`.
> > > > > > > > What about
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > struct S {
> > > > > > > > } S1;
> > > > > > > > ```
> > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > declared here. S and S1. What do you think?
> > > > > > > 
> > > > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > > > relatively common pattern (arguably more common than `struct S { 
> > > > > > > } S1, S2;`), but also, it names two very distinct entities (a 
> > > > > > > type and a variable).
> > > > > > > 
> > > > > > > > ```
> > > > > > > > struct {
> > > > > > > > } nn1, nn2;
> > > > > > > >```
> > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > 
> > > > > > > Yes, we basically have to.
> > > > > > > 
> > > > > > Transforming
> > > > > > ```
> > > > > > typedef struct X { int t; } X, Y;
> > > > > > ```
> > > > > > to
> > > > > > ```
> > > > > > typedef struct X { int t; };
> > > > > > typedef X X;
> > > > > > typedef X Y;
> > > > > > ```
> > > > > > will be valid, but looks odd.
> > > > > I am on the fence about this transformation -- it does not declare 
> > > > > new objects, but instead declares new types. A very common pattern in 
> > > > > some libraries (such as the Win32 SDK) is to declare:
> > > > > ```
> > > > > typedef struct Blah {
> > > > > 
> > > > > } Blah, *PBlah, **PPBlah;
> > > > > ```
> > > > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > > > very chatty in some projects, and I don't know that the fixit 
> > > > > provides much real benefit for types.
> > > > > 
> > > > > At least for the CERT 

[clang-tools-extra] r291186 - Fix for shared_ptrification in Clang

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:44:07 2017
New Revision: 291186

URL: http://llvm.org/viewvc/llvm-project?rev=291186=rev
Log:
Fix for shared_ptrification in Clang

Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=291186=291185=291186=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Thu Jan  5 16:44:07 
2017
@@ -82,14 +82,15 @@ IncludeFixerActionFactory::IncludeFixerA
 IncludeFixerActionFactory::~IncludeFixerActionFactory() = default;
 
 bool IncludeFixerActionFactory::runInvocation(
-clang::CompilerInvocation *Invocation, clang::FileManager *Files,
+std::shared_ptr Invocation,
+clang::FileManager *Files,
 std::shared_ptr PCHContainerOps,
 clang::DiagnosticConsumer *Diagnostics) {
   assert(Invocation->getFrontendOpts().Inputs.size() == 1);
 
   // Set up Clang.
   clang::CompilerInstance Compiler(PCHContainerOps);
-  Compiler.setInvocation(Invocation);
+  Compiler.setInvocation(std::move(Invocation));
   Compiler.setFileManager(Files);
 
   // Create the compiler's actual diagnostics engine. We want to drop all

Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev=291186=291185=291186=diff
==
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h Thu Jan  5 16:44:07 
2017
@@ -42,7 +42,7 @@ public:
   ~IncludeFixerActionFactory() override;
 
   bool
-  runInvocation(clang::CompilerInvocation *Invocation,
+  runInvocation(std::shared_ptr Invocation,
 clang::FileManager *Files,
 std::shared_ptr PCHContainerOps,
 clang::DiagnosticConsumer *Diagnostics) override;


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


[PATCH] D28381: [WebAssembly] Always inline atomics

2017-01-05 Thread Jacob Gravelle via Phabricator via cfe-commits
jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

Wasm MVP doesn't have any mechanism to respect atomicity. Skip emitting
libcalls for the time being.


https://reviews.llvm.org/D28381

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple ,
const TargetOptions )
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8610,7 +8610,7 @@
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8137,7 +8137,8 @@
   explicit WebAssembly32TargetInfo(const llvm::Triple ,
const TargetOptions )
   : WebAssemblyTargetInfo(T, Opts) {
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+// WebAssembly MVP has no way to express atomics, so always inline them
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128");
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291185 - Fix examples for recent shared_ptrification

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:36:44 2017
New Revision: 291185

URL: http://llvm.org/viewvc/llvm-project?rev=291185=rev
Log:
Fix examples for recent shared_ptrification

Modified:
cfe/trunk/examples/clang-interpreter/main.cpp

Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=291185=291184=291185=diff
==
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Thu Jan  5 16:36:44 2017
@@ -145,7 +145,7 @@ int main(int argc, const char **argv, ch
 
   // Create a compiler instance to handle the actual work.
   CompilerInstance Clang;
-  Clang.setInvocation(CI.release());
+  Clang.setInvocation(std::move(CI));
 
   // Create the compilers actual diagnostics engine.
   Clang.createDiagnostics();


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


[PATCH] D28231: -Wunreachable-code: Avoid multiple diagnostics that are triggered by the same source range and fix the unary operator fixit source range

2017-01-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Analysis/ReachableCode.cpp:229
+  if (SilenceableCondValNotSet && SilenceableCondVal->getBegin().isValid())
+*SilenceableCondVal = UO->getSourceRange();
+  return UO->getOpcode() == UO_LNot && IsSubExprConfigValue;

Thanks, that fixed the incorrect fixit. The patch looks good to me, but there 
are still cases in which the suggestions clang makes are not accurate. Perhaps 
you can leave a FIXME somewhere so that we don't forget to fix it later?

For example, if we change the condition in the test case to this,

```
if (!(s->p && 0))
```

, clang suggests enclosing the entire expression with a parenthesis (caret 
points to "!"), but the warning will not go away unless the parenthesis is 
around "0".

The second example is in function unaryOpFixit in warn-unreachable.c. clang 
suggests enclosing "-1" with a parenthesis, but it still warns after putting 
the parenthesis around "-1" or "1".


Repository:
  rL LLVM

https://reviews.llvm.org/D28231



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


r291184 - IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeCompleteConsumer

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 16:19:11 2017
New Revision: 291184

URL: http://llvm.org/viewvc/llvm-project?rev=291184=rev
Log:
IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and 
CodeCompleteConsumer

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Tooling/Tooling.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
cfe/trunk/tools/diagtool/ShowEnabledWarnings.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CXTranslationUnit.h
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=291184=291183=291184=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jan  5 16:19:11 2017
@@ -108,8 +108,8 @@ private:
 
   /// Optional owned invocation, just used to make the invocation used in
   /// LoadFromCommandLine available.
-  IntrusiveRefCntPtr Invocation;
-  
+  std::shared_ptr Invocation;
+
   // OnlyLocalDecls - when true, walking this AST should only visit 
declarations
   // that come from the AST itself, not from included precompiled headers.
   // FIXME: This is temporary; eventually, CIndex will always do this.
@@ -358,22 +358,21 @@ public:
   }
   
   /// \brief Retrieve the allocator used to cache global code completions.
-  IntrusiveRefCntPtr
+  std::shared_ptr
   getCachedCompletionAllocator() {
 return CachedCompletionAllocator;
   }
 
   CodeCompletionTUInfo () {
 if (!CCTUInfo)
-  CCTUInfo.reset(new CodeCompletionTUInfo(
-new 
GlobalCodeCompletionAllocator));
+  CCTUInfo = llvm::make_unique(
+  std::make_shared());
 return *CCTUInfo;
   }
 
 private:
   /// \brief Allocator used to store cached code completions.
-  IntrusiveRefCntPtr
-CachedCompletionAllocator;
+  std::shared_ptr CachedCompletionAllocator;
 
   std::unique_ptr CCTUInfo;
 
@@ -702,11 +701,11 @@ public:
   /// remapped contents of that file.
   typedef std::pair RemappedFile;
 
-  /// \brief Create a ASTUnit. Gets ownership of the passed 
CompilerInvocation. 
-  static ASTUnit *create(CompilerInvocation *CI,
- IntrusiveRefCntPtr Diags,
- bool CaptureDiagnostics,
- bool UserFilesAreVolatile);
+  /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
+  static std::unique_ptr
+  create(std::shared_ptr CI,
+ IntrusiveRefCntPtr Diags, bool CaptureDiagnostics,
+ bool UserFilesAreVolatile);
 
   /// \brief Create a ASTUnit from an AST file.
   ///
@@ -771,7 +770,7 @@ public:
   /// created ASTUnit was passed in \p Unit then the caller can check that.
   ///
   static ASTUnit *LoadFromCompilerInvocationAction(
-  CompilerInvocation *CI,
+  std::shared_ptr CI,
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags,
   FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
@@ -798,7 +797,7 @@ public:
   // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
   // shouldn't need to specify them at construction time.
   static std::unique_ptr LoadFromCompilerInvocation(
-  CompilerInvocation *CI,
+  std::shared_ptr CI,
   std::shared_ptr PCHContainerOps,
   IntrusiveRefCntPtr Diags, FileManager *FileMgr,
   bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291184=291183=291184=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 16:19:11 2017
@@ -70,7 +70,7 @@ class TargetInfo;
 /// and a long form that 

Re: r291179 - Add vec_insert4b and vec_extract4b functions to altivec.h

2017-01-05 Thread Evgenii Stepanov via cfe-commits
Tests on linux/x86_64 are failing with:
fatal error: error in backend: Cannot select: intrinsic %llvm.ppc.vsx.xxinsertw

On Thu, Jan 5, 2017 at 1:43 PM, Sean Fertile via cfe-commits
 wrote:
> Author: sfertile
> Date: Thu Jan  5 15:43:30 2017
> New Revision: 291179
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291179=rev
> Log:
> Add vec_insert4b and vec_extract4b functions to altivec.h
>
> Add builtins for the functions and custom codegen mapping the builtins to 
> their
> corresponding intrinsics and handling the endian related swapping.
>
> https://reviews.llvm.org/D26546
>
> Added:
> cfe/trunk/test/CodeGen/builtins-ppc-error.c
> cfe/trunk/test/CodeGen/builtins-ppc-extractword-error.c
> cfe/trunk/test/CodeGen/builtins-ppc-insertword-error.c
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsPPC.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/altivec.h
> cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=291179=291178=291179=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Jan  5 15:43:30 2017
> @@ -417,6 +417,9 @@ BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us
>  BUILTIN(__builtin_vsx_xvtstdcdp, "V2ULLiV2dIi", "")
>  BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4fIi", "")
>
> +BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")
> +BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
> +
>  // HTM builtins
>  BUILTIN(__builtin_tbegin, "UiUIi", "")
>  BUILTIN(__builtin_tend, "UiUIi", "")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=291179=291178=291179=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jan  5 15:43:30 2017
> @@ -35,6 +35,11 @@ using namespace clang;
>  using namespace CodeGen;
>  using namespace llvm;
>
> +static
> +int64_t clamp(int64_t Value, int64_t Low, int64_t High) {
> +  return std::min(High, std::max(Low, Value));
> +}
> +
>  /// getBuiltinLibFunction - Given a builtin id for a function like
>  /// "__builtin_fabsf", return a Function* for "fabsf".
>  llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
> @@ -8191,6 +8196,85 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
>  llvm_unreachable("Unknown FMA operation");
>  return nullptr; // Suppress no-return warning
>}
> +
> +  case PPC::BI__builtin_vsx_insertword: {
> +llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxinsertw);
> +
> +// Third argument is a compile time constant int. It must be clamped to
> +// to the range [0, 12].
> +ConstantInt *ArgCI = dyn_cast(Ops[2]);
> +assert(ArgCI &&
> +   "Third arg to xxinsertw intrinsic must be constant integer");
> +const int64_t MaxIndex = 12;
> +int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
> +
> +// The builtin semantics don't exactly match the xxinsertw instructions
> +// semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the
> +// word from the first argument, and inserts it in the second argument. 
> The
> +// instruction extracts the word from its second input register and 
> inserts
> +// it into its first input register, so swap the first and second 
> arguments.
> +std::swap(Ops[0], Ops[1]);
> +
> +// Need to cast the second argument from a vector of unsigned int to a
> +// vector of long long.
> +Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 
> 2));
> +
> +if (getTarget().isLittleEndian()) {
> +  // Create a shuffle mask of (1, 0)
> +  Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),
> +   ConstantInt::get(Int32Ty, 0)
> + };
> +  Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
> +
> +  // Reverse the double words in the vector we will extract from.
> +  Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 
> 2));
> +  Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], ShuffleMask);
> +
> +  // Reverse the index.
> +  Index = MaxIndex - Index;
> +}
> +
> +// Intrinsic expects the first arg to be a vector of int.
> +Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 
> 4));
> +Ops[2] = ConstantInt::getSigned(Int32Ty, Index);
> +return Builder.CreateCall(F, Ops);
> +  }
> +
> +  case PPC::BI__builtin_vsx_extractuword: {
> +llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxextractuw);
> +
> +// Intrinsic expects the first 

[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

(I could be missing something because the diff doesn't have much context.)

If I'm reading this right, it looks like it will no longer search the PATH in 
order to find cl.exe.  If that's the case, then I'm mildly worried about this 
change in behavior.  I know I have multiple versions of VS installed, and 
commonly select one just by moving its bin directory to the head of PATH.  The 
old behavior would find that one (which is used for things like defaulting 
-fms-compatibility-version) while the new behavior will find the newest one 
installed on the machine.

That's not necessarily a deal breaker, but it's an important change for Windows 
developers to be aware of.


https://reviews.llvm.org/D28365



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


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 83303.
hamzasood added a comment.

- Fixed an error in retrieving a toolchain path from the registry.
- Updated the base revision.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10809,16 +10809,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10843,33 +10837,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1155,6 +1155,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
@@ -1163,19 +1170,12 @@
   llvm::opt::ArgStringList ) const override;
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const override;
+  llvm::opt::ArgStringList ) const override;
 
-  bool getWindowsSDKDir(std::string , int ,
-std::string ,
-std::string ) const;
   bool getWindowsSDKLibraryPath(std::string ) const;
   /// \brief Check if Universal CRT should be used if available
-  bool useUniversalCRT(std::string ) const;
-  bool getUniversalCRTSdkDir(std::string , std::string ) const;
+  bool useUniversalCRT() const;
   bool getUniversalCRTLibraryPath(std::string ) const;
-  bool getVisualStudioInstallDir(std::string ) const;
-  bool getVisualStudioBinariesFolder(const char *clangProgramPath,
- std::string ) const;
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
@@ -1196,7 +1196,11 @@
 
   Tool *buildLinker() const override;
   Tool *buildAssembler() const override;
+
 private:
+  std::string VCToolChainPath;
+  bool IsVS2017OrNewer;
+
   VersionTuple getMSVCVersionFromTriple() const;
   

r291179 - Add vec_insert4b and vec_extract4b functions to altivec.h

2017-01-05 Thread Sean Fertile via cfe-commits
Author: sfertile
Date: Thu Jan  5 15:43:30 2017
New Revision: 291179

URL: http://llvm.org/viewvc/llvm-project?rev=291179=rev
Log:
Add vec_insert4b and vec_extract4b functions to altivec.h

Add builtins for the functions and custom codegen mapping the builtins to their
corresponding intrinsics and handling the endian related swapping.

https://reviews.llvm.org/D26546

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=291179=291178=291179=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Jan  5 15:43:30 2017
@@ -417,6 +417,9 @@ BUILTIN(__builtin_vsx_xvcvhpsp, "V4fV8Us
 BUILTIN(__builtin_vsx_xvtstdcdp, "V2ULLiV2dIi", "")
 BUILTIN(__builtin_vsx_xvtstdcsp, "V4UiV4fIi", "")
 
+BUILTIN(__builtin_vsx_insertword, "V16UcV4UiV16UcIi", "")
+BUILTIN(__builtin_vsx_extractuword, "V2ULLiV16UcIi", "")
+
 // HTM builtins
 BUILTIN(__builtin_tbegin, "UiUIi", "")
 BUILTIN(__builtin_tend, "UiUIi", "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=291179=291178=291179=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Jan  5 15:43:30 2017
@@ -35,6 +35,11 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm;
 
+static
+int64_t clamp(int64_t Value, int64_t Low, int64_t High) {
+  return std::min(High, std::max(Low, Value));
+}
+
 /// getBuiltinLibFunction - Given a builtin id for a function like
 /// "__builtin_fabsf", return a Function* for "fabsf".
 llvm::Constant *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
@@ -8191,6 +8196,85 @@ Value *CodeGenFunction::EmitPPCBuiltinEx
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning
   }
+
+  case PPC::BI__builtin_vsx_insertword: {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxinsertw);
+
+// Third argument is a compile time constant int. It must be clamped to
+// to the range [0, 12].
+ConstantInt *ArgCI = dyn_cast(Ops[2]);
+assert(ArgCI &&
+   "Third arg to xxinsertw intrinsic must be constant integer");
+const int64_t MaxIndex = 12;
+int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
+
+// The builtin semantics don't exactly match the xxinsertw instructions
+// semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the
+// word from the first argument, and inserts it in the second argument. The
+// instruction extracts the word from its second input register and inserts
+// it into its first input register, so swap the first and second 
arguments.
+std::swap(Ops[0], Ops[1]);
+
+// Need to cast the second argument from a vector of unsigned int to a
+// vector of long long.
+Ops[1] = Builder.CreateBitCast(Ops[1], llvm::VectorType::get(Int64Ty, 2));
+
+if (getTarget().isLittleEndian()) {
+  // Create a shuffle mask of (1, 0)
+  Constant *ShuffleElts[2] = { ConstantInt::get(Int32Ty, 1),
+   ConstantInt::get(Int32Ty, 0)
+ };
+  Constant *ShuffleMask = llvm::ConstantVector::get(ShuffleElts);
+
+  // Reverse the double words in the vector we will extract from.
+  Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 
2));
+  Ops[0] = Builder.CreateShuffleVector(Ops[0], Ops[0], ShuffleMask);
+
+  // Reverse the index.
+  Index = MaxIndex - Index;
+}
+
+// Intrinsic expects the first arg to be a vector of int.
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int32Ty, 4));
+Ops[2] = ConstantInt::getSigned(Int32Ty, Index);
+return Builder.CreateCall(F, Ops);
+  }
+
+  case PPC::BI__builtin_vsx_extractuword: {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_vsx_xxextractuw);
+
+// Intrinsic expects the first argument to be a vector of doublewords.
+Ops[0] = Builder.CreateBitCast(Ops[0], llvm::VectorType::get(Int64Ty, 2));
+
+// The second argument is a compile time constant int that needs to
+// be clamped to the range [0, 12].
+ConstantInt *ArgCI = dyn_cast(Ops[1]);
+assert(ArgCI &&
+   "Second Arg to xxextractuw intrinsic must be a constant integer!");
+const int64_t MaxIndex = 12;
+int64_t Index = 

[PATCH] D28242: [ubsan] Minimize size of data for type_mismatch (Redo of D19667)

2017-01-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

LGTM, but I am not the owner.


https://reviews.llvm.org/D28242



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@cryptoad good to go then?


https://reviews.llvm.org/D28304



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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse4.2 flag implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny retitled this revision from "[compiler-rt] [cmake] Disable appending 
-msse* flags implicitly" to "[compiler-rt] [cmake] Disable appending -msse4.2 
flag implicitly".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 83298.

https://reviews.llvm.org/D28304

Files:
  cmake/config-ix.cmake
  lib/scudo/CMakeLists.txt


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec 
COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)


Index: lib/scudo/CMakeLists.txt
===
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -4,7 +4,6 @@
 
 set(SCUDO_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SCUDO_CFLAGS)
-append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 SCUDO_CFLAGS)
 
 set(SCUDO_SOURCES
   scudo_allocator.cpp
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -29,7 +29,6 @@
 check_cxx_compiler_flag(-ftls-model=initial-exec COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC)
 check_cxx_compiler_flag(-fno-lto COMPILER_RT_HAS_FNO_LTO_FLAG)
 check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG)
-check_cxx_compiler_flag("-Werror -msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
 check_cxx_compiler_flag(--sysroot=.  COMPILER_RT_HAS_SYSROOT_FLAG)
 
 if(NOT WIN32 AND NOT CYGWIN)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Oh, sorry that I didn't check that. Then I guess it's good enough for me, we're 
losing just few old Athlon 64 CPUs, I guess. I'll update the patch to remove 
4.2 only.


https://reviews.llvm.org/D28304



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


[libcxx] r291174 - typeinfo: style adjustments for adding MS ABI RTTI

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 15:22:22 2017
New Revision: 291174

URL: http://llvm.org/viewvc/llvm-project?rev=291174=rev
Log:
typeinfo: style adjustments for adding MS ABI RTTI

This is motivated by adding a third RTTI scheme to libc++.  Split out
the two forms of the itanium RTTI representation.  This is based on
suggestions from Eric Fiselier.  NFC

Modified:
libcxx/trunk/include/typeinfo

Modified: libcxx/trunk/include/typeinfo
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=291174=291173=291174=diff
==
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Thu Jan  5 15:22:22 2017
@@ -69,6 +69,12 @@ public:
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
+#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
+#else
+#define _LIBCPP_HAS_UNIQUE_TYPEINFO
+#endif
+
 namespace std  // purposefully not using versioning namespace
 {
 
@@ -77,76 +83,89 @@ class _LIBCPP_EXCEPTION_ABI type_info
 type_info& operator=(const type_info&);
 type_info(const type_info&);
 
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
+_LIBCPP_INLINE_VISIBILITY
+int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
+{ return __builtin_strcmp(name(), __arg.name()); }
+#endif
+
 protected:
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-const char* __type_name;
-#else
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 // A const char* with the non-unique RTTI bit possibly set.
 uintptr_t __type_name;
-#endif
 
 _LIBCPP_INLINE_VISIBILITY
-explicit type_info(const char* __n)
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-: __type_name(__n) {}
+type_info(const char* __n) : __type_name(reinterpret_cast(__n)) 
{}
 #else
-: __type_name(reinterpret_cast(__n)) {}
+const char *__type_name;
+
+_LIBCPP_INLINE_VISIBILITY
+type_info(const char* __n) : __type_name(__n) {}
 #endif
 
 public:
 virtual ~type_info();
 
+#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
 _LIBCPP_INLINE_VISIBILITY
 const char* name() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name;}
-#else
-{return reinterpret_cast(__type_name & 
~_LIBCPP_NONUNIQUE_RTTI_BIT);}
-#endif
+{
+  return reinterpret_cast(__type_name &
+   ~_LIBCPP_NONUNIQUE_RTTI_BIT);
+}
 
 _LIBCPP_INLINE_VISIBILITY
 bool before(const type_info& __arg) const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name < __arg.__type_name;}
-#else
-{if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
-   return __type_name < __arg.__type_name;
- return __compare_nonunique_names(__arg) < 0;}
-#endif
+{
+  if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return __type_name < __arg.__type_name;
+  return __compare_nonunique_names(__arg) < 0;
+}
 
 _LIBCPP_INLINE_VISIBILITY
 size_t hash_code() const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return reinterpret_cast(__type_name);}
-#else
-{if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
- const char *__ptr = name();
- size_t __hash = 5381;
- while (unsigned char __c = static_cast(*__ptr++))
-   __hash = (__hash * 33) ^ __c;
- return __hash;}
-#endif
+{
+  if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return __type_name;
+
+  const char* __ptr = name();
+  size_t __hash = 5381;
+  while (unsigned char __c = static_cast(*__ptr++))
+__hash = (__hash * 33) ^ __c;
+  return __hash;
+}
 
 _LIBCPP_INLINE_VISIBILITY
 bool operator==(const type_info& __arg) const _NOEXCEPT
-#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
-{return __type_name == __arg.__type_name;}
+{
+  if (__type_name == __arg.__type_name)
+return true;
+
+  if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+return false;
+  return __compare_nonunique_names(__arg) == 0;
+}
 #else
-{if (__type_name == __arg.__type_name) return true;
- if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
-   return false;
- return __compare_nonunique_names(__arg) == 0;}
-#endif
 _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const type_info& __arg) const _NOEXCEPT
-{return !operator==(__arg);}
+const char* name() const _NOEXCEPT
+{ return __type_name; }
 
-#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT
-  private:
 _LIBCPP_INLINE_VISIBILITY
-int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
-{return __builtin_strcmp(name(), __arg.name());}
+bool before(const type_info& __arg) const _NOEXCEPT
+{ return __type_name < __arg.__type_name; }
+
+_LIBCPP_INLINE_VISIBILITY
+size_t hash_code() const _NOEXCEPT
+{ 

[PATCH] D28220: provide Win32 native threading

2017-01-05 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added inline comments.



Comment at: include/__threading_support:474
+  
system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+

compnerd wrote:
> halyavin wrote:
> > Since negative timeouts can't be avoided, we must make sure that 
> > timeout_ms.count() is at least zero.
> Good point.  I suppose that the assert takes care of that though.
Negative timeout_ms.count() is a normal case, we shouldn't fail on assertion. 
The reason is that program can always be slow enough for current timestamp 
(system_clock::now()) to pass any fixed point in time (__ts/abstime). 



Comment at: include/__threading_support:476
+
+  _LIBCPP_ASSERT(timeout_ms.count() > INFINITE && "timeout duration overflow");
+  if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count(), 0))

compnerd wrote:
> halyavin wrote:
> > It is >= INFINITE. _LIBCPP_ASSERT has 2 arguments and supports error 
> > message out of the box.
> Shouldnt this be, `timeout_ms.count() > 0` which implicitly ensures that it 
> is not `INFINITE` (-1)?
I just checked in the Windows SDK, INFINITE is defined as `0x` and 
negative timeouts are legal anyway.



Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


r291170 - If an explicitly-specified pack might have been extended by template argument

2017-01-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Jan  5 14:27:28 2017
New Revision: 291170

URL: http://llvm.org/viewvc/llvm-project?rev=291170=rev
Log:
If an explicitly-specified pack might have been extended by template argument
deduction, don't forget to check the argument is valid.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=291170=291169=291170=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Thu Jan  5 14:27:28 2017
@@ -2215,25 +2215,26 @@ static Sema::TemplateDeductionResult Con
 
 if (!Deduced[I].isNull()) {
   if (I < NumAlreadyConverted) {
-// We have already fully type-checked and converted this
-// argument, because it was explicitly-specified. Just record the
-// presence of this argument.
-Builder.push_back(Deduced[I]);
 // We may have had explicitly-specified template arguments for a
 // template parameter pack (that may or may not have been extended
 // via additional deduced arguments).
-if (Param->isParameterPack() && CurrentInstantiationScope) {
-  if (CurrentInstantiationScope->getPartiallySubstitutedPack() ==
-  Param) {
-// Forget the partially-substituted pack; its substitution is now
-// complete.
-CurrentInstantiationScope->ResetPartiallySubstitutedPack();
-  }
+if (Param->isParameterPack() && CurrentInstantiationScope &&
+CurrentInstantiationScope->getPartiallySubstitutedPack() == Param) 
{
+  // Forget the partially-substituted pack; its substitution is now
+  // complete.
+  CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+  // We still need to check the argument in case it was extended by
+  // deduction.
+} else {
+  // We have already fully type-checked and converted this
+  // argument, because it was explicitly-specified. Just record the
+  // presence of this argument.
+  Builder.push_back(Deduced[I]);
+  continue;
 }
-continue;
   }
 
-  // We have deduced this argument, so it still needs to be
+  // We may have deduced this argument, so it still needs to be
   // checked and converted.
   if (ConvertDeducedTemplateArgument(S, Param, Deduced[I], Template, Info,
  IsDeduced, Builder)) {

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=291170=291169=291170=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Thu Jan  5 14:27:28 2017
@@ -428,3 +428,17 @@ namespace deduction_from_empty_list {
 f<1>({0}, {0, 1}); // expected-error {{no matching}}
   }
 }
+
+namespace check_extended_pack {
+  template struct X { typedef int type; };
+  template void f(typename X::type...);
+  template void f(T, int, int);
+  void g() {
+f(0, 0, 0);
+  }
+
+  template struct Y {};
+  template void g(Y); // expected-note {{deduced non-type 
template argument does not have the same type as the corresponding template 
parameter ('int *' vs 'int')}}
+  int n;
+  void h() { g<0>(Y<0, >()); } // expected-error {{no matching function}}
+}


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


[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Dmitry Vyukov via Phabricator via cfe-commits
dvyukov added a comment.

> I don't see a big issue enabling it for x86-64 but for 32-bit systems you're 
> ruling out quite a lot of hardware.

Tsan does not support 32-bits.


https://reviews.llvm.org/D28304



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


r291167 - Move SerializedDiagnosticPrinter's SharedState to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:48:10 2017
New Revision: 291167

URL: http://llvm.org/viewvc/llvm-project?rev=291167=rev
Log:
Move SerializedDiagnosticPrinter's SharedState to std::shared_ptr rather than 
IntrusiveRefCntPtr

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

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=291167=291166=291167=diff
==
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Thu Jan  5 13:48:10 
2017
@@ -143,7 +143,7 @@ class SDiagsWriter : public DiagnosticCo
 
   struct SharedState;
 
-  explicit SDiagsWriter(IntrusiveRefCntPtr State)
+  explicit SDiagsWriter(std::shared_ptr State)
   : LangOpts(nullptr), OriginalInstance(false), MergeChildRecords(false),
 State(std::move(State)) {}
 
@@ -151,7 +151,7 @@ public:
   SDiagsWriter(StringRef File, DiagnosticOptions *Diags, bool 
MergeChildRecords)
   : LangOpts(nullptr), OriginalInstance(true),
 MergeChildRecords(MergeChildRecords),
-State(new SharedState(File, Diags)) {
+State(std::make_shared(File, Diags)) {
 if (MergeChildRecords)
   RemoveOldDiagnostics();
 EmitPreamble();
@@ -251,7 +251,7 @@ private:
 
   /// \brief State that is shared among the various clones of this diagnostic
   /// consumer.
-  struct SharedState : RefCountedBase {
+  struct SharedState {
 SharedState(StringRef File, DiagnosticOptions *Diags)
 : DiagOpts(Diags), Stream(Buffer), OutputFile(File.str()),
   EmittedAnyDiagBlocks(false) {}
@@ -299,7 +299,7 @@ private:
   };
 
   /// \brief State shared among the various clones of this diagnostic consumer.
-  IntrusiveRefCntPtr State;
+  std::shared_ptr State;
 };
 } // end anonymous namespace
 


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


r291166 - Move Preprocessor over to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:48:07 2017
New Revision: 291166

URL: http://llvm.org/viewvc/llvm-project?rev=291166=rev
Log:
Move Preprocessor over to std::shared_ptr rather than IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.h
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=291166=291165=291166=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Jan  5 13:48:07 2017
@@ -86,7 +86,7 @@ private:
   IntrusiveRefCntPtr   SourceMgr;
   std::unique_ptr   HeaderInfo;
   IntrusiveRefCntPtr  Target;
-  IntrusiveRefCntPtrPP;
+  std::shared_ptr   PP;
   IntrusiveRefCntPtr  Ctx;
   std::shared_ptr  TargetOpts;
   IntrusiveRefCntPtr HSOpts;
@@ -496,12 +496,13 @@ public:
 
   const Preprocessor () const { return *PP; }
 Preprocessor ()   { return *PP; }
+  std::shared_ptr getPreprocessorPtr() const { return PP; }
 
   const ASTContext () const { return *Ctx; }
 ASTContext ()   { return *Ctx; }
 
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
-  void setPreprocessor(Preprocessor *pp);
+  void setPreprocessor(std::shared_ptr pp);
 
   bool hasSema() const { return (bool)TheSema; }
   Sema () const { 

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291166=291165=291166=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 13:48:07 2017
@@ -91,7 +91,7 @@ class CompilerInstance : public ModuleLo
   IntrusiveRefCntPtr SourceMgr;
 
   /// The preprocessor.
-  IntrusiveRefCntPtr PP;
+  std::shared_ptr PP;
 
   /// The AST context.
   IntrusiveRefCntPtr Context;
@@ -433,13 +433,14 @@ public:
 return *PP;
   }
 
+  std::shared_ptr getPreprocessorPtr() { return PP; }
+
   void resetAndLeakPreprocessor() {
-BuryPointer(PP.get());
-PP.resetWithoutRelease();
+BuryPointer(new std::shared_ptr(PP));
   }
 
   /// Replace the current preprocessor.
-  void setPreprocessor(Preprocessor *Value);
+  void setPreprocessor(std::shared_ptr Value);
 
   /// }
   /// @name ASTContext

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=291166=291165=291166=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan  5 13:48:07 2017
@@ -94,7 +94,7 @@ enum MacroUse {
 /// Lexers know only about tokens within a single source file, and don't
 /// know anything about preprocessor-level issues like the \#include stack,
 /// token expansion, etc.
-class Preprocessor : public RefCountedBase {
+class Preprocessor {
   std::shared_ptr PPOpts;
   DiagnosticsEngine*Diags;
   LangOptions   

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291166=291165=291166=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jan  5 13:48:07 2017
@@ -257,7 +257,9 @@ ASTUnit::~ASTUnit() {
 fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
 }
 
-void ASTUnit::setPreprocessor(Preprocessor *pp) { PP = pp; }
+void ASTUnit::setPreprocessor(std::shared_ptr PP) {
+  this->PP = std::move(PP);
+}
 
 /// \brief Determine the set of code-completion contexts in which this 
 /// declaration should be shown.
@@ -693,11 +695,11 @@ std::unique_ptr ASTUnit::LoadFr
   HeaderSearch  = *AST->HeaderInfo;
   unsigned Counter;
 
-  AST->PP = new Preprocessor(std::move(PPOpts), AST->getDiagnostics(),
- AST->ASTFileLangOpts, AST->getSourceManager(),
- HeaderInfo, *AST,
- /*IILookup=*/nullptr,
- /*OwnsHeaderSearch=*/false);
+  AST->PP = std::make_shared(
+  std::move(PPOpts), AST->getDiagnostics(), AST->ASTFileLangOpts,
+  AST->getSourceManager(), HeaderInfo, 

r291159 - Move FailedModulesSet over to shared_ptr from IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:11:31 2017
New Revision: 291159

URL: http://llvm.org/viewvc/llvm-project?rev=291159=rev
Log:
Move FailedModulesSet over to shared_ptr from IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=291159=291158=291159=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jan  5 13:11:31 2017
@@ -117,7 +117,7 @@ public:
   ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary;
 
   /// \brief Records the set of modules
-  class FailedModulesSet : public RefCountedBase {
+  class FailedModulesSet {
 llvm::StringSet<> Failed;
 
   public:
@@ -136,7 +136,7 @@ public:
   /// to (re)build modules, so that once a module fails to build anywhere,
   /// other instances will see that the module has failed and won't try to
   /// build it again.
-  IntrusiveRefCntPtr FailedModules;
+  std::shared_ptr FailedModules;
 
 public:
   PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=291159=291158=291159=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jan  5 13:11:31 2017
@@ -1049,7 +1049,8 @@ static bool compileModuleImpl(CompilerIn
   PreprocessorOptions 
 = ImportingInstance.getInvocation().getPreprocessorOpts();
   if (!ImportingPPOpts.FailedModules)
-ImportingPPOpts.FailedModules = new PreprocessorOptions::FailedModulesSet;
+ImportingPPOpts.FailedModules =
+std::make_shared();
   PPOpts.FailedModules = ImportingPPOpts.FailedModules;
 
   // If there is a module map file, build the module using the module map.


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


r291160 - Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 13:11:36 2017
New Revision: 291160

URL: http://llvm.org/viewvc/llvm-project?rev=291160=rev
Log:
Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp
cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=291160=291159=291160=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Thu Jan  5 13:11:36 
2017
@@ -68,7 +68,7 @@ public:
   IntrusiveRefCntPtr HeaderSearchOpts;
 
   /// Options controlling the preprocessor (aside from \#include handling).
-  IntrusiveRefCntPtr PreprocessorOpts;
+  std::shared_ptr PreprocessorOpts;
 
   CompilerInvocationBase();
   ~CompilerInvocationBase();
@@ -90,6 +90,9 @@ public:
 return *HeaderSearchOpts;
   }
 
+  std::shared_ptr getPreprocessorOptsPtr() {
+return PreprocessorOpts;
+  }
   PreprocessorOptions () { return *PreprocessorOpts; }
   const PreprocessorOptions () const {
 return *PreprocessorOpts;

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=291160=291159=291160=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Jan  5 13:11:36 2017
@@ -95,7 +95,7 @@ enum MacroUse {
 /// know anything about preprocessor-level issues like the \#include stack,
 /// token expansion, etc.
 class Preprocessor : public RefCountedBase {
-  IntrusiveRefCntPtr PPOpts;
+  std::shared_ptr PPOpts;
   DiagnosticsEngine*Diags;
   LangOptions   
   const TargetInfo  *Target;
@@ -650,10 +650,9 @@ class Preprocessor : public RefCountedBa
   void updateOutOfDateIdentifier(IdentifierInfo ) const;
 
 public:
-  Preprocessor(IntrusiveRefCntPtr PPOpts,
-   DiagnosticsEngine , LangOptions ,
-   SourceManager , HeaderSearch ,
-   ModuleLoader ,
+  Preprocessor(std::shared_ptr PPOpts,
+   DiagnosticsEngine , LangOptions , SourceManager ,
+   HeaderSearch , ModuleLoader ,
IdentifierInfoLookup *IILookup = nullptr,
bool OwnsHeaderSearch = false,
TranslationUnitKind TUKind = TU_Complete);

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=291160=291159=291160=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Thu Jan  5 13:11:36 2017
@@ -40,7 +40,7 @@ enum ObjCXXARCStandardLibraryKind {
   
 /// PreprocessorOptions - This class is used for passing the various options
 /// used in preprocessor initialization to InitializePreprocessor().
-class PreprocessorOptions : public RefCountedBase {
+class PreprocessorOptions {
 public:
   std::vector > Macros;
   std::vector Includes;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=291160=291159=291160=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jan  5 13:11:36 2017
@@ -683,7 +683,7 @@ std::unique_ptr ASTUnit::LoadFr
  AST->ASTFileLangOpts,
  /*Target=*/nullptr));
 
-  PreprocessorOptions *PPOpts = new PreprocessorOptions();
+  auto PPOpts = std::make_shared();
 
   for (const auto  : RemappedFiles)
 PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second);
@@ -693,11 +693,11 @@ std::unique_ptr ASTUnit::LoadFr
   HeaderSearch  = *AST->HeaderInfo;
   unsigned Counter;
 
-  AST->PP =
-  new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts,
-   AST->getSourceManager(), HeaderInfo, *AST,
-   /*IILookup=*/nullptr,
-   /*OwnsHeaderSearch=*/false);
+  AST->PP = new Preprocessor(std::move(PPOpts), AST->getDiagnostics(),
+   

r291156 - Move VariantMatcher's Payload to std::shared_ptr rather than IntrusiveRefCntPtr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:51:54 2017
New Revision: 291156

URL: http://llvm.org/viewvc/llvm-project?rev=291156=rev
Log:
Move VariantMatcher's Payload to std::shared_ptr rather than IntrusiveRefCntPtr

Modified:
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h?rev=291156=291155=291156=diff
==
--- cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h Thu Jan  5 
12:51:54 2017
@@ -119,7 +119,7 @@ class VariantMatcher {
   /// \brief Payload interface to be specialized by each matcher type.
   ///
   /// It follows a similar interface as VariantMatcher itself.
-  class Payload : public RefCountedBase {
+  class Payload {
   public:
 virtual ~Payload();
 virtual llvm::Optional getSingleMatcher() const = 0;
@@ -208,7 +208,8 @@ public:
   std::string getTypeAsString() const;
 
 private:
-  explicit VariantMatcher(Payload *Value) : Value(Value) {}
+  explicit VariantMatcher(std::shared_ptr Value)
+  : Value(std::move(Value)) {}
 
   template  struct TypedMatcherOps;
 
@@ -216,7 +217,7 @@ private:
   class PolymorphicPayload;
   class VariadicOpPayload;
 
-  IntrusiveRefCntPtr Value;
+  std::shared_ptr Value;
 };
 
 template 

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp?rev=291156=291155=291156=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/VariantValue.cpp Thu Jan  5 12:51:54 2017
@@ -216,18 +216,20 @@ private:
 VariantMatcher::VariantMatcher() {}
 
 VariantMatcher VariantMatcher::SingleMatcher(const DynTypedMatcher ) {
-  return VariantMatcher(new SinglePayload(Matcher));
+  return VariantMatcher(std::make_shared(Matcher));
 }
 
 VariantMatcher
 VariantMatcher::PolymorphicMatcher(std::vector Matchers) {
-  return VariantMatcher(new PolymorphicPayload(std::move(Matchers)));
+  return VariantMatcher(
+  std::make_shared(std::move(Matchers)));
 }
 
 VariantMatcher VariantMatcher::VariadicOperatorMatcher(
 DynTypedMatcher::VariadicOperator Op,
 std::vector Args) {
-  return VariantMatcher(new VariadicOpPayload(Op, std::move(Args)));
+  return VariantMatcher(
+  std::make_shared(Op, std::move(Args)));
 }
 
 llvm::Optional VariantMatcher::getSingleMatcher() const {


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


r291155 - Simplify ASTReader ctor by using in-class initializers for many member variables

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:45:45 2017
New Revision: 291155

URL: http://llvm.org/viewvc/llvm-project?rev=291155=rev
Log:
Simplify ASTReader ctor by using in-class initializers for many member variables

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=291155=291154=291155=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Jan  5 12:45:45 2017
@@ -107,16 +107,16 @@ private:
   llvm::BitstreamWriter 
 
   /// \brief The ASTContext we're writing.
-  ASTContext *Context;
+  ASTContext *Context = nullptr;
 
   /// \brief The preprocessor we're writing.
-  Preprocessor *PP;
+  Preprocessor *PP = nullptr;
 
   /// \brief The reader of existing AST files, if we're chaining.
-  ASTReader *Chain;
+  ASTReader *Chain = nullptr;
 
   /// \brief The module we're currently writing, if any.
-  Module *WritingModule;
+  Module *WritingModule = nullptr;
 
   /// \brief The base directory for any relative paths we emit.
   std::string BaseDirectory;
@@ -129,14 +129,14 @@ private:
 
   /// \brief Indicates when the AST writing is actively performing
   /// serialization, rather than just queueing updates.
-  bool WritingAST;
+  bool WritingAST = false;
 
   /// \brief Indicates that we are done serializing the collection of decls
   /// and types to emit.
-  bool DoneWritingDeclsAndTypes;
+  bool DoneWritingDeclsAndTypes = false;
 
   /// \brief Indicates that the AST contained compiler errors.
-  bool ASTHasCompilerErrors;
+  bool ASTHasCompilerErrors = false;
 
   /// \brief Mapping from input file entries to the index into the
   /// offset table where information about that input file is stored.
@@ -170,10 +170,10 @@ private:
   std::queue DeclTypesToEmit;
 
   /// \brief The first ID number we can use for our own declarations.
-  serialization::DeclID FirstDeclID;
+  serialization::DeclID FirstDeclID = serialization::NUM_PREDEF_DECL_IDS;
 
   /// \brief The decl ID that will be assigned to the next new decl.
-  serialization::DeclID NextDeclID;
+  serialization::DeclID NextDeclID = FirstDeclID;
 
   /// \brief Map that provides the ID numbers of each declaration within
   /// the output stream, as well as those deserialized from a chained PCH.
@@ -205,10 +205,10 @@ private:
   void associateDeclWithFile(const Decl *D, serialization::DeclID);
 
   /// \brief The first ID number we can use for our own types.
-  serialization::TypeID FirstTypeID;
+  serialization::TypeID FirstTypeID = serialization::NUM_PREDEF_TYPE_IDS;
 
   /// \brief The type ID that will be assigned to the next new type.
-  serialization::TypeID NextTypeID;
+  serialization::TypeID NextTypeID = FirstTypeID;
 
   /// \brief Map that provides the ID numbers of each type within the
   /// output stream, plus those deserialized from a chained PCH.
@@ -226,10 +226,10 @@ private:
   std::vector TypeOffsets;
 
   /// \brief The first ID number we can use for our own identifiers.
-  serialization::IdentID FirstIdentID;
+  serialization::IdentID FirstIdentID = serialization::NUM_PREDEF_IDENT_IDS;
 
   /// \brief The identifier ID that will be assigned to the next new 
identifier.
-  serialization::IdentID NextIdentID;
+  serialization::IdentID NextIdentID = FirstIdentID;
 
   /// \brief Map that provides the ID numbers of each identifier in
   /// the output stream.
@@ -240,10 +240,10 @@ private:
   llvm::MapVector 
IdentifierIDs;
 
   /// \brief The first ID number we can use for our own macros.
-  serialization::MacroID FirstMacroID;
+  serialization::MacroID FirstMacroID = serialization::NUM_PREDEF_MACRO_IDS;
 
   /// \brief The identifier ID that will be assigned to the next new 
identifier.
-  serialization::MacroID NextMacroID;
+  serialization::MacroID NextMacroID = FirstMacroID;
 
   /// \brief Map that provides the ID numbers of each macro.
   llvm::DenseMap MacroIDs;
@@ -275,16 +275,18 @@ private:
   std::vector IdentifierOffsets;
 
   /// \brief The first ID number we can use for our own submodules.
-  serialization::SubmoduleID FirstSubmoduleID;
-  
+  serialization::SubmoduleID FirstSubmoduleID =
+  serialization::NUM_PREDEF_SUBMODULE_IDS;
+
   /// \brief The submodule ID that will be assigned to the next new submodule.
-  serialization::SubmoduleID NextSubmoduleID;
+  serialization::SubmoduleID NextSubmoduleID = FirstSubmoduleID;
 
   /// \brief The first ID number we can use for our own selectors.
-  serialization::SelectorID FirstSelectorID;
+  serialization::SelectorID FirstSelectorID =
+  serialization::NUM_PREDEF_SELECTOR_IDS;
 
   /// \brief The selector ID that will be assigned to the next new selector.
-  serialization::SelectorID NextSelectorID;
+  

r291154 - Simplify ASTReader ctor by using in-class initializers (NSDMIs to the rest of you) for many member variables

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:45:43 2017
New Revision: 291154

URL: http://llvm.org/viewvc/llvm-project?rev=291154=rev
Log:
Simplify ASTReader ctor by using in-class initializers (NSDMIs to the rest of 
you) for many member variables

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

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=291154=291153=291154=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jan  5 12:45:43 2017
@@ -384,8 +384,8 @@ private:
   std::unique_ptr Listener;
 
   /// \brief The receiver of deserialization events.
-  ASTDeserializationListener *DeserializationListener;
-  bool OwnsDeserializationListener;
+  ASTDeserializationListener *DeserializationListener = nullptr;
+  bool OwnsDeserializationListener = false;
 
   SourceManager 
   FileManager 
@@ -394,7 +394,7 @@ private:
 
   /// \brief The semantic analysis object that will be processing the
   /// AST files and the translation unit that uses it.
-  Sema *SemaObj;
+  Sema *SemaObj = nullptr;
 
   /// \brief The preprocessor that will be loading the source file.
   Preprocessor 
@@ -403,7 +403,7 @@ private:
   ASTContext 
 
   /// \brief The AST consumer.
-  ASTConsumer *Consumer;
+  ASTConsumer *Consumer = nullptr;
 
   /// \brief The module manager which manages modules and their dependencies
   ModuleManager ModuleMgr;
@@ -802,10 +802,10 @@ private:
   SourceLocation OptimizeOffPragmaLocation;
 
   /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
-  int PragmaMSStructState;
+  int PragmaMSStructState = -1;
 
   /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members 
state.
-  int PragmaMSPointersToMembersState;
+  int PragmaMSPointersToMembersState = -1;
   SourceLocation PointersToMembersPragmaLocation;
 
   /// \brief The OpenCL extension settings.
@@ -870,10 +870,10 @@ private:
   bool UseGlobalIndex;
 
   /// \brief Whether we have tried loading the global module index yet.
-  bool TriedLoadingGlobalIndex;
+  bool TriedLoadingGlobalIndex = false;
 
   ///\brief Whether we are currently processing update records.
-  bool ProcessingUpdateRecords;
+  bool ProcessingUpdateRecords = false;
 
   typedef llvm::DenseMap SwitchCaseMapTy;
   /// \brief Mapping from switch-case IDs in the chain to switch-case 
statements
@@ -886,73 +886,73 @@ private:
 
   /// \brief The number of source location entries de-serialized from
   /// the PCH file.
-  unsigned NumSLocEntriesRead;
+  unsigned NumSLocEntriesRead = 0;
 
   /// \brief The number of source location entries in the chain.
-  unsigned TotalNumSLocEntries;
+  unsigned TotalNumSLocEntries = 0;
 
   /// \brief The number of statements (and expressions) de-serialized
   /// from the chain.
-  unsigned NumStatementsRead;
+  unsigned NumStatementsRead = 0;
 
   /// \brief The total number of statements (and expressions) stored
   /// in the chain.
-  unsigned TotalNumStatements;
+  unsigned TotalNumStatements = 0;
 
   /// \brief The number of macros de-serialized from the chain.
-  unsigned NumMacrosRead;
+  unsigned NumMacrosRead = 0;
 
   /// \brief The total number of macros stored in the chain.
-  unsigned TotalNumMacros;
+  unsigned TotalNumMacros = 0;
 
   /// \brief The number of lookups into identifier tables.
-  unsigned NumIdentifierLookups;
+  unsigned NumIdentifierLookups = 0;
 
   /// \brief The number of lookups into identifier tables that succeed.
-  unsigned NumIdentifierLookupHits;
+  unsigned NumIdentifierLookupHits = 0;
 
   /// \brief The number of selectors that have been read.
-  unsigned NumSelectorsRead;
+  unsigned NumSelectorsRead = 0;
 
   /// \brief The number of method pool entries that have been read.
-  unsigned NumMethodPoolEntriesRead;
+  unsigned NumMethodPoolEntriesRead = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool.
-  unsigned NumMethodPoolLookups;
+  unsigned NumMethodPoolLookups = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool and found something.
-  unsigned NumMethodPoolHits;
+  unsigned NumMethodPoolHits = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool within a specific module.
-  unsigned NumMethodPoolTableLookups;
+  unsigned NumMethodPoolTableLookups = 0;
 
   /// \brief The number of times we have looked up a selector in the method
   /// pool within a specific module and found something.
-  unsigned NumMethodPoolTableHits;
+  unsigned NumMethodPoolTableHits = 0;
 
   /// \brief The total number of method pool entries in the selector table.
-  unsigned TotalNumMethodPoolEntries;
+  unsigned 

[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren added inline comments.



Comment at: include/clang/Basic/DiagnosticSerializationKinds.td:131
+  "diagnostic options now it is a non-system module">,
+  InGroup;
+

aprantl wrote:
> Is this better?
> 
> "module file '%0' was validated as a system module and is now being imported 
> as a non-system module; any differences in diagnostics options will be 
> ignored"
Thanks Adrian. Your wording sounds better.



Comment at: include/clang/Basic/DiagnosticSerializationKinds.td:135
+  "module file '%0' was validated in an ancestor thread, now it needs to "
+  "be invalidated">;
+

aprantl wrote:
> I wonder if there is a way to rephrase this message such that an end-user 
> could understan how to interpret this error?
I am not sure if we will emit this error diagnostic in some case, that is why I 
don't have a testing case. Maybe it is better to throw a hard error instead of 
a diagnostic that user can't understand?



https://reviews.llvm.org/D28299



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


[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren updated this revision to Diff 83273.
manmanren added a comment.

Add testing case.


https://reviews.llvm.org/D28299

Files:
  include/clang/Basic/DiagnosticSerializationKinds.td
  include/clang/Basic/FileManager.h
  include/clang/Serialization/ASTReader.h
  include/clang/Serialization/ASTWriter.h
  include/clang/Serialization/Module.h
  include/clang/Serialization/ModuleManager.h
  lib/Basic/FileManager.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/ChainedIncludesSource.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/GeneratePCH.cpp
  lib/Serialization/ModuleManager.cpp
  test/Modules/Inputs/system-out-of-date/X.h
  test/Modules/Inputs/system-out-of-date/Y.h
  test/Modules/Inputs/system-out-of-date/Z.h
  test/Modules/Inputs/system-out-of-date/module.map
  test/Modules/system-out-of-date-test.m

Index: test/Modules/system-out-of-date-test.m
===
--- /dev/null
+++ test/Modules/system-out-of-date-test.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: echo '@import X;' | \
+// RUN:   %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date \
+// RUN: -fsyntax-only -x objective-c -
+
+// We have an version built with different diagnostic options.
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/system-out-of-date -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module %s -fsyntax-only 2>&1 | FileCheck %s
+ @import X;
+ 
+ #import 
+// CHECK: While building module 'Z' imported from
+// CHECK: {{.*}}Y-{{.*}}pcm' was validated as a system module, ignoring differences in diagnostic options
Index: test/Modules/Inputs/system-out-of-date/module.map
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/module.map
@@ -0,0 +1,12 @@
+module X [system] {
+  header "X.h" // imports Y
+  export *
+}
+module Y {
+  header "Y.h"
+  export *
+}
+module Z {
+  header "Z.h" // imports Y
+  export *
+}
Index: test/Modules/Inputs/system-out-of-date/Z.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Z.h
@@ -0,0 +1 @@
+#import 
Index: test/Modules/Inputs/system-out-of-date/Y.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/Y.h
@@ -0,0 +1 @@
+//empty
Index: test/Modules/Inputs/system-out-of-date/X.h
===
--- /dev/null
+++ test/Modules/Inputs/system-out-of-date/X.h
@@ -0,0 +1 @@
+#import 
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -108,7 +108,11 @@
 // Load the contents of the module
 if (std::unique_ptr Buffer = lookupBuffer(FileName)) {
   // The buffer was already provided for us.
-  ModuleEntry->Buffer = std::move(Buffer);
+  ModuleEntry->Buffer = Buffer.get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(Buffer));
+} else if(llvm::MemoryBuffer *ConsistentB =
+  FileMgr.getPCMCache()->lookupConsistentBuffer(FileName)) {
+  ModuleEntry->Buffer = ConsistentB;
 } else {
   // Open the AST file.
   llvm::ErrorOr Buf(
@@ -131,7 +135,8 @@
 return Missing;
   }
 
-  ModuleEntry->Buffer = std::move(*Buf);
+  ModuleEntry->Buffer = (*Buf).get();
+  FileMgr.getPCMCache()->addConsistentBuffer(FileName, std::move(*Buf));
 }
 
 // Initialize the stream.
@@ -148,8 +153,11 @@
   ErrorStr = ModuleEntry->Signature != ASTFileSignature({{0}}) ?
  "signature mismatch" : "could not read module signature";
 
-  if (NewModule)
+  if (NewModule) {
+FileMgr.getPCMCache()->removeFromConsistentBuffer(
+ModuleEntry->FileName);
 delete ModuleEntry;
+  }
   return OutOfDate;
 }
   }
@@ -184,7 +192,8 @@
 void ModuleManager::removeModules(
 ModuleIterator first, ModuleIterator last,
 llvm::SmallPtrSetImpl ,
-ModuleMap *modMap) {
+ModuleMap *modMap,
+llvm::SmallVectorImpl ) {
   if (first == last)
 return;
 
@@ -227,16 +236,76 @@
 // Files that didn't make it through ReadASTCore successfully will be
 // rebuilt (or there was an error). Invalidate them so that we can load the
 // new files that will be renamed over the old ones.
-if (LoadedSuccessfully.count(*victim) == 0)
-  FileMgr.invalidateCache((*victim)->File);
-
+if (LoadedSuccessfully.count(*victim) == 0) {
+  // Before removing the module file, check if it was validated in an
+  // ancestor thread, if yes, throw 

[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.

2017-01-05 Thread Manman Ren via Phabricator via cfe-commits
manmanren added a comment.

I forgot to upload the testing case, I will add it now.

Manman




Comment at: include/clang/Basic/FileManager.h:176
+  /// Manage memory buffers associated with pcm files.
+  std::unique_ptr BufferMgr;
+

benlangmuir wrote:
> Why is this inside the FileManager? It isn't used by the FileManager.
I initially had another patch that puts PCMCache object at the top level (i.e 
whenever we create a FileManager, we create a PCMCache object). The initial 
patch is much bigger than this patch. PCMCache is cacheing the content of a PCM 
File, and is shared across threads that we spawned to build modules implicitly, 
just like FileManager. I had some discussions with Bruno and Adrian, we felt 
FileManager is a better place. But if you have other suggestions, please let me 
know!



Comment at: include/clang/Basic/FileManager.h:308
+  /// a thread, we pop a ThreadContext.
+  struct ThreadContext {
+/// Keep track of all module files that have been validated in this thread

benlangmuir wrote:
> Can we call this something like "ModuleLoadContext" or maybe 
> "ModuleCompilationContext"?  The word thread is misleading, since the threads 
> are not run concurrently, and are only an implementation detail of our crash 
> recovery.
> 
> Also, can you explain why it is only necessary to keep information about the 
> the current stack of contexts?  In a situation like
> 
> A imports B imports C
> A imports D imports C
> 
> We would no longer have information about C being validated, right?  What 
> happens if there's a mismatch there?  Can this never happen?
Sure, we can call it ModuleCompilationContext because we are spawning threads 
to build modules implicitly.

The issue we are trying to detect is use-after-free, i.e we don't want a thread 
to hold on to an invalid FileEntry. We error out before trying to delete the 
FileEntry that is live in another thread.

In a situation like
A imports B imports C
A imports D imports C

A will start a thread to build B, and B will start a thread to build C, C will 
be validated in B's compilation thread and A's compilation thread. Later on, if 
D tries to invalidate C, D knows that an ancestor thread A has validated C, so 
the compiler will error out. And it is okay for A to invalidate C in A's 
compilation thread, because we can clean up the references to C's FileEntry.



https://reviews.llvm.org/D28299



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


[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-05 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:65
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+

Is it common to do this in clang?


https://reviews.llvm.org/D28362



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


r291150 - Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 12:23:18 2017
New Revision: 291150

URL: http://llvm.org/viewvc/llvm-project?rev=291150=rev
Log:
Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtension

The intrusiveness wasn't needed here, so this simplifies/clarifies the
ownership model.

Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GeneratePCH.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=291150=291149=291150=diff
==
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jan  5 12:23:18 2017
@@ -653,7 +653,7 @@ public:
   StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
   bool AllowPCHWithCompilerErrors, Preprocessor , ASTContext ,
   const PCHContainerReader ,
-  ArrayRef Extensions,
+  ArrayRef Extensions,
   void *DeserializationListener, bool OwnDeserializationListener,
   bool Preamble, bool UseGlobalModuleIndex);
 

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=291150=291149=291150=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Jan  5 12:23:18 2017
@@ -243,7 +243,7 @@ public:
   std::vector Plugins;
 
   /// The list of module file extensions.
-  std::vector ModuleFileExtensions;
+  std::vector ModuleFileExtensions;
 
   /// \brief The list of module map files to load before processing the input.
   std::vector ModuleMapFiles;

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=291150=291149=291150=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jan  5 12:23:18 2017
@@ -414,7 +414,7 @@ private:
   IdentifierResolver DummyIdResolver;
 
   /// A mapping from extension block names to module file extensions.
-  llvm::StringMap 
ModuleFileExtensions;
+  llvm::StringMap ModuleFileExtensions;
 
   /// \brief A timer used to track the time spent deserializing.
   std::unique_ptr ReadTimer;
@@ -1366,7 +1366,7 @@ public:
   /// deserializing.
   ASTReader(Preprocessor , ASTContext ,
 const PCHContainerReader ,
-ArrayRef Extensions,
+ArrayRef Extensions,
 StringRef isysroot = "", bool DisableValidation = false,
 bool AllowASTWithCompilerErrors = false,
 bool AllowConfigurationMismatch = false,

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=291150=291149=291150=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Jan  5 12:23:18 2017
@@ -498,7 +498,7 @@ public:
   /// \brief Create a new precompiled header writer that outputs to
   /// the given bitstream.
   ASTWriter(llvm::BitstreamWriter ,
-ArrayRef Extensions,
+ArrayRef Extensions,
 bool IncludeTimestamps = true);
   ~ASTWriter() override;
 
@@ -934,13 +934,10 @@ protected:
   SmallVectorImpl () const { return Buffer->Data; }
 
 public:
-  PCHGenerator(
-const Preprocessor , StringRef OutputFile,
-StringRef isysroot,
-std::shared_ptr Buffer,
-ArrayRef Extensions,
-bool AllowASTWithErrors = false,
-bool IncludeTimestamps = true);
+  PCHGenerator(const Preprocessor , StringRef OutputFile, StringRef 
isysroot,
+   std::shared_ptr Buffer,
+   ArrayRef Extensions,
+   bool AllowASTWithErrors = false, bool IncludeTimestamps = 

[PATCH] D27424: Add the diagnose_if attribute to clang.

2017-01-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D27424#636496, @george.burgess.iv wrote:

> Do we have a page that details when we should/shouldn't use `auto`? I was 
> under the impression that it was preferred only in cases where the type's 
> spelled out (e.g. `cast`, ...). (To be clear, I'm happy to use it in 
> loops, too; I'd just like to know if we have guidelines about it. :) )


We do: 
http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

Btw, there's a question in there about late parsing that Phab won't let me 
delete, feel free to ignore it. ;-)




Comment at: include/clang/Basic/Attr.td:1584
+def DiagnoseIf : InheritableAttr {
+  let Spellings = [GNU<"diagnose_if">];
+  let Subjects = SubjectList<[Function]>;

george.burgess.iv wrote:
> aaron.ballman wrote:
> > I think this should also have a C++ spelling under the clang namespace.
> Agreed. Though, it looks like that would requires us teaching the parser how 
> to late-parse c++11 attrs if we wanted to do it properly. Given the size of 
> this patch, I think that can be done as a follow-up.
That seems reasonable to me.



Comment at: include/clang/Sema/Sema.h:2616
+  DiagnoseIfAttr *
+  checkArgDependentDiagnoseIf(FunctionDecl *Function, ArrayRef Args,
+  SmallVectorImpl ,

george.burgess.iv wrote:
> aaron.ballman wrote:
> > Can this (and the other new functions) accept the `FunctionDecl` as a 
> > `const FunctionDecl *` instead?
> Not easily, unless you'd prefer to see `const` here and a `const_cast` or two 
> in `checkArgDependentDiagnoseIf` over what we have now. I have no preference, 
> so if you would prefer to see that, I'm happy to do it.
> 
> If `ExprResult` and initialization routines like 
> `Sema::PerformCopyInitialization` were happy to take a `const Expr *`, this 
> would be a different story :)
That sounds like more churn than it's worth, to me. It'd be nice if we were 
better about const-correctness, but that's not this patch's problem to solve. 
;-)



Comment at: lib/AST/ExprConstant.cpp:10371
+assert(MD && "Don't provide `this` for non-methods.");
+assert(!MD->isStatic() && "Don't provide `this` for non-static methods.");
+#endif

I think the message means to say "Don't provide 'this' for static methods."



Comment at: lib/Parse/ParseDecl.cpp:371-372
 return;
   }
 
   // These may refer to the function arguments, but need to be parsed early to

In the last patch, this code was checking for `enable_if` or `diagnose_if`, but 
now only checks for `enable_if`. Do you not need this for `diagnose_if` because 
it's now late parsed?



Comment at: lib/Sema/SemaDeclAttr.cpp:949
+#ifndef NDEBUG
+if (auto *MD = dyn_cast(FD))
+  ClassType = MD->getParent();

`const auto *`


https://reviews.llvm.org/D27424



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


[PATCH] D28220: provide Win32 native threading

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added inline comments.



Comment at: include/__threading_support:474
+  
system_clock::time_point(duration_cast(duration));
+  auto timeout_ms = duration_cast(abstime - system_clock::now());
+

halyavin wrote:
> Since negative timeouts can't be avoided, we must make sure that 
> timeout_ms.count() is at least zero.
Good point.  I suppose that the assert takes care of that though.



Comment at: include/__threading_support:476
+
+  _LIBCPP_ASSERT(timeout_ms.count() > INFINITE && "timeout duration overflow");
+  if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count(), 0))

halyavin wrote:
> It is >= INFINITE. _LIBCPP_ASSERT has 2 arguments and supports error message 
> out of the box.
Shouldnt this be, `timeout_ms.count() > 0` which implicitly ensures that it is 
not `INFINITE` (-1)?


Repository:
  rL LLVM

https://reviews.llvm.org/D28220



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


r291148 - Typo

2017-01-05 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Thu Jan  5 11:59:44 2017
New Revision: 291148

URL: http://llvm.org/viewvc/llvm-project?rev=291148=rev
Log:
Typo

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

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=291148=291147=291148=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu Jan  5 11:59:44 2017
@@ -541,8 +541,8 @@ TEST_F(FormatTestJS, FunctionLiterals) {
"  foo();\n"
"  bar();\n"
"},\n"
-   "this, arg1IsReallyLongAndNeeedsLineBreaks,\n"
-   "arg3IsReallyLongAndNeeedsLineBreaks);");
+   "this, arg1IsReallyLongAndNeedsLineBreaks,\n"
+   "arg3IsReallyLongAndNeedsLineBreaks);");
   verifyFormat("var closure = goog.bind(function() {  // comment\n"
"  foo();\n"
"  bar();\n"


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


[PATCH] D28338: thread_support: split out {,non-}recursive mutex

2017-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd closed this revision.
compnerd added a comment.

SVN r291145


Repository:
  rL LLVM

https://reviews.llvm.org/D28338



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


[libcxx] r291145 - thread_support: split out {,non-}recursive mutex

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 11:54:45 2017
New Revision: 291145

URL: http://llvm.org/viewvc/llvm-project?rev=291145=rev
Log:
thread_support: split out {,non-}recursive mutex

Split out the recursive and non-recursive mutex.  This split is needed
for platforms which may use differing types for the two mutex (e.g.
Win32 threads).

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/include/mutex
libcxx/trunk/src/mutex.cpp

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=291145=291144=291145=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Jan  5 11:54:45 2017
@@ -63,6 +63,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
 
+typedef pthread_mutex_t __libcpp_recursive_mutex_t;
+
 // Condition Variable
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
@@ -83,7 +85,19 @@ typedef pthread_key_t __libcpp_tls_key;
 
 // Mutex
 _LIBCPP_THREAD_ABI_VISIBILITY
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
@@ -164,7 +178,7 @@ int __libcpp_tls_set(__libcpp_tls_key __
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
 defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
 
-int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
 {
   pthread_mutexattr_t attr;
   int __ec = pthread_mutexattr_init();
@@ -188,6 +202,26 @@ int __libcpp_recursive_mutex_init(__libc
   return 0;
 }
 
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_lock(__m);
+}
+
+int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_trylock(__m);
+}
+
+int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m)
+{
+  return pthread_mutex_unlock(__m);
+}
+
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
+{
+  return pthread_mutex_destroy(__m);
+}
+
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
 {
   return pthread_mutex_lock(__m);

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=291145=291144=291145=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Thu Jan  5 11:54:45 2017
@@ -206,7 +206,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 class _LIBCPP_TYPE_VIS recursive_mutex
 {
-__libcpp_mutex_t __m_;
+__libcpp_recursive_mutex_t __m_;
 
 public:
  recursive_mutex();
@@ -221,7 +221,8 @@ public:
 bool try_lock() _NOEXCEPT;
 void unlock()  _NOEXCEPT;
 
-typedef __libcpp_mutex_t* native_handle_type;
+typedef __libcpp_recursive_mutex_t* native_handle_type;
+
 _LIBCPP_INLINE_VISIBILITY
 native_handle_type native_handle() {return &__m_;}
 };

Modified: libcxx/trunk/src/mutex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=291145=291144=291145=diff
==
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Thu Jan  5 11:54:45 2017
@@ -59,7 +59,7 @@ recursive_mutex::recursive_mutex()
 
 recursive_mutex::~recursive_mutex()
 {
-int e = __libcpp_mutex_destroy(&__m_);
+int e = __libcpp_recursive_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -67,7 +67,7 @@ recursive_mutex::~recursive_mutex()
 void
 recursive_mutex::lock()
 {
-int ec = __libcpp_mutex_lock(&__m_);
+int ec = __libcpp_recursive_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
@@ -75,7 +75,7 @@ recursive_mutex::lock()
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = __libcpp_mutex_unlock(&__m_);
+int e = __libcpp_recursive_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
@@ -83,7 +83,7 @@ recursive_mutex::unlock() _NOEXCEPT
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return __libcpp_mutex_trylock(&__m_) == 0;
+return __libcpp_recursive_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex


___

[PATCH] D28330: [analyzer] Fix false positives in Keychain API checker

2017-01-05 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

I did not think of solution #1! It's definitely better than the pattern 
matching I've added here. However, this checker fires so infrequently, that I 
do not think it's worth investing more time into perfecting it.

I suspect the solution #2 is what this checker was trying to use to begin with. 
It marks the return symbol as dependent on the allocated symbol by calling:

  C.getSymbolManager().addSymbolDependency(V, RetStatusSymbol);

However, addSymbolDependency only worked for isLive() and not for !isDead(). 
Would be good to investigate this further as other checkers such as malloc also 
use addSymbolDependency.


https://reviews.llvm.org/D28330



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


Re: Fix for Visual Studio 2017

2017-01-05 Thread Hamza Sood via cfe-commits
I’ve submitted an updated version via Phabricator 
(https://reviews.llvm.org/D28365 ), so this 
one can be ignored.___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-01-05 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.
hamzasood added reviewers: rnk, ruiu, hans.
hamzasood added a subscriber: cfe-commits.

The patch updates the MSVC ToolChain for the changes made in Visual Studio 2017 
(https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/).
Other notable changes:

- Path handling code has been centralised to make potential future changes less 
painful.
- A compiler error is emitted if the driver is unable to locate a usable MSVC 
toolchain. (Previously it'd fail with a cryptic error such as "link.exe is not 
executable")
- Support for the new Setup Config Server 

 API has been added, albeit block commented out with a preprocessor 
conditional. This can probably be re-evaluated when the API is officially 
released (it's currently at the RC stage), but it's left in to make it easy for 
anyone familiar with the API to give it a go with Clang.

Patch by Hamza Sood.


https://reviews.llvm.org/D28365

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -10799,16 +10799,10 @@
   const char *Exe,
   const char *ClangProgramPath) {
   const auto  = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation , const JobAction ,
@@ -10833,33 +10827,17 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
 const auto  = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (MSVC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1140,6 +1140,13 @@
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
 
+  enum class SubDirectoryType {
+Bin,
+Include,
+Lib,
+  };
+  std::string getSubDirectoryPath(SubDirectoryType Type) const;
+
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
@@ -1147,17 +1154,10 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
 
-  bool getWindowsSDKDir(std::string , int ,
-std::string ,
-std::string ) const;
   bool getWindowsSDKLibraryPath(std::string ) const;
   /// \brief Check if Universal CRT should be used if available
-  bool 

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

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



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

firolino wrote:
> aaron.ballman wrote:
> > firolino wrote:
> > > aaron.ballman wrote:
> > > > firolino wrote:
> > > > > aaron.ballman wrote:
> > > > > > firolino wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > firolino wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > firolino wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > to
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } Object1, 
> > > > > > > > > > > > Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > or
> > > > > > > > > > > > ```
> > > > > > > > > > > > class A { 
> > > > > > > > > > > > } 
> > > > > > > > > > > > Object1, 
> > > > > > > > > > > > Object2;
> > > > > > > > > > > > ``` 
> > > > > > > > > > > > I might consider adding support for it. Moreover, this 
> > > > > > > > > > > > kind of definition is usually seen globally and I don't 
> > > > > > > > > > > > know how to handle globals yet. See 
> > > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > > I think this should be handled. It can be handled in 
> > > > > > > > > > > either of the forms you show, or by saying:
> > > > > > > > > > > ```
> > > > > > > > > > > A Object1;
> > > > > > > > > > > A Object2;
> > > > > > > > > > > ```
> > > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > > 
> > > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > > separate patch once we figure out the declaration 
> > > > > > > > > > > grouping.
> > > > > > > > > > OK. I will try to split the object definition from the 
> > > > > > > > > > class definition, as you have suggested. Thus, I can kick 
> > > > > > > > > > out the tagDecl-matcher as well. If there is no easy way to 
> > > > > > > > > > do this, it will be reported anyway but without a fixit.
> > > > > > > > > > 
> > > > > > > > > > Note for me: Update documentation!
> > > > > > > > > What about
> > > > > > > > > ```
> > > > > > > > > struct S {
> > > > > > > > > } S1;
> > > > > > > > > ```
> > > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > > ```
> > > > > > > > struct {
> > > > > > > > } nn1, nn2;
> > > > > > > > ```
> > > > > > > > Shall we ignore anonymous definitions?
> > > > > > > To be more precise: Warn and provide a fixit for `struct S {} 
> > > > > > > S1`. Only warn for `struct {} nn1, nn2`.
> > > > > > > What about
> > > > > > > 
> > > > > > > ```
> > > > > > > struct S {
> > > > > > > } S1;
> > > > > > > ```
> > > > > > > I would like to report this too, since two names are being 
> > > > > > > declared here. S and S1. What do you think?
> > > > > > 
> > > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > > relatively common pattern (arguably more common than `struct S { } 
> > > > > > S1, S2;`), but also, it names two very distinct entities (a type 
> > > > > > and a variable).
> > > > > > 
> > > > > > > ```
> > > > > > > struct {
> > > > > > > } nn1, nn2;
> > > > > > >```
> > > > > > > Shall we ignore anonymous definitions?
> > > > > > 
> > > > > > Yes, we basically have to.
> > > > > > 
> > > > > Transforming
> > > > > ```
> > > > > typedef struct X { int t; } X, Y;
> > > > > ```
> > > > > to
> > > > > ```
> > > > > typedef struct X { int t; };
> > > > > typedef X X;
> > > > > typedef X Y;
> > > > > ```
> > > > > will be valid, but looks odd.
> > > > I am on the fence about this transformation -- it does not declare new 
> > > > objects, but instead declares new types. A very common pattern in some 
> > > > libraries (such as the Win32 SDK) is to declare:
> > > > ```
> > > > typedef struct Blah {
> > > > 
> > > > } Blah, *PBlah, **PPBlah;
> > > > ```
> > > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > > very chatty in some projects, and I don't know that the fixit provides 
> > > > much real benefit for types.
> > > > 
> > > > At least for the CERT DCL04-C version of this rule, that code should 
> > > > not be flagged. Do you think any of the variations of this check should 
> > > > flag it?
> > > Maybe we should reconsider where to split and where not. The original 
> > > idea was to minimize confusion on code like

[PATCH] D28348: Taught the analyzer about Glib API to check Memory-leak

2017-01-05 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thanks for the patch!

Could you, please, resubmit the patch with context as described here 
http://llvm.org/docs/Phabricator.html
Also, please, add tests. See test/Analysis/ for examples.


Repository:
  rL LLVM

https://reviews.llvm.org/D28348



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


r291143 - Migrate PathDiagnosticPiece to std::shared_ptr

2017-01-05 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Jan  5 11:26:53 2017
New Revision: 291143

URL: http://llvm.org/viewvc/llvm-project?rev=291143=rev
Log:
Migrate PathDiagnosticPiece to std::shared_ptr

Simplifies and makes explicit the memory ownership model rather than
implicitly passing/acquiring ownership.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=291143=291142=291143=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Thu 
Jan  5 11:26:53 2017
@@ -66,8 +66,7 @@ public:
   typedef SmallVector VisitorList;
   typedef VisitorList::iterator visitor_iterator;
   typedef SmallVector ExtraTextList;
-  typedef SmallVector
-  NoteList;
+  typedef SmallVector NoteList;
 
 protected:
   friend class BugReporter;
@@ -268,12 +267,12 @@ public:
   /// the extra note should appear.
   void addNote(StringRef Msg, const PathDiagnosticLocation ,
ArrayRef Ranges) {
-PathDiagnosticNotePiece *P = new PathDiagnosticNotePiece(Pos, Msg);
+auto P = std::make_shared(Pos, Msg);
 
 for (const auto  : Ranges)
   P->addRange(R);
 
-Notes.push_back(P);
+Notes.push_back(std::move(P));
   }
 
   // FIXME: Instead of making an override, we could have default-initialized

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=291143=291142=291143=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Thu Jan  5 11:26:53 2017
@@ -59,10 +59,9 @@ public:
   ///
   /// The last parameter can be used to register a new visitor with the given
   /// BugReport while processing a node.
-  virtual PathDiagnosticPiece *VisitNode(const ExplodedNode *Succ,
- const ExplodedNode *Pred,
- BugReporterContext ,
- BugReport ) = 0;
+  virtual std::shared_ptr
+  VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred,
+BugReporterContext , BugReport ) = 0;
 
   /// \brief Provide custom definition for the final diagnostic piece on the
   /// path - the piece, which is displayed before the path is expanded.
@@ -121,10 +120,10 @@ public:
 
   void Profile(llvm::FoldingSetNodeID ) const override;
 
-  PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
- const ExplodedNode *PrevN,
- BugReporterContext ,
- BugReport ) override;
+  std::shared_ptr VisitNode(const ExplodedNode *N,
+ const ExplodedNode *PrevN,
+ BugReporterContext ,
+ BugReport ) override;
 };
 
 class TrackConstraintBRVisitor final
@@ -150,10 +149,10 @@ public:
   /// to make all PathDiagnosticPieces created by this visitor.
   static const char *getTag();
 
-  PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
- 

[PATCH] D28362: [ThinLTO] Optionally ignore empty index file

2017-01-05 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: mehdi_amini.
tejohnson added a subscriber: cfe-commits.

In order to simplify distributed build system integration, where actions
may be scheduled before the Thin Link which determines the list of
objects selected by the linker. The gold plugin currently will emit
0-sized index files for objects not selected by the link, to enable
checking for expected output files by the build system. If the build
system then schedules a backend action for these bitcode files, we want
to be able to fall back to normal compilation instead of failing.
Fallback is enabled under an option with this patch (I am investigating
whether this can be addressed in our build system, but that is a longer
term fix and so this enables a workaround in the meantime).


https://reviews.llvm.org/D28362

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto_backend.ll


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,11 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 
| FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc 
-ignore-empty-index-file 2>&1 | FileCheck %s -check-prefix=CHECK-NOERROR
+; CHECK-NOERROR-NOT: Error loading index file 'bad.thinlto.bc'
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -57,6 +58,12 @@
 using namespace clang;
 using namespace llvm;
 
+static llvm::cl::opt IgnoreEmptyThinLTOIndexFile(
+"ignore-empty-index-file", llvm::cl::ZeroOrMore,
+llvm::cl::desc(
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+
 namespace {
 
 class EmitAssemblyHelper {
@@ -935,8 +942,16 @@
   Module *M, BackendAction Action,
   std::unique_ptr OS) {
   if (!CGOpts.ThinLTOIndexFile.empty()) {
-runThinLTOBackend(CGOpts, M, std::move(OS));
-return;
+bool DoThinLTOBackend = true;
+if (IgnoreEmptyThinLTOIndexFile) {
+  uint64_t IndexFileSize;
+  llvm::sys::fs::file_size(CGOpts.ThinLTOIndexFile, IndexFileSize);
+  DoThinLTOBackend = IndexFileSize > 0;
+}
+if (DoThinLTOBackend) {
+  runThinLTOBackend(CGOpts, M, std::move(OS));
+  return;
+}
   }
 
   EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M);


Index: test/CodeGen/thinlto_backend.ll
===
--- test/CodeGen/thinlto_backend.ll
+++ test/CodeGen/thinlto_backend.ll
@@ -12,6 +12,11 @@
 ; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=bad.thinlto.bc 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR1
 ; CHECK-ERROR1: Error loading index file 'bad.thinlto.bc'
 
+; Ensure we ignore empty index file under -ignore-empty-index-file
+; RUN: touch %t4.thinlto.bc
+; RUN: %clang -O2 -o %t4.o -x ir %t1.o -c -fthinlto-index=%t4.thinlto.bc -ignore-empty-index-file 2>&1 | FileCheck %s -check-prefix=CHECK-NOERROR
+; CHECK-NOERROR-NOT: Error loading index file 'bad.thinlto.bc'
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c -fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check-prefix=CHECK-OBJ %s
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -57,6 +58,12 @@
 using namespace clang;
 using namespace llvm;
 
+static llvm::cl::opt IgnoreEmptyThinLTOIndexFile(
+"ignore-empty-index-file", llvm::cl::ZeroOrMore,
+llvm::cl::desc(
+"Ignore an empty index file and perform non-ThinLTO compilation"),
+llvm::cl::init(false));
+
 namespace {
 
 class EmitAssemblyHelper {
@@ -935,8 

[PATCH] D28131: [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.

2017-01-05 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__tree:1400
 __parent_pointer& __parent, const key_type& __v);
+// FIXME: Make this function const qualified. Unfortunetly doing so
+// breaks existing code which uses non-const callable comparators.

Didn't we address this in http://wg21.link/LWG2542 ?



https://reviews.llvm.org/D28131



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


r291142 - test: add a requires registered target

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 11:09:20 2017
New Revision: 291142

URL: http://llvm.org/viewvc/llvm-project?rev=291142=rev
Log:
test: add a requires registered target

It seems that the ARM buildbots do not include x86 support.  However,
other x86 targets do not support the ARM target.  Use a x86 triple and
require the registered target.

Modified:
cfe/trunk/test/CodeGen/inline-asm-inclusion.c

Modified: cfe/trunk/test/CodeGen/inline-asm-inclusion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-inclusion.c?rev=291142=291141=291142=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-inclusion.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-inclusion.c Thu Jan  5 11:09:20 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple i686--- -I %p/include -S -o - %s | FileCheck %s
+// REQUIRES: x86-registered-target
 
 __asm__(".include \"module.x\"");
 void function(void) {


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


[PATCH] D28323: [CUDA] Let NVPTX inherit the host's calling conventions.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291136: [CUDA] Let NVPTX inherit the host's calling 
conventions. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28323?vs=83130=83259#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28323

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu


Index: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
===
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1962,6 +1962,16 @@
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other 
than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {


Index: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
===
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1962,6 +1962,16 @@
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28326: [Docs] Update docs to indicate that CUDA compilation is supported on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291139: [Docs] Update docs to indicate that CUDA compilation 
is supported on Windows. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28326?vs=83134=83262#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28326

Files:
  llvm/trunk/docs/CompileCudaWithLLVM.rst


Index: llvm/trunk/docs/CompileCudaWithLLVM.rst
===
--- llvm/trunk/docs/CompileCudaWithLLVM.rst
+++ llvm/trunk/docs/CompileCudaWithLLVM.rst
@@ -35,8 +35,8 @@
 
 You will need CUDA 7.0, 7.5, or 8.0 to compile with clang.
 
-CUDA compilation is supported on Linux, and on MacOS as of -XX-XX.  Windows
-support is planned but not yet in place.
+CUDA compilation is supported on Linux, on MacOS as of 2016-11-18, and on
+Windows as of 2017-01-05.
 
 Invoking clang
 --


Index: llvm/trunk/docs/CompileCudaWithLLVM.rst
===
--- llvm/trunk/docs/CompileCudaWithLLVM.rst
+++ llvm/trunk/docs/CompileCudaWithLLVM.rst
@@ -35,8 +35,8 @@
 
 You will need CUDA 7.0, 7.5, or 8.0 to compile with clang.
 
-CUDA compilation is supported on Linux, and on MacOS as of -XX-XX.  Windows
-support is planned but not yet in place.
+CUDA compilation is supported on Linux, on MacOS as of 2016-11-18, and on
+Windows as of 2017-01-05.
 
 Invoking clang
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28325: [CUDA] Rename keywords used in macro so they don't conflict with MSVC.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291138: [CUDA] Rename keywords used in macro so they don't 
conflict with MSVC. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28325?vs=83133=83261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28325

Files:
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -35,50 +35,50 @@
 
 #pragma push_macro("__MAKE_SHUFFLES")
 #define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
-  inline __device__ int __FnName(int __in, int __offset,   
\
+  inline __device__ int __FnName(int __val, int __offset,  
\
  int __width = warpSize) { 
\
-return __IntIntrinsic(__in, __offset,  
\
+return __IntIntrinsic(__val, __offset, 
\
   ((warpSize - __width) << 8) | (__Mask)); 
\
   }
\
-  inline __device__ float __FnName(float __in, int __offset,   
\
+  inline __device__ float __FnName(float __val, int __offset,  
\
int __width = warpSize) {   
\
-return __FloatIntrinsic(__in, __offset,
\
+return __FloatIntrinsic(__val, __offset,   
\
 ((warpSize - __width) << 8) | (__Mask));   
\
   }
\
-  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, 
\
+  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,
\
   int __width = warpSize) {
\
 return static_cast(  
\
-::__FnName(static_cast(__in), __offset, __width));
\
+::__FnName(static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ long long __FnName(long long __in, int __offset,   
\
+  inline __device__ long long __FnName(long long __val, int __offset,  
\
int __width = warpSize) {   
\
 struct __Bits {
\
   int __a, __b;
\
 }; 
\
-_Static_assert(sizeof(__in) == sizeof(__Bits));
\
+_Static_assert(sizeof(__val) == sizeof(__Bits));   
\
 _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); 
\
 __Bits __tmp;  
\
-memcpy(&__in, &__tmp, sizeof(__in));   
\
+memcpy(&__val, &__tmp, sizeof(__val)); 
\
 __tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  
\
 __tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  
\
-long long __out;   
\
-memcpy(&__out, &__tmp, sizeof(__tmp)); 
\
-return __out;  
\
+long long __ret;   
\
+memcpy(&__ret, &__tmp, sizeof(__tmp)); 
\
+return __ret;  
\
   }
\
   inline __device__ unsigned long long __FnName(   
\
-  unsigned long long __in, int __offset, int __width = warpSize) { 
\
-return static_cast(
\
-::__FnName(static_cast(__in), __offset, __width)); 
\
+  unsigned long long __val, int __offset, int __width = warpSize) {
\
+return static_cast(::__FnName( 
\
+static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ double __FnName(double __in, int __offset, 
\
+  inline __device__ double __FnName(double __val, int __offset,
\
  

[PATCH] D28317: [Windows] Remove functions in intrin.h that are defined in Builtin.def.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291128: [Windows] Remove functions in intrin.h that are 
defined in Builtin.def. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28317?vs=83124=83252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28317

Files:
  cfe/trunk/lib/Headers/intrin.h

Index: cfe/trunk/lib/Headers/intrin.h
===
--- cfe/trunk/lib/Headers/intrin.h
+++ cfe/trunk/lib/Headers/intrin.h
@@ -65,7 +65,6 @@
 void __cpuid(int[4], int);
 static __inline__
 void __cpuidex(int[4], int, int);
-void __debugbreak(void);
 static __inline__
 __int64 __emul(int, int);
 static __inline__
@@ -109,10 +108,6 @@
 void __outdwordstring(unsigned short, unsigned long *, unsigned long);
 void __outword(unsigned short, unsigned short);
 void __outwordstring(unsigned short, unsigned short *, unsigned long);
-static __inline__
-unsigned int __popcnt(unsigned int);
-static __inline__
-unsigned short __popcnt16(unsigned short);
 unsigned long __readcr0(void);
 unsigned long __readcr2(void);
 static __inline__
@@ -124,8 +119,6 @@
 static __inline__
 unsigned char __readfsbyte(unsigned long);
 static __inline__
-unsigned long __readfsdword(unsigned long);
-static __inline__
 unsigned __int64 __readfsqword(unsigned long);
 static __inline__
 unsigned short __readfsword(unsigned long);
@@ -179,108 +172,34 @@
 unsigned char _bittestandreset(long *, long);
 static __inline__
 unsigned char _bittestandset(long *, long);
-unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
-unsigned long __cdecl _byteswap_ulong(unsigned long);
-unsigned short __cdecl _byteswap_ushort(unsigned short);
 void __cdecl _disable(void);
 void __cdecl _enable(void);
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
-static __inline__
-long _InterlockedAnd(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedAnd16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedAnd8(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset(long volatile *, long);
 static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
-static __inline__
-long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
- long _Exchange, long _Comparand);
 long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
 long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
-static __inline__
-short _InterlockedCompareExchange16(short volatile *_Destination,
-short _Exchange, short _Comparand);
-static __inline__
-__int64 _InterlockedCompareExchange64(__int64 volatile *_Destination,
-  __int64 _Exchange, __int64 _Comparand);
 __int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64,
  __int64);
 __int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
  __int64);
-static __inline__
-char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
-  char _Comparand);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
 void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
 void *);
-static __inline__
-long __cdecl _InterlockedDecrement(long volatile *_Addend);
-static __inline__
-short _InterlockedDecrement16(short volatile *_Addend);
-long _InterlockedExchange(long volatile *_Target, long _Value);
-static __inline__
-short _InterlockedExchange16(short volatile *_Target, short _Value);
-static __inline__
-char _InterlockedExchange8(char volatile *_Target, char _Value);
-static __inline__
-long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value);
 long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
-static __inline__
-short _InterlockedExchangeAdd16(short volatile *_Addend, short _Value);
 __int64 _InterlockedExchangeAdd64_HLEAcquire(__int64 volatile *, __int64);
 __int64 _InterlockedExchangeAdd64_HLERelease(__int64 volatile *, __int64);
-static __inline__
-char _InterlockedExchangeAdd8(char volatile *_Addend, char _Value);
-static __inline__
-long __cdecl _InterlockedIncrement(long volatile *_Addend);
-static __inline__
-short _InterlockedIncrement16(short volatile *_Addend);
-static __inline__
-long _InterlockedOr(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedOr16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedOr8(char volatile *_Value, char _Mask);
-static __inline__
-long 

r291138 - [CUDA] Rename keywords used in macro so they don't conflict with MSVC.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:54:11 2017
New Revision: 291138

URL: http://llvm.org/viewvc/llvm-project?rev=291138=rev
Log:
[CUDA] Rename keywords used in macro so they don't conflict with MSVC.

Summary:
MSVC seems to use "__in" and "__out" for its own purposes, so we have to
pick different names in this macro.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=291138=291137=291138=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Thu Jan  5 10:54:11 2017
@@ -35,50 +35,50 @@
 
 #pragma push_macro("__MAKE_SHUFFLES")
 #define __MAKE_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic, __Mask)
\
-  inline __device__ int __FnName(int __in, int __offset,   
\
+  inline __device__ int __FnName(int __val, int __offset,  
\
  int __width = warpSize) { 
\
-return __IntIntrinsic(__in, __offset,  
\
+return __IntIntrinsic(__val, __offset, 
\
   ((warpSize - __width) << 8) | (__Mask)); 
\
   }
\
-  inline __device__ float __FnName(float __in, int __offset,   
\
+  inline __device__ float __FnName(float __val, int __offset,  
\
int __width = warpSize) {   
\
-return __FloatIntrinsic(__in, __offset,
\
+return __FloatIntrinsic(__val, __offset,   
\
 ((warpSize - __width) << 8) | (__Mask));   
\
   }
\
-  inline __device__ unsigned int __FnName(unsigned int __in, int __offset, 
\
+  inline __device__ unsigned int __FnName(unsigned int __val, int __offset,
\
   int __width = warpSize) {
\
 return static_cast(  
\
-::__FnName(static_cast(__in), __offset, __width));
\
+::__FnName(static_cast(__val), __offset, __width));   
\
   }
\
-  inline __device__ long long __FnName(long long __in, int __offset,   
\
+  inline __device__ long long __FnName(long long __val, int __offset,  
\
int __width = warpSize) {   
\
 struct __Bits {
\
   int __a, __b;
\
 }; 
\
-_Static_assert(sizeof(__in) == sizeof(__Bits));
\
+_Static_assert(sizeof(__val) == sizeof(__Bits));   
\
 _Static_assert(sizeof(__Bits) == 2 * sizeof(int)); 
\
 __Bits __tmp;  
\
-memcpy(&__in, &__tmp, sizeof(__in));   
\
+memcpy(&__val, &__tmp, sizeof(__val)); 
\
 __tmp.__a = ::__FnName(__tmp.__a, __offset, __width);  
\
 __tmp.__b = ::__FnName(__tmp.__b, __offset, __width);  
\
-long long __out;   
\
-memcpy(&__out, &__tmp, sizeof(__tmp)); 
\
-return __out;  
\
+long long __ret;   
\
+memcpy(&__ret, &__tmp, sizeof(__tmp)); 
\
+return __ret;  
\
   }
\
   inline __device__ unsigned long long __FnName(   
\
-  unsigned long long __in, int __offset, int __width = warpSize) { 
\
-return static_cast(
\
-::__FnName(static_cast(__in), __offset, __width)); 
\
+  unsigned long long __val, int __offset, int __width = warpSize) {
\
+return static_cast(::__FnName( 
\
+static_cast(__val), __offset, __width));   
\
   }  

[PATCH] D28324: [CUDA] Don't define functions that the CUDA headers themselves define on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL291137: [CUDA] Don't define functions that the CUDA headers 
themselves define on… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28324?vs=83132=83260#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28324

Files:
  cfe/trunk/lib/Headers/__clang_cuda_cmath.h


Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -72,13 +72,21 @@
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 // For inscrutable reasons, __finite(), the double-precision version of
 // __finitef, does not exist when compiling for MacOS.  __isfinited is 
available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {


Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -72,13 +72,21 @@
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 // For inscrutable reasons, __finite(), the double-precision version of
 // __finitef, does not exist when compiling for MacOS.  __isfinited is available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291137 - [CUDA] Don't define functions that the CUDA headers themselves define on Windows.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:55 2017
New Revision: 291137

URL: http://llvm.org/viewvc/llvm-project?rev=291137=rev
Log:
[CUDA] Don't define functions that the CUDA headers themselves define on 
Windows.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=291137=291136=291137=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Thu Jan  5 10:53:55 2017
@@ -72,6 +72,10 @@ __DEVICE__ int fpclassify(double __x) {
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
+
+// For inscrutable reasons, the CUDA headers define these functions for us on
+// Windows.
+#ifndef _MSC_VER
 __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
 __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
@@ -79,6 +83,10 @@ __DEVICE__ bool isfinite(float __x) { re
 // __finitef, does not exist when compiling for MacOS.  __isfinited is 
available
 // everywhere and is just as good.
 __DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
+__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
+__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
+#endif
+
 __DEVICE__ bool isgreater(float __x, float __y) {
   return __builtin_isgreater(__x, __y);
 }
@@ -109,8 +117,6 @@ __DEVICE__ bool islessgreater(float __x,
 __DEVICE__ bool islessgreater(double __x, double __y) {
   return __builtin_islessgreater(__x, __y);
 }
-__DEVICE__ bool isnan(float __x) { return ::__isnanf(__x); }
-__DEVICE__ bool isnan(double __x) { return ::__isnan(__x); }
 __DEVICE__ bool isnormal(float __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isnormal(double __x) { return __builtin_isnormal(__x); }
 __DEVICE__ bool isunordered(float __x, float __y) {


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


r291136 - [CUDA] Let NVPTX inherit the host's calling conventions.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:38 2017
New Revision: 291136

URL: http://llvm.org/viewvc/llvm-project?rev=291136=rev
Log:
[CUDA] Let NVPTX inherit the host's calling conventions.

Summary:
When compiling device code, we may still see host code with explicit
calling conventions.  NVPTX needs to claim that it supports these CCs,
so that (a) we don't raise noisy warnings, and (b) we don't break
existing code which relies on the existence of these CCs when
specializing templates.  (If a CC doesn't exist, clang ignores it, so
two template specializations which are different only insofar as one
specifies a CC are considered identical and therefore are an error if
that CC is not supported.)

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=291136=291135=291136=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan  5 10:53:38 2017
@@ -1962,6 +1962,16 @@ public:
 Opts.support("cl_khr_local_int32_base_atomics");
 Opts.support("cl_khr_local_int32_extended_atomics");
   }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
+// CUDA compilations support all of the host's calling conventions.
+//
+// TODO: We should warn if you apply a non-default CC to anything other 
than
+// a host function.
+if (HostTarget)
+  return HostTarget->checkCallingConvention(CC);
+return CCCR_Warning;
+  }
 };
 
 const Builtin::Info NVPTXTargetInfo::BuiltinInfo[] = {

Added: cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu?rev=291136=auto
==
--- cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu (added)
+++ cfe/trunk/test/SemaCUDA/cuda-inherits-calling-conv.cu Thu Jan  5 10:53:38 
2017
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-windows-msvc \
+// RUN:   -aux-triple nvptx-nvidia-cuda -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple i386-windows-msvc -fsyntax-only \
+// RUN:   -fcuda-is-device -verify %s
+
+// RUN: %clang_cc1 -std=c++11 -triple nvptx-nvidia-cuda \
+// RUN:   -aux-triple x86_64-linux-gnu -fsyntax-only \
+// RUN:   -fcuda-is-device -verify -verify-ignore-unexpected=note \
+// RUN:   -DEXPECT_ERR %s
+
+// CUDA device code should inherit the host's calling conventions.
+
+template 
+struct Foo;
+
+template 
+struct Foo {};
+
+// On x86_64-linux-gnu, this is a redefinition of the template, because the
+// __fastcall calling convention doesn't exist (and is therefore ignored).
+#ifndef EXPECT_ERR
+// expected-no-diagnostics
+#else
+// expected-error@+4 {{redefinition of 'Foo}}
+// expected-warning@+3 {{calling convention '__fastcall' ignored}}
+#endif
+template 
+struct Foo {};


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


[PATCH] D28322: [CUDA] More correctly inherit primitive types from the host during device compilation.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291135: [CUDA] More correctly inherit primitive types from 
the host during device… (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28322?vs=83129=83258#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28322

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/cuda-types.cu

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -1751,30 +1751,57 @@
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
   CudaArch GPU;
+  std::unique_ptr HostTarget;
 
 public:
-  NVPTXTargetInfo(const llvm::Triple , const TargetOptions )
+  NVPTXTargetInfo(const llvm::Triple , const TargetOptions ,
+  unsigned TargetPointerWidth)
   : TargetInfo(Triple) {
+assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
+   "NVPTX only supports 32- and 64-bit modes.");
+
 TLSSupported = false;
-LongWidth = LongAlign = 64;
 AddrSpaceMap = 
 UseAddrSpaceMapMangling = true;
+
 // Define available target features
 // These must be defined in sorted order!
 NoAsmVariants = true;
 GPU = CudaArch::SM_20;
 
+if (TargetPointerWidth == 32)
+  resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
+else
+  resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
+
 // If possible, get a TargetInfo for our host triple, so we can match its
 // types.
 llvm::Triple HostTriple(Opts.HostTriple);
-if (HostTriple.isNVPTX())
-  return;
-std::unique_ptr HostTarget(
-AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+if (!HostTriple.isNVPTX())
+  HostTarget.reset(AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+
+// If no host target, make some guesses about the data layout and return.
 if (!HostTarget) {
+  LongWidth = LongAlign = TargetPointerWidth;
+  PointerWidth = PointerAlign = TargetPointerWidth;
+  switch (TargetPointerWidth) {
+  case 32:
+SizeType = TargetInfo::UnsignedInt;
+PtrDiffType = TargetInfo::SignedInt;
+IntPtrType = TargetInfo::SignedInt;
+break;
+  case 64:
+SizeType = TargetInfo::UnsignedLong;
+PtrDiffType = TargetInfo::SignedLong;
+IntPtrType = TargetInfo::SignedLong;
+break;
+  default:
+llvm_unreachable("TargetPointerWidth must be 32 or 64");
+  }
   return;
 }
 
+// Copy properties from host target.
 PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
 PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
 BoolWidth = HostTarget->getBoolWidth();
@@ -1953,31 +1980,6 @@
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-class NVPTX32TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX32TargetInfo(const llvm::Triple , const TargetOptions )
-  : NVPTXTargetInfo(Triple, Opts) {
-LongWidth = LongAlign = 32;
-PointerWidth = PointerAlign = 32;
-SizeType = TargetInfo::UnsignedInt;
-PtrDiffType = TargetInfo::SignedInt;
-IntPtrType = TargetInfo::SignedInt;
-resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
-class NVPTX64TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX64TargetInfo(const llvm::Triple , const TargetOptions )
-  : NVPTXTargetInfo(Triple, Opts) {
-PointerWidth = PointerAlign = 64;
-SizeType = TargetInfo::UnsignedLong;
-PtrDiffType = TargetInfo::SignedLong;
-IntPtrType = TargetInfo::SignedLong;
-resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
 static const unsigned AMDGPUAddrSpaceMap[] = {
   1,// opencl_global
   3,// opencl_local
@@ -8735,9 +8737,9 @@
 }
 
   case llvm::Triple::nvptx:
-return new NVPTX32TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/32);
   case llvm::Triple::nvptx64:
-return new NVPTX64TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/64);
 
   case llvm::Triple::amdgcn:
   case llvm::Triple::r600:
Index: cfe/trunk/test/Preprocessor/cuda-types.cu
===
--- cfe/trunk/test/Preprocessor/cuda-types.cu
+++ cfe/trunk/test/Preprocessor/cuda-types.cu
@@ -28,3 +28,19 @@
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
 // RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-device-defines-filtered
 // RUN: diff %T/powerpc64-host-defines-filtered %T/powerpc64-device-defines-filtered
+
+// RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
+// RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > 

[PATCH] D28321: [CUDA] Add __declspec spellings for CUDA attributes.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291134: [CUDA] Add __declspec spellings for CUDA attributes. 
(authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28321?vs=83128=83257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28321

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/test/SemaCUDA/attr-declspec.cu

Index: cfe/trunk/test/SemaCUDA/attr-declspec.cu
===
--- cfe/trunk/test/SemaCUDA/attr-declspec.cu
+++ cfe/trunk/test/SemaCUDA/attr-declspec.cu
@@ -0,0 +1,34 @@
+// Test the __declspec spellings of CUDA attributes.
+//
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -fcuda-is-device -verify %s
+// Now pretend that we're compiling a C file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fms-extensions -fsyntax-only -verify -x c %s
+
+#if defined(EXPECT_WARNINGS)
+// expected-warning@+12 {{'__device__' attribute ignored}}
+// expected-warning@+12 {{'__global__' attribute ignored}}
+// expected-warning@+12 {{'__constant__' attribute ignored}}
+// expected-warning@+12 {{'__shared__' attribute ignored}}
+// expected-warning@+12 {{'__host__' attribute ignored}}
+//
+// (Currently we don't for the other attributes. They are implemented with
+// IgnoredAttr, which is ignored irrespective of any LangOpts.)
+#else
+// expected-no-diagnostics
+#endif
+
+__declspec(__device__) void f_device();
+__declspec(__global__) void f_global();
+__declspec(__constant__) int* g_constant;
+__declspec(__shared__) float *g_shared;
+__declspec(__host__) void f_host();
+__declspec(__device_builtin__) void f_device_builtin();
+typedef __declspec(__device_builtin__) const void *t_device_builtin;
+enum __declspec(__device_builtin__) e_device_builtin {E};
+__declspec(__device_builtin__) int v_device_builtin;
+__declspec(__cudart_builtin__) void f_cudart_builtin();
+__declspec(__device_builtin_surface_type__) unsigned long long surface_var;
+__declspec(__device_builtin_texture_type__) unsigned long long texture_var;
+
+// Note that there's no __declspec spelling of nv_weak.
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -601,49 +601,53 @@
   let Documentation = [Undocumented];
 }
 
+// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
+
 def CUDAConstant : InheritableAttr {
-  let Spellings = [GNU<"constant">];
+  let Spellings = [GNU<"constant">, Declspec<"__constant__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDACudartBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"cudart_builtin">];
+  let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADevice : InheritableAttr {
-  let Spellings = [GNU<"device">];
+  let Spellings = [GNU<"device">, Declspec<"__device__">];
   let Subjects = SubjectList<[Function, Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDADeviceBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin">];
+  let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_surface_type">];
+  let Spellings = [GNU<"device_builtin_surface_type">,
+   Declspec<"__device_builtin_surface_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinTextureType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_texture_type">];
+  let Spellings = [GNU<"device_builtin_texture_type">,
+   Declspec<"__device_builtin_texture_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDAGlobal : InheritableAttr {
-  let Spellings = [GNU<"global">];
+  let Spellings = [GNU<"global">, Declspec<"__global__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDAHost : InheritableAttr {
-  let Spellings = [GNU<"host">];
+  let Spellings = [GNU<"host">, Declspec<"__host__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -657,7 +661,7 @@
 }
 
 def CUDALaunchBounds : InheritableAttr {
-  let Spellings = [GNU<"launch_bounds">];
+  let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
@@ -669,7 +673,7 @@
 }
 
 def CUDAShared : InheritableAttr {
-  let Spellings = [GNU<"shared">];
+  let Spellings = [GNU<"shared">, Declspec<"__shared__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts 

r291135 - [CUDA] More correctly inherit primitive types from the host during device compilation.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:21 2017
New Revision: 291135

URL: http://llvm.org/viewvc/llvm-project?rev=291135=rev
Log:
[CUDA] More correctly inherit primitive types from the host during device 
compilation.

Summary:
CUDA lets users share structs between the host and device, so for that
and other reasons, primitive types such as ptrdiff_t should be the same
on both sides of the compilation.

Our code to do this wasn't entirely successful.  In particular, we did a
bunch of work during the NVPTXTargetInfo constructor, only to override
it in the NVPTX{32,64}TargetInfo constructors.  It worked well enough on
Linux and Mac, but Windows is LLP64, which is different enough to break
it.

This patch removes the NVPTX{32,64}TargetInfo classes entirely and fixes
the bug described above.

Reviewers: tra

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/cuda-types.cu

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=291135=291134=291135=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan  5 10:53:21 2017
@@ -1751,30 +1751,57 @@ class NVPTXTargetInfo : public TargetInf
   static const char *const GCCRegNames[];
   static const Builtin::Info BuiltinInfo[];
   CudaArch GPU;
+  std::unique_ptr HostTarget;
 
 public:
-  NVPTXTargetInfo(const llvm::Triple , const TargetOptions )
+  NVPTXTargetInfo(const llvm::Triple , const TargetOptions ,
+  unsigned TargetPointerWidth)
   : TargetInfo(Triple) {
+assert((TargetPointerWidth == 32 || TargetPointerWidth == 64) &&
+   "NVPTX only supports 32- and 64-bit modes.");
+
 TLSSupported = false;
-LongWidth = LongAlign = 64;
 AddrSpaceMap = 
 UseAddrSpaceMapMangling = true;
+
 // Define available target features
 // These must be defined in sorted order!
 NoAsmVariants = true;
 GPU = CudaArch::SM_20;
 
+if (TargetPointerWidth == 32)
+  resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
+else
+  resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
+
 // If possible, get a TargetInfo for our host triple, so we can match its
 // types.
 llvm::Triple HostTriple(Opts.HostTriple);
-if (HostTriple.isNVPTX())
-  return;
-std::unique_ptr HostTarget(
-AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+if (!HostTriple.isNVPTX())
+  HostTarget.reset(AllocateTarget(llvm::Triple(Opts.HostTriple), Opts));
+
+// If no host target, make some guesses about the data layout and return.
 if (!HostTarget) {
+  LongWidth = LongAlign = TargetPointerWidth;
+  PointerWidth = PointerAlign = TargetPointerWidth;
+  switch (TargetPointerWidth) {
+  case 32:
+SizeType = TargetInfo::UnsignedInt;
+PtrDiffType = TargetInfo::SignedInt;
+IntPtrType = TargetInfo::SignedInt;
+break;
+  case 64:
+SizeType = TargetInfo::UnsignedLong;
+PtrDiffType = TargetInfo::SignedLong;
+IntPtrType = TargetInfo::SignedLong;
+break;
+  default:
+llvm_unreachable("TargetPointerWidth must be 32 or 64");
+  }
   return;
 }
 
+// Copy properties from host target.
 PointerWidth = HostTarget->getPointerWidth(/* AddrSpace = */ 0);
 PointerAlign = HostTarget->getPointerAlign(/* AddrSpace = */ 0);
 BoolWidth = HostTarget->getBoolWidth();
@@ -1953,31 +1980,6 @@ ArrayRef NVPTXTargetInfo::
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-class NVPTX32TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX32TargetInfo(const llvm::Triple , const TargetOptions )
-  : NVPTXTargetInfo(Triple, Opts) {
-LongWidth = LongAlign = 32;
-PointerWidth = PointerAlign = 32;
-SizeType = TargetInfo::UnsignedInt;
-PtrDiffType = TargetInfo::SignedInt;
-IntPtrType = TargetInfo::SignedInt;
-resetDataLayout("e-p:32:32-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
-class NVPTX64TargetInfo : public NVPTXTargetInfo {
-public:
-  NVPTX64TargetInfo(const llvm::Triple , const TargetOptions )
-  : NVPTXTargetInfo(Triple, Opts) {
-PointerWidth = PointerAlign = 64;
-SizeType = TargetInfo::UnsignedLong;
-PtrDiffType = TargetInfo::SignedLong;
-IntPtrType = TargetInfo::SignedLong;
-resetDataLayout("e-i64:64-v16:16-v32:32-n16:32:64");
-  }
-};
-
 static const unsigned AMDGPUAddrSpaceMap[] = {
   1,// opencl_global
   3,// opencl_local
@@ -8735,9 +8737,9 @@ static TargetInfo *AllocateTarget(const
 }
 
   case llvm::Triple::nvptx:
-return new NVPTX32TargetInfo(Triple, Opts);
+return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/32);
   case llvm::Triple::nvptx64:
-return new NVPTX64TargetInfo(Triple, Opts);
+return new 

r291134 - [CUDA] Add __declspec spellings for CUDA attributes.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:53:04 2017
New Revision: 291134

URL: http://llvm.org/viewvc/llvm-project?rev=291134=rev
Log:
[CUDA] Add __declspec spellings for CUDA attributes.

Summary: CUDA attributes are spelled __declspec(__foo__) on Windows.

Reviewers: tra

Subscribers: cfe-commits, rnk

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

Added:
cfe/trunk/test/SemaCUDA/attr-declspec.cu
Modified:
cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=291134=291133=291134=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Jan  5 10:53:04 2017
@@ -601,49 +601,53 @@ def Constructor : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+// CUDA attributes are spelled __attribute__((attr)) or __declspec(__attr__).
+
 def CUDAConstant : InheritableAttr {
-  let Spellings = [GNU<"constant">];
+  let Spellings = [GNU<"constant">, Declspec<"__constant__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDACudartBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"cudart_builtin">];
+  let Spellings = [GNU<"cudart_builtin">, Declspec<"__cudart_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADevice : InheritableAttr {
-  let Spellings = [GNU<"device">];
+  let Spellings = [GNU<"device">, Declspec<"__device__">];
   let Subjects = SubjectList<[Function, Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDADeviceBuiltin : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin">];
+  let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinSurfaceType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_surface_type">];
+  let Spellings = [GNU<"device_builtin_surface_type">,
+   Declspec<"__device_builtin_surface_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDADeviceBuiltinTextureType : IgnoredAttr {
-  let Spellings = [GNU<"device_builtin_texture_type">];
+  let Spellings = [GNU<"device_builtin_texture_type">,
+   Declspec<"__device_builtin_texture_type__">];
   let LangOpts = [CUDA];
 }
 
 def CUDAGlobal : InheritableAttr {
-  let Spellings = [GNU<"global">];
+  let Spellings = [GNU<"global">, Declspec<"__global__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
 }
 
 def CUDAHost : InheritableAttr {
-  let Spellings = [GNU<"host">];
+  let Spellings = [GNU<"host">, Declspec<"__host__">];
   let Subjects = SubjectList<[Function]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -657,7 +661,7 @@ def CUDAInvalidTarget : InheritableAttr
 }
 
 def CUDALaunchBounds : InheritableAttr {
-  let Spellings = [GNU<"launch_bounds">];
+  let Spellings = [GNU<"launch_bounds">, Declspec<"__launch_bounds__">];
   let Args = [ExprArgument<"MaxThreads">, ExprArgument<"MinBlocks", 1>];
   let LangOpts = [CUDA];
   let Subjects = SubjectList<[ObjCMethod, FunctionLike], WarnDiag,
@@ -669,7 +673,7 @@ def CUDALaunchBounds : InheritableAttr {
 }
 
 def CUDAShared : InheritableAttr {
-  let Spellings = [GNU<"shared">];
+  let Spellings = [GNU<"shared">, Declspec<"__shared__">];
   let Subjects = SubjectList<[Var]>;
   let LangOpts = [CUDA];
   let Documentation = [Undocumented];
@@ -1195,6 +1199,8 @@ def NoThrow : InheritableAttr {
 }
 
 def NvWeak : IgnoredAttr {
+  // No Declspec spelling of this attribute; the CUDA headers use
+  // __attribute__((nv_weak)) unconditionally.
   let Spellings = [GNU<"nv_weak">];
   let LangOpts = [CUDA];
 }

Added: cfe/trunk/test/SemaCUDA/attr-declspec.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/attr-declspec.cu?rev=291134=auto
==
--- cfe/trunk/test/SemaCUDA/attr-declspec.cu (added)
+++ cfe/trunk/test/SemaCUDA/attr-declspec.cu Thu Jan  5 10:53:04 2017
@@ -0,0 +1,34 @@
+// Test the __declspec spellings of CUDA attributes.
+//
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -fcuda-is-device -verify %s
+// Now pretend that we're compiling a C file. There should be warnings.
+// RUN: %clang_cc1 -DEXPECT_WARNINGS -fms-extensions -fsyntax-only -verify -x 
c %s
+
+#if defined(EXPECT_WARNINGS)
+// expected-warning@+12 {{'__device__' attribute ignored}}
+// expected-warning@+12 {{'__global__' attribute ignored}}
+// expected-warning@+12 {{'__constant__' attribute ignored}}
+// expected-warning@+12 {{'__shared__' attribute ignored}}
+// expected-warning@+12 {{'__host__' attribute ignored}}
+//
+// (Currently we don't for the other attributes. They are implemented with
+// IgnoredAttr, which is 

[PATCH] D28320: [Driver] Driver changes to support CUDA compilation on Windows.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked an inline comment as done.
Closed by commit rL291131: [Driver] Driver changes to support CUDA compilation 
on Windows. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28320?vs=83127=83255#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28320

Files:
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/MSVCToolChain.cpp
  cfe/trunk/lib/Driver/MinGWToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/bin/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/include/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/lib/.keep
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_30.10.bc
  cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing 
Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_35.10.bc
  cfe/trunk/test/Driver/cuda-windows.cu

Index: cfe/trunk/include/clang/Driver/ToolChain.h
===
--- cfe/trunk/include/clang/Driver/ToolChain.h
+++ cfe/trunk/include/clang/Driver/ToolChain.h
@@ -139,6 +139,13 @@
   vfs::FileSystem () const;
   const llvm::Triple () const { return Triple; }
 
+  /// Get the toolchain's aux triple, if it has one.
+  ///
+  /// Exactly what the aux triple represents depends on the toolchain, but for
+  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
+  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
+  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
+
   llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
   StringRef getArchName() const { return Triple.getArchName(); }
   StringRef getPlatform() const { return Triple.getVendorName(); }
Index: cfe/trunk/test/Driver/cuda-windows.cu
===
--- cfe/trunk/test/Driver/cuda-windows.cu
+++ cfe/trunk/test/Driver/cuda-windows.cu
@@ -0,0 +1,14 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+//
+// RUN: %clang -v --target=i386-pc-windows-msvc \
+// RUN:   --sysroot=%S/Inputs/CUDA-windows 2>&1 %s -### | FileCheck %s
+// RUN: %clang -v --target=i386-pc-windows-mingw32 \
+// RUN:   --sysroot=%S/Inputs/CUDA-windows 2>&1 %s -### | FileCheck %s
+
+// CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA-windows/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
+// CHECK: "-cc1" "-triple" "nvptx-nvidia-cuda"
+// CHECK-SAME: "-fms-extensions"
+// CHECK-SAME: "-fms-compatibility"
+// CHECK-SAME: "-fms-compatibility-version=
Index: cfe/trunk/lib/Driver/MinGWToolChain.cpp
===
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp
@@ -63,7 +63,7 @@
 }
 
 MinGW::MinGW(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
 // In Windows there aren't any standard install locations, we search
@@ -135,6 +135,15 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MinGW::AddCudaIncludeArgs(const ArgList ,
+   ArgStringList ) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
+void MinGW::printVerboseInfo(raw_ostream ) const {
+  CudaInstallation.print(OS);
+}
+
 // Include directories for various hosts:
 
 // Windows, mingw.org
Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp
===
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp
@@ -47,9 +47,9 @@
 using namespace clang;
 using namespace llvm::opt;
 
-MSVCToolChain::MSVCToolChain(const Driver , const llvm::Triple& Triple,
+MSVCToolChain::MSVCToolChain(const Driver , const llvm::Triple ,
  const ArgList )
-  : ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
@@ -94,6 +94,15 @@
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MSVCToolChain::AddCudaIncludeArgs(const ArgList ,
+   ArgStringList ) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
+void MSVCToolChain::printVerboseInfo(raw_ostream ) const {
+  

r291133 - [ToolChains] Use "static" instead of an anonymous namespace for a function. NFC

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:47 2017
New Revision: 291133

URL: http://llvm.org/viewvc/llvm-project?rev=291133=rev
Log:
[ToolChains] Use "static" instead of an anonymous namespace for a function.  NFC

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

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=291133=291132=291133=diff
==
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Thu Jan  5 10:52:47 2017
@@ -20,10 +20,9 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-namespace {
 // Simplified from 
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
-bool findGccVersion(StringRef LibDir, std::string ,
-std::string ) {
+static bool findGccVersion(StringRef LibDir, std::string ,
+   std::string ) {
   Generic_GCC::GCCVersion Version = Generic_GCC::GCCVersion::Parse("0.0.0");
   std::error_code EC;
   for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
@@ -40,7 +39,6 @@ bool findGccVersion(StringRef LibDir, st
   }
   return Ver.size();
 }
-}
 
 void MinGW::findGccLibDir() {
   llvm::SmallVector, 2> Archs;


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


r291131 - [Driver] Driver changes to support CUDA compilation on Windows.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:29 2017
New Revision: 291131

URL: http://llvm.org/viewvc/llvm-project?rev=291131=rev
Log:
[Driver] Driver changes to support CUDA compilation on Windows.

Summary:
For the most part this is straightforward: Just add a CudaInstallation
object to the MSVC and MinGW toolchains.

CudaToolChain has to override computeMSVCVersion so that
Clang::constructJob passes the right version flag to cc1.  We have to
modify IsWindowsMSVC and friends in Clang::constructJob to be true when
compiling CUDA device code on Windows for the same reason.

Depends on: D28319

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/Inputs/CUDA-windows/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/bin/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/bin/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/include/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/include/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/lib/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/lib/.keep
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_30.10.bc
cfe/trunk/test/Driver/Inputs/CUDA-windows/Program Files/NVIDIA GPU 
Computing Toolkit/CUDA/v8.0/nvvm/libdevice/libdevice.compute_35.10.bc
cfe/trunk/test/Driver/cuda-windows.cu
Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/MSVCToolChain.cpp
cfe/trunk/lib/Driver/MinGWToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=291131=291130=291131=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Thu Jan  5 10:52:29 2017
@@ -139,6 +139,13 @@ public:
   vfs::FileSystem () const;
   const llvm::Triple () const { return Triple; }
 
+  /// Get the toolchain's aux triple, if it has one.
+  ///
+  /// Exactly what the aux triple represents depends on the toolchain, but for
+  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
+  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
+  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
+
   llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
   StringRef getArchName() const { return Triple.getArchName(); }
   StringRef getPlatform() const { return Triple.getVendorName(); }

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=291131=291130=291131=diff
==
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Thu Jan  5 10:52:29 2017
@@ -47,9 +47,9 @@ using namespace clang::driver::toolchain
 using namespace clang;
 using namespace llvm::opt;
 
-MSVCToolChain::MSVCToolChain(const Driver , const llvm::Triple& Triple,
+MSVCToolChain::MSVCToolChain(const Driver , const llvm::Triple ,
  const ArgList )
-  : ToolChain(D, Triple, Args) {
+: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
@@ -94,6 +94,15 @@ bool MSVCToolChain::isPICDefaultForced()
   return getArch() == llvm::Triple::x86_64;
 }
 
+void MSVCToolChain::AddCudaIncludeArgs(const ArgList ,
+   ArgStringList ) const {
+  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
+}
+
+void MSVCToolChain::printVerboseInfo(raw_ostream ) const {
+  CudaInstallation.print(OS);
+}
+
 #ifdef USE_WIN32
 static bool 

[PATCH] D28319: [CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291130: [CUDA] Make CUDAInstallationDetector take the host 
triple in its constructor. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28319?vs=83126=83254#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28319

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


Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -43,7 +43,7 @@
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver , const llvm::Triple ,
+  CudaInstallationDetector(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1805,7 +1805,7 @@
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver , const llvm::Triple ,
+const Driver , const llvm::Triple ,
 const llvm::opt::ArgList )
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@
 CudaToolChain::CudaToolChain(const Driver , const llvm::Triple ,
  const ToolChain , const ArgList )
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }


Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -43,7 +43,7 @@
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver , const llvm::Triple ,
+  CudaInstallationDetector(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1805,7 +1805,7 @@
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver , const llvm::Triple ,
+const Driver , const llvm::Triple ,
 const llvm::opt::ArgList )
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@
 CudaToolChain::CudaToolChain(const Driver , const llvm::Triple ,
  const ToolChain , const ArgList )
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291130 - [CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:52:11 2017
New Revision: 291130

URL: http://llvm.org/viewvc/llvm-project?rev=291130=rev
Log:
[CUDA] Make CUDAInstallationDetector take the host triple in its constructor.

Summary:
Previously it was taking the true target triple, which is not really
what it needs: The location of the CUDA installation depends on the host
OS.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=291130=291129=291130=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Jan  5 10:52:11 2017
@@ -1805,7 +1805,7 @@ static CudaVersion ParseCudaVersionFile(
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
-const Driver , const llvm::Triple ,
+const Driver , const llvm::Triple ,
 const llvm::opt::ArgList )
 : D(D) {
   SmallVector CudaPathCandidates;
@@ -1840,7 +1840,7 @@ CudaInstallationDetector::CudaInstallati
 // It's sufficient for our purposes to be flexible: If both lib and lib64
 // exist, we choose whichever one matches our triple.  Otherwise, if only
 // lib exists, we use it.
-if (TargetTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
+if (HostTriple.isArch64Bit() && FS.exists(InstallPath + "/lib64"))
   LibPath = InstallPath + "/lib64";
 else if (FS.exists(InstallPath + "/lib"))
   LibPath = InstallPath + "/lib";
@@ -4870,7 +4870,7 @@ Tool *DragonFly::buildLinker() const {
 CudaToolChain::CudaToolChain(const Driver , const llvm::Triple ,
  const ToolChain , const ArgList )
 : ToolChain(D, Triple, Args), HostTC(HostTC),
-  CudaInstallation(D, Triple, Args) {
+  CudaInstallation(D, HostTC.getTriple(), Args) {
   if (CudaInstallation.isValid())
 getProgramPaths().push_back(CudaInstallation.getBinPath());
 }

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=291130=291129=291130=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Jan  5 10:52:11 2017
@@ -43,7 +43,7 @@ private:
   mutable llvm::SmallSet ArchsWithVersionTooLowErrors;
 
 public:
-  CudaInstallationDetector(const Driver , const llvm::Triple ,
+  CudaInstallationDetector(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
 
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,


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


r291129 - [TableGen] Only normalize the spelling of GNU-style attributes.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:51:54 2017
New Revision: 291129

URL: http://llvm.org/viewvc/llvm-project?rev=291129=rev
Log:
[TableGen] Only normalize the spelling of GNU-style attributes.

Summary:
When Sema looks up an attribute name, it strips off leading and trailing
"__" if the attribute is GNU-style.  That is, __attribute__((foo)) and
__attribute__((__foo__)) are equivalent.

This is only true for GNU-style attributes.  In particular,
__declspec(__foo__) is not equivalent to __declspec(foo), and Sema
respects this difference.

This patch fixes TableGen to match Sema's behavior.  The spelling
'GNU<"__foo__">' should be normalized to 'GNU<"foo">', but
'Declspec<"__foo__">' should not be changed.

This is necessary to make CUDA compilation work on Windows, because e.g.
the __device__ attribute is spelled __declspec(__device__).

Attr.td does not contain any Declspec spellings that start or end with
"__", so this change should not affect any other attributes.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

Modified:
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=291129=291128=291129=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Thu Jan  5 10:51:54 2017
@@ -133,10 +133,9 @@ static StringRef NormalizeNameForSpellin
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in 
"__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's 
name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@ void EmitClangAttrParsedAttrKinds(Record
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));


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


[PATCH] D28318: [TableGen] Only normalize the spelling of GNU-style attributes.

2017-01-05 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291129: [TableGen] Only normalize the spelling of GNU-style 
attributes. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D28318?vs=83125=83253#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28318

Files:
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -133,10 +133,9 @@
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in 
"__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's 
name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));


Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -133,10 +133,9 @@
   return Name.trim("_");
 }
 
-// Normalize attribute spelling only if the spelling has both leading
-// and trailing underscores. For example, __ms_struct__ will be 
-// normalized to "ms_struct"; __cdecl will remain intact.
-static StringRef NormalizeAttrSpelling(StringRef AttrSpelling) {
+// Normalize the spelling of a GNU attribute (i.e. "x" in "__attribute__((x))"),
+// removing "__" if it appears at the beginning and end of the attribute's name.
+static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
   if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
 AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
   }
@@ -3045,7 +3044,11 @@
 
 assert(Matches && "Unsupported spelling variety found");
 
-Spelling += NormalizeAttrSpelling(RawSpelling);
+if (Variety == "GNU")
+  Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+else
+  Spelling += RawSpelling;
+
 if (SemaHandler)
   Matches->push_back(StringMatcher::StringPair(Spelling,
   "return AttributeList::AT_" + AttrName + ";"));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291128 - [Windows] Remove functions in intrin.h that are defined in Builtin.def.

2017-01-05 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Jan  5 10:51:37 2017
New Revision: 291128

URL: http://llvm.org/viewvc/llvm-project?rev=291128=rev
Log:
[Windows] Remove functions in intrin.h that are defined in Builtin.def.

Summary:
These duplicate declarations cause a problem for CUDA compiles on
Windows.  All implicitly-defined functions are host+device, and this
applies to the declarations in Builtin.def.  But then when we see the
declarations in intrin.h, they have no attributes, so are host-only
functions.  This is an error.

(A better fix might be to make these builtins host-only, but that is a
much bigger change.)

Reviewers: rnk

Subscribers: cfe-commits, echristo

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

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

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=291128=291127=291128=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Thu Jan  5 10:51:37 2017
@@ -65,7 +65,6 @@ static __inline__
 void __cpuid(int[4], int);
 static __inline__
 void __cpuidex(int[4], int, int);
-void __debugbreak(void);
 static __inline__
 __int64 __emul(int, int);
 static __inline__
@@ -109,10 +108,6 @@ void __outdword(unsigned short, unsigned
 void __outdwordstring(unsigned short, unsigned long *, unsigned long);
 void __outword(unsigned short, unsigned short);
 void __outwordstring(unsigned short, unsigned short *, unsigned long);
-static __inline__
-unsigned int __popcnt(unsigned int);
-static __inline__
-unsigned short __popcnt16(unsigned short);
 unsigned long __readcr0(void);
 unsigned long __readcr2(void);
 static __inline__
@@ -124,8 +119,6 @@ unsigned int __readdr(unsigned int);
 static __inline__
 unsigned char __readfsbyte(unsigned long);
 static __inline__
-unsigned long __readfsdword(unsigned long);
-static __inline__
 unsigned __int64 __readfsqword(unsigned long);
 static __inline__
 unsigned short __readfsword(unsigned long);
@@ -179,108 +172,34 @@ static __inline__
 unsigned char _bittestandreset(long *, long);
 static __inline__
 unsigned char _bittestandset(long *, long);
-unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
-unsigned long __cdecl _byteswap_ulong(unsigned long);
-unsigned short __cdecl _byteswap_ushort(unsigned short);
 void __cdecl _disable(void);
 void __cdecl _enable(void);
 long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value);
-static __inline__
-long _InterlockedAnd(long volatile *_Value, long _Mask);
-static __inline__
-short _InterlockedAnd16(short volatile *_Value, short _Mask);
-static __inline__
-char _InterlockedAnd8(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset(long volatile *, long);
 static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
-static __inline__
-long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
- long _Exchange, long _Comparand);
 long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long);
 long _InterlockedCompareExchange_HLERelease(long volatile *, long, long);
-static __inline__
-short _InterlockedCompareExchange16(short volatile *_Destination,
-short _Exchange, short _Comparand);
-static __inline__
-__int64 _InterlockedCompareExchange64(__int64 volatile *_Destination,
-  __int64 _Exchange, __int64 _Comparand);
 __int64 _InterlockedcompareExchange64_HLEAcquire(__int64 volatile *, __int64,
  __int64);
 __int64 _InterlockedCompareExchange64_HLERelease(__int64 volatile *, __int64,
  __int64);
-static __inline__
-char _InterlockedCompareExchange8(char volatile *_Destination, char _Exchange,
-  char _Comparand);
 void *_InterlockedCompareExchangePointer_HLEAcquire(void *volatile *, void *,
 void *);
 void *_InterlockedCompareExchangePointer_HLERelease(void *volatile *, void *,
 void *);
-static __inline__
-long __cdecl _InterlockedDecrement(long volatile *_Addend);
-static __inline__
-short _InterlockedDecrement16(short volatile *_Addend);
-long _InterlockedExchange(long volatile *_Target, long _Value);
-static __inline__
-short _InterlockedExchange16(short volatile *_Target, short _Value);
-static __inline__
-char _InterlockedExchange8(char volatile *_Target, char _Value);
-static __inline__
-long __cdecl _InterlockedExchangeAdd(long volatile *_Addend, long _Value);
 long _InterlockedExchangeAdd_HLEAcquire(long volatile *, long);
 long _InterlockedExchangeAdd_HLERelease(long volatile *, long);
-static __inline__
-short _InterlockedExchangeAdd16(short volatile *_Addend, short _Value);
 

[PATCH] D28349: [Frontend] The macro that describes the Objective-C bool type should be defined in C as well

2017-01-05 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

The "!LangOpts.CPlusPlus" doesn't make sense to me. You're presumably defining 
this macro in C because the Objective-C runtime is usable from C, but that same 
logic applies to C++ code. It seems like we should be defining this macro 
unconditionally.


Repository:
  rL LLVM

https://reviews.llvm.org/D28349



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


r291125 - test: add an explicit triple

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 10:36:15 2017
New Revision: 291125

URL: http://llvm.org/viewvc/llvm-project?rev=291125=rev
Log:
test: add an explicit triple

Not all targets use the integrated assembler.  Specify a triple to
ensure we use the integrated as for this.

Modified:
cfe/trunk/test/CodeGen/inline-asm-inclusion.c

Modified: cfe/trunk/test/CodeGen/inline-asm-inclusion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline-asm-inclusion.c?rev=291125=291124=291125=diff
==
--- cfe/trunk/test/CodeGen/inline-asm-inclusion.c (original)
+++ cfe/trunk/test/CodeGen/inline-asm-inclusion.c Thu Jan  5 10:36:15 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I %p/include -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686--- -I %p/include -S -o - %s | FileCheck %s
 
 __asm__(".include \"module.x\"");
 void function(void) {


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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-01-05 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Ping.


https://reviews.llvm.org/D25866



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


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

2017-01-05 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added inline comments.



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

aaron.ballman wrote:
> firolino wrote:
> > aaron.ballman wrote:
> > > firolino wrote:
> > > > aaron.ballman wrote:
> > > > > firolino wrote:
> > > > > > firolino wrote:
> > > > > > > firolino wrote:
> > > > > > > > firolino wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > firolino wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > Why do we not want to match this?
> > > > > > > > > > > If we decide, whether we transform 
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } Object1, Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > to
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } Object1, 
> > > > > > > > > > > Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > or
> > > > > > > > > > > ```
> > > > > > > > > > > class A { 
> > > > > > > > > > > } 
> > > > > > > > > > > Object1, 
> > > > > > > > > > > Object2;
> > > > > > > > > > > ``` 
> > > > > > > > > > > I might consider adding support for it. Moreover, this 
> > > > > > > > > > > kind of definition is usually seen globally and I don't 
> > > > > > > > > > > know how to handle globals yet. See 
> > > > > > > > > > > http://lists.llvm.org/pipermail/cfe-dev/2015-November/046262.html
> > > > > > > > > > I think this should be handled. It can be handled in either 
> > > > > > > > > > of the forms you show, or by saying:
> > > > > > > > > > ```
> > > > > > > > > > A Object1;
> > > > > > > > > > A Object2;
> > > > > > > > > > ```
> > > > > > > > > > If all of these turn out to be a problem, we can still 
> > > > > > > > > > diagnose without providing a fixit.
> > > > > > > > > > 
> > > > > > > > > > As for globals in general, they can be handled in a 
> > > > > > > > > > separate patch once we figure out the declaration grouping.
> > > > > > > > > OK. I will try to split the object definition from the class 
> > > > > > > > > definition, as you have suggested. Thus, I can kick out the 
> > > > > > > > > tagDecl-matcher as well. If there is no easy way to do this, 
> > > > > > > > > it will be reported anyway but without a fixit.
> > > > > > > > > 
> > > > > > > > > Note for me: Update documentation!
> > > > > > > > What about
> > > > > > > > ```
> > > > > > > > struct S {
> > > > > > > > } S1;
> > > > > > > > ```
> > > > > > > > I would like to report this too, since two names are being 
> > > > > > > > declared here. `S` and `S1`. What do you think?
> > > > > > > ```
> > > > > > > struct {
> > > > > > > } nn1, nn2;
> > > > > > > ```
> > > > > > > Shall we ignore anonymous definitions?
> > > > > > To be more precise: Warn and provide a fixit for `struct S {} S1`. 
> > > > > > Only warn for `struct {} nn1, nn2`.
> > > > > > What about
> > > > > > 
> > > > > > ```
> > > > > > struct S {
> > > > > > } S1;
> > > > > > ```
> > > > > > I would like to report this too, since two names are being declared 
> > > > > > here. S and S1. What do you think?
> > > > > 
> > > > > I don't think that this should be diagnosed. For one, this is a 
> > > > > relatively common pattern (arguably more common than `struct S { } 
> > > > > S1, S2;`), but also, it names two very distinct entities (a type and 
> > > > > a variable).
> > > > > 
> > > > > > ```
> > > > > > struct {
> > > > > > } nn1, nn2;
> > > > > >```
> > > > > > Shall we ignore anonymous definitions?
> > > > > 
> > > > > Yes, we basically have to.
> > > > > 
> > > > Transforming
> > > > ```
> > > > typedef struct X { int t; } X, Y;
> > > > ```
> > > > to
> > > > ```
> > > > typedef struct X { int t; };
> > > > typedef X X;
> > > > typedef X Y;
> > > > ```
> > > > will be valid, but looks odd.
> > > I am on the fence about this transformation -- it does not declare new 
> > > objects, but instead declares new types. A very common pattern in some 
> > > libraries (such as the Win32 SDK) is to declare:
> > > ```
> > > typedef struct Blah {
> > > 
> > > } Blah, *PBlah, **PPBlah;
> > > ```
> > > Because of that pattern, diagnosing the above typedef is likely to be 
> > > very chatty in some projects, and I don't know that the fixit provides 
> > > much real benefit for types.
> > > 
> > > At least for the CERT DCL04-C version of this rule, that code should not 
> > > be flagged. Do you think any of the variations of this check should flag 
> > > it?
> > Maybe we should reconsider where to split and where not. The original idea 
> > was to minimize confusion on code like
> > ```
> > int* a,b;
> > ```
> > whereas 
> > ```
> > struct S {} *s1, s2;
> > ```
> > seems not so confusing as above. However, 
> > ```
> > struct S {}* s1, s2;
> > ```
> > looks dangerous again.
> > 
> > Even following code looks unfamiliar to me.
> > ```
> > typedef 

r291124 - [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Jan  5 10:02:49 2017
New Revision: 291124

URL: http://llvm.org/viewvc/llvm-project?rev=291124=rev
Log:
[OpenMP] Add fields for flags in the offload entry descriptor.

Summary:
This patch adds two fields to the offload entry descriptor. One field is meant 
to signal Ctors/Dtors and `link` global variables, and the other is reserved 
for runtime library use. 

 Currently, these fields are only filled with zeros in the current code 
generation, but that will change when `declare target` is added. 

The reason, we are adding these fields now is to make the code generation 
consistent with the runtime library proposal under review in 
https://reviews.llvm.org/D14031.

Reviewers: ABataev, hfinkel, carlo.bertolli, kkwli0, arpith-jacob, Hahnfeld

Subscribers: cfe-commits, caomhin, jholewinski

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_codegen_registration.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=291124=291123=291124=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  5 10:02:49 2017
@@ -2701,14 +2701,16 @@ void CGOpenMPRuntime::OffloadEntriesInfo
  "only required for the device "
  "code generation.");
   OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] =
-  OffloadEntryInfoTargetRegion(Order, /*Addr=*/nullptr, /*ID=*/nullptr);
+  OffloadEntryInfoTargetRegion(Order, /*Addr=*/nullptr, /*ID=*/nullptr,
+   /*Flags=*/0);
   ++OffloadingEntriesNum;
 }
 
 void CGOpenMPRuntime::OffloadEntriesInfoManagerTy::
 registerTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
   StringRef ParentName, unsigned LineNum,
-  llvm::Constant *Addr, llvm::Constant *ID) {
+  llvm::Constant *Addr, llvm::Constant *ID,
+  int32_t Flags) {
   // If we are emitting code for a target, the entry is already initialized,
   // only has to be registered.
   if (CGM.getLangOpts().OpenMPIsDevice) {
@@ -2719,9 +2721,10 @@ void CGOpenMPRuntime::OffloadEntriesInfo
 assert(Entry.isValid() && "Entry not initialized!");
 Entry.setAddress(Addr);
 Entry.setID(ID);
+Entry.setFlags(Flags);
 return;
   } else {
-OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum++, Addr, ID);
+OffloadEntryInfoTargetRegion Entry(OffloadingEntriesNum++, Addr, ID, 
Flags);
 OffloadEntriesTargetRegion[DeviceID][FileID][ParentName][LineNum] = Entry;
   }
 }
@@ -2888,7 +2891,8 @@ CGOpenMPRuntime::createOffloadingBinaryD
 }
 
 void CGOpenMPRuntime::createOffloadEntry(llvm::Constant *ID,
- llvm::Constant *Addr, uint64_t Size) {
+ llvm::Constant *Addr, uint64_t Size,
+ int32_t Flags) {
   StringRef Name = Addr->getName();
   auto *TgtOffloadEntryType = cast(
   CGM.getTypes().ConvertTypeForMem(getTgtOffloadEntryQTy()));
@@ -2918,6 +2922,8 @@ void CGOpenMPRuntime::createOffloadEntry
   EntryInit.add(AddrPtr);
   EntryInit.add(StrPtr);
   EntryInit.addInt(CGM.SizeTy, Size);
+  EntryInit.addInt(CGM.Int32Ty, Flags);
+  EntryInit.addInt(CGM.Int32Ty, 0);
   llvm::GlobalVariable *Entry =
 EntryInit.finishAndCreateGlobal(".omp_offloading.entry",
 Align,
@@ -3090,6 +3096,8 @@ QualType CGOpenMPRuntime::getTgtOffloadE
   //  // (function or global)
   //   char  *name;   // Name of the function or global.
   //   size_t size;   // Size of the entry info (0 if it a function).
+  //   int32_tflags;  // Flags associated with the entry, e.g. 'link'.
+  //   int32_treserved;   // Reserved, to use by the runtime library.
   // };
   if (TgtOffloadEntryQTy.isNull()) {
 ASTContext  = CGM.getContext();
@@ -3098,6 +3106,10 @@ QualType CGOpenMPRuntime::getTgtOffloadE
 addFieldToRecordDecl(C, RD, C.VoidPtrTy);
 addFieldToRecordDecl(C, RD, C.getPointerType(C.CharTy));
 addFieldToRecordDecl(C, RD, C.getSizeType());
+addFieldToRecordDecl(
+C, RD, C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true));
+addFieldToRecordDecl(
+C, RD, C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/true));
 RD->completeDefinition();
 TgtOffloadEntryQTy = C.getRecordType(RD);
   }
@@ -4852,7 

r291123 - CodeGen: plumb header search down to the IAS

2017-01-05 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Jan  5 10:02:32 2017
New Revision: 291123

URL: http://llvm.org/viewvc/llvm-project?rev=291123=rev
Log:
CodeGen: plumb header search down to the IAS

inline assembly may use the `.include` directive to include other
content into the file.  Without the integrated assembler, the `-I` group
gets passed to the assembler.  Emulate this by collecting the header
search paths and passing them to the IAS.

Resolves PR24811!

Added:
cfe/trunk/test/CodeGen/include/
cfe/trunk/test/CodeGen/include/function.x
cfe/trunk/test/CodeGen/include/module.x
cfe/trunk/test/CodeGen/inline-asm-inclusion.c
Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=291123=291122=291123=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Thu Jan  5 10:02:32 2017
@@ -21,6 +21,7 @@ namespace llvm {
 
 namespace clang {
   class DiagnosticsEngine;
+  class HeaderSearchOptions;
   class CodeGenOptions;
   class TargetOptions;
   class LangOptions;
@@ -34,7 +35,8 @@ namespace clang {
 Backend_EmitObj///< Emit native object files
   };
 
-  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions 
,
+  void EmitBackendOutput(DiagnosticsEngine , const HeaderSearchOptions &,
+ const CodeGenOptions ,
  const TargetOptions , const LangOptions ,
  const llvm::DataLayout , llvm::Module *M,
  BackendAction Action,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=291123=291122=291123=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jan  5 10:02:32 2017
@@ -14,6 +14,7 @@
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/Utils.h"
+#include "clang/Lex/HeaderSearchOptions.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
@@ -32,6 +33,7 @@
 #include "llvm/IR/ModuleSummaryIndex.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/LTO/LTOBackend.h"
+#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Object/ModuleSummaryIndexObjectFile.h"
 #include "llvm/Passes/PassBuilder.h"
@@ -61,6 +63,7 @@ namespace {
 
 class EmitAssemblyHelper {
   DiagnosticsEngine 
+  const HeaderSearchOptions 
   const CodeGenOptions 
   const clang::TargetOptions 
   const LangOptions 
@@ -100,11 +103,14 @@ private:
  raw_pwrite_stream );
 
 public:
-  EmitAssemblyHelper(DiagnosticsEngine &_Diags, const CodeGenOptions ,
+  EmitAssemblyHelper(DiagnosticsEngine &_Diags,
+ const HeaderSearchOptions ,
+ const CodeGenOptions ,
  const clang::TargetOptions ,
  const LangOptions , Module *M)
-  : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
-TheModule(M), CodeGenerationTime("codegen", "Code Generation Time") {}
+  : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts),
+TargetOpts(TOpts), LangOpts(LOpts), TheModule(M),
+CodeGenerationTime("codegen", "Code Generation Time") {}
 
   ~EmitAssemblyHelper() {
 if (CodeGenOpts.DisableFree)
@@ -584,12 +590,18 @@ void EmitAssemblyHelper::CreateTargetMac
   Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
   Options.MCOptions.MCIncrementalLinkerCompatible =
   CodeGenOpts.IncrementalLinkerCompatible;
-  Options.MCOptions.MCPIECopyRelocations =
-  CodeGenOpts.PIECopyRelocations;
+  Options.MCOptions.MCPIECopyRelocations = CodeGenOpts.PIECopyRelocations;
   Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
   Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
   Options.MCOptions.ABIName = TargetOpts.ABI;
+  for (const auto  : HSOpts.UserEntries)
+if (!Entry.IsFramework &&
+(Entry.Group == frontend::IncludeDirGroup::Quoted ||
+ Entry.Group == frontend::IncludeDirGroup::Angled ||
+ Entry.Group == frontend::IncludeDirGroup::System))
+  Options.MCOptions.IASSearchPaths.push_back(
+  Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
 
   TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
   Options, 

[PATCH] D28304: [compiler-rt] [cmake] Disable appending -msse* flags implicitly

2017-01-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D28304#636669, @dvyukov wrote:

> User -march flag won't help as runtime is prebuilt.


I meant the flag used by the compiler vendor when compiler-rt is built.

> SCUDO is sse4.2, but tsan is sse3. Do you actually see any problems with 
> sse3? It's like 10 years old. I agree with you that strictly speaking we do 
> wrong thing for old processors.

Well, it seems that SSE3 is supported since Pentium 4 / newer versions of 
Athlon64. I don't see a big issue enabling it for x86-64 but for 32-bit systems 
you're ruling out quite a lot of hardware. My only pure x86-32 box (which I use 
to test stuff) does not support SSE3.

> But if we disable it, we disable it for everybody.  So if you don't hit 
> cashes with it, I would prefer to keep sse3 in tsan.

Well, I guess that depends on how you build compiler-rt. On Gentoo, we just 
pass user CFLAGS (I need to think more on that, tbh). I would rather see the 
compiler vendor deciding on which CPUs are to be supported by the compiler, 
rather than the build system silently bumping the minimum for one component.

That said, I think we need to work on improved portability of compiler runtimes 
shipped with clang. I will probably start an open discussion on that soonish. 
FWICS we pretty much 'officially' support building just one or two variants of 
compiler-rt for different ABIs of a single architecture. This doesn't scale 
well. While I'm not sure how significant the performance impact is but right 
now we either force compiler-rt to not use newer instructions (= make it 
slower) or randomly cause -march= not to be respected.


https://reviews.llvm.org/D28304



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


[PATCH] D28298: [OpenMP] Add fields for flags in the offload entry descriptor.

2017-01-05 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D28298



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


  1   2   >