r293466 - [c-index-test] CMake: add missing reference to clangSerialization library.

2017-01-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Jan 30 01:11:27 2017
New Revision: 293466

URL: http://llvm.org/viewvc/llvm-project?rev=293466&view=rev
Log:
[c-index-test] CMake: add missing reference to clangSerialization library.

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=293466&r1=293465&r2=293466&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Mon Jan 30 01:11:27 2017
@@ -27,6 +27,7 @@ else()
 clangCodeGen
 clangFrontend
 clangIndex
+clangSerialization
   )
 endif()
 


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


r293465 - clang-format: [JavaScript] Undo r291974 for JavaScript.

2017-01-29 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Jan 30 01:08:40 2017
New Revision: 293465

URL: http://llvm.org/viewvc/llvm-project?rev=293465&view=rev
Log:
clang-format: [JavaScript] Undo r291974 for JavaScript.

This had significant negative consequences and I don't have a good
solution for it yet.

Before:
  var string =
  [
'aa',
'bb',
  ]
  .join('+');

After:
  var string = [
'aa',
'bb',
  ].join('+');

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=293465&r1=293464&r2=293465&view=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jan 30 01:08:40 2017
@@ -199,7 +199,14 @@ bool ContinuationIndenter::mustBreak(con
 
   if (startsSegmentOfBuilderTypeCall(Current) &&
   (State.Stack.back().CallContinuation != 0 ||
-   State.Stack.back().BreakBeforeParameter))
+   State.Stack.back().BreakBeforeParameter) &&
+  // JavaScript is treated different here as there is a frequent pattern:
+  //   SomeFunction(function() {
+  // ...
+  //   }.bind(...));
+  // FIXME: We should find a more generic solution to this problem.
+  !(State.Column <= NewLineColumn &&
+Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
   if (State.Column <= NewLineColumn)

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=293465&r1=293464&r2=293465&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jan 30 01:08:40 2017
@@ -497,6 +497,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
"[];");
 
   verifyFormat("someFunction([], {a: a});");
