[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

mgorny wrote:
> Hahnfeld wrote:
> > pirama wrote:
> > > pirama wrote:
> > > > I feel this test is fragile.  Any idea how to further restrict and 
> > > > require that the default target triple has linux and one of i386, 
> > > > x86_64, arm, aarch64?
> > > > 
> > > > I could create sub-dirs for all archs returned by 
> > > > Triple::getArchTypeName (llvm/lib/Support/Triple.cpp) but it seems 
> > > > overkill.
> > > I've restricted the test to just x86_64-linux.
> > Instead of `REQUIRES`, you should probably add `-target 
> > x86_64-unknown-linux`
> Hmm, I don't see any good solution for this. Looking at the code, the host 
> triple is hardcoded, so you'd indeed have to either restrict the test to 
> triples matching LLVM_HOST_TRIPLE. Or maybe add a command-line option to 
> override the host triple.
Sorry, I missed that it's cross-compiling then. `x86_64` is in that case 
probably the best thing to do because it's most widespread, also among the 
buildbots.


https://reviews.llvm.org/D30015



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


[libcxx] r295428 - Use inline namespaces with GCC instead of __attribute__((__strong__)).

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 17 01:31:38 2017
New Revision: 295428

URL: http://llvm.org/viewvc/llvm-project?rev=295428=rev
Log:
Use inline namespaces with GCC instead of __attribute__((__strong__)).

GCC 7.0.1 started warning that __attribute__((__strong__)) is depricated.
This patch switches to using inline namespace with GCC instead. I believe
this wasn't done originally in order to support older GCC versions w/o
support for inline namespaces, or because earlier versions of GCC warned
users that the STL was using an inline namespace (even though it shouldn't 
affect users).

However I believe all of the above problems are gone for GCC 4.9 and greater.
Therefore switching to using inline namespaces instead of using __strong__
is the most correct behavior.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=295428=295427=295428=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Feb 17 01:31:38 2017
@@ -482,14 +482,13 @@ namespace std {
 
 #endif  // __GXX_EXPERIMENTAL_CXX0X__
 
-#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace 
_LIBCPP_NAMESPACE {
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace 
_LIBCPP_NAMESPACE {
 #define _LIBCPP_END_NAMESPACE_STD  } }
 #define _VSTD std::_LIBCPP_NAMESPACE
 
 namespace std {
-namespace _LIBCPP_NAMESPACE {
-}
-using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
+  inline namespace _LIBCPP_NAMESPACE {
+  }
 }
 
 #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)


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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

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

Thanks. The -L tests look good, -rpath is not perfect but I don't think you can 
improve it without additional changes to the Driver.




Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

Hahnfeld wrote:
> pirama wrote:
> > pirama wrote:
> > > I feel this test is fragile.  Any idea how to further restrict and 
> > > require that the default target triple has linux and one of i386, x86_64, 
> > > arm, aarch64?
> > > 
> > > I could create sub-dirs for all archs returned by Triple::getArchTypeName 
> > > (llvm/lib/Support/Triple.cpp) but it seems overkill.
> > I've restricted the test to just x86_64-linux.
> Instead of `REQUIRES`, you should probably add `-target x86_64-unknown-linux`
Hmm, I don't see any good solution for this. Looking at the code, the host 
triple is hardcoded, so you'd indeed have to either restrict the test to 
triples matching LLVM_HOST_TRIPLE. Or maybe add a command-line option to 
override the host triple.


https://reviews.llvm.org/D30015



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


r295427 - Revert r295421, new ODR checker for modules, to fix build bot.

2017-02-16 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 17 01:19:24 2017
New Revision: 295427

URL: http://llvm.org/viewvc/llvm-project?rev=295427=rev
Log:
Revert r295421, new ODR checker for modules, to fix build bot.

Removed:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295427=295426=295427=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Feb 17 01:19:24 2017
@@ -458,9 +458,6 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
-/// \brief A hash of parts of the class to help in ODR checking.
-unsigned ODRHash;
-
 /// \brief The number of base class specifiers in Bases.
 unsigned NumBases;
 
@@ -706,9 +703,6 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
-  void computeODRHash();
-  unsigned getODRHash() const { return data().ODRHash; }
-
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
 

Removed: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=295426=auto
==
--- cfe/trunk/include/clang/AST/ODRHash.h (original)
+++ cfe/trunk/include/clang/AST/ODRHash.h (removed)
@@ -1,82 +0,0 @@
-//===-- ODRHash.h - Hashing to diagnose ODR failures *- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-///
-/// \file
-/// This file contains the declaration of the ODRHash class, which calculates
-/// a hash based on AST nodes, which is stable across different runs.
-///
-//===--===//
-
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/TemplateBase.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang {
-
-class Decl;
-class IdentifierInfo;
-class NestedNameSpecifer;
-class Stmt;
-class TemplateParameterList;
-
-// ODRHash is used to calculate a hash based on AST node contents that
-// does not rely on pointer addresses.  This allows the hash to not vary
-// between runs and is usable to detect ODR problems in modules.  To use,
-// construct an ODRHash object, then call Add* methods over the nodes that
-// need to be hashed.  Then call CalculateHash to get the hash value.
-// Typically, only one Add* call is needed.  clear can be called to reuse the
-// object.
-class ODRHash {
-  // Use DenseMaps to convert between Decl and Type pointers and an index 
value.
-  llvm::DenseMap DeclMap;
-  llvm::DenseMap TypeMap;
-
-  // Save space by processing bools at the end.
-  llvm::SmallVector Bools;
-
-  llvm::FoldingSetNodeID ID;
-
-public:
-  ODRHash() {}
-
-  // Use this for ODR checking classes between modules.  This method compares
-  // more information than the AddDecl class.
-  void AddCXXRecordDecl(const CXXRecordDecl *Record);
-
-  // Process SubDecls of the main Decl.  This method calls the DeclVisitor
-  // while AddDecl does not.
-  void AddSubDecl(const Decl *D);
-
-  // Reset the object for reuse.
-  void clear();
-
-  // Add booleans to ID and uses it to calculate the hash.
-  unsigned CalculateHash();
-
-  // Add AST nodes that need to be processed.
-  void AddDecl(const Decl *D);
-  void AddType(const Type *T);
-  void AddQualType(QualType T);
-  void AddStmt(const Stmt *S);
-  void AddIdentifierInfo(const IdentifierInfo *II);
-  void AddNestedNameSpecifier(const NestedNameSpecifier *NNS);
-  void AddTemplateName(TemplateName Name);
-  void AddDeclarationName(DeclarationName Name);
-  void AddTemplateArgument(TemplateArgument TA);
-  void AddTemplateParameterList(const TemplateParameterList *TPL);
-
-  // Save booleans until the end to lower the size of data to process.
-  void AddBoolean(bool value);

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Please adapt the title and summary for the more general changes this has 
evolved to.




Comment at: lib/Driver/Tools.cpp:284
+// If we are not cross-compling, add '-rpath' with architecture-specific
+// library path so libraries lined from this path can be automatically
+// found.

s/lined/linked/



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

pirama wrote:
> pirama wrote:
> > I feel this test is fragile.  Any idea how to further restrict and require 
> > that the default target triple has linux and one of i386, x86_64, arm, 
> > aarch64?
> > 
> > I could create sub-dirs for all archs returned by Triple::getArchTypeName 
> > (llvm/lib/Support/Triple.cpp) but it seems overkill.
> I've restricted the test to just x86_64-linux.
Instead of `REQUIRES`, you should probably add `-target x86_64-unknown-linux`



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

Can you split that into two lines? Then it won't fail if there is some argument 
added in between


https://reviews.llvm.org/D30015



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


[libcxx] r295423 - Remove dead code in test

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 17 01:00:04 2017
New Revision: 295423

URL: http://llvm.org/viewvc/llvm-project?rev=295423=rev
Log:
Remove dead code in test

Modified:

libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp?rev=295423=295422=295423=diff
==
--- 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
 Fri Feb 17 01:00:04 2017
@@ -23,7 +23,6 @@
 #include 
 
 #include "test_macros.h"
-#include "test_allocator.h"
 #include "constexpr_char_traits.hpp"
 
 // Overloads
@@ -34,7 +33,6 @@
 // (4)  basic_string_view(const CharT*)
 int main()
 {
-  using TestSizeT = test_allocator::size_type;
   { // Testing (1)
 // Nothing TODO. Cannot deduce without any arguments.
   }


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


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88861.
EricWF marked an inline comment as done.
EricWF added a comment.

Address @majnemer's comments.


https://reviews.llvm.org/D30082

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-template-deduction-guide.cpp


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF marked an inline comment as done.
EricWF added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2479
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");

majnemer wrote:
> You are unconditionally dereferencing a dyn_cast, this seems bad. Is T 
> sometimes not a DeducedType or should the dyn_cast be a cast?
Woops that should have been a `cast` instead of a `dyn_cast`. `T` should always 
be `DeducedType` (See AstContext.cpp:1879 for an example use of 
`cast(...)` ).


https://reviews.llvm.org/D30082



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


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-16 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2479
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");

You are unconditionally dereferencing a dyn_cast, this seems bad. Is T 
sometimes not a DeducedType or should the dyn_cast be a cast?


https://reviews.llvm.org/D30082



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


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88859.
EricWF added a comment.

Remove unintentional changes.


https://reviews.llvm.org/D30082

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-template-deduction-guide.cpp


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;

2017-02-16 Thread Eric Fiselier via cfe-commits
I put my attempt to fix this up for review:

https://reviews.llvm.org/D30082

On Thu, Feb 16, 2017 at 10:17 PM, Eric Fiselier  wrote:

> Hi Richard,
>
> One more issue. When compiling with `-g` the following code hits a
> `llvm_unreachable` in CGDebugInfo::CreateTypeNode.
>
> template  struct S { S(T) {} };
> S s(42);
>
> /Eric
>
> On Thu, Feb 16, 2017 at 2:29 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Thu Feb 16 15:29:21 2017
>> New Revision: 295379
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295379=rev
>> Log:
>> Properly set up the DeclContext for parameters of implicit deduction
>> guides;
>> this is needed for deferred instantiation of default arguments.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaT
>> emplate.cpp?rev=295379=295378=295379=diff
>> 
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 16 15:29:21 2017
>> @@ -1677,6 +1677,9 @@ private:
>>   bool Explicit, TypeSourceInfo *TInfo,
>>   SourceLocation LocStart, SourceLocation
>> Loc,
>>   SourceLocation LocEnd) {
>> +ArrayRef Params =
>> +TInfo->getTypeLoc().castAs().getParams();
>> +
>>  // Build the implicit deduction guide template.
>>  auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart,
>> Loc,
>> DeductionGuideName,
>> TInfo->getType(),
>> @@ -1685,8 +1688,10 @@ private:
>>  if (Explicit)
>>Guide->setExplicitSpecified();
>>  Guide->setRangeEnd(LocEnd);
>> -Guide->setParams(
>> -TInfo->getTypeLoc().castAs().getParams());
>> +Guide->setParams(Params);
>> +
>> +for (auto *Param : Params)
>> +  Param->setDeclContext(Guide);
>>
>>  auto *GuideTemplate = FunctionTemplateDecl::Create(
>>  SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams,
>> Guide);
>>
>> Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deducti
>> on.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/
>> cxx1z-class-template-argument-deduction.cpp?rev=295379=
>> 295378=295379=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>> (original)
>> +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>> Thu Feb 16 15:29:21 2017
>> @@ -168,3 +168,11 @@ namespace nondeducible {
>> typename ...B>
>>X(float) -> X; // ok
>>  }
>> +
>> +namespace default_args_from_ctor {
>> +  template  struct S { S(A = 0) {} };
>> +  S s(0);
>> +
>> +  template  struct T { template T(A = 0, B = 0) {}
>> };
>> +  T t(0, 0);
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
Herald added a subscriber: aprantl.

Currently the following code hits an `llvm_unreachable` in 
`CGDebugInfo::CreateTypeNode`  because `DeducedTemplateSpecialization` isn't 
handled.

  // clang++ -std=c++1z -g test.cpp
  template  struct S { S(T) {} };
  S s(42);

This patch attempts to fix the handling of `DeducedTemplateSpecialization` as 
to correctly emit debug information. I've also attempted to write a test 
checking the emission of the debug information, but IDK if it's testing for the 
right output.


https://reviews.llvm.org/D30082

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-template-deduction-guide.cpp


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
@@ -2638,11 +2644,12 @@
   case Type::TemplateSpecialization:
 return CreateType(cast(Ty), Unit);
 
+  case Type::DeducedTemplateSpecialization:
+assert(isa(Ty));
   case Type::Auto:
   case Type::Attributed:
   case Type::Adjusted:
   case Type::Decayed:
-  case Type::DeducedTemplateSpecialization:
   case Type::Elaborated:
   case Type::Paren:
   case Type::SubstTemplateTypeParm:


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,6 +2475,12 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = dyn_cast(T)->getDeducedType();
+  assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
+  T = DT;
+  break;
+}
 case Type::Auto: {
   QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
@@ -2638,11 +2644,12 @@
   case Type::TemplateSpecialization:
 return CreateType(cast(Ty), Unit);
 
+  case Type::DeducedTemplateSpecialization:
+assert(isa(Ty));
   case Type::Auto:
   case Type::Attributed:
   case Type::Adjusted:
   case Type::Decayed:
-  case Type::DeducedTemplateSpecialization:
   case Type::Elaborated:
   case Type::Paren:
   case Type::SubstTemplateTypeParm:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295421 - Add better ODR checking for modules.

2017-02-16 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Thu Feb 16 23:54:30 2017
New Revision: 295421

URL: http://llvm.org/viewvc/llvm-project?rev=295421=rev
Log:
Add better ODR checking for modules.

A slightly weaker form of ODR checking than previous attempts, but hopefully
won't break the modules build bot.  Future work will be needed to catch all
cases.

When objects are imported for modules, there is a chance that a name collision
will cause an ODR violation.  Previously, only a small number of such
violations were detected.  This patch provides a stronger check based on
AST nodes.

The information needed to uniquely identify an object is taken from the AST and
put into a one-dimensional byte stream.  This stream is then hashed to give
a value to represent the object, which is stored with the other object data
in the module.

When modules are loaded, and Decl's are merged, the hash values of the two
Decl's are compared.  Only Decl's with matched hash values will be merged.
Mismatch hashes will generate a module error, and if possible, point to the
first difference between the two objects.

The transform from AST to byte stream is a modified depth first algorithm.
Due to references between some AST nodes, a pure depth first algorithm could
generate loops.  For Stmt nodes, a straight depth first processing occurs.
For Type and Decl nodes, they are replaced with an index number and only on
first visit will these nodes be processed.  As an optimization, boolean
values are saved and stored together in reverse order at the end of the
byte stream to lower the ammount of data that needs to be hashed.

Compile time impact was measured at 1.5-2.0% during module building, and
negligible during builds without module building.

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

Added:
cfe/trunk/include/clang/AST/ODRHash.h
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295421=295420=295421=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 16 23:54:30 2017
@@ -458,6 +458,9 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
+/// \brief A hash of parts of the class to help in ODR checking.
+unsigned ODRHash;
+
 /// \brief The number of base class specifiers in Bases.
 unsigned NumBases;
 
@@ -703,6 +706,9 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
+  void computeODRHash();
+  unsigned getODRHash() const { return data().ODRHash; }
+
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
 

Added: cfe/trunk/include/clang/AST/ODRHash.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ODRHash.h?rev=295421=auto
==
--- cfe/trunk/include/clang/AST/ODRHash.h (added)
+++ cfe/trunk/include/clang/AST/ODRHash.h Thu Feb 16 23:54:30 2017
@@ -0,0 +1,82 @@
+//===-- ODRHash.h - Hashing to diagnose ODR failures *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the declaration of the ODRHash class, which calculates
+/// a hash based on AST nodes, which is stable across different runs.
+///
+//===--===//
+
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TemplateBase.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class IdentifierInfo;
+class NestedNameSpecifer;
+class Stmt;
+class TemplateParameterList;
+
+// ODRHash is used to calculate a hash based on AST node contents that
+// does not rely on pointer addresses.  This allows the hash to not vary
+// between runs and is usable to detect ODR problems in modules.  To use,
+// construct an ODRHash object, then 

Re: r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;

2017-02-16 Thread Eric Fiselier via cfe-commits
Hi Richard,

One more issue. When compiling with `-g` the following code hits a
`llvm_unreachable` in CGDebugInfo::CreateTypeNode.

template  struct S { S(T) {} };
S s(42);

/Eric

On Thu, Feb 16, 2017 at 2:29 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Thu Feb 16 15:29:21 2017
> New Revision: 295379
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295379=rev
> Log:
> Properly set up the DeclContext for parameters of implicit deduction
> guides;
> this is needed for deferred instantiation of default arguments.
>
> Modified:
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaTemplate.cpp?rev=295379=295378=295379=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 16 15:29:21 2017
> @@ -1677,6 +1677,9 @@ private:
>   bool Explicit, TypeSourceInfo *TInfo,
>   SourceLocation LocStart, SourceLocation
> Loc,
>   SourceLocation LocEnd) {
> +ArrayRef Params =
> +TInfo->getTypeLoc().castAs().getParams();
> +
>  // Build the implicit deduction guide template.
>  auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart,
> Loc,
> DeductionGuideName,
> TInfo->getType(),
> @@ -1685,8 +1688,10 @@ private:
>  if (Explicit)
>Guide->setExplicitSpecified();
>  Guide->setRangeEnd(LocEnd);
> -Guide->setParams(
> -TInfo->getTypeLoc().castAs().getParams());
> +Guide->setParams(Params);
> +
> +for (auto *Param : Params)
> +  Param->setDeclContext(Guide);
>
>  auto *GuideTemplate = FunctionTemplateDecl::Create(
>  SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams,
> Guide);
>
> Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-
> deduction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=
> 295379=295378=295379=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
> (original)
> +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
> Thu Feb 16 15:29:21 2017
> @@ -168,3 +168,11 @@ namespace nondeducible {
> typename ...B>
>X(float) -> X; // ok
>  }
> +
> +namespace default_args_from_ctor {
> +  template  struct S { S(A = 0) {} };
> +  S s(0);
> +
> +  template  struct T { template T(A = 0, B = 0) {} };
> +  T t(0, 0);
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r295417 - Work around Clang assertion when testing C++17 deduction guides with '-g'.

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 23:04:09 2017
New Revision: 295417

URL: http://llvm.org/viewvc/llvm-project?rev=295417=rev
Log:
Work around Clang assertion when testing C++17  deduction guides with '-g'.

Modified:

libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp?rev=295417=295416=295417=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
 Thu Feb 16 23:04:09 2017
@@ -10,6 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-deduction-guides
 
+// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling this
+// test with '-g' (as the sanitizers do).
+// XFAIL: ubsan, asan, msan, tsan
+
 // 
 
 // Test that the constructors offered by std::basic_string are formulated


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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-16 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 88854.
smeenai added a comment.

Rebase


https://reviews.llvm.org/D29157

Files:
  include/__config
  include/locale
  include/string


Index: include/string
===
--- include/string
+++ include/string
@@ -792,6 +792,7 @@
 basic_string(const basic_string& __str, size_type __pos,
  const _Allocator& __a = _Allocator());
 template
+_LIBCPP_HIDDEN
 basic_string(const _Tp& __t, size_type __pos, size_type __n,
  const allocator_type& __a = allocator_type(),
  typename 
enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 
void>::type* = 0);
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -623,16 +623,19 @@
 ~num_get() {}
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_floating_point
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Fp& __v) const;
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_signed
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Signed& __v) const;
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_unsigned
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Unsigned& __v) const;
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -669,7 +669,7 @@
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && 
__has_attribute(__type_visibility__)
-#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ 
((__type_visibility__("default")))
+#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ 
((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  endif


Index: include/string
===
--- include/string
+++ include/string
@@ -792,6 +792,7 @@
 basic_string(const basic_string& __str, size_type __pos,
  const _Allocator& __a = _Allocator());
 template
+_LIBCPP_HIDDEN
 basic_string(const _Tp& __t, size_type __pos, size_type __n,
  const allocator_type& __a = allocator_type(),
  typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type* = 0);
Index: include/locale
===
--- include/locale
+++ include/locale
@@ -623,16 +623,19 @@
 ~num_get() {}
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_floating_point
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Fp& __v) const;
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_signed
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Signed& __v) const;
 
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_unsigned
 (iter_type __b, iter_type __e, ios_base& __iob,
  ios_base::iostate& __err, _Unsigned& __v) const;
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -669,7 +669,7 @@
 
 #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__type_visibility__("default")))
+#define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default")))
 #  else
 #define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
 #  endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-16 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Will do the rebase.




Comment at: include/locale:626
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_floating_point

EricWF wrote:
> After applying the changes to `__config` but not this header 
> `check-cxx-abilist` didn't report any changes to these symbols. Why is this 
> needed again?
It's to prevent https://llvm.org/bugs/show_bug.cgi?id=30642 from occurring 
again. If an extern template class is marked default visibility, and you have 
template methods of that class which get instantiated in other libraries, those 
template method instantiations also get marked default visibility, so now other 
libraries are exporting libc++ symbols. This change marks all such template 
methods as hidden to prevent the leakage.

That might not be the most clear explanation, so 
https://ghostbin.com/paste/29y9d demonstrates what I mean. (It's also the root 
cause of PR30642.)

https://reviews.llvm.org/D25208 addresses the same issue for non-template 
classes.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

EricWF wrote:
> Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` everywhere 
> else?
This function is really small, so I figured marking it for inlining was more 
appropriate.


https://reviews.llvm.org/D29157



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


r295416 - [index] Improvde how we handle synthesized ObjC properties and the associated ivars.

2017-02-16 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Thu Feb 16 22:49:41 2017
New Revision: 295416

URL: http://llvm.org/viewvc/llvm-project?rev=295416=rev
Log:
[index] Improvde how we handle synthesized ObjC properties and the associated 
ivars.

Related synthesized properties with the ivar they use with the 'accessor' 
relation, and make sure
we mark them 'implicit' when appropriate.

Patch by Nathan Hawes!
https://reviews.llvm.org/D30012

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-source.m
cfe/trunk/test/Index/Core/index-subkinds.m
cfe/trunk/test/Index/index-decls.m

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=295416=295415=295416=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu Feb 16 22:49:41 2017
@@ -98,7 +98,10 @@ public:
 if (MethodLoc.isInvalid())
   MethodLoc = D->getLocation();
 
-if (!IndexCtx.handleDecl(D, MethodLoc, (unsigned)SymbolRole::Dynamic, 
Relations))
+SymbolRoleSet Roles = (SymbolRoleSet)SymbolRole::Dynamic;
+if (D->isImplicit())
+  Roles |= (SymbolRoleSet)SymbolRole::Implicit;
+if (!IndexCtx.handleDecl(D, MethodLoc, Roles, Relations))
   return false;
 IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
 bool hasIBActionAndFirst = D->hasAttr();
@@ -178,14 +181,8 @@ public:
 
   bool VisitObjCIvarDecl(const ObjCIvarDecl *D) {
 if (D->getSynthesize()) {
-  // For synthesized ivars, use the location of the ObjC implementation,
-  // not the location of the property.
-  // Otherwise the header file containing the @interface will have 
different
-  // indexing contents based on whether the @implementation was present or
-  // not in the translation unit.
-  return IndexCtx.handleDecl(D,
- 
cast(D->getDeclContext())->getLocation(),
- (unsigned)SymbolRole::Implicit);
+  // handled in VisitObjCPropertyImplDecl
+  return true;
 }
 if (!IndexCtx.handleDecl(D))
   return false;
@@ -281,12 +278,16 @@ public:
 if (!IndexCtx.handleDecl(D))
   return false;
 
-// Index the ivars first to make sure the synthesized ivars are indexed
-// before indexing the methods that can reference them.
-for (const auto *IvarI : D->ivars())
-  IndexCtx.indexDecl(IvarI);
+// Visit implicit @synthesize property implementations first as their
+// location is reported at the name of the @implementation block. This
+// serves no purpose other than to simplify the FileCheck-based tests.
+for (const auto *I : D->property_impls()) {
+  if (I->getLocation().isInvalid())
+IndexCtx.indexDecl(I);
+}
 for (const auto *I : D->decls()) {
-  if (!isa(I))
+  if (!isa(I) ||
+  cast(I)->getLocation().isValid())
 IndexCtx.indexDecl(I);
 }
 
@@ -355,32 +356,58 @@ public:
 
   bool VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
 ObjCPropertyDecl *PD = D->getPropertyDecl();
-if (!IndexCtx.handleReference(PD, D->getLocation(),
- /*Parent=*/cast(D->getDeclContext()),
- D->getDeclContext(), SymbolRoleSet(), {},
- /*RefE=*/nullptr, D))
+auto *Container = cast(D->getDeclContext());
+SourceLocation Loc = D->getLocation();
+SymbolRoleSet Roles = 0;
+SmallVector Relations;
+
+if (ObjCIvarDecl *ID = D->getPropertyIvarDecl())
+  Relations.push_back({(SymbolRoleSet)SymbolRole::RelationAccessorOf, ID});
+if (Loc.isInvalid()) {
+  Loc = Container->getLocation();
+  Roles |= (SymbolRoleSet)SymbolRole::Implicit;
+}
+if (!IndexCtx.handleDecl(D, Loc, Roles, Relations))
   return false;
 
 if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
   return true;
-assert(D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize);
-
-if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) {
-  if (!IvarD->getSynthesize())
-IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
- D->getDeclContext(), SymbolRoleSet());
-}
 
-auto *ImplD = cast(D->getDeclContext());
+assert(D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize);
 if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) {
   if (MD->isPropertyAccessor() &&
-  !hasUserDefined(MD, ImplD))
-IndexCtx.handleDecl(MD, D->getLocation(), SymbolRoleSet(), {}, ImplD);
+  !hasUserDefined(MD, Container))
+IndexCtx.handleDecl(MD, Loc, SymbolRoleSet(SymbolRole::Implicit), {},
+Container);
 }
 if (ObjCMethodDecl *MD = 

[PATCH] D26316: [coroutines] Build and pass coroutine_handle to await_suspend.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88852.
EricWF added a comment.

- Update so that it merges with https://reviews.llvm.org/D26057


https://reviews.llvm.org/D26316

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaExprMember.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -16,41 +16,53 @@
   // expected-error@-1 {{use of undeclared identifier 'a'}}
 }
 
+void no_coroutine_traits() {
+  co_await 4; // expected-error {{need to include }}
+}
+
+namespace std {
+namespace experimental {
+template 
+struct coroutine_traits; // expected-note {{declared here}}
+
+template 
+struct coroutine_handle {
+  static coroutine_handle from_address(void *);
+};
+
+template <>
+struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle);
+  static coroutine_handle from_address(void *);
+};
+}} // namespace std::experimental
+
+template struct coro {};
+template 
+struct std::experimental::coroutine_traits {
+  using promise_type = Promise;
+};
+
 
 struct awaitable {
   bool await_ready();
-  void await_suspend(); // FIXME: coroutine_handle
+  void await_suspend(std::experimental::coroutine_handle<>);
   void await_resume();
 } a;
 
 struct suspend_always {
   bool await_ready() { return false; }
-  void await_suspend() {}
+  void await_suspend(std::experimental::coroutine_handle<>) {}
   void await_resume() {}
 };
 
 struct suspend_never {
   bool await_ready() { return true; }
-  void await_suspend() {}
+  void await_suspend(std::experimental::coroutine_handle<>) {}
   void await_resume() {}
 };
 
-void no_coroutine_traits() {
-  co_await a; // expected-error {{need to include }}
-}
-
-namespace std {
-namespace experimental {
-template 
-struct coroutine_traits; // expected-note {{declared here}}
-}
-}
-
-template struct coro {};
-template 
-struct std::experimental::coroutine_traits {
-  using promise_type = Promise;
-};
 
 void no_specialization() {
   co_await a; // expected-error {{implicit instantiation of undefined template 'std::experimental::coroutine_traits'}}
@@ -86,13 +98,6 @@
 struct std::experimental::coroutine_traits
 { using promise_type = promise_void; };
 
-namespace std {
-namespace experimental {
-template 
-struct coroutine_handle;
-}
-}
-
 // FIXME: This diagnostic is terrible.
 void undefined_promise() { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits::promise_type' (aka 'promise') is an incomplete type}}
   co_await a;
Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- test/CodeGenCoroutines/coro-alloc.cpp
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -4,12 +4,27 @@
 namespace experimental {
 template 
 struct coroutine_traits; // expected-note {{declared here}}
+
+template 
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) { return {}; }
+};
+
+template <>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template 
+  coroutine_handle(coroutine_handle) {}
+};
+
 }
 }
 
 struct suspend_always {
   bool await_ready() { return false; }
-  void await_suspend() {}
+  void await_suspend(std::experimental::coroutine_handle<>) {}
   void await_resume() {}
 };
 
Index: lib/Sema/SemaExprMember.cpp
===
--- lib/Sema/SemaExprMember.cpp
+++ lib/Sema/SemaExprMember.cpp
@@ -973,7 +973,7 @@
 
   // C++1z [expr.ref]p2:
   //   For the first option (dot) the first expression shall be a glvalue [...]
-  if (!IsArrow && BaseExpr->isRValue()) {
+  if (!IsArrow && BaseExpr && BaseExpr->isRValue()) {
 ExprResult Converted = TemporaryMaterializationConversion(BaseExpr);
 if (Converted.isInvalid())
   return ExprError();
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -116,6 +116,53 @@
   return PromiseType;
 }
 
+/// Look up the std::coroutine_traits<...>::promise_type for the given
+/// function type.
+static QualType lookupCoroutineHandleType(Sema , QualType PromiseType,
+  SourceLocation Loc) {
+  if (PromiseType.isNull())
+return QualType();
+
+  NamespaceDecl *StdExp = S.lookupStdExperimentalNamespace();
+  assert(StdExp && "Should already be diagnosed");
+
+  LookupResult Result(S, ().get("coroutine_handle"),
+  Loc, Sema::LookupOrdinaryName);
+  if (!S.LookupQualifiedName(Result, StdExp)) {
+S.Diag(Loc, diag::err_implied_std_coroutine_traits_not_found);
+return QualType();
+  }
+
+  ClassTemplateDecl 

[libcxxabi] r295411 - Fix test_exception_storage.pass.cpp in C++17 my re-enabling the unexpected handlers

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 22:26:22 2017
New Revision: 295411

URL: http://llvm.org/viewvc/llvm-project?rev=295411=rev
Log:
Fix test_exception_storage.pass.cpp in C++17 my re-enabling the unexpected 
handlers

Modified:
libcxxabi/trunk/test/test_exception_storage.pass.cpp

Modified: libcxxabi/trunk/test/test_exception_storage.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage.pass.cpp?rev=295411=295410=295411=diff
==
--- libcxxabi/trunk/test/test_exception_storage.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_storage.pass.cpp Thu Feb 16 22:26:22 
2017
@@ -7,6 +7,10 @@
 //
 
//===--===//
 
+// FIXME: cxa_exception.hpp directly references `std::unexpected` and friends.
+// This breaks this test when compiled in C++17. For now fix this by manually
+// re-enabling the STL functions.
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
 #include "../src/config.h"
 
 #include 


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


[PATCH] D29986: Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

2017-02-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

LGTM.


https://reviews.llvm.org/D29986



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


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

2017-02-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D24812#678931, @tigerleapgorge wrote:

> @rjmccall
>
> Hi John, I've made the changes to volatile.cpp.
>  I take it this patch is good for commit?


Yes, I think I have the information I wanted from Reid.  LGTM.


https://reviews.llvm.org/D24812



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


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

2017-02-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: test/CodeGenCXX/static-init.cpp:14
+// CHECK98: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global 
%"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK11: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global { i8** } 
{ i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN5test49HasVTableE, i32 0, inrange i32 0, i32 2) }, comdat, align 8
 

rnk wrote:
> rjmccall wrote:
> > Interesting.  It looks to me like the C++11 IR pattern is actually the only 
> > one that would've exposed the bug that Reid was fixing in r242704.  Reid, 
> > do you agree?
> I'm not sure I follow exactly, but I think what's going on here is that, in 
> C++11, the implicit default constructor is constexpr. I'm not sure how that 
> feeds into what type we choose to use for the global.
The global gets created using its formal type, and then we need to give it an 
initializer, which in some cases will have a different type, and so we need to 
replace the global with something with the right type.  Maybe that's not the 
type mismatch you were fixing in that revision?

Really I'm telling you to please go ahead and finish your 
eliminating-types-from-pointer work. :)


https://reviews.llvm.org/D24812



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


[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-16 Thread Ehsan Akhgari via Phabricator via cfe-commits
ehsan added a comment.

Gentle ping.  :-)


https://reviews.llvm.org/D29806



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


[PATCH] D30045: Remove `std::random_shuffle` in C++17

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@mclow.lists A couple of additional things:

- Add `_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE` to the 
`_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES` list in `__config`.
- Add a test for that in 
`test/libcxx/depr/enable_removed_cpp17_features.pass.cpp`




Comment at: include/algorithm:3029
 
+#if _LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
 class _LIBCPP_TYPE_VIS __rs_default;

EricWF wrote:
> We should still expose these when building the library using `|| 
> defined(_LIBCPP_BUILDING_LIBRARY)`.
This is specifically needed in this case because the definitions for symbols 
exist in the `dylib` and must be declared when compiling it.


https://reviews.llvm.org/D30045



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


[libcxx] r295407 - Add doc for _LIBCPP_ENABLE_CXX17_DISABLED_AUTO_PTR and make it work under _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 21:30:25 2017
New Revision: 295407

URL: http://llvm.org/viewvc/llvm-project?rev=295407=rev
Log:
Add doc for _LIBCPP_ENABLE_CXX17_DISABLED_AUTO_PTR and make it work under 
_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES

Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config
libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=295407=295406=295407=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Thu Feb 16 21:30:25 2017
@@ -188,5 +188,7 @@ C++17 Specific Configuration Macros
 
 **_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
   This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and
-  `unexpected` functions, which were removed in C++17. Unless this macro is
-  define those names will not be available in C++17.
+  `unexpected` functions, which were removed in C++17.
+
+**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
+  This macro is used to re-enable `std::auto_ptr` in C++17.

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=295407=295406=295407=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Feb 16 21:30:25 2017
@@ -1057,6 +1057,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
+# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
 # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 

Modified: libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp?rev=295407=295406=295407=diff
==
--- libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp Thu 
Feb 16 21:30:25 2017
@@ -18,5 +18,9 @@
 #error _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS must be defined
 #endif
 
+#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
+#error _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR must be defined
+#endif
+
 int main() {
 }


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


[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-16 Thread David Herzka via Phabricator via cfe-commits
herzka added a comment.

Currently, `A.customGetterProperty` would be turned into `[A 
customGetterProperty]`, which would fail to compile because that selector isn't 
declared anywhere. With my fix, it does compile because it (correctly) resolves 
to `[A customGet]`, which does exist. Similarly, `a.customSetterProperty = 1` 
got turned into `[a setCustomSetterProperty:1]` (another nonexistent selector), 
but now becomes `[a customSet:1]`.

Here are the errors I get when I run the test without my fix:

  error: 'error' diagnostics seen but not expected:
File 
/Users/herzka/dev/OSS/llvm/tools/clang/test/SemaObjC/objc-class-property.m Line 
45: no setter method 'setCustomSetterProperty:' for assignment to property
File 
/Users/herzka/dev/OSS/llvm/tools/clang/test/SemaObjC/objc-class-property.m Line 
46: no getter method for read from property
  2 errors generated.


https://reviews.llvm.org/D29967



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


[libcxx] r295406 - [libcxx] Remove unexpected handlers in C++17

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 21:25:08 2017
New Revision: 295406

URL: http://llvm.org/viewvc/llvm-project?rev=295406=rev
Log:
[libcxx] Remove unexpected handlers in C++17

Summary:
This patch implements 
[P0003R5](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0003r5.html) 
which removes exception specifications from C++17.

The only changes to the library are removing `set_unexpected`, 
`get_unexpected`, `unexpected`, and `unexpected_handler`. These functions can 
be re-enabled in C++17 using 
`_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS`.

@mclow.lists what do you think about removing stuff is this way?

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: mclow.lists, cfe-commits

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

Added:
libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp
libcxx/trunk/test/libcxx/depr/exception.unexpected/
libcxx/trunk/test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp
libcxx/trunk/test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp
libcxx/trunk/test/libcxx/depr/exception.unexpected/unexpected.pass.cpp

libcxx/trunk/test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config
libcxx/trunk/include/exception

libcxx/trunk/test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp

libcxx/trunk/test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp

libcxx/trunk/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp

libcxx/trunk/test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=295406=295405=295406=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Thu Feb 16 21:25:08 2017
@@ -180,3 +180,13 @@ thread safety annotations.
 * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
   const callable.
 
+C++17 Specific Configuration Macros
+---
+**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
+  This macro is used to re-enable all the features removed in C++17. The effect
+  is equivalent to manually defining each macro listed below.
+
+**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
+  This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and
+  `unexpected` functions, which were removed in C++17. Unless this macro is
+  define those names will not be available in C++17.

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=295406=295405=295406=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Feb 16 21:25:08 2017
@@ -1056,6 +1056,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_DECLSPEC_EMPTY_BASES
 #endif
 
+#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
+# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
+#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=295406=295405=295406=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Thu Feb 16 21:25:08 2017
@@ -112,10 +112,14 @@ public:
 };
 #endif // !_LIBCPP_ABI_MICROSOFT
 
+#if _LIBCPP_STD_VER <= 14 \
+|| defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \
+|| defined(_LIBCPP_BUILDING_LIBRARY)
 typedef void (*unexpected_handler)();
 _LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) 
_NOEXCEPT;
 _LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT;
 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected();
+#endif
 
 typedef void (*terminate_handler)();
 _LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT;

Added: libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp?rev=295406=auto
==
--- libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/depr/enable_removed_cpp17_features.pass.cpp Thu 
Feb 16 21:25:08 2017
@@ -0,0 +1,22 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual 

[PATCH] D28172: [libcxx] Remove unexpected handlers in C++17

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88843.
EricWF added a comment.

- Update so that it merges with master.

- add `_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES` macro for re-enabling all removed 
C++17 features.


https://reviews.llvm.org/D28172

Files:
  docs/UsingLibcxx.rst
  include/__config
  include/exception
  test/libcxx/depr/enable_removed_cpp17_features.pass.cpp
  test/libcxx/depr/exception.unexpected/get_unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/set_unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/unexpected.pass.cpp
  test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
  test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
  test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
  
test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
  test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -122,7 +122,7 @@
 	http://wg21.link/p0393r3;>p0393r3LWGMaking Variant Greater EqualOuluComplete4.0
 	http://wg21.link/P0394r4;>P0394r4LWGHotel Parallelifornia: terminate() for Parallel Algorithms Exception HandlingOulu
   	
-	http://wg21.link/P0003R5;>P0003R5LWGRemoving Deprecated Exception Specifications from C++17Issaquah
+	http://wg21.link/P0003R5;>P0003R5LWGRemoving Deprecated Exception Specifications from C++17IssaquahComplete5.0
 	http://wg21.link/P0067R5;>P0067R5LWGElementary string conversions, revision 5Issaquah
 	http://wg21.link/P0403R1;>P0403R1LWGLiteral suffixes for basic_string_viewIssaquahComplete4.0
 	http://wg21.link/P0414R2;>P0414R2LWGMerging shared_ptr changes from Library Fundamentals to C++17Issaquah
Index: test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/unexpected/unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: c++98 || c++03 || c++11 || c++14
+
 // test unexpected
 
 #include 
Index: test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
===
--- test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
+++ test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: c++98 || c++03 || c++11 || c++14
+
 // test unexpected_handler
 
 #include 
Index: test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: c++98 || c++03 || c++11 || c++14
+
 // test set_unexpected
 
 #include 
Index: test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
===
--- test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
+++ test/std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// REQUIRES: c++98 || c++03 || c++11 || c++14
+
 // test get_unexpected
 
 #include 
Index: test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
===
--- /dev/null
+++ test/libcxx/depr/exception.unexpected/unexpected_disabled_cpp17.fail.cpp
@@ -0,0 +1,23 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// test unexpected
+
+#include 
+
+void f() {}
+
+int main() {
+  using T = std::unexpected_handler; // expected-error {{no type named 'unexpected_handler' in namespace 'std'}}
+  std::unexpected(); // expected-error {{no member named 'unexpected' in namespace 'std'}}
+  std::get_unexpected(); // expected-error {{no member named 'get_unexpected' in namespace 'std'}}
+  std::set_unexpected(f); // expected-error {{no type named 'set_unexpected' in namespace 'std'}}
+}
Index: 

[PATCH] D30045: Remove `std::random_shuffle` in C++17

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM after fixing inline comments.




Comment at: include/algorithm:3029
 
+#if _LIBCPP_STD_VER <= 14 || 
defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
 class _LIBCPP_TYPE_VIS __rs_default;

We should still expose these when building the library using `|| 
defined(_LIBCPP_BUILDING_LIBRARY)`.



Comment at: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp:11
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 

`REQUIRES-ANY` got removed. This should be written:

```
// REQUIRES: c++98 || c++03 || c++11 || c++14
```



Comment at: 
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp:11
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 

`REQUIRES-ANY` got removed. This should be written:

```
// REQUIRES: c++98 || c++03 || c++11 || c++14
```


https://reviews.llvm.org/D30045



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


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/locale:626
 template 
+_LIBCPP_HIDDEN
 iter_type __do_get_floating_point

After applying the changes to `__config` but not this header 
`check-cxx-abilist` didn't report any changes to these symbols. Why is this 
needed again?


https://reviews.llvm.org/D29157



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


r295404 - Added doxygen comments to smmintrin.h's intrinsics.

2017-02-16 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Feb 16 20:49:50 2017
New Revision: 295404

URL: http://llvm.org/viewvc/llvm-project?rev=295404=rev
Log:
Added doxygen comments to smmintrin.h's intrinsics.

Note: The doxygen comments are automatically generated based on Sony's intrinsic
s document.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.



Modified:
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/smmintrin.h

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=295404=295403=295404=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Thu Feb 16 20:49:50 2017
@@ -2391,7 +2391,7 @@ _mm_mul_epu32(__m128i __a, __m128i __b)
 
 /// \brief Computes the absolute differences of corresponding 8-bit integer
 ///values in two 128-bit vectors. Sums the first 8 absolute differences, 
and
-///separately sums the second 8 absolute differences. Packss these two
+///separately sums the second 8 absolute differences. Packs these two
 ///unsigned 16-bit integer sums into the upper and lower elements of a
 ///[2 x i64] vector.
 ///

Modified: cfe/trunk/lib/Headers/smmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/smmintrin.h?rev=295404=295403=295404=diff
==
--- cfe/trunk/lib/Headers/smmintrin.h (original)
+++ cfe/trunk/lib/Headers/smmintrin.h Thu Feb 16 20:49:50 2017
@@ -46,37 +46,394 @@
 #define _MM_FROUND_RINT  (_MM_FROUND_RAISE_EXC | _MM_FROUND_CUR_DIRECTION)
 #define _MM_FROUND_NEARBYINT (_MM_FROUND_NO_EXC | _MM_FROUND_CUR_DIRECTION)
 
+/// \brief Rounds up each element of the 128-bit vector of [4 x float] to an
+///integer and returns the rounded values in a 128-bit vector of
+///[4 x float].
+///
+/// \headerfile 
+///
+/// \code
+/// __m128 _mm_ceil_ps(__m128 X);
+/// \endcode
+///
+/// This intrinsic corresponds to the   VROUNDPS / ROUNDPS  
+/// instruction.
+///
+/// \param X
+///A 128-bit vector of [4 x float] values to be rounded up.
+/// \returns A 128-bit vector of [4 x float] containing the rounded values.
 #define _mm_ceil_ps(X)   _mm_round_ps((X), _MM_FROUND_CEIL)
+
+/// \brief Rounds up each element of the 128-bit vector of [2 x double] to an
+///integer and returns the rounded values in a 128-bit vector of
+///[2 x double].
+///
+/// \headerfile 
+///
+/// \code
+/// __m128d _mm_ceil_pd(__m128d X);
+/// \endcode
+///
+/// This intrinsic corresponds to the   VROUNDPD / ROUNDPD  
+/// instruction.
+///
+/// \param X
+///A 128-bit vector of [2 x double] values to be rounded up.
+/// \returns A 128-bit vector of [2 x double] containing the rounded values.
 #define _mm_ceil_pd(X)   _mm_round_pd((X), _MM_FROUND_CEIL)
+
+/// \brief Copies three upper elements of the first 128-bit vector operand to
+///the corresponding three upper elements of the 128-bit result vector of
+///[4 x float]. Rounds up the lowest element of the second 128-bit vector
+///operand to an integer and copies it to the lowest element of the 128-bit
+///result vector of [4 x float].
+///
+/// \headerfile 
+///
+/// \code
+/// __m128 _mm_ceil_ss(__m128 X, __m128 Y);
+/// \endcode
+///
+/// This intrinsic corresponds to the   VROUNDSS / ROUNDSS  
+/// instruction.
+///
+/// \param X
+///A 128-bit vector of [4 x float]. The values stored in bits [127:32] are
+///copied to the corresponding bits of the result.
+/// \param Y
+///A 128-bit vector of [4 x float]. The value stored in bits [31:0] is
+///rounded up to the nearest integer and copied to the corresponding bits
+///of the result.
+/// \returns A 128-bit vector of [4 x float] containing the copied and rounded
+///values.
 #define _mm_ceil_ss(X, Y)_mm_round_ss((X), (Y), _MM_FROUND_CEIL)
+
+/// \brief Copies the upper element of the first 128-bit vector operand to the
+///corresponding upper element of the 128-bit result vector of [2 x 
double].
+///Rounds up the lower element of the second 128-bit vector operand to an
+///integer and copies it to the lower element of the 128-bit result vector
+///of [2 x double].
+///
+/// \headerfile 
+///
+/// \code
+/// __m128d _mm_ceil_sd(__m128d X, __m128d Y);
+/// \endcode
+///
+/// This intrinsic corresponds to the   VROUNDSD / ROUNDSD  
+/// instruction.
+///
+/// \param X
+///A 128-bit vector of [2 x double]. The value stored in bits [127:64] is
+///copied to the corresponding bits of the result.
+/// \param Y
+///A 128-bit vector of [2 x double]. The value stored in bits [63:0] is
+///rounded up to the nearest integer and copied to the corresponding bits
+///of the result.
+/// \returns A 128-bit vector of [2 x double] containing the copied and rounded
+///values.
 #define 

[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

I applied `inline` to most of the functions changed in `basic_string`, and 
updated the ABI lists accordingly.

Please update this patch so it merges with trunk. Note you can add 
`_LIBCPP_HIDDEN` to the functions in `basic_string` as well if you want, 
however the `inline`is enough to make them hidden in the dylib.


https://reviews.llvm.org/D29157



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


[libcxx] r295403 - Mark a couple for basic_string member templates as inline. no ABI change this time.

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 20:31:56 2017
New Revision: 295403

URL: http://llvm.org/viewvc/llvm-project?rev=295403=rev
Log:
Mark a couple for basic_string member templates as inline. no ABI change this 
time.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=295403=295402=295403=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Feb 16 20:31:56 2017
@@ -927,7 +927,7 @@ public:
 basic_string& append(__self_view __sv) { return append(__sv.data(), 
__sv.size()); }
 basic_string& append(const basic_string& __str, size_type __pos, size_type 
__n=npos);
 template 
-typename enable_if
+inline typename enable_if
 <
 __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
 basic_string&
@@ -939,7 +939,7 @@ public:
 template 
 inline basic_string& __append_forward_unsafe(_ForwardIterator, 
_ForwardIterator);
 template
-typename enable_if
+inline typename enable_if
 <
 __is_exactly_input_iterator<_InputIterator>::value
 || 
!__libcpp_string_gets_noexcept_iterator<_InputIterator>::value,
@@ -952,7 +952,7 @@ public:
   return *this;
 }
 template
-typename enable_if
+inline typename enable_if
 <
 __is_forward_iterator<_ForwardIterator>::value
 && 
__libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value,


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


[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I think Im misunderstanding something.  How does the test actually test what 
you are changing?


https://reviews.llvm.org/D29967



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


r295401 - Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-16 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Feb 16 20:03:51 2017
New Revision: 295401

URL: http://llvm.org/viewvc/llvm-project?rev=295401=rev
Log:
Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)

This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '>x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -
  | Setup  | # of null checks |
  -
  | unpatched, -O0 |21767 |
  | patched, -O0   |10758 |
  -

Changes since the initial commit: don't rely on IRGen of C labels in the
test.

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

Added:
cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295401=295400=295401=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb 16 20:03:51 2017
@@ -947,15 +947,45 @@ LValue CodeGenFunction::EmitUnsupportedL
 E->getType());
 }
 
+bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
+  if (isa(Obj))
+return true;
+
+  const Expr *Base = Obj;
+  while (!isa(Base)) {
+// The result of a dynamic_cast can be null.
+if (isa(Base))
+  return false;
+
+if (const auto *CE = dyn_cast(Base)) {
+  Base = CE->getSubExpr();
+} else if (const auto *PE = dyn_cast(Base)) {
+  Base = PE->getSubExpr();
+} else if (const auto *UO = dyn_cast(Base)) {
+  if (UO->getOpcode() == UO_Extension)
+Base = UO->getSubExpr();
+  else
+return false;
+} else {
+  return false;
+}
+  }
+  return true;
+}
+
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
   if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
-  if (!isa(E) && !LV.isBitField() && LV.isSimple())
+  if (!isa(E) && !LV.isBitField() && LV.isSimple()) {
+bool SkipNullCheck = false;
+if (const auto *ME = dyn_cast(E))
+  SkipNullCheck = CanElideObjectPointerNullCheck(ME->getBase());
 EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(),
-  E->getType(), LV.getAlignment());
+  E->getType(), LV.getAlignment(), SkipNullCheck);
+  }
   return LV;
 }
 
@@ -3335,7 +3365,9 @@ LValue CodeGenFunction::EmitMemberExpr(c
 AlignmentSource AlignSource;
 Address Addr = EmitPointerWithAlignment(BaseExpr, );
 QualType PtrTy = BaseExpr->getType()->getPointeeType();
-EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy);
+bool SkipNullCheck = CanElideObjectPointerNullCheck(BaseExpr);
+EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy,
+  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
 BaseLV = MakeAddrLValue(Addr, PtrTy, AlignSource);
   } else
 BaseLV = EmitCheckedLValue(BaseExpr, TCK_MemberAccess);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295401=295400=295401=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu Feb 16 20:03:51 2017
@@ -290,10 +290,15 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (CE)
 CallLoc = CE->getExprLoc();
 
-  EmitTypeCheck(isa(CalleeDecl)
-? CodeGenFunction::TCK_ConstructorCall
-: CodeGenFunction::TCK_MemberCall,
-CallLoc, This.getPointer(), 
C.getRecordType(CalleeDecl->getParent()));
+  bool SkipNullCheck = false;
+  if (const auto *CMCE = dyn_cast(CE))
+SkipNullCheck =
+

[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

aaron.ballman wrote:
> arphaman wrote:
> > aaron.ballman wrote:
> > > I have strong reservations about this -- users are going to have no idea 
> > > what attributes are and are not supported because they're not going to 
> > > know whether the attribute has a subject list or requires delayed 
> > > parsing. We have a considerable number of attributes for which the 
> > > Subjects line is currently commented out simply because no one has 
> > > bothered to fix that. This means those attributes can't be used with this 
> > > pragma until someone fixes that, but when it happens, they magically can 
> > > be used, which is a good thing. But the converse is more problematic -- 
> > > if there's an existing Subjects line that gets removed because a subject 
> > > is added that is difficult to express in TableGen it may break user code.
> > > 
> > > We can fix the discoverability issues somewhat by updating the 
> > > documentation emitter to spit out some wording that says when an 
> > > attribute is/is not supported by this feature, but that only works for 
> > > attributes which have documentation and so it's not a particularly 
> > > reliable workaround.
> > > I have strong reservations about this -- users are going to have no idea 
> > > what attributes are and are not supported because they're not going to 
> > > know whether the attribute has a subject list or requires delayed 
> > > parsing. We have a considerable number of attributes for which the 
> > > Subjects line is currently commented out simply because no one has 
> > > bothered to fix that. This means those attributes can't be used with this 
> > > pragma until someone fixes that, but when it happens, they magically can 
> > > be used, which is a good thing. But the converse is more problematic -- 
> > > if there's an existing Subjects line that gets removed because a subject 
> > > is added that is difficult to express in TableGen it may break user code.
> > 
> > That's a good point. I think we can address this problem by creating a test 
> > that verifies the list of attributes that support the pragma. This would 
> > allow us to ensure that no attributes loose the ability to use the pragma.
> > 
> > > We can fix the discoverability issues somewhat by updating the 
> > > documentation emitter to spit out some wording that says when an 
> > > attribute is/is not supported by this feature, but that only works for 
> > > attributes which have documentation and so it's not a particularly 
> > > reliable workaround.
> > 
> > We can enforce the rule that the attributes can only be used with '#pragma 
> > clang attribute' when they're documented. This way we can ensure that all 
> > attributes that can be used with the pragma are explicitly documented.
> > That's a good point. I think we can address this problem by creating a test 
> > that verifies the list of attributes that support the pragma. This would 
> > allow us to ensure that no attributes loose the ability to use the pragma.
> 
> That would be good.
> 
> > We can enforce the rule that the attributes can only be used with '#pragma 
> > clang attribute' when they're documented. This way we can ensure that all 
> > attributes that can be used with the pragma are explicitly documented.
> 
> This addresses the concern about discoverability, but it worsens the concerns 
> about fragility. The biggest problem is: the user has very little hope of 
> understanding what attributes will apply to what declarations with which 
> version of the compiler they're using. With this sort of thing, the act of us 
> adding documentation can impact the behavior of a user's program from one 
> release to the next.
> 
> While I can imagine this pragma reducing some amount of code clutter, it is 
> far too "magical" for me to feel comfortable with it (at least in the 
> proposed form). I cannot read the user's source code and understand what 
> attributes are going to be applied to which declarations, and that's not a 
> good story for usability of the feature.
What about the following idea:

The user has to include a **strict** set of declarations that receive the 
attribute explicitly, e.g.:

```
#pragma clang attribute push([[noreturn]], apply_to={ function })
``` 

The compiler then would verify that the set of declarations (in this case just 
`function`) is **strictly** identical to the built-in compiler-defined set of 
declarations that can receive the attribute (i.e. the strict set has to include 
all of the supported declarations). This will ensure that the user will know 
what declarations receive the attribute. If the compiler changes the set of 
allowed attributes in the future, 

[libcxx] r295399 - update revision in CHANGELOG.TXT and fix python error

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 19:56:57 2017
New Revision: 295399

URL: http://llvm.org/viewvc/llvm-project?rev=295399=rev
Log:
update revision in CHANGELOG.TXT and fix python error

Modified:
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/utils/libcxx/sym_check/extract.py

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=295399=295398=295399=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Thu Feb 16 19:56:57 2017
@@ -134,8 +134,8 @@ Version 4.0
   Symbol added: _ZTSSt12bad_any_cast
   Symbol added: _ZTVSt12bad_any_cast
 
-* rTBD - Remove basic_string::insert and basic_string::replace template methods
- which should be inline.
+* r295398 - Remove basic_string::insert and basic_string::replace template 
methods
+which should be inline.
 
   These functions should never have had visible definitions in the dylib but
   since they were previously not specified with 'inline' they accidentally

Modified: libcxx/trunk/utils/libcxx/sym_check/extract.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/sym_check/extract.py?rev=295399=295398=295399=diff
==
--- libcxx/trunk/utils/libcxx/sym_check/extract.py (original)
+++ libcxx/trunk/utils/libcxx/sym_check/extract.py Thu Feb 16 19:56:57 2017
@@ -49,7 +49,7 @@ class NMExtractor(object):
 parsed symbols.
 """
 cmd = [self.nm_exe] + self.flags + [lib]
-out, _, exit_code = util.executeCommandVerbose(cmd)
+out, _, exit_code = libcxx.util.executeCommandVerbose(cmd)
 if exit_code != 0:
 raise RuntimeError('Failed to run %s on %s' % (self.nm_exe, lib))
 fmt_syms = (self._extract_sym(l)


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


Re: [libcxx] r294116 - Remove CMake hack

2017-02-16 Thread Eric Fiselier via cfe-commits
Sorry about the breakage. I'm not sure what else to do.

The hack had been sitting there for more than a month IIRC.

Any advice for next time?

/Eric

On Thu, Feb 16, 2017 at 7:00 PM, Justin Bogner 
wrote:

> Eric Fiselier via cfe-commits  writes:
> > Author: ericwf
> > Date: Sat Feb  4 19:19:02 2017
> > New Revision: 294116
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=294116=rev
> > Log:
> > Remove CMake hack
>
> FWIW, I just spent half an hour trying to figure out why a tree I hadn't
> built in a bit wouldn't build anymore, because it had LIBCXX_CXX_ABI=""
> in its cache. There isn't really a general "safe" timeframe to remove
> cmake variable upgrade hacks.
>
> > Modified:
> > libcxx/trunk/CMakeLists.txt
> >
> > Modified: libcxx/trunk/CMakeLists.txt
> > URL:
> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/
> CMakeLists.txt?rev=294116=294115=294116=diff
> > 
> ==
> >
> > --- libcxx/trunk/CMakeLists.txt (original)
> > +++ libcxx/trunk/CMakeLists.txt Sat Feb  4 19:19:02 2017
> > @@ -107,15 +107,6 @@ set(LIBCXX_CXX_ABI "default" CACHE STRIN
> >  set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++
> vcruntime)
> >  set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
> >
> > -# FIXME: This is a temporary hack to force LLVM buildbots to store
> > -# the fixed cache entry instead of the previous cache entry. This is
> needed
> > -# because some LLVM buildbots don't clear their cache. It will be
> removed
> > -# once all LLVM bots have been run.
> > -if (LIBCXX_CXX_ABI STREQUAL "")
> > -  set(LIBCXX_CXX_ABI "default" CACHE STRING
> > -  "Specify the C++ ABI library to use." FORCE)
> > -endif()
> > -
> >  # Setup the default options if LIBCXX_CXX_ABI is not specified.
> >  if (LIBCXX_CXX_ABI STREQUAL "default")
> >find_path(
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r294116 - Remove CMake hack

2017-02-16 Thread Justin Bogner via cfe-commits
Eric Fiselier via cfe-commits  writes:
> Author: ericwf
> Date: Sat Feb  4 19:19:02 2017
> New Revision: 294116
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294116=rev
> Log:
> Remove CMake hack

FWIW, I just spent half an hour trying to figure out why a tree I hadn't
built in a bit wouldn't build anymore, because it had LIBCXX_CXX_ABI=""
in its cache. There isn't really a general "safe" timeframe to remove
cmake variable upgrade hacks.

> Modified:
> libcxx/trunk/CMakeLists.txt
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=294116=294115=294116=diff
> ==
>
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Sat Feb  4 19:19:02 2017
> @@ -107,15 +107,6 @@ set(LIBCXX_CXX_ABI "default" CACHE STRIN
>  set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
>  set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
>  
> -# FIXME: This is a temporary hack to force LLVM buildbots to store
> -# the fixed cache entry instead of the previous cache entry. This is needed
> -# because some LLVM buildbots don't clear their cache. It will be removed
> -# once all LLVM bots have been run.
> -if (LIBCXX_CXX_ABI STREQUAL "")
> -  set(LIBCXX_CXX_ABI "default" CACHE STRING
> -  "Specify the C++ ABI library to use." FORCE)
> -endif()
> -
>  # Setup the default options if LIBCXX_CXX_ABI is not specified.
>  if (LIBCXX_CXX_ABI STREQUAL "default")
>find_path(
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29157: [libc++] Make _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS export members

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/string:1100
 template
+inline _LIBCPP_INLINE_VISIBILITY
 typename enable_if

Why `inline _LIBCPP_INLINE_VISIBILITY` here but `_LIBCPP_HIDDEN` everywhere 
else?


https://reviews.llvm.org/D29157



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


r295396 - Revert "[ubsan] Reduce null checking of C++ object pointers (PR27581)"

2017-02-16 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Feb 16 19:42:36 2017
New Revision: 295396

URL: http://llvm.org/viewvc/llvm-project?rev=295396=rev
Log:
Revert "[ubsan] Reduce null checking of C++ object pointers (PR27581)"

This reverts commit r295391. It breaks this bot:

http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/1898

I need to not rely on labels in the IR test.

Removed:
cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295396=295395=295396=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb 16 19:42:36 2017
@@ -947,45 +947,15 @@ LValue CodeGenFunction::EmitUnsupportedL
 E->getType());
 }
 
-bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
-  if (isa(Obj))
-return true;
-
-  const Expr *Base = Obj;
-  while (!isa(Base)) {
-// The result of a dynamic_cast can be null.
-if (isa(Base))
-  return false;
-
-if (const auto *CE = dyn_cast(Base)) {
-  Base = CE->getSubExpr();
-} else if (const auto *PE = dyn_cast(Base)) {
-  Base = PE->getSubExpr();
-} else if (const auto *UO = dyn_cast(Base)) {
-  if (UO->getOpcode() == UO_Extension)
-Base = UO->getSubExpr();
-  else
-return false;
-} else {
-  return false;
-}
-  }
-  return true;
-}
-
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
   if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
-  if (!isa(E) && !LV.isBitField() && LV.isSimple()) {
-bool SkipNullCheck = false;
-if (const auto *ME = dyn_cast(E))
-  SkipNullCheck = CanElideObjectPointerNullCheck(ME->getBase());
+  if (!isa(E) && !LV.isBitField() && LV.isSimple())
 EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(),
-  E->getType(), LV.getAlignment(), SkipNullCheck);
-  }
+  E->getType(), LV.getAlignment());
   return LV;
 }
 
@@ -3365,9 +3335,7 @@ LValue CodeGenFunction::EmitMemberExpr(c
 AlignmentSource AlignSource;
 Address Addr = EmitPointerWithAlignment(BaseExpr, );
 QualType PtrTy = BaseExpr->getType()->getPointeeType();
-bool SkipNullCheck = CanElideObjectPointerNullCheck(BaseExpr);
-EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy,
-  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
+EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy);
 BaseLV = MakeAddrLValue(Addr, PtrTy, AlignSource);
   } else
 BaseLV = EmitCheckedLValue(BaseExpr, TCK_MemberAccess);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295396=295395=295396=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu Feb 16 19:42:36 2017
@@ -290,15 +290,10 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (CE)
 CallLoc = CE->getExprLoc();
 
-  bool SkipNullCheck = false;
-  if (const auto *CMCE = dyn_cast(CE))
-SkipNullCheck =
-CanElideObjectPointerNullCheck(CMCE->getImplicitObjectArgument());
-  EmitTypeCheck(
-  isa(CalleeDecl) ? 
CodeGenFunction::TCK_ConstructorCall
-  : CodeGenFunction::TCK_MemberCall,
-  CallLoc, This.getPointer(), C.getRecordType(CalleeDecl->getParent()),
-  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
+  EmitTypeCheck(isa(CalleeDecl)
+? CodeGenFunction::TCK_ConstructorCall
+: CodeGenFunction::TCK_MemberCall,
+CallLoc, This.getPointer(), 
C.getRecordType(CalleeDecl->getParent()));
 
   // FIXME: Uses of 'MD' past this point need to be audited. We may need to use
   // 'CalleeDecl' instead.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=295396=295395=295396=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Feb 16 19:42:36 2017
@@ -948,11 +948,6 @@ void CodeGenFunction::StartFunction(Glob
   // fast register allocator would be happier...
   CXXThisValue = CXXABIThisValue;
 }
-
-// Sanitize the 'this' pointer once per function, 

[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I really don't like this change (and https://reviews.llvm.org/D29757) because 
they start to include a ton of extra headers, and because they lift complex 
configuration logic into what should be a very simple header.
These functions are much better suited to being define out-of-line for a number 
of reasons.

Is there another way we can allow "external implementations" of these functions 
without lifting everything into a header?


https://reviews.llvm.org/D29818



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


[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

Same comment as https://reviews.llvm.org/D29818

I really don't like this change (and https://reviews.llvm.org/D29818) because 
they start to include a ton of extra headers, and because they lift complex 
configuration logic into what should be a very simple header.
These functions are much better suited to being define out-of-line for a number 
of reasons.

Is there another way we can allow "external implementations" of these functions 
without lifting everything into a header?


https://reviews.llvm.org/D29757



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


[PATCH] D30035: Add const to function parameters

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

This change is ABI breaking because these functions are exported using explicit 
template instantiations, and because changing their signature changes the 
mangling.

Can you explain why this change is needed?


https://reviews.llvm.org/D30035



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


[libcxx] r295393 - [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 19:17:10 2017
New Revision: 295393

URL: http://llvm.org/viewvc/llvm-project?rev=295393=rev
Log:
[libc++] Fix PR 31938 - std::basic_string constructors use non-deductible 
parameter types.

Summary:
This patch fixes http://llvm.org/PR31938. The description below is copy/pasted 
from the bug:

The standard says:

template,
 class Allocator = allocator>
class basic_string {
  using value_type = typename traits::char_type;
  // ...
  basic_string(const charT* s, const Allocator& a = Allocator());
};

libc++ actually chooses to declare the constructor as

  basic_string(const value_type* s, const Allocator& a = Allocator());

The implicit deduction guides from class template argument deduction make what 
was previously an implementation detail visible:

std::basic_string s = "foo"; // error, can't deduce charT.

The constructor in question is in the libc++ DSO, but fortunately it looks like 
fixing this will not result in an ABI break.


@rsmith How does this look? I did more than just the constructors mentioned in 
the PR, but IDK how far to take it.


Reviewers: mclow.lists, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rsmith

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

Added:

libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
Modified:
libcxx/trunk/include/string
libcxx/trunk/test/support/constexpr_char_traits.hpp
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=295393=295392=295393=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Feb 16 19:17:10 2017
@@ -775,30 +775,30 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 basic_string(basic_string&& __str, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-_LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s);
+_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(const value_type* __s, const allocator_type& __a);
+basic_string(const _CharT* __s, const _Allocator& __a);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(const value_type* __s, size_type __n);
+basic_string(const _CharT* __s, size_type __n);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(const value_type* __s, size_type __n, const allocator_type& 
__a);
+basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(size_type __n, value_type __c);
+basic_string(size_type __n, _CharT __c);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(size_type __n, value_type __c, const allocator_type& __a);
+basic_string(size_type __n, _CharT __c, const _Allocator& __a);
 basic_string(const basic_string& __str, size_type __pos, size_type __n,
- const allocator_type& __a = allocator_type());
+ const _Allocator& __a = _Allocator());
 _LIBCPP_INLINE_VISIBILITY
 basic_string(const basic_string& __str, size_type __pos,
- const allocator_type& __a = allocator_type());
+ const _Allocator& __a = _Allocator());
 template
-basic_string(const _Tp& __t, size_type __pos, size_type __n, 
+basic_string(const _Tp& __t, size_type __pos, size_type __n,
  const allocator_type& __a = allocator_type(),
  typename 
enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 
void>::type* = 0);
 _LIBCPP_INLINE_VISIBILITY explicit
 basic_string(__self_view __sv);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(__self_view __sv, const allocator_type& __a);
+basic_string(__self_view __sv, const _Allocator& __a);
 template
 _LIBCPP_INLINE_VISIBILITY
 basic_string(_InputIterator __first, _InputIterator __last);
@@ -807,9 +807,9 @@ public:
 basic_string(_InputIterator __first, _InputIterator __last, const 
allocator_type& __a);
 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 _LIBCPP_INLINE_VISIBILITY
-basic_string(initializer_list __il);
+basic_string(initializer_list<_CharT> __il);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(initializer_list __il, const allocator_type& __a);
+basic_string(initializer_list<_CharT> __il, const _Allocator& __a);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
 
 inline ~basic_string();
@@ -1557,7 +1557,7 @@ basic_string<_CharT, _Traits, _Allocator
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s)
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected 
nullptr");
 __init(__s, traits_type::length(__s));
@@ -1568,7 

[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:57
+  { // Testing (2)
+// FIXME: (2) doesn't work with implicit deduction.
+// const test_allocator alloc{};

rsmith wrote:
> I think that at least matches the standard as-is. I'm not sure this case is 
> worth adding an explicit deduction guide for. *shrug*
I agree this probably matches the standard as-is, and that it's probably not 
worth adding an explicit guide for.
In general I don't think libc++ should add *any* explicit guides until the are 
required by the standard.

I'll remove the FIXME and clarify the comment before committing.




Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:107
+  { // Testing (5) w/o allocator
+#if 0 // FIXME: This doesn't work
+const std::string sin("abc");

rsmith wrote:
> Do you know why not?
Yeah. It seems to choose the `basic_string(size_type, CharT, const Allocator&)` 
overload after deducing `CharT` and `Allocator` to be `unsigned long`.

The compiler diagnostics produced are:
```
/home/eric/workspace/libcxx/include/memory:1494:22: error: type 
'allocator_type' (aka 'unsigned long') cannot be used prior to '::' because it 
has no members
typedef typename allocator_type::value_type value_type;
 ^
/home/eric/workspace/libcxx/include/string:788:28: note: in instantiation of 
template class 'std::__1::allocator_traits' requested here
basic_string(size_type __n, _CharT __c, const _Allocator& __a);
   ^
/home/eric/workspace/libcxx/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:111:23:
 note: while substituting deduced template arguments into function template 
'' [with _CharT = unsigned long, _Traits = 
(no value), _Allocator = unsigned long]
std::basic_string s(sin, (size_t)1, (size_t)3);
 ```



Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:291
+  { // Testing (15)
+// FIXME: This overload is broken. Fix it and add tests.
+  }

rsmith wrote:
> I think the inability to deduce using this overload matches the standard. I 
> don't think there's any way in general to map the type `T` to a `charT`.
OK. I'll update the comment before committing. 


https://reviews.llvm.org/D29863



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295391: [ubsan] Reduce null checking of C++ object pointers 
(PR27581) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D29530?vs=88259=88808#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29530

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/catch-undef-behavior.c
  cfe/trunk/test/CodeGen/sanitize-recover.c
  cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp

Index: cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
===
--- cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null -DCHECK_LAMBDA | FileCheck %s --check-prefix=LAMBDA
+
+struct A {
+  int foo;
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
+  void do_nothing() {
+// CHECK: icmp ne %struct.A* %[[THIS1:[a-z0-9]+]], null, !nosanitize
+// CHECK: ptrtoint %struct.A* %[[THIS1]] to i64, !nosanitize
+// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+// CHECK: ret void
+  }
+
+#ifdef CHECK_LAMBDA
+  // LAMBDA-LABEL: define linkonce_odr void @_ZN1A22do_nothing_with_lambdaEv
+  void do_nothing_with_lambda() {
+// LAMBDA: icmp ne %struct.A* %[[THIS2:[a-z0-9]+]], null, !nosanitize
+// LAMBDA: ptrtoint %struct.A* %[[THIS2]] to i64, !nosanitize
+// LAMBDA-NEXT: call void @__ubsan_handle_type_mismatch
+
+auto f = [&] {
+  foo = 0;
+};
+f();
+
+// LAMBDA: ret void
+  }
+
+// Check the IR for the lambda:
+//
+// LAMBDA-LABEL: define linkonce_odr void @_ZZN1A22do_nothing_with_lambdaEvENKUlvE_clEv
+// LAMBDA: call void @__ubsan_handle_type_mismatch
+// LAMBDA-NOT: call void @__ubsan_handle_type_mismatch
+// LAMBDA: ret void
+#endif
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
+  int load_member() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L1
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L1:
+return foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
+  int call_method() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L2
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L2:
+return load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
+  void assign_member_1() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L3
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L3:
+foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_2Ev
+  void assign_member_2() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L4
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L4:
+(__extension__ (this))->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZNK1A15assign_member_3Ev
+  void assign_member_3() const {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L5
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L5:
+const_cast(this)->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A22call_through_referenceERS_
+  static int call_through_reference(A ) {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return a.load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A20call_through_pointerEPS_
+  static int call_through_pointer(A *a) {
+// CHECK: call void @__ubsan_handle_type_mismatch
+return a->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct B {
+  operator A*() const { return nullptr; }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEv
+  static int load_member() {
+// Null-check  before converting it to an A*.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// Null-check the result of the conversion before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+B b;
+return static_cast(b)->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct Base {
+  int foo;
+
+  virtual int load_member_1() = 0;
+};
+
+struct Derived : public Base {
+  int bar;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_2Ev
+  int load_member_2() {
+// CHECK: call void 

r295391 - [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-16 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Feb 16 19:05:42 2017
New Revision: 295391

URL: http://llvm.org/viewvc/llvm-project?rev=295391=rev
Log:
[ubsan] Reduce null checking of C++ object pointers (PR27581)

This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '>x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang and check-ubsan. I also compiled X86FastISel.cpp
with -fsanitize=null using patched/unpatched clangs based on r293572.
Here are the number of null checks emitted:

  -
  | Setup  | # of null checks |
  -
  | unpatched, -O0 |21767 |
  | patched, -O0   |10758 |
  -

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

Added:
cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295391=295390=295391=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Feb 16 19:05:42 2017
@@ -947,15 +947,45 @@ LValue CodeGenFunction::EmitUnsupportedL
 E->getType());
 }
 
+bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
+  if (isa(Obj))
+return true;
+
+  const Expr *Base = Obj;
+  while (!isa(Base)) {
+// The result of a dynamic_cast can be null.
+if (isa(Base))
+  return false;
+
+if (const auto *CE = dyn_cast(Base)) {
+  Base = CE->getSubExpr();
+} else if (const auto *PE = dyn_cast(Base)) {
+  Base = PE->getSubExpr();
+} else if (const auto *UO = dyn_cast(Base)) {
+  if (UO->getOpcode() == UO_Extension)
+Base = UO->getSubExpr();
+  else
+return false;
+} else {
+  return false;
+}
+  }
+  return true;
+}
+
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
   if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
-  if (!isa(E) && !LV.isBitField() && LV.isSimple())
+  if (!isa(E) && !LV.isBitField() && LV.isSimple()) {
+bool SkipNullCheck = false;
+if (const auto *ME = dyn_cast(E))
+  SkipNullCheck = CanElideObjectPointerNullCheck(ME->getBase());
 EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(),
-  E->getType(), LV.getAlignment());
+  E->getType(), LV.getAlignment(), SkipNullCheck);
+  }
   return LV;
 }
 
@@ -3335,7 +3365,9 @@ LValue CodeGenFunction::EmitMemberExpr(c
 AlignmentSource AlignSource;
 Address Addr = EmitPointerWithAlignment(BaseExpr, );
 QualType PtrTy = BaseExpr->getType()->getPointeeType();
-EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy);
+bool SkipNullCheck = CanElideObjectPointerNullCheck(BaseExpr);
+EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy,
+  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
 BaseLV = MakeAddrLValue(Addr, PtrTy, AlignSource);
   } else
 BaseLV = EmitCheckedLValue(BaseExpr, TCK_MemberAccess);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295391=295390=295391=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu Feb 16 19:05:42 2017
@@ -290,10 +290,15 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (CE)
 CallLoc = CE->getExprLoc();
 
-  EmitTypeCheck(isa(CalleeDecl)
-? CodeGenFunction::TCK_ConstructorCall
-: CodeGenFunction::TCK_MemberCall,
-CallLoc, This.getPointer(), 
C.getRecordType(CalleeDecl->getParent()));
+  bool SkipNullCheck = false;
+  if (const auto *CMCE = dyn_cast(CE))
+SkipNullCheck =
+CanElideObjectPointerNullCheck(CMCE->getImplicitObjectArgument());
+  EmitTypeCheck(
+  isa(CalleeDecl) ? 

[libcxx] r295390 - add tests for ENAMETOOLONG

2017-02-16 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Feb 16 19:00:37 2017
New Revision: 295390

URL: http://llvm.org/viewvc/llvm-project?rev=295390=rev
Log:
add tests for ENAMETOOLONG

Modified:

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp

libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp?rev=295390=295389=295390=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.exists/exists.pass.cpp
 Thu Feb 16 19:00:37 2017
@@ -85,4 +85,13 @@ TEST_CASE(test_exists_fails)
 TEST_CHECK_THROW(filesystem_error, exists(file));
 }
 
+TEST_CASE(test_name_too_long) {
+std::string long_name(2500, 'a');
+const path file(long_name);
+
+std::error_code ec;
+TEST_CHECK(exists(file, ec) == false);
+TEST_CHECK(ec);
+}
+
 TEST_SUITE_END()

Modified: 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp?rev=295390=295389=295390=diff
==
--- 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.status/status.pass.cpp
 Thu Feb 16 19:00:37 2017
@@ -65,29 +65,36 @@ TEST_CASE(test_status_cannot_resolve)
 
 const std::error_code set_ec =
 std::make_error_code(std::errc::address_in_use);
-const std::error_code expect_ec =
+const std::error_code perm_ec =
 std::make_error_code(std::errc::permission_denied);
+const std::error_code name_too_long_ec =
+std::make_error_code(std::errc::filename_too_long);
 
-const path cases[] = {
-file, sym
+struct TestCase {
+  path p;
+  std::error_code expect_ec;
+} const TestCases[] = {
+  {file, perm_ec},
+  {sym, perm_ec},
+  {path(std::string(2500, 'a')), name_too_long_ec}
 };
-for (auto& p : cases)
+for (auto& TC : TestCases)
 {
 { // test non-throwing case
 std::error_code ec = set_ec;
-file_status st = status(p, ec);
-TEST_CHECK(ec == expect_ec);
+file_status st = status(TC.p, ec);
+TEST_CHECK(ec == TC.expect_ec);
 TEST_CHECK(st.type() == file_type::none);
 TEST_CHECK(st.permissions() == perms::unknown);
 }
 #ifndef TEST_HAS_NO_EXCEPTIONS
 { // test throwing case
 try {
-status(p);
+status(TC.p);
 } catch (filesystem_error const& err) {
-TEST_CHECK(err.path1() == p);
+TEST_CHECK(err.path1() == TC.p);
 TEST_CHECK(err.path2() == "");
-TEST_CHECK(err.code() == expect_ec);
+TEST_CHECK(err.code() == TC.expect_ec);
 }
 }
 #endif


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


[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-16 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Other than (5), all the failing cases look like they should fail per the 
current `basic_string` spec.




Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:57
+  { // Testing (2)
+// FIXME: (2) doesn't work with implicit deduction.
+// const test_allocator alloc{};

I think that at least matches the standard as-is. I'm not sure this case is 
worth adding an explicit deduction guide for. *shrug*



Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:107
+  { // Testing (5) w/o allocator
+#if 0 // FIXME: This doesn't work
+const std::string sin("abc");

Do you know why not?



Comment at: 
test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp:291
+  { // Testing (15)
+// FIXME: This overload is broken. Fix it and add tests.
+  }

I think the inability to deduce using this overload matches the standard. I 
don't think there's any way in general to map the type `T` to a `charT`.


https://reviews.llvm.org/D29863



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


[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88803.
EricWF added a comment.

- Enumerate and test each constructor.


https://reviews.llvm.org/D29863

Files:
  include/string
  test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -397,6 +397,9 @@
 if '__cpp_structured_bindings' not in macros:
 self.config.available_features.add('libcpp-no-structured-bindings')
 
+if '__cpp_deduction_guides' not in macros:
+self.config.available_features.add('libcpp-no-deduction-guides')
+
 if self.is_windows:
 self.config.available_features.add('windows')
 
Index: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
===
--- /dev/null
+++ test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
@@ -0,0 +1,293 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+// 
+
+// Test that the constructors offered by std::basic_string are formulated
+// so they're compatible with implicit deduction guides.
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "constexpr_char_traits.hpp"
+
+template >
+using BStr = std::basic_string;
+
+// Overloads
+//  using A = Allocator;
+//  using BS = basic_string
+//  using BSV = basic_string_view
+// ---
+// (1)  basic_string() - NOT TESTED
+// (2)  basic_string(A const&) - BROKEN
+// (3)  basic_string(size_type, CharT, const A& = A())
+// (4)  basic_string(BS const&, size_type, A const& = A())
+// (5)  basic_string(BS const&, size_type, size_type, A const& = A()) - PARTIALLY BROKEN
+// (6)  basic_string(const CharT*, size_type, A const& = A())
+// (7)  basic_string(const CharT*, A const& = A())
+// (8)  basic_string(InputIt, InputIt, A const& = A()) - BROKEN
+// (9)  basic_string(BS const&)
+// (10) basic_string(BS const&, A const&)
+// (11) basic_string(BS&&)
+// (12) basic_string(BS&&, A const&)
+// (13) basic_string(initializer_list, A const& = A())
+// (14) basic_string(BSV, A const& = A())
+// (15) basic_string(const T&, size_type, size_type, A const& = A()) - BROKEN
+int main()
+{
+  using TestSizeT = test_allocator::size_type;
+  { // Testing (1)
+// Nothing TODO. Cannot deduce without any arguments.
+  }
+  { // Testing (2)
+// FIXME: (2) doesn't work with implicit deduction.
+// const test_allocator alloc{};
+// std::basic_string s(alloc);
+  }
+  { // Testing (3) w/o allocator
+std::basic_string s(6ull, 'a');
+ASSERT_SAME_TYPE(decltype(s), std::string);
+assert(s == "aa");
+std::basic_string w(2ull, L'b');
+ASSERT_SAME_TYPE(decltype(w), std::wstring);
+assert(w == L"bb");
+  }
+  { // Testing (3) w/ allocator
+std::basic_string s(6ull, 'a', test_allocator{});
+ASSERT_SAME_TYPE(decltype(s), BStr);
+assert(s == "aa");
+
+std::basic_string w(2ull, L'b', test_allocator{});
+ASSERT_SAME_TYPE(decltype(w), BStr);
+assert(w == L"bb");
+  }
+  { // Testing (4) w/o allocator
+const std::string sin("abc");
+std::basic_string s(sin, (size_t)1);
+ASSERT_SAME_TYPE(decltype(s), std::string);
+assert(s == "bc");
+
+using WStr = std::basic_string;
+const WStr win(L"abcdef");
+std::basic_string w(win, (TestSizeT)3);
+ASSERT_SAME_TYPE(decltype(w), WStr);
+assert(w == L"def");
+  }
+  { // Testing (4) w/ allocator
+const std::string sin("abc");
+std::basic_string s(sin, (size_t)1, std::allocator{});
+ASSERT_SAME_TYPE(decltype(s), std::string);
+assert(s == "bc");
+
+using WStr = std::basic_string;
+const WStr win(L"abcdef");
+std::basic_string w(win, (TestSizeT)3, test_allocator{});
+ASSERT_SAME_TYPE(decltype(w), WStr);
+assert(w == L"def");
+  }
+  { // Testing (5) w/o allocator
+#if 0 // FIXME: This doesn't work
+const std::string sin("abc");
+std::basic_string s(sin, (size_t)1, (size_t)3);
+ASSERT_SAME_TYPE(decltype(s), std::string);
+assert(s == "bc");
+
+using WStr = 

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

pirama wrote:
> I feel this test is fragile.  Any idea how to further restrict and require 
> that the default target triple has linux and one of i386, x86_64, arm, 
> aarch64?
> 
> I could create sub-dirs for all archs returned by Triple::getArchTypeName 
> (llvm/lib/Support/Triple.cpp) but it seems overkill.
I've restricted the test to just x86_64-linux.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88799.
pirama added a comment.

Stricter tests.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp

r295381 - Use correct fix-it location for -Wblock-capture-autoreleasing

2017-02-16 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Feb 16 17:15:36 2017
New Revision: 295381

URL: http://llvm.org/viewvc/llvm-project?rev=295381=rev
Log:
Use correct fix-it location for -Wblock-capture-autoreleasing

The '__autoreleasing' keyword should be inserted after the Objective-C pointer
type.

rdar://30123548

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=295381=295380=295381=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Feb 16 17:15:36 2017
@@ -13634,8 +13634,30 @@ static bool captureInBlock(BlockScopeInf
   if (BuildAndDiagnose) {
 SourceLocation VarLoc = Var->getLocation();
 S.Diag(Loc, diag::warn_block_capture_autoreleasing);
-S.Diag(VarLoc, diag::note_declare_parameter_autoreleasing) <<
-FixItHint::CreateInsertion(VarLoc, "__autoreleasing");
+{
+  auto AddAutoreleaseNote =
+  S.Diag(VarLoc, diag::note_declare_parameter_autoreleasing);
+  // Provide a fix-it for the '__autoreleasing' keyword at the
+  // appropriate location in the variable's type.
+  if (const auto *TSI = Var->getTypeSourceInfo()) {
+PointerTypeLoc PTL =
+TSI->getTypeLoc().getAsAdjusted();
+if (PTL) {
+  SourceLocation Loc = PTL.getPointeeLoc().getEndLoc();
+  Loc = Lexer::getLocForEndOfToken(Loc, 0, S.getSourceManager(),
+   S.getLangOpts());
+  if (Loc.isValid()) {
+StringRef CharAtLoc = Lexer::getSourceText(
+CharSourceRange::getCharRange(Loc, 
Loc.getLocWithOffset(1)),
+S.getSourceManager(), S.getLangOpts());
+AddAutoreleaseNote << FixItHint::CreateInsertion(
+Loc, CharAtLoc.empty() || !isWhitespace(CharAtLoc[0])
+ ? " __autoreleasing "
+ : " __autoreleasing");
+  }
+}
+  }
+}
 S.Diag(VarLoc, diag::note_declare_parameter_strong);
   }
 }

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=295381=295380=295381=diff
==
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Thu Feb 16 17:15:36 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak 
-fsyntax-only -fobjc-arc -fblocks -Wno-objc-root-class 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 typedef unsigned long NSUInteger;
 typedef const void * CFTypeRef;
@@ -821,6 +822,12 @@ void block_capture_autoreleasing(A * __a
  id _Nullable __autoreleasing *j,
  id * _Nullable k, // expected-note {{declare 
the parameter __autoreleasing explicitly to suppress this warning}} 
expected-note {{declare the parameter __strong or capture a __block __strong 
variable to keep values alive across autorelease pools}}
  id __autoreleasing * _Nullable l) {
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-11]]:37-[[@LINE-11]]:37}:" 
__autoreleasing "
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-11]]:47-[[@LINE-11]]:47}:" 
__autoreleasing"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-10]]:37-[[@LINE-10]]:37}:" 
__autoreleasing "
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-8]]:36-[[@LINE-8]]:36}:" __autoreleasing"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-8]]:46-[[@LINE-8]]:46}:" __autoreleasing"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-7]]:36-[[@LINE-7]]:36}:" __autoreleasing"
   ^{
 (void)*a;
 (void)*b; // expected-warning {{block captures an autoreleasing 
out-parameter, which may result in use-after-free bugs}}


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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88795.
EricWF added a comment.

Remove test code that snuck in.


https://reviews.llvm.org/D29930

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2048,6 +2048,8 @@
 
   // PR25513
   { int arr[F(__is_constructible(int(int)))]; }
+
+  { int arr[T(__is_constructible(int const&, long))]; }
 }
 
 // Instantiation of __is_trivially_constructible
@@ -2078,6 +2080,46 @@
   { int arr[F((is_trivially_constructible::value))]; } // PR19178
 }
 
+template 
+struct ConvertsToRef {
+  operator RefType() const { return static_cast(obj); }
+  mutable T obj = 42;
+};
+
+void reference_binds_to_temporary_checks() {
+  { int arr[F((__reference_binds_to_temporary(int&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int const&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int const&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int&, long &)))]; } // doesn't construct
+  { int arr[T((__reference_binds_to_temporary(int const&, long&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, long&&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int&&, long&)))]; }
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
+  { int arr[T((__is_constructible(int&&, RRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, RRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, CLRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, CLRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, LongRef)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, LongRef)))]; }
+
+  // Test that it doesn't accept non-reference types as input.
+  { int arr[F((__reference_binds_to_temporary(int, long)))]; }
+
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4564,11 +4564,14 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
 return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
Args[1]->getType(), RParenLoc);
 
   switch (Kind) {
+  case clang::BTT_ReferenceBindsToTemporary:
   case clang::TT_IsConstructible:
   case clang::TT_IsNothrowConstructible:
   case clang::TT_IsTriviallyConstructible: {
@@ -4644,6 +4647,13 @@
 if (Kind == clang::TT_IsConstructible)
   return true;
 
+if (Kind == clang::BTT_ReferenceBindsToTemporary) {
+  if (!T->isReferenceType())
+return false;
+
+  return !Init.isDirectReferenceBinding();
+}
+
 if (Kind == clang::TT_IsNothrowConstructible)
   return S.canThrow(Result.get()) == CT_Cannot;
 
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -847,6 +847,7 @@
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
+  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
 #undef REVERTIBLE_TYPE_TRAIT
 #undef RTT_JOIN
 }
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1431,7 +1431,8 @@
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile))
+  tok::kw___is_volatile,
+  tok::kw___reference_binds_to_temporary))
 // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
 // name of struct templates, but some are keywords in GCC >= 4.3
 // and Clang. Therefore, when we see the token sequence "struct
Index: include/clang/Basic/TypeTraits.h
===
--- 

[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

arphaman wrote:
> aaron.ballman wrote:
> > I have strong reservations about this -- users are going to have no idea 
> > what attributes are and are not supported because they're not going to know 
> > whether the attribute has a subject list or requires delayed parsing. We 
> > have a considerable number of attributes for which the Subjects line is 
> > currently commented out simply because no one has bothered to fix that. 
> > This means those attributes can't be used with this pragma until someone 
> > fixes that, but when it happens, they magically can be used, which is a 
> > good thing. But the converse is more problematic -- if there's an existing 
> > Subjects line that gets removed because a subject is added that is 
> > difficult to express in TableGen it may break user code.
> > 
> > We can fix the discoverability issues somewhat by updating the 
> > documentation emitter to spit out some wording that says when an attribute 
> > is/is not supported by this feature, but that only works for attributes 
> > which have documentation and so it's not a particularly reliable workaround.
> > I have strong reservations about this -- users are going to have no idea 
> > what attributes are and are not supported because they're not going to know 
> > whether the attribute has a subject list or requires delayed parsing. We 
> > have a considerable number of attributes for which the Subjects line is 
> > currently commented out simply because no one has bothered to fix that. 
> > This means those attributes can't be used with this pragma until someone 
> > fixes that, but when it happens, they magically can be used, which is a 
> > good thing. But the converse is more problematic -- if there's an existing 
> > Subjects line that gets removed because a subject is added that is 
> > difficult to express in TableGen it may break user code.
> 
> That's a good point. I think we can address this problem by creating a test 
> that verifies the list of attributes that support the pragma. This would 
> allow us to ensure that no attributes loose the ability to use the pragma.
> 
> > We can fix the discoverability issues somewhat by updating the 
> > documentation emitter to spit out some wording that says when an attribute 
> > is/is not supported by this feature, but that only works for attributes 
> > which have documentation and so it's not a particularly reliable workaround.
> 
> We can enforce the rule that the attributes can only be used with '#pragma 
> clang attribute' when they're documented. This way we can ensure that all 
> attributes that can be used with the pragma are explicitly documented.
> That's a good point. I think we can address this problem by creating a test 
> that verifies the list of attributes that support the pragma. This would 
> allow us to ensure that no attributes loose the ability to use the pragma.

That would be good.

> We can enforce the rule that the attributes can only be used with '#pragma 
> clang attribute' when they're documented. This way we can ensure that all 
> attributes that can be used with the pragma are explicitly documented.

This addresses the concern about discoverability, but it worsens the concerns 
about fragility. The biggest problem is: the user has very little hope of 
understanding what attributes will apply to what declarations with which 
version of the compiler they're using. With this sort of thing, the act of us 
adding documentation can impact the behavior of a user's program from one 
release to the next.

While I can imagine this pragma reducing some amount of code clutter, it is far 
too "magical" for me to feel comfortable with it (at least in the proposed 
form). I cannot read the user's source code and understand what attributes are 
going to be applied to which declarations, and that's not a good story for 
usability of the feature.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-02-16 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88794.
EricWF retitled this revision from "Add `__is_direct_constructible` trait for 
checking safe reference initialization." to "Add 
`__reference_binds_to_temporary` trait for checking safe reference 
initialization.".
EricWF edited the summary of this revision.
EricWF added a comment.

Address all of @rsmith's comments.


https://reviews.llvm.org/D29930

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -2048,6 +2048,8 @@
 
   // PR25513
   { int arr[F(__is_constructible(int(int)))]; }
+
+  { int arr[T(__is_constructible(int const&, long))]; }
 }
 
 // Instantiation of __is_trivially_constructible
@@ -2078,6 +2080,46 @@
   { int arr[F((is_trivially_constructible::value))]; } // PR19178
 }
 
+template 
+struct ConvertsToRef {
+  operator RefType() const { return static_cast(obj); }
+  mutable T obj = 42;
+};
+
+void reference_binds_to_temporary_checks() {
+  { int arr[F((__reference_binds_to_temporary(int&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int const&, int&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int const&)))]; }
+  { int arr[F((__reference_binds_to_temporary(int const&, int&&)))]; }
+
+  { int arr[F((__reference_binds_to_temporary(int&, long &)))]; } // doesn't construct
+  { int arr[T((__reference_binds_to_temporary(int const&, long&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, long&&)))]; }
+  { int arr[T((__reference_binds_to_temporary(int&&, long&)))]; }
+
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
+  { int arr[T((__is_constructible(int&&, RRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, RRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, CLRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&&, CLRef)))]; }
+
+  { int arr[T((__is_constructible(int const&, LongRef)))]; }
+  { int arr[T((__reference_binds_to_temporary(int const&, LongRef)))]; }
+
+  // Test that it doesn't accept non-reference types as input.
+  { int arr[F((__reference_binds_to_temporary(int, long)))]; }
+
+}
+
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4564,11 +4564,14 @@
   if (Kind <= UTT_Last)
 return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
 return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
Args[1]->getType(), RParenLoc);
 
   switch (Kind) {
+  case clang::BTT_ReferenceBindsToTemporary:
   case clang::TT_IsConstructible:
   case clang::TT_IsNothrowConstructible:
   case clang::TT_IsTriviallyConstructible: {
@@ -4644,6 +4647,15 @@
 if (Kind == clang::TT_IsConstructible)
   return true;
 
+if (Kind == clang::BTT_ReferenceBindsToTemporary) {
+  if (!T->isReferenceType())
+return false;
+
+  assert(isa(Result.get())
+ == !Init.isDirectReferenceBinding());
+  return !Init.isDirectReferenceBinding();
+}
+
 if (Kind == clang::TT_IsNothrowConstructible)
   return S.canThrow(Result.get()) == CT_Cannot;
 
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -847,6 +847,7 @@
   REVERTIBLE_TYPE_TRAIT(__is_unsigned);
   REVERTIBLE_TYPE_TRAIT(__is_void);
   REVERTIBLE_TYPE_TRAIT(__is_volatile);
+  REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
 #undef REVERTIBLE_TYPE_TRAIT
 #undef RTT_JOIN
 }
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1431,7 +1431,8 @@
   tok::kw___is_union,
   tok::kw___is_unsigned,
   tok::kw___is_void,
-  tok::kw___is_volatile))
+  tok::kw___is_volatile,
+  

[PATCH] D29901: Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-02-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 88792.
dblaikie added a comment.

- Simplify ModuleFile lookup


https://reviews.llvm.org/D29901

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTReader.h
  lib/AST/ASTContext.cpp
  lib/AST/ExternalASTSource.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/codegen/foo.h
  test/Modules/Inputs/codegen/use.cpp
  test/Modules/codegen.test

Index: test/Modules/codegen.test
===
--- test/Modules/codegen.test
+++ test/Modules/codegen.test
@@ -3,8 +3,23 @@
 
 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 -emit-llvm -o - %t/foo.pcm | FileCheck %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
 
-CHECK: $_Z2f1PKcz = comdat any
-CHECK: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
-CHECK:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+FOO: $_Z2f1PKcz = comdat any
+FOO: $_ZN13implicit_dtorD1Ev = comdat any
+USE: $_Z4instIiEvv = comdat any
+FOO: $_ZN13implicit_dtorD2Ev = comdat any
+FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
+FOO:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+
+Test that implicit special members (like this dtor) are emitted into both module (if they're used there) and user.
+FIXME: Proactively instantiate any valid implicit special members to emit them into the module object.
+
+FOO: define weak_odr void @_ZN13implicit_dtorD1Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+FOO: define weak_odr void @_Z4instIfEvv() #0 comdat {
+FOO: define weak_odr void @_ZN13implicit_dtorD2Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+USE: define linkonce_odr void @_Z4instIiEvv() #0 comdat {
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
Index: test/Modules/Inputs/codegen/use.cpp
===
--- /dev/null
+++ test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,8 @@
+#include "foo.h"
+void non_modular_use_of_implicit_dtor() {
+  implicit_dtor d1;
+  uninst_implicit_dtor d2;
+}
+void use_of_instantiated_declaration_without_definition() {
+  inst();
+}
Index: test/Modules/Inputs/codegen/foo.h
===
--- test/Modules/Inputs/codegen/foo.h
+++ test/Modules/Inputs/codegen/foo.h
@@ -2,3 +2,29 @@
   __builtin_va_list args;
   __builtin_va_start(args, fmt);
 }
+
+struct non_trivial_dtor {
+  ~non_trivial_dtor();
+};
+
+struct implicit_dtor {
+  non_trivial_dtor d;
+};
+
+struct uninst_implicit_dtor {
+  non_trivial_dtor d;
+};
+
+inline void use_implicit_dtor() {
+  implicit_dtor d;
+}
+
+template
+void inst() {
+}
+
+inline void inst_decl() {
+  // cause inst's declaration to be instantiated, without a definition.
+  (void)sizeof();
+  inst();
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -2224,6 +2224,8 @@
   Writer->ClearSwitchCaseIDs();
 
   assert(FD->doesThisDeclarationHaveABody());
+  Record->push_back(Writer->Context->getLangOpts().ModularCodegen &&
+Writer->WritingModule);
   if (auto *CD = dyn_cast(FD)) {
 Record->push_back(CD->getNumCtorInitializers());
 if (CD->getNumCtorInitializers())
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -423,6 +423,11 @@
 }
 
 void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
+  if (Record.readInt()) {
+Reader.BodySource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile
+? ExternalASTSource::EK_Never
+: ExternalASTSource::EK_Always;
+  }
   if (auto *CD = dyn_cast(FD)) {
 CD->NumCtorInitializers = Record.readInt();
 if (CD->NumCtorInitializers)
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -7911,16 +7911,11 @@
   return None;
 }
 

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/arch-specific-libdir.c:6
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//

Please be more specific in the tests, i.e. check if the correct arch dir is 
selected. Also add a test for i386-* triple, and make sure that both i386-* and 
i686-* give the same result.


https://reviews.llvm.org/D30015



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


[PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-16 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

It seems to me that the problem here is that `DeclMustBeEmitted` is not safe to 
call in the middle of deserialization if anything partially-deserialized might 
be reachable from the declaration we're querying, and yet we're currently 
calling it in that case. I don't see how this patch actually addresses that 
problem, though: if you build this testcase as a module instead of a PCH, won't 
it still fail in the same way that it does now?

I think we probably need to track all the declarations we deserialize in a 
top-level deserialization,  and only check whether they're interesting when we 
finish recursive deserialization (somewhere around 
`ASTReader::FinishedDeserializing`). For the update record case, this will need 
some care in order to retain the property that we only pass a declaration to 
the consumer once, but I think we can make that work by observing that it 
should generally be safe to call `DeclMustBeEmitted` on a declaration that we 
didn't create in this deserialization step, and when we're loading update 
records we know whether that's the case.


https://reviews.llvm.org/D29753



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

aaron.ballman wrote:
> I have strong reservations about this -- users are going to have no idea what 
> attributes are and are not supported because they're not going to know 
> whether the attribute has a subject list or requires delayed parsing. We have 
> a considerable number of attributes for which the Subjects line is currently 
> commented out simply because no one has bothered to fix that. This means 
> those attributes can't be used with this pragma until someone fixes that, but 
> when it happens, they magically can be used, which is a good thing. But the 
> converse is more problematic -- if there's an existing Subjects line that 
> gets removed because a subject is added that is difficult to express in 
> TableGen it may break user code.
> 
> We can fix the discoverability issues somewhat by updating the documentation 
> emitter to spit out some wording that says when an attribute is/is not 
> supported by this feature, but that only works for attributes which have 
> documentation and so it's not a particularly reliable workaround.
> I have strong reservations about this -- users are going to have no idea what 
> attributes are and are not supported because they're not going to know 
> whether the attribute has a subject list or requires delayed parsing. We have 
> a considerable number of attributes for which the Subjects line is currently 
> commented out simply because no one has bothered to fix that. This means 
> those attributes can't be used with this pragma until someone fixes that, but 
> when it happens, they magically can be used, which is a good thing. But the 
> converse is more problematic -- if there's an existing Subjects line that 
> gets removed because a subject is added that is difficult to express in 
> TableGen it may break user code.

That's a good point. I think we can address this problem by creating a test 
that verifies the list of attributes that support the pragma. This would allow 
us to ensure that no attributes loose the ability to use the pragma.

> We can fix the discoverability issues somewhat by updating the documentation 
> emitter to spit out some wording that says when an attribute is/is not 
> supported by this feature, but that only works for attributes which have 
> documentation and so it's not a particularly reliable workaround.

We can enforce the rule that the attributes can only be used with '#pragma 
clang attribute' when they're documented. This way we can ensure that all 
attributes that can be used with the pragma are explicitly documented.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


Re: [PATCH] D29753: [PCH] Avoid early VarDecl emission attempt if no owning module avaiable

2017-02-16 Thread Hans Wennborg via cfe-commits
Richard, can you take a look when you have a moment? The PR is marked
as a release blocker.

On Thu, Feb 9, 2017 at 1:54 PM, Duncan P. N. Exon Smith via
Phabricator via cfe-commits  wrote:
> dexonsmith added a comment.
>
> I'm not comfortable signing off on this, but it seems like this should be set 
> up as a blocker for LLVM 4.0 if it isn't already.
>
>
>
> 
> Comment at: lib/Serialization/ASTReaderDecl.cpp:2518-2523
>// An ImportDecl or VarDecl imported from a module will get emitted when
>// we import the relevant module.
> -  if ((isa(D) || isa(D)) && Ctx.DeclMustBeEmitted(D) &&
> -  D->getImportedOwningModule())
> +  if ((isa(D) || isa(D)) && 
> D->getImportedOwningModule() &&
> +  Ctx.DeclMustBeEmitted(D))
>  return false;
>
> 
> It's not locally obvious why the order matters.  Can you add a comment 
> explaining why you need to check getImportedOwningModule first?  It might be 
> worth splitting Ctx.DeclMustBeEmitted into its own; e.g.,
> ```
> // An ImportDecl or VarDecl imported from a module will get emitted when
> // we import the relevant module.
> if ((isa(D) || isa(D)) && D->getImportedOwningModule())
>   // Only check DeclMustBeEmitted if D has been fully imported, since it may
>   // emit D as a side effect.
>   if (Ctx.DeclMustBeEmitted(D))
> return false;
> ```
> but anything that prevents someone from swapping the conditions when they 
> refactor this would be good enough I think.
>
>
> https://reviews.llvm.org/D29753
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295379 - Properly set up the DeclContext for parameters of implicit deduction guides;

2017-02-16 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Feb 16 15:29:21 2017
New Revision: 295379

URL: http://llvm.org/viewvc/llvm-project?rev=295379=rev
Log:
Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=295379=295378=295379=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Feb 16 15:29:21 2017
@@ -1677,6 +1677,9 @@ private:
  bool Explicit, TypeSourceInfo *TInfo,
  SourceLocation LocStart, SourceLocation Loc,
  SourceLocation LocEnd) {
+ArrayRef Params =
+TInfo->getTypeLoc().castAs().getParams();
+
 // Build the implicit deduction guide template.
 auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart, Loc,
DeductionGuideName, TInfo->getType(),
@@ -1685,8 +1688,10 @@ private:
 if (Explicit)
   Guide->setExplicitSpecified();
 Guide->setRangeEnd(LocEnd);
-Guide->setParams(
-TInfo->getTypeLoc().castAs().getParams());
+Guide->setParams(Params);
+
+for (auto *Param : Params)
+  Param->setDeclContext(Guide);
 
 auto *GuideTemplate = FunctionTemplateDecl::Create(
 SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=295379=295378=295379=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Thu Feb 
16 15:29:21 2017
@@ -168,3 +168,11 @@ namespace nondeducible {
typename ...B>
   X(float) -> X; // ok
 }
+
+namespace default_args_from_ctor {
+  template  struct S { S(A = 0) {} };
+  S s(0);
+
+  template  struct T { template T(A = 0, B = 0) {} };
+  T t(0, 0);
+}


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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Well hmm... changing this from MSVC to always caused a ton of regressions.  I 
no longer think that this is a proper patch as it sits.  Additionally, it 
doesn't fix the A::TYPE *var3 condition.


https://reviews.llvm.org/D29401



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> efriedma wrote:
> > arphaman wrote:
> > > arphaman wrote:
> > > > efriedma wrote:
> > > > > I'm wondering if we can tweak the approach so that we don't have to 
> > > > > separately define how this works for each attribute; for example, 
> > > > > `#pragma clang attribute_function_declaration push(...)` would apply 
> > > > > to each function declaration, `#pragma clang 
> > > > > attribute_global_variable_declaration push(...)` would apply to each 
> > > > > global variable declaration, etc.
> > > > I agree with this idea, I think it would be useful to have the ability 
> > > > to specify the target declarations. I do think it would be better to 
> > > > use the 'clang attribute' umbrella pragma, and maybe add an extra 
> > > > argument to the 'push', e.g.:
> > > > 
> > > > ```
> > > > #pragma attribute push (annotate("functions-only"), 
> > > > applicable_to=function) // or maybe received_by=?
> > > > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > > > applicable_to=enum)
> > > > ```
> > > I think that the further tweaks that control which declarations receive 
> > > the attributes should be kept for a follow-up patch.
> > I'm not sure we can wait to address this, especially if we're turning this 
> > on for all attributes by default.  There's a compatibility hazard here: if 
> > the push doesn't specify what declarations it applies to, we can never 
> > change AttributeAppliesToDecl for any existing attribute.
> Are you saying that we should never allow a push without specifying which 
> declarations should the attribute apply to? I think that would make this 
> feature less useful, as some attributes have a well defined set of 
> declarations that they apply to. Even if we will change the attribute's 
> subjects in the future, I think it might be more likely that the users 
> would've wanted to apply the attribute to the updated compiler-determined 
> subject list.
I agree, users shouldn't have to repeat that attribute "target" applies to 
functions and attribute "warn_unused" applies to record types. Asking the user 
to figure it out just makes it harder to use.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: docs/LanguageExtensions.rst:2418
+In general, the attributes are applied to a declaration only when there would
+have been no error or warning for that attribute if it was specified 
explicitly.
+An attribute is applied to each relevant declaration individually,

So then this code does not produce an error?
```
#pragma clang attribute push(hot)

void func(void) __attribute__((cold));

#pragma clang attribute pop
```



Comment at: docs/LanguageExtensions.rst:2428
+whether or not an attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

This doesn't make clear what would happen with something like:
```
  #pragma clang attribute push(cdecl)

  void function(void (*fp)(int));

  #pragma clang attribute pop
```
Naively, I would expect the cdecl attribute to appertain to both `function` and 
`fp`, but I'm guessing that's not what actually happens (because cdecl is both 
a decl and a type attribute at the same time).

Also, why is this not available for __declspec attributes?

Why do C++ attributes require the syntax to be present in the #pragma, but 
GNU-style attributes do not? There are also MS-style attribute (currently 
unsupported, but there have been some efforts to include them in the past) and 
__declspec attributes as well. Why not require the syntax so that any of them 
can be supported?



Comment at: include/clang/Basic/Attr.td:308-311
+  // - An attribute requires delayed parsing (LateParsed is on)
+  // - An attribute has no GNU/CXX11 spelling
+  // - An attribute has no subject list
+  // - An attribute derives from a StmtAttr or a TypeAttr

I have strong reservations about this -- users are going to have no idea what 
attributes are and are not supported because they're not going to know whether 
the attribute has a subject list or requires delayed parsing. We have a 
considerable number of attributes for which the Subjects line is currently 
commented out simply because no one has bothered to fix that. This means those 
attributes can't be used with this pragma until someone fixes that, but when it 
happens, they magically can be used, which is a good thing. But the converse is 
more problematic -- if there's an existing Subjects line that gets removed 
because a subject is added that is difficult to express in TableGen it may 
break user code.

We can fix the discoverability issues somewhat by updating the documentation 
emitter to spit out some wording that says when an attribute is/is not 
supported by this feature, but that only works for attributes which have 
documentation and so it's not a particularly reliable workaround.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


Re: r295224 - PR24440: Do not silently discard a fold-expression appearing as the operand of a cast-expression.

2017-02-16 Thread Hans Wennborg via cfe-commits
Merged in r295375.

Thanks,
Hans

On Wed, Feb 15, 2017 at 12:14 PM, Richard Smith  wrote:
> Hans, this would be a good candidate for Clang 4. The bug in question is not
> a regression, but it is an accepts-invalid / wrong-code bug.
>
> On 15 February 2017 at 11:57, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Wed Feb 15 13:57:10 2017
>> New Revision: 295224
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=295224=rev
>> Log:
>> PR24440: Do not silently discard a fold-expression appearing as the
>> operand of a cast-expression.
>>
>> Modified:
>> cfe/trunk/lib/Parse/ParseExpr.cpp
>> cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
>> cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
>>
>> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=295224=295223=295224=diff
>>
>> ==
>> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 15 13:57:10 2017
>> @@ -2409,7 +2409,7 @@ Parser::ParseParenExpression(ParenParseO
>>// fold-expressions, we'll need to allow multiple ArgExprs here.
>>if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
>>NextToken().is(tok::ellipsis))
>> -return ParseFoldExpression(Result, T);
>> +return ParseFoldExpression(ArgExprs[0], T);
>>
>>ExprType = SimpleExpr;
>>Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
>>
>> Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=295224=295223=295224=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Wed Feb 15 13:57:10 2017
>> @@ -1015,6 +1015,11 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>CheckFoldOperand(*this, LHS);
>>CheckFoldOperand(*this, RHS);
>>
>> +  auto DiscardOperands = [&] {
>> +CorrectDelayedTyposInExpr(LHS);
>> +CorrectDelayedTyposInExpr(RHS);
>> +  };
>> +
>>// [expr.prim.fold]p3:
>>//   In a binary fold, op1 and op2 shall be the same fold-operator, and
>>//   either e1 shall contain an unexpanded parameter pack or e2 shall
>> contain
>> @@ -1022,6 +1027,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>if (LHS && RHS &&
>>LHS->containsUnexpandedParameterPack() ==
>>RHS->containsUnexpandedParameterPack()) {
>> +DiscardOperands();
>>  return Diag(EllipsisLoc,
>>  LHS->containsUnexpandedParameterPack()
>>  ? diag::err_fold_expression_packs_both_sides
>> @@ -1035,6 +1041,7 @@ ExprResult Sema::ActOnCXXFoldExpr(Source
>>if (!LHS || !RHS) {
>>  Expr *Pack = LHS ? LHS : RHS;
>>  assert(Pack && "fold expression with neither LHS nor RHS");
>> +DiscardOperands();
>>  if (!Pack->containsUnexpandedParameterPack())
>>return Diag(EllipsisLoc,
>> diag::err_pack_expansion_without_parameter_packs)
>>   << Pack->getSourceRange();
>>
>> Modified: cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp?rev=295224=295223=295224=diff
>>
>> ==
>> --- cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp (original)
>> +++ cfe/trunk/test/Parser/cxx1z-fold-expressions.cpp Wed Feb 15 13:57:10
>> 2017
>> @@ -34,3 +34,12 @@ template int bad9() { return (
>>  template int bad10() { return (3 ? ... : N); } //
>> expected-error +{{}} expected-note {{to match}}
>>  template int bad11() { return (N + ... 0); } // expected-error
>> {{expected a foldable binary operator}} expected-error {{expected
>> expression}}
>>  template int bad12() { return (... N); } // expected-error
>> {{expected expression}}
>> +
>> +template void as_operand_of_cast(int a, T ...t) {
>> +  return
>> +(int)(a + ... + undeclared_junk) + // expected-error {{undeclared}}
>> expected-error {{does not contain any unexpanded}}
>> +(int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
>> +(int)(... + undeclared_junk) + // expected-error {{undeclared}}
>> expected-error {{does not contain any unexpanded}}
>> +(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
>> +(int)(a + ...); // expected-error {{does not contain any unexpanded}}
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

efriedma wrote:
> arphaman wrote:
> > arphaman wrote:
> > > efriedma wrote:
> > > > I'm wondering if we can tweak the approach so that we don't have to 
> > > > separately define how this works for each attribute; for example, 
> > > > `#pragma clang attribute_function_declaration push(...)` would apply to 
> > > > each function declaration, `#pragma clang 
> > > > attribute_global_variable_declaration push(...)` would apply to each 
> > > > global variable declaration, etc.
> > > I agree with this idea, I think it would be useful to have the ability to 
> > > specify the target declarations. I do think it would be better to use the 
> > > 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> > > 'push', e.g.:
> > > 
> > > ```
> > > #pragma attribute push (annotate("functions-only"), 
> > > applicable_to=function) // or maybe received_by=?
> > > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > > applicable_to=enum)
> > > ```
> > I think that the further tweaks that control which declarations receive the 
> > attributes should be kept for a follow-up patch.
> I'm not sure we can wait to address this, especially if we're turning this on 
> for all attributes by default.  There's a compatibility hazard here: if the 
> push doesn't specify what declarations it applies to, we can never change 
> AttributeAppliesToDecl for any existing attribute.
Are you saying that we should never allow a push without specifying which 
declarations should the attribute apply to? I think that would make this 
feature less useful, as some attributes have a well defined set of declarations 
that they apply to. Even if we will change the attribute's subjects in the 
future, I think it might be more likely that the users would've wanted to apply 
the attribute to the updated compiler-determined subject list.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> arphaman wrote:
> > efriedma wrote:
> > > I'm wondering if we can tweak the approach so that we don't have to 
> > > separately define how this works for each attribute; for example, 
> > > `#pragma clang attribute_function_declaration push(...)` would apply to 
> > > each function declaration, `#pragma clang 
> > > attribute_global_variable_declaration push(...)` would apply to each 
> > > global variable declaration, etc.
> > I agree with this idea, I think it would be useful to have the ability to 
> > specify the target declarations. I do think it would be better to use the 
> > 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> > 'push', e.g.:
> > 
> > ```
> > #pragma attribute push (annotate("functions-only"), applicable_to=function) 
> > // or maybe received_by=?
> > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> > applicable_to=enum)
> > ```
> I think that the further tweaks that control which declarations receive the 
> attributes should be kept for a follow-up patch.
I'm not sure we can wait to address this, especially if we're turning this on 
for all attributes by default.  There's a compatibility hazard here: if the 
push doesn't specify what declarations it applies to, we can never change 
AttributeAppliesToDecl for any existing attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:6
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//

I feel this test is fragile.  Any idea how to further restrict and require that 
the default target triple has linux and one of i386, x86_64, arm, aarch64?

I could create sub-dirs for all archs returned by Triple::getArchTypeName 
(llvm/lib/Support/Triple.cpp) but it seems overkill.


https://reviews.llvm.org/D30015



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


[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 88770.

Repository:
  rL LLVM

https://reviews.llvm.org/D26654

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

Index: cmake/caches/Fuchsia.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- /dev/null
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,61 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-16 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88768.
pirama added a comment.

- Arch-subdir is now always added to -L
- It is added to -rpath during native compilation.
- Tests have been updated


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c

Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,38 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,19 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation
+// REQUIRES: native
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
@@ -276,8 +277,18 @@
 
   // LIBRARY_PATH - included following the user specified library paths.
   //and only supported on native toolchains.
-  if (!TC.isCrossCompiling())
+  if (!TC.isCrossCompiling()) {
 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
+
+// If we are not cross-compling, add '-rpath' with architecture-specific
+// library path so libraries lined from this path can be automatically
+// found.
+std::string CandidateRPath = TC.getArchSpecificLibPath();
+if (D.getVFS().exists(CandidateRPath)) {
+  CmdArgs.push_back("-rpath");
+  CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
+}
+  }
 }
 
 /// Add OpenMP linker script arguments at the end of the argument list so that
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -10,6 +10,7 @@
 #include "clang/Driver/ToolChain.h"
 #include "Tools.h"
 #include 

[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute `.

arphaman wrote:
> efriedma wrote:
> > I'm wondering if we can tweak the approach so that we don't have to 
> > separately define how this works for each attribute; for example, `#pragma 
> > clang attribute_function_declaration push(...)` would apply to each 
> > function declaration, `#pragma clang attribute_global_variable_declaration 
> > push(...)` would apply to each global variable declaration, etc.
> I agree with this idea, I think it would be useful to have the ability to 
> specify the target declarations. I do think it would be better to use the 
> 'clang attribute' umbrella pragma, and maybe add an extra argument to the 
> 'push', e.g.:
> 
> ```
> #pragma attribute push (annotate("functions-only"), applicable_to=function) 
> // or maybe received_by=?
> #pragma attribute push (annotate("struct+enum"), applicable_to=struct, 
> applicable_to=enum)
> ```
I think that the further tweaks that control which declarations receive the 
attributes should be kept for a follow-up patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 88764.
arphaman marked an inline comment as done.
arphaman added a comment.

The updated patch switches over to the opt-out approach, allows the C++11 style 
syntax and improves documentation.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Parse/Parser.h
  include/clang/Sema/AttributeList.h
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/AttributeList.cpp
  lib/Sema/SemaAttr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaObjCProperty.cpp
  test/Parser/pragma-attribute.cpp
  test/Sema/pragma-attribute.c
  test/SemaCXX/pragma-attribute.cpp
  test/SemaObjC/pragma-attribute.m
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1522,6 +1522,38 @@
   OS << "#endif // CLANG_ATTR_LATE_PARSED_LIST\n\n";
 }
 
+static bool hasGNUorCXX11Spelling(const Record ) {
+  std::vector Spellings = GetFlattenedSpellings(Attribute);
+  for (const auto  : Spellings) {
+if (I.variety() == "GNU" || I.variety() == "CXX11")
+  return true;
+  }
+  return false;
+}
+
+static bool isSupportedByPragmaAttribute(const Record ) {
+  if (Attribute.getValueAsBit("ForcePragmaAttributeSupport"))
+return true;
+  // Opt-out rules:
+  // An attribute requires delayed parsing (LateParsed is on)
+  if (Attribute.getValueAsBit("LateParsed"))
+return false;
+  // An attribute has no GNU/CXX11 spelling
+  if (!hasGNUorCXX11Spelling(Attribute))
+return false;
+  // An attribute has no subject list or its subject list is empty
+  if (Attribute.isValueUnset("Subjects"))
+return false;
+  const Record *SubjectObj = Attribute.getValueAsDef("Subjects");
+  std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
+  if (Subjects.empty())
+return false;
+  // An attribute derives from a StmtAttr or a TypeAttr
+  if (Attribute.isSubClassOf("TypeAttr") || Attribute.isSubClassOf("StmtAttr"))
+return false;
+  return true;
+}
+
 template 
 static void forEachUniqueSpelling(const Record , Fn &) {
   std::vector Spellings = GetFlattenedSpellings(Attr);
@@ -2692,9 +2724,13 @@
   return B + "Decl";
 }
 
+static std::string functionNameForCustomAppertainsTo(const Record ) {
+  return "is" + Subject.getName().str();
+}
+
 static std::string GenerateCustomAppertainsTo(const Record ,
   raw_ostream ) {
-  std::string FnName = "is" + Subject.getName().str();
+  std::string FnName = functionNameForCustomAppertainsTo(Subject);
 
   // If this code has already been generated, simply return the previous
   // instance of it.
@@ -2779,6 +2815,50 @@
   return FnName;
 }
 
+static void GenerateDefaultAppliesTo(raw_ostream ) {
+  OS << "static bool defaultAttributeAppliesTo(Sema &, const Decl *) {\n";
+  OS << "  return true;\n";
+  OS << "}\n\n";
+}
+
+static std::string GenerateAppliesTo(const Record , raw_ostream ) {
+  // If the attribute doesn't support '#pragma clang attribute' or if it doesn't
+  // contain a subjects definition, then use the default appliedTo logic.
+  if (!isSupportedByPragmaAttribute(Attr) || Attr.isValueUnset("Subjects"))
+return "defaultAttributeAppliesTo";
+
+  const Record *SubjectObj = Attr.getValueAsDef("Subjects");
+  std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
+
+  // If the list of subjects is empty, it is assumed that the attribute applies
+  // to everything.
+  if (Subjects.empty())
+return "defaultAttributeAppliesTo";
+
+  // Otherwise, generate an appliesTo check specific to this attribute which
+  // checks all of the given subjects against the Decl passed in. Return the
+  // name of that check to the caller.
+  std::string FnName = "check" + Attr.getName().str() + "AttributeAppliesTo";
+  std::stringstream SS;
+  SS << "static bool " << FnName << "(Sema , const Decl *D) {\n";
+  SS << "  return ";
+  for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
+// If the subject has custom code associated with it, use the function
+// that was generated for GenerateAppertainsTo to check if the declaration
+// is valid.
+if ((*I)->isSubClassOf("SubsetSubject"))
+  SS << functionNameForCustomAppertainsTo(**I) << "(D)";
+else
+  SS << "isa<" << GetSubjectWithSuffix(*I) << ">(D)";
+
+if (I + 1 != E)
+  SS << " || ";
+  }
+  SS << ";\n}\n\n";
+  OS << SS.str();
+  return FnName;
+}
+
 static void GenerateDefaultLangOptRequirements(raw_ostream ) {
   OS << "static bool defaultDiagnoseLangOpts(Sema &, ";
   OS << "const 

Re: [libcxx] r295330 - math: correct the MSVCRT condition

2017-02-16 Thread Andrey Khalyavin via cfe-commits
What is _VC_CRT_NAJOR_VERSION? Is it misprint or a hack? Google gives zero
results.

-- Andrey Khalyavin

On Thu, Feb 16, 2017 at 6:47 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Thu Feb 16 09:47:50 2017
> New Revision: 295330
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295330=rev
> Log:
> math: correct the MSVCRT condition
>
> Fixes a number of tests in the testsuite on Windows.
>
> Modified:
> libcxx/trunk/include/cmath
> libcxx/trunk/include/math.h
>
> Modified: libcxx/trunk/include/cmath
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> cmath?rev=295330=295329=295330=diff
> 
> ==
> --- libcxx/trunk/include/cmath (original)
> +++ libcxx/trunk/include/cmath Thu Feb 16 09:47:50 2017
> @@ -398,7 +398,7 @@ using ::cbrtf;
>  using ::copysign;
>  using ::copysignf;
>
> -#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_NAJOR_VERSION-0) >= 14)
> +#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>  using ::erf;
>  using ::erff;
>  using ::erfc;
> @@ -435,7 +435,7 @@ using ::lrint;
>  using ::lrintf;
>  using ::lround;
>  using ::lroundf;
> -#endif // _LIBCPP_MSVCRT
> +#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  using ::nan;
>  using ::nanf;
>
> Modified: libcxx/trunk/include/math.h
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/
> math.h?rev=295330=295329=295330=diff
> 
> ==
> --- libcxx/trunk/include/math.h (original)
> +++ libcxx/trunk/include/math.h Thu Feb 16 09:47:50 2017
> @@ -1020,7 +1020,7 @@ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NO
>  return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
>  }
>
> -#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
> +#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  // erf
>
> @@ -1404,7 +1404,7 @@ inline _LIBCPP_INLINE_VISIBILITY
>  typename std::enable_if::value, double>::type
>  trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
>
> -#endif // !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
> +#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
>
>  } // extern "C++"
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-16 Thread Taewook Oh via Phabricator via cfe-commits
twoh added inline comments.



Comment at: test/Lexer/case-insensitive-include-pr31836.sh:6
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+

karies wrote:
> @twoh Does that actually work on Linux? I thought (most?) Linux file systems 
> are case sensitive? I.e. I'd expect to get a "file not found" diag on the 
> `#include`.
This is an unsupported test on Linux because of REQUIRES: 
case-insensitive-filesystem.


https://reviews.llvm.org/D3



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


[PATCH] D30000: Fix for pr31836 - pp_nonportable_path on absolute paths: broken delimiters

2017-02-16 Thread Axel Naumann via Phabricator via cfe-commits
karies added inline comments.



Comment at: test/Lexer/case-insensitive-include-pr31836.sh:6
+// RUN: touch %T/case-insensitive-include-pr31836.h
+// RUN: echo "#include \"%T/Case-Insensitive-Include-Pr31836.h\"" | %clang_cc1 
-E - 2>&1 | FileCheck %s
+

@twoh Does that actually work on Linux? I thought (most?) Linux file systems 
are case sensitive? I.e. I'd expect to get a "file not found" diag on the 
`#include`.


https://reviews.llvm.org/D3



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


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

2017-02-16 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

@rjmccall

Hi John, I've made the changes to volatile.cpp.
I take it this patch is good for commit?


https://reviews.llvm.org/D24812



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

efriedma wrote:
> erichkeane wrote:
> > efriedma wrote:
> > > erichkeane wrote:
> > > > Clang-tidy created this layout here that I'm not thrilled with, if OK, 
> > > > I'd like to move the entirety of the 2nd component to the "&&" on its 
> > > > own line.  Additionally, if anyone has a better way to do this logic, 
> > > > I'm all ears!
> > > Why is this checking for MSVCCompat?  I think we want to detect 
> > > constructs like your testcase in all modes so we can generate a good 
> > > error message.
> > We get a good error message here ("typename missing") in normal mode.  The 
> > issue here is that the examples below work in MSVC's relaxed 'typename' 
> > situation, thus this should only be accepting code in MSVC mode, right?  Or 
> > am I missing something.
> This is what I see for the testcase in your commit message on trunk:
> 
> ```
> :7:4: error: expected ';' after expression
>   S::TD varname =0;
>^
>;
> :7:14: error: use of undeclared identifier 'varname'
>   S::TD varname =0;
>  ^
> :7:3: error: missing 'typename' prior to dependent type name 
> 'S::TD'
>   S::TD varname =0;
>   ^~
> :11:3: note: in instantiation of function template specialization 
> 'foo' requested here
>   foo();
>   ^
> 3 errors generated.
> ```
> 
> Technically speaking, we do get the "missing typename" message, but I still 
> wouldn't call this result "a good error message".
Ah, I see!  You're right, I got caught up in this a bunch.  I'll look to see if 
I can get both cases to be better.  Thanks!


https://reviews.llvm.org/D29401



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

erichkeane wrote:
> efriedma wrote:
> > erichkeane wrote:
> > > Clang-tidy created this layout here that I'm not thrilled with, if OK, 
> > > I'd like to move the entirety of the 2nd component to the "&&" on its own 
> > > line.  Additionally, if anyone has a better way to do this logic, I'm all 
> > > ears!
> > Why is this checking for MSVCCompat?  I think we want to detect constructs 
> > like your testcase in all modes so we can generate a good error message.
> We get a good error message here ("typename missing") in normal mode.  The 
> issue here is that the examples below work in MSVC's relaxed 'typename' 
> situation, thus this should only be accepting code in MSVC mode, right?  Or 
> am I missing something.
This is what I see for the testcase in your commit message on trunk:

```
:7:4: error: expected ';' after expression
  S::TD varname =0;
   ^
   ;
:7:14: error: use of undeclared identifier 'varname'
  S::TD varname =0;
 ^
:7:3: error: missing 'typename' prior to dependent type name 'S::TD'
  S::TD varname =0;
  ^~
:11:3: note: in instantiation of function template specialization 
'foo' requested here
  foo();
  ^
3 errors generated.
```

Technically speaking, we do get the "missing typename" message, but I still 
wouldn't call this result "a good error message".


https://reviews.llvm.org/D29401



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


[libcxx] r295355 - Update a couple of issue statuses

2017-02-16 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb 16 12:50:30 2017
New Revision: 295355

URL: http://llvm.org/viewvc/llvm-project?rev=295355=rev
Log:
Update a couple of issue statuses

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=295355=295354=295355=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Feb 16 12:50:30 2017
@@ -55,14 +55,14 @@
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3911;>N3911LWGTransformationTrait
 Alias 
void_t.UrbanaComplete3.6
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4089;>N4089LWGSafe
 conversions in unique_ptrT[].UrbanaIn 
progress3.9
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169;>N4169LWGA
 proposal to add invoke function 
templateUrbanaComplete3.7
-   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190;>N4190LWGRemoving
 auto_ptr, random_shuffle(), And Old  
Stuff.Urbana
+   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190;>N4190LWGRemoving
 auto_ptr, random_shuffle(), And Old  
Stuff.UrbanaIn progress
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4258;>N4258LWGCleaning-up
 noexcept in the Library.UrbanaIn 
progress3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4259;>N4259CWGWording
 for 
std::uncaught_exceptionsUrbanaComplete3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4277;>N4277LWGTriviallyCopyable
 
reference_wrapper.UrbanaComplete3.2
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4279;>N4279LWGImproved
 insertion interface for unique-key 
maps.UrbanaComplete3.7
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4280;>N4280LWGNon-member
 size() and moreUrbanaComplete3.6
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4284;>N4284LWGContiguous
 Iterators.UrbanaComplete3.6
-   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4285;>N4285CWGCleanup
 for exception-specification and 
throw-expression.Urbana
+   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4285;>N4285CWGCleanup
 for exception-specification and 
throw-expression.UrbanaComplete4.0

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387;>N4387LWGimproving
 pair and tupleLenexaComplete4.0
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4389;>N4389LWGbool_constantLenexaComplete3.7
@@ -417,7 +417,7 @@
 
   
 
-  Last Updated: 26-Jan-2017
+  Last Updated: 16-Feb-2017
 
 
 


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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

efriedma wrote:
> erichkeane wrote:
> > Clang-tidy created this layout here that I'm not thrilled with, if OK, I'd 
> > like to move the entirety of the 2nd component to the "&&" on its own line. 
> >  Additionally, if anyone has a better way to do this logic, I'm all ears!
> Why is this checking for MSVCCompat?  I think we want to detect constructs 
> like your testcase in all modes so we can generate a good error message.
We get a good error message here ("typename missing") in normal mode.  The 
issue here is that the examples below work in MSVC's relaxed 'typename' 
situation, thus this should only be accepting code in MSVC mode, right?  Or am 
I missing something.



Comment at: test/SemaCXX/MicrosoftCompatibility.cpp:222
+const A::TYPE var2 = 2; // expected-warning {{missing 'typename' prior 
to dependent type name}}
+A::TYPE var3 = 2; // expected-warning {{missing 'typename' prior to 
dependent type name}}
+MissingTypename::A::TYPE var4 = 2; // expected-warning {{missing 
'typename' prior to dependent type name}}

efriedma wrote:
> erichkeane wrote:
> > This is the line that previously failed.  Curiously, the one above and 
> > below seemed to succeed without this change.
> The first one is obviously a declaration because of the "const" keyword, so 
> we don't follow the same codepath.  I would guess the last one hits the 
> "Next.isNot(tok::coloncolon)" check in the if statment you're modifying.
> 
> A couple more related testcases:
> 
> ```
> A::TYPE const var3 = 2; // const after type
> A::TYPE *var3 = 2; // we can't tell this is invalid until the template is 
> instantiated
> ```
Ah, right!  I'll add those tests as well!


https://reviews.llvm.org/D29401



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Parse/ParseStmt.cpp:186
 // found.
-if (Next.isNot(tok::coloncolon)) {
+if (Next.isNot(tok::coloncolon) && (!getLangOpts().MSVCCompat ||
+Next.isNot(tok::less))) {

erichkeane wrote:
> Clang-tidy created this layout here that I'm not thrilled with, if OK, I'd 
> like to move the entirety of the 2nd component to the "&&" on its own line.  
> Additionally, if anyone has a better way to do this logic, I'm all ears!
Why is this checking for MSVCCompat?  I think we want to detect constructs like 
your testcase in all modes so we can generate a good error message.



Comment at: test/SemaCXX/MicrosoftCompatibility.cpp:222
+const A::TYPE var2 = 2; // expected-warning {{missing 'typename' prior 
to dependent type name}}
+A::TYPE var3 = 2; // expected-warning {{missing 'typename' prior to 
dependent type name}}
+MissingTypename::A::TYPE var4 = 2; // expected-warning {{missing 
'typename' prior to dependent type name}}

erichkeane wrote:
> This is the line that previously failed.  Curiously, the one above and below 
> seemed to succeed without this change.
The first one is obviously a declaration because of the "const" keyword, so we 
don't follow the same codepath.  I would guess the last one hits the 
"Next.isNot(tok::coloncolon)" check in the if statment you're modifying.

A couple more related testcases:

```
A::TYPE const var3 = 2; // const after type
A::TYPE *var3 = 2; // we can't tell this is invalid until the template is 
instantiated
```


https://reviews.llvm.org/D29401



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D30009#678890, @arphaman wrote:

> In https://reviews.llvm.org/D30009#678091, @hfinkel wrote:
>
> > I don't understand why it only supports some attributes. Is there some 
> > handling that needs to take place (I don't see anything obvious in this 
> > patch)? If most attributes will "just work", I'd much rather opt-out the 
> > few exceptions (which we can then explicitly document), if any, than using 
> > this opt-in solution.
>
>
> I think it would be reasonable to use an opt-out approach. I think the 
> following set of initial rules should determine when an attribute should not 
> be supported by the pragma:
>
> - If an attribute is late parsed
> - Or if it has no GNU/CXX11 spelling
> - Or if it has no subject list, or its subject list is empty (excluding 
> annotate)
> - Or if it derives from StmtAttr or TypeAttr


SGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D30009#678091, @hfinkel wrote:

> I don't understand why it only supports some attributes. Is there some 
> handling that needs to take place (I don't see anything obvious in this 
> patch)? If most attributes will "just work", I'd much rather opt-out the few 
> exceptions (which we can then explicitly document), if any, than using this 
> opt-in solution.


I think it would be reasonable to use an opt-out approach. I think the 
following set of initial rules should determine when an attribute should not be 
supported by the pragma:

- If an attribute is late parsed
- Or if it has no GNU/CXX11 spelling
- Or if it has no subject list, or its subject list is empty (excluding 
annotate)
- Or if it derives from StmtAttr or TypeAttr


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D29530



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


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thoughts?


https://reviews.llvm.org/D29401



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


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Hi guys-
Since this is a rework of Vlad's changes, I'm not sure you noticed that this 
was a different review!  Anyone have opinions?  Additionally, I had 1 question 
in SemaDecl.cpp that I think was right, otherwise I hope this is a pretty light 
review.


https://reviews.llvm.org/D28266



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-02-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@rsmith  did you ever get a chance to re-review this?  Is this what you were 
wanting for this?


https://reviews.llvm.org/D27486



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


Re: D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-16 Thread Hans Wennborg via cfe-commits
I've merged it in r295340.

Cheers,
Hans

On Thu, Feb 16, 2017 at 6:26 AM, Anastasia Stulova
 wrote:
> Hans, could we merge this documentation only change (r295313) in release40 
> branch. I can commit myself if needed. :)
>
> Thanks in advance,
> Anastasia
>
> -Original Message-
> From: Anastasia Stulova via Phabricator [mailto:revi...@reviews.llvm.org]
> Sent: 16 February 2017 14:15
> To: Anastasia Stulova; yaxun@amd.com
> Cc: cfe-commits@lists.llvm.org
> Subject: [PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor 
> extension in user manual
>
> Anastasia closed this revision.
> Anastasia added a comment.
>
> Committed in 295313!
>
>
> https://reviews.llvm.org/D29829
>
>
>
> IMPORTANT NOTICE: The contents of this email and any attachments are 
> confidential and may also be privileged. If you are not the intended 
> recipient, please notify the sender immediately and do not disclose the 
> contents to any other person, use it for any purpose, or store or copy the 
> information in any medium. Thank you.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295335: [OpenMP] Teams reduction on the NVPTX device. 
(authored by arpith).

Changed prior to commit:
  https://reviews.llvm.org/D29879?vs=88715=88746#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29879

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -3553,10 +3553,14 @@
 OMPPrivateScope PrivateScope(CGF);
 (void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
 CGF.EmitOMPPrivateClause(S, PrivateScope);
+CGF.EmitOMPReductionClauseInit(S, PrivateScope);
 (void)PrivateScope.Privatize();
 CGF.EmitStmt(cast(S.getAssociatedStmt())->getCapturedStmt());
+CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   emitCommonOMPTeamsDirective(*this, S, OMPD_teams, CodeGen);
+  emitPostUpdateForReductionClause(
+  *this, S, [](CodeGenFunction &) -> llvm::Value * { return nullptr; });
 }
 
 static void emitTargetTeamsRegion(CodeGenFunction , PrePostActionTy ,
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -56,6 +56,16 @@
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
   OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
+  /// \brief Call to __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+  /// int32_t num_vars, size_t reduce_size, void *reduce_data,
+  /// void (*kmp_ShuffleReductFctPtr)(void *rhs, int16_t lane_id, int16_t
+  /// lane_offset, int16_t shortCircuit),
+  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+  /// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+  /// int32_t index, int32_t width),
+  /// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad, int32_t
+  /// index, int32_t width, int32_t reduce))
+  OMPRTL_NVPTX__kmpc_teams_reduce_nowait,
   /// \brief Call to __kmpc_nvptx_end_reduce_nowait(int32_t global_tid);
   OMPRTL_NVPTX__kmpc_end_reduce_nowait
 };
@@ -125,6 +135,9 @@
   /// computed as log_2(WarpSize).
   LaneIDBits = 5,
   LaneIDMask = WarpSize - 1,
+
+  /// Global memory alignment for performance.
+  GlobalMemoryAlignment = 256,
 };
 
 enum NamedBarrier : unsigned {
@@ -694,6 +707,49 @@
 FnTy, /*Name=*/"__kmpc_nvptx_parallel_reduce_nowait");
 break;
   }
+  case OMPRTL_NVPTX__kmpc_teams_reduce_nowait: {
+// Build int32_t __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+// int32_t num_vars, size_t reduce_size, void *reduce_data,
+// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
+// lane_offset, int16_t shortCircuit),
+// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width),
+// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width, int32_t reduce))
+llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
+ CGM.Int16Ty, CGM.Int16Ty};
+auto *ShuffleReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, ShuffleReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *InterWarpCopyTypeParams[] = {CGM.VoidPtrTy, CGM.Int32Ty};
+auto *InterWarpCopyFnTy =
+llvm::FunctionType::get(CGM.VoidTy, InterWarpCopyTypeParams,
+/*isVarArg=*/false);
+llvm::Type *CopyToScratchpadTypeParams[] = {CGM.VoidPtrTy, CGM.VoidPtrTy,
+CGM.Int32Ty, CGM.Int32Ty};
+auto *CopyToScratchpadFnTy =
+llvm::FunctionType::get(CGM.VoidTy, CopyToScratchpadTypeParams,
+/*isVarArg=*/false);
+llvm::Type *LoadReduceTypeParams[] = {
+CGM.VoidPtrTy, CGM.VoidPtrTy, CGM.Int32Ty, CGM.Int32Ty, CGM.Int32Ty};
+auto *LoadReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, LoadReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *TypeParams[] = {CGM.Int32Ty,
+CGM.Int32Ty,
+CGM.SizeTy,
+CGM.VoidPtrTy,
+ShuffleReduceFnTy->getPointerTo(),
+InterWarpCopyFnTy->getPointerTo(),
+CopyToScratchpadFnTy->getPointerTo(),
+LoadReduceFnTy->getPointerTo()};
+  

r295335 - [OpenMP] Teams reduction on the NVPTX device.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 10:48:49 2017
New Revision: 295335

URL: http://llvm.org/viewvc/llvm-project?rev=295335=rev
Log:
[OpenMP] Teams reduction on the NVPTX device.

This patch implements codegen for the reduction clause on
any teams construct for elementary data types.  It builds
on parallel reductions on the GPU.  Subsequently,
the team master writes to a unique location in a global
memory scratchpad.  The last team to do so loads and
reduces this array to calculate the final result.

This patch emits two helper functions that are used by
the OpenMP runtime on the GPU to perform reductions across
teams.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29879

Added:
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=295335=295334=295335=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Feb 16 10:48:49 2017
@@ -56,6 +56,16 @@ enum OpenMPRTLFunctionNVPTX {
   /// lane_offset, int16_t shortCircuit),
   /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num));
   OMPRTL_NVPTX__kmpc_parallel_reduce_nowait,
+  /// \brief Call to __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+  /// int32_t num_vars, size_t reduce_size, void *reduce_data,
+  /// void (*kmp_ShuffleReductFctPtr)(void *rhs, int16_t lane_id, int16_t
+  /// lane_offset, int16_t shortCircuit),
+  /// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+  /// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+  /// int32_t index, int32_t width),
+  /// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad, 
int32_t
+  /// index, int32_t width, int32_t reduce))
+  OMPRTL_NVPTX__kmpc_teams_reduce_nowait,
   /// \brief Call to __kmpc_nvptx_end_reduce_nowait(int32_t global_tid);
   OMPRTL_NVPTX__kmpc_end_reduce_nowait
 };
