Re: [clang-tools-extra] r318809 - Silence some MSVC warnings about not all control paths returning a value; NFC.

2017-11-22 Thread Kim Gräsman via cfe-commits
Den 21 nov. 2017 11:24 em skrev "Aaron Ballman via cfe-commits" <
cfe-commits@lists.llvm.org>:

Author: aaronballman
Date: Tue Nov 21 14:24:13 2017
New Revision: 318809

URL: http://llvm.org/viewvc/llvm-project?rev=318809=rev
Log:
Silence some MSVC warnings about not all control paths returning a value;
NFC.

Modified:
clang-tools-extra/trunk/clangd/JSONExpr.cpp
clang-tools-extra/trunk/clangd/JSONExpr.h

Modified: clang-tools-extra/trunk/clangd/JSONExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
trunk/clangd/JSONExpr.cpp?rev=318809=318808=318809=diff

==
--- clang-tools-extra/trunk/clangd/JSONExpr.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONExpr.cpp Tue Nov 21 14:24:13 2017
@@ -519,6 +519,7 @@ bool operator==(const Expr , const Exp
   case Expr::Object:
 return *L.object() == *R.object();
   }
+  llvm_unreachable("Unknown expressiopn kind");


Typo: expressiopn. Though it *is* unreachable :)

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


[PATCH] D40381: Parse concept definition

2017-11-22 Thread changyu via Phabricator via cfe-commits
changyu added a comment.

I should add that this depends on

https://reviews.llvm.org/D40380


https://reviews.llvm.org/D40381



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


[libcxx] r318897 - Add additional 'UNSUPPORTED' to the test case.

2017-11-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 22 21:43:25 2017
New Revision: 318897

URL: http://llvm.org/viewvc/llvm-project?rev=318897=rev
Log:
Add additional 'UNSUPPORTED' to the test case.

Modified:
libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp

Modified: libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp?rev=318897=318896=318897=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp (original)
+++ libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp Wed Nov 
22 21:43:25 2017
@@ -8,7 +8,8 @@
 
//===--===//
 //
 // UNSUPPORTED: libcpp-has-no-threads
-// UNSUPPORTED: c++98, c++03
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
 
 // 
 


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


[PATCH] D40013: [DeclPrinter] Allow printing fully qualified name of function declaration

2017-11-22 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318896: [DeclPrinter] Allow printing fully qualified name of 
function declaration (authored by sepavloff).

Repository:
  rL LLVM

https://reviews.llvm.org/D40013

Files:
  cfe/trunk/include/clang/AST/PrettyPrinter.h
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Index: cfe/trunk/include/clang/AST/PrettyPrinter.h
===
--- cfe/trunk/include/clang/AST/PrettyPrinter.h
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h
@@ -51,7 +51,8 @@
   TerseOutput(false), PolishForDeclaration(false),
   Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
   IncludeNewlines(true), MSVCFormatting(false),
-  ConstantsAsWritten(false), SuppressImplicitBase(false) { }
+  ConstantsAsWritten(false), SuppressImplicitBase(false),
+  FullyQualifiedName(false) { }
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -220,6 +221,10 @@
 
   /// When true, don't print the implicit 'self' or 'this' expressions.
   bool SuppressImplicitBase : 1;
+
+  /// When true, print the fully qualified name of function declarations.
+  /// This is the opposite of SuppressScope and thus overrules it.
+  bool FullyQualifiedName : 1;
 };
 
 } // end namespace clang
Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -580,13 +580,19 @@
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto;
-  if (!Policy.SuppressScope) {
-if (const NestedNameSpecifier *NS = D->getQualifier()) {
-  llvm::raw_string_ostream OS(Proto);
-  NS->print(OS, Policy);
+
+  if (Policy.FullyQualifiedName) {
+Proto += D->getQualifiedNameAsString();
+  } else {
+if (!Policy.SuppressScope) {
+  if (const NestedNameSpecifier *NS = D->getQualifier()) {
+llvm::raw_string_ostream OS(Proto);
+NS->print(OS, Policy);
+  }
 }
+Proto += D->getNameInfo().getAsString();
   }
-  Proto += D->getNameInfo().getAsString();
+
   if (GuideDecl)
 Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
   if (const TemplateArgumentList *TArgs = D->getTemplateSpecializationArgs()) {
Index: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
===
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp
@@ -104,15 +104,17 @@
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult PrintedDeclCXX98Matches(StringRef Code,
-   StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult
+PrintedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+StringRef ExpectedPrinted,
+PrintingPolicyModifier PolicyModifier = nullptr) {
   std::vector Args(1, "-std=c++98");
   return PrintedDeclMatches(Code,
 Args,
 namedDecl(hasName(DeclName)).bind("id"),
 ExpectedPrinted,
-"input.cc");
+"input.cc",
+PolicyModifier);
 }
 
 ::testing::AssertionResult
@@ -350,6 +352,47 @@
 "void A()"));
 }
 
+TEST(DeclPrinter, TestFreeFunctionDecl_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "void A();",
+  "A",
+  "void A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, TestFreeFunctionDeclInNamespace_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "namespace X { void A(); };",
+  "A",
+  "void X::A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, TestMemberFunction_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "struct X { void A(); };",
+  "A",
+  "void X::A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, TestMemberFunctionInNamespace_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "namespace Z { struct X { void A(); }; }",
+  "A",
+  "void Z::X::A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, TestMemberFunctionOutside_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "struct X { void A(); };"
+   "void X::A() {}",
+  functionDecl(hasName("A"), isDefinition()).bind("id"),
+  "void X::A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
 TEST(DeclPrinter, TestFunctionDecl2) {
  

r318896 - [DeclPrinter] Allow printing fully qualified name of function declaration

2017-11-22 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Nov 22 21:38:20 2017
New Revision: 318896

URL: http://llvm.org/viewvc/llvm-project?rev=318896=rev
Log:
[DeclPrinter] Allow printing fully qualified name of function declaration

When requesting a tooltip for a function call in an IDE, the fully
qualified name helps to remove ambiguity in the function signature.

Patch by Nikolai Kosjar!

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

Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=318896=318895=318896=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Wed Nov 22 21:38:20 2017
@@ -51,7 +51,8 @@ struct PrintingPolicy {
   TerseOutput(false), PolishForDeclaration(false),
   Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
   IncludeNewlines(true), MSVCFormatting(false),
-  ConstantsAsWritten(false), SuppressImplicitBase(false) { }
+  ConstantsAsWritten(false), SuppressImplicitBase(false),
+  FullyQualifiedName(false) { }
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -220,6 +221,10 @@ struct PrintingPolicy {
 
   /// When true, don't print the implicit 'self' or 'this' expressions.
   bool SuppressImplicitBase : 1;
+
+  /// When true, print the fully qualified name of function declarations.
+  /// This is the opposite of SuppressScope and thus overrules it.
+  bool FullyQualifiedName : 1;
 };
 
 } // end namespace clang

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=318896=318895=318896=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed Nov 22 21:38:20 2017
@@ -580,13 +580,19 @@ void DeclPrinter::VisitFunctionDecl(Func
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto;
-  if (!Policy.SuppressScope) {
-if (const NestedNameSpecifier *NS = D->getQualifier()) {
-  llvm::raw_string_ostream OS(Proto);
-  NS->print(OS, Policy);
+
+  if (Policy.FullyQualifiedName) {
+Proto += D->getQualifiedNameAsString();
+  } else {
+if (!Policy.SuppressScope) {
+  if (const NestedNameSpecifier *NS = D->getQualifier()) {
+llvm::raw_string_ostream OS(Proto);
+NS->print(OS, Policy);
+  }
 }
+Proto += D->getNameInfo().getAsString();
   }
-  Proto += D->getNameInfo().getAsString();
+
   if (GuideDecl)
 Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
   if (const TemplateArgumentList *TArgs = D->getTemplateSpecializationArgs()) {

Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=318896=318895=318896=diff
==
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Wed Nov 22 21:38:20 2017
@@ -104,15 +104,17 @@ PrintedDeclMatches(StringRef Code, const
   return ::testing::AssertionSuccess();
 }
 
-::testing::AssertionResult PrintedDeclCXX98Matches(StringRef Code,
-   StringRef DeclName,
-   StringRef ExpectedPrinted) {
+::testing::AssertionResult
+PrintedDeclCXX98Matches(StringRef Code, StringRef DeclName,
+StringRef ExpectedPrinted,
+PrintingPolicyModifier PolicyModifier = nullptr) {
   std::vector Args(1, "-std=c++98");
   return PrintedDeclMatches(Code,
 Args,
 namedDecl(hasName(DeclName)).bind("id"),
 ExpectedPrinted,
-"input.cc");
+"input.cc",
+PolicyModifier);
 }
 
 ::testing::AssertionResult
@@ -350,6 +352,47 @@ TEST(DeclPrinter, TestFunctionDecl1) {
 "void A()"));
 }
 
+TEST(DeclPrinter, TestFreeFunctionDecl_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "void A();",
+  "A",
+  "void A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, TestFreeFunctionDeclInNamespace_FullyQualifiedName) {
+ASSERT_TRUE(PrintedDeclCXX98Matches(
+  "namespace X { void A(); };",
+  "A",
+  "void X::A()",
+  [](PrintingPolicy ){ Policy.FullyQualifiedName = true; }));
+}
+
+TEST(DeclPrinter, 

[PATCH] D40381: Parse concept definition

2017-11-22 Thread changyu via Phabricator via cfe-commits
changyu created this revision.

Per p0734r0.


https://reviews.llvm.org/D40381

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/TemplateKinds.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclTemplate.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReaderDecl.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5906,6 +5906,7 @@
   case Decl::PragmaComment:
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
+  case Decl::Concept:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -1,7 +1,7 @@
 
 // Support parsing of concepts
-// Disabled for now.
-// expected-no-diagnostics
 
 // RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
-// template concept C1 = true;
+template concept C1 = true;
+
+template concept D1 = true; // expected-error {{expected template parameter}}
Index: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
@@ -0,0 +1,5 @@
+// RUN:  %clang_cc1 -std=c++1z -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
+// expected-no-diagnostics
+
+template concept C = true;
+static_assert(C);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -337,6 +337,7 @@
 void VisitBindingDecl(BindingDecl *BD);
 void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
 DeclID VisitTemplateDecl(TemplateDecl *D);
+void VisitConceptDecl(ConceptDecl *D);
 RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
 void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D);
@@ -1970,6 +1971,10 @@
   return PatternID;
 }
 
+void ASTDeclReader::VisitConceptDecl(ConceptDecl *D) {
+  VisitTemplateDecl(D);
+}
+
 ASTDeclReader::RedeclarableResult
 ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarable(D);
Index: lib/Serialization/ASTCommon.cpp
===
--- lib/Serialization/ASTCommon.cpp
+++ lib/Serialization/ASTCommon.cpp
@@ -313,6 +313,7 @@
   case Decl::BuiltinTemplate:
   case Decl::Decomposition:
   case Decl::Binding:
+  case Decl::Concept:
 return false;
 
   // These indirectly derive from Redeclarable but are not actually
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3095,6 +3095,11 @@
   return nullptr;
 }
 
+Decl *TemplateDeclInstantiator::VisitConceptDecl(ConceptDecl *D) {
+  // TODO: Do something here?
+  return nullptr;
+}
+
 Decl *TemplateDeclInstantiator::VisitDecl(Decl *D) {
   llvm_unreachable("Unexpected decl");
 }
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -232,9 +232,11 @@
 } else {
   assert(isa(TD) || isa(TD) ||
  isa(TD) || isa(TD) ||
- isa(TD));
+ isa(TD) || isa(TD));
   TemplateKind =
-  isa(TD) ? TNK_Var_template : TNK_Type_template;
+  isa(TD) ? TNK_Var_template :
+  isa(TD) ? TNK_Concept_template :
+  TNK_Type_template;
 }
   }
 
@@ -3884,6 +3886,24 @@
   /*FoundD=*/nullptr, TemplateArgs);
 }
 
+ExprResult
+Sema::CheckConceptTemplateId(const CXXScopeSpec ,
+ const DeclarationNameInfo ,
+ ConceptDecl *Template, SourceLocation TemplateLoc,
+ const TemplateArgumentListInfo *TemplateArgs) {
+
+  // DeclResult Decl = CheckVarTemplateId(Template, TemplateLoc, NameInfo.getLoc(),
+  //  *TemplateArgs);
+  // if (Decl.isInvalid())
+  //   return ExprError();
+
+  // // Build an ordinary singleton decl ref.
+  // return BuildDeclarationNameExpr(SS, NameInfo, cast(Decl.get()),
+  //   

[PATCH] D40284: [Sema] Improve diagnostics for template arg deduction

2017-11-22 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 124033.
jtbandes added a comment.

@erik.pilkington Updated to use a wrapper function. This is definitely less 
invasive, but it could defeat some optimizations (any approach that checks the 
return value will defeat tail recursion, I suppose...)


https://reviews.llvm.org/D40284

Files:
  lib/Sema/SemaTemplateDeduction.cpp
  test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp


Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
===
--- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
+++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
@@ -45,3 +45,11 @@
 func(foo()); // expected-error {{no matching function}}
   }
 }
+
+namespace test4 {
+  // expected-note@+1 {{candidate template ignored: could not match 'int [N]' 
against 'int []'}}
+  template void f1(int ()[N]);
+  template void f2(int ()[]) {
+f1(arr); // expected-error {{no matching function}}
+  }
+}
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1056,6 +1056,12 @@
   return false;
 }
 
+static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatchInner(
+Sema , TemplateParameterList *TemplateParams, QualType ParamIn,
+QualType ArgIn, TemplateDeductionInfo ,
+SmallVectorImpl , unsigned TDF,
+bool PartialOrdering, bool DeducedFromArrayBound);
+
 /// \brief Deduce the template arguments by comparing the parameter type and
 /// the argument type (C++ [temp.deduct.type]).
 ///
@@ -1080,15 +1086,34 @@
 /// \returns the result of template argument deduction so far. Note that a
 /// "success" result means that template argument deduction has not yet failed,
 /// but it may still fail, later, for other reasons.
-static Sema::TemplateDeductionResult
-DeduceTemplateArgumentsByTypeMatch(Sema ,
-   TemplateParameterList *TemplateParams,
-   QualType ParamIn, QualType ArgIn,
-   TemplateDeductionInfo ,
-SmallVectorImpl ,
-   unsigned TDF,
-   bool PartialOrdering,
-   bool DeducedFromArrayBound) {
+static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(
+Sema , TemplateParameterList *TemplateParams, QualType ParamIn,
+QualType ArgIn, TemplateDeductionInfo ,
+SmallVectorImpl , unsigned TDF,
+bool PartialOrdering, bool DeducedFromArrayBound) {
+  // Because DeduceTemplateArgumentsByTypeMatchInner is recursive, and tends to
+  // modify Info.FirstArg and SecondArg even when deduction succeeds, save the
+  // original values and restore them if no error occurred.
+  const auto OriginalFirstArg = Info.FirstArg;
+  const auto OriginalSecondArg = Info.SecondArg;
+
+  const auto Result = DeduceTemplateArgumentsByTypeMatchInner(
+  S, TemplateParams, ParamIn, ArgIn, Info, Deduced, TDF, PartialOrdering,
+  DeducedFromArrayBound);
+
+  if (Result == Sema::TDK_Success) {
+Info.FirstArg = OriginalFirstArg;
+Info.SecondArg = OriginalSecondArg;
+  }
+  return Result;
+}
+
+/// \see DeduceTemplateArgumentsByTypeMatch()
+static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatchInner(
+Sema , TemplateParameterList *TemplateParams, QualType ParamIn,
+QualType ArgIn, TemplateDeductionInfo ,
+SmallVectorImpl , unsigned TDF,
+bool PartialOrdering, bool DeducedFromArrayBound) {
   // We only want to look at the canonical types, since typedefs and
   // sugar are not part of template argument deduction.
   QualType Param = S.Context.getCanonicalType(ParamIn);


Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
===
--- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
+++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
@@ -45,3 +45,11 @@
 func(foo()); // expected-error {{no matching function}}
   }
 }
+
+namespace test4 {
+  // expected-note@+1 {{candidate template ignored: could not match 'int [N]' against 'int []'}}
+  template void f1(int ()[N]);
+  template void f2(int ()[]) {
+f1(arr); // expected-error {{no matching function}}
+  }
+}
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1056,6 +1056,12 @@
   return false;
 }
 
+static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatchInner(
+Sema , TemplateParameterList *TemplateParams, QualType ParamIn,
+QualType ArgIn, TemplateDeductionInfo ,
+SmallVectorImpl , unsigned TDF,
+bool 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-22 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:230
+  std::vector LocationVector;
+  auto test = Items->Value;
+

remove



Comment at: clangd/ClangdLSPServer.cpp:236
+
+  C.reply(json::ary(LocationVector));
 }

I think you can just do Items->Value here and not have LocationVector at all.



Comment at: clangd/ClangdLSPServer.cpp:251
+  Position{Params.position.line, Params.position.character});
+  if (!H)
+return C.replyError(ErrorCode::InvalidParams,

I think we should return an empty Hover here and not an error. Since the empty 
Hover is already generated, this would mean simply removing those two lines.



Comment at: clangd/ClangdServer.cpp:11
 #include "ClangdServer.h"
+#include "Protocol.h"
 #include "clang/Format/Format.h"

Remove include?



Comment at: clangd/ClangdServer.cpp:432
 ClangdServer::findDefinitions(PathRef File, Position Pos) {
+
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);

revert



Comment at: clangd/ClangdServer.cpp:447
   });
+
   return make_tagged(std::move(Result), TaggedFS.Tag);

revert



Comment at: clangd/ClangdServer.cpp:517
+  Range DefaultRange = {BeginPosition, EndPosition};
+  Hover FinalHover = {EmptyVector, DefaultRange};
+

I think you remove all default values and just do 
Hover FinalHover;



Comment at: clangd/ClangdServer.cpp:527
+  return;
+// Only show hover for the first found definition, we could potentially
+// expand this in a later patch.

I don't think this comment belong here anymore?



Comment at: clangd/ClangdUnit.cpp:1187
+  } else if (auto ClassDecl = dyn_cast(LocationDecl)) {
+if (!ClassDecl->isInterface() && !ClassDecl->isUnion() &&
+ClassDecl->isThisDeclarationADefinition())

what's wrong with interface and union?



Comment at: clangd/ClangdUnit.cpp:1246
+  Contexts.push_back(Ctx);
+  Ctx = Ctx->getParent();
+}

Ctx is never used so you can remove lines 1231 to 1247



