[PATCH] D26244: [Driver] Prefer libraries installed next to Clang over those from GCC

2017-01-08 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Ping. Could I get comments before the branching this week?


https://reviews.llvm.org/D26244



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


[PATCH] D22452: [libcxx] Fix last_write_time tests for filesystems that don't support negative and very large times.

2017-01-08 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Ping. Would this be ok to land before branching for 4.0 this week?


https://reviews.llvm.org/D22452



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


[PATCH] D20693: [clang-tidy] New checker to replace dynamic exception specifications

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

- Omit noexcept(false) replacement except for dtor and operator delete.


https://reviews.llvm.org/D20693

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tidy/modernize/UseNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-noexcept.rst
  test/clang-tidy/modernize-use-noexcept-macro.cpp
  test/clang-tidy/modernize-use-noexcept.cpp

Index: test/clang-tidy/modernize-use-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -- -std=c++11
+
+class A {};
+class B {};
+
+void foo() throw();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: found dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void foo() noexcept;
+
+void bar() throw(...);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: found dynamic exception specification 'throw(...)' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() ;
+
+void k() throw(int(int));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: found dynamic exception specification 'throw(int(int))' [modernize-use-noexcept]
+// CHECK-FIXES: void k() ;
+
+void foobar() throw(A, B)
+{}
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: found dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+// CHECK-FIXES: void foobar()
+
+void baz(int = (throw A(), 0)) throw(A, B) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: found dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+// CHECK-FIXES: void baz(int = (throw A(), 0)) {}
+
+void g(void (*fp)(void) throw());
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: found dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);
+
+void f(void (*fp)(void) throw(int)) throw(char);
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: found dynamic exception specification 'throw(int)' [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: found dynamic exception specification 'throw(char)' [modernize-use-noexcept]
+// CHECK-FIXES: void f(void (*fp)(void) ) ;
+
+void j() throw(int(int) throw(void(void) throw(int)));
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: found dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' [modernize-use-noexcept]
+// CHECK-FIXES: void j() ;
+
+class Y {
+  Y() throw() = default;
+};
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: found dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: Y() noexcept = default;
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: found dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: found dynamic exception specification 'throw(int)' [modernize-use-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: found dynamic exception specification 'throw(int)' [modernize-use-noexcept]
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
+// CHECK-FIXES: ~Z() noexcept(false) {}
+
+// Should not trigger a replacement.
+void titi() noexcept {}
+void toto() noexcept(true) {}
+
+// Should not trigger a replacement.
+void bad()
+#if !__has_feature(cxx_noexcept)
+throw()
+#endif
+  ;
Index: test/clang-tidy/modernize-use-noexcept-macro.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-noexcept-macro.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
+// RUN:   -- -std=c++11
+
+// Example definition of NOEXCEPT -- simplified test to see if noexcept is supported.
+#if (__has_feature(cxx_noexcept))
+#define NOEXCEPT noexcept
+#else
+#define NOEXCEPT throw()
+#endif
+
+void bar() throw() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: found dynamic exception specification 'throw()' [modernize-use-noexcept]
+// CHECK-FIXES: void bar() NOEXCEPT {}
+
+// Should not trigger a FixItHint, since macros only support noexcept, and this
+// case throws.
+class A {};
+class B {};
+void foobar() throw(A, B);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: found dynamic exception specification 'throw(A, B)' [modernize-use-noexcept]
+
+// Should not trigger a replacement.
+void foo() noexcept(true);
+
+struct Z {
+  void operator delete(void *ptr) throw();
+  void operator delete[](void *ptr) throw(int);
+  ~Z() throw(int) {}
+};
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: found

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

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

Hi Anna,

Thanks for your review!

I use:

  svn diff --diff-cmd=diff -x -U99 
lib/StaticAnalyzer/Checkers/MallocChecker.cpp test/Analysis/gmalloc.c > 
Glib-MallocChecker.patch

to generate the patch, please check is it correct.

And I run:

  clang -cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region 
-verify gmalloc.c

There is *NO* issue, please check it, thanks a lot!

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D28348

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

Index: test/Analysis/gmalloc.c
===
--- test/Analysis/gmalloc.c
+++ test/Analysis/gmalloc.c
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+typedef void* gpointer;
+typedef const void *gconstpointer;
+typedef unsigned long gsize;
+typedef unsigned int guint;
+
+gpointer g_malloc(gsize n_bytes);
+gpointer g_malloc0(gsize n_bytes);
+gpointer g_realloc(gpointer mem, gsize n_bytes);
+gpointer g_try_malloc(gsize n_bytes);
+gpointer g_try_malloc0(gsize n_bytes);
+gpointer g_try_realloc(gpointer mem, gsize n_bytes);
+gpointer g_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_malloc0_n(gsize n_blocks, gsize n_block_bytes);
+gpointer g_try_realloc_n(gpointer mem, gsize n_blocks, gsize n_block_bytes);
+void g_free(gpointer mem);
+gpointer g_memdup(gconstpointer mem, guint byte_size);
+
+static const gsize n_bytes = 1024;
+
+void f1() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g2); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char));
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char));
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char));
+
+  g_free(g1);
+  g_free(g2);
+  g_free(g3);
+  g3 = g_memdup(g3, n_bytes); // expected-warning{{Use of memory after it is freed}}
+}
+
+void f3() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2); // expected-warning{{Potential leak of memory pointed to by 'g4'}}
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{{Potential leak of memory pointed to by 'g7'}}
+  g_free(g2);
+  g_free(g3);
+}
+
+void f4() {
+  gpointer g1 = g_malloc(n_bytes);
+  gpointer g2 = g_malloc0(n_bytes);
+  g1 = g_realloc(g1, n_bytes * 2);
+  gpointer g3 = g_try_malloc(n_bytes);
+  gpointer g4 = g_try_malloc0(n_bytes);
+  g3 = g_try_realloc(g3, n_bytes * 2);
+  gpointer g5 = g_malloc_n(n_bytes, sizeof(char));
+  gpointer g6 = g_malloc0_n(n_bytes, sizeof(char));
+  g5 = g_realloc_n(g5, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g6'}}
+  gpointer g7 = g_try_malloc_n(n_bytes, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g5'}}
+  gpointer g8 = g_try_malloc0_n(n_bytes, sizeof(char));
+  g7 = g_try_realloc_n(g7, n_bytes * 2, sizeof(char)); // expected-warning{{Potential leak of memory pointed to by 'g8'}}
+
+  g_free(g1); // expected-warning{

r291425 - Implement DR1388 (wg21.link/cwg1388).

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan  9 01:14:40 2017
New Revision: 291425

URL: http://llvm.org/viewvc/llvm-project?rev=291425&view=rev
Log:
Implement DR1388 (wg21.link/cwg1388).

This issue clarifies how deduction proceeds past a non-trailing function
parameter pack. Essentially, the pack itself is skipped and consumes no
arguments (except for those implied by an explicitly-specified template
arguments), and nothing is deduced from it. As a small fix to the standard's
rule, we do not allow subsequent deduction to change the length of the function
parameter pack (by preventing extension of the explicitly-specified pack if
present, and otherwise deducing all contained packs to empty packs).

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=291425&r1=291424&r2=291425&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Jan  9 01:14:40 2017
@@ -669,6 +669,19 @@ public:
   Info.PendingDeducedPacks[Pack.Index] = Pack.Outer;
   }
 
+  /// Determine whether this pack has already been partially expanded into a
+  /// sequence of (prior) function parameters / template arguments.
+  bool isPartiallyExpanded() {
+if (Packs.size() != 1 || !S.CurrentInstantiationScope)
+  return false;
+
+auto *PartiallySubstitutedPack =
+S.CurrentInstantiationScope->getPartiallySubstitutedPack();
+return PartiallySubstitutedPack &&
+   getDepthAndIndex(PartiallySubstitutedPack) ==
+   std::make_pair(Info.getDeducedDepth(), Packs.front().Index);
+  }
+
   /// Move to deducing the next element in each pack that is being deduced.
   void nextPackElement() {
 // Capture the deduced template arguments for each parameter pack expanded
@@ -2552,6 +2565,12 @@ static bool isSimpleTemplateIdType(QualT
   return false;
 }
 
+static void
+MarkUsedTemplateParameters(ASTContext &Ctx, QualType T,
+   bool OnlyDeduced,
+   unsigned Level,
+   llvm::SmallBitVector &Deduced);
+
 /// \brief Substitute the explicitly-provided template arguments into the
 /// given function template according to C++ [temp.arg.explicit].
 ///
@@ -2613,7 +2632,7 @@ Sema::SubstituteExplicitTemplateArgument
   // Enter a new template instantiation context where we check the
   // explicitly-specified template arguments against this function template,
   // and then substitute them into the function parameter types.
-  SmallVector DeducedArgs(Deduced.begin(), Deduced.end());
+  SmallVector DeducedArgs;
   InstantiatingTemplate Inst(*this, Info.getLocation(), FunctionTemplate,
  DeducedArgs,
ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution,
@@ -3389,7 +3408,6 @@ Sema::TemplateDeductionResult Sema::Dedu
   //   Template argument deduction is done by comparing each function template
   //   parameter type (call it P) with the type of the corresponding argument
   //   of the call (call it A) as described below.
-  unsigned CheckArgs = Args.size();
   if (Args.size() < Function->getMinRequiredArguments() && !PartialOverloading)
 return TDK_TooFewArguments;
   else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) {
@@ -3397,9 +3415,7 @@ Sema::TemplateDeductionResult Sema::Dedu
   = Function->getType()->getAs();
 if (Proto->isTemplateVariadic())
   /* Do nothing */;
-else if (Proto->isVariadic())
-  CheckArgs = NumParams;
-else
+else if (!Proto->isVariadic())
   return TDK_TooManyArguments;
   }
 
@@ -3456,7 +3472,7 @@ Sema::TemplateDeductionResult Sema::Dedu
 dyn_cast(ParamType);
 if (!ParamExpansion) {
   // Simple case: matching a function parameter to a function argument.
-  if (ArgIdx >= CheckArgs)
+  if (ArgIdx >= Args.size())
 break;
 
   if (auto Result = DeduceCallArgument(ParamType, ArgIdx++))
@@ -3465,36 +3481,47 @@ Sema::TemplateDeductionResult Sema::Dedu
   continue;
 }
 
+QualType ParamPattern = ParamExpansion->getPattern();
+PackDeductionScope PackScope(*this, TemplateParams, Deduced, Info,
+ ParamPattern);
+
 // C++0x [temp.deduct.call]p1:
 //   For a function parameter pack that occurs at the end of the
 //   parameter-declaration-list, the type A of each remaining argument of
 //   the call is compared with the type P of the declarator-id of the
 //   function parameter pack. Each comparison deduces template arguments
 //   for subsequent

Re: r291416 - [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.

2017-01-08 Thread Richard Smith via cfe-commits
On 8 January 2017 at 19:02, Faisal Vali via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: faisalv
> Date: Sun Jan  8 21:02:53 2017
> New Revision: 291416
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291416&view=rev
> Log:
> [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing
> lambda expressions.
>
> Add a visitor for lambda expressions to RecordExprEvaluator in
> ExprConstant.cpp that creates an empty APValue of Struct type to represent
> the closure object. Additionally, add a LambdaExpr visitor to the
> TemporaryExprEvaluator that forwards constant evaluation of
> immediately-called-lambda-expressions to the one in RecordExprEvaluator
> through VisitConstructExpr.
>
> This patch supports:
> constexpr auto ID = [] (auto a) { return a; };
> static_assert(ID(3.14) == 3.14);
> static_assert([](auto a) { return a + 1; }(10) == 11);
>
> Lambda captures are still not supported for constexpr lambdas.
>
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=291416&r1=291415&r2=291416&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Jan  8 21:02:53 2017
> @@ -5868,6 +5868,7 @@ namespace {
>  bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
>return VisitCXXConstructExpr(E, E->getType());
>  }
> +bool VisitLambdaExpr(const LambdaExpr *E);
>  bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr
> *E);
>  bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
>  bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr
> *E);
> @@ -6202,6 +6203,21 @@ bool RecordExprEvaluator::VisitCXXStdIni
>return true;
>  }
>
> +bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
> +  const CXXRecordDecl *ClosureClass = E->getLambdaClass();
> +  if (ClosureClass->isInvalidDecl()) return false;
> +
> +  if (Info.checkingPotentialConstantExpression()) return true;
> +  if (E->capture_size()) {
> +Info.FFDiag(E, diag::note_unimplemented_constexpr_lambda_feature_ast)
> +<< "can not evaluate lambda expressions with captures";
> +return false;
> +  }
> +  // FIXME: Implement captures.
> +  Result = APValue(APValue::UninitStruct(), /*NumBases*/0,
> /*NumFields*/0);
> +  return true;
> +}
> +
>  static bool EvaluateRecord(const Expr *E, const LValue &This,
> APValue &Result, EvalInfo &Info) {
>assert(E->isRValue() && E->getType()->isRecordType() &&
> @@ -6251,6 +6267,9 @@ public:
>bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr
> *E) {
>  return VisitConstructExpr(E);
>}
> +  bool VisitLambdaExpr(const LambdaExpr *E) {
> +return VisitConstructExpr(E);
> +  }
>  };
>  } // end anonymous namespace
>
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaExpr.cpp?rev=291416&r1=291415&r2=291416&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jan  8 21:02:53 2017
> @@ -13097,8 +13097,10 @@ void Sema::PopExpressionEvaluationContex
>  //   evaluate [...] a lambda-expression.
>  D = diag::err_lambda_in_constant_expression;
>}
> -  for (const auto *L : Rec.Lambdas)
> -Diag(L->getLocStart(), D);
> +  // C++1z allows lambda expressions as core constant expressions.
> +  if (Rec.Context != ConstantEvaluated || !getLangOpts().CPlusPlus1z)
> +for (const auto *L : Rec.Lambdas)
> +  Diag(L->getLocStart(), D);
>