+
+  verifyFormat("var string = [\n"
+   "  'aa',\n"
+   "  'bb',\n"
+   "].join('+');");
 }
 
 TEST_F(FormatTestJS, ColumnLayoutForArrayLiterals) {
@@ -587,6 +592,11 @@ TEST_F(FormatTestJS, FunctionLiterals) {
"  doSomething();\n"
"}, this));");
 
+  verifyFormat("SomeFunction(function() {\n"
+   "  foo();\n"
+   "  bar();\n"
+   "}.bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"


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


r293463 - [index] CMake: add missing reference to clangSerialization library.

2017-01-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Jan 30 00:48:27 2017
New Revision: 293463

URL: http://llvm.org/viewvc/llvm-project?rev=293463&view=rev
Log:
[index] CMake: add missing reference to clangSerialization library.

Modified:
cfe/trunk/lib/Index/CMakeLists.txt

Modified: cfe/trunk/lib/Index/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CMakeLists.txt?rev=293463&r1=293462&r2=293463&view=diff
==
--- cfe/trunk/lib/Index/CMakeLists.txt (original)
+++ cfe/trunk/lib/Index/CMakeLists.txt Mon Jan 30 00:48:27 2017
@@ -24,5 +24,6 @@ add_clang_library(clangIndex
   clangFormat
   clangFrontend
   clangRewrite
+  clangSerialization
   clangToolingCore
   )


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


r293462 - Reapply "DebugInfo: Omit class definitions even in the presence of available_externally vtables"

2017-01-29 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Jan 30 00:36:08 2017
New Revision: 293462

URL: http://llvm.org/viewvc/llvm-project?rev=293462&view=rev
Log:
Reapply "DebugInfo: Omit class definitions even in the presence of 
available_externally vtables"

Accounts for a case that caused an assertion failure by attempting to
query for the vtable linkage of a non-dynamic type.t

This reverts commit r292801.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-class-optzns.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGVTables.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=293462&r1=293461&r2=293462&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jan 30 00:36:08 2017
@@ -1714,7 +1714,27 @@ void CGDebugInfo::completeType(const Rec
 completeRequiredType(RD);
 }
 
+/// Return true if the class or any of its methods are marked dllimport.
+static bool isClassOrMethodDLLImport(const CXXRecordDecl *RD) {
+  if (RD->hasAttr())
+return true;
+  for (const CXXMethodDecl *MD : RD->methods())
+if (MD->hasAttr())
+  return true;
+  return false;
+}
+
 void CGDebugInfo::completeClassData(const RecordDecl *RD) {
+  if (auto *CXXRD = dyn_cast(RD))
+if (CXXRD->isDynamicClass() &&
+CGM.getVTableLinkage(CXXRD) ==
+llvm::GlobalValue::AvailableExternallyLinkage &&
+!isClassOrMethodDLLImport(CXXRD))
+  return;
+  completeClass(RD);
+}
+
+void CGDebugInfo::completeClass(const RecordDecl *RD) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
   QualType Ty = CGM.getContext().getRecordType(RD);
@@ -1760,16 +1780,6 @@ static bool isDefinedInClangModule(const
   return true;
 }
 
-/// Return true if the class or any of its methods are marked dllimport.
-static bool isClassOrMethodDLLImport(const CXXRecordDecl *RD) {
-  if (RD->hasAttr())
-return true;
-  for (const CXXMethodDecl *MD : RD->methods())
-if (MD->hasAttr())
-  return true;
-  return false;
-}
-
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
  bool DebugTypeExtRefs, const RecordDecl *RD,
  const LangOptions &LangOpts) {

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=293462&r1=293461&r2=293462&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jan 30 00:36:08 2017
@@ -409,6 +409,7 @@ public:
   void completeType(const RecordDecl *RD);
   void completeRequiredType(const RecordDecl *RD);
   void completeClassData(const RecordDecl *RD);
+  void completeClass(const RecordDecl *RD);
 
   void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD);
 

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=293462&r1=293461&r2=293462&view=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Mon Jan 30 00:36:08 2017
@@ -744,9 +744,10 @@ CodeGenModule::getVTableLinkage(const CX
 switch (keyFunction->getTemplateSpecializationKind()) {
   case TSK_Undeclared:
   case TSK_ExplicitSpecialization:
-assert((def || CodeGenOpts.OptimizationLevel > 0) &&
-   "Shouldn't query vtable linkage without key function or "
-   "optimizations");
+assert((def || CodeGenOpts.OptimizationLevel > 0 ||
+CodeGenOpts.getDebugInfo() != codegenoptions::NoDebugInfo) &&
+   "Shouldn't query vtable linkage without key function, "
+   "optimizations, or debug info");
 if (!def && CodeGenOpts.OptimizationLevel > 0)
   return llvm::GlobalVariable::AvailableExternallyLinkage;
 

Added: cfe/trunk/test/CodeGenCXX/debug-info-class-optzns.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-class-optzns.cpp?rev=293462&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-class-optzns.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-class-optzns.cpp Mon Jan 30 00:36:08 
2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm 
-debug-info-kind=limited %s -O1 -o - | FileCheck %s
+
+// Ensure class definitions are not emitted to debug info just because the
+// vtable is emitted for optimization purposes (as available_externally). The
+// class definition debug info should only go where the vtable is actually
+// emitt

r293461 - [c-index-test] Provide capability to index module file imports and dump their input files.

2017-01-29 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Mon Jan 30 00:05:58 2017
New Revision: 293461

URL: http://llvm.org/viewvc/llvm-project?rev=293461&view=rev
Log:
[c-index-test] Provide capability to index module file imports and dump their 
input files.

This ensures the capability to index a module file using an existing ASTReader 
from a compiler instance or ASTUnit.

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Index/IndexingAction.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Index/IndexingAction.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Index/Core/index-with-module.m
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=293461&r1=293460&r2=293461&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jan 30 00:05:58 2017
@@ -519,6 +519,8 @@ public:
 
   const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
 
+  IntrusiveRefCntPtr getASTReader() const;
+
   StringRef getOriginalSourceFileName() {
 return OriginalSourceFile;
   }

Modified: cfe/trunk/include/clang/Index/IndexingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexingAction.h?rev=293461&r1=293460&r2=293461&view=diff
==
--- cfe/trunk/include/clang/Index/IndexingAction.h (original)
+++ cfe/trunk/include/clang/Index/IndexingAction.h Mon Jan 30 00:05:58 2017
@@ -14,9 +14,14 @@
 #include 
 
 namespace clang {
+  class ASTReader;
   class ASTUnit;
   class FrontendAction;
 
+namespace serialization {
+  class ModuleFile;
+}
+
 namespace index {
   class IndexDataConsumer;
 
@@ -42,6 +47,11 @@ void indexASTUnit(ASTUnit &Unit,
   std::shared_ptr DataConsumer,
   IndexingOptions Opts);
 
+void indexModuleFile(serialization::ModuleFile &Mod,
+ ASTReader &Reader,
+ std::shared_ptr DataConsumer,
+ IndexingOptions Opts);
+
 } // namespace index
 } // namespace clang
 

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=293461&r1=293460&r2=293461&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Jan 30 00:05:58 2017
@@ -1270,6 +1270,7 @@ private:
   llvm::iterator_range
   getModulePreprocessedEntities(ModuleFile &Mod) const;
 
+public:
   class ModuleDeclIterator
   : public llvm::iterator_adaptor_base<
 ModuleDeclIterator, const serialization::LocalDeclID *,
@@ -1300,6 +1301,7 @@ private:
   llvm::iterator_range
   getModuleFileLevelDecls(ModuleFile &Mod);
 
+private:
   void PassInterestingDeclsToConsumer();
   void PassInterestingDeclToConsumer(Decl *D);
 
@@ -2192,6 +2194,12 @@ public:
   /// \brief Loads comments ranges.
   void ReadComments() override;
 
+  /// Visit all the input files of the given module file.
+  void visitInputFiles(serialization::ModuleFile &MF,
+   bool IncludeSystem, bool Complain,
+  llvm::function_ref Visitor);
+
   bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
 };
 

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=293461&r1=293460&r2=293461&view=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Mon Jan 30 00:05:58 2017
@@ -211,6 +211,10 @@ public:
   /// \brief The input files that have been loaded from this AST file.
   std::vector InputFilesLoaded;
 
+  // All user input files reside at the index range [0, NumUserInputFiles), and
+  // system input files reside at [NumUserInputFiles, InputFilesLoaded.size()).
+  unsigned NumUserInputFiles = 0;
+
   /// \brief If non-zero, specifies the time when we last validated input
   /// files.  Zero means we never validated them.
   ///

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=293461&r1=293460&r2=293461&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Jan 30 00:05:58 2017
@@ -619,6 +619,10 @@ void StoredDiagnosticConsumer::HandleDia
  

r293457 - Tidy up codegen modules test & make it x86 specific since it relies on Itanium name manglings

2017-01-29 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Sun Jan 29 23:33:51 2017
New Revision: 293457

URL: http://llvm.org/viewvc/llvm-project?rev=293457&view=rev
Log:
Tidy up codegen modules test & make it x86 specific since it relies on Itanium 
name manglings

Modified:
cfe/trunk/test/Modules/codegen.test

Modified: cfe/trunk/test/Modules/codegen.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/codegen.test?rev=293457&r1=293456&r2=293457&view=diff
==
--- cfe/trunk/test/Modules/codegen.test (original)
+++ cfe/trunk/test/Modules/codegen.test Sun Jan 29 23:33:51 2017
@@ -1,15 +1,16 @@
 RUN: rm -rf %t
+REQUIRES: x86-registered-target
 
-RUN: %clang_cc1 -fmodules-codegen -x c++ -fmodules -emit-module 
-fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
-RUN: %clang_cc1 -fmodules-codegen -x c++ -fmodules -emit-module 
-fmodule-name=bar %S/Inputs/codegen/bar.modulemap -o %t/bar.pcm 
-fmodule-file=%t/foo.pcm
+RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules 
-emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
+RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules 
-emit-module -fmodule-name=bar %S/Inputs/codegen/bar.modulemap -o %t/bar.pcm 
-fmodule-file=%t/foo.pcm
 
-RUN: %clang_cc1 -emit-llvm %t/foo.pcm -o - | FileCheck --check-prefix=FOO %s
-RUN: %clang_cc1 -emit-llvm %t/bar.pcm -o - -fmodule-file=%t/foo.pcm | 
FileCheck --check-prefix=BAR-CMN --check-prefix=BAR %s
-RUN: %clang_cc1 -fmodules -fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm 
%S/Inputs/codegen/use.cpp -emit-llvm -o - | FileCheck --check-prefix=USE-CMN 
--check-prefix=USE %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | 
FileCheck --check-prefix=FOO %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/bar.pcm 
-fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN --check-prefix=BAR 
%s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules 
-fmodule-file=%t/foo.pcm -fmodule-file=%t/bar.pcm %S/Inputs/codegen/use.cpp | 
FileCheck --check-prefix=USE-CMN --check-prefix=USE %s
 
-RUN: %clang_cc1 -O2 -disable-llvm-passes -emit-llvm %t/foo.pcm -o - | 
FileCheck --check-prefix=FOO %s
-RUN: %clang_cc1 -O2 -disable-llvm-passes -emit-llvm %t/bar.pcm -o - 
-fmodule-file=%t/foo.pcm | FileCheck --check-prefix=BAR-CMN 
--check-prefix=BAR-OPT %s
-RUN: %clang_cc1 -O2 -disable-llvm-passes -fmodules -fmodule-file=%t/foo.pcm 
-fmodule-file=%t/bar.pcm %S/Inputs/codegen/use.cpp -emit-llvm -o - | FileCheck 
--check-prefix=USE-CMN --check-prefix=USE-OPT %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 
-disable-llvm-passes %t/foo.pcm | FileCheck --check-prefix=FOO %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 
-disable-llvm-passes %t/bar.pcm -fmodule-file=%t/foo.pcm | FileCheck 
--check-prefix=BAR-CMN --check-prefix=BAR-OPT %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -O2 
-disable-llvm-passes -fmodules -fmodule-file=%t/foo.pcm 
-fmodule-file=%t/bar.pcm %S/Inputs/codegen/use.cpp | FileCheck 
--check-prefix=USE-CMN --check-prefix=USE-OPT %s
 
 FOO-NOT: comdat
 FOO: $_Z3foov = comdat any


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


Re: [PATCH] D28845: Prototype of modules codegen

2017-01-29 Thread David Blaikie via cfe-commits
On Sun, Jan 29, 2017 at 10:21 AM Richard Smith via Phabricator <
revi...@reviews.llvm.org> wrote:

> rsmith accepted this revision.
> rsmith added inline comments.
> This revision is now accepted and ready to land.
>
>
> 
> Comment at: lib/AST/ExternalASTSource.cpp:33
> +ExternalASTSource::hasExternalDefinitions(unsigned ID) {
> +  return EK_ReplyHazy;
> +}
> 
> dblaikie wrote:
> > rsmith wrote:
> > > You should add support for this function to
> `clang::MultiplexExternalSemaSource` too.
> > Done - though is there any test coverage I should add? Not sure exactly
> when/where/how this is used.
> >
> > Also only made a rough guess at what the right behavior is here. It
> could be a bit more obvious if I made "hasExternalDefinitions" return
> Optional - then when we find an ExternalASTSource that owns the ID
> (are the IDs unique across the MultiplexExternalSemaSource? I assume they
> have to be, but thought they'd only be valid within a single Module...
> guess I'm confused in a few ways - certainly haven't thought about it in
> great detail) we'd know to stop asking other sources. Probably not worth it
> unless there's a lot of sources?
> You could test this with `-chain-include`. I don't think there's any other
> in-tree way to get multiple external sources.
>

Ah - guess that doesn't make for very interesting testing, then - since I
wouldn't be able to make those external sources with interesting
differences in ExtDefs, I think? Happy to chat more if it's worth
testing/I've not understood how to exercise this.

- Dave


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


[PATCH] D28845: Prototype of modules codegen

2017-01-29 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dblaikie marked 2 inline comments as done.
Closed by commit rL293456: Prototype of modules codegen (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D28845?vs=86200&id=86239#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28845

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/ExternalASTSource.h
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Basic/Module.h
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/include/clang/Serialization/ASTWriter.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ExternalASTSource.cpp
  cfe/trunk/lib/Basic/Module.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Lex/ModuleMap.cpp
  cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/Modules/Inputs/codegen/bar.h
  cfe/trunk/test/Modules/Inputs/codegen/bar.modulemap
  cfe/trunk/test/Modules/Inputs/codegen/foo.h
  cfe/trunk/test/Modules/Inputs/codegen/foo.modulemap
  cfe/trunk/test/Modules/Inputs/codegen/use.cpp
  cfe/trunk/test/Modules/codegen.test

Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -432,6 +432,10 @@
   Flag<["-"], "fmodules-local-submodule-visibility">,
   HelpText<"Enforce name visibility rules across submodules of the same "
"top-level module.">;
+def fmodule_codegen :
+  Flag<["-"], "fmodules-codegen">,
+  HelpText<"Generate code for uses of this module that assumes an explicit "
+   "object file will be built for the module">;
 def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
   HelpText<"Select the container format for clang modules and PCH. "
"Supported options are 'raw' and 'obj'.">;
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -2494,7 +2494,7 @@
   ///
   /// \returns true if the function/var must be CodeGen'ed/deserialized even if
   /// it is not used.
-  bool DeclMustBeEmitted(const Decl *D);
+  bool DeclMustBeEmitted(const Decl *D, bool ForModularCodegen = false);
 
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);
Index: cfe/trunk/include/clang/AST/ExternalASTSource.h
===
--- cfe/trunk/include/clang/AST/ExternalASTSource.h
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h
@@ -16,6 +16,7 @@
 
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/Module.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
@@ -169,6 +170,10 @@
   /// Return a descriptor for the corresponding module, if one exists.
   virtual llvm::Optional getSourceDescriptor(unsigned ID);
 
+  enum ExtKind { EK_Always, EK_Never, EK_ReplyHazy };
+
+  virtual ExtKind hasExternalDefinitions(unsigned ID);
+
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
   ///
Index: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
===
--- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
+++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -90,6 +90,8 @@
   /// initializers themselves.
   CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override;
 
+  ExtKind hasExternalDefinitions(unsigned ID) override;
+
   /// \brief Find all declarations with the given name in the
   /// given context.
   bool FindExternalVisibleDeclsByName(const DeclContext *DC,
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -201,6 +201,7 @@
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(NewAlignOverride  , 32, 0, "maximum alignment guaranteed by '::operator new(size_t)'")
 LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
+BENIGN_LANGOPT(ModularCodegen , 1, 0, "Modular codegen")
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 

r293456 - Prototype of modules codegen

2017-01-29 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Sun Jan 29 23:00:26 2017
New Revision: 293456

URL: http://llvm.org/viewvc/llvm-project?rev=293456&view=rev
Log:
Prototype of modules codegen

First pass at generating weak definitions of inline functions from module files
(& skipping (-O0) or emitting available_externally (optimizations)
definitions where those modules are used).

External functions defined in modules are emitted into the modular
object file as well (this may turn an existing ODR violation (if that
module were imported into multiple translations) into valid/linkable
code).

Internal symbols (static functions, for example) are not correctly
supported yet. The symbol will be produced, internal, in the modular
object - unreferenceable from the users.

Reviewers: rsmith

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

Added:
cfe/trunk/test/Modules/Inputs/codegen/
cfe/trunk/test/Modules/Inputs/codegen/bar.h
cfe/trunk/test/Modules/Inputs/codegen/bar.modulemap
cfe/trunk/test/Modules/Inputs/codegen/foo.h
cfe/trunk/test/Modules/Inputs/codegen/foo.modulemap
cfe/trunk/test/Modules/Inputs/codegen/use.cpp
cfe/trunk/test/Modules/codegen.test
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExternalASTSource.cpp
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=293456&r1=293455&r2=293456&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sun Jan 29 23:00:26 2017
@@ -2494,7 +2494,7 @@ public:
   ///
   /// \returns true if the function/var must be CodeGen'ed/deserialized even if
   /// it is not used.
-  bool DeclMustBeEmitted(const Decl *D);
+  bool DeclMustBeEmitted(const Decl *D, bool ForModularCodegen = false);
 
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=293456&r1=293455&r2=293456&view=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Sun Jan 29 23:00:26 2017
@@ -16,6 +16,7 @@
 
 #include "clang/AST/CharUnits.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/Module.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
@@ -169,6 +170,10 @@ public:
   /// Return a descriptor for the corresponding module, if one exists.
   virtual llvm::Optional getSourceDescriptor(unsigned ID);
 
+  enum ExtKind { EK_Always, EK_Never, EK_ReplyHazy };
+
+  virtual ExtKind hasExternalDefinitions(unsigned ID);
+
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
   ///

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=293456&r1=293455&r2=293456&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Sun Jan 29 23:00:26 2017
@@ -201,6 +201,7 @@ LANGOPT(SizedDeallocation , 1, 0, "sized
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(NewAlignOverride  , 32, 0, "maximum alignment guaranteed by 
'::operator new(size_t)'")
 LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
+BENIGN_LANGOPT(ModularCodegen , 1, 0, "Modular codegen")
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
 BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd 
records")
 BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd 
records in a simple form")

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=293456&r1=293455&r2=293456&view=

r293455 - Towards P0091R3: parsing support for class template argument deduction in typename-specifiers.

2017-01-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan 29 22:38:28 2017
New Revision: 293455

URL: http://llvm.org/viewvc/llvm-project?rev=293455&view=rev
Log:
Towards P0091R3: parsing support for class template argument deduction in 
typename-specifiers.

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=293455&r1=293454&r2=293455&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Jan 29 22:38:28 2017
@@ -2946,6 +2946,16 @@ inline NamedDecl *getAsNamedDecl(Templat
   return P.get();
 }
 
+inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) {
+  auto *TD = dyn_cast(D);
+  return TD && (isa(TD) ||
+isa(TD) ||
+isa(TD) ||
+isa(TD))
+ ? TD
+ : nullptr;
+}
+
 } /* end of namespace clang */
 
 #endif

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=293455&r1=293454&r2=293455&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jan 29 22:38:28 
2017
@@ -1884,6 +1884,11 @@ def err_auto_not_allowed : Error<
   "|in conversion function type|here|in lambda parameter"
   "|in type allocated by 'new'|in K&R-style function parameter"
   "|in template parameter|in friend declaration}1">;
+def err_dependent_deduced_tst : Error<
+  "typename specifier refers to "
+  "%select{class template|function template|variable template|alias template|"
+  "template template parameter|template}0 member in %1; "
+  "argument deduction not allowed here">;
 def err_auto_not_allowed_var_inst : Error<
   "'auto' variable template instantiation is not allowed">;
 def err_auto_var_requires_init : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=293455&r1=293454&r2=293455&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sun Jan 29 22:38:28 2017
@@ -7359,7 +7359,8 @@ public:
 
   TypeSourceInfo *SubstType(TypeSourceInfo *T,
 const MultiLevelTemplateArgumentList &TemplateArgs,
-SourceLocation Loc, DeclarationName Entity);
+SourceLocation Loc, DeclarationName Entity,
+bool AllowDeducedTST = false);
 
   QualType SubstType(QualType T,
  const MultiLevelTemplateArgumentList &TemplateArgs,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=293455&r1=293454&r2=293455&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jan 29 22:38:28 2017
@@ -60,11 +60,6 @@ Sema::DeclGroupPtrTy Sema::ConvertDeclTo
   return DeclGroupPtrTy::make(DeclGroupRef(Ptr));
 }
 
-static bool isTypeTemplate(NamedDecl *ND) {
-  return isa(ND) || isa(ND) ||
- isa(ND);
-}
-
 namespace {
 
 class TypeNameValidatorCCC : public CorrectionCandidateCallback {
@@ -81,7 +76,7 @@ class TypeNameValidatorCCC : public Corr
   bool ValidateCandidate(const TypoCorrection &candidate) override {
 if (NamedDecl *ND = candidate.getCorrectionDecl()) {
   bool IsType = isa(ND) || isa(ND);
-  bool AllowedTemplate = AllowTemplates && isTypeTemplate(ND);
+  bool AllowedTemplate = AllowTemplates && getAsTypeTemplateDecl(ND);
   return (IsType || AllowedTemplate) &&
  (AllowInvalidDecl || !ND->isInvalidDecl());
 }
@@ -405,7 +400,7 @@ ParsedType Sema::getTypeName(const Ident
 for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end();
  Res != ResEnd; ++Res) {
   if (isa(*Res) || isa(*Res) ||
-  (AllowDeducedTemplate && isTypeTemplate(*Res))) {
+  (AllowDeducedTemplate && getAsTypeTemplateDecl(*Res))) {
 if (!IIDecl ||
 (*Res)->getLocation().getRawEncoding() <
   IIDecl->getLocation().getRawEncoding())
@@ -458,9 +453,10 @@ ParsedType Sema::getTypeName(const Ide

[libcxx] r293454 - experimental: remove some extraneous _LIBCPP_FUNC_VIS

2017-01-29 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Jan 29 21:58:26 2017
New Revision: 293454

URL: http://llvm.org/viewvc/llvm-project?rev=293454&view=rev
Log:
experimental: remove some extraneous _LIBCPP_FUNC_VIS

These member functions were decorated with `_LIBCPP_FUNC_VIS` when the
class is also decorated with external visibility.  This breaks down when
building for PE/COFF, where the member function cannot be decorated if
it is within a decorated class.  The class attribute will propagate to
the member.  Remove the extraneous decoration.

Modified:
libcxx/trunk/include/experimental/filesystem

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=293454&r1=293453&r2=293454&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Jan 29 21:58:26 2017
@@ -942,15 +942,15 @@ public:
 std::u32string generic_u32string() const { return string(); }
 
 private:
-_LIBCPP_FUNC_VIS int __compare(__string_view) const;
-_LIBCPP_FUNC_VIS __string_view __root_name() const;
-_LIBCPP_FUNC_VIS __string_view __root_directory() const;
-_LIBCPP_FUNC_VIS __string_view __root_path_raw() const;
-_LIBCPP_FUNC_VIS __string_view __relative_path() const;
-_LIBCPP_FUNC_VIS __string_view __parent_path() const;
-_LIBCPP_FUNC_VIS __string_view __filename() const;
-_LIBCPP_FUNC_VIS __string_view __stem() const;
-_LIBCPP_FUNC_VIS __string_view __extension() const;
+int __compare(__string_view) const;
+__string_view __root_name() const;
+__string_view __root_directory() const;
+__string_view __root_path_raw() const;
+__string_view __relative_path() const;
+__string_view __parent_path() const;
+__string_view __filename() const;
+__string_view __stem() const;
+__string_view __extension() const;
 
 public:
 // compare
@@ -988,8 +988,8 @@ public:
 class _LIBCPP_TYPE_VIS iterator;
 typedef iterator const_iterator;
 
-_LIBCPP_FUNC_VIS iterator begin() const;
-_LIBCPP_FUNC_VIS iterator end() const;
+iterator begin() const;
+iterator end() const;
 
 private:
 inline _LIBCPP_INLINE_VISIBILITY
@@ -1154,8 +1154,8 @@ private:
 inline _LIBCPP_INLINE_VISIBILITY
 friend bool operator==(const iterator&, const iterator&);
 
-_LIBCPP_FUNC_VIS iterator& __increment();
-_LIBCPP_FUNC_VIS iterator& __decrement();
+iterator& __increment();
+iterator& __decrement();
 
 path __stashed_elem_;
 const path* __path_ptr_;
@@ -1206,7 +1206,6 @@ public:
 return __paths_->second;
 }
 
-_LIBCPP_FUNC_VIS
 ~filesystem_error() override; // key function
 
 // TODO(ericwf): Create a custom error message.


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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-01-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:60
 
-The improvements are...
+Added a safety module for safety-critical checks like those from High 
Integrity C++.
+

Please take look on Release Notes format in previous releases branches (3.9 and 
40).



Comment at: clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst:9
+Inline assembler is forbidden by safety-critical C++ standards like High
+Intergrity C++ as it restricts the portability of code.

Link to particular standard will be helpful.


https://reviews.llvm.org/D29267



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


[libcxx] r293450 - experimental: inline single use of a typedef

2017-01-29 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Jan 29 18:15:50 2017
New Revision: 293450

URL: http://llvm.org/viewvc/llvm-project?rev=293450&view=rev
Log:
experimental: inline single use of a typedef

The typedef is not particularly long, and used in exactly one location.
Just spell it out at the site.  NFC.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=293450&r1=293449&r2=293450&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Sun Jan 29 
18:15:50 2017
@@ -24,10 +24,7 @@ inline bool set_or_throw(std::error_code
 return false;
 }
 
-typedef path::string_type string_type;
-
-
-inline string_type posix_readdir(DIR *dir_stream, error_code& ec) {
+inline path::string_type posix_readdir(DIR *dir_stream, error_code& ec) {
 struct dirent* dir_entry_ptr = nullptr;
 errno = 0; // zero errno in order to detect errors
 if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {


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


[libcxx] r293449 - experimental: tolerate the existence of a `__deref` macro

2017-01-29 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Jan 29 18:15:47 2017
New Revision: 293449

URL: http://llvm.org/viewvc/llvm-project?rev=293449&view=rev
Log:
experimental: tolerate the existence of a `__deref` macro

Microsoft's SAL has a `__deref` macro which results in a compilation
failure when building the filesystem module on Windows.  Rename the
member function internally to avoid the conflict.

Modified:
libcxx/trunk/include/experimental/filesystem
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/include/experimental/filesystem
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=293449&r1=293448&r2=293449&view=diff
==
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Sun Jan 29 18:15:47 2017
@@ -1924,7 +1924,7 @@ public:
 
 const directory_entry& operator*() const {
 _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced");
-return __deref();
+return __dereference();
 }
 
 const directory_entry* operator->() const
@@ -1949,11 +1949,14 @@ private:
 
 // construct the dir_stream
 _LIBCPP_FUNC_VIS
-directory_iterator(const path&, error_code *, directory_options = 
directory_options::none);
+directory_iterator(const path&, error_code *,
+   directory_options = directory_options::none);
+
 _LIBCPP_FUNC_VIS
 directory_iterator& __increment(error_code * __ec = nullptr);
+
 _LIBCPP_FUNC_VIS
-const directory_entry& __deref() const;
+const directory_entry& __dereference() const;
 
 private:
 shared_ptr<__dir_stream> __imp_;
@@ -2036,11 +2039,11 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 const directory_entry& operator*() const
-{ return __deref(); }
+{ return __dereference(); }
 
 _LIBCPP_INLINE_VISIBILITY
 const directory_entry* operator->() const
-{ return &__deref(); }
+{ return &__dereference(); }
 
 recursive_directory_iterator& operator++()
 { return __increment(); }
@@ -2079,7 +2082,7 @@ private:
  error_code *__ec);
 
 _LIBCPP_FUNC_VIS
-const directory_entry& __deref() const;
+const directory_entry& __dereference() const;
 
 _LIBCPP_FUNC_VIS
 bool __try_recursion(error_code* __ec);

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=293449&r1=293448&r2=293449&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Sun Jan 29 
18:15:47 2017
@@ -136,7 +136,7 @@ directory_iterator& directory_iterator::
 
 }
 
-directory_entry const& directory_iterator::__deref() const {
+directory_entry const& directory_iterator::__dereference() const {
 _LIBCPP_ASSERT(__imp_, "Attempting to dereference an invalid iterator");
 return __imp_->__entry_;
 }
@@ -182,7 +182,7 @@ int recursive_directory_iterator::depth(
 return __imp_->__stack_.size() - 1;
 }
 
-const directory_entry& recursive_directory_iterator::__deref() const {
+const directory_entry& recursive_directory_iterator::__dereference() const {
 return __imp_->__stack_.top().__entry_;
 }
 


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


[PATCH] D29267: [clang-tidy] safety-no-assembler

2017-01-29 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added a project: clang-tools-extra.
Herald added subscribers: JDevlieghere, mgorny.

Add a new clang-tidy module for safety-critical checks.

Include a check for inline assembler.


https://reviews.llvm.org/D29267

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.cpp
  clang-tools-extra/clang-tidy/safety/NoAssemblerCheck.h
  clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
  clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp

Index: clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/safety-no-assembler.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s safety-no-assembler %t
+
+void f() {
+  __asm("mov al, 2");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: '__asm("mov al, 2")' is an inline assembler statement [safety-no-assembler]
+}
+
Index: clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/safety-no-assembler.rst
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - safety-no-assembler
+
+safety-no-assembler
+===
+
+Check for assembler statements. No fix is offered.
+
+Inline assembler is forbidden by safety-critical C++ standards like High
+Intergrity C++ as it restricts the portability of code.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -152,3 +152,5 @@
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
+   safety-no-assembler
+   safety-no-vector-bool
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -57,7 +57,9 @@
 Improvements to clang-tidy
 --
 
-The improvements are...
+Added a safety module for safety-critical checks like those from High Integrity C++.
+
+Added safety-no-assembler check.
 
 Improvements to include-fixer
 -
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -475,6 +475,11 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
+// This anchor is used to force the linker to link the SafetyModule.
+extern volatile int SafetyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED SafetyModuleAnchorDestination =
+SafetyModuleAnchorSource;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -23,6 +23,7 @@
   clangTidyMPIModule
   clangTidyPerformanceModule
   clangTidyReadabilityModule
+  clangTidySafetyModule
   clangTooling
   )
 
Index: clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
@@ -0,0 +1,38 @@
+//===--- SafetyTidyModule.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "NoAssemblerCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+class SafetyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"safety-no-assembler");
+  }
+};
+
+// Register the SafetyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add
+X("safety-module", "Adds safety-critical checks.");
+
+} // namespace safety
+
+// This anchor is used to force the linker to link in the generated o

[PATCH] D27985: Add demangling support for C++11 thread_local variables

2017-01-29 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini accepted this revision.
mehdi_amini added a comment.
This revision is now accepted and ready to land.

LGTM.

Can you apply the patch in LLVM (libDemangle) as well please?


Repository:
  rL LLVM

https://reviews.llvm.org/D27985



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


[libcxx] r293445 - experimental: remove dead function

2017-01-29 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Jan 29 16:31:28 2017
New Revision: 293445

URL: http://llvm.org/viewvc/llvm-project?rev=293445&view=rev
Log:
experimental: remove dead function

This template was defined inline, within the TU only and had no uses
across the entire repository.  Remove the dead code.  NFC.

Modified:
libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=293445&r1=293444&r2=293445&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Sun Jan 29 
16:31:28 2017
@@ -12,19 +12,6 @@ inline error_code capture_errno() {
 }
 
 template 
-inline bool capture_error_or_throw(std::error_code* user_ec,
-   const char* msg, Args&&... args)
-{
-std::error_code my_ec = capture_errno();
-if (user_ec) {
-*user_ec = my_ec;
-return true;
-}
-__throw_filesystem_error(msg, std::forward(args)..., my_ec);
-return false;
-}
-
-template 
 inline bool set_or_throw(std::error_code& my_ec,
std::error_code* user_ec,
const char* msg, Args&&... args)


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


[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-29 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 86225.
jbcoe added a comment.

Minor changes in response to review comments.

Patch abandoned as approach taken cannot handle templates.


https://reviews.llvm.org/D29118

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/CMakeLists.txt
  clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp
  clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.h
  clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
  clang-tools-extra/clang-tidy/tool/CMakeLists.txt
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
  clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp

Index: clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/safety-no-vector-bool.cpp
@@ -0,0 +1,37 @@
+// RUN: %check_clang_tidy %s safety-no-vector-bool %t
+
+namespace std
+{
+  template  
+  class allocator {};
+
+  template >
+  class vector {};
+}
+
+std::vector v0;
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: variable 'v0' is an instance of std::vector [safety-no-vector-bool]
+
+std::vector vb();
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'vb' returns an instance of std::vector [safety-no-vector-bool]
+
+class C {
+  std::vector v_;
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member 'v_' is an instance of std::vector [safety-no-vector-bool]
+};
+
+typedef bool BoolTypedef;
+std::vector v1;
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: variable 'v1' is an instance of std::vector [safety-no-vector-bool]
+
+using vbool = std::vector;
+vbool v2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'v2' is an instance of std::vector [safety-no-vector-bool]
+
+std::vector v3;  
+
+template 
+class user_allocator {};
+
+std::vector> v4;  
+
Index: clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/safety-no-vector-bool.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - safety-no-vector-bool
+
+safety-no-vector-bool
+=
+
+``std::vector`` cannot be accessed safely concurrently in the same way as
+other ``std::vector`` specializations and is banned by some
+safefty-critical-c++ standards like High Integrity C++.
+
+This check finds instances of ``std::vector``. No fix is offered.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -152,3 +152,4 @@
readability-simplify-boolean-expr
readability-static-definition-in-anonymous-namespace
readability-uniqueptr-delete-release
+   safety-no-vector-bool
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -475,6 +475,11 @@
 static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination =
 ReadabilityModuleAnchorSource;
 
+// This anchor is used to force the linker to link the SafetyModule.
+extern volatile int SafetyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED SafetyModuleAnchorDestination =
+SafetyModuleAnchorSource;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/tool/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -23,6 +23,7 @@
   clangTidyMPIModule
   clangTidyPerformanceModule
   clangTidyReadabilityModule
+  clangTidySafetyModule
   clangTooling
   )
 
Index: clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/safety/SafetyTidyModule.cpp
@@ -0,0 +1,38 @@
+//===--- SafetyTidyModule.cpp - clang-tidy ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "NoVectorBoolCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace safety {
+
+class SafetyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"safety-no-vector-bool");
+  }
+};
+
+// Regis

[PATCH] D29118: [clang-tidy] safety-no-vector-bool

2017-01-29 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked 5 inline comments as done.
jbcoe added a comment.

Handling code like `std::pair, int>` is currently eluding me.

If I define `std::pair` to have members `first` and `second` then 
`std::pair, int>` triggers the `vector` diagnostic but 
in the template, not the instantiation point.

I need to match class definitions that have `vector` as a template 
argument and exclude them from later matchers. I can't see how to do this right 
now. I suspect some more sophisticated matchers or approaches are needed.




Comment at: clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp:50
+diag(MatchedDecl->getLocation(),
+ " function %0 returns an instance of std::vector")
+<< MatchedDecl;

JonasToth wrote:
> jbcoe wrote:
> > djehuti wrote:
> > > JonasToth wrote:
> > > > i think all those diag() calls can be merged into one. inside the 
> > > > if/else-if you can just set a StringRef with the specific part of the 
> > > > warning, and have a parameterized diag() at the end of the function.
> > > > 
> > > > in NoMallocCheck there is a similar pattern:
> > > > 
> > > >   const CallExpr *Call = nullptr;   
> > > >
> > > >   StringRef Recommendation; 
> > > >
> > > > 
> > > >
> > > >   if ((Call = Result.Nodes.getNodeAs("aquisition")))  
> > > >
> > > > Recommendation = "consider a container or a smart pointer"; 
> > > >
> > > >   else if ((Call = Result.Nodes.getNodeAs("realloc")))
> > > >
> > > > Recommendation = "consider std::vector or std::string"; 
> > > >
> > > >   else if ((Call = Result.Nodes.getNodeAs("free")))   
> > > >
> > > > Recommendation = "use RAII";
> > > >
> > > > 
> > > >
> > > >   assert(Call && "Unhandled binding in the Matcher");   
> > > >
> > > > 
> > > >
> > > >   diag(Call->getLocStart(), "do not manage memory manually; %0")
> > > >
> > > >   << Recommendation << SourceRange(Call->getLocStart(), 
> > > > Call->getLocEnd());
> > > > 
> > > Except with braces, right? (That's another High-Integrity C++ rule btw.)  
> > > ;)
> > I agree that this _can_ be done but I'm not convinced it helps readability. 
> > Repetition is partial and very localized. I'll happily make the change if 
> > you feel strongly that it's an improvement.
> i think either is ok. maybe someone else prefers one strongly over the other, 
> but i dont mind.
> 
> but i think the else path should exist, make an failing assert or sth like 
> that, for the safety ;)
Agreed on the else, especially as it agrees with the safety-critical standards 
we're checking.



Comment at: clang-tools-extra/clang-tidy/safety/NoVectorBoolCheck.cpp:50
+diag(MatchedDecl->getLocation(),
+ " function %0 returns an instance of std::vector")
+<< MatchedDecl;

jbcoe wrote:
> JonasToth wrote:
> > jbcoe wrote:
> > > djehuti wrote:
> > > > JonasToth wrote:
> > > > > i think all those diag() calls can be merged into one. inside the 
> > > > > if/else-if you can just set a StringRef with the specific part of the 
> > > > > warning, and have a parameterized diag() at the end of the function.
> > > > > 
> > > > > in NoMallocCheck there is a similar pattern:
> > > > > 
> > > > >   const CallExpr *Call = nullptr; 
> > > > >  
> > > > >   StringRef Recommendation;   
> > > > >  
> > > > >   
> > > > >  
> > > > >   if ((Call = Result.Nodes.getNodeAs("aquisition")))
> > > > >  
> > > > > Recommendation = "consider a container or a smart pointer";   
> > > > >  
> > > > >   else if ((Call = Result.Nodes.getNodeAs("realloc")))  
> > > > >  
> > > > > Recommendation = "consider std::vector or std::string";   
> > > > >  
> > > > >   else if ((Call = Result.Nodes.getNodeAs("free"))) 
> > > > >  
> > > > > Recommendation = "use RAII";  
> > > > >  
> > > > >   
> > > > >  
> > > > >   assert(Call && "Unhandled binding in the Matcher"); 
> > > > >  
> > > > >   
> > > > >  
> > > > >   diag(Call->getLocStart(), "do not manage memory manually; %0")  
> > > > >  
> > > 

[PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2017-01-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL293444: [OpenMP][NVPTX][CUDA] Adding support for printf for 
an NVPTX OpenMP device. (authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D17890?vs=49832&id=86222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D17890

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
  cfe/trunk/lib/CodeGen/CGGPUBuiltin.cpp
  cfe/trunk/lib/CodeGen/CMakeLists.txt
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c

Index: cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c
===
--- cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c
+++ cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c
@@ -0,0 +1,116 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+#include 
+
+// expected-no-diagnostics
+extern int printf(const char *, ...);
+extern int vprintf(const char *, va_list);
+
+// Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
+int CheckSimple() {
+// CHECK: define {{.*}}void [[T1:@__omp_offloading_.+CheckSimple.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T1]]()
+// Alloca in entry block.
+// CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
+
+// CHECK: {{call|invoke}} void [[T1]]_worker()
+// CHECK: br label {{%?}}[[EXIT:.+]]
+//
+// CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+// CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+// CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]],
+// CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label {{%?}}[[EXIT]]
+//
+// CHECK: [[MASTER]]
+// CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+// CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+// CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
+// CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
+
+// printf in master-only basic block.
+// CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
+const char* fmt = "%d %lld %f";
+// CHECK: [[PTR0:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 0
+// CHECK: store i32 1, i32* [[PTR0]], align 4
+// CHECK: [[PTR1:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 1
+// CHECK: store i64 2, i64* [[PTR1]], align 8
+// CHECK: [[PTR2:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 2
+
+// CHECK: store double 3.0{{[^,]*}}, double* [[PTR2]], align 8
+// CHECK: [[BUF_CAST:%[0-9]+]] = bitcast [[SIMPLE_PRINTF_TY]]* [[BUF]] to i8*
+// CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF_CAST]])
+printf(fmt, 1, 2ll, 3.0);
+  }
+
+  return 0;
+}
+
+void CheckNoArgs() {
+// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+CheckNoArgs.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T2]]()
+
+// CHECK: {{call|invoke}} void [[T2]]_worker()
+// CHECK: br label {{%?}}[[EXIT:.+]]
+//
+// CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+// CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+// CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]],
+// CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label {{%?}}[[EXIT]]
+//
+// CHECK: [[MASTER]]
+// CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+// CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+// CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
+// CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
+
+// printf in master-only basic block.
+// CHECK: call i32 @vprintf({{.*}}, i8* n

r293444 - [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2017-01-29 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Sun Jan 29 14:49:31 2017
New Revision: 293444

URL: http://llvm.org/viewvc/llvm-project?rev=293444&view=rev
Log:
[OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

Support for CUDA printf is exploited to support printf for
an NVPTX OpenMP device.

To reflect the support of both programming models, the file
CGCUDABuiltin.cpp has been renamed to CGGPUBuiltin.cpp, and
the call EmitCUDADevicePrintfCallExpr has been renamed to
EmitGPUDevicePrintfCallExpr.

Reviewers: jlebar
Differential Revision: https://reviews.llvm.org/D17890

Added:
cfe/trunk/lib/CodeGen/CGGPUBuiltin.cpp
  - copied, changed from r293443, cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
cfe/trunk/test/OpenMP/nvptx_target_printf_codegen.c
Removed:
cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=293444&r1=293443&r2=293444&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Jan 29 14:49:31 2017
@@ -2620,8 +2620,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 Arg));
   }
   case Builtin::BIprintf:
-if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
-  return EmitCUDADevicePrintfCallExpr(E, ReturnValue);
+if (getTarget().getTriple().isNVPTX())
+  return EmitNVPTXDevicePrintfCallExpr(E, ReturnValue);
 break;
   case Builtin::BI__builtin_canonicalize:
   case Builtin::BI__builtin_canonicalizef:

Removed: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp?rev=293443&view=auto
==
--- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (removed)
@@ -1,123 +0,0 @@
-//===- CGCUDABuiltin.cpp - Codegen for CUDA builtins 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// Generates code for built-in CUDA calls which are not runtime-specific.
-// (Runtime-specific codegen lives in CGCUDARuntime.)
-//
-//===--===//
-
-#include "CodeGenFunction.h"
-#include "clang/Basic/Builtins.h"
-#include "llvm/IR/DataLayout.h"
-#include "llvm/IR/Instruction.h"
-#include "llvm/Support/MathExtras.h"
-
-using namespace clang;
-using namespace CodeGen;
-
-static llvm::Function *GetVprintfDeclaration(llvm::Module &M) {
-  llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()),
-llvm::Type::getInt8PtrTy(M.getContext())};
-  llvm::FunctionType *VprintfFuncType = llvm::FunctionType::get(
-  llvm::Type::getInt32Ty(M.getContext()), ArgTypes, false);
-
-  if (auto* F = M.getFunction("vprintf")) {
-// Our CUDA system header declares vprintf with the right signature, so
-// nobody else should have been able to declare vprintf with a bogus
-// signature.
-assert(F->getFunctionType() == VprintfFuncType);
-return F;
-  }
-
-  // vprintf doesn't already exist; create a declaration and insert it into the
-  // module.
-  return llvm::Function::Create(
-  VprintfFuncType, llvm::GlobalVariable::ExternalLinkage, "vprintf", &M);
-}
-
-// Transforms a call to printf into a call to the NVPTX vprintf syscall (which
-// isn't particularly special; it's invoked just like a regular function).
-// vprintf takes two args: A format string, and a pointer to a buffer 
containing
-// the varargs.
-//
-// For example, the call
-//
-//   printf("format string", arg1, arg2, arg3);
-//
-// is converted into something resembling
-//
-//   struct Tmp {
-// Arg1 a1;
-// Arg2 a2;
-// Arg3 a3;
-//   };
-//   char* buf = alloca(sizeof(Tmp));
-//   *(Tmp*)buf = {a1, a2, a3};
-//   vprintf("format string", buf);
-//
-// buf is aligned to the max of {alignof(Arg1), ...}.  Furthermore, each of the
-// args is itself aligned to its preferred alignment.
-//
-// Note that by the time this function runs, E's args have already undergone 
the
-// standard C vararg promotion (short -> int, float -> double, etc.).
-RValue
-CodeGenFunction::EmitCUDADevicePrintfCallExpr(const CallExpr *E,
-  ReturnValueSlot ReturnValue) {
-  assert(getLangOpts().CUDA);
-  assert(getLangOpts().CUDAIsDevice);
-  assert(E->getBuiltinCallee() == Builtin::BIprintf);
-  assert(E->getNumArgs() >= 1); // printf always has at least one arg.
-
-  const llvm::DataLayout &D

Re: [libcxx] r293197 - Disable thread safety analysis for some functions in __thread_support

2017-01-29 Thread Dimitry Andric via cfe-commits
Thanks, merged in r293443.

-Dimitry

> On 29 Jan 2017, at 19:55, Eric Fiselier  wrote:
> 
> I'm OK with this.
> 
> On Sun, Jan 29, 2017 at 10:18 AM, Dimitry Andric  > wrote:
> I'd like to merge this to the release_40 branch.  Eric, you OK with that?
> 
> -Dimitry
> 
> > On 26 Jan 2017, at 19:37, Dimitry Andric via cfe-commits 
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >
> > Author: dim
> > Date: Thu Jan 26 12:37:18 2017
> > New Revision: 293197
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=293197&view=rev 
> > 
> > Log:
> > Disable thread safety analysis for some functions in __thread_support
> >
> > Many thread-related libc++ test cases fail on FreeBSD, due to the
> > following -Werror warnings:
> >
> >In file included from 
> > test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
> >In file included from include/thread:97:
> >In file included from include/__mutex_base:17:
> >include/__threading_support:222:1: error: mutex '__m' is still held at 
> > the end of function [-Werror,-Wthread-safety-analysis]
> >}
> >^
> >include/__threading_support:221:10: note: mutex acquired here
> >  return pthread_mutex_lock(__m);
> > ^
> >include/__threading_support:231:10: error: releasing mutex '__m' that 
> > was not held [-Werror,-Wthread-safety-analysis]
> >  return pthread_mutex_unlock(__m);
> > ^
> >include/__threading_support:242:1: error: mutex '__m' is still held at 
> > the end of function [-Werror,-Wthread-safety-analysis]
> >}
> >^
> >include/__threading_support:241:10: note: mutex acquired here
> >  return pthread_mutex_lock(__m);
> > ^
> >include/__threading_support:251:10: error: releasing mutex '__m' that 
> > was not held [-Werror,-Wthread-safety-analysis]
> >  return pthread_mutex_unlock(__m);
> > ^
> >include/__threading_support:272:10: error: calling function 
> > 'pthread_cond_wait' requires holding mutex '__m' exclusively 
> > [-Werror,-Wthread-safety-analysis]
> >  return pthread_cond_wait(__cv, __m);
> > ^
> >include/__threading_support:278:10: error: calling function 
> > 'pthread_cond_timedwait' requires holding mutex '__m' exclusively 
> > [-Werror,-Wthread-safety-analysis]
> >  return pthread_cond_timedwait(__cv, __m, __ts);
> > ^
> >6 errors generated.
> >
> > This is because on FreeBSD, the pthread functions have lock annotations.
> > Since the functions in __thread_support are internal to libc++ only, add
> > no_thread_safety_analysis attributes to suppress these warnings.
> >
> > Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
> > Reviewed By: aaron.ballman
> > Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
> > Differential Revision: https://reviews.llvm.org/D28520 
> > 
> >
> > Modified:
> >libcxx/trunk/include/__threading_support
> >
> > Modified: libcxx/trunk/include/__threading_support
> > URL: 
> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff
> >  
> > 
> > ==
> > --- libcxx/trunk/include/__threading_support (original)
> > +++ libcxx/trunk/include/__threading_support Thu Jan 26 12:37:18 2017
> > @@ -40,6 +40,12 @@
> > #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
> > #endif
> >
> > +#if defined(__FreeBSD__) && defined(__clang__) && 
> > __has_attribute(no_thread_safety_analysis)
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
> > __attribute__((no_thread_safety_analysis))
> > +#else
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > +#endif
> > +
> > _LIBCPP_BEGIN_NAMESPACE_STD
> >
> > #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> > @@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > 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
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_mutex_