Comment at: clangd/ClangdUnit.cpp:942
 
 /// Finds declarations locations that a given source location refers to.
 class DeclarationLocationsFinder : public index::IndexDataConsumer {

This comment isn't accurate anymore.



Comment at: clangd/ClangdUnit.cpp:943
 /// Finds declarations locations that a given source location refers to.
 class DeclarationLocationsFinder : public index::IndexDataConsumer {
+  std::vector DeclarationDecls;

I think this should be renamed, it doesn't find locations for declarations 
anymore. I don't know what to call it, hmmm DeclOrMacroAtLocationFinder? :)



Comment at: clangd/ClangdUnit.cpp:944
 class DeclarationLocationsFinder : public index::IndexDataConsumer {
-  std::vector DeclarationLocations;
+  std::vector DeclarationDecls;
+  std::vector DeclarationMacroInfs;

just Decls?



Comment at: clangd/ClangdUnit.cpp:945
+  std::vector DeclarationDecls;
+  std::vector DeclarationMacroInfs;
   const SourceLocation 

just MacroInfos?



Comment at: clangd/ClangdUnit.cpp:986
 
+  std::vector getDeclarationDecls() { return DeclarationDecls; };
+  std::vector getMacroInfos() {

I don't think that getter is necessary, only use the take



Comment at: clangd/ClangdUnit.cpp:987
+  std::vector getDeclarationDecls() { return DeclarationDecls; };
+  std::vector getMacroInfos() {
+return DeclarationMacroInfs;

I don't think that getter is necessary, only use the take



Comment at: clangd/ClangdUnit.cpp:1044
+  Location L;
+  if (const FileEntry *F =
+  SourceMgr.getFileEntryForID(SourceMgr.getFileID(LocStart))) {

It looks like this sometimes return null and we don't handle this well. Need to 
investigate this more though. See later comment.



Comment at: clangd/ClangdUnit.cpp:1086
+  for (auto Item : MacroInfos) {
+SourceRange SR =
+SourceRange(Item->getDefinitionLoc(), Item->getDefinitionEndLoc());

You can omit the "= SourceRange"



Comment at: clangd/ClangdUnit.cpp:1102
+  Range DefaultRange = {BeginPosition, EndPosition};
+  Hover H = {EmptyVector, DefaultRange};
+  unsigned Start, End;

you can remove the lines before, just
"Hover H;" is OK
Range is optional and the vector is already initialized to empty.



Comment at: clangd/ClangdUnit.cpp:1103
+  Hover H = {EmptyVector, DefaultRange};
+  unsigned Start, End;
+  StringRef Ref;

I think those should be declared where they are 

[libcxx] r318889 - Add [[nodiscard]] to std::async as part of P0600.

2017-11-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 22 17:25:03 2017
New Revision: 318889

URL: http://llvm.org/viewvc/llvm-project?rev=318889=rev
Log:
Add [[nodiscard]] to std::async as part of P0600.

Added:
libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp
Modified:
libcxx/trunk/include/future
libcxx/trunk/include/new

Modified: libcxx/trunk/include/future
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=318889=31=318889=diff
==
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Wed Nov 22 17:25:03 2017
@@ -2335,6 +2335,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __
 { return (int(__policy) & int(__value)) != 0; }
 
 template 
+_LIBCPP_NODISCARD_AFTER_CXX17
 future::type, typename 
decay<_Args>::type...>::type>
 async(launch __policy, _Fp&& __f, _Args&&... __args)
 {
@@ -2360,7 +2361,7 @@ async(launch __policy, _Fp&& __f, _Args&
 }
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 future::type, typename 
decay<_Args>::type...>::type>
 async(_Fp&& __f, _Args&&... __args)
 {

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=318889=31=318889=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Wed Nov 22 17:25:03 2017
@@ -271,7 +271,7 @@ template 
 _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
 constexpr _Tp* launder(_Tp* __p) noexcept
 {
-return __launder(__p);
+return _VSTD::__launder(__p);
 }
 #endif
 

Added: libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp?rev=318889=auto
==
--- libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp (added)
+++ libcxx/trunk/test/std/thread/futures/futures.async/async.fail.cpp Wed Nov 
22 17:25:03 2017
@@ -0,0 +1,37 @@
+//===--===//
+//
+// 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: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// template 
+// future::type>
+// async(F&& f, Args&&... args);
+
+// template 
+// future::type>
+// async(launch policy, F&& f, Args&&... args);
+
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int foo (int x) { return x; }
+
+int main ()
+{
+   std::async(foo, 3); // expected-error {{ignoring 
return value of function declared with 'nodiscard' attribute}}
+   std::async(std::launch::async, foo, 3); // expected-error {{ignoring 
return value of function declared with 'nodiscard' attribute}}
+}
\ No newline at end of file


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


r318888 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Nov 22 17:20:07 2017
New Revision: 31

URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=31=318887=31=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Nov 22 17:20:07 2017
@@ -1,4 +1,4 @@
-//===--- ASTContext.h - Context to hold long-lived AST nodes *- C++ 
-*-===//
+//===- ASTContext.h - Context to hold long-lived AST nodes --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -6,10 +6,10 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-///
+//
 /// \file
 /// \brief Defines the clang::ASTContext interface.
-///
+//
 
//===--===//
 
 #ifndef LLVM_CLANG_AST_ASTCONTEXT_H
@@ -19,8 +19,8 @@
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -30,10 +30,9 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Linkage.h"
-#include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SanitizerBlacklist.h"
@@ -46,17 +45,17 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
@@ -66,7 +65,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -76,49 +74,72 @@ namespace llvm {
 
 struct fltSemantics;
 
-} // end namespace llvm
+} // namespace llvm
 
 namespace clang {
 
+class APValue;
 class ASTMutationListener;
 class ASTRecordLayout;
 class AtomicExpr;
 class BlockExpr;
+class BuiltinTemplateDecl;
 class CharUnits;
 class CXXABI;
+class CXXConstructorDecl;
+class CXXMethodDecl;
+class CXXRecordDecl;
 class DiagnosticsEngine;
 class Expr;
+class MangleContext;
 class MangleNumberingContext;
 class MaterializeTemporaryExpr;
-// Decls
-class MangleContext;
+class MemberSpecializationInfo;
+class Module;
+class ObjCCategoryDecl;
+class ObjCCategoryImplDecl;
+class ObjCContainerDecl;
+class ObjCImplDecl;
+class ObjCImplementationDecl;
+class ObjCInterfaceDecl;
 class ObjCIvarDecl;
+class ObjCMethodDecl;
 class ObjCPropertyDecl;
+class ObjCPropertyImplDecl;
+class ObjCProtocolDecl;
+class ObjCTypeParamDecl;
+class Preprocessor;
+class Stmt;
+class StoredDeclsMap;
+class TemplateDecl;
+class TemplateParameterList;
+class TemplateTemplateParmDecl;
+class TemplateTypeParmDecl;
 class UnresolvedSetIterator;
-class UsingDecl;
 class UsingShadowDecl;
+class VarTemplateDecl;
 class VTableContextBase;
 
 namespace Builtin {
 
-  class Context;
+class Context;
 
-} // end namespace Builtin
+} // namespace Builtin
 
 enum BuiltinTemplateKind : int;
 
 namespace comments {
 
-  class FullComment;
+class FullComment;
 
-} // end namespace comments
+} // namespace comments
 
 struct TypeInfo {
-  uint64_t Width;
-  unsigned Align;
+  uint64_t Width = 0;
+  unsigned Align = 0;
   bool AlignIsRequired : 1;
 
-  TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}
+  TypeInfo() : AlignIsRequired(false) {}
   TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
   : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
 };
@@ -126,7 +147,7 @@ struct TypeInfo {
 /// \brief Holds long-lived AST nodes (such as types and decls) that can be
 /// referred to throughout the semantic analysis of a file.
 class ASTContext : public RefCountedBase {
-  ASTContext _() { return *this; }
+  friend 

[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-22 Thread William Enright via Phabricator via cfe-commits
Nebiroth added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:108
   Logger.log("Failed to find compilation database for " + Twine(File) +
- "in overriden directory " + CompileCommandsDir.getValue() +
+ " in overriden directory " + CompileCommandsDir.getValue() +
  "\n");

ilya-biryukov wrote:
> Accidental change?
Twine(File) and "in overriden directory" did not have a space to separate 
otherwise.


https://reviews.llvm.org/D39571



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2017-11-22 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 124024.
Nebiroth marked 19 inline comments as done.
Nebiroth added a comment.

Fixed DraftStore thread-safe API being broken
Removed superfluous getCompilationDatabase call
Changed name of struct to ClangDConfigurationParamsChange
Removed operator ! overload for struct
Minor code cleanup


https://reviews.llvm.org/D39571

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/did-change-configuration.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -18,6 +18,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:  "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -48,4 +49,4 @@
 # CHECK-NEXT:  "result": null
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -1,3 +1,4 @@
+
 # RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
 # It is absolutely vital that this file has CRLF line endings.
 #
@@ -18,6 +19,7 @@
 # CHECK-NEXT:  ":"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:  "configurationChangeProvider": true,
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
@@ -45,4 +47,4 @@
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
 Content-Length: 33
 
-{"jsonrpc":"2.0":"method":"exit"}
+{"jsonrpc":"2.0":"method":"exit"}
\ No newline at end of file
Index: test/clangd/did-change-configuration.test
===
--- /dev/null
+++ test/clangd/did-change-configuration.test
@@ -0,0 +1,46 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 150
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"voidmain(){}"}}}
+
+Content-Length: 86
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":""}}
+#Failed to decode workspace/didChangeConfiguration request.
+#Incorrect mapping node
+
+Content-Length: 114
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":{
+#Failed to decode workspace/didChangeConfiguration request.
+#compilationDatabasePath is not a scalar node
+
+Content-Length: 140
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/","testBadValue":"foo1234"}}}
+#Ignored unknown field "testBadValue"
+#Failed to find compilation database for / in overriden directory /
+#Bad field, bad compilation database
+
+Content-Length: 722
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///compile_commands.json","languageId":"json","version":1,"text":"[\n{\n"directory":"/",\n"command":"/usr/bin/c++-DGTEST_HAS_RTTI=0-D_GNU_SOURCE-D__STDC_CONSTANT_MACROS-D__STDC_FORMAT_MACROS-D__STDC_LIMIT_MACROS-Ilib/Demangle-I../lib/Demangle-I/usr/include/libxml2-Iinclude-I../include-fPIC-fvisibility-inlines-hidden-Werror=date-time-std=c++11-Wall-W-Wno-unused-parameter-Wwrite-strings-Wcast-qual-Wno-missing-field-initializers-pedantic-Wno-long-long-Wno-maybe-uninitialized-Wdelete-non-virtual-dtor-Wno-comment-O0-g-fno-exceptions-fno-rtti-o/foo.c.o-c/foo.c",\n"file":"/foo.c"\n},"}}}
+
+Content-Length: 115
+
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabasePath":"/"}}}
+#CHECK:{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"type specifier missing, defaults to 'int'","range":{"end":{"character":1,"line":0},"start":{"character":1,"line":0}},"severity":2},{"message":"control reaches end of non-void 

[PATCH] D40284: [Sema] Improve diagnostics for template arg deduction

2017-11-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

This looks correct, but I definitely agree that RAII would make this a lot 
nicer. Have you considered adding a `CancelableSaveAndRestore` or something to 
SaveAndRestore.h? It seems useful and generic enough to make it worthwhile. 
Otherwise, you could just write your own RAII object special-cased to handle 
this. A less intrusive way of doing this might be to wrap calls to this 
function with another that checks if the return value is TDK_Success, and if so 
restores these fields.




Comment at: lib/Sema/SemaTemplateDeduction.cpp:1376
   if (const ComplexType *ComplexArg = Arg->getAs())
 return DeduceTemplateArgumentsByTypeMatch(S, TemplateParams,
 cast(Param)->getElementType(),

What if this return TDK_Success?


https://reviews.llvm.org/D40284



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


[PATCH] D40325: add new check to find OSSpinlock usage

2017-11-22 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 124011.
Wizard marked an inline comment as done.
Wizard added a comment.

fix nit


https://reviews.llvm.org/D40325

Files:
  clang-tidy/objc/AvoidSpinlockCheck.cpp
  clang-tidy/objc/AvoidSpinlockCheck.h
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-avoid-spinlock.rst
  test/clang-tidy/objc-avoid-spinlock.m

Index: test/clang-tidy/objc-avoid-spinlock.m
===
--- /dev/null
+++ test/clang-tidy/objc-avoid-spinlock.m
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s objc-avoid-spinlock %t
+
+typedef int OSSpinLock;
+void OSSpinlockTry(OSSpinLock *__lock) {}
+
+@implementation Foo
+- (void)f {
+int i = 1;
+OSSpinlockLock();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: OSSpinlock is deprecated on iOS. Please use other locks or dispatch queue. [objc-avoid-spinlock]
+OSSpinlockTry();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: OSSpinlock is deprecated on iOS. Please use other locks or dispatch queue. [objc-avoid-spinlock]
+OSSpinlockUnlock();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: OSSpinlock is deprecated on iOS. Please use other locks or dispatch queue. [objc-avoid-spinlock]
+}
+@end
Index: docs/clang-tidy/checks/objc-avoid-spinlock.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-avoid-spinlock.rst
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - objc-avoid-spinlock
+
+objc-avoid-spinlock
+===
+
+Finds usages of OSSpinlock in Objective-C files, which is deprecated due to potential
+livelock problems. 
+
+This check will detect following function invocations:
+
+- `OSSpinlockLock`
+- `OSSpinlockTry`
+- `OSSpinlockUnlcok`
+
+The corresponding information about the problem of OSSpinlock: https://blog.postmates.com/why-spinlocks-are-bad-on-ios-b69fc5221058
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -175,6 +175,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-avoid-spinlock
objc-forbidden-subclassing
objc-property-declaration
performance-faster-string-find
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-avoid-spinlock
+  `_ check
+
+  Add new check to detect the use of OSSpinlock in Objective-C files.
+
 - New `google-avoid-throwing-objc-exception
   `_ check
 
Index: clang-tidy/objc/ObjCTidyModule.cpp
===
--- clang-tidy/objc/ObjCTidyModule.cpp
+++ clang-tidy/objc/ObjCTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "AvoidSpinlockCheck.h"
 #include "ForbiddenSubclassingCheck.h"
 #include "PropertyDeclarationCheck.h"
 
@@ -22,6 +23,8 @@
 class ObjCModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"objc-avoid-spinlock");
 CheckFactories.registerCheck(
 "objc-forbidden-subclassing");
 CheckFactories.registerCheck(
Index: clang-tidy/objc/CMakeLists.txt
===
--- clang-tidy/objc/CMakeLists.txt
+++ clang-tidy/objc/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyObjCModule
+  AvoidSpinlockCheck.cpp
   ForbiddenSubclassingCheck.cpp
   ObjCTidyModule.cpp
   PropertyDeclarationCheck.cpp
Index: clang-tidy/objc/AvoidSpinlockCheck.h
===
--- /dev/null
+++ clang-tidy/objc/AvoidSpinlockCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidSpinlockCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace objc {
+
+/// Finds usages of OSSpinlock in Objective-C files, which is deprecated due to
+/// potential livelock problems.
+///
+/// For the user-facing documentation see:
+/// 

r318882 - [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2017-11-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Nov 22 13:32:07 2017
New Revision: 318882

URL: http://llvm.org/viewvc/llvm-project?rev=318882=rev
Log:
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other 
minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=318882=318881=318882=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Nov 22 13:32:07 2017
@@ -1,4 +1,4 @@
-//===--- DeclObjC.h - Classes for representing declarations -*- C++ 
-*-===//
+//===- DeclObjC.h - Classes for representing declarations ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,33 +15,59 @@
 #define LLVM_CLANG_AST_DECLOBJC_H
 
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
+#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/Redeclarable.h"
 #include "clang/AST/SelectorLocationsKind.h"
+#include "clang/AST/Type.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/TrailingObjects.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 namespace clang {
+
+class ASTContext;
+class CompoundStmt;
+class CXXCtorInitializer;
 class Expr;
-class Stmt;
-class FunctionDecl;
-class RecordDecl;
-class ObjCIvarDecl;
-class ObjCMethodDecl;
-class ObjCProtocolDecl;
 class ObjCCategoryDecl;
+class ObjCCategoryImplDecl;
+class ObjCImplementationDecl;
+class ObjCInterfaceDecl;
+class ObjCIvarDecl;
 class ObjCPropertyDecl;
 class ObjCPropertyImplDecl;
-class CXXCtorInitializer;
+class ObjCProtocolDecl;
+class Stmt;
 
 class ObjCListBase {
-  ObjCListBase(const ObjCListBase &) = delete;
-  void operator=(const ObjCListBase &) = delete;
 protected:
   /// List is an array of pointers to objects that are not owned by this 
object.
-  void **List;
-  unsigned NumElts;
+  void **List = nullptr;
+  unsigned NumElts = 0;
 
 public:
-  ObjCListBase() : List(nullptr), NumElts(0) {}
+  ObjCListBase() = default;
+  ObjCListBase(const ObjCListBase &) = delete;
+  ObjCListBase =(const ObjCListBase &) = delete;
+
   unsigned size() const { return NumElts; }
   bool empty() const { return NumElts == 0; }
 
@@ -49,7 +75,6 @@ protected:
   void set(void *const* InList, unsigned Elts, ASTContext );
 };
 
-
 /// ObjCList - This is a simple template class used to hold various lists of
 /// decls etc, which is heavily used by the ObjC front-end.  This only use case
 /// this supports is setting the list all at once and then reading elements out
@@ -61,7 +86,8 @@ public:
 ObjCListBase::set(reinterpret_cast(InList), Elts, Ctx);
   }
 
-  typedef T* const * iterator;
+  using iterator = T* const *;
+
   iterator begin() const { return (iterator)List; }
   iterator end() const { return (iterator)List+NumElts; }
 
@@ -74,14 +100,15 @@ public:
 /// \brief A list of Objective-C protocols, along with the source
 /// locations at which they were referenced.
 class ObjCProtocolList : public ObjCList {
-  SourceLocation *Locations;
+  SourceLocation *Locations = nullptr;
 
   using ObjCList::set;
 
 public:
-  ObjCProtocolList() : ObjCList(), Locations(nullptr) { }
+  ObjCProtocolList() = default;
+
+  using loc_iterator = const SourceLocation *;
 
-  typedef const SourceLocation *loc_iterator;
   loc_iterator loc_begin() const { return Locations; }
   loc_iterator loc_end() const { return Locations + size(); }
 
@@ -89,7 +116,6 @@ public:
const SourceLocation *Locs, ASTContext );
 };
 
-
 /// ObjCMethodDecl - Represents an instance or class method declaration.
 /// ObjC methods can be declared within 4 contexts: class interfaces,
 /// categories, protocols, and class implementations. While C++ member
@@ -113,6 +139,7 @@ public:
 class ObjCMethodDecl : public NamedDecl, public DeclContext {
 public:
   enum ImplementationControl { None, Required, Optional };
+
 private:
   // The conventional meaning of this method; an ObjCMethodFamily.
   // This is not serialized; instead, it is computed on demand and
@@ -170,8 +197,8 @@ private:
 
   /// \brief Array of ParmVarDecls for the formal parameters of this method
   /// and optionally followed by selector locations.
-  void *ParamsAndSelLocs;
-  unsigned NumParams;
+  void *ParamsAndSelLocs = nullptr;
+  unsigned NumParams = 0;
 
   /// List of attributes for this method 

[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

@rjmccall : are you OK with this approach? If VLA is not supported by the 
target, CUDA is handled as a special case so it can emit deferred diag, OpenMP 
reports an error only if shouldDiagnoseTargetSupportFromOpenMP() allows it, and 
everything else does so unconditionally.


https://reviews.llvm.org/D40275



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


[PATCH] D40284: [Sema] Improve diagnostics for template arg deduction

2017-11-22 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a reviewer: rsmith.
jtbandes added a subscriber: rsmith.
jtbandes added a comment.

Adding @rsmith for review based on the commit history of 
SemaTemplateDeduction.cpp :)


https://reviews.llvm.org/D40284



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


r318881 - [OPENMP] Add support for cancel constructs in `target teams distribute

2017-11-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 22 13:12:03 2017
New Revision: 318881

URL: http://llvm.org/viewvc/llvm-project?rev=318881=rev
Log:
[OPENMP] Add support for cancel constructs in `target teams distribute
parallel for`.

Add support for cancel/cancellation point directives inside `target
teams distribute parallel for` directives.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_ast_print.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=318881=318880=318881=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Nov 22 13:12:03 2017
@@ -957,8 +957,13 @@ public:
T->getStmtClass() == OMPTargetSimdDirectiveClass ||
T->getStmtClass() == OMPTeamsDistributeDirectiveClass ||
T->getStmtClass() == OMPTeamsDistributeSimdDirectiveClass ||
-   T->getStmtClass() == 
OMPTeamsDistributeParallelForSimdDirectiveClass ||
-   T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass;
+   T->getStmtClass() ==
+   OMPTeamsDistributeParallelForSimdDirectiveClass ||
+   T->getStmtClass() == OMPTeamsDistributeParallelForDirectiveClass ||
+   T->getStmtClass() ==
+   OMPTargetTeamsDistributeParallelForDirectiveClass ||
+   T->getStmtClass() ==
+   OMPTargetTeamsDistributeParallelForSimdDirectiveClass;
   }
 };
 
@@ -3799,6 +3804,8 @@ public:
 class OMPTargetTeamsDistributeParallelForDirective final
 : public OMPLoopDirective {
   friend class ASTStmtReader;
+  /// true if the construct has inner cancel directive.
+  bool HasCancel = false;
 
   /// Build directive with the given start and end location.
   ///
@@ -3814,7 +3821,8 @@ class OMPTargetTeamsDistributeParallelFo
   : OMPLoopDirective(this,
  OMPTargetTeamsDistributeParallelForDirectiveClass,
  OMPD_target_teams_distribute_parallel_for, StartLoc,
- EndLoc, CollapsedNum, NumClauses) {}
+ EndLoc, CollapsedNum, NumClauses),
+HasCancel(false) {}
 
   /// Build an empty directive.
   ///
@@ -3826,7 +3834,11 @@ class OMPTargetTeamsDistributeParallelFo
   : OMPLoopDirective(
 this, OMPTargetTeamsDistributeParallelForDirectiveClass,
 OMPD_target_teams_distribute_parallel_for, SourceLocation(),
-SourceLocation(), CollapsedNum, NumClauses) {}
+SourceLocation(), CollapsedNum, NumClauses),
+HasCancel(false) {}
+
+  /// Set cancel state.
+  void setHasCancel(bool Has) { HasCancel = Has; }
 
 public:
   /// Creates directive with a list of \a Clauses.
@@ -3838,11 +3850,12 @@ public:
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement, associated with the directive.
   /// \param Exprs Helper expressions for CodeGen.
+  /// \param HasCancel true if this directive has inner cancel directive.
   ///
   static OMPTargetTeamsDistributeParallelForDirective *
   Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
  unsigned CollapsedNum, ArrayRef Clauses,
- Stmt *AssociatedStmt, const HelperExprs );
+ Stmt *AssociatedStmt, const HelperExprs , bool HasCancel);
 
   /// Creates an empty directive with the place for \a NumClauses clauses.
   ///
@@ -3854,6 +3867,9 @@ public:
   CreateEmpty(const ASTContext , unsigned NumClauses, unsigned CollapsedNum,
   EmptyShell);
 