We'll need an implementation of DR1607 before we're done here, since it
looks like this has removed the last restriction on lambda-expressions in
function template signatures in some contexts (array bounds, template
arguments).

 } else {
>// Mark the capture expressions odr-used. This was deferred
>// during lambda expression creation.
>
> Modified: cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx1z-constexpr-lambdas.cpp?rev=291416&r1=
> 291415&r2=291416&view=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Sun Jan  8
> 21:02:53 2017
> @@ -96,4 +96,81 @@ decltype(deduced_return_type(0)) d;  //e
>
>  } // end ns test_conversion_function_for_non_capturing_lambdas
>
> +namespace test_lambda_is_cce {
> +namespace ns1_simple_lambda {
> +
> +namespace ns0 {
> +constexpr in

r291422 - Add release notes for `diagnose_if`

2017-01-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Sun Jan  8 23:58:18 2017
New Revision: 291422

URL: http://llvm.org/viewvc/llvm-project?rev=291422&view=rev
Log:
Add release notes for `diagnose_if`

Bots seem happy with `diagnose_if` so far, so I'm optimistically adding
release notes for it.

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=291422&r1=291421&r2=291422&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Sun Jan  8 23:58:18 2017
@@ -47,6 +47,10 @@ sections with improvements to Clang's su
 Major New Features
 --
 
+- The ``diagnose_if`` attribute has been added to clang. This attribute allows
+  clang to emit a warning or error if a function call meets one or more
+  user-specified conditions.
+
 -  ...
 
 Improvements to Clang's diagnostics


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


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

2017-01-08 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Thanks for the review! :)


Repository:
  rL LLVM

https://reviews.llvm.org/D27424



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


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

2017-01-08 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291418: Add the diagnose_if attribute to clang. (authored by 
gbiv).

Changed prior to commit:
  https://reviews.llvm.org/D27424?vs=83412&id=83584#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27424

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Initialization.h
  cfe/trunk/include/clang/Sema/Overload.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/Sema/diagnose_if.c
  cfe/trunk/test/SemaCXX/diagnose_if.cpp

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -651,7 +651,8 @@
   /// constant.
   bool EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
 const FunctionDecl *Callee,
-ArrayRef Args) const;
+ArrayRef Args,
+const Expr *This = nullptr) const;
 
   /// \brief If the current Expr is a pointer, this will try to statically
   /// determine the number of bytes available where the pointer is pointing.
Index: cfe/trunk/include/clang/Sema/Overload.h
===
--- cfe/trunk/include/clang/Sema/Overload.h
+++ cfe/trunk/include/clang/Sema/Overload.h
@@ -668,6 +668,26 @@
 /// to be used while performing partial ordering of function templates.
 unsigned ExplicitCallArguments;
 
+/// The number of diagnose_if attributes that this overload triggered.
+/// If any of the triggered attributes are errors, this won't count
+/// diagnose_if warnings.
+unsigned NumTriggeredDiagnoseIfs = 0;
+
+/// Basically a TinyPtrVector that doesn't own the vector:
+/// If NumTriggeredDiagnoseIfs is 0 or 1, this is a DiagnoseIfAttr *,
+/// otherwise it's a pointer to an array of `NumTriggeredDiagnoseIfs`
+/// DiagnoseIfAttr *s.
+llvm::PointerUnion DiagnoseIfInfo;
+
+/// Gets an ArrayRef for the data at DiagnoseIfInfo. Note that this may give
+/// you a pointer into DiagnoseIfInfo.
+ArrayRef getDiagnoseIfInfo() const {
+  auto *Ptr = NumTriggeredDiagnoseIfs <= 1
+  ? DiagnoseIfInfo.getAddrOfPtr1()
+  : DiagnoseIfInfo.get();
+  return {Ptr, NumTriggeredDiagnoseIfs};
+}
+
 union {
   DeductionFailureInfo DeductionFailure;
   
@@ -732,31 +752,61 @@
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for OverloadCandidate::Conversions. We store the first few
-// elements inline to avoid allocation for small sets.
-llvm::BumpPtrAllocator ConversionSequenceAllocator;
+// Allocator for OverloadCandidate::Conversions and DiagnoseIfAttr* arrays.
+// We store the first few of each of these inline to avoid allocation for
+// small sets.
+llvm::BumpPtrAllocator SlabAllocator;
 
 SourceLocation Loc;
 CandidateSetKind Kind;
 
-unsigned NumInlineSequences;
-llvm::AlignedCharArray
-InlineSpace;
+constexpr static unsigned NumInlineBytes =
+24 * sizeof(ImplicitConversionSequence);
+unsigned NumInlineBytesUsed;
+llvm::AlignedCharArray InlineSpace;
+
+/// If we have space, allocates from inline storage. Otherwise, allocates
+/// from the slab allocator.
+/// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
+/// instead.
+template 
+T *slabAllocate(unsigned N) {
+  // It's simpler if this doesn't need to consider alignment.
+  static_assert(alignof(T) == alignof(void *),
+"Only works for pointer-aligned types.");
+  static_assert(std::is_trivial::value ||
+std::is_same::value,
+"Add destruction logic to OverloadCandidateSet::clear().");
+
+  unsigned NBytes = sizeof(T) * N;
+  if (NBytes > NumInlineBytes - NumInlineBytesUsed)
+return SlabAllocator.Allocate(N);
+  char *FreeSpaceStart = InlineSpace.buffer + NumInlineBytesUsed;
+  assert(uintptr_t(FreeSpaceStart) % alignof(void *) == 0 &&
+ "Misaligned storage!");
+
+  NumInlineBytesUsed += NBytes;
+  return reinterpret_cast(FreeSpaceStart);
+}
 
 OverloadCandidateSet(const OverloadCandidateSet &) = delete;
 void operator=(const OverloadCandidateSet &) = delete;
 
 void destroyCandid

r291418 - Add the diagnose_if attribute to clang.

2017-01-08 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Sun Jan  8 22:12:14 2017
New Revision: 291418

URL: http://llvm.org/viewvc/llvm-project?rev=291418&view=rev
Log:
Add the diagnose_if attribute to clang.

`diagnose_if` can be used to have clang emit either warnings or errors
for function calls that meet user-specified conditions. For example:

```
constexpr int foo(int a)
  __attribute__((diagnose_if(a > 10, "configurations with a > 10 are "
  "expensive.", "warning")));

int f1 = foo(9);
int f2 = foo(10); // warning: configuration with a > 10 are expensive.
int f3 = foo(f2);
```

It currently only emits diagnostics in cases where the condition is
guaranteed to always be true. So, the following code will emit no
warnings:

```
constexpr int bar(int a) {
  foo(a);
  return 0;
}

constexpr int i = bar(10);
```

We hope to support optionally emitting diagnostics for cases like that
(and emitting runtime checks) in the future.

Release notes will appear shortly. :)

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

Added:
cfe/trunk/test/Sema/diagnose_if.c
cfe/trunk/test/SemaCXX/diagnose_if.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=291418&r1=291417&r2=291418&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Jan  8 22:12:14 2017
@@ -651,7 +651,8 @@ public:
   /// constant.
   bool EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
 const FunctionDecl *Callee,
-ArrayRef Args) const;
+ArrayRef Args,
+const Expr *This = nullptr) const;
 
   /// \brief If the current Expr is a pointer, this will try to statically
   /// determine the number of bytes available where the pointer is pointing.

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=291418&r1=291417&r2=291418&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sun Jan  8 22:12:14 2017
@@ -140,12 +140,15 @@ class Argument : Argument;
+class BoolArgument : Argument;
 class IdentifierArgument : Argument;
 class IntArgument : Argument;
 class StringArgument : Argument;
 class ExprArgument : Argument;
-class FunctionArgument : Argument;
+class FunctionArgument : Argument;
 class TypeArgument : Argument;
 class UnsignedArgument : Argument;
 class VariadicUnsignedArgument : Argument;