@@ -125,6 +135,9 @@ enum MachineConfiguration : unsigned {
   /// computed as log_2(WarpSize).
   LaneIDBits = 5,
   LaneIDMask = WarpSize - 1,
+
+  /// Global memory alignment for performance.
+  GlobalMemoryAlignment = 256,
 };
 
 enum NamedBarrier : unsigned {
@@ -694,6 +707,49 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 FnTy, /*Name=*/"__kmpc_nvptx_parallel_reduce_nowait");
 break;
   }
+  case OMPRTL_NVPTX__kmpc_teams_reduce_nowait: {
+// Build int32_t __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid,
+// int32_t num_vars, size_t reduce_size, void *reduce_data,
+// void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t
+// lane_offset, int16_t shortCircuit),
+// void (*kmp_InterWarpCopyFctPtr)(void* src, int32_t warp_num),
+// void (*kmp_CopyToScratchpadFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width),
+// void (*kmp_LoadReduceFctPtr)(void *reduce_data, void * scratchpad,
+// int32_t index, int32_t width, int32_t reduce))
+llvm::Type *ShuffleReduceTypeParams[] = {CGM.VoidPtrTy, CGM.Int16Ty,
+ CGM.Int16Ty, CGM.Int16Ty};
+auto *ShuffleReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, ShuffleReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *InterWarpCopyTypeParams[] = {CGM.VoidPtrTy, CGM.Int32Ty};
+auto *InterWarpCopyFnTy =
+llvm::FunctionType::get(CGM.VoidTy, InterWarpCopyTypeParams,
+/*isVarArg=*/false);
+llvm::Type *CopyToScratchpadTypeParams[] = {CGM.VoidPtrTy, CGM.VoidPtrTy,
+CGM.Int32Ty, CGM.Int32Ty};
+auto *CopyToScratchpadFnTy =
+llvm::FunctionType::get(CGM.VoidTy, CopyToScratchpadTypeParams,
+/*isVarArg=*/false);
+llvm::Type *LoadReduceTypeParams[] = {
+CGM.VoidPtrTy, CGM.VoidPtrTy, CGM.Int32Ty, CGM.Int32Ty, CGM.Int32Ty};
+auto *LoadReduceFnTy =
+llvm::FunctionType::get(CGM.VoidTy, LoadReduceTypeParams,
+/*isVarArg=*/false);
+llvm::Type *TypeParams[] = {CGM.Int32Ty,
+CGM.Int32Ty,
+CGM.SizeTy,
+CGM.VoidPtrTy,
+ShuffleReduceFnTy->getPointerTo(),
+InterWarpCopyFnTy->getPointerTo(),
+CopyToScratchpadFnTy->getPointerTo(),
+LoadReduceFnTy->getPointerTo()};
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg=*/false);
+