+  /// Return true if current directive has inner cancel directive.
+  bool hasCancel() const { return HasCancel; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() ==
OMPTargetTeamsDistributeParallelForDirectiveClass;

Modified: cfe/trunk/lib/AST/StmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtOpenMP.cpp?rev=318881=318880=318881=diff
==
--- cfe/trunk/lib/AST/StmtOpenMP.cpp (original)
+++ cfe/trunk/lib/AST/StmtOpenMP.cpp Wed Nov 22 13:12:03 2017
@@ -1624,7 +1624,7 @@ OMPTargetTeamsDistributeParallelForDirec
 OMPTargetTeamsDistributeParallelForDirective::Create(
 const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
 unsigned CollapsedNum, ArrayRef Clauses, Stmt *AssociatedStmt,
-const HelperExprs ) {
+const HelperExprs , bool HasCancel) {
   auto Size =
   llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
 alignof(OMPClause *));
@@ -1670,6 

[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-22 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo updated this revision to Diff 124005.
K-ballo added a comment.

Back to `decltype`-based SFINAE.


https://reviews.llvm.org/D40259

Files:
  include/__functional_base
  include/functional
  
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
  test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp

Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 class functor1
 {
@@ -41,4 +42,19 @@
 test(i);
 const int j = 0;
 test(j);
+
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_constructible::value), "");
+static_assert((!std::is_constructible::value), "");
+static_assert((!std::is_constructible::value), "");
+}
+
+#if TEST_STD_VER >= 11
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_nothrow_constructible::value), "");
+static_assert((!std::is_nothrow_constructible::value), "");
+}
+#endif
 }
Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
@@ -0,0 +1,82 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template 
+//   reference_wrapper(U&&) noexcept(see below);
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+
+struct convertible_to_int_ref {
+int val = 0;
+operator int&() { return val; }
+operator int const&() const { return val; }
+};
+
+template 
+struct nothrow_convertible {
+int val = 0;
+operator int&() noexcept(IsNothrow) { return val; }
+};
+
+struct convertible_from_int {
+convertible_from_int(int) {}
+};
+
+void meow(std::reference_wrapper) {}
+void meow(convertible_from_int) {}
+
+int gi;
+std::reference_wrapper purr() { return gi; };
+
+template 
+void
+test(T& t)
+{
+std::reference_wrapper r(t);
+assert(() == );
+}
+
+void f() {}
+
+int main()
+{
+convertible_to_int_ref convi;
+test(convi);
+convertible_to_int_ref const convic;
+test(convic);
+
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_nothrow_constructible::value), "");
+static_assert((!std::is_nothrow_constructible::value), "");
+}
+
+{
+meow(0);
+(true) ? purr() : 0;
+}
+
+#ifdef __cpp_deduction_guides
+{
+int i = 0;
+std::reference_wrapper ri(i);
+static_assert((std::is_same::value), "" );
+const int j = 0;
+std::reference_wrapper rj(j);
+static_assert((std::is_same::value), "" );
+}
+#endif
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template 
+//   reference_wrapper(U&&) noexcept(see below);
+
+// UNSUPPORTED: c++98, c++03
+
+#include 
+#include 
+
+struct convertible_to_float_ref {
+float val = 0;
+operator float const&() const { return val; }
+};
+
+int main()
+{
+convertible_to_float_ref convf;
+std::reference_wrapper r(convf);
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
+++ test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -15,11 +15,18 @@
 
 #include 
 #include 
+#include 
 
 

[PATCH] D40279: [libcxxabi][demangler] Add demangling for __attribute__((abi_tag))

2017-11-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318874: [demangler] Support for abi_tag attribute (authored 
by epilk).

Changed prior to commit:
  https://reviews.llvm.org/D40279?vs=123787=124003#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40279

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

Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -184,6 +184,7 @@
 KConversionOperatorType,
 KPostfixQualifiedType,
 KNameType,
+KAbiTagAttr,
 KObjCProtoName,
 KPointerType,
 KLValueReferenceType,
@@ -390,6 +391,21 @@
   void printLeft(OutputStream ) const override { s += Name; }
 };
 
+class AbiTagAttr final : public Node {
+  const Node* Base;
+  StringView Tag;
+public:
+  AbiTagAttr(const Node* Base_, StringView Tag_)
+  : Node(KAbiTagAttr), Base(Base_), Tag(Tag_) {}
+
+  void printLeft(OutputStream ) const override {
+Base->printLeft(S);
+S += "[abi:";
+S += Tag;
+S += "]";
+  }
+};
+
 class ObjCProtoName : public Node {
   Node *Ty;
   Node *Protocol;
@@ -1801,10 +1817,9 @@
 return first;
 }
 
-//  ::=  
-
+//  ::= [0-9]*
 const char*
-parse_source_name(const char* first, const char* last, Db& db)
+parse_positive_integer(const char* first, const char* last, size_t* out)
 {
 if (first != last)
 {
@@ -1819,15 +1834,53 @@
 if (++t == last)
 return first;
 }
-if (static_cast(last - t) >= n)
-{
-StringView r(t, t + n);
-if (r.substr(0, 10) == "_GLOBAL__N")
-db.Names.push_back(db.make("(anonymous namespace)"));
-else
-db.Names.push_back(db.make(r));
-first = t + n;
-}
+*out = n;
+first = t;
+}
+}
+return first;
+}
+
+// extension
+//  ::= *
+//  ::= B  
+const char*
+parse_abi_tag_seq(const char* first, const char* last, Db& db)
+{
+while (first != last && *first == 'B' && first+1 != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first+1, last, );
+if (t == first+1)
+return first;
+if (static_cast(last - t) < length || db.Names.empty())
+return first;
+db.Names.back() = db.make(
+db.Names.back(), StringView(t, t + length));
+first = t + length;
+}
+return first;
+}
+
+//  ::=   []
+const char*
+parse_source_name(const char* first, const char* last, Db& db)
+{
+if (first != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first, last, );
+if (t == first)
+return first;
+if (static_cast(last - t) >= length)
+{
+StringView r(t, t + length);
+if (r.substr(0, 10) == "_GLOBAL__N")
+db.Names.push_back(db.make("(anonymous namespace)"));
+else
+db.Names.push_back(db.make(r));
+first = t + length;
+first = parse_abi_tag_seq(first, last, db);
 }
 }
 return first;
@@ -3763,10 +3816,11 @@
 //   ::= rs# >>
 //   ::= rS# >>=   
 //   ::= v  # vendor extended operator
-
+//   extension   ::=  
 const char*
 parse_operator_name(const char* first, const char* last, Db& db)
 {
+const char* original_first = first;
 if (last - first >= 2)
 {
 switch (first[0])
@@ -4063,6 +4117,10 @@
 break;
 }
 }
+
+if (original_first != first)
+first = parse_abi_tag_seq(first, last, db);
+
 return first;
 }
 
@@ -4299,7 +4357,7 @@
 //  ::= D1# complete object destructor
 //  ::= D2# base object destructor
 //   extension  ::= D5# ?
-
+//   extension  ::=  
 const char*
 parse_ctor_dtor_name(const char* first, const char* last, Db& db)
 {
@@ -4321,6 +4379,7 @@
 db.Names.push_back(
 db.make(db.Names.back(), false));
 first += 2;
+first = parse_abi_tag_seq(first, last, db);
 db.ParsedCtorDtorCV = true;
 break;
 }
@@ -4337,6 +4396,7 @@
 db.Names.push_back(
 db.make(db.Names.back(), true));
 first += 2;
+first = parse_abi_tag_seq(first, last, db);
 db.ParsedCtorDtorCV = true;
 break;
 }
@@ -4346,13 +4406,12 @@
 return first;
 }
 
-//  ::= Ut [  ] _
+//  ::= Ut [] _ []
 // ::= 
 // 
 //  ::= Ul  E [  ] _ 
 // 
 //  ::= +  # Parameter types or "v" if the lambda has no parameters
-
 const char*

[libcxxabi] r318874 - [demangler] Support for abi_tag attribute

2017-11-22 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Wed Nov 22 12:38:22 2017
New Revision: 318874

URL: http://llvm.org/viewvc/llvm-project?rev=318874=rev
Log:
[demangler] Support for abi_tag attribute

Differential revision: https://reviews.llvm.org/D40279

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

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=318874=318873=318874=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Wed Nov 22 12:38:22 2017
@@ -184,6 +184,7 @@ public:
 KConversionOperatorType,
 KPostfixQualifiedType,
 KNameType,
+KAbiTagAttr,
 KObjCProtoName,
 KPointerType,
 KLValueReferenceType,
@@ -390,6 +391,21 @@ public:
   void printLeft(OutputStream ) const override { s += Name; }
 };
 
+class AbiTagAttr final : public Node {
+  const Node* Base;
+  StringView Tag;
+public:
+  AbiTagAttr(const Node* Base_, StringView Tag_)
+  : Node(KAbiTagAttr), Base(Base_), Tag(Tag_) {}
+
+  void printLeft(OutputStream ) const override {
+Base->printLeft(S);
+S += "[abi:";
+S += Tag;
+S += "]";
+  }
+};
+
 class ObjCProtoName : public Node {
   Node *Ty;
   Node *Protocol;
@@ -1801,10 +1817,9 @@ parse_floating_number(const char* first,
 return first;
 }
 
-//  ::=  
-
+//  ::= [0-9]*
 const char*
-parse_source_name(const char* first, const char* last, Db& db)
+parse_positive_integer(const char* first, const char* last, size_t* out)
 {
 if (first != last)
 {
@@ -1819,15 +1834,53 @@ parse_source_name(const char* first, con
 if (++t == last)
 return first;
 }
-if (static_cast(last - t) >= n)
-{
-StringView r(t, t + n);
-if (r.substr(0, 10) == "_GLOBAL__N")
-db.Names.push_back(db.make("(anonymous 
namespace)"));
-else
-db.Names.push_back(db.make(r));
-first = t + n;
-}
+*out = n;
+first = t;
+}
+}
+return first;
+}
+
+// extension
+//  ::= *
+//  ::= B  
+const char*
+parse_abi_tag_seq(const char* first, const char* last, Db& db)
+{
+while (first != last && *first == 'B' && first+1 != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first+1, last, );
+if (t == first+1)
+return first;
+if (static_cast(last - t) < length || db.Names.empty())
+return first;
+db.Names.back() = db.make(
+db.Names.back(), StringView(t, t + length));
+first = t + length;
+}
+return first;
+}
+
+//  ::=   []
+const char*
+parse_source_name(const char* first, const char* last, Db& db)
+{
+if (first != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first, last, );
+if (t == first)
+return first;
+if (static_cast(last - t) >= length)
+{
+StringView r(t, t + length);
+if (r.substr(0, 10) == "_GLOBAL__N")
+db.Names.push_back(db.make("(anonymous namespace)"));
+else
+db.Names.push_back(db.make(r));
+first = t + length;
+first = parse_abi_tag_seq(first, last, db);
 }
 }
 return first;
@@ -3763,10 +3816,11 @@ parse_type(const char* first, const char
 //   ::= rs# >>
 //   ::= rS# >>=   
 //   ::= v  # vendor extended 
operator
-
+//   extension   ::=  
 const char*
 parse_operator_name(const char* first, const char* last, Db& db)
 {
+const char* original_first = first;
 if (last - first >= 2)
 {
 switch (first[0])
@@ -4063,6 +4117,10 @@ parse_operator_name(const char* first, c
 break;
 }
 }
+
+if (original_first != first)
+first = parse_abi_tag_seq(first, last, db);
+
 return first;
 }
 
@@ -4299,7 +4357,7 @@ Node* maybe_change_special_sub_name(Node
 //  ::= D1# complete object destructor
 //  ::= D2# base object destructor
 //   extension  ::= D5# ?
-
+//   extension  ::=  
 const char*
 parse_ctor_dtor_name(const char* first, const char* last, Db& db)
 {
@@ -4321,6 +4379,7 @@ parse_ctor_dtor_name(const char* first,
 db.Names.push_back(
 db.make(db.Names.back(), false));
 first += 2;
+first = parse_abi_tag_seq(first, last, db);
 db.ParsedCtorDtorCV = true;
 break;
 }
@@ -4337,6 +4396,7 @@ parse_ctor_dtor_name(const char* first,
 db.Names.push_back(
 db.make(db.Names.back(), true));
  

[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-22 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.

Looks really good to me now! @rnk?


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


r318872 - [OPENMP] Add support for cancel constructs in [teams] distribute

2017-11-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 22 12:19:50 2017
New Revision: 318872

URL: http://llvm.org/viewvc/llvm-project?rev=318872=rev
Log:
[OPENMP] Add support for cancel constructs in [teams] distribute
parallel for directives.

Added codegen/sema support for cancel constructs in [teams] distribute
parallel for directives.

Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=318872=318871=318872=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Wed Nov 22 12:19:50 2017
@@ -3033,6 +3033,8 @@ public:
 ///
 class OMPDistributeParallelForDirective : public OMPLoopDirective {
   friend class ASTStmtReader;
+  /// true if the construct has inner cancel directive.
+  bool HasCancel = false;
 
   /// \brief Build directive with the given start and end location.
   ///
@@ -3046,7 +3048,7 @@ class OMPDistributeParallelForDirective
 unsigned CollapsedNum, unsigned NumClauses)
   : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
  OMPD_distribute_parallel_for, StartLoc, EndLoc,
- CollapsedNum, NumClauses) {}
+ CollapsedNum, NumClauses), HasCancel(false) {}
 
   /// \brief Build an empty directive.
   ///
@@ -3057,7 +3059,11 @@ class OMPDistributeParallelForDirective
  unsigned NumClauses)
   : OMPLoopDirective(this, OMPDistributeParallelForDirectiveClass,
  OMPD_distribute_parallel_for, SourceLocation(),
- SourceLocation(), CollapsedNum, NumClauses) {}
+ SourceLocation(), CollapsedNum, NumClauses),
+HasCancel(false) {}
+
+  /// Set cancel state.
+  void setHasCancel(bool Has) { HasCancel = Has; }
 
 public:
   /// \brief Creates directive with a list of \a Clauses.
@@ -3069,11 +3075,12 @@ public:
   /// \param Clauses List of clauses.
   /// \param AssociatedStmt Statement, associated with the directive.
   /// \param Exprs Helper expressions for CodeGen.
+  /// \param HasCancel true if this directive has inner cancel directive.
   ///
   static OMPDistributeParallelForDirective *
   Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
  unsigned CollapsedNum, ArrayRef Clauses,
- Stmt *AssociatedStmt, const HelperExprs );
+ Stmt *AssociatedStmt, const HelperExprs , bool HasCancel);
 
   /// \brief Creates an empty directive with the place
   /// for \a NumClauses clauses.
@@ -3087,6 +3094,9 @@ public:
 unsigned CollapsedNum,
 EmptyShell);
 
+  /// Return true if current directive has inner cancel directive.
+  bool hasCancel() const { return HasCancel; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OMPDistributeParallelForDirectiveClass;
   }
@@ -3583,6 +3593,8 @@ public:
 ///
 class OMPTeamsDistributeParallelForDirective final : public OMPLoopDirective {
   friend class ASTStmtReader;
+  /// true if the construct has inner cancel directive.
+  bool HasCancel = false;
 
   /// Build directive with the given start and end location.
   ///
@@ -3597,7 +3609,7 @@ class OMPTeamsDistributeParallelForDirec
  unsigned NumClauses)
   : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
  OMPD_teams_distribute_parallel_for, StartLoc, EndLoc,
- CollapsedNum, NumClauses) {}
+ CollapsedNum, NumClauses), HasCancel(false) {}
 
   /// Build an empty directive.
   ///
@@ -3608,7 +3620,11 @@ class OMPTeamsDistributeParallelForDirec
   unsigned NumClauses)
   : OMPLoopDirective(this, OMPTeamsDistributeParallelForDirectiveClass,
  OMPD_teams_distribute_parallel_for, SourceLocation(),
- SourceLocation(), CollapsedNum, NumClauses) {}
+ SourceLocation(), CollapsedNum, NumClauses),
+HasCancel(false) {}
+
+  /// Set cancel state.
+  void setHasCancel(bool Has) { HasCancel = Has; }
 
 public:
   /// Creates 

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-22 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 23:59, Reimar Döffinger  wrote:
> 
> On 21.11.2017, at 03:54, Volodymyr Sapsai  > wrote:
>> 
>>> If (exceptions()) != 0 then the exception is rethrown.
>> And looks like libstdc++ rethrows exception even if badbit is not set.
> 
> Thanks for looking all that up, I was in a hurry.
> 
>> If you feel comfortable, I can finish exception tests myself and commit the 
>> patch. How does it sound?
> 
> That would be very welcome if you don't mind.
> I don't have much time over to spend on this most days.
> 
> Thanks,
> Reimar Döffinger

Committed in r318862 and r318863 (the latter one is my mistake). Thanks for 
contributing the fix.

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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-22 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.

LGTM, thanks for updating it!


https://reviews.llvm.org/D40181



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


[PATCH] D40144: Implement `std::launder`

2017-11-22 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

landed as revision 318864


https://reviews.llvm.org/D40144



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


r318866 - Revert "[CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)"

2017-11-22 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Nov 22 11:50:17 2017
New Revision: 318866

URL: http://llvm.org/viewvc/llvm-project?rev=318866=rev
Log:
Revert "[CodeGen] Fix vtable not receiving hidden visibility when using 
push(visibility)"

This reverts commit r318853: tests are failing on Windows bots

Removed:
cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=318866=318865=318866=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Nov 22 11:50:17 2017
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, , ForDefinition);
+  setGlobalVisibility(GV, );
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=318866=318865=318866=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Nov 22 11:50:17 2017
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTT, RD);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=318866=318865=318866=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Nov 22 11:50:17 2017
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
+  CGM.setGlobalVisibility(Fn, MD);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
+  CGM.setGlobalVisibility(VTable, RD);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=318866=318865=318866=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 22 11:50:17 2017
@@ -662,8 +662,7 @@ llvm::ConstantInt *CodeGenModule::getSiz
 }
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
-const NamedDecl *D,
-ForDefinition_t IsForDefinition) const 
{
+const NamedDecl *D) const {
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
@@ -672,8 +671,7 @@ void CodeGenModule::setGlobalVisibility(
 
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() ||
-  (IsForDefinition && !GV->hasAvailableExternallyLinkage()))
+  if (LV.isVisibilityExplicit() || !GV->hasAvailableExternallyLinkage())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
@@ -1054,7 +1052,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cast_or_null(D))
-setGlobalVisibility(GV, ND, ForDefinition);
+setGlobalVisibility(GV, ND);
   else
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
@@ -1110,8 +1108,8 @@ void CodeGenModule::SetInternalFunctionA
   setNonAliasAttributes(D, F);
 }
 
-static void 

[libcxx] r318865 - [libcxx] Implement std::to_address for C++20

2017-11-22 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Nov 22 11:49:21 2017
New Revision: 318865

URL: http://llvm.org/viewvc/llvm-project?rev=318865=rev
Log:
[libcxx] Implement std::to_address for C++20

Summary: Now implements P0653R2 - Utility to convert to raw pointer.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

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

Added:
libcxx/trunk/test/std/utilities/memory/pointer.conversion/

libcxx/trunk/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=318865=318864=318865=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Wed Nov 22 11:49:21 2017
@@ -46,6 +46,9 @@ struct pointer_traits
 static pointer pointer_to() noexcept;
 };
 
+template  constexpr T* to_address(T* p) noexcept; // C++20
+template  auto to_address(const Ptr& p) noexcept; // C++20
+
 template 
 struct allocator_traits
 {
@@ -1090,13 +1093,14 @@ struct __const_void_pointer<_Ptr, _Alloc
 };
 
 template 
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
 _Tp*
 __to_raw_pointer(_Tp* __p) _NOEXCEPT
 {
 return __p;
 }
 
+#if _LIBCPP_STD_VER <= 17
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 typename pointer_traits<_Pointer>::element_type*
@@ -1104,6 +1108,41 @@ __to_raw_pointer(_Pointer __p) _NOEXCEPT
 {
 return _VSTD::__to_raw_pointer(__p.operator->());
 }