[libcxx] r293443 - Merging r293197:

2017-01-29 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Sun Jan 29 14:30:51 2017
New Revision: 293443

URL: http://llvm.org/viewvc/llvm-project?rev=293443&view=rev
Log:
Merging r293197:

r293197 | dim | 2017-01-26 19:37:18 +0100 (Thu, 26 Jan 2017) | 43 lines

Disable thread safety analysis for some functions in __thread_support

Many thread-related libc++ test cases fail on FreeBSD, due to the
following -Werror warnings:

In file included from 
test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
In file included from include/thread:97:
In file included from include/__mutex_base:17:
include/__threading_support:222:1: error: mutex '__m' is still held at the 
end of function [-Werror,-Wthread-safety-analysis]
}
^
include/__threading_support:221:10: note: mutex acquired here
  return pthread_mutex_lock(__m);
 ^
include/__threading_support:231:10: error: releasing mutex '__m' that was 
not held [-Werror,-Wthread-safety-analysis]
  return pthread_mutex_unlock(__m);
 ^
include/__threading_support:242:1: error: mutex '__m' is still held at the 
end of function [-Werror,-Wthread-safety-analysis]
}
^
include/__threading_support:241:10: note: mutex acquired here
  return pthread_mutex_lock(__m);
 ^
include/__threading_support:251:10: error: releasing mutex '__m' that was 
not held [-Werror,-Wthread-safety-analysis]
  return pthread_mutex_unlock(__m);
 ^