@@ -1591,6 +1594,26 @@ def Unavailable : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def DiagnoseIf : InheritableAttr {
+  let Spellings = [GNU<"diagnose_if">];
+  let Subjects = SubjectList<[Function]>;
+  let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
+  EnumArgument<"DiagnosticType",
+   "DiagnosticType",
+   ["error", "warning"],
+   ["DT_Error", "DT_Warning"]>,
+  BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
+  FunctionArgument<"Parent", 0, /*fake*/ 1>];
+  let DuplicatesAllowedWhileMerging = 1;
+  let LateParsed = 1;
+  let AdditionalMembers = [{
+bool isError() const { return diagnosticType == DT_Error; }
+bool isWarning() const { return diagnosticType == DT_Warning; }
+  }];
+  let TemplateDependent = 1;
+  let Documentation = [DiagnoseIfDocs];
+}
+
 def ArcWeakrefUnavailable : InheritableAttr {
   let Spellings = [GNU<"objc_arc_weak_reference_unavailable">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=291418&r1=291417&r2=291418&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Sun Jan  8 22:12:14 2017
@@ -378,6 +378,65 @@ template instantiation, so the value for
   }];
 }
 
+def Diagnose

[PATCH] D28461: [clang] Enable using --section-ordering-file option of ld.gold

2017-01-08 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap updated this revision to Diff 83582.
alexshap added a comment.
This revision is now accepted and ready to land.

Address comments


Repository:
  rL LLVM

https://reviews.llvm.org/D28461

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -72,7 +72,7 @@
 
 # Configure plist creation for OS X.
 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
-if (APPLE)  
+if (APPLE)
   if (CLANG_VENDOR)
 set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
   else()
@@ -82,20 +82,19 @@
   set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
   set(TOOL_INFO_VERSION "${CLANG_VERSION}")
   set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
-  
+
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
-  
+
   set(TOOL_INFO_UTI)
   set(TOOL_INFO_NAME)
   set(TOOL_INFO_VERSION)
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
-# the linker -order_file flag is only supported by ld64
-if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
+if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE))
   include(CMakePushCheckState)
 
   function(check_linker_flag flag out_var)
@@ -105,9 +104,14 @@
 cmake_pop_check_state()
   endfunction()
 
+  if (LD64_EXECUTABLE)
+set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
+  elseif (GOLD_EXECUTABLE)
+set(LINKER_ORDER_FILE_OPTION 
"-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
+  endif()
+
   # This is a test to ensure the actual order file works with the linker.
-  check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
-LINKER_ORDER_FILE_WORKS)
+  check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file
@@ -117,7 +121,7 @@
   if("${ORDER_FILE}" STREQUAL "\n")
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS 
${CLANG_ORDER_FILE})
   elseif(LINKER_ORDER_FILE_WORKS)
-target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION})
 set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
   endif()
 endif()


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -72,7 +72,7 @@
 
 # Configure plist creation for OS X.
 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
-if (APPLE)  
+if (APPLE)
   if (CLANG_VENDOR)
 set(TOOL_INFO_NAME "${CLANG_VENDOR} clang")
   else()
@@ -82,20 +82,19 @@
   set(TOOL_INFO_UTI "${CLANG_VENDOR_UTI}")
   set(TOOL_INFO_VERSION "${CLANG_VERSION}")
   set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
-  
+
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
   target_link_libraries(clang
 "-Wl,-sectcreate,__TEXT,__info_plist,${TOOL_INFO_PLIST_OUT}")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)
-  
+
   set(TOOL_INFO_UTI)
   set(TOOL_INFO_NAME)
   set(TOOL_INFO_VERSION)
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
-# the linker -order_file flag is only supported by ld64
-if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
+if(CLANG_ORDER_FILE AND (LD64_EXECUTABLE OR GOLD_EXECUTABLE))
   include(CMakePushCheckState)
 
   function(check_linker_flag flag out_var)
@@ -105,9 +104,14 @@
 cmake_pop_check_state()
   endfunction()
 
+  if (LD64_EXECUTABLE)
+set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
+  elseif (GOLD_EXECUTABLE)
+set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
+  endif()
+
   # This is a test to ensure the actual order file works with the linker.
-  check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
-LINKER_ORDER_FILE_WORKS)
+  check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file
@@ -117,7 +121,7 @@
   if("${ORDER_FILE}" STREQUAL "\n")
 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLANG_ORDER_FILE})
   elseif(LINKER_ORDER_FILE_WORKS)
-target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+target_link_libraries(clang ${LINKER_ORDER_FILE_OPTION})
 set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
   endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2017-01-08 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist created this revision.
enyquist added reviewers: djasper, sylvestre.ledru.
enyquist added a subscriber: cfe-commits.
enyquist set the repository for this revision to rL LLVM.
enyquist added a project: clang-c.
Herald added a subscriber: klimek.

This option behaves similarly to AlignConsecutiveDeclarations and 
AlignConsecutiveAssignments, aligning the assignment of C/C++ preprocessor 
macros on consecutive lines


Repository:
  rL LLVM

https://reviews.llvm.org/D28462

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8514,8 +8514,78 @@
   verifyFormat("a or_eq 8;", Spaces);
 }
 
+TEST_F(FormatTest, AlignConsecutiveMacros) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveAssignments = true;
+  Alignment.AlignConsecutiveDeclarations = true;
+  Alignment.AlignConsecutiveMacros = false;
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Alignment);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Alignment);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar (5, 6)(2 + 2)",
+   Alignment);
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Alignment);
+
+  Alignment.AlignConsecutiveMacros = true;
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)",
+   Alignment);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Alignment);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar   (5, 6)(2 + 2)",
+   Alignment);
+
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Alignment);
+
+  verifyFormat("#define a 5\n"
+   "#define foo(x, y) (x + y)\n"
+   "#define CCC   (6)\n"
+   "auto lambda = []() {\n"
+   "  auto  ii = 0;\n"
+   "  float j  = 0;\n"
+   "  return 0;\n"
+   "};\n"
+   "int   i  = 0;\n"
+   "float i2 = 0;\n"
+   "auto  v  = type{\n"
+   "i = 1,   //\n"
+   "(i = 2), //\n"
+   "i = 3//\n"
+   "};",
+   Alignment);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignments) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveAssignments = false;
   verifyFormat("int a = 5;\n"
"int oneTwoThree = 123;",
@@ -8656,7 +8726,10 @@
"int j = 2;",
Alignment);
 
-  verifyFormat("auto lambda = []() {\n"
+  verifyFormat("#define a 5\n"
+   "#define foo(x, y) (x + y)\n"
+   "#define CCC   (6)\n"
+   "auto lambda = []() {\n"
"  auto i = 0;\n"
"  return 0;\n"
"};\n"
@@ -8692,6 +8765,7 @@
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveDeclarations = false;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
@@ -8851,7 +8925,10 @@
Alignment);
 
   Alignment.AlignConsecutiveAssignments = true;
-  verifyFormat("auto lambda = []() {\n"
+  verifyFormat("#define a 5\n"
+   "#define foo(x, y) (x + y)\n"
+   "#define CCC   (6)\n"
+   "auto lambda = []() {\n"
"  auto  ii = 0;\n"
"  float j  = 0;\n"
"  return 0;\n"
@@ -9576,6 +9653,7 @@
   CHECK_PARSE_BOOL(AlignEscapedNewlinesLeft);
   CHECK_PARSE_BOOL(AlignOperands);
   CHECK_PARSE_BOOL(AlignTrailingComments);
+  CHECK_PARSE_BOOL(AlignConsecutiveMacros);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
Ind

[PATCH] D28461: [clang] Enable using --section-ordering-file option of ld.gold

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

LGTM




Comment at: CMakeLists.txt:113
+check_linker_flag("-Wl,--section-ordering-file,${CLANG_ORDER_FILE}"
+  LINKER_ORDER_FILE_WORKS)
+  endif()

Can we refactor the option by putting it in a string and using the variable 
here and below?


Repository:
  rL LLVM

https://reviews.llvm.org/D28461



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


r291416 - [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.

2017-01-08 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sun Jan  8 21:02:53 2017
New Revision: 291416

URL: http://llvm.org/viewvc/llvm-project?rev=291416&view=rev
Log:
[cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda 
expressions.

Add a visitor for lambda expressions to RecordExprEvaluator in ExprConstant.cpp 
that creates an empty APValue of Struct type to represent the closure object. 
Additionally, add a LambdaExpr visitor to the TemporaryExprEvaluator that 
forwards constant evaluation of immediately-called-lambda-expressions to the 
one in RecordExprEvaluator through VisitConstructExpr.

This patch supports:
constexpr auto ID = [] (auto a) { return a; };
static_assert(ID(3.14) == 3.14);
static_assert([](auto a) { return a + 1; }(10) == 11);

Lambda captures are still not supported for constexpr lambdas.


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=291416&r1=291415&r2=291416&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Jan  8 21:02:53 2017
@@ -5868,6 +5868,7 @@ namespace {
 bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
   return VisitCXXConstructExpr(E, E->getType());
 }
+bool VisitLambdaExpr(const LambdaExpr *E);
 bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
 bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
 bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
@@ -6202,6 +6203,21 @@ bool RecordExprEvaluator::VisitCXXStdIni
   return true;
 }
 
+bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
+  const CXXRecordDecl *ClosureClass = E->getLambdaClass();
+  if (ClosureClass->isInvalidDecl()) return false;
+
+  if (Info.checkingPotentialConstantExpression()) return true;
+  if (E->capture_size()) {
+Info.FFDiag(E, diag::note_unimplemented_constexpr_lambda_feature_ast)
+<< "can not evaluate lambda expressions with captures";
+return false;
+  }
+  // FIXME: Implement captures.
+  Result = APValue(APValue::UninitStruct(), /*NumBases*/0, /*NumFields*/0);
+  return true;
+}
+
 static bool EvaluateRecord(const Expr *E, const LValue &This,
APValue &Result, EvalInfo &Info) {
   assert(E->isRValue() && E->getType()->isRecordType() &&
@@ -6251,6 +6267,9 @@ public:
   bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E) {
 return VisitConstructExpr(E);
   }
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+return VisitConstructExpr(E);
+  }
 };
 } // end anonymous namespace
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=291416&r1=291415&r2=291416&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jan  8 21:02:53 2017
@@ -13097,8 +13097,10 @@ void Sema::PopExpressionEvaluationContex
 //   evaluate [...] a lambda-expression.
 D = diag::err_lambda_in_constant_expression;
   }
-  for (const auto *L : Rec.Lambdas)
-Diag(L->getLocStart(), D);
+  // C++1z allows lambda expressions as core constant expressions.
+  if (Rec.Context != ConstantEvaluated || !getLangOpts().CPlusPlus1z)
+for (const auto *L : Rec.Lambdas)
+  Diag(L->getLocStart(), D);
 } else {
   // Mark the capture expressions odr-used. This was deferred
   // during lambda expression creation.

Modified: cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp?rev=291416&r1=291415&r2=291416&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Sun Jan  8 21:02:53 2017
@@ -96,4 +96,81 @@ decltype(deduced_return_type(0)) d;  //e
 
 } // end ns test_conversion_function_for_non_capturing_lambdas
 