+#else
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__to_raw_pointer(const _Pointer& __p) _NOEXCEPT
+-> decltype(pointer_traits<_Pointer>::to_address(__p))
+{
+return pointer_traits<_Pointer>::to_address(__p);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+__to_raw_pointer(const _Pointer& __p, _None...) _NOEXCEPT
+{
+return _VSTD::__to_raw_pointer(__p.operator->());
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY constexpr
+_Tp*
+to_address(_Tp* __p) _NOEXCEPT
+{
+static_assert(!is_function_v<_Tp>, "_Tp is a function type");
+return __p;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+to_address(const _Pointer& __p) _NOEXCEPT
+{
+return _VSTD::__to_raw_pointer(__p);
+}
+#endif
 
 template 
 struct __has_size_type : false_type {};

Added: 
libcxx/trunk/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp?rev=318865=auto
==
--- 
libcxx/trunk/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/utilities/memory/pointer.conversion/to_address.pass.cpp 
Wed Nov 22 11:49:21 2017
@@ -0,0 +1,120 @@
+//===--===//
+//
+// 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, c++17
+
+// template  constexpr T* to_address(T* p) noexcept;
+// template  auto to_address(const Ptr& p) noexcept;
+
+#include 
+#include 
+#include "test_macros.h"
+
+class P1
+{
+public:
+using element_type = int;
+
+explicit P1(int* p)
+: p_(p) { }
+
+int* operator->() const noexcept
+{ return p_; }
+
+private:
+int* p_;
+};
+
+class P2
+{
+public:
+using element_type = int;
+
+explicit P2(int* p)
+: p_(p) { }
+
+P1 operator->() const noexcept
+{ return p_; }
+
+private:
+P1 p_;
+};
+
+class P3
+{
+public:
+explicit P3(int* p)
+: p_(p) { }
+
+int* get() const noexcept
+{ return p_; }
+
+private:
+int* p_;
+};
+
+namespace std
+{
+template<>
+struct pointer_traits<::P3>
+{
+static int* to_address(const ::P3& p) noexcept
+{ return p.get(); }
+};
+}
+
+class P4
+{
+public:
+explicit P4(int* p)
+: p_(p) { }
+
+int* operator->() const noexcept
+{ return nullptr; }
+
+int* get() const noexcept
+{ return p_; }
+
+private:
+int* p_;
+};
+
+namespace std
+{
+template<>
+struct pointer_traits<::P4>
+{
+static int* to_address(const ::P4& p) noexcept
+{ return p.get(); }
+};
+}
+
+int n = 0;
+static_assert(std::to_address() == );
+
+int main()
+{
+int i = 0;
+ASSERT_NOEXCEPT(std::to_address());
+assert(std::to_address() == );
+P1 p1();
+ASSERT_NOEXCEPT(std::to_address(p1));
+assert(std::to_address(p1) == );
+P2 p2();
+ASSERT_NOEXCEPT(std::to_address(p2));
+assert(std::to_address(p2) == );
+P3 p3();
+ASSERT_NOEXCEPT(std::to_address(p3));
+assert(std::to_address(p3) 

[libcxx] r318864 - Implement p0137r1 - std::launder. Reviewed as https://reviews.llvm.org/D40144

2017-11-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Nov 22 11:49:03 2017
New Revision: 318864

URL: http://llvm.org/viewvc/llvm-project?rev=318864=rev
Log:
Implement p0137r1 - std::launder. Reviewed as https://reviews.llvm.org/D40144

Added:
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/

libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp

libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/new
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=318864=318863=318864=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Nov 22 11:49:03 2017
@@ -456,6 +456,10 @@ namespace std {
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
 #endif 
 
+#if __has_builtin(__builtin_launder)
+#define_LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+#endif
+
 #elif defined(_LIBCPP_COMPILER_GCC)
 
 #define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -538,6 +542,10 @@ namespace std {
 #define _LIBCPP_HAS_NO_ASAN
 #endif
 
+#if _GNUC_VER >= 700
+#define_LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+#endif
+
 #elif defined(_LIBCPP_COMPILER_MSVC)
 
 #define _LIBCPP_TOSTRING2(x) #x

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=318864=318863=318864=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Wed Nov 22 11:49:03 2017
@@ -46,6 +46,8 @@ typedef void (*new_handler)();
 new_handler set_new_handler(new_handler new_p) noexcept;
 new_handler get_new_handler() noexcept;
 
+// 21.6.4, pointer optimization barrier
+template  constexpr T* launder(T* p) noexcept; // C++17
 }  // std
 
 void* operator new(std::size_t size);   // 
replaceable
@@ -250,6 +252,29 @@ void __throw_bad_array_length()
 }
 #endif
 
+template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline 
+_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT
+{
+static_assert (!(is_function<_Tp>::value), "can't launder functions" );
+static_assert (!(is_same::type>::value), 
"can't launder cv-void" );
+#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
+return __builtin_launder(__p);
+#else
+return __p;
+#endif
+}
+
+
+#if _LIBCPP_STD_VER > 14
+template 
+_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
+constexpr _Tp* launder(_Tp* __p) noexcept
+{
+return __launder(__p);
+}
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_NEW

Added: 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp?rev=318864=auto
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
 Wed Nov 22 11:49:03 2017
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// 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  constexpr T* launder(T* p) noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main ()
+{
+int *p = nullptr;
+std::launder(p);  // expected-error {{ignoring return value of function 
declared with 'nodiscard' attribute}}
+}

Added: 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp?rev=318864=auto
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
 Wed Nov 22 11:49:03 2017
@@ -0,0 +1,35 @@
+//===--===//
+//
+// 

[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-22 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added inline comments.
This revision now requires changes to proceed.



Comment at: include/__functional_base:396
+!is_same<__uncvref_t<_Up>, reference_wrapper>::value
+>::type, bool _IsNothrow = noexcept(__bind(_VSTD::declval<_Up>()))>
+_LIBCPP_INLINE_VISIBILITY reference_wrapper(_Up&& __u) 
_NOEXCEPT_(_IsNothrow)

So I need to backpeddel about using `noexcept` in the SFINAE instead of 
`decltype`. I forgot that `noexcept` specifications are evaluated "as-needed", 
and using it in SFINAE could potentially cause the evaluation of "unneeded" 
noexcept specifications.

Could we go back to `decltype` please?

Sorry about that.



Comment at: 
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp:17
+
+// XFAIL: c++98, c++03
+

This should probably be `// UNSUPPORTED`.


https://reviews.llvm.org/D40259



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


[PATCH] D40325: add new check to find OSSpinlock usage

2017-11-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/objc/AvoidSpinlockCheck.cpp:35
+  diag(MatchedExpr->getLocStart(),
+   "OSSpinlock is deprecated on iOS. Please use other locks or dispatch "
+   "queue.");

hokein wrote:
> nit: clang-tidy message is not a complete message, please follow the rule.
> 
> The `OSSpinlock` is also deprecated on macOS, I think? from 
> https://developer.apple.com/documentation/os/1646466-os_unfair_lock_lock.
oops, sorry for my typo: s/is not a complete message/is not a complete sentence.


https://reviews.llvm.org/D40325



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


[libcxx] r318863 - [libcxx][fixup] Mark std::basic_istream::getline tests as failing for previous libcxx versions.

2017-11-22 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Nov 22 11:36:54 2017
New Revision: 318863

URL: http://llvm.org/viewvc/llvm-project?rev=318863=rev
Log:
[libcxx][fixup] Mark std::basic_istream::getline tests as failing for previous 
libcxx versions.

r318862 added a fix for 0-termination input array in case of an error. Previous
libcxx versions don't have the fix and corresponding tests should be failing.


Modified:

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp?rev=318863=318862=318863=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 Wed Nov 22 11:36:54 2017
@@ -7,6 +7,14 @@
 //
 
//===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& getline(char_type* s, streamsize n);

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp?rev=318863=318862=318863=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
 Wed Nov 22 11:36:54 2017
@@ -7,6 +7,14 @@
 //
 
//===--===//
 
+// XFAIL: with_system_cxx_lib=macosx10.13
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.10
+// XFAIL: with_system_cxx_lib=macosx10.9
+// XFAIL: with_system_cxx_lib=macosx10.8
+// XFAIL: with_system_cxx_lib=macosx10.7
+
 // 
 
 // basic_istream& getline(char_type* s, streamsize n, char_type 
delim);


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


[PATCH] D40325: add new check to find OSSpinlock usage

2017-11-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

The implementation looks good, I will let Ben to do the Object-C specific 
review since he probably knows more about it.




Comment at: clang-tidy/objc/AvoidSpinlockCheck.cpp:35
+  diag(MatchedExpr->getLocStart(),
+   "OSSpinlock is deprecated on iOS. Please use other locks or dispatch "
+   "queue.");

nit: clang-tidy message is not a complete message, please follow the rule.

The `OSSpinlock` is also deprecated on macOS, I think? from 
https://developer.apple.com/documentation/os/1646466-os_unfair_lock_lock.


https://reviews.llvm.org/D40325



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


[PATCH] D40372: [ExprConstant] Fix assert when initializing constexpr array

2017-11-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

Previously, clang would assert on the following:

  struct S {
constexpr S (const int& ir = 0) {}
  };
  constexpr S foo[2];

The problem was that while initializing foo, CallStackFrame::createTemporary() 
was called twice for the MaterializeTemporaryExpr for `0` in the default 
constructor (once for each array element) without ending the lifetime of the 
first. This caused createTemporary() to assert. This patch fixes this problem 
by separating the lifetime of temporaries created for successive calls to the 
ctor when initializing arrays.

https://bugs.llvm.org/show_bug.cgi?id=34858

Thanks for taking a look!
Erik


https://reviews.llvm.org/D40372

Files:
  lib/AST/ExprConstant.cpp
  test/SemaCXX/constant-expression-cxx1y.cpp


Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1021,3 +1021,10 @@
 }
 static_assert(evalNested(), "");
 } // namespace PR19741
+
+namespace PR34858 {
+struct S {
+  constexpr S(const int & = 0) {}
+};
+constexpr S s[2];
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6912,12 +6912,14 @@
 // Initialize the elements.
 LValue ArrayElt = Subobject;
 ArrayElt.addArray(Info, E, CAT);
-for (unsigned I = 0; I != N; ++I)
+for (unsigned I = 0; I != N; ++I) {
+  BlockScopeRAII Scope(Info);
   if (!VisitCXXConstructExpr(E, ArrayElt, 
>getArrayInitializedElt(I),
  CAT->getElementType()) ||
   !HandleLValueArrayAdjustment(Info, E, ArrayElt,
CAT->getElementType(), 1))
 return false;
+}
 
 return true;
   }


Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1021,3 +1021,10 @@
 }
 static_assert(evalNested(), "");
 } // namespace PR19741
+
+namespace PR34858 {
+struct S {
+  constexpr S(const int & = 0) {}
+};
+constexpr S s[2];
+}
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6912,12 +6912,14 @@
 // Initialize the elements.
 LValue ArrayElt = Subobject;
 ArrayElt.addArray(Info, E, CAT);
-for (unsigned I = 0; I != N; ++I)
+for (unsigned I = 0; I != N; ++I) {
+  BlockScopeRAII Scope(Info);
   if (!VisitCXXConstructExpr(E, ArrayElt, >getArrayInitializedElt(I),
  CAT->getElementType()) ||
   !HandleLValueArrayAdjustment(Info, E, ArrayElt,
CAT->getElementType(), 1))
 return false;
+}
 
 return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r318862 - [libcxx] Make std::basic_istream::getline 0-terminate input array in case of error.

2017-11-22 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed Nov 22 10:52:36 2017
New Revision: 318862

URL: http://llvm.org/viewvc/llvm-project?rev=318862=rev
Log:
[libcxx] Make std::basic_istream::getline 0-terminate input array in case of 
error.

It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p21:
  In any case, if n is greater than zero, it then stores a null character
  (using charT()) into the next successive location of the array.

Patch by Reimar Döffinger.


Modified:
libcxx/trunk/include/istream

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp

Modified: libcxx/trunk/include/istream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=318862=318861=318862=diff
==
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Wed Nov 22 10:52:36 2017
@@ -1069,16 +1069,18 @@ basic_istream<_CharT, _Traits>::getline(
 this->rdbuf()->sbumpc();
 ++__gc_;
 }
-if (__n > 0)
-*__s = char_type();
 if (__gc_ == 0)
__err |= ios_base::failbit;
 this->setstate(__err);
 }
+if (__n > 0)
+*__s = char_type();
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
 catch (...)
 {
+if (__n > 0)
+*__s = char_type();
 this->__set_badbit_and_consider_rethrow();
 }
 #endif  // _LIBCPP_NO_EXCEPTIONS

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp?rev=318862=318861=318862=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
 Wed Nov 22 10:52:36 2017
@@ -14,6 +14,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 struct testbuf
 : public std::basic_streambuf
@@ -59,7 +61,33 @@ int main()
 assert(!is.fail());
 assert(std::string(s) == " ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.getline(s, 5);
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == "");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(" ");
+std::istream is();
+char s[5] = "test";
+is.exceptions(std::istream::eofbit | std::istream::badbit);
+try
+{
+is.getline(s, 5);
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::string(s) == " ");
+assert(is.gcount() == 1);
 }
+#endif
 {
 testbuf sb(L"  \n\n ");
 std::wistream is();
@@ -79,5 +107,31 @@ int main()
 assert(!is.fail());
 assert(std::wstring(s) == L" ");
 assert(is.gcount() == 1);
+// Check that even in error case the buffer is properly 0-terminated.
+is.getline(s, 5);
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L"");
+assert(is.gcount() == 0);
+}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+{
+testbuf sb(L" ");
+std::wistream is();
+wchar_t s[5] = L"test";
+is.exceptions(std::wistream::eofbit | std::wistream::badbit);
+try
+{
+is.getline(s, 5);
+assert(false);
+}
+catch (std::ios_base::failure&)
+{
+}
+assert( is.eof());
+assert( is.fail());
+assert(std::wstring(s) == L" ");
+assert(is.gcount() == 1);
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp?rev=318862=318861=318862=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
 (original)
+++ 

[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-11-22 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi added a comment.

Ping.


https://reviews.llvm.org/D34030



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


r318860 - [OPENMP] Added missed checks for for [simd] based directives.

2017-11-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 22 10:34:02 2017
New Revision: 318860

URL: http://llvm.org/viewvc/llvm-project?rev=318860=rev
Log:
[OPENMP] Added missed checks for for [simd] based directives.

Added missed checks/analysis for safelen/simdlen clauses + linear clause
in for [simd] based directives.

Added:
cfe/trunk/test/OpenMP/distribute_parallel_for_linear_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/lib/Sema/SemaOpenMP.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_teams_distribute_simd_misc_messages.c
cfe/trunk/test/OpenMP/taskloop_simd_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_misc_messages.c

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=318860=318859=318860=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Nov 22 10:34:02 2017
@@ -610,6 +610,7 @@ OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(sh
 OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(reduction)
 OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(copyin)
 OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(schedule)
+OPENMP_DISTRIBUTE_PARALLEL_FOR_CLAUSE(linear)
 
 // Clauses allowed for OpenMP directive 'distribute parallel for simd'
 OPENMP_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(firstprivate)

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=318860=318859=318860=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 22 10:34:02 2017
@@ -6731,6 +6731,8 @@ StmtResult Sema::ActOnOpenMPTaskLoopSimd
   // clause must not be specified.
   if (checkReductionClauseWithNogroup(*this, Clauses))
 return StmtError();
+  if (checkSimdlenSafelenSpecified(*this, Clauses))
+return StmtError();
 
   getCurFunction()->setHasBranchProtectedScope();
   return OMPTaskLoopSimdDirective::Create(Context, StartLoc, EndLoc,
@@ -6802,6 +6804,17 @@ StmtResult Sema::ActOnOpenMPDistributePa
   assert((CurContext->isDependentContext() || B.builtAll()) &&
  "omp for loop exprs were not built");
 
+  if (!CurContext->isDependentContext()) {
+// Finalize the clauses that need pre-built expressions for CodeGen.
+for (auto C : Clauses) {
+  if (auto *LC = dyn_cast(C))
+if (FinishOpenMPLinearClause(*LC, cast(B.IterationVarRef),
+ B.NumIterations, *this, CurScope,
+ DSAStack))
+  return StmtError();
+}
+  }
+
   getCurFunction()->setHasBranchProtectedScope();
   return OMPDistributeParallelForDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
@@ -6835,6 +6848,17 @@ StmtResult Sema::ActOnOpenMPDistributePa
   assert((CurContext->isDependentContext() || B.builtAll()) &&
  "omp for loop exprs were not built");
 
+  if (!CurContext->isDependentContext()) {
+// Finalize the clauses that need pre-built expressions for CodeGen.
+for (auto C : Clauses) {
+  if (auto *LC = dyn_cast(C))
+if (FinishOpenMPLinearClause(*LC, cast(B.IterationVarRef),
+ B.NumIterations, *this, CurScope,
+ DSAStack))
+  return StmtError();
+}
+  }
+
   if (checkSimdlenSafelenSpecified(*this, Clauses))
 return StmtError();
 
@@ -6871,6 +6895,17 @@ StmtResult Sema::ActOnOpenMPDistributeSi
   assert((CurContext->isDependentContext() || B.builtAll()) &&
  "omp for loop exprs were not built");
 
+  if (!CurContext->isDependentContext()) {
+// Finalize the clauses that need pre-built expressions for CodeGen.
+for (auto C : Clauses) {
+  if (auto *LC = dyn_cast(C))
+if (FinishOpenMPLinearClause(*LC, cast(B.IterationVarRef),
+ B.NumIterations, *this, CurScope,
+ DSAStack))
+  return StmtError();
+}
+  }
+
   if (checkSimdlenSafelenSpecified(*this, Clauses))
 return StmtError();
 
@@ -7329,6 +7364,9 @@ StmtResult Sema::ActOnOpenMPTargetTeamsD
 }
   }
 
+  if (checkSimdlenSafelenSpecified(*this, Clauses))
+return StmtError();
+
   getCurFunction()->setHasBranchProtectedScope();
   return OMPTargetTeamsDistributeParallelForSimdDirective::Create(
   Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
@@ -7362,6 +7400,20 @@ StmtResult Sema::ActOnOpenMPTargetTeamsD
   assert((CurContext->isDependentContext() || B.builtAll()) &&
  "omp target teams distribute simd loop exprs were not built");
 
+  if (!CurContext->isDependentContext()) {
+// Finalize the clauses that need 

r318857 - CachePruning: Allow limiting the number of files in the cache directory.

2017-11-22 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Wed Nov 22 10:27:31 2017
New Revision: 318857

URL: http://llvm.org/viewvc/llvm-project?rev=318857=rev
Log:
CachePruning: Allow limiting the number of files in the cache directory.

The default limit is 100 but it can be configured with a cache
policy. The motivation is that some filesystems (notably ext4) have
a limit on the number of files that can be contained in a directory
(separate from the inode limit).

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

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=318857=318856=318857=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Wed Nov 22 10:27:31 2017
@@ -173,6 +173,10 @@ Possible key-value pairs are:
   ``cache_size_bytes=1g`` on its own will cause both the 1GB and default 75%
   policies to be applied unless the default ``cache_size`` is overridden.
 
+- ``cache_size_files=X``:
+  Set the maximum number of files in the cache directory. Set to 0 to indicate
+  no limit. The default is 100 files.
+
 - ``prune_after=Xs``, ``prune_after=Xm``, ``prune_after=Xh``: Sets the
   expiration time for cache files to ``X`` seconds (or minutes, hours
   respectively).  When a file hasn't been accessed for ``prune_after`` seconds,


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


[PATCH] D39627: Fix vtable not receiving hidden visibility when using push(visibility)

2017-11-22 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318853: [CodeGen] Fix vtable not receiving hidden visibility 
when using push(visibility) (authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D39627?vs=123399=123969#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39627

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGVTT.cpp
  cfe/trunk/lib/CodeGen/CGVTables.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp

Index: cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp
===
--- cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp
+++ cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang -S -emit-llvm -o %t %s
+// RUN: FileCheck --input-file=%t %s
+
+#pragma GCC visibility push(hidden)
+
+struct Base {
+  virtual ~Base() = default;
+  virtual void* Alloc() = 0;
+};
+
+class Child : public Base {
+public:
+  Child() = default;
+  void* Alloc();
+};
+
+void test() {
+  Child x;
+}
+
+// CHECK: @_ZTV5Child = external hidden unnamed_addr constant
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -240,7 +240,7 @@
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, );
+  setGlobalVisibility(GV, , ForDefinition);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -710,7 +710,8 @@
   llvm::ConstantInt *getSize(CharUnits numChars);
 
   /// Set the visibility for the given LLVM GlobalValue.
-  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const;
+  void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D,
+   ForDefinition_t IsForDefinition) const;
 
   /// Set the TLS mode for the given LLVM GlobalValue for the thread-local
   /// variable declaration D.
Index: cfe/trunk/lib/CodeGen/CGVTables.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTables.cpp
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp
@@ -51,7 +51,7 @@
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
Index: cfe/trunk/lib/CodeGen/CGVTT.cpp
===
--- cfe/trunk/lib/CodeGen/CGVTT.cpp
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp
@@ -100,7 +100,7 @@
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1527,7 +1527,7 @@
 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
 
   // Use pointer alignment for the vtable. Otherwise we would align them based
   // on the size of the initializer which doesn't make sense as only single
@@ -1637,6 +1637,7 @@
   VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
   Name, VTableType, llvm::GlobalValue::ExternalLinkage);
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
+  CGM.setGlobalVisibility(VTable, RD, NotForDefinition);
 
   if (RD->hasAttr())
 VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===

r318853 - [CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)

2017-11-22 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Nov 22 09:59:30 2017
New Revision: 318853

URL: http://llvm.org/viewvc/llvm-project?rev=318853=rev
Log:
[CodeGen] Fix vtable not receiving hidden visibility when using push(visibility)

This change should resolve https://bugs.llvm.org/show_bug.cgi?id=35022

Patch by Jake Ehrlich

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

Added:
cfe/trunk/test/CodeGen/push-hidden-visibility-subclass.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=318853=318852=318853=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Nov 22 09:59:30 2017
@@ -240,7 +240,7 @@ llvm::Constant *CodeGenModule::getOrCrea
   getModule(), LTy, Ty.isConstant(getContext()), Linkage, Init, Name,
   nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
   GV->setAlignment(getContext().getDeclAlign().getQuantity());
-  setGlobalVisibility(GV, );
+  setGlobalVisibility(GV, , ForDefinition);
 
   if (supportsCOMDAT() && GV->isWeakForLinker())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));

Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=318853=318852=318853=diff
==
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Wed Nov 22 09:59:30 2017
@@ -100,7 +100,7 @@ CodeGenVTables::EmitVTTDefinition(llvm::
 VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));
 
   // Set the right visibility.