include/__threading_support:272:10: error: calling function 
'pthread_cond_wait' requires holding mutex '__m' exclusively 
[-Werror,-Wthread-safety-analysis]
  return pthread_cond_wait(__cv, __m);
 ^
include/__threading_support:278:10: error: calling function 
'pthread_cond_timedwait' requires holding mutex '__m' exclusively 
[-Werror,-Wthread-safety-analysis]
  return pthread_cond_timedwait(__cv, __m, __ts);
 ^
6 errors generated.

This is because on FreeBSD, the pthread functions have lock annotations.
Since the functions in __thread_support are internal to libc++ only, add
no_thread_safety_analysis attributes to suppress these warnings.

Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
Differential Revision: https://reviews.llvm.org/D28520



Modified:
libcxx/branches/release_40/   (props changed)
libcxx/branches/release_40/include/__threading_support

Propchange: libcxx/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan 29 14:30:51 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:292013,292091,292607,292990,293154
+/libcxx/trunk:292013,292091,292607,292990,293154,293197

Modified: libcxx/branches/release_40/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_40/include/__threading_support?rev=293443&r1=293442&r2=293443&view=diff
==
--- libcxx/branches/release_40/include/__threading_support (original)
+++ libcxx/branches/release_40/include/__threading_support Sun Jan 29 14:30:51 
2017
@@ -40,6 +40,12 @@
 #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
 #endif
 