r295333 - [OpenMP] Parallel reduction on the NVPTX device.

2017-02-16 Thread Arpith Chacko Jacob via cfe-commits
Author: arpith
Date: Thu Feb 16 10:20:16 2017
New Revision: 295333

URL: http://llvm.org/viewvc/llvm-project?rev=295333=rev
Log:
[OpenMP] Parallel reduction on the NVPTX device.

This patch implements codegen for the reduction clause on
any parallel construct for elementary data types.  An efficient
implementation requires hierarchical reduction within a
warp and a threadblock.  It is complicated by the fact that
variables declared in the stack of a CUDA thread cannot be
shared with other threads.

The patch creates a struct to hold reduction variables and
a number of helper functions.  The OpenMP runtime on the GPU
implements reduction algorithms that uses these helper
functions to perform reductions within a team.  Variables are
shared between CUDA threads using shuffle intrinsics.

An implementation of reductions on the NVPTX device is
substantially different to that of CPUs.  However, this patch
is written so that there are minimal changes to the rest of
OpenMP codegen.

The implemented design allows the compiler and runtime to be
decoupled, i.e., the runtime does not need to know of the
reduction operation(s), the type of the reduction variable(s),
or the number of reductions.  The design also allows reuse of
host codegen, with appropriate specialization for the NVPTX
device.