-  CGM.setGlobalVisibility(VTT, RD);
+  CGM.setGlobalVisibility(VTT, RD, ForDefinition);
 }
 
 llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {

Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=318853=318852=318853=diff
==
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Nov 22 09:59:30 2017
@@ -51,7 +51,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
 
 static void setThunkVisibility(CodeGenModule , const CXXMethodDecl *MD,
const ThunkInfo , llvm::Function *Fn) {
-  CGM.setGlobalVisibility(Fn, MD);
+  CGM.setGlobalVisibility(Fn, MD, ForDefinition);
 }
 
 static void setThunkProperties(CodeGenModule , const ThunkInfo ,
@@ -730,7 +730,7 @@ CodeGenVTables::GenerateConstructionVTab
   // Create the variable that will hold the construction vtable.
   llvm::GlobalVariable *VTable =
 CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage);
-  CGM.setGlobalVisibility(VTable, RD);
+  CGM.setGlobalVisibility(VTable, RD, ForDefinition);
 
   // V-tables are always unnamed_addr.
   VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=318853=318852=318853=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 22 09:59:30 2017
@@ -662,7 +662,8 @@ llvm::ConstantInt *CodeGenModule::getSiz
 }
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
-const NamedDecl *D) const {
+const NamedDecl *D,
+ForDefinition_t IsForDefinition) const 
{
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
@@ -671,7 +672,8 @@ void CodeGenModule::setGlobalVisibility(
 
   // Set visibility for definitions.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() || !GV->hasAvailableExternallyLinkage())
+  if (LV.isVisibilityExplicit() ||
+  (IsForDefinition && !GV->hasAvailableExternallyLinkage()))
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
@@ -1052,7 +1054,7 @@ void CodeGenModule::SetLLVMFunctionAttri
 void CodeGenModule::SetCommonAttributes(const Decl *D,
 llvm::GlobalValue *GV) {
   if (const auto *ND = dyn_cast_or_null(D))
-setGlobalVisibility(GV, ND);
+setGlobalVisibility(GV, ND, ForDefinition);
   else
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
 
@@ -1108,8 +1110,8 @@ void 

[PATCH] D39936: [OpenCL] Add extensions cl_intel_subgroups and cl_intel_subgroups_short

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

LGTM! Thanks!


https://reviews.llvm.org/D39936



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


[PATCH] D40224: [X86] Control-Flow Enforcement Technology - Shadow Stack and Indirect Branch Tracking support (Clang side)

2017-11-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D40224



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-22 Thread Ana Pazos via Phabricator via cfe-commits
apazos added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8872
+  else
+NeededArgGPRs = 1;
+

Suggestion to make 1 default value when you declare the var



Comment at: lib/CodeGen/TargetInfo.cpp:8938
+
+  // The size of the actual thing passed, which might end up just
+  // being a pointer for indirect types.

The size -> The type


https://reviews.llvm.org/D40023



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


[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-22 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 123958.
Nebiroth marked 10 inline comments as done.
Nebiroth added a comment.

Removed accidentally included files
Fixed some coding standard issues
Removed getDeclarationLocation declaration from header file
Replaced getFunctionComments with clang implementation
onCodeHover now follows error-reporting pattern


https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -5,6 +5,7 @@
 Content-Length: 143
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
+
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
@@ -30,6 +31,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
@@ -40,6 +41,7 @@
 # CHECK-NEXT:  "textDocumentSync": 1
 # CHECK-NEXT:}
 # CHECK-NEXT:  }
+
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,52 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 407
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nint test = 5;\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};}\nint main() {\nint a;\na;\nint b = ns1::test;\nns1::MyClass* Params;\nParams->anotherOperation();\nMACRO;}\n"}}}
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":12}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":14,"character":1}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"int a"}],"range":{"end":{"character":5,"line":13},"start":{"character":0,"line":13
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":15,"character":15}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"int test = 5"}],"range":{"end":{"character":12,"line":2},"start":{"character":0,"line":2
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":16,"character":10}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"struct MyClass {"}],"range":{"end":{"character":16,"line":3},"start":{"character":0,"line":3
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":13}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1::MyClass"},{"language":"C++","value":"void anotherOperation() 

r318849 - [OPENMP] General improvement of code, NFC.

2017-11-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 22 09:19:31 2017
New Revision: 318849

URL: http://llvm.org/viewvc/llvm-project?rev=318849=rev
Log:
[OPENMP] General improvement of code, NFC.

Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=318849=318848=318849=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Nov 22 09:19:31 2017
@@ -901,6 +901,17 @@ void clang::getOpenMPCaptureRegions(
 CaptureRegions.push_back(OMPD_teams);
 CaptureRegions.push_back(OMPD_parallel);
 break;
+  case OMPD_target_parallel:
+  case OMPD_target_parallel_for:
+  case OMPD_target_parallel_for_simd:
+CaptureRegions.push_back(OMPD_target);
+CaptureRegions.push_back(OMPD_parallel);
+break;
+  case OMPD_target_enter_data:
+  case OMPD_target_exit_data:
+  case OMPD_target_update:
+CaptureRegions.push_back(OMPD_task);
+break;
   case OMPD_teams:
   case OMPD_simd:
   case OMPD_for:
@@ -929,17 +940,6 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_target_teams_distribute_simd:
 CaptureRegions.push_back(DKind);
 break;
-  case OMPD_target_parallel:
-  case OMPD_target_parallel_for:
-  case OMPD_target_parallel_for_simd:
-CaptureRegions.push_back(OMPD_target);
-CaptureRegions.push_back(OMPD_parallel);
-break;
-  case OMPD_target_enter_data:
-  case OMPD_target_exit_data:
-  case OMPD_target_update:
-CaptureRegions.push_back(OMPD_task);
-break;
   case OMPD_threadprivate:
   case OMPD_taskyield:
   case OMPD_barrier:

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=318849=318848=318849=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 22 09:19:31 2017
@@ -6777,13 +6777,24 @@ StmtResult Sema::ActOnOpenMPDistributePa
   // The point of exit cannot be a branch out of the structured block.
   // longjmp() and throw() must not violate the entry/exit criteria.
   CS->getCapturedDecl()->setNothrow();
+  for (int ThisCaptureLevel =
+   getOpenMPCaptureLevels(OMPD_distribute_parallel_for);
+   ThisCaptureLevel > 1; --ThisCaptureLevel) {
+CS = cast(CS->getCapturedStmt());
+// 1.2.2 OpenMP Language Terminology
+// Structured block - An executable statement with a single entry at the
+// top and a single exit at the bottom.
+// The point of exit cannot be a branch out of the structured block.
+// longjmp() and throw() must not violate the entry/exit criteria.
+CS->getCapturedDecl()->setNothrow();
+  }
 
   OMPLoopDirective::HelperExprs B;
   // In presence of clause 'collapse' with number of loops, it will
   // define the nested loops number.
   unsigned NestedLoopCount = CheckOpenMPLoop(
   OMPD_distribute_parallel_for, getCollapseNumberExpr(Clauses),
-  nullptr /*ordered not a clause on distribute*/, AStmt, *this, *DSAStack,
+  nullptr /*ordered not a clause on distribute*/, CS, *this, *DSAStack,
   VarsWithImplicitDSA, B);
   if (NestedLoopCount == 0)
 return StmtError();
@@ -7723,14 +7734,16 @@ static OpenMPDirectiveKind getOpenMPCapt
 case OMPD_teams_distribute_parallel_for:
   CaptureRegion = OMPD_teams;
   break;
+case OMPD_distribute_parallel_for:
+  CaptureRegion = OMPD_parallel;
+  break;
 case OMPD_parallel_for:
 case OMPD_parallel_for_simd:
 case OMPD_target_teams_distribute_parallel_for:
 case OMPD_target_teams_distribute_parallel_for_simd:
 case OMPD_teams_distribute_parallel_for_simd:
-case OMPD_distribute_parallel_for:
 case OMPD_distribute_parallel_for_simd:
-  // Do not capture thread_limit-clause expressions.
+  // Do not capture schedule clause expressions.
   break;
 case OMPD_task:
 case OMPD_taskloop:


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


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-11-22 Thread Melanie Blower via Phabricator via cfe-commits
mibintc reopened this revision.
mibintc added a comment.

Hi.

I also posted this question on IRC

@erichkeane pushed a fix for https://reviews.llvm.org/D34158 which on Linux 
does a preinclude of stdc-predef.h; on Monday. Later on Monday he pulled it out 
because it caused 3 test failures and word-of-mouth that it also caused 
chromium build to fail. I haven't been watching this IRC so I didn't catch the 
details about the chromium build fail.

if you know, can you send me details about how/why chromium build fails?

also, the 3 tests (2 lit tests, 1 google test) which failed on buildbot do not 
fail on the linux servers in-house at Intel. Any clue about why that would be? 
I have a patched compiler, and verify that the new functionality is present. I 
build check-clang and there are no fails.

I looked with llvm-lit at each of the 2 failing tests and they don't fail, I 
checked the google test libclang "skip ranges" and it doesn't fail

also maybe i should redirect this question elsewhere.  don't hesitate to let me 
know

also i have used the self-build for https://reviews.llvm.org/D34158 and 
likewise those 3 tests do not fail.

i used "llvm-lit -a" on one of the failing tests 
test/Modules/crash-vfs-path-symlink-component.m to see why the test was 
failing. i was not able to run the commands directly from the linux shell
 the lit command that didn't work is not env FORCE_CLANG_DIAGNOSTICS_CRASH= ...
 it's the "not" which is not understood - does that ring a bell?  it works OK 
within llvm-lit
sptel9-ws/llorg1/builds/llorgefi2linux_debug/llvm/bin/count 1 ; the buildbot is 
showing 2 not 1


Repository:
  rL LLVM

https://reviews.llvm.org/D34158



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


[PATCH] D40132: [clangd] Tracing improvements

2017-11-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

Oops, accidentally accepted the revision.
There are no major issues, but still wanted to learn the reasons we use 
rval-refs and allocate span dynamically.


https://reviews.llvm.org/D40132



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


[PATCH] D40132: [clangd] Tracing improvements

2017-11-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/JSONRPCDispatcher.h:61
+ llvm::Optional ID)
+  : Out(Out), ID(std::move(ID)), Tracer(new trace::Span(Method)) {
+if (this->ID)

NIT: maybe replace `new` with `llvm::make_unique`?



Comment at: clangd/JSONRPCDispatcher.h:78
   llvm::Optional ID;
+  std::unique_ptr Tracer;
 };

Why do we need `unique_ptr`? Are `Span`s non-movable?



Comment at: clangd/Trace.cpp:50
   // Contents must be a list of the other JSON key/values.
-  template  void event(StringRef Phase, const T ) {
+  void event(StringRef Phase, json::obj &) {
 uint64_t TID = get_threadid();

Any reason why we use rval-ref instead of accepting by-value?


https://reviews.llvm.org/D40132



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


[PATCH] D39882: [clangd] Filter completion results by fuzzy-matching identifiers.

2017-11-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

We definitely need to:

- Rebase this change on top of current head (to account for limits and scoring)
- Set `incomplete=true` for fuzzy-matched completion results

Maybe also make fuzzy-matching configurable via a flag? Off-by-default for now, 
so we could start testing it before we finish optimizing single-identifier 
edits. When we have it, enable fuzzy-matching by default.




Comment at: clangd/ClangdUnit.cpp:427
+  static bool fuzzyMatch(StringRef Filter, StringRef Target) {
+llvm::errs() << "match " << Target << " against " << Filter << "\n";
+size_t TPos = 0;

Debug output sneaked into the commit.


https://reviews.llvm.org/D39882



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


[clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-22 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Nov 22 07:38:23 2017
New Revision: 318840

URL: http://llvm.org/viewvc/llvm-project?rev=318840=rev
Log:
[FindAllSymbols] Cache regexes, creating them is expensive

This is a bit annoying because LLVM regexes are always mutable to store
errors. Assert that there are never errors and fix broken hardcoded
regexes.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp?rev=318840=318839=318840=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp 
Wed Nov 22 07:38:23 2017
@@ -13,6 +13,16 @@
 namespace clang {
 namespace find_all_symbols {
 
+HeaderMapCollector::HeaderMapCollector(
+const RegexHeaderMap *RegexHeaderMappingTable) {
+  assert(RegexHeaderMappingTable);
+  this->RegexHeaderMappingTable.reserve(RegexHeaderMappingTable->size());
+  for (const auto  : *RegexHeaderMappingTable) {
+this->RegexHeaderMappingTable.emplace_back(llvm::Regex(Entry.first),
+   Entry.second);
+  }
+}
+
 llvm::StringRef
 HeaderMapCollector::getMappedHeader(llvm::StringRef Header) const {
   auto Iter = HeaderMappingTable.find(Header);
@@ -20,11 +30,13 @@ HeaderMapCollector::getMappedHeader(llvm
 return Iter->second;
   // If there is no complete header name mapping for this header, check the
   // regex header mapping.
-  if (RegexHeaderMappingTable) {
-for (const auto  : *RegexHeaderMappingTable) {
-  if (llvm::Regex(Entry.first).match(Header))
-return Entry.second;
-}
+  for (auto  : RegexHeaderMappingTable) {
+#ifndef NDEBUG
+std::string Dummy;
+assert(Entry.first.isValid(Dummy) && "Regex should never be invalid!");
+#endif
+if (Entry.first.match(Header))
+  return Entry.second;
   }
   return Header;
 }

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h?rev=318840=318839=318840=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h 
Wed Nov 22 07:38:23 2017
@@ -25,10 +25,8 @@ public:
   typedef llvm::StringMap HeaderMap;
   typedef std::vector RegexHeaderMap;
 
-  HeaderMapCollector() : RegexHeaderMappingTable(nullptr) {}
-
-  explicit HeaderMapCollector(const RegexHeaderMap *RegexHeaderMappingTable)
-  : RegexHeaderMappingTable(RegexHeaderMappingTable) {}
+  HeaderMapCollector() = default;
+  explicit HeaderMapCollector(const RegexHeaderMap *RegexHeaderMappingTable);
 
   void addHeaderMapping(llvm::StringRef OrignalHeaderPath,
 llvm::StringRef MappingHeaderPath) {
@@ -47,8 +45,10 @@ private:
   HeaderMap HeaderMappingTable;
 
   // A map from header patterns to header names.
-  // This is a reference to a hard-coded map.
-  const RegexHeaderMap *const RegexHeaderMappingTable;
+  // The header names are not owned. This is only threadsafe because the 
regexes
+  // never fail.
+  mutable std::vector>
+  RegexHeaderMappingTable;
 };
 
 } // namespace find_all_symbols

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp?rev=318840=318839=318840=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp 
Wed Nov 22 07:38:23 2017
@@ -314,10 +314,10 @@ const HeaderMapCollector::RegexHeaderMap
   {"include/xlocale.h$", ""},
   {"bits/atomic_word.h$", ""},
   {"bits/basic_file.h$", ""},
-  {"bits/c++allocator.h$", ""},
-  {"bits/c++config.h$", ""},
-  {"bits/c++io.h$", ""},
-  {"bits/c++locale.h$", ""},
+  {"bits/c\\+\\+allocator.h$", ""},
+  {"bits/c\\+\\+config.h$", ""},
+  {"bits/c\\+\\+io.h$", ""},
+  {"bits/c\\+\\+locale.h$", ""},
   {"bits/cpu_defines.h$", ""},
   {"bits/ctype_base.h$", ""},
   {"bits/cxxabi_tweaks.h$", ""},



[libcxx] r318837 - Merging r315994:

2017-11-22 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Nov 22 07:06:35 2017
New Revision: 318837

URL: http://llvm.org/viewvc/llvm-project?rev=318837=rev
Log:
Merging r315994:


r315994 | ericwf | 2017-10-17 06:03:17 -0700 (Tue, 17 Oct 2017) | 18 lines

[libc++] Fix PR34898 - vector iterator constructors and assign method perform 
push_back instead of emplace_back.

Summary:
The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter, Iter)` 
don't correctly perform EmplaceConstruction from the result of dereferencing 
the iterator. This results in them performing an additional and unneeded copy.

This patch addresses the issue by correctly using `emplace_back` in C++11 and 
newer.

There are also some bugs in our `insert` implementation, but those will be 
handled separately.

@mclow.lists We should probably merge this into 5.1, agreed?

Reviewers: mclow.lists, dlj, EricWF

Reviewed By: mclow.lists, EricWF

Subscribers: cfe-commits, mclow.lists

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


Added:

libcxx/branches/release_50/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
libcxx/branches/release_50/test/support/emplace_constructible.h
Modified:
libcxx/branches/release_50/include/deque
libcxx/branches/release_50/include/list
libcxx/branches/release_50/include/vector

libcxx/branches/release_50/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp

libcxx/branches/release_50/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp

libcxx/branches/release_50/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp

libcxx/branches/release_50/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp

libcxx/branches/release_50/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp

libcxx/branches/release_50/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
libcxx/branches/release_50/test/support/container_test_types.h

Modified: libcxx/branches/release_50/include/deque
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/deque?rev=318837=318836=318837=diff
==
--- libcxx/branches/release_50/include/deque (original)
+++ libcxx/branches/release_50/include/deque Wed Nov 22 07:06:35 2017
@@ -1356,7 +1356,6 @@ public:
 iterator insert(const_iterator __p, initializer_list __il)
 {return insert(__p, __il.begin(), __il.end());}
 #endif  // _LIBCPP_CXX03_LANG
-
 iterator insert(const_iterator __p, const value_type& __v);
 iterator insert(const_iterator __p, size_type __n, const value_type& __v);
 template 
@@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIte

!__is_forward_iterator<_InpIter>::value>::type*)
 {
 for (; __f != __l; ++__f)
+#ifdef _LIBCPP_CXX03_LANG
 push_back(*__f);
+#else
+emplace_back(*__f);
+#endif
 }
 
 template 

Modified: libcxx/branches/release_50/include/list
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/list?rev=318837=318836=318837=diff
==
--- libcxx/branches/release_50/include/list (original)
+++ libcxx/branches/release_50/include/list Wed Nov 22 07:06:35 2017
@@ -992,6 +992,15 @@ public:
 void push_front(const value_type& __x);
 void push_back(const value_type& __x);
 
+#ifndef _LIBCPP_CXX03_LANG
+template 
+_LIBCPP_INLINE_VISIBILITY
+void __emplace_back(_Arg&& __arg) { 
emplace_back(_VSTD::forward<_Arg>(__arg)); }
+#else
+_LIBCPP_INLINE_VISIBILITY
+void __emplace_back(value_type const& __arg) { push_back(__arg); }
+#endif
+
 iterator insert(const_iterator __p, const value_type& __x);
 iterator insert(const_iterator __p, size_type __n, const value_type& __x);
 template 
@@ -1189,7 +1198,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _I
 __get_db()->__insert_c(this);
 #endif
 for (; __f != __l; ++__f)
-push_back(*__f);
+__emplace_back(*__f);
 }
 
 template 
@@ -1202,7 +1211,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _I
 __get_db()->__insert_c(this);
 #endif
 for (; __f != __l; ++__f)
-push_back(*__f);
+__emplace_back(*__f);
 }
 
 template 

Modified: libcxx/branches/release_50/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/vector?rev=318837=318836=318837=diff
==
--- libcxx/branches/release_50/include/vector (original)
+++ libcxx/branches/release_50/include/vector Wed Nov 22 07:06:35 2017
@@ -674,6 +674,17 @@ public:
 const value_type* data() const _NOEXCEPT
  

[PATCH] D40224: [X86] Control-Flow Enforcement Technology - Shadow Stack and Indirect Branch Tracking support (Clang side)

2017-11-22 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon updated this revision to Diff 123937.
oren_ben_simhon added a comment.

Implemented comments posted until 11/21 (Thanks Craig)


Repository:
  rL LLVM

https://reviews.llvm.org/D40224

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Basic/BuiltinsX86_64.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cetintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/builtins-x86.c
  test/CodeGen/cetintrin.c
  test/Driver/x86-target-features.c
  test/Preprocessor/x86_target_features.c

Index: test/Preprocessor/x86_target_features.c
===
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -333,6 +333,10 @@
 
 // ADX: #define __ADX__ 1
 
+// RUN: %clang -target i386-unknown-unknown -mshstk -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CETSS %s
+
+// CETSS: #define __SHSTK__ 1
+
 // RUN: %clang -target i386-unknown-unknown -march=atom -mrdseed -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=RDSEED %s
 
 // RDSEED: #define __RDSEED__ 1
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -70,6 +70,16 @@
 // MPX: "-target-feature" "+mpx"
 // NO-MPX: "-target-feature" "-mpx"
 
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mshstk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CETSS %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-shstk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-CETSS %s
+// CETSS: "-target-feature" "+shstk"
+// NO-CETSS: "-target-feature" "-shstk"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mibt %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CETIBT %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-ibt %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-CETIBT %s
+// CETIBT: "-target-feature" "+ibt"
+// NO-CETIBT: "-target-feature" "-ibt"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msgx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SGX %s
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sgx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SGX %s
 // SGX: "-target-feature" "+sgx"
Index: test/CodeGen/cetintrin.c
===
--- /dev/null
+++ test/CodeGen/cetintrin.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +shstk -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +shstk  -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=X86_64
+
+#include 
+
+void test_incsspd(int a) {
+  // CHECK-LABEL: @test_incsspd
+  // CHECK:   call void @llvm.x86.incsspd(i32 %{{[0-9]+}})
+  _incsspd(a);
+}
+
+#ifdef __x86_64__
+void test_incsspq(int a) {
+  // X86_64-LABEL: @test_incsspq
+  // X86_64:   call void @llvm.x86.incsspq(i64 %{{[a-z0-9.]+}})
+  _incsspq(a);
+}
+#endif
+
+unsigned int test_rdsspd(unsigned int a) {
+  // CHECK-LABEL: @test_rdsspd
+  // CHECK:   call i32 @llvm.x86.rdsspd(i32 %{{[a-z0-9.]+}})
+  return _rdsspd(a);
+}
+
+#ifdef __x86_64__
+unsigned long long test_rdsspq(unsigned long long a) {
+  // X86_64-LABEL: @test_rdsspq
+  // X86_64:   call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}})
+  return _rdsspq(a);
+}
+#endif
+
+void  test_saveprevssp() {
+  // CHECK-LABEL: @test_saveprevssp
+  // CHECK:   call void @llvm.x86.saveprevssp()
+  _saveprevssp();
+}
+
+void test_rstorssp(void * __p) {
+  // CHECK-LABEL: @test_rstorssp
+  // CHECK:   call void @llvm.x86.rstorssp(i8* %{{[a-z0-9.]+}})
+  _rstorssp(__p);
+}
+
+void test_wrssd(unsigned int __a, void * __p) {
+  // CHECK-LABEL: @test_wrssd
+  // CHECK:   call void @llvm.x86.wrssd(i32 %{{[a-z0-9.]+}}, i8* %{{[a-z0-9.]+}})
+  _wrssd(__a, __p);
+}
+
+#ifdef __x86_64__
+void test_wrssq(unsigned long long __a, void * __p) {
+  // X86_64-LABEL: @test_wrssq
+  // X86_64:   call void @llvm.x86.wrssq(i64 %{{[a-z0-9.]+}}, i8* %{{[a-z0-9.]+}})
+  _wrssq(__a, __p);
+}
+#endif
+
+void test_wrussd(unsigned int __a, void * __p) {
+  // CHECK-LABEL: @test_wrussd
+  // CHECK:   call void @llvm.x86.wrussd(i32 %{{[a-z0-9.]+}}, i8* %{{[a-z0-9.]+}})
+  _wrussd(__a, __p);
+}
+
+#ifdef __x86_64__
+void test_wrussq(unsigned long long __a, void * __p) {
+  // X86_64-LABEL: @test_wrussq
+  // X86_64:   call void @llvm.x86.wrussq(i64 %{{[a-z0-9.]+}}, i8* %{{[a-z0-9.]+}})
+  _wrussq(__a, __p);
+}
+#endif
+
+void test_setssbsy() {
+  // CHECK-LABEL: @test_setssbsy
+  // CHECK:   call void @llvm.x86.setssbsy()
+  _setssbsy();
+}
+
+void test_clrssbsy(void * __p) {
+  // CHECK-LABEL: @test_clrssbsy
+  // CHECK:   call void @llvm.x86.clrssbsy(i8* %{{[a-z0-9.]+}})
+  

[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-22 Thread Keith Walker via Phabricator via cfe-commits
keith.walker.arm updated this revision to Diff 123936.
keith.walker.arm added a comment.

I have updated the patch with the suggested change to use a list of features to 
disable.

I checked that LLVM does indeed implicitly disable features if they are 
dependent on a feature that is explicitly disabled, so in theory we
could just disable "vfp2" and "neon".However I found that this made the 
tests in clang more difficult to write and understand.

For example if a test wants to check that "dotprod" is not enabled:

- with the explicit disabling the check can be: CHECK-NO-DOTPROD-NOT: 
"--target-feature" "+dotprod"
- with implicit disabling the check needs to be something like: 
CHECK-NO-DOTPROD: "--target-feature" "+dotprod" CHECK-NO-DOTPROD: 
"--target-feature" "-neon"

I think this made the tests harder to understand as there is more implicit 
knowledge required to understand what is going on.

For this reason I have gone for still explicitly disabling the dependent FP 
features, with a FIXME so that this could be improved in the future.


https://reviews.llvm.org/D40256

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-cortex-cpus.c
  test/Driver/arm-dotprod.c
  test/Driver/arm-mfpu.c
  test/Preprocessor/arm-target-features.c

Index: test/Driver/arm-dotprod.c
===
--- test/Driver/arm-dotprod.c
+++ test/Driver/arm-dotprod.c
@@ -4,8 +4,21 @@
 // RUN: %clang -### -target arm -march=armv8.3a %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
 // CHECK-NONE-NOT: "-target-feature" "+dotprod"
 
-// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
-// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -march=armv8.2a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -march=armv8.3a+dotprod %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a75 %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target arm-linux-eabi -mcpu=cortex-a55 %s 2>&1 | FileCheck %s
 // CHECK: "+dotprod"
+
+// The following default to -msoft-float
+// RUN: %clang -### -target arm -march=armv8.2a+dotprod %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -march=armv8.3a+dotprod %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a75 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// RUN: %clang -### -target arm -mcpu=cortex-a55 %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-DOTPROD
+// We rely on the backend disabling dotprod as it depends on neon, so check that
+// neon is disabled after the dotprod was enabled.
+// CHECK-NO-DOTPROD-NOT: "+dotprod"
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -284,13 +284,13 @@
 // RUN: %clang -target arm -march=armebv8.2-a -mbig-endian -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V82A-THUMB %s
 // CHECK-BE-V82A-THUMB: "-cc1"{{.*}} "-triple" "thumbebv8.2a-{{.*}}" "-target-cpu" "generic"
 
-// RUN: %clang -target armv8a -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -march=armv8.2-a+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-V82A-FP16 %s
 // CHECK-V82A-FP16: "-cc1"{{.*}} "-triple" "armv8.2{{.*}}" "-target-cpu" "generic" {{.*}}"-target-feature" "+fullfp16"
 
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
-// RUN: %clang -target armv8a -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
-// RUN: %clang -target armv8a -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
+// RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+nofp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-NOFP16 %s
 // CHECK-CORTEX-A53-FP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "+fullfp16"
 // CHECK-CORTEX-A53-NOFP16: "-cc1" {{.*}}"-target-cpu" "cortex-a53" {{.*}}"-target-feature" "-fullfp16"
 
Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target arm-linux-eabi %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-DEFAULT: "-target-feature" 

[PATCH] D40288: [clang-format] Add option to group multiple #include blocks when sorting includes

2017-11-22 Thread Krzysztof Kapusta via Phabricator via cfe-commits
KrzysztofKapusta added inline comments.



Comment at: unittests/Format/SortIncludesTest.cpp:357
+ "#include \"c.h\"\n",
+ "a.cc"));
+}

krasimir wrote:
> What is this testing?
I changed this to better reflect what I was trying to test. Now the expected 
order is not sorted from a..c 


Repository:
  rL LLVM

https://reviews.llvm.org/D40288



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


[PATCH] D40354: [OpenMP] Adjust arguments of nvptx runtime functions

2017-11-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318836: [OpenMP] Adjust arguments of nvptx runtime functions 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D40354?vs=123930=123934#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40354

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
  cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -22,19 +22,21 @@
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit);
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit,
+  /// int16_t RequiresOMPRuntime);
   OMPRTL_NVPTX__kmpc_kernel_init,
-  /// \brief Call to void __kmpc_kernel_deinit();
+  /// \brief Call to void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized);
   OMPRTL_NVPTX__kmpc_kernel_deinit,
   /// \brief Call to void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
-  /// short RequiresOMPRuntime, short RequiresDataSharing);
+  /// int16_t RequiresOMPRuntime, int16_t RequiresDataSharing);
   OMPRTL_NVPTX__kmpc_spmd_kernel_init,
   /// \brief Call to void __kmpc_spmd_kernel_deinit();
   OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
-  /// *outlined_function);
+  /// *outlined_function, void ***args, kmp_int32 nArgs);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
-  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function);
+  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function, void
+  /// ***args);
   OMPRTL_NVPTX__kmpc_kernel_parallel,
   /// \brief Call to void __kmpc_kernel_end_parallel();
   OMPRTL_NVPTX__kmpc_kernel_end_parallel,
@@ -355,7 +357,9 @@
   CGF.EmitBlock(MasterBB);
   // First action in sequential region:
   // Initialize the state of the OpenMP runtime library on the GPU.
-  llvm::Value *Args[] = {getThreadLimit(CGF)};
+  // TODO: Optimize runtime initialization and pass in correct value.
+  llvm::Value *Args[] = {getThreadLimit(CGF),
+ Bld.getInt16(/*RequiresOMPRuntime=*/1)};
   CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_init), Args);
 }
@@ -370,8 +374,10 @@
 
   CGF.EmitBlock(TerminateBB);
   // Signal termination condition.
+  // TODO: Optimize runtime initialization and pass in correct value.
+  llvm::Value *Args[] = {CGF.Builder.getInt16(/*IsOMPRuntimeInitialized=*/1)};
   CGF.EmitRuntimeCall(
-  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_deinit), None);
+  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_deinit), Args);
   // Barrier to terminate worker threads.
   syncCTAThreads(CGF);
   // Master thread jumps to exit point.
@@ -597,23 +603,25 @@
   llvm::Constant *RTLFn = nullptr;
   switch (static_cast(Function)) {
   case OMPRTL_NVPTX__kmpc_kernel_init: {
-// Build void __kmpc_kernel_init(kmp_int32 thread_limit);
-llvm::Type *TypeParams[] = {CGM.Int32Ty};
+// Build void __kmpc_kernel_init(kmp_int32 thread_limit, int16_t
+// RequiresOMPRuntime);
+llvm::Type *TypeParams[] = {CGM.Int32Ty, CGM.Int16Ty};
 llvm::FunctionType *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_init");
 break;
   }
   case OMPRTL_NVPTX__kmpc_kernel_deinit: {
-// Build void __kmpc_kernel_deinit();
+// Build void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized);
+llvm::Type *TypeParams[] = {CGM.Int16Ty};
 llvm::FunctionType *FnTy =
-llvm::FunctionType::get(CGM.VoidTy, llvm::None, /*isVarArg*/ false);
+llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_deinit");
 break;
   }
   case OMPRTL_NVPTX__kmpc_spmd_kernel_init: {
 // Build void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
-// short RequiresOMPRuntime, short RequiresDataSharing);
+// int16_t RequiresOMPRuntime, int16_t RequiresDataSharing);
 llvm::Type *TypeParams[] = {CGM.Int32Ty, CGM.Int16Ty, CGM.Int16Ty};
 llvm::FunctionType *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
Index: cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
===
--- cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
+++ cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
@@ -166,7 +166,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void 

r318836 - [OpenMP] Adjust arguments of nvptx runtime functions

2017-11-22 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Wed Nov 22 06:46:49 2017
New Revision: 318836

URL: http://llvm.org/viewvc/llvm-project?rev=318836=rev
Log:
[OpenMP] Adjust arguments of nvptx runtime functions

In the future the compiler will analyze whether the OpenMP
runtime needs to be (fully) initialized and avoid that overhead
if possible. The functions already take an argument to transfer
that information to the runtime, so pass in the default value 1.
(This is needed for binary compatibility with libomptarget-nvptx
currently being upstreamed.)

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=318836=318835=318836=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Wed Nov 22 06:46:49 2017
@@ -22,19 +22,21 @@ using namespace CodeGen;
 
 namespace {
 enum OpenMPRTLFunctionNVPTX {
-  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit);
+  /// \brief Call to void __kmpc_kernel_init(kmp_int32 thread_limit,
+  /// int16_t RequiresOMPRuntime);
   OMPRTL_NVPTX__kmpc_kernel_init,
-  /// \brief Call to void __kmpc_kernel_deinit();
+  /// \brief Call to void __kmpc_kernel_deinit(int16_t 
IsOMPRuntimeInitialized);
   OMPRTL_NVPTX__kmpc_kernel_deinit,
   /// \brief Call to void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
-  /// short RequiresOMPRuntime, short RequiresDataSharing);
+  /// int16_t RequiresOMPRuntime, int16_t RequiresDataSharing);
   OMPRTL_NVPTX__kmpc_spmd_kernel_init,
   /// \brief Call to void __kmpc_spmd_kernel_deinit();
   OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
-  /// *outlined_function);
+  /// *outlined_function, void ***args, kmp_int32 nArgs);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
-  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function);
+  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function, void
+  /// ***args);
   OMPRTL_NVPTX__kmpc_kernel_parallel,
   /// \brief Call to void __kmpc_kernel_end_parallel();
   OMPRTL_NVPTX__kmpc_kernel_end_parallel,
@@ -355,7 +357,9 @@ void CGOpenMPRuntimeNVPTX::emitGenericEn
   CGF.EmitBlock(MasterBB);
   // First action in sequential region:
   // Initialize the state of the OpenMP runtime library on the GPU.
-  llvm::Value *Args[] = {getThreadLimit(CGF)};
+  // TODO: Optimize runtime initialization and pass in correct value.
+  llvm::Value *Args[] = {getThreadLimit(CGF),
+ Bld.getInt16(/*RequiresOMPRuntime=*/1)};
   CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_init), Args);
 }
@@ -370,8 +374,10 @@ void CGOpenMPRuntimeNVPTX::emitGenericEn
 
   CGF.EmitBlock(TerminateBB);
   // Signal termination condition.
+  // TODO: Optimize runtime initialization and pass in correct value.
+  llvm::Value *Args[] = {CGF.Builder.getInt16(/*IsOMPRuntimeInitialized=*/1)};
   CGF.EmitRuntimeCall(
-  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_deinit), None);
+  createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_deinit), Args);
   // Barrier to terminate worker threads.
   syncCTAThreads(CGF);
   // Master thread jumps to exit point.
@@ -597,23 +603,25 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
   llvm::Constant *RTLFn = nullptr;
   switch (static_cast(Function)) {
   case OMPRTL_NVPTX__kmpc_kernel_init: {
-// Build void __kmpc_kernel_init(kmp_int32 thread_limit);
-llvm::Type *TypeParams[] = {CGM.Int32Ty};
+// Build void __kmpc_kernel_init(kmp_int32 thread_limit, int16_t
+// RequiresOMPRuntime);
+llvm::Type *TypeParams[] = {CGM.Int32Ty, CGM.Int16Ty};
 llvm::FunctionType *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_init");
 break;
   }
   case OMPRTL_NVPTX__kmpc_kernel_deinit: {
-// Build void __kmpc_kernel_deinit();
+// Build void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized);
+llvm::Type *TypeParams[] = {CGM.Int16Ty};
 llvm::FunctionType *FnTy =
-llvm::FunctionType::get(CGM.VoidTy, llvm::None, /*isVarArg*/ false);
+llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_deinit");
 break;
   }
   case OMPRTL_NVPTX__kmpc_spmd_kernel_init: {
 // Build void __kmpc_spmd_kernel_init(kmp_int32 thread_limit,
-// short RequiresOMPRuntime, short RequiresDataSharing);
+// 

[libcxx] r318835 - Merging r312892:

2017-11-22 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Nov 22 06:45:26 2017
New Revision: 318835

URL: http://llvm.org/viewvc/llvm-project?rev=318835=rev
Log:
Merging r312892:


r312892 | ericwf | 2017-09-10 16:41:20 -0700 (Sun, 10 Sep 2017) | 10 lines

Fix PR34298 - Allow std::function with an incomplete return type.

This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated
the __invokable trait via the converting constructor `function(Tp)` [with Tp = 
std::function]
whenever the copy constructor or copy assignment operator
was required. This patch further constrains that constructor to short
circut before evaluating the troublesome SFINAE when `Tp` matches
std::function.

The original patch is from Alex Lorenz.


Modified:
libcxx/branches/release_50/include/functional
libcxx/branches/release_50/include/type_traits

libcxx/branches/release_50/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp

Modified: libcxx/branches/release_50/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/functional?rev=318835=318834=318835=diff
==
--- libcxx/branches/release_50/include/functional (original)
+++ libcxx/branches/release_50/include/functional Wed Nov 22 06:45:26 2017
@@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
   return reinterpret_cast<__base*>(p);
 }
 
-template ::value &&
-__invokable<_Fp&, _ArgTypes...>::value>
-struct __callable;
+template , function>::value>,
+__invokable<_Fp&, _ArgTypes...>
+>::value>
+struct __callable;
 template 
 struct __callable<_Fp, true>
 {
@@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(
 {
 static const bool value = false;
 };
+
+  template 
+  using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
 public:
 typedef _Rp result_type;
 
@@ -1622,9 +1627,7 @@ public:
 function(nullptr_t) _NOEXCEPT : __f_(0) {}
 function(const function&);
 function(function&&) _NOEXCEPT;
-template::value && !is_same<_Fp, function>::value
->::type>
+template>
 function(_Fp);
 
 #if _LIBCPP_STD_VER <= 14
@@ -1638,21 +1641,15 @@ public:
   function(allocator_arg_t, const _Alloc&, const function&);
 template
   function(allocator_arg_t, const _Alloc&, function&&);
-template::value>::type>
+template>
   function(allocator_arg_t, const _Alloc& __a, _Fp __f);
 #endif
 
 function& operator=(const function&);
 function& operator=(function&&) _NOEXCEPT;
 function& operator=(nullptr_t) _NOEXCEPT;
-template
-  typename enable_if
-  <
-__callable::type>::value &&
-!is_same::type, function>::value,
-function&
-  >::type
-  operator=(_Fp&&);
+template>
+function& operator=(_Fp&&);
 
 ~function();
 
@@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(n
 }
 
 template
-template 
-typename enable_if
-<
-function<_Rp(_ArgTypes...)>::template __callable::type>::value &&
-!is_same::type, 
function<_Rp(_ArgTypes...)>>::value,
-function<_Rp(_ArgTypes...)>&
->::type
+template 
+function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
 {
 function(_VSTD::forward<_Fp>(__f)).swap(*this);

Modified: libcxx/branches/release_50/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/type_traits?rev=318835=318834=318835=diff
==
--- libcxx/branches/release_50/include/type_traits (original)
+++ libcxx/branches/release_50/include/type_traits Wed Nov 22 06:45:26 2017
@@ -4339,8 +4339,8 @@ struct __invokable_r
 using _Result = decltype(
 _VSTD::__invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...));
 
-static const bool value =
-conditional<
+using type =
+typename conditional<
 !is_same<_Result, __nat>::value,
 typename conditional<
 is_void<_Ret>::value,
@@ -4348,7 +4348,8 @@ struct __invokable_r
 is_convertible<_Result, _Ret>
 >::type,
 false_type
->::type::value;
+>::type;
+static const bool value = type::value;
 };
 
 template 

Modified: 
libcxx/branches/release_50/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp?rev=318835=318834=318835=diff

[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2017-11-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 123932.
ABataev added a comment.

Added codegen for `target teams` construct.


https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,74 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework 
is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 
codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :partial:`Partial`.  No support for the 
`reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp target parallel for [simd]: :partial:`Partial`.  No support for 
the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp target simd: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp target teams: :partial:`Partial`.  No support for the 
`reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp teams distribute [simd]: :partial:`Partial`.  No full codegen 
support.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No full 
codegen support.
+
+* #pragma omp teams distribute parallel for [simd]: :partial:`Partial`.  No 
full codegen support.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task`-based directives.
+


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,74 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 

[PATCH] D40354: [OpenMP] Adjust arguments of nvptx runtime functions

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

LG


https://reviews.llvm.org/D40354



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


[PATCH] D40354: [OpenMP] Adjust arguments of nvptx runtime functions

2017-11-22 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Herald added a subscriber: jholewinski.

In the future the compiler will analyze whether the OpenMP
runtime needs to be (fully) initialized and avoid that overhead
if possible. The functions already take an argument to transfer
that information to the runtime, so pass in the default value 1.
(This is needed for binary compatibility with libomptarget-nvptx
currently being upstreamed.)


https://reviews.llvm.org/D40354

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp
  test/OpenMP/nvptx_teams_reduction_codegen.cpp

Index: test/OpenMP/nvptx_teams_reduction_codegen.cpp
===
--- test/OpenMP/nvptx_teams_reduction_codegen.cpp
+++ test/OpenMP/nvptx_teams_reduction_codegen.cpp
@@ -84,7 +84,7 @@
   // CHECK: br label %[[EXIT]]
   //
   // CHECK: [[EXIT]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
 
   //
   // Reduction function
@@ -360,7 +360,7 @@
   // CHECK: br label %[[EXIT]]
   //
   // CHECK: [[EXIT]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
 
   //
   // Reduction function
@@ -776,7 +776,7 @@
   // CHECK: br label %[[EXIT]]
   //
   // CHECK: [[EXIT]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
 
   //
   // Reduction function
Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -125,7 +125,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -211,7 +211,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- test/OpenMP/nvptx_target_codegen.cpp
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -91,7 +91,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -168,7 +168,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -278,7 +278,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -441,7 +441,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -531,7 +531,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -616,7 +616,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -166,7 +166,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
@@ -303,7 +303,7 @@
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
-  // CHECK: call void @__kmpc_kernel_deinit()
+  // CHECK: call void @__kmpc_kernel_deinit(
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: br label {{%?}}[[EXIT]]
   //
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp

r318834 - [OPENMP] Codegen for `target teams` directive.

2017-11-22 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Nov 22 06:25:55 2017
New Revision: 318834

URL: http://llvm.org/viewvc/llvm-project?rev=318834=rev
Log:
[OPENMP] Codegen for `target teams` directive.

Added codegen of the clauses for `target teams` directive.

Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=318834=318833=318834=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Wed Nov 22 06:25:55 2017
@@ -3812,11 +3812,20 @@ static void emitTargetTeamsRegion(CodeGe
   const OMPTargetTeamsDirective ) {
   auto *CS = S.getCapturedStmt(OMPD_teams);
   Action.Enter(CGF);
-  auto & = [CS](CodeGenFunction , PrePostActionTy &) {
-// TODO: Add support for clauses.
+  // Emit teams region as a standalone region.
+  auto & = [, CS](CodeGenFunction , PrePostActionTy ) {
+CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
+(void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);
+CGF.EmitOMPPrivateClause(S, PrivateScope);
+CGF.EmitOMPReductionClauseInit(S, PrivateScope);
+(void)PrivateScope.Privatize();
+Action.Enter(CGF);
 CGF.EmitStmt(CS->getCapturedStmt());
+CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
   emitCommonOMPTeamsDirective(CGF, S, OMPD_teams, CodeGen);
+  emitPostUpdateForReductionClause(
+  CGF, S, [](CodeGenFunction &) -> llvm::Value * { return nullptr; });
 }
 
 void CodeGenFunction::EmitOMPTargetTeamsDeviceFunction(

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=318834=318833=318834=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Nov 22 06:25:55 2017
@@ -7182,6 +7182,16 @@ StmtResult Sema::ActOnOpenMPTargetTeamsD
   // longjmp() and throw() must not violate the entry/exit criteria.
   CS->getCapturedDecl()->setNothrow();
 
+  for (int ThisCaptureLevel = getOpenMPCaptureLevels(OMPD_target_teams);
+   ThisCaptureLevel > 1; --ThisCaptureLevel) {
+CS = cast(CS->getCapturedStmt());
+// 1.2.2 OpenMP Language Terminology
+// Structured block - An executable statement with a single entry at the
+// top and a single exit at the bottom.
+// The point of exit cannot be a branch out of the structured block.
+// longjmp() and throw() must not violate the entry/exit criteria.
+CS->getCapturedDecl()->setNothrow();
+  }
   getCurFunction()->setHasBranchProtectedScope();
 
   return OMPTargetTeamsDirective::Create(Context, StartLoc, EndLoc, Clauses,

Modified: cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp?rev=318834=318833=318834=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp Wed Nov 22 06:25:55 
2017
@@ -121,7 +121,9 @@ int bar(int n){
   // CHECK: [[ACV:%.+]] = load i[[SZ]], i[[SZ]]* [[AC]], align
   // CHECK: store i[[SZ]] [[ACV]], i[[SZ]]* [[A_ADDR_T:%.+]], align
   // CHECK: [[CONV2:%.+]] = bitcast i[[SZ]]* [[A_ADDR_T]] to i8*
-  // CHECK: store i8 49, i8* [[CONV2]], align
+  // CHECK: [[LD_CONV2:%.+]] = load i8, i8* [[CONV2]],
+  // CHECK: store i8 [[LD_CONV2]], i8* [[A_PRIV:%[^,]+]],
+  // CHECK: store i8 49, i8* [[A_PRIV]], align
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]
@@ -207,7 +209,9 @@ int bar(int n){
   // CHECK: [[ACV:%.+]] = load i[[SZ]], i[[SZ]]* [[AC]], align
   // CHECK: store i[[SZ]] [[ACV]], i[[SZ]]* [[AA_ADDR_T:%.+]], align
   // CHECK: [[CONV2:%.+]] = bitcast i[[SZ]]* [[AA_ADDR_T]] to i16*
-  // CHECK: store i16 1, i16* [[CONV2]], align
+  // CHECK: [[LD_CONV2:%.+]] = load i16, i16* [[CONV2]],
+  // CHECK: store i16 [[LD_CONV2]], i16* [[A_PRIV:%[^,]+]],
+  // CHECK: store i16 1, i16* [[A_PRIV]], align
   // CHECK: br label {{%?}}[[TERMINATE:.+]]
   //
   // CHECK: [[TERMINATE]]

Modified: cfe/trunk/test/OpenMP/target_teams_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_teams_codegen.cpp?rev=318834=318833=318834=diff
==
--- cfe/trunk/test/OpenMP/target_teams_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_teams_codegen.cpp Wed Nov 22 06:25:55 2017
@@ -38,7 +38,9 @@
 // code, only 6 will have mapped arguments, and only 4 have all-constant map
 // sizes.
 
-// CHECK-DAG: 

[PATCH] D40288: [clang-format] Add option to group multiple #include blocks when sorting includes

2017-11-22 Thread Krzysztof Kapusta via Phabricator via cfe-commits
KrzysztofKapusta updated this revision to Diff 123924.
KrzysztofKapusta added a comment.

Addressed all comments. Changed one testcase to better reflect the desired 
effect.


Repository:
  rL LLVM

https://reviews.llvm.org/D40288

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -77,6 +77,28 @@
   EXPECT_TRUE(sortIncludes(Style, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
+TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "\n"
+ "#include \"b.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, SupportClangFormatOff) {
   EXPECT_EQ("#include \n"
 "#include \n"
@@ -159,6 +181,48 @@
  "#include \"b.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) {
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"c.h\"\n"
+ "\n"
+ "#include \"b.h\"\n"));
+}
+
+TEST_F(SortIncludesTest, CommentsAlwaysSeparateGroups) {
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"// comment\n"
+"#include \"b.h\"\n",
+sort("#include \"c.h\"\n"
+ "#include \"a.h\"\n"
+ "// comment\n"
+ "#include \"b.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, HandlesAngledIncludesAsSeparateBlocks) {
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
@@ -180,6 +244,19 @@
  "#include \"a.h\"\n"));
 }
 
+TEST_F(SortIncludesTest, RegroupsAngledIncludesInSeparateBlocks) {
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"c.h\"\n"
+"\n"
+"#include \n"
+"#include \n",
+sort("#include \n"
+ "#include \n"
+ "#include \"c.h\"\n"
+ "#include \"a.h\"\n"));
+}
+
 TEST_F(SortIncludesTest, HandlesMultilineIncludes) {
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"b.h\"\n"
@@ -266,6 +343,35 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) {
+  Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
+  Style.IncludeBlocks = FormatStyle::IBS_Merge;
+
+  EXPECT_EQ("#include \"c.h\"\n"
+"#include \"a.h\"\n"
+"#include \"b.h\"\n",
+sort("#include \"b.h\"\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"c.h\"\n",
+ "c.cc"));
+}
+
+TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) {
+  Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
+  Style.IncludeBlocks = FormatStyle::IBS_Regroup;
+
+  EXPECT_EQ("#include \"a.h\"\n"
+"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"b.h\"\n"
+ "\n"
+ "#include \"a.h\"\n"
+ "#include \"c.h\"\n",
+ "a.cc"));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
@@ -309,6 +415,34 @@
  "c_main.cc"));
 }
 
+TEST_F(SortIncludesTest, PriorityGroupsAreSeparatedWhenRegroupping) {
+  Style.IncludeCategories = 

[concepts] Step 1: Remove unneeded partial support for concepts.

2017-11-22 Thread Saar Raz via cfe-commits
As part of the roadmap for concepts,
https://github.com/saarraz/clang-concepts-roadmap, as discussed on
[cfe-dev] -
http://lists.llvm.org/pipermail/cfe-dev/2017-November/056009.html, we're
doing incremental commits with the end goal of supporting concepts as they
are in the current C++2a working draft.
This is the first step - removing old support for function and variable
concepts in preparation for the addition of concepts as they are defined in
the current working draft.
Tests were removed because they are no longer relevant/true to the current
standard. A very small amount of them can be adapted, and will be salvaged
later when we have some compilation code to support them.
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 2879452f24..d764e485dd 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -383,7 +383,7 @@ protected:
   TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC,
SourceLocation L, DeclarationName Name,
TemplateParameterList *Params)
-  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false),
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
 TemplateParams(CTDI) {
 this->setTemplateParameters(Params);
   }
@@ -396,7 +396,7 @@ protected:
   TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC,
SourceLocation L, DeclarationName Name,
TemplateParameterList *Params, NamedDecl *Decl)
-  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl, false),
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl),
 TemplateParams(CTDI) {
 this->setTemplateParameters(Params);
   }
@@ -428,7 +428,7 @@ public:
   }
 
   /// Get the underlying, templated declaration.
-  NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); }
+  NamedDecl *getTemplatedDecl() const { return TemplatedDecl; }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -438,20 +438,13 @@ public:
 
   SourceRange getSourceRange() const override LLVM_READONLY {
 return SourceRange(getTemplateParameters()->getTemplateLoc(),
-   TemplatedDecl.getPointer()->getSourceRange().getEnd());
+   TemplatedDecl->getSourceRange().getEnd());
   }
 