+#if defined(__FreeBSD__) && defined(__clang__) && 
__has_attribute(no_thread_safety_analysis)
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
__attribute__((no_thread_safety_analysis))
+#else
+#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
@@ -98,25 +104,25 @@ typedef DWORD __libcpp_tls_key;
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 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
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
 
-_LIBCPP_THREAD_ABI_VISIBILITY
+_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
 int __l

[PATCH] D16135: Macro Debug Info support in Clang

2017-01-29 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud added a comment.

Kindly reminder, I am still waiting for a review on this new patch.

Thanks


https://reviews.llvm.org/D16135



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


Re: [libcxx] r293197 - Disable thread safety analysis for some functions in __thread_support

2017-01-29 Thread Eric Fiselier via cfe-commits
I'm OK with this.

On Sun, Jan 29, 2017 at 10:18 AM, Dimitry Andric  wrote:

> I'd like to merge this to the release_40 branch.  Eric, you OK with that?
>
> -Dimitry
>
> > On 26 Jan 2017, at 19:37, Dimitry Andric via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: dim
> > Date: Thu Jan 26 12:37:18 2017
> > New Revision: 293197
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=293197&view=rev
> > Log:
> > Disable thread safety analysis for some functions in __thread_support
> >
> > Many thread-related libc++ test cases fail on FreeBSD, due to the
> > following -Werror warnings:
> >
> >In file included from test/std/thread/thread.
> threads/thread.thread.this/sleep_until.pass.cpp:17:
> >In file included from include/thread:97:
> >In file included from include/__mutex_base:17:
> >include/__threading_support:222:1: error: mutex '__m' is still held
> at the end of function [-Werror,-Wthread-safety-analysis]
> >}
> >^
> >include/__threading_support:221:10: note: mutex acquired here
> >  return pthread_mutex_lock(__m);
> > ^
> >include/__threading_support:231:10: error: releasing mutex '__m'
> that was not held [-Werror,-Wthread-safety-analysis]
> >  return pthread_mutex_unlock(__m);
> > ^
> >include/__threading_support:242:1: error: mutex '__m' is still held
> at the end of function [-Werror,-Wthread-safety-analysis]
> >}
> >^
> >include/__threading_support:241:10: note: mutex acquired here
> >  return pthread_mutex_lock(__m);
> > ^
> >include/__threading_support:251:10: error: releasing mutex '__m'
> that was not held [-Werror,-Wthread-safety-analysis]
> >  return pthread_mutex_unlock(__m);
> > ^
> >include/__threading_support:272:10: error: calling function
> 'pthread_cond_wait' requires holding mutex '__m' exclusively
> [-Werror,-Wthread-safety-analysis]
> >  return pthread_cond_wait(__cv, __m);
> > ^
> >include/__threading_support:278:10: error: calling function
> 'pthread_cond_timedwait' requires holding mutex '__m' exclusively
> [-Werror,-Wthread-safety-analysis]
> >  return pthread_cond_timedwait(__cv, __m, __ts);
> > ^
> >6 errors generated.
> >
> > This is because on FreeBSD, the pthread functions have lock annotations.
> > Since the functions in __thread_support are internal to libc++ only, add
> > no_thread_safety_analysis attributes to suppress these warnings.
> >
> > Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
> > Reviewed By: aaron.ballman
> > Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
> > Differential Revision: https://reviews.llvm.org/D28520
> >
> > Modified:
> >libcxx/trunk/include/__threading_support
> >
> > Modified: libcxx/trunk/include/__threading_support
> > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/_
> _threading_support?rev=293197&r1=293196&r2=293197&view=diff
> > 
> ==
> > --- libcxx/trunk/include/__threading_support (original)
> > +++ libcxx/trunk/include/__threading_support Thu Jan 26 12:37:18 2017
> > @@ -40,6 +40,12 @@
> > #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
> > #endif
> >
> > +#if defined(__FreeBSD__) && defined(__clang__) &&
> __has_attribute(no_thread_safety_analysis)
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_
> safety_analysis))
> > +#else
> > +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > +#endif
> > +
> > _LIBCPP_BEGIN_NAMESPACE_STD
> >
> > #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> > @@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > 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
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
> >
> > -_LIBCPP_THREAD_ABI_VISIBILITY
> > +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> > int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
> >
> > _LIBCPP_THREAD_ABI_VISIBILITY
> > @