While the patch does introduce a number of abstractions, the
expected use case calls for inlining of the GPU OpenMP runtime.
After inlining and optimizations in LLVM, these abstractions
are unwound and performance of OpenMP reductions is comparable
to CUDA-canonical code.

Patch by Tian Jin in collaboration with Arpith Jacob

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29758

Added:
cfe/trunk/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295333=295332=295333=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Feb 16 10:20:16 2017
@@ -4257,12 +4257,10 @@ static void emitReductionCombiner(CodeGe
   CGF.EmitIgnoredExpr(ReductionOp);
 }
 
-static llvm::Value *emitReductionFunction(CodeGenModule ,
-  llvm::Type *ArgsType,
-  ArrayRef Privates,
-  ArrayRef LHSExprs,
-  ArrayRef RHSExprs,
-  ArrayRef ReductionOps) 
{
+llvm::Value *CGOpenMPRuntime::emitReductionFunction(
+CodeGenModule , llvm::Type *ArgsType, ArrayRef Privates,
+ArrayRef LHSExprs, ArrayRef RHSExprs,
+ArrayRef ReductionOps) {
   auto  = CGM.getContext();
 
   // void reduction_func(void *LHSArg, void *RHSArg);
@@ -4345,11 +4343,11 @@ static llvm::Value *emitReductionFunctio
   return Fn;
 }
 
-static void emitSingleReductionCombiner(CodeGenFunction ,
-const Expr *ReductionOp,
-const Expr *PrivateRef,
-const DeclRefExpr *LHS,
-const DeclRefExpr *RHS) {
+void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction ,
+  const Expr *ReductionOp,
+  const Expr *PrivateRef,
+  const DeclRefExpr *LHS,
+  const DeclRefExpr *RHS) {
   if (PrivateRef->getType()->isArrayType()) {
 // Emit reduction for array section.
 auto *LHSVar = cast(LHS->getDecl());
@@ -4369,9 +4367,13 @@ void CGOpenMPRuntime::emitReduction(Code
 ArrayRef LHSExprs,
 ArrayRef RHSExprs,
 ArrayRef ReductionOps,
-bool WithNowait, bool SimpleReduction) {
+ReductionOptionsTy Options) {
   if (!CGF.HaveInsertPoint())
 return;
+
+  bool WithNowait = Options.WithNowait;
+  bool SimpleReduction = Options.SimpleReduction;
+
   // Next code should be emitted for reduction:
   //
   // static kmp_critical_name lock = { 0 };
@@ -4513,12 +4515,13 @@ void CGOpenMPRuntime::emitReduction(Code
   };
   auto & = [, , , ](
   CodeGenFunction , PrePostActionTy ) {
+auto  = CGF.CGM.getOpenMPRuntime();
 auto IPriv = Privates.begin();
 auto ILHS = LHSExprs.begin();
 auto 

[libcxx] r295329 - threading_support: make __thread_sleep_for be alertable

2017-02-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Feb 16 09:47:45 2017
New Revision: 295329

URL: http://llvm.org/viewvc/llvm-project?rev=295329=rev
Log:
threading_support: make __thread_sleep_for be alertable

On Windows, we were using `Sleep` which is not alertable.  This means
that if the thread was used for a user APC or WinProc handling and
thread::sleep was used, we could potentially dead lock.  Use `SleepEx`
with an alertable sleep, resuming until the time has expired if we are
awoken early.

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=295329=295328=295329=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Feb 16 09:47:45 2017
@@ -589,11 +589,14 @@ void __libcpp_thread_yield()
 
 void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
 {
-  using namespace chrono;
+  using namespace _VSTD::chrono;
+
   // round-up to the nearest milisecond
   milliseconds __ms =
   duration_cast(__ns + chrono::nanoseconds(99));
-  Sleep(__ms.count());
+  auto start = system_clock::now();
+  while (::SleepEx((__ms - (system_clock::now() - start)).count(),
+   TRUE) == WAIT_IO_COMPLETION);
 }
 
 // Thread Local Storage


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


[libcxx] r295330 - math: correct the MSVCRT condition

2017-02-16 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Feb 16 09:47:50 2017
New Revision: 295330

URL: http://llvm.org/viewvc/llvm-project?rev=295330=rev
Log:
math: correct the MSVCRT condition

Fixes a number of tests in the testsuite on Windows.

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=295330=295329=295330=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Thu Feb 16 09:47:50 2017
@@ -398,7 +398,7 @@ using ::cbrtf;
 using ::copysign;
 using ::copysignf;
 
-#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_NAJOR_VERSION-0) >= 14)
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 using ::erf;
 using ::erff;
 using ::erfc;
@@ -435,7 +435,7 @@ using ::lrint;
 using ::lrintf;
 using ::lround;
 using ::lroundf;
-#endif // _LIBCPP_MSVCRT
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 using ::nan;
 using ::nanf;

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=295330=295329=295330=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Thu Feb 16 09:47:50 2017
@@ -1020,7 +1020,7 @@ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NO
 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
 }
 
-#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 // erf
 
@@ -1404,7 +1404,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
 trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
 
-#endif // !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 } // extern "C++"
 


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


Re: r291905 - [Sema] Add warning for unused lambda captures

2017-02-16 Thread Aaron Ballman via cfe-commits
On Wed, Feb 15, 2017 at 7:42 PM, Richard Smith via cfe-commits
 wrote:
> https://bugs.llvm.org/show_bug.cgi?id=31977 makes the good point that this
> is warning on a certain idiomatic use of capture-by-value to extend the
> lifetime of an RAII object; consider:
>
>   shared_ptr p = /*...*/;
>   int *q = >n;
>   return [=, p] { return *q++; }
>
> Here, we'll warn that the capture of p is unused, but it's not -- the "use"
> is to hold a reference to keep the Foo object alive.
>
> I'd suggest suppressing the warning for a by-copy capture of a variable with
> a non-trivial destructor (this mirrors what we do for -Wunused-variable).

Thank you for the compelling example -- I agree, that's a good
solution to the issue.

~Aaron

>
> On 13 January 2017 at 07:01, Malcolm Parsons via cfe-commits
>  wrote:
>>
>> Author: malcolm.parsons
>> Date: Fri Jan 13 09:01:06 2017
>> New Revision: 291905
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291905=rev
>> Log:
>> [Sema] Add warning for unused lambda captures
>>
>> Summary:
>> Warn when a lambda explicitly captures something that is not used in its
>> body.
>>
>> The warning is part of -Wunused and can be enabled with
>> -Wunused-lambda-capture.
>>
>> Reviewers: rsmith, arphaman, jbcoe, aaron.ballman
>>
>> Subscribers: Quuxplusone, arphaman, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D28467
>>
>> Added:
>> cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/ScopeInfo.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/lib/Sema/SemaLambda.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
>> cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
>> cfe/trunk/test/SemaCXX/uninitialized.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=291905=291904=291905=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06
>> 2017
>> @@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
>>  def UnusedMemberFunction : DiagGroup<"unused-member-function",
>>   [UnneededMemberFunction]>;
>>  def UnusedLabel : DiagGroup<"unused-label">;
>> +def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
>>  def UnusedParameter : DiagGroup<"unused-parameter">;
>>  def UnusedResult : DiagGroup<"unused-result">;
>>  def PotentiallyEvaluatedExpression :
>> DiagGroup<"potentially-evaluated-expression">;
>> @@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
>> [UnusedArgument, UnusedFunction, UnusedLabel,
>>  // UnusedParameter, (matches GCC's behavior)
>>  // UnusedMemberFunction, (clean-up llvm before
>> enabling)
>> -UnusedPrivateField, UnusedLocalTypedef,
>> -UnusedValue, UnusedVariable,
>> UnusedPropertyIvar]>,
>> +UnusedPrivateField, UnusedLambdaCapture,
>> +UnusedLocalTypedef, UnusedValue, UnusedVariable,
>> +UnusedPropertyIvar]>,
>>  DiagCategory<"Unused Entity Issue">;
>>
>>  // Format settings.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291905=291904=291905=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13
>> 09:01:06 2017
>> @@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
>>InGroup, DefaultIgnore;
>>  def warn_unused_private_field: Warning<"private field %0 is not used">,
>>InGroup, DefaultIgnore;
>> +def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
>> +  "%select{used|required to be captured for use in an unevaluated
>> context}1">,
>> +  InGroup, DefaultIgnore;
>>
>>  def warn_parameter_size: Warning<
>>"%0 is a large (%1 bytes) pass-by-value argument; "
>>
>> Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
>> URL:
>> 

[PATCH] D30045: Remove `std::random_shuffle` in C++17

2017-02-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190  removed 
`random_shuffle` from C++1z. (and other stuff)

Wrap all the random_shuffle bits in an #ifdef so they disappear when compiling 
with `-std=c++1z` or later.

Introduce a new configuration option, 
`_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE` which allows user code to 
continue using `random_shuffle` in C++1z mode if desired.

Add a test for `_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE`, and mark all the 
rest of the `random_shuffle` tests to XFAIL for c++1z


https://reviews.llvm.org/D30045

Files:
  include/algorithm
  
test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
  
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp

Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
===
--- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
+++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 // template Rand>
 //   requires ShuffleIterator
Index: test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
===
--- test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 // 
+// REQUIRES-ANY: c++98, c++03, c++11, c++14
 
 // template
 //   requires ShuffleIterator
Index: test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
===
--- test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
+++ test/libcxx/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
@@ -0,0 +1,46 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+// 
+// template 
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+//RandomNumberGenerator& rand);
+
+//
+//  In C++17, random_shuffle has been removed.
+//  However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+//  is defined before including , then random_shuffle will be restored.
+
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+
+#include 
+#include 
+
+struct gen
+{
+std::ptrdiff_t operator()(std::ptrdiff_t n)
+{
+return n-1;
+}
+};
+
+
+int main()
+{
+std::vector v;
+std::random_shuffle(v.begin(), v.end());
+gen r;
+std::random_shuffle(v.begin(), v.end(), r);
+}
Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -281,12 +281,12 @@
 
 template 
 void
-random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
+random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
 
 template 
 void
 random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
-   RandomNumberGenerator& rand);  // deprecated in C++14
+   RandomNumberGenerator& rand);  // deprecated in C++14, removed in C++17
 
 template
@@ -3026,6 +3026,7 @@
 return static_cast(__u + __p.a());
 }
 
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE)
 class _LIBCPP_TYPE_VIS __rs_default;
 
 _LIBCPP_FUNC_VIS __rs_default __rs_get();
@@ -3095,6 +3096,7 @@
 }
 }
 }
+#endif
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28172: [libcxx] Remove unexpected handlers in C++17

2017-02-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Sorry for the slow response.


https://reviews.llvm.org/D28172



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


  1   2   >