-  /// Whether this is a (C++ Concepts TS) function or variable concept.
-  bool isConcept() const { return TemplatedDecl.getInt(); }
-  void setConcept() { TemplatedDecl.setInt(true); }
-
 protected:
   /// \brief The named declaration from which this template was instantiated.
   /// (or null).
-  ///
-  /// The boolean value will be true to indicate that this template
-  /// (function or variable) is a concept.
-  llvm::PointerIntPair TemplatedDecl;
+  NamedDecl *TemplatedDecl;
 
   /// \brief The template parameter list and optional requires-clause
   /// associated with this declaration; alternatively, a
@@ -481,9 +474,9 @@ public:
   /// \brief Initialize the underlying templated declaration and
   /// template parameters.
   void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
-assert(!TemplatedDecl.getPointer() && "TemplatedDecl already set!");
+assert(!TemplatedDecl && "TemplatedDecl already set!");
 assert(!TemplateParams && "TemplateParams already set!");
-TemplatedDecl.setPointer(templatedDecl);
+TemplatedDecl = templatedDecl;
 TemplateParams = templateParams;
   }
 };
@@ -996,7 +989,7 @@ public:
 
   /// Get the underlying function declaration of the template.
   FunctionDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl.getPointer());
+return static_cast(TemplatedDecl);
   }
 
   /// Returns whether this template declaration defines the primary