[libcxx] r293439 - config: prevent the re-definition of a macro

2017-01-29 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Jan 29 12:16:33 2017
New Revision: 293439

URL: http://llvm.org/viewvc/llvm-project?rev=293439&view=rev
Log:
config: prevent the re-definition of a macro

This causes unnecessary warnings when building with `cl`.  Newer
versions of the C standard permit the redefinition of the macro to the
same value (which is the case here), unfortunately, `cl` does not yet
implement this.  Add a check to prevent the redefinition.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=293439&r1=293438&r2=293439&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Sun Jan 29 12:16:33 2017
@@ -12,8 +12,10 @@
 #define _LIBCPP_CONFIG
 
 #if defined(_MSC_VER) && !defined(__clang__)
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #endif
+#endif
 
 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #pragma GCC system_header


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


[PATCH] D28845: Prototype of modules codegen

2017-01-29 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/AST/ExternalASTSource.cpp:33
+ExternalASTSource::hasExternalDefinitions(unsigned ID) {
+  return EK_ReplyHazy;
+}

dblaikie wrote:
> rsmith wrote:
> > You should add support for this function to 
> > `clang::MultiplexExternalSemaSource` too.
> Done - though is there any test coverage I should add? Not sure exactly 
> when/where/how this is used.
> 
> Also only made a rough guess at what the right behavior is here. It could be 
> a bit more obvious if I made "hasExternalDefinitions" return 
> Optional - then when we find an ExternalASTSource that owns the ID 
> (are the IDs unique across the MultiplexExternalSemaSource? I assume they 
> have to be, but thought they'd only be valid within a single Module... guess 
> I'm confused in a few ways - certainly haven't thought about it in great 
> detail) we'd know to stop asking other sources. Probably not worth it unless 
> there's a lot of sources?
You could test this with `-chain-include`. I don't think there's any other 
in-tree way to get multiple external sources.