+namespace test_lambda_is_cce {
+namespace ns1_simple_lambda {
+
+namespace ns0 {
+constexpr int I = [](auto a) { return a; }(10);
+
+static_assert(I == 10); 
+static_assert(10 == [](auto a) { return a; }(10));
+static_assert(3.14 == [](auto a) { return a; }(3.14));
+
+} //end ns0
+
+namespace ns1 {
+constexpr auto f(int i) {
+  double d = 3.14;
+  auto L = [=](auto a) { 
+int Isz = sizeof(i);
+return sizeof(i) + sizeof(a) + sizeof(d); 
+  };
+  int I = L("abc") + L(nullptr);
+  return L;
+}
+constexpr auto L = f(3);
+constexpr auto M =  L("abc") + L(nullptr);
+
+static_assert(M == sizeof(int) * 2 + sizeof(double) * 2 + sizeo

r291412 - Revert r291410 and r291411.

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  8 19:18:18 2017
New Revision: 291412

URL: http://llvm.org/viewvc/llvm-project?rev=291412&view=rev
Log:
Revert r291410 and r291411.

The test-suite bots are still failing even after r291410's fix.

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp
cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp
cfe/trunk/test/SemaCXX/attr-noreturn.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/overload-member-call.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=291412&r1=291411&r2=291412&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sun Jan  8 19:18:18 2017
@@ -531,13 +531,6 @@ namespace clang {
   Ambiguous.construct();
 }
 
-void setAsIdentityConversion(QualType T) {
-  setStandard();
-  Standard.setAsIdentityConversion();
-  Standard.setFromType(T);
-  Standard.setAllToTypes(T);
-}
-
 /// \brief Whether the target is really a std::initializer_list, and the
 /// sequence only represents the worst element conversion.
 bool isStdInitializerListElement() const {
@@ -614,11 +607,6 @@ namespace clang {
 ovl_fail_inhctor_slice,
   };
 
-  /// A list of implicit conversion sequences for the arguments of an
-  /// OverloadCandidate.
-  typedef llvm::MutableArrayRef
-  ConversionSequenceList;
-
   /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
   struct OverloadCandidate {
 /// Function - The actual function that this candidate
@@ -643,13 +631,18 @@ namespace clang {
 /// is a surrogate, but only if IsSurrogate is true.
 CXXConversionDecl *Surrogate;
 
-/// The conversion sequences used to convert the function arguments
-/// to the function parameters.
-ConversionSequenceList Conversions;
+/// Conversions - The conversion sequences used to convert the
+/// function arguments to the function parameters, the pointer points to a
+/// fixed size array with NumConversions elements. The memory is owned by
+/// the OverloadCandidateSet.
+ImplicitConversionSequence *Conversions;
 
 /// The FixIt hints which can be used to fix the Bad candidate.
 ConversionFixItGenerator Fix;
 
+/// NumConversions - The number of elements in the Conversions array.
+unsigned NumConversions;
+
 /// Viable - True to indicate that this overload candidate is viable.
 bool Viable;
 
@@ -688,9 +681,9 @@ namespace clang {
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {
-  for (auto &C : Conversions) {
-if (!C.isInitialized()) return false;
-if (C.isAmbiguous()) return true;
+  for (unsigned i = 0, e = NumConversions; i != e; ++i) {
+if (!Conversions[i].isInitialized()) return false;
+if (Conversions[i].isAmbiguous()) return true;
   }
   return false;
 }
@@ -739,7 +732,7 @@ namespace clang {
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for ConversionSequenceLists. We store the first few
+// Allocator for OverloadCandidate::Conversions. We store the first few
 // elements inline to avoid allocation for small sets.
 llvm::BumpPtrAllocator ConversionSequenceAllocator;
 
@@ -780,45 +773,30 @@ namespace clang {
 size_t size() const { return Candidates.size(); }
 bool empty() const { return Candidates.empty(); }
 
-/// \brief Allocate storage for conversion sequences for NumConversions
-/// conversions.
-ConversionSequenceList
-allocateConversionSequences(unsigned NumConversions) {
-  ImplicitConversionSequence *Conversions;
+/// \brief Add a new candidate with NumConversions conversion sequence 
slots
+/// to the overload set.
+OverloadCandidate &addCandidate(unsigned NumConversions = 0) {
+  Candidates.push_back(OverloadCandidate());
+  OverloadCandidate &C = Candidates.back();
 
   // Assign space from the inline array if there are enough free slots
   // available.
   if (NumConversions + NumInlineSequences <= 16) {
 ImplicitConversionSequence *I =
 (ImplicitConversionSequence *)InlineSpace.buffer;
-Conversions = &I[NumInlineSequences];
+C.Conversions = &I[NumInlineSequences];
 NumInlineSequences += NumConversions;
   } else {
 // Otherwise get memory from the allocator.
-Conversions =
-

r291411 - Fix test for targets whose preferred spelling for an 8-byte int is 'long long', not 'long'.

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  8 19:10:14 2017
New Revision: 291411

URL: http://llvm.org/viewvc/llvm-project?rev=291411&view=rev
Log:
Fix test for targets whose preferred spelling for an 8-byte int is 'long long', 
not 'long'.

Modified:
cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp

Modified: cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp?rev=291411&r1=291410&r2=291411&view=diff
==
--- cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp Sun Jan  8 19:10:14 2017
@@ -45,7 +45,7 @@ void CheckMachineMode() {
 
 // Check attributes on function parameters.
 template 
-void CheckParameters(T1 __attribute__((mode(SI)))   paramSI, // 
expected-note{{ignored: substitution failure}} expected-note-re{{not viable: no 
known conversion from '{{.*}}' (vector of 4 'long' values) to 'EnumType' for 
2nd argument}}
+void CheckParameters(T1 __attribute__((mode(SI)))   paramSI, // 
expected-note{{ignored: substitution failure}} expected-note-re{{not viable: no 
known conversion from '{{.*}}' (vector of 4 '{{.*}}' values) to 'EnumType' for 
2nd argument}}
  T1 __attribute__((mode(V4DI))) paramV4DI,   // 
expected-warning{{deprecated}}
  T2 __attribute__((mode(SF)))   paramSF,
  T2 __attribute__((mode(V4DF))) paramV4DF) { // 
expected-warning{{deprecated}}


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


r291410 - Implement C++ DR1391 (wg21.link/cwg1391)

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  8 18:43:47 2017
New Revision: 291410

URL: http://llvm.org/viewvc/llvm-project?rev=291410&view=rev
Log:
Implement C++ DR1391 (wg21.link/cwg1391)

Check for implicit conversion sequences for non-dependent function
template parameters between deduction and substitution. The idea is to accept
as many cases as possible, on the basis that substitution failure outside the
immediate context is much more common during substitution than during implicit
conversion sequence formation.

This re-commits r290808, reverted in r290811, with a fix for handling of
explicitly-specified template argument packs.

Modified:
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp
cfe/trunk/test/SemaCXX/attr-mode-tmpl.cpp
cfe/trunk/test/SemaCXX/attr-noreturn.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/overload-member-call.cpp
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=291410&r1=291409&r2=291410&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sun Jan  8 18:43:47 2017
@@ -531,6 +531,13 @@ namespace clang {
   Ambiguous.construct();
 }
 
+void setAsIdentityConversion(QualType T) {
+  setStandard();
+  Standard.setAsIdentityConversion();
+  Standard.setFromType(T);
+  Standard.setAllToTypes(T);
+}
+
 /// \brief Whether the target is really a std::initializer_list, and the
 /// sequence only represents the worst element conversion.
 bool isStdInitializerListElement() const {
@@ -607,6 +614,11 @@ namespace clang {
 ovl_fail_inhctor_slice,
   };
 
+  /// A list of implicit conversion sequences for the arguments of an
+  /// OverloadCandidate.
+  typedef llvm::MutableArrayRef
+  ConversionSequenceList;
+
   /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).
   struct OverloadCandidate {
 /// Function - The actual function that this candidate
@@ -631,18 +643,13 @@ namespace clang {
 /// is a surrogate, but only if IsSurrogate is true.
 CXXConversionDecl *Surrogate;
 
-/// Conversions - The conversion sequences used to convert the
-/// function arguments to the function parameters, the pointer points to a
-/// fixed size array with NumConversions elements. The memory is owned by
-/// the OverloadCandidateSet.
-ImplicitConversionSequence *Conversions;
+/// The conversion sequences used to convert the function arguments
+/// to the function parameters.
+ConversionSequenceList Conversions;
 
 /// The FixIt hints which can be used to fix the Bad candidate.
 ConversionFixItGenerator Fix;
 
-/// NumConversions - The number of elements in the Conversions array.
-unsigned NumConversions;
-
 /// Viable - True to indicate that this overload candidate is viable.
 bool Viable;
 
@@ -681,9 +688,9 @@ namespace clang {
 /// hasAmbiguousConversion - Returns whether this overload
 /// candidate requires an ambiguous conversion or not.
 bool hasAmbiguousConversion() const {
-  for (unsigned i = 0, e = NumConversions; i != e; ++i) {
-if (!Conversions[i].isInitialized()) return false;
-if (Conversions[i].isAmbiguous()) return true;
+  for (auto &C : Conversions) {
+if (!C.isInitialized()) return false;
+if (C.isAmbiguous()) return true;
   }
   return false;
 }
@@ -732,7 +739,7 @@ namespace clang {
 SmallVector Candidates;
 llvm::SmallPtrSet Functions;
 
-// Allocator for OverloadCandidate::Conversions. We store the first few
+// Allocator for ConversionSequenceLists. We store the first few
 // elements inline to avoid allocation for small sets.
 llvm::BumpPtrAllocator ConversionSequenceAllocator;
 
@@ -773,30 +780,45 @@ namespace clang {
 size_t size() const { return Candidates.size(); }
 bool empty() const { return Candidates.empty(); }
 
-/// \brief Add a new candidate with NumConversions conversion sequence 
slots
-/// to the overload set.
-OverloadCandidate &addCandidate(unsigned NumConversions = 0) {
-  Candidates.push_back(OverloadCandidate());
-  OverloadCandidate &C = Candidates.back();
+/// \brief Allocate storage for conversion sequences for NumConversions
+/// conversions.
+ConversionSequenceList
+allocateConversionSequences(unsigned NumConversions) {
+  ImplicitConversionSequence *Conversions;
 
   // Assign space from the inline array if there are enough free slots
   // avail

r291409 - [index] Introduce SymbolSubKind for reporting language-specific details.

2017-01-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sun Jan  8 17:21:35 2017
New Revision: 291409

URL: http://llvm.org/viewvc/llvm-project?rev=291409&view=rev
Log:
[index] Introduce SymbolSubKind for reporting language-specific details.

Initially reports if a constructor symbol is a copy or move constructor.

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.cpp
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=291409&r1=291408&r2=291409&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Sun Jan  8 17:21:35 2017
@@ -59,6 +59,13 @@ enum class SymbolLanguage {
   CXX,
 };
 
+/// Language specific sub-kinds.
+enum class SymbolSubKind {
+  None,
+  CXXCopyConstructor,
+  CXXMoveConstructor,
+};
+
 /// Set of properties that provide additional info about a symbol.
 enum class SymbolProperty : uint8_t {
   Generic   = 1 << 0,
@@ -107,6 +114,7 @@ struct SymbolRelation {
 
 struct SymbolInfo {
   SymbolKind Kind;
+  SymbolSubKind SubKind;
   SymbolPropertySet Properties;
   SymbolLanguage Lang;
 };
@@ -121,6 +129,7 @@ void printSymbolRoles(SymbolRoleSet Role
 bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
 
 StringRef getSymbolKindString(SymbolKind K);
+StringRef getSymbolSubKindString(SymbolSubKind K);
 StringRef getSymbolLanguageString(SymbolLanguage K);
 
 void applyForEachSymbolProperty(SymbolPropertySet Props,

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=291409&r1=291408&r2=291409&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Sun Jan  8 17:21:35 2017
@@ -53,6 +53,7 @@ SymbolInfo index::getSymbolInfo(const De
   assert(D);
   SymbolInfo Info;
   Info.Kind = SymbolKind::Unknown;
+  Info.SubKind = SymbolSubKind::None;
   Info.Properties = SymbolPropertySet();
   Info.Lang = SymbolLanguage::C;
 
@@ -183,10 +184,16 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::NamespaceAlias;
   Info.Lang = SymbolLanguage::CXX;
   break;
-case Decl::CXXConstructor:
+case Decl::CXXConstructor: {
   Info.Kind = SymbolKind::Constructor;
   Info.Lang = SymbolLanguage::CXX;
+  auto *CD = cast(D);
+  if (CD->isCopyConstructor())
+Info.SubKind = SymbolSubKind::CXXCopyConstructor;
+  else if (CD->isMoveConstructor())
+Info.SubKind = SymbolSubKind::CXXMoveConstructor;
   break;
+}
 case Decl::CXXDestructor:
   Info.Kind = SymbolKind::Destructor;
   Info.Lang = SymbolLanguage::CXX;
@@ -363,6 +370,15 @@ StringRef index::getSymbolKindString(Sym
   llvm_unreachable("invalid symbol kind");
 }
 
+StringRef index::getSymbolSubKindString(SymbolSubKind K) {
+  switch (K) {
+  case SymbolSubKind::None: return "";
+  case SymbolSubKind::CXXCopyConstructor: return "cxx-copy-ctor";
+  case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
+  }
+  llvm_unreachable("invalid symbol subkind");
+}
+
 StringRef index::getSymbolLanguageString(SymbolLanguage K) {
   switch (K) {
   case SymbolLanguage::C: return "C";

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=291409&r1=291408&r2=291409&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Sun Jan  8 17:21:35 2017
@@ -1,5 +1,16 @@
 // RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target 
x86_64-apple-macosx10.7 | FileCheck %s
 
+// CHECK: [[@LINE+1]]:7 | class/C++ | Cls | c:@S@Cls |  | Def | 
rel: 0
+class Cls {
+  // CHECK: [[@LINE+2]]:3 | constructor/C++ | Cls | c:@S@Cls@F@Cls#I# | 
__ZN3ClsC1Ei | Decl,RelChild | rel: 1
+  // CHECK-NEXT: RelChild | Cls | c:@S@Cls
+  Cls(int x);
+  // CHECK: [[@LINE+1]]:3 | constructor/cxx-copy-ctor/C++ | Cls | 
c:@S@Cls@F@Cls#&1$@S@Cls# | __ZN3ClsC1ERKS_ | Decl,RelChild | rel: 1
+  Cls(const Cls &);
+  // CHECK: [[@LINE+1]]:3 | constructor/cxx-move-ctor/C++ | Cls | 
c:@S@Cls@F@Cls#&&$@S@Cls# | __ZN3ClsC1EOS_ | Decl,RelChild | rel: 1
+  Cls(Cls &&);
+};
+
 template 
 class TemplCls {
 // CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls | 
 | Def | rel: 0

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=291409&r1=291408&r2=291409&view=diff
=

Re: [PATCH] Use the correct ObjC EH personality

2017-01-08 Thread Benjamin Kramer via cfe-commits
Committed r291408. Thanks!

On Sun, Jan 8, 2017 at 9:03 PM, Jonathan Schleifer via cfe-commits
 wrote:
> Sorry, it seems the inline patch has been garbled.
>
> Trying as an attachment this time.
>
>
> --
> Jonathan
>
>
> ___
> 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


r291408 - Use the correct ObjC EH personality

2017-01-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Jan  8 16:58:07 2017
New Revision: 291408

URL: http://llvm.org/viewvc/llvm-project?rev=291408&view=rev
Log:
Use the correct ObjC EH personality

This fixes ObjC exceptions on Win64 (which uses SEH), among others.

Patch by Jonathan Schleifer!

Modified:
cfe/trunk/lib/CodeGen/CGCleanup.h
cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.h?rev=291408&r1=291407&r2=291408&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.h (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.h Sun Jan  8 16:58:07 2017
@@ -616,6 +616,8 @@ struct EHPersonality {
   static const EHPersonality GNU_C_SJLJ;
   static const EHPersonality GNU_C_SEH;
   static const EHPersonality GNU_ObjC;
+  static const EHPersonality GNU_ObjC_SJLJ;
+  static const EHPersonality GNU_ObjC_SEH;
   static const EHPersonality GNUstep_ObjC;
   static const EHPersonality GNU_ObjCXX;
   static const EHPersonality NeXT_ObjC;

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=291408&r1=291407&r2=291408&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Sun Jan  8 16:58:07 2017
@@ -97,6 +97,10 @@ EHPersonality::GNU_CPlusPlus_SEH = { "__
 const EHPersonality
 EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", 
"objc_exception_throw"};
 const EHPersonality
+EHPersonality::GNU_ObjC_SJLJ = {"__gnu_objc_personality_sj0", 
"objc_exception_throw"};
+const EHPersonality
+EHPersonality::GNU_ObjC_SEH = {"__gnu_objc_personality_seh0", 
"objc_exception_throw"};
+const EHPersonality
 EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", nullptr };
 const EHPersonality
 EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", nullptr };
@@ -137,6 +141,10 @@ static const EHPersonality &getObjCPerso
 // fallthrough
   case ObjCRuntime::GCC:
   case ObjCRuntime::ObjFW:
+if (L.SjLjExceptions)
+  return EHPersonality::GNU_ObjC_SJLJ;
+else if (useLibGCCSEHPersonality(T))
+  return EHPersonality::GNU_ObjC_SEH;
 return EHPersonality::GNU_ObjC;
   }
   llvm_unreachable("bad runtime kind");


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


r291407 - PR31514: Add recursive self-instantiation check during template argument

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  8 16:45:21 2017
New Revision: 291407

URL: http://llvm.org/viewvc/llvm-project?rev=291407&view=rev
Log:
PR31514: Add recursive self-instantiation check during template argument
deduction in partial ordering.

This prevents us from crashing due to attempting to instantiate the same class
template specialization definition multiple times. (Debug builds also appear to
sometimes hit the stack limit before hitting the instantiation depth limit in
this case.)

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/alias-templates.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=291407&r1=291406&r2=291407&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Sun Jan  8 16:45:21 2017
@@ -2280,16 +2280,18 @@ namespace {
   };
 }
 
-bool Sema::InstantiateClassTemplateSpecialization(
-SourceLocation PointOfInstantiation,
+/// Get the instantiation pattern to use to instantiate the definition of a
+/// given ClassTemplateSpecializationDecl (either the pattern of the primary
+/// template or of a partial specialization).
+static CXXRecordDecl *
+getPatternForClassTemplateSpecialization(
+Sema &S, SourceLocation PointOfInstantiation,
 ClassTemplateSpecializationDecl *ClassTemplateSpec,
 TemplateSpecializationKind TSK, bool Complain) {
-  // Perform the actual instantiation on the canonical declaration.
-  ClassTemplateSpec = cast(
- 
ClassTemplateSpec->getCanonicalDecl());
-  if (ClassTemplateSpec->isInvalidDecl())
-return true;
-  
+  Sema::InstantiatingTemplate Inst(S, PointOfInstantiation, ClassTemplateSpec);
+  if (Inst.isInvalid() || Inst.isAlreadyInstantiating())
+return nullptr;
+
   ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
   CXXRecordDecl *Pattern = nullptr;
 
@@ -2309,15 +2311,13 @@ bool Sema::InstantiateClassTemplateSpeci
   for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
 ClassTemplatePartialSpecializationDecl *Partial = PartialSpecs[I];
 TemplateDeductionInfo Info(FailedCandidates.getLocation());
-if (TemplateDeductionResult Result
-  = DeduceTemplateArguments(Partial,
-ClassTemplateSpec->getTemplateArgs(),
-Info)) {
+if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
+Partial, ClassTemplateSpec->getTemplateArgs(), Info)) {
   // Store the failed-deduction information for use in diagnostics, later.
   // TODO: Actually use the failed-deduction info?
   FailedCandidates.addCandidate().set(
   DeclAccessPair::make(Template, AS_public), Partial,
-  MakeDeductionFailureInfo(Context, Result, Info));
+  MakeDeductionFailureInfo(S.Context, Result, Info));
   (void)Result;
 } else {
   Matched.push_back(PartialSpecMatchResult());
@@ -2347,9 +2347,8 @@ bool Sema::InstantiateClassTemplateSpeci
   for (SmallVectorImpl::iterator P = Best + 1,
PEnd = Matched.end();
P != PEnd; ++P) {
-if (getMoreSpecializedPartialSpecialization(P->Partial, Best->Partial,
-PointOfInstantiation) 
-  == P->Partial)
+if (S.getMoreSpecializedPartialSpecialization(
+P->Partial, Best->Partial, PointOfInstantiation) == P->Partial)
   Best = P;
   }
   
@@ -2360,9 +2359,9 @@ bool Sema::InstantiateClassTemplateSpeci
PEnd = Matched.end();
P != PEnd; ++P) {
 if (P != Best &&
-getMoreSpecializedPartialSpecialization(P->Partial, Best->Partial,
-PointOfInstantiation)
-  != Best->Partial) {
+S.getMoreSpecializedPartialSpecialization(P->Partial, 
Best->Partial,
+  PointOfInstantiation) !=
+Best->Partial) {
   Ambiguous = true;
   break;
 }
@@ -2370,20 +2369,20 @@ bool Sema::InstantiateClassTemplateSpeci

   if (Ambiguous) {
 // Partial ordering did not produce a clear winner. Complain.
+Inst.Clear();
 ClassTemplateSpec->setInvalidDecl();
-Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
+S.Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
   << ClassTemplateSpec;
 
 // Print the matching partial specializations.
 for (SmallVectorImpl::iterator P = Matched.begin(),
  

[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2017-01-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

LGTM. This seems consistent with what GCC does. On x86 it also sets 
__GCC_ATOMIC_LLONG_LOCK_FREE to 2.


https://reviews.llvm.org/D28213



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


r291403 - PR30305: Implement proposed DR resolution to prevent slicing via inherited constructor.

2017-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sun Jan  8 15:45:44 2017
New Revision: 291403

URL: http://llvm.org/viewvc/llvm-project?rev=291403&view=rev
Log:
PR30305: Implement proposed DR resolution to prevent slicing via inherited 
constructor.

The rule we use is that a construction of a class type T from an argument of
type U cannot use an inherited constructor if U is the same as T or is derived
from T (or if the initialization would first convert it to such a type). This
(approximately) matches the rule in use by GCC, and matches the current proposed
DR resolution.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp
cfe/trunk/test/CXX/drs/dr19xx.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291403&r1=291402&r2=291403&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Jan  8 15:45:44 
2017
@@ -,6 +,9 @@ def note_ovl_candidate : Note<"candidate
 
 def note_ovl_candidate_inherited_constructor : Note<
 "constructor from base class %0 inherited here">;
+def note_ovl_candidate_inherited_constructor_slice : Note<
+"constructor inherited from base class cannot be used to initialize from "
+"an argument of the derived class type">;
 def note_ovl_candidate_illegal_constructor : Note<
 "candidate %select{constructor|template}0 ignored: "
 "instantiation %select{takes|would take}0 its own class type by value">;

Modified: cfe/trunk/include/clang/Sema/Overload.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=291403&r1=291402&r2=291403&view=diff
==
--- cfe/trunk/include/clang/Sema/Overload.h (original)
+++ cfe/trunk/include/clang/Sema/Overload.h Sun Jan  8 15:45:44 2017
@@ -601,6 +601,10 @@ namespace clang {
 
 /// This candidate was not viable because its OpenCL extension is disabled.
 ovl_fail_ext_disabled,
+
+/// This inherited constructor is not viable because it would slice the
+/// argument.
+ovl_fail_inhctor_slice,
   };
 
   /// OverloadCandidate - A single candidate in an overload set (C++ 13.3).

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=291403&r1=291402&r2=291403&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Jan  8 15:45:44 2017
@@ -5971,6 +5971,31 @@ Sema::AddOverloadCandidate(FunctionDecl
 }
   }
 
+  // C++ [over.best.ics]p4+: (proposed DR resolution)
+  //   If the target is the first parameter of an inherited constructor when
+  //   constructing an object of type C with an argument list that has exactly
+  //   one expression, an implicit conversion sequence cannot be formed if C is
+  //   reference-related to the type that the argument would have after the
+  //   application of the user-defined conversion (if any) and before the final
+  //   standard conversion sequence. 
+  auto *Shadow = dyn_cast(FoundDecl.getDecl());
+  if (Shadow && Args.size() == 1 && !isa(Args.front())) {
+bool DerivedToBase, ObjCConversion, ObjCLifetimeConversion;
+QualType ConvertedArgumentType = Args.front()->getType();
+if (Candidate.Conversions[0].isUserDefined())
+  ConvertedArgumentType =
+  Candidate.Conversions[0].UserDefined.After.getFromType();
+if (CompareReferenceRelationship(Args.front()->getLocStart(),
+ 
Context.getRecordType(Shadow->getParent()),
+ ConvertedArgumentType, DerivedToBase,
+ ObjCConversion,
+ ObjCLifetimeConversion) >= Ref_Related) {
+  Candidate.Viable = false;
+  Candidate.FailureKind = ovl_fail_inhctor_slice;
+  return;
+}
+  }
+
   if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
 Candidate.Viable = false;
 Candidate.FailureKind = ovl_fail_enable_if;
@@ -9927,6 +9952,12 @@ static void NoteFunctionCandidate(Sema &
   case ovl_fail_ext_disabled:
 return DiagnoseOpenCLExtensionDisabled(S, Cand);
 
+  case ovl_fail_inhctor_slice:
+S.Diag(Fn->getLocation(),
+   diag::note_ovl_candidate_inherited_constructor_slice);
+MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
+return;
+
   case ovl_fail_addr_not_available: {
 bool Available = checkAddressOfCandidateIsAvailable(S, Cand->Function);
 (void)Available;

Modified: cfe/trunk/test/CXX/dc

[PATCH] D28018: AMD family 17h (znver1) enablement

2017-01-08 Thread Ganesh Gopalasubramanian via Phabricator via cfe-commits
GGanesh added inline comments.



Comment at: lib/Basic/Targets.cpp:3189
 break;
+  case CK_ZNVER1:
+setFeatureEnabledImpl(Features, "adx", true);

RKSimon wrote:
> Same as what I asked on D28017 - is there an accepted order that we should be 
> using here?
Some of them seems to be chronological.
Some of them are alphabetical.

I personally don't have any preference as such.
Alphabetical order suits a long list. 
I would like to know your suggestion.


https://reviews.llvm.org/D28018



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


Re: [PATCH] Use the correct ObjC EH personality

2017-01-08 Thread Jonathan Schleifer via cfe-commits
Sorry, it seems the inline patch has been garbled.

Trying as an attachment this time.


0001-Use-the-correct-ObjC-EH-personality.patch
Description: Binary data

--
Jonathan

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


[PATCH] Use the correct ObjC EH personality

2017-01-08 Thread Jonathan Schleifer via cfe-commits
Use the correct ObjC EH personality

This fixes ObjC exceptions on Win64 (which uses SEH), among others.
---
lib/CodeGen/CGCleanup.h | 2 ++
lib/CodeGen/CGException.cpp | 8 
2 files changed, 10 insertions(+)

diff --git a/lib/CodeGen/CGCleanup.h b/lib/CodeGen/CGCleanup.h
index 2166490ec1..105c5629d5 100644
--- a/lib/CodeGen/CGCleanup.h
+++ b/lib/CodeGen/CGCleanup.h
@@ -616,6 +616,8 @@ struct EHPersonality {
  static const EHPersonality GNU_C_SJLJ;
  static const EHPersonality GNU_C_SEH;
  static const EHPersonality GNU_ObjC;
+  static const EHPersonality GNU_ObjC_SJLJ;
+  static const EHPersonality GNU_ObjC_SEH;
  static const EHPersonality GNUstep_ObjC;
  static const EHPersonality GNU_ObjCXX;
  static const EHPersonality NeXT_ObjC;
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 7b7880e07a..f908bf2b3b 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -97,6 +97,10 @@ EHPersonality::GNU_CPlusPlus_SEH = { 
"__gxx_personality_seh0", nullptr };
const EHPersonality
EHPersonality::GNU_ObjC = {"__gnu_objc_personality_v0", "objc_exception_throw"};
const EHPersonality
+EHPersonality::GNU_ObjC_SJLJ = {"__gnu_objc_personality_sj0", 
"objc_exception_throw"};
+const EHPersonality
+EHPersonality::GNU_ObjC_SEH = {"__gnu_objc_personality_seh0", 
"objc_exception_throw"};
+const EHPersonality
EHPersonality::GNU_ObjCXX = { "__gnustep_objcxx_personality_v0", nullptr };
const EHPersonality
EHPersonality::GNUstep_ObjC = { "__gnustep_objc_personality_v0", nullptr };
@@ -137,6 +141,10 @@ static const EHPersonality &getObjCPersonality(const 
llvm::Triple &T,
// fallthrough
  case ObjCRuntime::GCC:
  case ObjCRuntime::ObjFW:
+if (L.SjLjExceptions)
+  return EHPersonality::GNU_ObjC_SJLJ;
+else if (useLibGCCSEHPersonality(T))
+  return EHPersonality::GNU_ObjC_SEH;
return EHPersonality::GNU_ObjC;
  }
  llvm_unreachable("bad runtime kind");
-- 
Jonathan

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


[PATCH] D18510: [cxx1z-constexpr-lambda] Make conversion function constexpr

2017-01-08 Thread Faisal Vali via Phabricator via cfe-commits
faisalv abandoned this revision.
faisalv added a comment.

See richard's comment for why this attempt at implementing a compatibility 
warning for the constexpr conversion operator for lambda's is being abandoned.


https://reviews.llvm.org/D18510



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


[PATCH] D22997: [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2017-01-08 Thread Faisal Vali via Phabricator via cfe-commits
faisalv accepted this revision.
faisalv added a reviewer: faisalv.
faisalv added a comment.
This revision is now accepted and ready to land.

committed as https://reviews.llvm.org/rL291397


https://reviews.llvm.org/D22997



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


[PATCH] D22997: [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2017-01-08 Thread Faisal Vali via Phabricator via cfe-commits
faisalv closed this revision.
faisalv added a comment.

Committed as https://reviews.llvm.org/rL291397


https://reviews.llvm.org/D22997



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


r291397 - [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2017-01-08 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sun Jan  8 12:56:11 2017
New Revision: 291397

URL: http://llvm.org/viewvc/llvm-project?rev=291397&view=rev
Log:
[cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the 
expression-evaluator to evaluate the static-invoker.

This patch has been sitting in review hell since july 2016 and our lack of 
constexpr lambda support is getting embarrassing (given that I've had a branch 
that implements the feature (modulo *this capture) for over a year.  While in 
Issaquah I was enjoying shamelessly trying to convince folks of the lie that 
this was Richard's fault ;) I won't be able to do so in Kona since I won't be 
attending - so I'm going to aim to have this feature be implemented by then.

I'm quite confident of the approach in this patch, which simply maps the 
static-invoker 'thunk' back to the corresponding call-operator (specialization).

Thanks!


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=291397&r1=291396&r2=291397&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Jan  8 12:56:11 2017
@@ -4543,6 +4543,12 @@ public:
  Call.getLValueBase().dyn_cast());
   if (!FD)
 return Error(Callee);
+  // Don't call function pointers which have been cast to some other type.
+  // Per DR (no number yet), the caller and callee can differ in noexcept.
+  if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
+CalleeType->getPointeeType(), FD->getType())) {
+return Error(E);
+  }
 
   // Overloaded operator calls to member functions are represented as 
normal
   // calls with '*this' as the first argument.
@@ -4558,14 +4564,42 @@ public:
   return false;
 This = &ThisVal;
 Args = Args.slice(1);
-  }
+  } else if (MD && MD->isLambdaStaticInvoker()) {   
+// Map the static invoker for the lambda back to the call operator.
+// Conveniently, we don't have to slice out the 'this' argument (as is
+// being done for the non-static case), since a static member function
+// doesn't have an implicit argument passed in.
+const CXXRecordDecl *ClosureClass = MD->getParent();
+assert(
+ClosureClass->captures_begin() == ClosureClass->captures_end() &&
+"Number of captures must be zero for conversion to function-ptr");
 
-  // Don't call function pointers which have been cast to some other type.
-  // Per DR (no number yet), the caller and callee can differ in noexcept.
-  if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
-  CalleeType->getPointeeType(), FD->getType())) {
-return Error(E);
+const CXXMethodDecl *LambdaCallOp =
+ClosureClass->getLambdaCallOperator();
+
+// Set 'FD', the function that will be called below, to the call
+// operator.  If the closure object represents a generic lambda, find
+// the corresponding specialization of the call operator.
+
+if (ClosureClass->isGenericLambda()) {
+  assert(MD->isFunctionTemplateSpecialization() &&
+ "A generic lambda's static-invoker function must be a "
+ "template specialization");
+  const TemplateArgumentList *TAL = 
MD->getTemplateSpecializationArgs();
+  FunctionTemplateDecl *CallOpTemplate =
+  LambdaCallOp->getDescribedFunctionTemplate();
+  void *InsertPos = nullptr;
+  FunctionDecl *CorrespondingCallOpSpecialization =
+  CallOpTemplate->findSpecialization(TAL->asArray(), InsertPos);
+  assert(CorrespondingCallOpSpecialization &&
+ "We must always have a function call operator specialization "
+ "that corresponds to our static invoker specialization");
+  FD = cast(CorrespondingCallOpSpecialization);
+} else
+  FD = LambdaCallOp;
   }
+
+  
 } else
   return Error(E);
 

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=291397&r1=291396&r2=291397&view=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Sun Jan  8 12:56:11 2017
@@ -1274,7 +1274,7 @@ static void addFunctionPointerConversion
 ConvTy, 
 ConvTSI,
 /*isInline=*/true, /*isExplicit=*/false,
-/*isConstexpr=*/false, 
+/*isConstexpr=*/S.getL

[PATCH] D28018: AMD family 17h (znver1) enablement

2017-01-08 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: lib/Basic/Targets.cpp:3189
 break;
+  case CK_ZNVER1:
+setFeatureEnabledImpl(Features, "adx", true);

Same as what I asked on D28017 - is there an accepted order that we should be 
using here?


https://reviews.llvm.org/D28018



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


[PATCH] D28018: AMD family 17h (znver1) enablement

2017-01-08 Thread Ganesh Gopalasubramanian via Phabricator via cfe-commits
GGanesh removed rL LLVM as the repository for this revision.
GGanesh updated this revision to Diff 83566.
GGanesh added a comment.

The clzero builtins and feature addition will be handled separately in another 
patch.
SSE4a and movbe are added to the ISA list.


https://reviews.llvm.org/D28018

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2651,6 +2651,12 @@
 CK_BDVER4,
 //@}
 
+/// \name zen
+/// Zen architecture processors.
+//@{
+CK_ZNVER1,
+//@}
+
 /// This specification is deprecated and will be removed in the future.
 /// Users should prefer \see CK_K8.
 // FIXME: Warn on this when the CPU is set to it.
@@ -2732,6 +2738,7 @@
 .Case("bdver2", CK_BDVER2)
 .Case("bdver3", CK_BDVER3)
 .Case("bdver4", CK_BDVER4)
+.Case("znver1", CK_ZNVER1)
 .Case("x86-64", CK_x86_64)
 .Case("geode", CK_Geode)
 .Default(CK_Generic);
@@ -2931,6 +2938,7 @@
 case CK_BDVER2:
 case CK_BDVER3:
 case CK_BDVER4:
+case CK_ZNVER1:
 case CK_x86_64:
   return true;
 }
@@ -3178,6 +3186,33 @@
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
+  case CK_ZNVER1:
+setFeatureEnabledImpl(Features, "adx", true);
+setFeatureEnabledImpl(Features, "aes", true);
+setFeatureEnabledImpl(Features, "avx2", true);
+setFeatureEnabledImpl(Features, "bmi", true);
+setFeatureEnabledImpl(Features, "bmi2", true);
+setFeatureEnabledImpl(Features, "clflushopt", true);
+setFeatureEnabledImpl(Features, "cx16", true);
+setFeatureEnabledImpl(Features, "f16c", true);
+setFeatureEnabledImpl(Features, "fma", true);
+setFeatureEnabledImpl(Features, "fsgsbase", true);
+setFeatureEnabledImpl(Features, "fxsr", true);
+setFeatureEnabledImpl(Features, "lzcnt", true);
+setFeatureEnabledImpl(Features, "mwaitx", true);
+setFeatureEnabledImpl(Features, "movbe", true);
+setFeatureEnabledImpl(Features, "pclmul", true);
+setFeatureEnabledImpl(Features, "popcnt", true);
+setFeatureEnabledImpl(Features, "prfchw", true);
+setFeatureEnabledImpl(Features, "rdrnd", true);
+setFeatureEnabledImpl(Features, "rdseed", true);
+setFeatureEnabledImpl(Features, "sha", true);
+setFeatureEnabledImpl(Features, "sse4a", true);
+setFeatureEnabledImpl(Features, "xsave", true);
+setFeatureEnabledImpl(Features, "xsavec", true);
+setFeatureEnabledImpl(Features, "xsaveopt", true);
+setFeatureEnabledImpl(Features, "xsaves", true);
+break;
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
@@ -3729,6 +3764,9 @@
   case CK_BDVER4:
 defineCPUMacros(Builder, "bdver4");
 break;
+  case CK_ZNVER1:
+defineCPUMacros(Builder, "znver1");
+break;
   case CK_Geode:
 defineCPUMacros(Builder, "geode");
 break;


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2651,6 +2651,12 @@
 CK_BDVER4,
 //@}
 
+/// \name zen
+/// Zen architecture processors.
+//@{
+CK_ZNVER1,
+//@}
+
 /// This specification is deprecated and will be removed in the future.
 /// Users should prefer \see CK_K8.
 // FIXME: Warn on this when the CPU is set to it.
@@ -2732,6 +2738,7 @@
 .Case("bdver2", CK_BDVER2)
 .Case("bdver3", CK_BDVER3)
 .Case("bdver4", CK_BDVER4)
+.Case("znver1", CK_ZNVER1)
 .Case("x86-64", CK_x86_64)
 .Case("geode", CK_Geode)
 .Default(CK_Generic);
@@ -2931,6 +2938,7 @@
 case CK_BDVER2:
 case CK_BDVER3:
 case CK_BDVER4:
+case CK_ZNVER1:
 case CK_x86_64:
   return true;
 }
@@ -3178,6 +3186,33 @@
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 break;
+  case CK_ZNVER1:
+setFeatureEnabledImpl(Features, "adx", true);
+setFeatureEnabledImpl(Features, "aes", true);
+setFeatureEnabledImpl(Features, "avx2", true);
+setFeatureEnabledImpl(Features, "bmi", true);
+setFeatureEnabledImpl(Features, "bmi2", true);
+setFeatureEnabledImpl(Features, "clflushopt", true);
+setFeatureEnabledImpl(Features, "cx16", true);
+setFeatureEnabledImpl(Features, "f16c", true);
+setFeatureEnabledImpl(Features, "fma", true);
+setFeatureEnabledImpl(Features, "fsgsbase", true);
+setFeatureEnabledImpl(Features, "fxsr", true);
+setFeatureEnabledImpl(Features, "lzcnt", true);
+setFeatureEnabledImpl(Features, "mwaitx", true);
+setFeatureEnabledImpl(Features, "movbe", true);
+setFeatureEnabledImpl(Features, "pclmul", true);
+setFeatureEnabledImpl(Features, "popcnt", true);
+setFeatureEnabledImpl(F

[PATCH] D28457: Add missing const qualifier to member function Decl::isLocalExternDecl()

2017-01-08 Thread Firat Kasmis via Phabricator via cfe-commits
firolino created this revision.
firolino added a reviewer: rsmith.
firolino added a subscriber: cfe-commits.

This patch simply adds a const qualifier to the member function 
Decl::isLocalExternDecl().


https://reviews.llvm.org/D28457

Files:
  include/clang/AST/DeclBase.h


Index: include/clang/AST/DeclBase.h
===
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -949,7 +949,7 @@
   /// \brief Determine whether this is a block-scope declaration with linkage.
   /// This will either be a local variable declaration declared 'extern', or a
   /// local function declaration.
-  bool isLocalExternDecl() {
+  bool isLocalExternDecl() const {
 return IdentifierNamespace & IDNS_LocalExtern;
   }
 


Index: include/clang/AST/DeclBase.h
===
--- include/clang/AST/DeclBase.h
+++ include/clang/AST/DeclBase.h
@@ -949,7 +949,7 @@
   /// \brief Determine whether this is a block-scope declaration with linkage.
   /// This will either be a local variable declaration declared 'extern', or a
   /// local function declaration.
-  bool isLocalExternDecl() {
+  bool isLocalExternDecl() const {
 return IdentifierNamespace & IDNS_LocalExtern;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-01-08 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

In https://reviews.llvm.org/D28365#639260, @awson wrote:

> It's weird th[[ URL | name ]]at cl.exe command-line compiler reports version 
> 19.10.24629 and lives in the 14.10.24629 directory (only first 2 digits are 
> different).
>
> Moreover, in their explanation blogpost 
> 
>  they claim that //There’s a subdirectory in the MSVC directory with a 
> compiler version number. For VS 2017 RC, that version number is 
> 14.10.24629.//, i.e., they name this 14.10.24629 a "compiler version".


I'll admit I'm also slightly confused by the difference and maybe someone more 
familiar with the matter can correct me, but from what I understand: v14 is the 
toolchain version and v19 is the cl.exe version (i.e. specifically the compiler 
version). Wikipedia has a useful table 
 showing cl.exe 
version numbers over the years.  I've got no idea why they're kept separate, 
probably historical reasons.
As for the blog post, I can only assume that it's a typo and they meant to say 
"compiler tools version".


https://reviews.llvm.org/D28365



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


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

2017-01-08 Thread Kyrill Briantsev via Phabricator via cfe-commits
awson added a comment.

It's weird that cl.exe command-line compiler reports version 19.10.24629 and 
lives in the 14.10.24629 directory (only first 2 digits are different).

Moreover, in their explanation blogpost 

 they claim that //There’s a subdirectory in the MSVC directory with a compiler 
version number. For VS 2017 RC, that version number is 14.10.24629.//, i.e., 
they name this 14.10.24629 a "compiler version".


https://reviews.llvm.org/D28365



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


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

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

- Added an option to set the environment in a clang::driver::Command, which 
makes the environment modifying introduced in the last update a bit more 
reliable.

@rnk I looked into using the new MSVC toolchain layout to get a version number 
without opening an exe, but it doesn't look like it'll be possible. The version 
number in the toolchain path is the MSVC version number (e.g. Visual Studio 
2015 ships with MSVC 14). The version numbers that Clang use are the compiler 
version numbers (e.g. cl.exe v19 for Visual Studio 2015). As far as I'm aware, 
there's no mapping between the two.


https://reviews.llvm.org/D28365

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

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -48,6 +48,15 @@
 #include  // For getuid().
 #endif
 
+#ifdef LLVM_ON_WIN32
+  #define WIN32_LEAN_AND_MEAN
+  #include 
+
+  // Undefine this macro so we can call the ANSI version of the function.
+  #undef GetEnvironmentStrings
+  #define GetEnvironmentStringsA GetEnvironmentStrings
+#endif
+
 using namespace clang::driver;
 using namespace clang::driver::tools;
 using namespace clang;
@@ -10806,19 +10815,12 @@
 // making sure that whatever executable that's found is not a same-named exe
 // from clang itself to prevent clang from falling back to itself.
 static std::string FindVisualStudioExecutable(const ToolChain &TC,
-  const char *Exe,
-  const char *ClangProgramPath) {
+  const char *Exe) {
   const auto &MSVC = static_cast(TC);
-  std::string visualStudioBinDir;
-  if (MSVC.getVisualStudioBinariesFolder(ClangProgramPath,
- visualStudioBinDir)) {
-SmallString<128> FilePath(visualStudioBinDir);
-llvm::sys::path::append(FilePath, Exe);
-if (llvm::sys::fs::can_execute(FilePath.c_str()))
-  return FilePath.str();
-  }
-
-  return Exe;
+  SmallString<128> FilePath(MSVC.getSubDirectoryPath(toolchains::MSVCToolChain
+ ::SubDirectoryType::Bin));
+  llvm::sys::path::append(FilePath, Exe);
+  return (llvm::sys::fs::can_execute(FilePath) ? FilePath.str() : Exe);
 }
 
 void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -10827,7 +10829,7 @@
 const ArgList &Args,
 const char *LinkingOutput) const {
   ArgStringList CmdArgs;
-  const ToolChain &TC = getToolChain();
+  auto &TC = static_cast(getToolChain());
 
   assert((Output.isFilename() || Output.isNothing()) && "invalid output");
   if (Output.isFilename())
@@ -10843,37 +10845,20 @@
 // did not run vcvarsall), try to build a consistent link environment.  If
 // the environment variable is set however, assume the user knows what
 // they're doing.
-std::string VisualStudioDir;
-const auto &MSVC = static_cast(TC);
-if (MSVC.getVisualStudioInstallDir(VisualStudioDir)) {
-  SmallString<128> LibDir(VisualStudioDir);
-  llvm::sys::path::append(LibDir, "VC", "lib");
-  switch (MSVC.getArch()) {
-  case llvm::Triple::x86:
-// x86 just puts the libraries directly in lib
-break;
-  case llvm::Triple::x86_64:
-llvm::sys::path::append(LibDir, "amd64");
-break;
-  case llvm::Triple::arm:
-llvm::sys::path::append(LibDir, "arm");
-break;
-  default:
-break;
-  }
-  CmdArgs.push_back(
-  Args.MakeArgString(std::string("-libpath:") + LibDir.c_str()));
+CmdArgs.push_back(Args.MakeArgString(
+  std::string("-libpath:")
+  + TC.getSubDirectoryPath(toolchains::MSVCToolChain
+   ::SubDirectoryType::Lib)));
 
-  if (MSVC.useUniversalCRT(VisualStudioDir)) {
-std::string UniversalCRTLibPath;
-if (MSVC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
-  CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:") +
-   UniversalCRTLibPath));
-  }
+if (TC.useUniversalCRT()) {
+  std::string UniversalCRTLibPath;
+  if (TC.getUniversalCRTLibraryPath(UniversalCRTLibPath))
+CmdArgs.push_back(Args.MakeArgString(std::string("-libpath:")
+ + UniversalCRTLibPath));
 }
 
 std::string WindowsSdkLibPath;
-if (MSVC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
+if (TC.getWindowsSDKLibraryPath(WindowsSdkLibPath))
   CmdArgs.push_back(
   Args.MakeArgStri

[PATCH] D24688: Introduce "hosted" module flag.

2017-01-08 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D24688#639158, @jyknight wrote:

> Since this requires everyone generating llvm IR to add this module attribute 
> for optimal codegen, it should be documented in release notes and the 
> LangRef, I think.


And, for something like this, here: 
http://llvm.org/docs/Frontend/PerformanceTips.html

> I mean: it's unfortunate that it's needed at all, but at the very least it 
> should be possible for people to find out about it.




https://reviews.llvm.org/D24688



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


[PATCH] D28289: Fix tests with CLANG_DEFAULT_LINKER

2017-01-08 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291389: Fix tests with CLANG_DEFAULT_LINKER (authored by 
Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D28289?vs=83036&id=83553#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28289

Files:
  cfe/trunk/test/Driver/B-opt.c
  cfe/trunk/test/Driver/coverage-ld.c
  cfe/trunk/test/Driver/cross-linux.c
  cfe/trunk/test/Driver/fuchsia.c
  cfe/trunk/test/Driver/fuchsia.cpp
  cfe/trunk/test/Driver/fuse-ld.c
  cfe/trunk/test/Driver/instrprof-ld.c
  cfe/trunk/test/Driver/mips-mti-linux.c
  cfe/trunk/test/Driver/nostdlib.c
  cfe/trunk/test/Driver/prefixed-tools.c
  cfe/trunk/test/Driver/sanitizer-ld.c
  cfe/trunk/test/Driver/windows-cross.c

Index: cfe/trunk/test/Driver/instrprof-ld.c
===
--- cfe/trunk/test/Driver/instrprof-ld.c
+++ cfe/trunk/test/Driver/instrprof-ld.c
@@ -1,34 +1,34 @@
 // Test instrumented profiling ld flags.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -fprofile-instr-generate \
+// RUN: -target i386-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386 %s
 //
 // CHECK-LINUX-I386: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-I386: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-i386.a" {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-unknown-linux -fprofile-instr-generate \
+// RUN: -target x86_64-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
 //
 // CHECK-LINUX-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-x86_64.a" {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-unknown-linux -fprofile-instr-generate -nostdlib \
+// RUN: -target x86_64-unknown-linux -fprofile-instr-generate -nostdlib -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB-X86-64 %s
 //
 // CHECK-LINUX-NOSTDLIB-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LINUX-NOSTDLIB-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate \
+// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-FREEBSD-X86-64 %s
@@ -38,7 +38,7 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -shared \
-// RUN: -target i386-unknown-linux -fprofile-instr-generate \
+// RUN: -target i386-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386-SHARED %s
@@ -48,7 +48,7 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -shared \
-// RUN: -target x86_64-unknown-linux -fprofile-instr-generate \
+// RUN: -target x86_64-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64-SHARED %s
@@ -58,48 +58,48 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -shared \
-// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate \
+// RUN: -target x86_64-unknown-freebsd -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-FREEBSD-X86-64-SHARED %s
 //
 // CHECK-FREEBSD-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-FREEBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}freebsd{{/|}}libclang_rt.profile-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-apple-darwin14 -fprofile-instr-generate \
+// RUN: -target x86_64-apple-darwin14 -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=CHECK-DARWIN-X86-64 %s
 //
 // C

r291389 - Fix tests with CLANG_DEFAULT_LINKER

2017-01-08 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Sun Jan  8 04:04:07 2017
New Revision: 291389

URL: http://llvm.org/viewvc/llvm-project?rev=291389&view=rev
Log:
Fix tests with CLANG_DEFAULT_LINKER

I originally requested this to be tested in D25263 but in the end
forgot to make sure that it was done.

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

Modified:
cfe/trunk/test/Driver/B-opt.c
cfe/trunk/test/Driver/coverage-ld.c
cfe/trunk/test/Driver/cross-linux.c
cfe/trunk/test/Driver/fuchsia.c
cfe/trunk/test/Driver/fuchsia.cpp
cfe/trunk/test/Driver/fuse-ld.c
cfe/trunk/test/Driver/instrprof-ld.c
cfe/trunk/test/Driver/mips-mti-linux.c
cfe/trunk/test/Driver/nostdlib.c
cfe/trunk/test/Driver/prefixed-tools.c
cfe/trunk/test/Driver/sanitizer-ld.c
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/test/Driver/B-opt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/B-opt.c?rev=291389&r1=291388&r2=291389&view=diff
==
--- cfe/trunk/test/Driver/B-opt.c (original)
+++ cfe/trunk/test/Driver/B-opt.c Sun Jan  8 04:04:07 2017
@@ -1,22 +1,22 @@
 // Check -B driver option.
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
-// RUN: -B %S/Inputs/B_opt_tree/dir1 2>&1 \
+// RUN: -B %S/Inputs/B_opt_tree/dir1 -fuse-ld=ld 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-TRIPLE %s
 // CHECK-B-OPT-TRIPLE: 
"{{.*}}/Inputs/B_opt_tree/dir1{{/|}}i386-unknown-linux-ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
-// RUN: -B %S/Inputs/B_opt_tree/dir2 2>&1 \
+// RUN: -B %S/Inputs/B_opt_tree/dir2 -fuse-ld=ld 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-DIR %s
 // CHECK-B-OPT-DIR: "{{.*}}/Inputs/B_opt_tree/dir2{{/|}}ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
-// RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- 2>&1 \
+// RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- -fuse-ld=ld 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-PREFIX %s
 // CHECK-B-OPT-PREFIX: "{{.*}}/Inputs/B_opt_tree/dir3{{/|}}prefix-ld"
 //
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
 // RUN: -B %S/Inputs/B_opt_tree/dir3/prefix- \
-// RUN: -B %S/Inputs/B_opt_tree/dir2 2>&1 \
+// RUN: -B %S/Inputs/B_opt_tree/dir2 2>&1 -fuse-ld=ld \
 // RUN:   | FileCheck --check-prefix=CHECK-B-OPT-MULT %s
 // CHECK-B-OPT-MULT: "{{.*}}/Inputs/B_opt_tree/dir3{{/|}}prefix-ld"

Modified: cfe/trunk/test/Driver/coverage-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/coverage-ld.c?rev=291389&r1=291388&r2=291389&view=diff
==
--- cfe/trunk/test/Driver/coverage-ld.c (original)
+++ cfe/trunk/test/Driver/coverage-ld.c Sun Jan  8 04:04:07 2017
@@ -1,7 +1,7 @@
 // Test coverage ld flags.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux --coverage \
+// RUN: -target i386-unknown-linux --coverage -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-I386 %s
@@ -10,7 +10,7 @@
 // CHECK-LINUX-I386: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-i386.a"
 {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-unknown-linux --coverage \
+// RUN: -target x86_64-unknown-linux --coverage -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LINUX-X86-64 %s
@@ -19,7 +19,7 @@
 // CHECK-LINUX-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.profile-x86_64.a"
 {{.*}} "-lc"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target x86_64-unknown-freebsd --coverage \
+// RUN: -target x86_64-unknown-freebsd --coverage -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_freebsd64_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-FREEBSD-X86-64 %s
@@ -28,7 +28,7 @@
 // CHECK-FREEBSD-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}freebsd{{/|}}libclang_rt.profile-x86_64.a"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi --coverage \
+// RUN: -target arm-linux-androideabi --coverage -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ARM %s

Modified: cfe/trunk/test/Driver/cross-linux.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cross-linux.c?rev=291389&r1=291388&r2=291389&view=diff
=