@@ -2092,7 +2085,7 @@ public:
 
   /// \brief Get the underlying class declarations of the template.
   CXXRecordDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl.getPointer());
+return static_cast(TemplatedDecl);
   }
 
   /// \brief Returns whether this template declaration defines the primary
@@ -2345,7 +2338,7 @@ protected:
 public:
   /// Get the underlying function declaration of the template.
   TypeAliasDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl.getPointer());
+return static_cast(TemplatedDecl);
   }
 
 
@@ -2900,7 +2893,7 @@ public:
 
   /// \brief Get the underlying variable declarations of the template.
   VarDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl.getPointer());
+return static_cast(TemplatedDecl);
   }
 
   /// \brief Returns whether this template declaration defines the primary
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 8725415af9..a4719c2260 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2366,30 +2366,15 @@ 

[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-22 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin updated this revision to Diff 123923.

https://reviews.llvm.org/D40181

Files:
  include/__config
  include/__locale
  include/support/win32/locale_win32.h
  src/support/win32/locale_win32.cpp

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -877,7 +877,7 @@
 #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) ||   \
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -18,23 +18,9 @@
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
 {
-return _create_locale( mask, locale );
+return {_create_locale( LC_ALL, locale ), locale};
 }
 
-locale_t uselocale( locale_t newloc )
-{
-locale_t old_locale = _get_current_locale();
-if ( newloc == NULL )
-return old_locale;
-// uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
-_configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
-// uselocale sets all categories
-// disable setting locale on Windows temporarily because the structure is opaque (PR31516)
-//setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
-// uselocale returns the old locale_t
-return old_locale;
-}
-
 decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
 {
 #if defined(_LIBCPP_MSVCRT)
Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -14,6 +14,7 @@
 #include <__config>
 #include 
 #include  // _locale_t
+#include <__nullptr>
 
 #define LC_COLLATE_MASK _M_COLLATE
 #define LC_CTYPE_MASK _M_CTYPE
@@ -28,13 +29,77 @@
  | LC_NUMERIC_MASK \
  | LC_TIME_MASK )
 
-#define locale_t _locale_t
+class locale_t {
+public:
+locale_t()
+: __locale(nullptr), __locale_str(nullptr) {}
+locale_t(std::nullptr_t)
+: __locale(nullptr), __locale_str(nullptr) {}
+locale_t(_locale_t __locale, const char* __locale_str)
+: __locale(__locale), __locale_str(__locale_str) {}
 
+friend bool operator==(const locale_t& __left, const locale_t& __right) {
+return __left.__locale == __right.__locale;
+}
+
+friend bool operator==(const locale_t& __left, int __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
+friend bool operator==(const locale_t& __left, std::nullptr_t) {
+return __left.__locale == nullptr;
+}
+
+friend bool operator==(int __left, const locale_t& __right) {
+return __left == 0 && nullptr == __right.__locale;
+}
+
+friend bool operator==(std::nullptr_t, const locale_t& __right) {
+return nullptr == __right.__locale;
+}
+
+friend bool operator!=(const locale_t& __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(const locale_t& __left, int __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(int __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(std::nullptr_t __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+operator bool() const {
+return __locale != nullptr;
+}
+
+const char* __get_locale() const { return __locale_str; }
+
+operator _locale_t() const {
+return __locale;
+}
+private:
+_locale_t __locale;
+const char* __locale_str;
+};
+
 // Locale management functions
 #define freelocale _free_locale
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t base );
-locale_t uselocale( locale_t newloc );
+// uselocale can't be implemented on Windows because Windows allows partial modification
+// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
+// not create any copies.
+// We can still implement raii even without uselocale though.
 
 
 lconv *localeconv_l( locale_t loc );
Index: include/__locale
===
--- include/__locale
+++ include/__locale
@@ -49,7 +49,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if 

[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-22 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin added a comment.

In https://reviews.llvm.org/D40181#930779, @mstorsjo wrote:

>   (but I think it does define some sort of dummy functions that at least will 
> allow it to build)


Looked into MinGW-w64 sources and this is indeed the case. _configthreadlocale 
will return -1 and will not do anything.


https://reviews.llvm.org/D40181



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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-22 Thread Andrey Khalyavin via Phabricator via cfe-commits
halyavin updated this revision to Diff 123921.
halyavin added a comment.
Herald added a subscriber: krytarowski.

Fixed problem with C++98, added std for nullptr_t and switched on _l functions 
for MinGW.


https://reviews.llvm.org/D40181

Files:
  include/__config
  include/__locale
  include/support/win32/locale_win32.h
  src/support/win32/locale_win32.cpp

Index: include/__config
===
--- include/__config
+++ include/__config
@@ -877,7 +877,7 @@
 #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
 #endif
 
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) ||   \
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
 defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
Index: src/support/win32/locale_win32.cpp
===
--- src/support/win32/locale_win32.cpp
+++ src/support/win32/locale_win32.cpp
@@ -18,23 +18,9 @@
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
 {
-return _create_locale( mask, locale );
+return {_create_locale( LC_ALL, locale ), locale};
 }
 
-locale_t uselocale( locale_t newloc )
-{
-locale_t old_locale = _get_current_locale();
-if ( newloc == NULL )
-return old_locale;
-// uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
-_configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
-// uselocale sets all categories
-// disable setting locale on Windows temporarily because the structure is opaque (PR31516)
-//setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
-// uselocale returns the old locale_t
-return old_locale;
-}
-
 decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
 {
 #if defined(_LIBCPP_MSVCRT)
Index: include/support/win32/locale_win32.h
===
--- include/support/win32/locale_win32.h
+++ include/support/win32/locale_win32.h
@@ -14,6 +14,7 @@
 #include <__config>
 #include 
 #include  // _locale_t
+#include <__nullptr>
 
 #define LC_COLLATE_MASK _M_COLLATE
 #define LC_CTYPE_MASK _M_CTYPE
@@ -28,13 +29,77 @@
  | LC_NUMERIC_MASK \
  | LC_TIME_MASK )
 
-#define locale_t _locale_t
+class locale_t {
+public:
+locale_t()
+: __locale(nullptr), __locale_str(nullptr) {}
+locale_t(std::nullptr_t)
+: __locale(nullptr), __locale_str(nullptr) {}
+locale_t(_locale_t __locale, const char* __locale_str)
+: __locale(__locale), __locale_str(__locale_str) {}
 
+friend bool operator==(const locale_t& __left, const locale_t& __right) {
+return __left.__locale == __right.__locale;
+}
+
+friend bool operator==(const locale_t& __left, int __right) {
+return __left.__locale == nullptr && __right == 0;
+}
+
+friend bool operator==(const locale_t& __left, std::nullptr_t) {
+return __left.__locale == nullptr;
+}
+
+friend bool operator==(int __left, const locale_t& __right) {
+return __left == 0 && nullptr == __right.__locale;
+}
+
+friend bool operator==(std::nullptr_t, const locale_t& __right) {
+return nullptr == __right.__locale;
+}
+
+friend bool operator!=(const locale_t& __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(const locale_t& __left, int __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(int __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+friend bool operator!=(std::nullptr_t __left, const locale_t& __right) {
+return !(__left == __right);
+}
+
+operator bool() const {
+return __locale != nullptr;
+}
+
+const char* __get_locale() const { return __locale_str; }
+
+operator _locale_t() const {
+return __locale;
+}
+private:
+_locale_t __locale;
+const char* __locale_str;
+};
+
 // Locale management functions
 #define freelocale _free_locale
 // FIXME: base currently unused. Needs manual work to construct the new locale
 locale_t newlocale( int mask, const char * locale, locale_t base );
-locale_t uselocale( locale_t newloc );
+// uselocale can't be implemented on Windows because Windows allows partial modification
+// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
+// not create any copies.
+// We can still implement raii even without uselocale though.
 
 
 lconv *localeconv_l( locale_t loc );
Index: include/__locale

Re: [PATCH] D40065: [libcxx] [test] Change (void)s to TEST_IGNORE_NODISCARD as requested by Eric.

2017-11-22 Thread Evgeny Astigeevich via cfe-commits
Yes, r318830 has made our libcxx buildbots green.  The public ones should 
become green as well.

Thanks,
Evgeny

-Original Message-
From: Billy O'Neal 
Date: Wednesday, 22 November 2017 at 12:30
To: Evgeny Astigeevich 
Cc: "reviews+d40065+public+cdf4c853d41b4...@reviews.llvm.org" 
, Billy Robert O'Neal 
III via Phabricator , "e...@efcs.ca" , 
"mclow.li...@gmail.com" , "cfe-commits@lists.llvm.org" 
, nd 
Subject: Re: [PATCH] D40065: [libcxx] [test] Change (void)s to 
TEST_IGNORE_NODISCARD as requested by Eric.

OK, I think r318830 fixes the other one here. Thanks!

Billy3

On Wed, Nov 22, 2017 at 4:25 AM, Billy O'Neal  wrote:
> Sorry, I saw one bot fail and I thought I fixed it with
> 37332d772480307af423fbea817c29a0832be86e but apparently there were
> others I missed.
>
> On Wed, Nov 22, 2017 at 4:04 AM, Evgeny Astigeevich
>  wrote:
>> Hi Billy,
>>
>> These changes caused buildbot failures: tuple.by.type.fail.cpp Line 19: 
>> unknown type name 'TEST_IGNORE_NODISCARD'
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14/builds/1109
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17/builds/1
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/924
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/972
>>
>> Thanks,
>> Evgeny Astigeevich
>>
>>
>> -Original Message-
>> From: cfe-commits  on behalf of Billy 
>> Robert O'Neal III via Phabricator via cfe-commits 
>> 
>> Reply-To: "reviews+d40065+public+cdf4c853d41b4...@reviews.llvm.org" 
>> , Billy Robert 
>> O'Neal III via Phabricator 
>> Date: Tuesday, 21 November 2017 at 21:38
>> To: "billy.on...@gmail.com" , "e...@efcs.ca" 
>> , "mclow.li...@gmail.com" 
>> Cc: "cfe-commits@lists.llvm.org" 
>> Subject: [PATCH] D40065: [libcxx] [test] Change (void)s to 
>> TEST_IGNORE_NODISCARD as requested by Eric.
>>
>> BillyONeal closed this revision.
>> BillyONeal added a comment.
>>
>> Committed r318804
>>
>>
>> https://reviews.llvm.org/D40065
>>
>>
>>
>> ___
>> 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] D39834: [clang] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-22 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk updated this revision to Diff 123914.

https://reviews.llvm.org/D39834

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/opt-record.c


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,8 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc 
-nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O 
-check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib 
%s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record 
-foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt 
-fno-save-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-FOPT-DISABLE
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
@@ -20,3 +22,4 @@
 // CHECK-EQ: "-cc1"
 // CHECK-EQ: "-opt-record-file" "BAR.txt"
 
+// CHECK-FOPT-DISABLE-NOT: "-fno-save-optimization-record"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4342,6 +4342,7 @@
 CmdArgs.push_back("-fapple-pragma-pack");
 
   if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_foptimization_record_file_EQ,
options::OPT_fno_save_optimization_record, false)) {
 CmdArgs.push_back("-opt-record-file");
 


Index: test/Driver/opt-record.c
===
--- test/Driver/opt-record.c
+++ test/Driver/opt-record.c
@@ -9,6 +9,8 @@
 // RUN: %clang -### -S -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -fsave-optimization-record -x cuda -nocudainc -nocudalib %s 2>&1 | FileCheck %s -check-prefix=CHECK-NO-O -check-prefix=CHECK-CUDA-DEV
 // RUN: %clang -### -S -o FOO -fsave-optimization-record -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt %s 2>&1 | FileCheck %s -check-prefix=CHECK-EQ
+// RUN: %clang -### -S -o FOO -foptimization-record-file=BAR.txt -fno-save-optimization-record %s 2>&1 | FileCheck %s --check-prefix=CHECK-FOPT-DISABLE
 
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
@@ -20,3 +22,4 @@
 // CHECK-EQ: "-cc1"
 // CHECK-EQ: "-opt-record-file" "BAR.txt"
 
+// CHECK-FOPT-DISABLE-NOT: "-fno-save-optimization-record"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4342,6 +4342,7 @@
 CmdArgs.push_back("-fapple-pragma-pack");
 
   if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_foptimization_record_file_EQ,
options::OPT_fno_save_optimization_record, false)) {
 CmdArgs.push_back("-opt-record-file");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D40065: [libcxx] [test] Change (void)s to TEST_IGNORE_NODISCARD as requested by Eric.

2017-11-22 Thread Billy O'Neal via cfe-commits
OK, I think r318830 fixes the other one here. Thanks!

Billy3

On Wed, Nov 22, 2017 at 4:25 AM, Billy O'Neal  wrote:
> Sorry, I saw one bot fail and I thought I fixed it with
> 37332d772480307af423fbea817c29a0832be86e but apparently there were
> others I missed.
>
> On Wed, Nov 22, 2017 at 4:04 AM, Evgeny Astigeevich
>  wrote:
>> Hi Billy,
>>
>> These changes caused buildbot failures: tuple.by.type.fail.cpp Line 19: 
>> unknown type name 'TEST_IGNORE_NODISCARD'
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14/builds/1109
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17/builds/1
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/924
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/972
>>
>> Thanks,
>> Evgeny Astigeevich
>>
>>
>> -Original Message-
>> From: cfe-commits  on behalf of Billy 
>> Robert O'Neal III via Phabricator via cfe-commits 
>> 
>> Reply-To: "reviews+d40065+public+cdf4c853d41b4...@reviews.llvm.org" 
>> , Billy Robert 
>> O'Neal III via Phabricator 
>> Date: Tuesday, 21 November 2017 at 21:38
>> To: "billy.on...@gmail.com" , "e...@efcs.ca" 
>> , "mclow.li...@gmail.com" 
>> Cc: "cfe-commits@lists.llvm.org" 
>> Subject: [PATCH] D40065: [libcxx] [test] Change (void)s to 
>> TEST_IGNORE_NODISCARD as requested by Eric.
>>
>> BillyONeal closed this revision.
>> BillyONeal added a comment.
>>
>> Committed r318804
>>
>>
>> https://reviews.llvm.org/D40065
>>
>>
>>
>> ___
>> 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] r318830 - Add another test_macros.h include I missed to tuple.by.type.pass.cpp

2017-11-22 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Wed Nov 22 04:29:17 2017
New Revision: 318830

URL: http://llvm.org/viewvc/llvm-project?rev=318830=rev
Log:
Add another test_macros.h include I missed to tuple.by.type.pass.cpp

Modified:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp?rev=318830=318829=318830=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
 Wed Nov 22 04:29:17 2017
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include "test_macros.h"
 
 struct UserType {};
 


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


Re: [PATCH] D40065: [libcxx] [test] Change (void)s to TEST_IGNORE_NODISCARD as requested by Eric.

2017-11-22 Thread Billy O'Neal via cfe-commits
Sorry, I saw one bot fail and I thought I fixed it with
37332d772480307af423fbea817c29a0832be86e but apparently there were
others I missed.

On Wed, Nov 22, 2017 at 4:04 AM, Evgeny Astigeevich
 wrote:
> Hi Billy,
>
> These changes caused buildbot failures: tuple.by.type.fail.cpp Line 19: 
> unknown type name 'TEST_IGNORE_NODISCARD'
>
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14/builds/1109
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17/builds/1
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/924
> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/972
>
> Thanks,
> Evgeny Astigeevich
>
>
> -Original Message-
> From: cfe-commits  on behalf of Billy 
> Robert O'Neal III via Phabricator via cfe-commits 
> Reply-To: "reviews+d40065+public+cdf4c853d41b4...@reviews.llvm.org" 
> , Billy Robert 
> O'Neal III via Phabricator 
> Date: Tuesday, 21 November 2017 at 21:38
> To: "billy.on...@gmail.com" , "e...@efcs.ca" 
> , "mclow.li...@gmail.com" 
> Cc: "cfe-commits@lists.llvm.org" 
> Subject: [PATCH] D40065: [libcxx] [test] Change (void)s to 
> TEST_IGNORE_NODISCARD as requested by Eric.
>
> BillyONeal closed this revision.
> BillyONeal added a comment.
>
> Committed r318804
>
>
> https://reviews.llvm.org/D40065
>
>
>
> ___
> 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] D40270: [Modules TS] Added re-export support

2017-11-22 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

All our tests pass as well. Thanks for your work!


Repository:
  rL LLVM

https://reviews.llvm.org/D40270



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


Re: [PATCH] D40065: [libcxx] [test] Change (void)s to TEST_IGNORE_NODISCARD as requested by Eric.

2017-11-22 Thread Evgeny Astigeevich via cfe-commits
Hi Billy,

These changes caused buildbot failures: tuple.by.type.fail.cpp Line 19: unknown 
type name 'TEST_IGNORE_NODISCARD'

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14/builds/1109
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17/builds/1
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/924
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/972

Thanks,
Evgeny Astigeevich


-Original Message-
From: cfe-commits  on behalf of Billy 
Robert O'Neal III via Phabricator via cfe-commits 
Reply-To: "reviews+d40065+public+cdf4c853d41b4...@reviews.llvm.org" 
, Billy Robert O'Neal 
III via Phabricator 
Date: Tuesday, 21 November 2017 at 21:38
To: "billy.on...@gmail.com" , "e...@efcs.ca" 
, "mclow.li...@gmail.com" 
Cc: "cfe-commits@lists.llvm.org" 
Subject: [PATCH] D40065: [libcxx] [test] Change (void)s to 
TEST_IGNORE_NODISCARD as requested by Eric.

BillyONeal closed this revision.
BillyONeal added a comment.

Committed r318804


https://reviews.llvm.org/D40065



___
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] D40068: Implement more accurate penalty & trade-offs while breaking protruding tokens.

2017-11-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir requested changes to this revision.
krasimir added a comment.
This revision now requires changes to proceed.

looks like there are more changes needed.


https://reviews.llvm.org/D40068



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


[PATCH] D40310: Restructure how we break tokens.

2017-11-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Here're a few nits. I'll need an evening to review the meaty part :)




Comment at: lib/Format/BreakableToken.cpp:73
+  if (ColumnLimit <= ContentStartColumn + 1) {
 return BreakableToken::Split(StringRef::npos, 0);
+  }

nit: no braces around single-statement if body.



Comment at: lib/Format/BreakableToken.cpp:198
+ "Getting the length of a part of the string literal indicates that "
+ "the code tries to reflow it.");
+  return UnbreakableTailLength + Postfix.size() +