https://reviews.llvm.org/D28845



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


Re: [libcxx] r293197 - Disable thread safety analysis for some functions in __thread_support

2017-01-29 Thread Dimitry Andric via cfe-commits
I'd like to merge this to the release_40 branch.  Eric, you OK with that?

-Dimitry

> On 26 Jan 2017, at 19:37, Dimitry Andric via cfe-commits 
>  wrote:
> 
> Author: dim
> Date: Thu Jan 26 12:37:18 2017
> New Revision: 293197
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=293197&view=rev
> Log:
> Disable thread safety analysis for some functions in __thread_support
> 
> Many thread-related libc++ test cases fail on FreeBSD, due to the
> following -Werror warnings:
> 
>In file included from 
> test/std/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp:17:
>In file included from include/thread:97:
>In file included from include/__mutex_base:17:
>include/__threading_support:222:1: error: mutex '__m' is still held at the 
> end of function [-Werror,-Wthread-safety-analysis]
>}
>^
>include/__threading_support:221:10: note: mutex acquired here
>  return pthread_mutex_lock(__m);
> ^
>include/__threading_support:231:10: error: releasing mutex '__m' that was 
> not held [-Werror,-Wthread-safety-analysis]
>  return pthread_mutex_unlock(__m);
> ^
>include/__threading_support:242:1: error: mutex '__m' is still held at the 
> end of function [-Werror,-Wthread-safety-analysis]
>}
>^
>include/__threading_support:241:10: note: mutex acquired here
>  return pthread_mutex_lock(__m);
> ^
>include/__threading_support:251:10: error: releasing mutex '__m' that was 
> not held [-Werror,-Wthread-safety-analysis]
>  return pthread_mutex_unlock(__m);
> ^
>include/__threading_support:272:10: error: calling function 
> 'pthread_cond_wait' requires holding mutex '__m' exclusively 
> [-Werror,-Wthread-safety-analysis]
>  return pthread_cond_wait(__cv, __m);
> ^
>include/__threading_support:278:10: error: calling function 
> 'pthread_cond_timedwait' requires holding mutex '__m' exclusively 
> [-Werror,-Wthread-safety-analysis]
>  return pthread_cond_timedwait(__cv, __m, __ts);
> ^
>6 errors generated.
> 
> This is because on FreeBSD, the pthread functions have lock annotations.
> Since the functions in __thread_support are internal to libc++ only, add
> no_thread_safety_analysis attributes to suppress these warnings.
> 
> Reviewers: mclow.lists, EricWF, delesley, aaron.ballman
> Reviewed By: aaron.ballman
> Subscribers: ed, aaron.ballman, joerg, emaste, cfe-commits
> Differential Revision: https://reviews.llvm.org/D28520
> 
> Modified:
>libcxx/trunk/include/__threading_support
> 
> Modified: libcxx/trunk/include/__threading_support
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293197&r1=293196&r2=293197&view=diff
> ==
> --- libcxx/trunk/include/__threading_support (original)
> +++ libcxx/trunk/include/__threading_support Thu Jan 26 12:37:18 2017
> @@ -40,6 +40,12 @@
> #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
> #endif
> 
> +#if defined(__FreeBSD__) && defined(__clang__) && 
> __has_attribute(no_thread_safety_analysis)
> +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS 
> __attribute__((no_thread_safety_analysis))
> +#else
> +#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> +#endif
> +
> _LIBCPP_BEGIN_NAMESPACE_STD
> 
> #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
> @@ -102,25 +108,25 @@ typedef DWORD __libcpp_tls_key;
> _LIBCPP_THREAD_ABI_VISIBILITY
> int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> 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
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
> 
> _LIBCPP_THREAD_ABI_VISIBILITY
> @@ -133,10 +139,10 @@ int __libcpp_condvar_signal(__libcpp_con
> _LIBCPP_THREAD_ABI_VISIBILITY
> int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
> 
> -_LIBCPP_THREAD_ABI_VISIBILITY
> +_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
> int __libcpp_condvar_wait(__libcpp_con

[PATCH] D13289: [libc++] Provide additional templates for valarray transcendentals that satisfy the standard synopsis

2017-01-29 Thread Petr Pavlu via Phabricator via cfe-commits
petpav01 updated this revision to Diff 86217.
petpav01 added a comment.

Patch rebased.


https://reviews.llvm.org/D13289

Files:
  include/valarray
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
  
test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp

Index: test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
===
--- test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
+++ test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
@@ -34,19 +34,36 @@
 
 int main()
 {
+typedef double T;
+T a1[] = {-.9, -.5, 0., .5, .75};
+T a3[] = {-7.1629787019902447e-01,
+  -4.6211715726000974e-01,
+   0.e+00,
+   4.6211715726000974e-01,
+   6.3514895238728730e-01};
+const unsigned N = sizeof(a1)/sizeof(a1[0]);
 {
-typedef double T;
-T a1[] = {-.9, -.5, 0., .5, .75};
-T a3[] = {-7.1629787019902447e-01,
-  -4.6211715726000974e-01,
-   0.e+00,
-   4.6211715726000974e-01,
-   6.3514895238728730e-01};
-const unsigned N = sizeof(a1)/sizeof(a1[0]);
+// tanh(valarray&)
 std::valarray v1(a1, N);
 std::valarray v3 = tanh(v1);
 assert(v3.size() == v1.size());
 for (std::size_t i = 0; i < v3.size(); ++i)
 assert(is_about(v3[i], a3[i], 10));
 }
+{
+// tanh(__val_expr&)
+std::valarray v1(a1, N);
+std::valarray v3 = tanh(v1 + 0.0);
+assert(v3.size() == v1.size());
+for (int i = 0; i < v3.size(); ++i)
+assert(is_about(v3[i], a3[i], 10));
+}
+{
+// tanh()
+std::valarray v1(a1, N);
+std::valarray v3 = std::tanh(v1);
+assert(v3.size() == v1.size());
+for (int i = 0; i < v3.size(); ++i)
+assert(is_about(v3[i], a3[i], 10));
+}
 }
Index: test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
===
--- test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
+++ test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
@@ -34,19 +34,36 @@
 
 int main()
 {
+typedef double T;
+T a1[] = {-.9, -.5, 0., .5, .75};
+T a3[] = {-1.2601582175503390e+00,
+  -5.4630248984379048e-01,
+   0.e+00,
+   5.4630248984379048e-01,
+   9.3159645994407259e-01};
+const unsigned N = sizeof(a1)/sizeof(a1[0]);
 {
-typedef double T;
-T a1[] = {-.9, -.5, 0., .5, .75};
-T a3[] = {-1.2601582175503390e+00,
-  -5.4630248984379048e-01,
-   0.e+00,
-   5.4630248984379048e-01,
-   9.3159645994407259e-01};
-const unsigned N = sizeof(a1)/sizeof(a1[0]);
+// tan(valarray&)
 std::valarray v1(a1, N);
 std::valarray v3 = tan(v1);
 assert(v3

r293420 - [windows] [asan] Add linker flag when including "asan_dynamic_runtime_thunk".

2017-01-29 Thread Marcos Pividori via cfe-commits
Author: mpividori
Date: Sun Jan 29 00:03:05 2017
New Revision: 293420

URL: http://llvm.org/viewvc/llvm-project?rev=293420&view=rev
Log:
[windows] [asan] Add linker flag when including "asan_dynamic_runtime_thunk".

I modify clang driver for windows to include:
"-wholearchive:asan_dynamic_runtime_thunk", so all object files in the
static library: asan_dynamic_runtime_thunk are considered by the linker.
This is necessary, because some object files only include linker pragmas,
and doesn't resolve any symbol. If we don't include that flag, the
linker will ignore them, and won't read the linker pragmas.

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-link.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=293420&r1=293419&r2=293420&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Jan 29 00:03:05 2017
@@ -10990,6 +10990,10 @@ void visualstudio::Linker::ConstructJob(
   TC.getArch() == llvm::Triple::x86
   ? "-include:___asan_seh_interceptor"
   : "-include:__asan_seh_interceptor"));
+  // Make sure the linker consider all object files from the dynamic 
runtime
+  // thunk.
+  CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") +
+  TC.getCompilerRT(Args, "asan_dynamic_runtime_thunk")));
 } else if (DLL) {
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk"));
 } else {

Modified: cfe/trunk/test/Driver/cl-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-link.c?rev=293420&r1=293419&r2=293420&view=diff
==
--- cfe/trunk/test/Driver/cl-link.c (original)
+++ cfe/trunk/test/Driver/cl-link.c Sun Jan 29 00:03:05 2017
@@ -22,8 +22,9 @@
 // ASAN-MD: "-debug"
 // ASAN-MD: "-incremental:no"
 // ASAN-MD: "{{.*}}clang_rt.asan_dynamic-i386.lib"
-// ASAN-MD: "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
+// ASAN-MD: "{{[^"]*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
 // ASAN-MD: "-include:___asan_seh_interceptor"
+// ASAN-MD: "-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib"
 // ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
 
 // RUN: %clang_cl /LD -### /Tc%s 2>&1 | FileCheck --check-prefix=DLL %s


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


[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2017-01-29 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

My questions were answered. LGTM!


https://reviews.llvm.org/D27604



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