How about clients that explicitly pass `Length = Line.size() - Offset`?



Comment at: lib/Format/BreakableToken.cpp:476
+StartColumn, Style.TabWidth, Encoding);
+  // FIXME: Test that this is handled correctly for Length != npos!
+  // The last line gets a "*/" postfAix.

Could you elaborate?



Comment at: lib/Format/BreakableToken.cpp:477
+  // FIXME: Test that this is handled correctly for Length != npos!
+  // The last line gets a "*/" postfAix.
   if (LineIndex + 1 == Lines.size()) {

nit: postfix.



Comment at: lib/Format/BreakableToken.cpp:566
 if (DelimitersOnNewline) {
   // Since we're breaking af index 1 below, the break position and the
   // break length are the same.

nit: af -> at



Comment at: lib/Format/BreakableToken.cpp:570
   if (BreakLength != StringRef::npos) {
 insertBreak(LineIndex, 0, Split(1, BreakLength), Whitespaces);
   }

nit: no braces around single-statement if bodies.



Comment at: lib/Format/BreakableToken.cpp:851
   }
+  // FIXME: Decide whether we want to reflow non-regular indents.
   return LineIndex > 0 && !CommentPragmasRegex.match(IndentContent) &&

could you give an example of what's a non-regular indent?



Comment at: lib/Format/BreakableToken.h:52
+///
+/// The mechanism to adapt the layout of the breakable token are organised
+/// around the concept of a \c Split, which is a whitespace range that 
signifies

Replace `are` with `is`.



Comment at: lib/Format/BreakableToken.h:100
+  /// \brief Returns the number of columns required to format the range at 
bytes
+  /// \p Offset to \p Offset \c + \p Length.
+  ///

Does this include the byte `Offset + Length`?



Comment at: lib/Format/BreakableToken.h:107
   ///
-  /// Note that previous breaks are not taken into account. \p TailOffset is
-  /// always specified from the start of the (original) line.
-  /// \p Length can be set to StringRef::npos, which means "to the end of 
line".
-  virtual unsigned
-  getLineLengthAfterSplit(unsigned LineIndex, unsigned TailOffset,
-  StringRef::size_type Length) const = 0;
+  /// \p StartColumn is the column at which the text starts, needed to compute
+  ///tab stops correctly.

`text` is ambiguous here: does it refer to the content of the line or to the 
range defined by the offset and length?



Comment at: lib/Format/BreakableToken.h:114
+  /// \brief Returns the column at which content in line \p LineIndex starts,
+  /// assuming no reflow.
+  virtual unsigned getContentStartColumn(unsigned LineIndex,

What is `Break` used for?



Comment at: lib/Format/BreakableToken.h:120
   /// \p LineIndex, if previously broken at \p TailOffset. If possible, do not
   /// violate \p ColumnLimit.
   virtual Split getSplit(unsigned LineIndex, unsigned TailOffset,

What is `ReflownColumn` used for?



Comment at: lib/Format/BreakableToken.h:142
   /// \brief Returns a whitespace range (offset, length) of the content at
-  /// \p LineIndex such that the content preceding this range needs to be
-  /// reformatted before any breaks are made to this line.
+  /// \p LineIndex such that the content of the current line is reflown to the
+  /// end of the previous one.

Does the current line refer to the line at LineIndex?



Comment at: lib/Format/ContinuationIndenter.cpp:1504
  : Style.PenaltyBreakComment;
-  unsigned RemainingSpace = ColumnLimit - Current.UnbreakableTailLength;
+  // Stores whether we introduce a break anywhere in the token.
   bool BreakInserted = Token->introducesBreakBeforeToken();

Does a reflow count as a break?



Comment at: unittests/Format/FormatTest.cpp:7735
 
+TEST_F(FormatTest, BreaksStringLiteralsTODO) {
+  EXPECT_EQ("C a = \"some more \"\n"

TODO?



Comment at: unittests/Format/FormatTest.cpp:10603
 format("\"一\t二 \t三 四 五\t六 \t七 八九十\tqq\"",
getLLVMStyleWithColumns(11)));
 

What 

[PATCH] D39722: [ASTImporter] Support TypeTraitExpr Importing

2017-11-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: lib/AST/ASTImporter.cpp:5622
+  SmallVector ToArgVec;
+  for (auto FromArg : E->getArgs()) {
+TypeSourceInfo *ToTI = Importer.Import(FromArg);

aaron.ballman wrote:
> `const auto *`?
By the way, you can replace the loop with `ImportContainerChecked()`.


https://reviews.llvm.org/D39722



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


[PATCH] D40288: [clang-format] Add option to group multiple #include blocks when sorting includes

2017-11-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Looks good! Just a few nits:




Comment at: lib/Format/Format.cpp:1570
 IncludesInBlock.push_back({IncludeName, Line, Prev, Category});
+  } else if (Style.IncludeBlocks > FormatStyle::IBS_Preserve &&
+ Trimmed.empty()) {

Please replace this with two explicit checks for the expected styles. Plus, an 
`else if` with an empty body is super awkward.



Comment at: unittests/Format/SortIncludesTest.cpp:357
+ "#include \"c.h\"\n",
+ "a.cc"));
+}

What is this testing?


Repository:
  rL LLVM

https://reviews.llvm.org/D40288



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


r318827 - [Docs] Update list of languages clang-format can format

2017-11-22 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Nov 22 02:47:35 2017
New Revision: 318827

URL: http://llvm.org/viewvc/llvm-project?rev=318827=rev
Log:
[Docs] Update list of languages clang-format can format

Modified:
cfe/trunk/docs/ClangFormat.rst

Modified: cfe/trunk/docs/ClangFormat.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormat.rst?rev=318827=318826=318827=diff
==
--- cfe/trunk/docs/ClangFormat.rst (original)
+++ cfe/trunk/docs/ClangFormat.rst Wed Nov 22 02:47:35 2017
@@ -11,7 +11,7 @@ Standalone Tool
 ===
 
 :program:`clang-format` is located in `clang/tools/clang-format` and can be 
used
-to format C/C++/Obj-C code.
+to format C/C++/Java/JavaScript/Objective-C/Protobuf code.
 
 .. code-block:: console
 


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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-22 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:169
+  clangd::CodeCompleteOptions CCOpts;
+  CCOpts.EnableSnippets = EnableSnippets;
+  CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;

We should also set `IncludeCodePatterns = EnableSnippets` here.  May be worth 
adding a test that they are in the completion results.


https://reviews.llvm.org/D39836



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


[PATCH] D40013: [DeclPrinter] Allow printing fully qualified name of function declaration

2017-11-22 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Please submit/land this for me. I don't have the necessary permissions.


https://reviews.llvm.org/D40013



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


[PATCH] D40176: [CodeGen] Collect information about sizes of accesses and access types for TBAA

2017-11-22 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added inline comments.



Comment at: lib/CodeGen/CGClass.cpp:2426
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
-  CGM.DecorateInstructionWithTBAA(Store, CGM.getTBAAVTablePtrAccessInfo());
+  TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
+  CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);

Now that type and access descriptors include information about sizes, the 
function needs to know the type of the virtual table pointer to access.



Comment at: lib/CodeGen/CodeGenModule.cpp:139
   (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
-TBAA.reset(new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),
+TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(),
getCXXABI().getMangleContext()));

To clarify why we pass the module instead of LLVM context: we need it to 
compute the size of virtual table pointers as their types are llvm::Type types 
and not clang::Type or QualType ones.



Comment at: lib/CodeGen/CodeGenModule.cpp:585
+  if (AccessType->isIncompleteType())
+return TBAAAccessInfo::getIncompleteInfo();
+

getAccessTagInfo() will raise an assertion failure if such an access descriptor 
is passed to it. This way we explicitly claim that generating access tags for 
incomplete objects is not allowed.


Repository:
  rL LLVM

https://reviews.llvm.org/D40176



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-22 Thread Martell Malone via Phabricator via cfe-commits
martell added a comment.

In https://reviews.llvm.org/D39673#931861, @rnk wrote:

> We have to know the EH model before pre-processing, and that shouldn't rely 
> on LLVM TargetOptions. We can probably reuse the `llvm::ExceptionHandling` 
> enum instead of these various overlapping booleans, if that's the direction 
> you want to go. However, I don't see how we can get away from the clang 
> toolchain knowing the default EH model for each target.


I ended up folding USESjLjExceptions into a GetExceptionModel function that 
returns the llvm::ExceptionHandling.
Reid you are right that clang needed to know some targets beforehand, this is 
especially obvious for the various apple devices. watch and co.

relying on LLVM TargetOptions is much better for platforms like windows
rather then checking `T.isOSWindows() && T.getArch() == llvm::Triple::x86_64` 
to decide on enabling SEH I opted to do a best effort attempt to check what the 
default is much like how cc1as does.
the difference being if it fails we just specify the default as none giving us 
the following pattern.

1. set eh based no user flags passed into clang
2. if no flags passed check the toolchain defaults,
3. if no toolchain default then check llvm,
4. if we can not determine if it is a supported triple default to None.

I also addressed Martin's concern in the folding by adding `| 
LangOpts.DWARFExceptions` and no longer have to specifically check for mingw or 
netbsd.

Sorry for the noise on this, I just want to make sure we get the best 
functionality on this while ensuring it is future proof for other model.


Repository:
  rL LLVM

https://reviews.llvm.org/D39673



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


[PATCH] D39673: Toolchain: Normalize dwarf, sjlj and seh eh

2017-11-22 Thread Martell Malone via Phabricator via cfe-commits
martell updated this revision to Diff 123883.
martell edited the summary of this revision.
martell added a comment.
Herald added subscribers: kristof.beyls, emaste, aemerson.

fold USESjLjExceptions into GetExceptionModel.
do a best effort to check the llvm default exception model for the triple if 
the toolchain does not specify.
(mostly based on the cc1_as code)


Repository:
  rL LLVM

https://reviews.llvm.org/D39673

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Basic/Targets/ARM.cpp
  lib/Basic/Targets/OSTargets.cpp
  lib/Basic/Targets/OSTargets.h
  lib/Basic/Targets/X86.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGException.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/FreeBSD.cpp
  lib/Driver/ToolChains/FreeBSD.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.cpp
  lib/Driver/ToolChains/NetBSD.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/CodeGenCXX/mingw-w64-exceptions.c
  test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
  test/Preprocessor/arm-target-features.c
  test/Preprocessor/init.c

Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -1442,6 +1442,7 @@
 //
 // ARM-MSVC: #define _M_ARM_NT 1
 // ARM-MSVC: #define _WIN32 1
+// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
 //
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -214,6 +214,7 @@
 // A5:#define __ARM_ARCH_7A__ 1
 // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
 // A5:#define __ARM_ARCH_PROFILE 'A'
+// A5-NOT:#define __ARM_DWARF_EH__ 1
 // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
 // A5:#define __ARM_FEATURE_DSP 1
 // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
@@ -225,6 +226,7 @@
 // A7:#define __ARM_ARCH 7
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
+// A7-NOT:#define __ARM_DWARF_EH__ 1
 // A7:#define __ARM_FEATURE_DSP 1
 // A7:#define __ARM_FP 0xE
 
Index: test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
===
--- test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
+++ test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
 
 extern "C" void foo();
Index: test/CodeGenCXX/mingw-w64-exceptions.c
===
--- /dev/null
+++ test/CodeGenCXX/mingw-w64-exceptions.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SEH
+// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -fseh-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SEH
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fsjlj-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
+
+// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions -fdwarf-exceptions -c %s -### 2>&1 | \
+// RUN: FileCheck %s --check-prefix=CHECK-DWARF
+
+// CHECK-SEH: "-fseh-exceptions"
+// CHECK-SJLJ: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fsjlj-exceptions"
+// CHECK-DWARF-NOT: "-fseh-exceptions"
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -677,8 +677,14 @@
 Builder.defineMacro("__EXCEPTIONS");
   if (!LangOpts.MSVCCompat && LangOpts.RTTI)
 Builder.defineMacro("__GXX_RTTI");
+
   if (LangOpts.SjLjExceptions)
 Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
+  else if (LangOpts.SEHExceptions)
+