r298487 - Move setting of LangOpts based on target flags out of CompilerInstance

2017-03-21 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Wed Mar 22 01:36:09 2017
New Revision: 298487

URL: http://llvm.org/viewvc/llvm-project?rev=298487&view=rev
Log:
Move setting of LangOpts based on target flags out of CompilerInstance
and into TargetInfo::adjust so that it gets called in more places
throughout the compiler (AST serialization in particular).

Should fix PPC modules after removing of faltivec.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=298487&r1=298486&r2=298487&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Mar 22 01:36:09 2017
@@ -823,8 +823,9 @@ public:
   /// \brief Set forced language options.
   ///
   /// Apply changes to the target information with respect to certain
-  /// language options which change the target configuration.
-  virtual void adjust(const LangOptions &Opts);
+  /// language options which change the target configuration and adjust
+  /// the language based on the target options where applicable.
+  virtual void adjust(LangOptions &Opts);
 
   /// \brief Adjust target options based on codegen options.
   virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=298487&r1=298486&r2=298487&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed Mar 22 01:36:09 2017
@@ -282,8 +282,9 @@ bool TargetInfo::isTypeSigned(IntType T)
 
 /// adjust - Set forced language options.
 /// Apply changes to the target information with respect to certain
-/// language options which change the target configuration.
-void TargetInfo::adjust(const LangOptions &Opts) {
+/// language options which change the target configuration and adjust
+/// the language based on the target options where applicable.
+void TargetInfo::adjust(LangOptions &Opts) {
   if (Opts.NoBitFieldTypeAlign)
 UseBitFieldTypeAlignment = false;
   if (Opts.ShortWChar)

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=298487&r1=298486&r2=298487&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Mar 22 01:36:09 2017
@@ -933,6 +933,13 @@ public:
 ArchDefineA2q   = 1 << 15
   } ArchDefineTypes;
 
+  // Set the language option for altivec based on our value.
+  void adjust(LangOptions &Opts) override {
+if (HasAltivec)
+  Opts.AltiVec = 1;
+TargetInfo::adjust(Opts);
+  }
+
   // Note: GCC recognizes the following additional cpus:
   //  401, 403, 405, 405fp, 440fp, 464, 464fp, 476, 476fp, 505, 740, 801,
   //  821, 823, 8540, 8548, e300c2, e300c3, e500mc64, e6500, 860, cell,

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=298487&r1=298486&r2=298487&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Mar 22 01:36:09 2017
@@ -916,12 +916,6 @@ bool CompilerInstance::ExecuteAction(Fro
   if (!hasTarget())
 return false;
 
-  // FIXME: Setting this here is less than ideal, but it is set based on a
-  // target option for compatibility and this is immediately after we construct
-  // a target.
-  if (getTarget().hasFeature("altivec"))
-getLangOpts().AltiVec = 1;
-
   // Create TargetInfo for the other side of CUDA compilation.
   if (getLangOpts().CUDA && !getFrontendOpts().AuxTriple.empty()) {
 auto TO = std::make_shared();


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


[PATCH] D31234: Implement P0599 - noexcept for hash functions

2017-03-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

Mark most of the hash functions provided by libc++ as noexcept; the exceptions 
being `optional` and `variant`.
Tests to ensure this.

There's still some investigation to be done on `unique_ptr` and fancy pointer 
support, but that can come later.


https://reviews.llvm.org/D31234

Files:
  include/optional
  include/thread
  include/variant
  test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
  test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
  test/std/diagnostics/syserr/syserr.hash/error_condition.pass.cpp
  test/std/strings/basic.string.hash/strings.pass.cpp
  test/std/strings/string.view/string.view.hash/string_view.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
  test/std/utilities/function.objects/unord.hash/enum.pass.cpp
  test/std/utilities/function.objects/unord.hash/floating.pass.cpp
  test/std/utilities/function.objects/unord.hash/integral.pass.cpp
  test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
  test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
  test/std/utilities/variant/variant.hash/hash.pass.cpp

Index: test/std/utilities/variant/variant.hash/hash.pass.cpp
===
--- test/std/utilities/variant/variant.hash/hash.pass.cpp
+++ test/std/utilities/variant/variant.hash/hash.pass.cpp
@@ -102,6 +102,7 @@
   assert(h(m1) == h(m2));
   {
 ASSERT_SAME_TYPE(decltype(h(m1)), std::size_t);
+ASSERT_NOEXCEPT(h(m1));
 static_assert(std::is_copy_constructible::value, "");
   }
   {
Index: test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
===
--- test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
+++ test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
@@ -30,6 +30,8 @@
 typedef std::hash H;
 static_assert((std::is_same::value), "" );
 static_assert((std::is_same::value), "" );
+ASSERT_NOEXCEPT(H()(T()));
+
 H h;
 T bs(static_cast(N));
 const std::size_t result = h(bs);
Index: test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
===
--- test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 void
 test()
@@ -30,6 +32,7 @@
 typedef std::hash H;
 static_assert((std::is_same::value), "" );
 static_assert((std::is_same::value), "" );
+ASSERT_NOEXCEPT(H()(T()));
 H h;
 
 typedef typename std::remove_pointer::type type;
@@ -38,7 +41,17 @@
 assert(h(&i) != h(&j));
 }
 
+void test_nullptr()
+{
+typedef std::nullptr_t T;
+typedef std::hash H;
+static_assert((std::is_same::value), "" );
+static_assert((std::is_same::value), "" );
+ASSERT_NOEXCEPT(H()(T()));
+}
+
 int main()
 {
 test();
+test_nullptr();
 }
Index: test/std/utilities/function.objects/unord.hash/integral.pass.cpp
===
--- test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -31,6 +31,7 @@
 typedef std::hash H;
 static_assert((std::is_same::value), "" );
 static_assert((std::is_same::value), "" );
+ASSERT_NOEXCEPT(H()(T()));
 H h;
 
 for (int i = 0; i <= 5; ++i)
@@ -64,42 +65,42 @@
 test();
 test();
 
-//	LWG #2119
+//  LWG #2119
 test();
 test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
 test();
 test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
-	test();
-	test();
-	test();
-	test();
+test();
+test();
+test();
+test();
 
 test();
 test();
Index: test/std/utilities/function.objects/unord.hash/floating.pass.cpp
===
--- test/std/utilities/function.objects/unord.hash/floating.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/floating.pass.cpp
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 void
 test()
@@ -31,6 +33,7 @@
 typedef std::hash H;
 static_assert((std::is_same::value), "" );
 static_assert((std::is_same::value), "" );
+ASSERT_NOEXCEPT(H()(T()));
 H h;
 
 std::size_t t0 = h(0.);
Index: test/std/utilities/function.objects/unord.hash/enum.pass.cpp
=

Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Breno Guimarães via cfe-commits
Hi,

Thanks for the suggestions. I actually had tested with a fake header file
(so I could build more interesting testcases) but it didn't occur to me to
actually make it part of the codebase test.

I was afraid of being too kind to exempt PredefinedExpr symbols in any
context, and that's why I only do it if the symbol appears on a system
header. Had I exempted the symbol in any context, this would be allowed:

void some_user_function(const char*);
some_user_func(__PRETTY_FUNCTION__);

That's a judgment call, really. I went for the safe side, but wouldn't mind
to change it at all. As you pointed we already allow the decay of string
literals, so it may be the better way.

On the other hand, I went a little beyond the original scope. I added the
precondition of not being a "system symbol decay in system header".
By "system symbol" I mean a PredefinedExpr or any symbol declared in a
system header.

Let's do it like this: I'll create a header, include it passing the
-isystem flag, and add several more tests and scenarios. I'll add the
result the code after my changes produce, and we can judge on the concrete
case what makes more sense.

Is that reasonable?

Best Regards,
Breno G.




On Tue, Mar 21, 2017 at 11:37 PM, Richard Smith 
wrote:

> On 21 March 2017 at 18:57, Breno Guimarães via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hey guys,
>>
>> I'm sorry the test did not make the decay explicit. It's indeed sort of
>> tricky: https://bugs.llvm.org/show_bug.cgi?id=32239
>>
>> Basically, assert is expanded into:
>>
>> (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e)
>>
>> Maybe in your libc, and even in most libc's, but not in general, and we
> can't and shouldn't rely on that in this test. (And there may not even *be*
> a usable  in the include path...)
>
>> Well, __func__ and __FILE__ are const char[], while __assert_rtn expects 
>> const char*.
>>
>> I would think __func__ (and its friends __FUNCTION__,
> __PRETTY_FUNCTION__, etc) should be exempted from this warning just like
> decay on a string literal is. __FILE__ is string literal, so should be
> exempted already. Perhaps checking for a system header is not the right
> change at all?
>
>> I've also seen this in my own environment (Linux) with slightly different 
>> function names, but basically the same problem.
>>
>> Any ideas of how to rewrite the test (or the code?) to have the change 
>> pushed?
>>
>> For the current approach: add a header file (to Inputs/...) that contains
> the macro you want to use and add a -isystem path to the test pointing at
> your Inputs/... directory. To whitelist conversions of __func__ etc you
> should also check for PredefinedExpr wherever we're currently checking for
> StringLiteral.
>
>> Thanks!
>>
>> Breno G.
>>
>>
>>
>>
>> On Tue, Mar 21, 2017 at 10:36 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Thank you!
>>>
>>> On 21 March 2017 at 18:22, Aaron Ballman  wrote:
>>>
 On Tue, Mar 21, 2017 at 9:15 PM, Richard Smith 
 wrote:
 > On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits
 >  wrote:
 >>
 >> Author: aaronballman
 >> Date: Tue Mar 21 14:01:17 2017
 >> New Revision: 298421
 >>
 >> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
 >> Log:
 >> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
 >> diagnosing array to pointer decay stemming from system macros.
 >>
 >> Patch by Breno Rodrigues Guimaraes.
 >>
 >> Modified:
 >>
 >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
 dsArrayToPointerDecayCheck.cpp
 >>
 >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pr
 o-bounds-array-to-pointer-decay.cpp
 >>
 >> Modified:
 >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
 dsArrayToPointerDecayCheck.cpp
 >> URL:
 >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayChe
 ck.cpp?rev=298421&r1=298420&r2=298421&view=diff
 >>
 >> 
 ==
 >> ---
 >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
 dsArrayToPointerDecayCheck.cpp
 >> (original)
 >> +++
 >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
 dsArrayToPointerDecayCheck.cpp
 >> Tue Mar 21 14:01:17 2017
 >> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
 >>return InnerMatcher.matches(*E, Finder, Builder);
 >>  }
 >>
 >> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
 >> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
 >> +}
 >> +
 >> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
 >> +  auto &SM = Finder->getASTContext().getSourceManager();
 >> +  if (SM.isInSystemMacro(Node.getLocStart())) {
 >> +if 

Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Richard Smith via cfe-commits
On 21 March 2017 at 18:57, Breno Guimarães via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hey guys,
>
> I'm sorry the test did not make the decay explicit. It's indeed sort of
> tricky: https://bugs.llvm.org/show_bug.cgi?id=32239
>
> Basically, assert is expanded into:
>
> (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e)
>
> Maybe in your libc, and even in most libc's, but not in general, and we
can't and shouldn't rely on that in this test. (And there may not even *be*
a usable  in the include path...)

> Well, __func__ and __FILE__ are const char[], while __assert_rtn expects 
> const char*.
>
> I would think __func__ (and its friends __FUNCTION__, __PRETTY_FUNCTION__,
etc) should be exempted from this warning just like decay on a string
literal is. __FILE__ is string literal, so should be exempted already.
Perhaps checking for a system header is not the right change at all?

> I've also seen this in my own environment (Linux) with slightly different 
> function names, but basically the same problem.
>
> Any ideas of how to rewrite the test (or the code?) to have the change pushed?
>
> For the current approach: add a header file (to Inputs/...) that contains
the macro you want to use and add a -isystem path to the test pointing at
your Inputs/... directory. To whitelist conversions of __func__ etc you
should also check for PredefinedExpr wherever we're currently checking for
StringLiteral.

> Thanks!
>
> Breno G.
>
>
>
>
> On Tue, Mar 21, 2017 at 10:36 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Thank you!
>>
>> On 21 March 2017 at 18:22, Aaron Ballman  wrote:
>>
>>> On Tue, Mar 21, 2017 at 9:15 PM, Richard Smith 
>>> wrote:
>>> > On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits
>>> >  wrote:
>>> >>
>>> >> Author: aaronballman
>>> >> Date: Tue Mar 21 14:01:17 2017
>>> >> New Revision: 298421
>>> >>
>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
>>> >> Log:
>>> >> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
>>> >> diagnosing array to pointer decay stemming from system macros.
>>> >>
>>> >> Patch by Breno Rodrigues Guimaraes.
>>> >>
>>> >> Modified:
>>> >>
>>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>>> dsArrayToPointerDecayCheck.cpp
>>> >>
>>> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pr
>>> o-bounds-array-to-pointer-decay.cpp
>>> >>
>>> >> Modified:
>>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>>> dsArrayToPointerDecayCheck.cpp
>>> >> URL:
>>> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayChe
>>> ck.cpp?rev=298421&r1=298420&r2=298421&view=diff
>>> >>
>>> >> 
>>> ==
>>> >> ---
>>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>>> dsArrayToPointerDecayCheck.cpp
>>> >> (original)
>>> >> +++
>>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>>> dsArrayToPointerDecayCheck.cpp
>>> >> Tue Mar 21 14:01:17 2017
>>> >> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
>>> >>return InnerMatcher.matches(*E, Finder, Builder);
>>> >>  }
>>> >>
>>> >> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
>>> >> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
>>> >> +}
>>> >> +
>>> >> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
>>> >> +  auto &SM = Finder->getASTContext().getSourceManager();
>>> >> +  if (SM.isInSystemMacro(Node.getLocStart())) {
>>> >> +if (isa(Node.getSubExpr()))
>>> >> +  return true;
>>> >> +
>>> >> +if (const auto *SymbolDeclRef =
>>> >> dyn_cast(Node.getSubExpr())) {
>>> >> +  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
>>> >> +  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl
>>> ->getLocation()))
>>> >> +return true;
>>> >> +}
>>> >> +  }
>>> >> +  return false;
>>> >> +}
>>> >> +
>>> >>  void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder
>>> >> *Finder) {
>>> >>if (!getLangOpts().CPlusPlus)
>>> >>  return;
>>> >> @@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
>>> >>// 2) inside a range-for over an array
>>> >>// 3) if it converts a string literal to a pointer
>>> >>Finder->addMatcher(
>>> >> -  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
>>> >> +  implicitCastExpr(isArrayToPointerDecay(),
>>> >> +   unless(hasParent(arraySubscriptExpr())),
>>> >>
>>> >> unless(hasParentIgnoringImpCasts(explicitCastExpr())),
>>> >> unless(isInsideOfRangeBeginEndStmt()),
>>> >> -   unless(hasSourceExpression(stringLiteral(
>>> >> +   unless(hasSourceExpression(stringLiteral())),
>>> >> +   unless(sysSymbolDecayInSysHeader()))
>>> >>.bind("cast"),
>>> >>this);
>>

[PATCH] D30018: [XRay] Add __xray_customeevent(...) as a clang-supported builtin

2017-03-21 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a reviewer: rnk.
dberris added a subscriber: rnk.
dberris added a comment.

@rnk -- if you have time, a review for this would be appreciated too.


https://reviews.llvm.org/D30018



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


[PATCH] D31069: Don't warn about an unreachable fallthrough annotation in a template function

2017-03-21 Thread Richard Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298477: Suppress warning on unreachable 
[[clang::fallthrough]] within a template… (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D31069?vs=92104&id=92588#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31069

Files:
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/test/SemaCXX/P30636.cpp


Index: cfe/trunk/test/SemaCXX/P30636.cpp
===
--- cfe/trunk/test/SemaCXX/P30636.cpp
+++ cfe/trunk/test/SemaCXX/P30636.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// expected-no-diagnostics
+
+template
+int fallthrough_template(int i)
+{
+  switch (i) {
+case 1:
+  if (param)
+return 3;
+  [[clang::fallthrough]]; // no warning here, for an unreachable 
annotation (in the fallthrough_template case) in a template function
+case 2:
+  return 4;
+default:
+  return 5;
+  }
+}
+  
+template int fallthrough_template(int);
+
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -972,7 +972,8 @@
   }
 }
 
-bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt) {
+bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt,
+   bool IsTemplateInstantiation) {
   assert(!ReachableBlocks.empty() && "ReachableBlocks empty");
 
   int UnannotatedCnt = 0;
@@ -1002,8 +1003,12 @@
ElemIt != ElemEnd; ++ElemIt) {
 if (Optional CS = ElemIt->getAs()) {
   if (const AttributedStmt *AS = asFallThroughAttr(CS->getStmt())) 
{
-S.Diag(AS->getLocStart(),
-   diag::warn_fallthrough_attr_unreachable);
+// Don't issue a warning for an unreachable fallthrough
+// attribute in template instantiations as it may not be
+// unreachable in all instantiations of the template.
+if (!IsTemplateInstantiation)
+  S.Diag(AS->getLocStart(),
+ diag::warn_fallthrough_attr_unreachable);
 markFallthroughVisited(AS);
 ++AnnotatedCnt;
 break;
@@ -1164,7 +1169,11 @@
 
 int AnnotatedCnt;
 
-if (!FM.checkFallThroughIntoBlock(*B, AnnotatedCnt))
+bool IsTemplateInstantiation = false;
+if (const FunctionDecl *Function = dyn_cast(AC.getDecl()))
+  IsTemplateInstantiation = Function->isTemplateInstantiation();
+if (!FM.checkFallThroughIntoBlock(*B, AnnotatedCnt,
+  IsTemplateInstantiation))
   continue;
 
 S.Diag(Label->getLocStart(),


Index: cfe/trunk/test/SemaCXX/P30636.cpp
===
--- cfe/trunk/test/SemaCXX/P30636.cpp
+++ cfe/trunk/test/SemaCXX/P30636.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// expected-no-diagnostics
+
+template
+int fallthrough_template(int i)
+{
+  switch (i) {
+case 1:
+  if (param)
+return 3;
+  [[clang::fallthrough]]; // no warning here, for an unreachable annotation (in the fallthrough_template case) in a template function
+case 2:
+  return 4;
+default:
+  return 5;
+  }
+}
+  
+template int fallthrough_template(int);
+
Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -972,7 +972,8 @@
   }
 }
 
-bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt) {
+bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt,
+   bool IsTemplateInstantiation) {
   assert(!ReachableBlocks.empty() && "ReachableBlocks empty");
 
   int UnannotatedCnt = 0;
@@ -1002,8 +1003,12 @@
ElemIt != ElemEnd; ++ElemIt) {
 if (Optional CS = ElemIt->getAs()) {
   if (const AttributedStmt *AS = asFallThroughAttr(CS->getStmt())) {
-S.Diag(AS->getLocStart(),
-   diag::warn_fallthrough_attr_unreachable);
+// Don't issue a warning for an unreachable fallthrough
+// attribute in template instantiations as it may not be
+// unreachable in all instantiations of the template.
+if (!IsTemplateInstantiation)
+  S.Diag(AS->getLocStart(),
+ diag::warn_fallthrough_attr_unreachable);
 markFallthroughVisited(AS);
   

r298477 - Suppress warning on unreachable [[clang::fallthrough]] within a template instantiation.

2017-03-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Mar 21 20:49:19 2017
New Revision: 298477

URL: http://llvm.org/viewvc/llvm-project?rev=298477&view=rev
Log:
Suppress warning on unreachable [[clang::fallthrough]] within a template 
instantiation.

We don't know whether some other instantiation of the template might be able to
reach the annotation, so warning on it has a high chance of false positives.

Patch by Ahmed Asadi!

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

Added:
cfe/trunk/test/SemaCXX/P30636.cpp
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=298477&r1=298476&r2=298477&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Mar 21 20:49:19 2017
@@ -972,7 +972,8 @@ namespace {
   }
 }
 
-bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt) {
+bool checkFallThroughIntoBlock(const CFGBlock &B, int &AnnotatedCnt,
+   bool IsTemplateInstantiation) {
   assert(!ReachableBlocks.empty() && "ReachableBlocks empty");
 
   int UnannotatedCnt = 0;
@@ -1002,8 +1003,12 @@ namespace {
ElemIt != ElemEnd; ++ElemIt) {
 if (Optional CS = ElemIt->getAs()) {
   if (const AttributedStmt *AS = asFallThroughAttr(CS->getStmt())) 
{
-S.Diag(AS->getLocStart(),
-   diag::warn_fallthrough_attr_unreachable);
+// Don't issue a warning for an unreachable fallthrough
+// attribute in template instantiations as it may not be
+// unreachable in all instantiations of the template.
+if (!IsTemplateInstantiation)
+  S.Diag(AS->getLocStart(),
+ diag::warn_fallthrough_attr_unreachable);
 markFallthroughVisited(AS);
 ++AnnotatedCnt;
 break;
@@ -1164,7 +1169,11 @@ static void DiagnoseSwitchLabelsFallthro
 
 int AnnotatedCnt;
 
-if (!FM.checkFallThroughIntoBlock(*B, AnnotatedCnt))
+bool IsTemplateInstantiation = false;
+if (const FunctionDecl *Function = dyn_cast(AC.getDecl()))
+  IsTemplateInstantiation = Function->isTemplateInstantiation();
+if (!FM.checkFallThroughIntoBlock(*B, AnnotatedCnt,
+  IsTemplateInstantiation))
   continue;
 
 S.Diag(Label->getLocStart(),

Added: cfe/trunk/test/SemaCXX/P30636.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/P30636.cpp?rev=298477&view=auto
==
--- cfe/trunk/test/SemaCXX/P30636.cpp (added)
+++ cfe/trunk/test/SemaCXX/P30636.cpp Tue Mar 21 20:49:19 2017
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s
+// expected-no-diagnostics
+
+template
+int fallthrough_template(int i)
+{
+  switch (i) {
+case 1:
+  if (param)
+return 3;
+  [[clang::fallthrough]]; // no warning here, for an unreachable 
annotation (in the fallthrough_template case) in a template function
+case 2:
+  return 4;
+default:
+  return 5;
+  }
+}
+  
+template int fallthrough_template(int);
+


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


Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Breno Guimarães via cfe-commits
Hey guys,

I'm sorry the test did not make the decay explicit. It's indeed sort of
tricky: https://bugs.llvm.org/show_bug.cgi?id=32239

Basically, assert is expanded into:

(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e)


Well, __func__ and __FILE__ are const char[], while __assert_rtn
expects const char*.

I've also seen this in my own environment (Linux) with slightly
different function names, but basically the same problem.

Any ideas of how to rewrite the test (or the code?) to have the change pushed?

Thanks!

Breno G.




On Tue, Mar 21, 2017 at 10:36 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Thank you!
>
> On 21 March 2017 at 18:22, Aaron Ballman  wrote:
>
>> On Tue, Mar 21, 2017 at 9:15 PM, Richard Smith 
>> wrote:
>> > On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits
>> >  wrote:
>> >>
>> >> Author: aaronballman
>> >> Date: Tue Mar 21 14:01:17 2017
>> >> New Revision: 298421
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
>> >> Log:
>> >> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
>> >> diagnosing array to pointer decay stemming from system macros.
>> >>
>> >> Patch by Breno Rodrigues Guimaraes.
>> >>
>> >> Modified:
>> >>
>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>> dsArrayToPointerDecayCheck.cpp
>> >>
>> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pr
>> o-bounds-array-to-pointer-decay.cpp
>> >>
>> >> Modified:
>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>> dsArrayToPointerDecayCheck.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayChe
>> ck.cpp?rev=298421&r1=298420&r2=298421&view=diff
>> >>
>> >> 
>> ==
>> >> ---
>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>> dsArrayToPointerDecayCheck.cpp
>> >> (original)
>> >> +++
>> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoun
>> dsArrayToPointerDecayCheck.cpp
>> >> Tue Mar 21 14:01:17 2017
>> >> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
>> >>return InnerMatcher.matches(*E, Finder, Builder);
>> >>  }
>> >>
>> >> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
>> >> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
>> >> +}
>> >> +
>> >> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
>> >> +  auto &SM = Finder->getASTContext().getSourceManager();
>> >> +  if (SM.isInSystemMacro(Node.getLocStart())) {
>> >> +if (isa(Node.getSubExpr()))
>> >> +  return true;
>> >> +
>> >> +if (const auto *SymbolDeclRef =
>> >> dyn_cast(Node.getSubExpr())) {
>> >> +  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
>> >> +  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl
>> ->getLocation()))
>> >> +return true;
>> >> +}
>> >> +  }
>> >> +  return false;
>> >> +}
>> >> +
>> >>  void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder
>> >> *Finder) {
>> >>if (!getLangOpts().CPlusPlus)
>> >>  return;
>> >> @@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
>> >>// 2) inside a range-for over an array
>> >>// 3) if it converts a string literal to a pointer
>> >>Finder->addMatcher(
>> >> -  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
>> >> +  implicitCastExpr(isArrayToPointerDecay(),
>> >> +   unless(hasParent(arraySubscriptExpr())),
>> >>
>> >> unless(hasParentIgnoringImpCasts(explicitCastExpr())),
>> >> unless(isInsideOfRangeBeginEndStmt()),
>> >> -   unless(hasSourceExpression(stringLiteral(
>> >> +   unless(hasSourceExpression(stringLiteral())),
>> >> +   unless(sysSymbolDecayInSysHeader()))
>> >>.bind("cast"),
>> >>this);
>> >>  }
>> >> @@ -67,8 +88,6 @@ void ProBoundsArrayToPointerDecayCheck::
>> >>  void ProBoundsArrayToPointerDecayCheck::check(
>> >>  const MatchFinder::MatchResult &Result) {
>> >>const auto *MatchedCast =
>> >> Result.Nodes.getNodeAs("cast");
>> >> -  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
>> >> -return;
>> >>
>> >>diag(MatchedCast->getExprLoc(), "do not implicitly decay an array
>> into
>> >> a "
>> >>"pointer; consider using
>> >> gsl::array_view or "
>> >>
>> >> Modified:
>> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pr
>> o-bounds-array-to-pointer-decay.cpp
>> >> URL:
>> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-
>> pointer-decay.cpp?rev=298421&r1=298420&r2=298421&view=diff
>> >>
>> >> 
>> ==
>> >> ---
>> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreg

[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 92587.
yaxunl added a comment.

Fix getDWARFAddressSpace.


https://reviews.llvm.org/D31210

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/amdgpu-new-addr.cl

Index: test/CodeGenOpenCL/amdgpu-new-addr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-new-addr.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn -target-feature "+new-addr" -emit-llvm -o - | FileCheck -check-prefix=NEW %s
+
+// CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// NEW: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+void foo(void) {}
+
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1997,16 +1997,6 @@
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-static const unsigned AMDGPUAddrSpaceMap[] = {
-  1,// opencl_global
-  3,// opencl_local
-  2,// opencl_constant
-  4,// opencl_generic
-  1,// cuda_device
-  2,// cuda_constant
-  3 // cuda_shared
-};
-
 // If you edit the description strings, make sure you update
 // getPointerWidthV().
 
@@ -2014,15 +2004,65 @@
   "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
-static const char *const DataLayoutStringSI =
+static const char *const DataLayoutStringSIOld =
   "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
   "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
+static const char *const DataLayoutStringSINew =
+  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
+  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
+  "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
+
 class AMDGPUTargetInfo final : public TargetInfo {
   static const Builtin::Info BuiltinInfo[];
   static const char * const GCCRegNames[];
 
+  struct AddrSpace {
+unsigned Generic, Global, Local, Constant, Private;
+bool UseNew;
+AddrSpace(bool UseNew_ = false){
+  reset(UseNew_);
+}
+void reset(bool UseNew_) {
+  UseNew = UseNew_;
+  if (UseNew) {
+Generic   = 0;
+Global= 1;
+Local = 3;
+Constant  = 4;
+Private   = 5;
+  } else {
+Generic   = 4;
+Global= 1;
+Local = 3;
+Constant  = 2;
+Private   = 0;
+  }
+}
+const LangAS::Map *getMap() {
+  static LangAS::Map OldMap = {
+  1,  // opencl_global
+  3,  // opencl_local
+  2,  // opencl_constant
+  4,  // opencl_generic
+  1,  // cuda_device
+  2,  // cuda_constant
+  3   // cuda_shared
+  };
+  static LangAS::Map NewMap = {
+  1,  // opencl_global
+  3,  // opencl_local
+  4,  // opencl_constant
+  0,  // opencl_generic
+  1,  // cuda_device
+  4,  // cuda_constant
+  3   // cuda_shared
+  };
+  return UseNew ? &NewMap : &OldMap;
+}
+  };
+
   /// \brief The GPU profiles supported by the AMDGPU target.
   enum GPUKind {
 GK_NONE,
@@ -2044,6 +2084,7 @@
   bool hasFMAF:1;
   bool hasLDEXPF:1;
   bool hasFullSpeedFP32Denorms:1;
+  bool UseNewAddrMap:1;
 
   static bool isAMDGCN(const llvm::Triple &TT) {
 return TT.getArch() == llvm::Triple::amdgcn;
@@ -2056,17 +2097,29 @@
   hasFP64(false),
   hasFMAF(false),
   hasLDEXPF(false),
-  hasFullSpeedFP32Denorms(false){
+  hasFullSpeedFP32Denorms(false),
+  UseNewAddrMap(false){
 if (getTriple().getArch() == llvm::Triple::amdgcn) {
   hasFP64 = true;
   hasFMAF = true;
   hasLDEXPF = true;
 }
+// At this stage, Opt.Features has not been populated yet.
+for (auto &I:Opts.FeaturesAsWritten) {
+  if (I == "+new-addr") {
+UseNewAddrMap = true;
+  } else if (I == "-new-addr") {
+UseNewAddrMap = false;
+  }
+}
+AS.reset(UseNewAddrMap);
 
 resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn ?
-DataLayoutStringSI : DataLayoutStringR600);
+(UseNewAddrMap ? DataLayoutStringSINew :
+DataLayoutStringSIOld)
+: DataLayoutStringR600);
 
-AddrSpaceMap = &AMDGPUAddrSpaceMap;
+AddrSpaceMap = AS.getMap();
 UseAddrSpaceMapMangling = true;
   }
 
@@ -2074,14 +2127,10 @@
 if (GPU <= GK_CAYMAN)
   return 32;
 
-switch(AddrSpace) {
-  default:
-return 64;
-  case 0:
-  case 3:
- 

[PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In https://reviews.llvm.org/D30760#707178, @zhizhouy wrote:

> Hi aprantl, thanks for replying. I checked the usage of DwarfDebugFlags, it 
> seems that it really did the same work of recording command line options.
>
> And I noticed that it is set to false by default. Is it because of some 
> concerns like the debug info size?


I think it is off by default because it doesn't really help the debugger and is 
more useful as a informational tool (e.g., when investigating compiler bugs). 
It also might leak unexpected information into the build (paths, macros, etc, 
...) that a user might want to have control over.

> Is it proper to just set it to true when -grecord-gcc-switches exists on 
> whatever platform?

I think so.

thanks,
adrian


https://reviews.llvm.org/D30760



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


Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Richard Smith via cfe-commits
Thank you!

On 21 March 2017 at 18:22, Aaron Ballman  wrote:

> On Tue, Mar 21, 2017 at 9:15 PM, Richard Smith 
> wrote:
> > On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Tue Mar 21 14:01:17 2017
> >> New Revision: 298421
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
> >> Log:
> >> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
> >> diagnosing array to pointer decay stemming from system macros.
> >>
> >> Patch by Breno Rodrigues Guimaraes.
> >>
> >> Modified:
> >>
> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> >>
> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
> >>
> >> Modified:
> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/
> cppcoreguidelines/ProBoundsArrayToPointerDecayCh
> eck.cpp?rev=298421&r1=298420&r2=298421&view=diff
> >>
> >> 
> ==
> >> ---
> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> >> (original)
> >> +++
> >> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> >> Tue Mar 21 14:01:17 2017
> >> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
> >>return InnerMatcher.matches(*E, Finder, Builder);
> >>  }
> >>
> >> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
> >> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
> >> +}
> >> +
> >> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
> >> +  auto &SM = Finder->getASTContext().getSourceManager();
> >> +  if (SM.isInSystemMacro(Node.getLocStart())) {
> >> +if (isa(Node.getSubExpr()))
> >> +  return true;
> >> +
> >> +if (const auto *SymbolDeclRef =
> >> dyn_cast(Node.getSubExpr())) {
> >> +  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
> >> +  if (SymbolDecl && SM.isInSystemHeader(
> SymbolDecl->getLocation()))
> >> +return true;
> >> +}
> >> +  }
> >> +  return false;
> >> +}
> >> +
> >>  void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder
> >> *Finder) {
> >>if (!getLangOpts().CPlusPlus)
> >>  return;
> >> @@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
> >>// 2) inside a range-for over an array
> >>// 3) if it converts a string literal to a pointer
> >>Finder->addMatcher(
> >> -  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
> >> +  implicitCastExpr(isArrayToPointerDecay(),
> >> +   unless(hasParent(arraySubscriptExpr())),
> >>
> >> unless(hasParentIgnoringImpCasts(explicitCastExpr())),
> >> unless(isInsideOfRangeBeginEndStmt()),
> >> -   unless(hasSourceExpression(stringLiteral(
> >> +   unless(hasSourceExpression(stringLiteral())),
> >> +   unless(sysSymbolDecayInSysHeader()))
> >>.bind("cast"),
> >>this);
> >>  }
> >> @@ -67,8 +88,6 @@ void ProBoundsArrayToPointerDecayCheck::
> >>  void ProBoundsArrayToPointerDecayCheck::check(
> >>  const MatchFinder::MatchResult &Result) {
> >>const auto *MatchedCast =
> >> Result.Nodes.getNodeAs("cast");
> >> -  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
> >> -return;
> >>
> >>diag(MatchedCast->getExprLoc(), "do not implicitly decay an array
> into
> >> a "
> >>"pointer; consider using
> >> gsl::array_view or "
> >>
> >> Modified:
> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-
> array-to-pointer-decay.cpp?rev=298421&r1=298420&r2=298421&view=diff
> >>
> >> 
> ==
> >> ---
> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
> >> (original)
> >> +++
> >> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
> >> Tue Mar 21 14:01:17 2017
> >> @@ -1,4 +1,5 @@
> >>  // RUN: %check_clang_tidy %s
> >> cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
> >> +#include 
> >
> >
> > This test is using a header that we do not supply (unlike stddef.h which
> > Clang provides itself). That does not seem especially reasonable to me;
> this
> > test is failing for us as a result. Can you supply a fake 
> system
> > header as an input to this test?
> >
> >>
> >>  #include 
> >>
> >>  namespace gsl {
> >> @@ -34,6 +35,11 @@ void f() {
> >>
> >>for (auto &e : a) // OK, iteration internally decays array to poi

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 92583.
ahatanak added a comment.

Rebase and ping.


https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/Analysis/nullability-no-arc.mm
  test/Analysis/nullability_nullonly.mm
  test/Sema/conditional-expr.c
  test/Sema/null_constant_to_nonnull.c

Index: test/Sema/null_constant_to_nonnull.c
===
--- /dev/null
+++ test/Sema/null_constant_to_nonnull.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnullable-to-nonnull-conversion %s -verify
+
+void null_const_to_nonnull(int c) {
+  int * _Nonnull p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  int * _Nonnull p1;
+  int * _Nonnull p2 = c ? p1 : 0; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+}
Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -17,7 +17,7 @@
   dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}}
   dp = 0 ? (double *)0 : (void *)0;
   vp = 0 ? (double *)0 : (void *)0;
-  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+  ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double * _Nullable'}}
 
   const int *cip;
   vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
@@ -90,7 +90,7 @@
 
 int f0(int a) {
   // GCC considers this a warning.
-  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
+  return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void * _Nullable' from a function with result type 'int'}}
 }
 
 int f2(int x) {
Index: test/Analysis/nullability_nullonly.mm
===
--- test/Analysis/nullability_nullonly.mm
+++ test/Analysis/nullability_nullonly.mm
@@ -100,7 +100,7 @@
 }
 
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}} expected-warning{{implicitly casting a null constant to non-nullable pointer type 'TestObject * _Nonnull __strong'}}
 }
 
 // Under ARC, returned expressions of ObjC objects types are are implicitly
Index: test/Analysis/nullability-no-arc.mm
===
--- test/Analysis/nullability-no-arc.mm
+++ test/Analysis/nullability-no-arc.mm
@@ -43,7 +43,7 @@
 }
 
 void testObjCNonARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}} expected-warning {{implicitly casting a null constant to non-nullable pointer type 'TestObject * _Nonnull'}}
 }
 
 @interface ClassWithInitializers : NSObject
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7105,20 +7105,26 @@
 }
 
 /// Compute the nullability of a conditional expression.
-static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
-  QualType LHSTy, QualType RHSTy,
-  ASTContext &Ctx) {
+static QualType computeConditionalNullability(Sema &S, QualType ResTy,
+  bool IsBin, Expr *LHSExpr,
+  Expr *RHSExpr, ASTContext &Ctx) {
   if (!ResTy->isAnyPointerType())
 return ResTy;
 
-  auto GetNullability = [&Ctx](QualType Ty) {
+  auto GetNullability = [&S, &Ctx](QualType Ty, Expr *E = nullptr) {
+// If E evaluates to a null constant, return nullable.
+if (E && S.checkNonNullExpr(E))
+  return NullabilityKind::Nullable;
+
 Optional Kind = Ty->getNullability(Ctx);
 if (Kind)
   return *Kind;
 return NullabilityKind

[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2017-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman reopened this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This change was reverted in r298470. The use of the  include is a 
problem because this is not a clang-supplied header file. Also, there's a 
(good) question about what array decay is happening in the `assert(false)` test 
case.


https://reviews.llvm.org/D31130



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


Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Aaron Ballman via cfe-commits
On Tue, Mar 21, 2017 at 9:15 PM, Richard Smith  wrote:
> On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Tue Mar 21 14:01:17 2017
>> New Revision: 298421
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
>> Log:
>> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
>> diagnosing array to pointer decay stemming from system macros.
>>
>> Patch by Breno Rodrigues Guimaraes.
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
>>
>> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=298421&r1=298420&r2=298421&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
>> Tue Mar 21 14:01:17 2017
>> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
>>return InnerMatcher.matches(*E, Finder, Builder);
>>  }
>>
>> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
>> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
>> +}
>> +
>> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
>> +  auto &SM = Finder->getASTContext().getSourceManager();
>> +  if (SM.isInSystemMacro(Node.getLocStart())) {
>> +if (isa(Node.getSubExpr()))
>> +  return true;
>> +
>> +if (const auto *SymbolDeclRef =
>> dyn_cast(Node.getSubExpr())) {
>> +  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
>> +  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl->getLocation()))
>> +return true;
>> +}
>> +  }
>> +  return false;
>> +}
>> +
>>  void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder
>> *Finder) {
>>if (!getLangOpts().CPlusPlus)
>>  return;
>> @@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
>>// 2) inside a range-for over an array
>>// 3) if it converts a string literal to a pointer
>>Finder->addMatcher(
>> -  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
>> +  implicitCastExpr(isArrayToPointerDecay(),
>> +   unless(hasParent(arraySubscriptExpr())),
>>
>> unless(hasParentIgnoringImpCasts(explicitCastExpr())),
>> unless(isInsideOfRangeBeginEndStmt()),
>> -   unless(hasSourceExpression(stringLiteral(
>> +   unless(hasSourceExpression(stringLiteral())),
>> +   unless(sysSymbolDecayInSysHeader()))
>>.bind("cast"),
>>this);
>>  }
>> @@ -67,8 +88,6 @@ void ProBoundsArrayToPointerDecayCheck::
>>  void ProBoundsArrayToPointerDecayCheck::check(
>>  const MatchFinder::MatchResult &Result) {
>>const auto *MatchedCast =
>> Result.Nodes.getNodeAs("cast");
>> -  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
>> -return;
>>
>>diag(MatchedCast->getExprLoc(), "do not implicitly decay an array into
>> a "
>>"pointer; consider using
>> gsl::array_view or "
>>
>> Modified:
>> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp?rev=298421&r1=298420&r2=298421&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
>> Tue Mar 21 14:01:17 2017
>> @@ -1,4 +1,5 @@
>>  // RUN: %check_clang_tidy %s
>> cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
>> +#include 
>
>
> This test is using a header that we do not supply (unlike stddef.h which
> Clang provides itself). That does not seem especially reasonable to me; this
> test is failing for us as a result. Can you supply a fake  system
> header as an input to this test?
>
>>
>>  #include 
>>
>>  namespace gsl {
>> @@ -34,6 +35,11 @@ void f() {
>>
>>for (auto &e : a) // OK, iteration internally decays array to pointer
>>  e = 1;
>> +
>> +  assert(false); // OK, array decay inside system header macro
>
>
> Huh? What decay is this referring to?

I am now wondering the same question...

I've rolled this back r298470 and will follow up with the author.

Thanks!

~Aaron

>
>> +
>> +  assert(a);
>> +  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not implicitly d

[clang-tools-extra] r298470 - Reverting r298421 due to using a header that's unavailable to all systems and some other post-commit review feedback.

2017-03-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar 21 20:08:54 2017
New Revision: 298470

URL: http://llvm.org/viewvc/llvm-project?rev=298470&view=rev
Log:
Reverting r298421 due to using a header that's unavailable to all systems and 
some other post-commit review feedback.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=298470&r1=298469&r2=298470&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 Tue Mar 21 20:08:54 2017
@@ -47,25 +47,6 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
   return InnerMatcher.matches(*E, Finder, Builder);
 }
 
-AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
-  return Node.getCastKind() == CK_ArrayToPointerDecay;
-}
-
-AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
-  auto &SM = Finder->getASTContext().getSourceManager();
-  if (SM.isInSystemMacro(Node.getLocStart())) {
-if (isa(Node.getSubExpr()))
-  return true;
-
-if (const auto *SymbolDeclRef = dyn_cast(Node.getSubExpr())) {
-  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
-  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl->getLocation()))
-return true;
-}
-  }
-  return false;
-}
-
 void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -75,12 +56,10 @@ void ProBoundsArrayToPointerDecayCheck::
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  implicitCastExpr(isArrayToPointerDecay(),
-   unless(hasParent(arraySubscriptExpr())),
+  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
unless(hasParentIgnoringImpCasts(explicitCastExpr())),
unless(isInsideOfRangeBeginEndStmt()),
-   unless(hasSourceExpression(stringLiteral())),
-   unless(sysSymbolDecayInSysHeader()))
+   unless(hasSourceExpression(stringLiteral(
   .bind("cast"),
   this);
 }
@@ -88,6 +67,8 @@ void ProBoundsArrayToPointerDecayCheck::
 void ProBoundsArrayToPointerDecayCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *MatchedCast = Result.Nodes.getNodeAs("cast");
+  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
+return;
 
   diag(MatchedCast->getExprLoc(), "do not implicitly decay an array into a "
   "pointer; consider using gsl::array_view or "

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp?rev=298470&r1=298469&r2=298470&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 Tue Mar 21 20:08:54 2017
@@ -1,5 +1,4 @@
 // RUN: %check_clang_tidy %s 
cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
-#include 
 #include 
 
 namespace gsl {
@@ -35,11 +34,6 @@ void f() {
 
   for (auto &e : a) // OK, iteration internally decays array to pointer
 e = 1;
-
-  assert(false); // OK, array decay inside system header macro
-
-  assert(a);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not implicitly decay an array 
into a pointer; consider using gsl::array_view or an explicit cast instead 
[cppcoreguidelines-pro-bounds-array-to-pointer-decay]
 }
 
 const char *g() {


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


Re: [clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Richard Smith via cfe-commits
On 21 March 2017 at 12:01, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Tue Mar 21 14:01:17 2017
> New Revision: 298421
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
> Log:
> Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from
> diagnosing array to pointer decay stemming from system macros.
>
> Patch by Breno Rodrigues Guimaraes.
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCh
> eck.cpp?rev=298421&r1=298420&r2=298421&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/
> ProBoundsArrayToPointerDecayCheck.cpp Tue Mar 21 14:01:17 2017
> @@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
>return InnerMatcher.matches(*E, Finder, Builder);
>  }
>
> +AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
> +  return Node.getCastKind() == CK_ArrayToPointerDecay;
> +}
> +
> +AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
> +  auto &SM = Finder->getASTContext().getSourceManager();
> +  if (SM.isInSystemMacro(Node.getLocStart())) {
> +if (isa(Node.getSubExpr()))
> +  return true;
> +
> +if (const auto *SymbolDeclRef = dyn_cast(Node.getSubExpr()))
> {
> +  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
> +  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl->getLocation()))
> +return true;
> +}
> +  }
> +  return false;
> +}
> +
>  void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder
> *Finder) {
>if (!getLangOpts().CPlusPlus)
>  return;
> @@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
>// 2) inside a range-for over an array
>// 3) if it converts a string literal to a pointer
>Finder->addMatcher(
> -  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
> +  implicitCastExpr(isArrayToPointerDecay(),
> +   unless(hasParent(arraySubscriptExpr())),
> unless(hasParentIgnoringImpCasts(
> explicitCastExpr())),
> unless(isInsideOfRangeBeginEndStmt()),
> -   unless(hasSourceExpression(stringLiteral(
> +   unless(hasSourceExpression(stringLiteral())),
> +   unless(sysSymbolDecayInSysHeader()))
>.bind("cast"),
>this);
>  }
> @@ -67,8 +88,6 @@ void ProBoundsArrayToPointerDecayCheck::
>  void ProBoundsArrayToPointerDecayCheck::check(
>  const MatchFinder::MatchResult &Result) {
>const auto *MatchedCast = Result.Nodes.getNodeAs<
> ImplicitCastExpr>("cast");
> -  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
> -return;
>
>diag(MatchedCast->getExprLoc(), "do not implicitly decay an array into
> a "
>"pointer; consider using
> gsl::array_view or "
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-
> array-to-pointer-decay.cpp?rev=298421&r1=298420&r2=298421&view=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-
> pro-bounds-array-to-pointer-decay.cpp Tue Mar 21 14:01:17 2017
> @@ -1,4 +1,5 @@
>  // RUN: %check_clang_tidy %s 
> cppcoreguidelines-pro-bounds-array-to-pointer-decay
> %t
> +#include 
>

This test is using a header that we do not supply (unlike stddef.h which
Clang provides itself). That does not seem especially reasonable to me;
this test is failing for us as a result. Can you supply a fake 
system header as an input to this test?


>  #include 
>
>  namespace gsl {
> @@ -34,6 +35,11 @@ void f() {
>
>for (auto &e : a) // OK, iteration internally decays array to pointer
>  e = 1;
> +
> +  assert(false); // OK, array decay inside system header macro
>

Huh? What decay is this referring to?

+
> +  assert(a);
> +  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not implicitly decay an
> array into a pointer; consider using gsl::array_view or an explicit cast
> instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
>  }
>
>  const char *g() {
>
>
> 

r298469 - Remove -ffp-contract=fast from this test

2017-03-21 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Mar 21 19:58:18 2017
New Revision: 298469

URL: http://llvm.org/viewvc/llvm-project?rev=298469&view=rev
Log:
Remove -ffp-contract=fast from this test

It does not need it and causes mismatch after -ffp-contract=fast is turned
into an FMF.

Modified:
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=298469&r1=298468&r2=298469&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Tue Mar 21 19:58:18 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
-// RUN: -fallow-half-arguments-and-returns -ffp-contract=fast -S 
-emit-llvm -o - %s \
+// RUN: -fallow-half-arguments-and-returns -S -emit-llvm -o - %s \
 // RUN: | opt -S -mem2reg \
 // RUN: | FileCheck %s
 


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


r298468 - Change -ffp-contract=fast test to run on Aarch64

2017-03-21 Thread Adam Nemet via cfe-commits
Author: anemet
Date: Tue Mar 21 19:58:15 2017
New Revision: 298468

URL: http://llvm.org/viewvc/llvm-project?rev=298468&view=rev
Log:
Change -ffp-contract=fast test to run on Aarch64

(I don't have powerpc enabled in my build and I am changing
how -ffp-contract=fast works.)

Modified:
cfe/trunk/test/CodeGen/ffp-contract-option.c

Modified: cfe/trunk/test/CodeGen/ffp-contract-option.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ffp-contract-option.c?rev=298468&r1=298467&r2=298468&view=diff
==
--- cfe/trunk/test/CodeGen/ffp-contract-option.c (original)
+++ cfe/trunk/test/CodeGen/ffp-contract-option.c Tue Mar 21 19:58:15 2017
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=powerpc-apple-darwin10 -S -o 
- %s | FileCheck %s
-// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=aarch64-apple-darwin -S -o - 
%s | FileCheck %s
+// REQUIRES: aarch64-registered-target
 
 float fma_test1(float a, float b, float c) {
-// CHECK: fmadds
+// CHECK: fmadd
   float x = a * b;
   float y = x + c;
   return y;


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


Buildbot numbers for the week of 03/12/2017 - 03/18/2017

2017-03-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 03/12/2017 -
03/18/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername | was_red
+-
 sanitizer-x86_64-linux | 61:48:26
 sanitizer-windows  | 38:12:04
 clang-cmake-mipsel | 38:03:10
 clang-x86-windows-msvc2015 | 37:58:47
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 25:00:41
 clang-cmake-aarch64-lld| 23:59:46
 clang-s390x-linux  | 23:07:48
 clang-lld-x86_64-2stage| 20:07:59
 perf-x86_64-penryn-O3  | 19:04:33
 clang-cmake-armv7-a15-selfhost-neon| 18:27:27
 llvm-clang-x86_64-expensive-checks-win | 18:14:44
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 18:14:14
 sanitizer-ppc64be-linux| 17:17:10
 clang-cmake-armv7-a15  | 16:40:31
 clang-with-thin-lto-ubuntu | 16:13:12
 sanitizer-ppc64le-linux| 15:51:09
 clang-cmake-mips   | 15:46:41
 clang-cmake-aarch64-full   | 15:39:30
 clang-with-lto-ubuntu  | 15:30:43
 clang-ppc64be-linux-lnt| 15:19:24
 perf-x86_64-penryn-O3-polly-parallel-fast  | 14:51:42
 clang-native-arm-lnt   | 14:45:39
 clang-ppc64be-linux-multistage | 14:41:51
 perf-x86_64-penryn-O3-polly-unprofitable   | 14:39:51
 clang-bpf-build| 14:33:46
 lldb-x86_64-ubuntu-14.04-buildserver   | 14:27:23
 lldb-amd64-ninja-netbsd7   | 14:26:45
 perf-x86_64-penryn-O3-polly| 14:25:25
 clang-ppc64le-linux-multistage | 14:24:48
 clang-cmake-armv7-a15-selfhost | 14:23:26
 clang-cmake-thumbv7-a15-full-sh| 14:11:28
 clang-cmake-aarch64-quick  | 14:09:20
 clang-ppc64be-linux| 14:09:05
 llvm-mips-linux| 14:07:30
 clang-cmake-armv7-a15-full | 14:07:08
 clang-x86_64-linux-selfhost-modules-2  | 14:03:30
 clang-cmake-aarch64-39vma  | 14:03:17
 clang-atom-d525-fedora-rel | 14:02:10
 sanitizer-x86_64-linux-bootstrap   | 14:01:46
 clang-cmake-aarch64-42vma  | 14:00:21
 clang-x86_64-linux-selfhost-modules| 13:59:52
 lldb-x86-windows-msvc2015  | 13:59:01
 clang-hexagon-elf  | 13:56:33
 clang-ppc64le-linux| 13:55:16
 polly-amd64-linux  | 13:52:16
 clang-ppc64le-linux-lnt| 13:49:21
 lld-x86_64-freebsd | 13:46:54
 lld-x86_64-darwin13| 13:46:18
 clang-cuda-build   | 13:44:58
 lld-x86_64-win7| 13:43:40
 clang-x86_64-linux-abi-test| 13:41:21
 llvm-hexagon-elf   | 13:41:13
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 13:41:06
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 13:39:03
 sanitizer-x86_64-linux-fast| 13:36:57
 polly-arm-linux| 13:35:42
 clang-x86_64-debian-fast   | 13:26:42
 lldb-amd64-ninja-freebsd11 | 13:20:26
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 12:49:29
 clang-cmake-thumbv7-a15 

Buildbot numbers for the week of 03/05/2017 - 03/11/2017

2017-03-21 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 03/05/2017 - 03/11/2017.

Please see the same data in attached csv files:

The longest time each builder was red during the last week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the last week:

buildername |  was_red
+--
 clang-bpf-build| 132:35:47
 clang-x86-windows-msvc2015 | 102:23:37
 clang-lld-x86_64-2stage| 80:38:29
 sanitizer-x86_64-linux-fast| 51:15:06
 clang-cmake-aarch64-lld| 50:56:29
 sanitizer-x86_64-linux-bootstrap   | 48:22:47
 clang-cmake-mipsel | 44:13:26
 clang-ppc64le-linux-multistage | 39:58:29
 lldb-x86-windows-msvc2015  | 39:52:30
 clang-ppc64le-linux| 39:11:59
 sanitizer-x86_64-linux | 36:25:13
 clang-ppc64le-linux-lnt| 36:07:38
 lldb-windows7-android  | 35:13:43
 sanitizer-ppc64le-linux| 35:08:56
 lldb-x86_64-ubuntu-14.04-android   | 32:03:01
 lldb-x86_64-darwin-13.4| 31:37:06
 lldb-x86_64-ubuntu-14.04-cmake | 31:33:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 17:53:02
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 16:39:21
 llvm-clang-x86_64-expensive-checks-win | 13:51:22
 clang-cmake-armv7-a15-selfhost-neon| 10:41:11
 clang-cmake-armv7-a15-selfhost | 10:27:10
 clang-with-thin-lto-ubuntu | 10:01:08
 perf-x86_64-penryn-O3-polly-before-vectorizer-detect-only  | 09:16:35
 sanitizer-ppc64be-linux| 08:46:00
 clang-x86_64-debian-fast   | 08:41:18
 clang-with-lto-ubuntu  | 08:20:38
 clang-cmake-mips   | 08:03:57
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast | 07:09:51
 clang-cmake-aarch64-full   | 06:30:01
 clang-3stage-ubuntu| 06:22:09
 lld-x86_64-darwin13| 05:54:50
 polly-amd64-linux  | 04:46:29
 perf-x86_64-penryn-O3-polly-parallel-fast  | 04:24:41
 clang-s390x-linux  | 04:14:21
 libcxx-libcxxabi-libunwind-aarch64-linux   | 04:10:47
 clang-x86_64-linux-selfhost-modules-2  | 04:09:15
 sanitizer-windows  | 03:51:36
 clang-cmake-thumbv7-a15-full-sh| 03:50:56
 perf-x86_64-penryn-O3-polly-unprofitable   | 03:36:02
 clang-x86_64-linux-selfhost-modules| 03:11:39
 clang-cmake-thumbv7-a15| 02:54:48
 lld-x86_64-freebsd | 02:51:07
 perf-x86_64-penryn-O3-polly-before-vectorizer-unprofitable | 02:46:45
 clang-ppc64be-linux-lnt| 02:38:54
 clang-cmake-armv7-a15  | 02:38:54
 sanitizer-x86_64-linux-fuzzer  | 02:29:45
 clang-ppc64be-linux| 02:21:44
 clang-cmake-armv7-a15-full | 01:59:38
 clang-cmake-aarch64-39vma  | 01:49:13
 clang-ppc64be-linux-multistage | 01:48:31
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   | 01:46:08
 clang-cuda-build   | 01:44:36
 clang-hexagon-elf  | 01:40:48
 clang-cmake-aarch64-quick  | 01:30:09
 lldb-amd64-ninja-netbsd7   | 01:21:06
 polly-arm-linux| 01:20:07
 clang-cmake-aarch64-42vma  | 00:59:38
 clang-atom-d525-fedora-rel | 00:57:23
 lldb-x86_64-ubuntu-14.04-

[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: test/CodeGenCXX/ubsan-global-alignment.cpp:9
+extern S1 S1_array[];
+extern S1 *S1ptr_array[];
+

Probably a good idea to also test extern globals which aren't arrays; arrays 
are sort of a special-case due to array->pointer decay.


https://reviews.llvm.org/D30283



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


[PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Zhizhou Yang via Phabricator via cfe-commits
zhizhouy added a comment.

Hi aprantl, thanks for replying. I checked the usage of DwarfDebugFlags, it 
seems that it really did the same work of recording command line options.

And I noticed that it is set to false by default. Is it because of some 
concerns like the debug info size?

Is it proper to just set it to true when -grecord-gcc-switches exists on 
whatever platform?

Thanks,
Zhizhou


https://reviews.llvm.org/D30760



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


Re: [PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Eric Christopher via cfe-commits
I think that's a good idea.

On Tue, Mar 21, 2017 at 5:19 PM Adrian Prantl via Phabricator <
revi...@reviews.llvm.org> wrote:

> aprantl added a comment.
>
> Sorry for being late to the party, but have you looked at
> CodeGenOptions::DwarfDebugFlags? It looks like it almost does what you
> want, but it is currently only enabled for MachO and when a specific
> environment variable is set. Would it make sense to generalize that
> mechanism instead?
>
>
> https://reviews.llvm.org/D30760
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30810: Preserve vec3 type.

2017-03-21 Thread JinGu Kang via Phabricator via cfe-commits
jaykang10 added a comment.

In https://reviews.llvm.org/D30810#706677, @Anastasia wrote:

> In https://reviews.llvm.org/D30810#706676, @Anastasia wrote:
>
> > In https://reviews.llvm.org/D30810#699428, @Anastasia wrote:
> >
> > > Would you be able to update ScalarExprEmitter::VisitAsTypeExpr 
> > > implementation accordingly to make things consistent?
> >
> >
> > Not sure it got lost somewhere... do you think you could address this too?
>
>
> I guess due to 4 element alignment the generated casts as vec4 should be fine 
> for vec3, but it is worth checking...


Let's look at examples.

Source code

  void kernel float4_to_float3(global float3 *a, global float4 *b) {
//float4 --> float3
*a = __builtin_astype(*b, float3);
  }
  
  void kernel float3_to_float4(global float3 *a, global float4 *b) {
//float3 --> float4
*b = __builtin_astype(*a, float4);
  }

LLVM IR

  ; Function Attrs: norecurse nounwind
  define void @float4_to_float3(<3 x float>* nocapture %a, <4 x float>* 
nocapture readonly %b) {
  entry:
%0 = load <4 x float>, <4 x float>* %b, align 16, !tbaa !6
%storetmp = bitcast <3 x float>* %a to <4 x float>*
store <4 x float> %0, <4 x float>* %storetmp, align 16, !tbaa !6
ret void
  }
  
  ; Function Attrs: norecurse nounwind
  define void @float3_to_float4(<3 x float>* nocapture readonly %a, <4 x 
float>* nocapture %b) {
  entry:
%castToVec4 = bitcast <3 x float>* %a to <4 x float>*
%loadVec4 = load <4 x float>, <4 x float>* %castToVec4, align 16
store <4 x float> %loadVec4, <4 x float>* %b, align 16, !tbaa !6
ret void
  }

We could change above IR with vec3 as following:

  ; Function Attrs: norecurse nounwinddefine void @float4_to_float3(<3 x 
float>* nocapture %a, <4 x float>* nocapture readonly %b) {
  entry:
%0 = load <4 x float>, <4 x float>* %b, align 16
%1 = shufflevector <4 x float> %0, <4 x float> undef, <3 x i32>
store <3 x float> %1, <3 x float>* %a, align 16
ret void
  }
  
  ; Function Attrs: norecurse nounwinddefine void @float3_to_float4(<3 x 
float>* nocapture readonly %a, <4 x float>* nocapture %b){
  entry:
%0 = load <3 x float>, <3 x float>* %a, align 16  %1 = shufflevector <3 x 
float> %0, <3 x float> undef, <4 x i32> 
store <4 x float> %1, <4 x float>* %b, align 16
ret void
  }

I guess it is what you want on LLVM IR. I have compiled above IRs with amdgcn 
target.

vec4 float4_to_float3 assembly code

  float4_to_float3:   ; @float4_to_float3
  ; BB#0: ; %entry
  s_load_dword s2, s[0:1], 0x9 
  s_load_dword s0, s[0:1], 0xa 
  s_mov_b32 s4, SCRATCH_RSRC_DWORD0
  s_mov_b32 s5, SCRATCH_RSRC_DWORD1
  s_mov_b32 s6, -1
  s_mov_b32 s8, s3
  s_mov_b32 s7, 0xe8f000
  s_waitcnt lgkmcnt(0)
  v_mov_b32_e32 v0, s0
  buffer_load_dword v2, v0, s[4:7], s8 offen
  buffer_load_dword v3, v0, s[4:7], s8 offen offset:4
  buffer_load_dword v4, v0, s[4:7], s8 offen offset:8
  buffer_load_dword v0, v0, s[4:7], s8 offen offset:12
  v_mov_b32_e32 v1, s2
  s_waitcnt vmcnt(0)
  buffer_store_dword v0, v1, s[4:7], s8 offen offset:12
  buffer_store_dword v4, v1, s[4:7], s8 offen offset:8
  buffer_store_dword v3, v1, s[4:7], s8 offen offset:4
  buffer_store_dword v2, v1, s[4:7], s8 offen
  s_endpgm

vec3 float4_to_float3 assembly code

  float4_to_float3:   ; @float4_to_float3
  ; BB#0: ; %entry
  s_load_dword s2, s[0:1], 0x9 
  s_load_dword s0, s[0:1], 0xa 
  s_mov_b32 s4, SCRATCH_RSRC_DWORD0
  s_mov_b32 s5, SCRATCH_RSRC_DWORD1
  s_mov_b32 s6, -1
  s_mov_b32 s8, s3
  s_mov_b32 s7, 0xe8f000
  s_waitcnt lgkmcnt(0)
  v_mov_b32_e32 v0, s0
  buffer_load_dword v2, v0, s[4:7], s8 offen
  buffer_load_dword v3, v0, s[4:7], s8 offen offset:8
  buffer_load_dword v0, v0, s[4:7], s8 offen offset:4
  v_mov_b32_e32 v1, s2
  s_waitcnt vmcnt(0)
  buffer_store_dword v0, v1, s[4:7], s8 offen offset:4
  buffer_store_dword v2, v1, s[4:7], s8 offen
  buffer_store_dword v3, v1, s[4:7], s8 offen offset:8
  s_endpgm

I think it is what we expect because there are 3 load/store for vec instead of 
4 load/store.

The float3_to_float4's output is different with float4_to_float3.

vec4 float3_to_float4 assembly code

  float3_to_float4:   ; @float3_to_float4
  ; BB#0: ; %entry
  s_load_dword s2, s[0:1], 0x9
  s_mov_b32 s4, SCRATCH_RSRC_DWORD0
  s_mov_b32 s5, SCRATCH_RSRC_DWORD1
  s_mov_b32 s6, -1
  s_mov_b32 s8, s3
  s_mov_b32 s7, 0xe8f000
  s_waitcnt lgkmcnt(0)
  v_mov_b32_e32 v0, s2
  buffer_load_dword v2, v0, s[4:7], s8 offen
  bu

r298464 - [Modules] Rebuild modules on umbrella header mismatch

2017-03-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 21 19:11:21 2017
New Revision: 298464

URL: http://llvm.org/viewvc/llvm-project?rev=298464&view=rev
Log:
[Modules] Rebuild modules on umbrella header mismatch

This restores behavior pre-r230064 since after PCMCache work (r298278)
we don't reload PCMs from disk within the same compiler invocation.

Testcases from r230064 are still left around since they still guarantee
the correct behavior we're expecting.

rdar://problem/19889777

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=298464&r1=298463&r2=298464&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Mar 21 19:11:21 2017
@@ -4890,13 +4890,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
 if (!CurrentModule->getUmbrellaHeader())
   ModMap.setUmbrellaHeader(CurrentModule, Umbrella, Blob);
 else if (CurrentModule->getUmbrellaHeader().Entry != Umbrella) {
-  // This can be a spurious difference caused by changing the VFS to
-  // point to a different copy of the file, and it is too late to
-  // to rebuild safely.
-  // FIXME: If we wrote the virtual paths instead of the 'real' paths,
-  // after input file validation only real problems would remain and we
-  // could just error. For now, assume it's okay.
-  break;
+  if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
+Error("mismatched umbrella headers in submodule");
+  return OutOfDate;
 }
   }
   break;


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


[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-03-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 92572.
vsk added a comment.

Add a test which shows that we don't regress alignment-checking when accessing 
extern variables.


https://reviews.llvm.org/D30283

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/sanitize-recover.c
  test/CodeGenCXX/ubsan-global-alignment.cpp
  test/CodeGenCXX/ubsan-suppress-checks.cpp
  test/CodeGenCXX/ubsan-suppress-null-checks.cpp
  test/CodeGenCXX/ubsan-type-checks.cpp

Index: test/CodeGenCXX/ubsan-type-checks.cpp
===
--- test/CodeGenCXX/ubsan-type-checks.cpp
+++ test/CodeGenCXX/ubsan-type-checks.cpp
@@ -5,8 +5,8 @@
 struct A {
   // COMMON-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
   void do_nothing() {
-// ALIGN-NOT: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
-// ALIGN-NOT: and i64 %{{.*}}, 7, !nosanitize
+// ALIGN: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
+// ALIGN: and i64 %{{.*}}, 0, !nosanitize
  
 // NULL: icmp ne %struct.A* %{{.*}}, null, !nosanitize
  
Index: test/CodeGenCXX/ubsan-suppress-checks.cpp
===
--- test/CodeGenCXX/ubsan-suppress-checks.cpp
+++ test/CodeGenCXX/ubsan-suppress-checks.cpp
@@ -1,24 +1,28 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null -DCHECK_LAMBDA | FileCheck %s --check-prefix=LAMBDA
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=alignment | FileCheck %s --check-prefixes=CHECK,ALIGN
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s --check-prefixes=CHECK,NULL
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=alignment,null -DCHECK_LAMBDA | FileCheck %s --check-prefixes=LAMBDA
 
 struct A {
   int foo;
 
   // CHECK-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
   void do_nothing() {
-// CHECK: icmp ne %struct.A* %[[THIS1:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS1]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// ALIGN: %[[THISINT1:[0-9]+]] = ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
+// ALIGN: and i64 %[[THISINT1]], 3, !nosanitize
+// NULL: icmp ne %struct.A* %[[THIS1:[a-z0-9]+]], null, !nosanitize
+// NULL: ptrtoint %struct.A* %[[THIS1]] to i64, !nosanitize
+// CHECK: call void @__ubsan_handle_type_mismatch
 // CHECK-NOT: call void @__ubsan_handle_type_mismatch
 // CHECK: ret void
   }
 
 #ifdef CHECK_LAMBDA
   // LAMBDA-LABEL: define linkonce_odr void @_ZN1A22do_nothing_with_lambdaEv
   void do_nothing_with_lambda() {
 // LAMBDA: icmp ne %struct.A* %[[THIS2:[a-z0-9]+]], null, !nosanitize
-// LAMBDA: ptrtoint %struct.A* %[[THIS2]] to i64, !nosanitize
-// LAMBDA-NEXT: call void @__ubsan_handle_type_mismatch
+// LAMBDA: %[[THISINT2:[0-9]+]] = ptrtoint %struct.A* %[[THIS2]] to i64, !nosanitize
+// LAMBDA: and i64 %[[THISINT2]], 3, !nosanitize
+// LAMBDA: call void @__ubsan_handle_type_mismatch
 
 auto f = [&] {
   foo = 0;
@@ -38,49 +42,59 @@
 
   // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
   int load_member() {
-// CHECK: icmp ne %struct.A* %[[THIS3:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS3]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// ALIGN: %[[THISINT3:[0-9]+]] = ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
+// ALIGN: and i64 %[[THISINT3]], 3, !nosanitize
+// NULL: icmp ne %struct.A* %[[THIS3:[a-z0-9]+]], null, !nosanitize
+// NULL: ptrtoint %struct.A* %[[THIS3]] to i64, !nosanitize
+// CHECK: call void @__ubsan_handle_type_mismatch
 // CHECK-NOT: call void @__ubsan_handle_type_mismatch
 return foo;
 // CHECK: ret i32
   }
 
   // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
   int call_method() {
-// CHECK: icmp ne %struct.A* %[[THIS4:[a-z0-9]+]], null, !nosanitize
-// CHECK: ptrtoint %struct.A* %[[THIS4]] to i64, !nosanitize
-// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// ALIGN: %[[THISINT4:[0-9]+]] = ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
+// ALIGN: and i64 %[[THISINT4]], 3, !nosanitize
+// NULL: icmp ne %struct.A* %[[THIS4:[a-z0-9]+]], null, !nosanitize
+// NULL: ptrtoint %struct.A* %[[THIS4]] to i64, !nosanitize
+// CHECK: call void @__ubsan_handle_type_mismatch
 // CHECK-NOT: call void @__ubsan_handle_type_mismatch
 return load_member();
 // CHECK: ret i32
   }
 
   // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
   void assign_member_1() {
-// CHECK: icmp ne %s

[PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Sorry for being late to the party, but have you looked at 
CodeGenOptions::DwarfDebugFlags? It looks like it almost does what you want, 
but it is currently only enabled for MachO and when a specific environment 
variable is set. Would it make sense to generalize that mechanism instead?


https://reviews.llvm.org/D30760



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


[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-03-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D30283#707007, @efriedma wrote:

> It's possible to misalign a global definition by misaligning its section with 
> a linker script... but we can probably ignore that possibility.


The current implementation does ignore this case.

> It's very easy to misalign global declaration, though; for example: [...]

Thanks for pointing this out, I hadn't thought of this case! The current patch 
does not regress UBSan checking in this area. I'll upload a new test that 
demonstrates this.


https://reviews.llvm.org/D30283



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D31210#707014, @scchan wrote:

> In https://reviews.llvm.org/D31210#706955, @yaxunl wrote:
>
> > In https://reviews.llvm.org/D31210#706890, @kzhuravl wrote:
> >
> > > In https://reviews.llvm.org/D31210#706880, @rampitec wrote:
> > >
> > > > I'm concerned about the default address space to be 64 bit. It would 
> > > > move alloca into generic address space effectively making private 
> > > > address to be 64 bit.
> > > >  This may have very undesirable performance implications, like address 
> > > > arithmetic can become expensive 64 bit and only be truncated at load or 
> > > > store.
> > > >  I realize you will use addrspacecast on an alloca's value, though I'm 
> > > > not sure that is sufficient to mitigate performance hit.
> > > >  I believe such change shall not be made without a good performance 
> > > > comparison with the feature enabled, provided the very likely 
> > > > performance issues.
> > >
> > >
> > > Did not we want to use this: 
> > > http://lists.llvm.org/pipermail/llvm-dev/2017-March/99.html and use 
> > > non-0 for our allocas?
> >
> >
> > Our final goal is to let alloca return private pointer. The Clang changes 
> > are mostly common whether alloca returns generic pointer or private 
> > pointer. Actually to be able to test the above patch we need to get the 
> > changes in Clang done first.
>
>
> The goal for this is mainly to bring the mapping closer to nvptx?


Our goal is to be able to support both OpenCL and C++-based kernel languages 
without degrading OpenCL's performance. To achieve that goal alloca returning 
private pointer may be necessary.


https://reviews.llvm.org/D31210



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


[PATCH] D30954: Modules: Simulate diagnostic settings for implicit modules

2017-03-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM

> - The patch-as-is checks whether pragmas should be demoted to warnings for 
> all AST files, not just implicit modules. I can add a bit of logic to 
> `ReadPragmaDiagnosticMappings` that limits it to `F.Kind == 
> MK_ImplicitModule`, but I'm not sure it's necessary. Maybe it hits when 
> reading PCH files, but no tests fail, and I'm not sure this is worse... 
> thoughts?

For the PCH and preamble cases, `PCHValidator` should check that the diagnostic 
mappings are the same prior to applying the diagnostic pragmas, so there should 
never be a case where a warning mapping is upgraded to error/fatal error and 
wasn't when the PCH was built (or vice versa) except when building with 
`-fno-validate-pch`. Even in that case, the emergent behavior here seems mostly 
OK (you imagine what the PCH would have looked like if it were built with the 
current compilation's warning flags), except...

If you build a PCH that contains `#pragma clang diagnostic warning "-Wfoo"` and 
then use it from a `-Werror=foo` compilation, it looks like we won't notice 
that we need to upgrade the warning to an error when replaying the PCH's pragma 
mappings. This is a corner case of a corner case, though.

> - If ReadDiagState sees a back-reference, it doesn't bother to check whether 
> pragmas should be demoted; it assumes it should match whatever was done with 
> the back-reference. I think this could be exercised with -Werror=X on the 
> command-line and pragmas modifying -WX (first "ignored", then "error", then 
> "warning"). Perhaps I should add a FIXME or a comment, but otherwise I think 
> this is okay to miss...

IIRC we only get backreferences from pragma push/pop (and `CurDiagState`), and 
I think the push/pop cases will always have the same upgrade behavior (you 
can't push inside a module and pop outside it, for instance, so the starting 
state for the push and pop should be consistent).

> It could be a back-reference to CurDiagState, which current gets 
> (de)serialized before the pragma mappings. If we instead (de)serialize 
> CurDiagState last, I think this one goes away. Is there a problem with that?

I don't think so, and putting `CurDiagState` last seems better in general (it 
keeps the states in something much more like source order). I think I only put 
it second for convenience (so I didn't need to check whether I'd just read the 
last state in order to handle it differently).




Comment at: clang/include/clang/Basic/DiagnosticIDs.h:119-120
+
+  bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
+  void setUpgradedFromWarning(bool Value) { WasUpgradedFromWarning = Value; }
+

This could do with a documentation comment. Something like "Whether this 
mapping attempted to map the diagnostic to a warning but was overruled because 
the diagnostic was already mapped to an error or fatal error."


https://reviews.llvm.org/D30954



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


[PATCH] D31168: Set FMF for -ffp-contract=fast rather than a TargetConfig

2017-03-21 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 92564.
anemet added a comment.

Address Akira's comments


https://reviews.llvm.org/D31168

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ffp-contract-fast-option.c


Index: test/CodeGen/ffp-contract-fast-option.c
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple 
-emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: @fp_contract_1(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: @fp_contract_2(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -252,12 +252,33 @@
 return Builder.CreateIsNotNull(V, "tobool");
   }
 
+  static Optional getFPFeatures(Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  /// A RAII to apply the FP features from the expression to the IRBuilder.
+  struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+ApplyFPFeatures(llvm::IRBuilderBase &Builder, Expr *E)
+: CGBuilderTy::FastMathFlagGuard(Builder) {
+  if (Optional FPFeatures = getFPFeatures(E)) {
+llvm::FastMathFlags FMF = Builder.getFastMathFlags();
+FMF.setAllowContract(FPFeatures->allowFPContractAcrossStatement());
+Builder.setFastMathFlags(FMF);
+  }
+}
+  };
+
   
//======//
   //Visitor Methods
   
//======//
 
   Value *Visit(Expr *E) {
 ApplyDebugLocation DL(CGF, E);
+ApplyFPFeatures FPF(Builder, E);
 return StmtVisitor::Visit(E);
   }
 


Index: test/CodeGen/ffp-contract-fast-option.c
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: @fp_contract_1(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: @fp_contract_2(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -252,12 +252,33 @@
 return Builder.CreateIsNotNull(V, "tobool");
   }
 
+  static Optional getFPFeatures(Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  /// A RAII to apply the FP features from the expression to the IRBuilder.
+  struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+ApplyFPFeatures(llvm::IRBuilderBase &Builder, Expr *E)
+: CGBuilderTy::FastMathFlagGuard(Builder) {
+  if (Optional FPFeatures = getFPFeatures(E)) {
+llvm::FastMathFlags FMF = Builder.getFastMathFlags();
+FMF.setAllowContract(FPFeatures->allowFPContractAcrossStatement());
+Builder.setFastMathFlags(FMF);
+  }
+}
+  };
+
   //======//
   //Visitor Methods
   //======//
 
   Value *Visit(Expr *E) {
 ApplyDebugLocation DL(CGF, E);
+ApplyFPFeatures FPF(Builder, E);
 return StmtVisitor::Visit(E);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31168: Set FMF for -ffp-contract=fast rather than a TargetConfig

2017-03-21 Thread Adam Nemet via Phabricator via cfe-commits
anemet added a comment.

Thanks, Akira.  You're right on both accounts.  I actually had a test written 
but failed to git add it.


https://reviews.llvm.org/D31168



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added a comment.

In https://reviews.llvm.org/D31210#706955, @yaxunl wrote:

> In https://reviews.llvm.org/D31210#706890, @kzhuravl wrote:
>
> > In https://reviews.llvm.org/D31210#706880, @rampitec wrote:
> >
> > > I'm concerned about the default address space to be 64 bit. It would move 
> > > alloca into generic address space effectively making private address to 
> > > be 64 bit.
> > >  This may have very undesirable performance implications, like address 
> > > arithmetic can become expensive 64 bit and only be truncated at load or 
> > > store.
> > >  I realize you will use addrspacecast on an alloca's value, though I'm 
> > > not sure that is sufficient to mitigate performance hit.
> > >  I believe such change shall not be made without a good performance 
> > > comparison with the feature enabled, provided the very likely performance 
> > > issues.
> >
> >
> > Did not we want to use this: 
> > http://lists.llvm.org/pipermail/llvm-dev/2017-March/99.html and use 
> > non-0 for our allocas?
>
>
> Our final goal is to let alloca return private pointer. The Clang changes are 
> mostly common whether alloca returns generic pointer or private pointer. 
> Actually to be able to test the above patch we need to get the changes in 
> Clang done first.


The goal for this is mainly to bring the mapping closer to nvptx?


https://reviews.llvm.org/D31210



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


[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-03-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It's possible to misalign a global definition by misaligning its section with a 
linker script... but we can probably ignore that possibility.

It's very easy to misalign global declaration, though; for example:

a.c:

  extern int a[];
  int f(int x) { return a[x]; }

b.c:

  char a[] = "asdfzxcv";


https://reviews.llvm.org/D30283



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


[PATCH] D31219: Update the SamplePGO test to verify that unroll/icp is not invoked in thinlto compile phase.

2017-03-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
Herald added a subscriber: Prazek.

This is the test added for https://reviews.llvm.org/D31217


https://reviews.llvm.org/D31219

Files:
  test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
  test/CodeGen/pgo-sample-thinlto-summary.c


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=INLINE
-// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=O2
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 
@@ -11,9 +11,30 @@
 g += baz(i);
 }
 
-// INLINE-NOT: call{{.*}}foo
-// NOINLINE: call{{.*}}foo
+// O2-LABEL: define void @bar
+// THINLTO-LABEL: define void @bar
+// O2-NOT: call{{.*}}foo
+// THINLTO: call{{.*}}foo
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
 }
+
+// O2-LABEL: define void @unroll
+// THINLTO-LABEL: define void @unroll
+// O2: call{{.*}}baz
+// O2: call{{.*}}baz
+// THINLTO: call{{.*}}baz
+// THINLTO-NOT: call{{.*}}baz
+void unroll() {
+  for (int i = 0; i < 2; i++)
+baz(i);
+}
+
+// O2-LABEL: define void @icp
+// THINLTO-LABEL: define void @icp
+// O2: if.true.direct_targ
+// ThinLTO-NOT: if.true.direct_targ
+void icp(void (*p)()) {
+  p();
+}
Index: test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
===
--- test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
+++ test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
@@ -1,2 +1,4 @@
 bar:100:100
  2: 2000 foo:2000
+icp:100:100
+ 1: 1000 unroll:1000


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- test/CodeGen/pgo-sample-thinlto-summary.c
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INLINE
-// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=O2
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=THINLTO
 // Checks if hot call is inlined by normal compile, but not inlined by
 // thinlto compile.
 
@@ -11,9 +11,30 @@
 g += baz(i);
 }
 
-// INLINE-NOT: call{{.*}}foo
-// NOINLINE: call{{.*}}foo
+// O2-LABEL: define void @bar
+// THINLTO-LABEL: define void @bar
+// O2-NOT: call{{.*}}foo
+// THINLTO: call{{.*}}foo
 void bar(int n) {
   for (int i = 0; i < n; i++)
 foo(i);
 }
+
+// O2-LABEL: define void @unroll
+// THINLTO-LABEL: define void @unroll
+// O2: call{{.*}}baz
+// O2: call{{.*}}baz
+// THINLTO: call{{.*}}baz
+// THINLTO-NOT: call{{.*}}baz
+void unroll() {
+  for (int i = 0; i < 2; i++)
+baz(i);
+}
+
+// O2-LABEL: define void @icp
+// THINLTO-LABEL: define void @icp
+// O2: if.true.direct_targ
+// ThinLTO-NOT: if.true.direct_targ
+void icp(void (*p)()) {
+  p();
+}
Index: test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
===
--- test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
+++ test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
@@ -1,2 +1,4 @@
 bar:100:100
  2: 2000 foo:2000
+icp:100:100
+ 1: 1000 unroll:1000
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30283: [ubsan] Reduce alignment checking of C++ object pointers

2017-03-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Hi Eli, thanks for your feedback :).

In https://reviews.llvm.org/D30283#702085, @efriedma wrote:

> I'm not sure we actually want to skip these checks for DeclRefExps.  I mean, 
> you can rely on the backend to correctly align a local variable (assuming the 
> stack is correctly aligned), but it's very easy to misalign a global.


I did some experimenting, and think that we can safely skip the alignment check 
for DeclRefExps. Here is what I found:

1. It seems hard to declare a misaligned global. I could not come up with an 
example where this happens. FWIW, I tried playing tricks with the linker but it 
refused to do the wrong thing (`-Wl,-sectalign,__DATA,__common,1` ; 
`-Wl,-order_file,insert_pad_byte_to_misalign_global.order_file`).
2. It's easy to declare a global pointer or reference to misaligned data. UBSan 
already misses this bug: this patch doesn't affect the situation (I filed 
llvm.org/PR32364 to track the issue).

When you said "it's very easy to misalign a global", did you mean that it's 
easy for the compiler to mess up? If so, my thinking is that we should write 
better verifiers, either in our linkers or in LLVM proper. UBSan shouldn't be 
used as a compiler verifier: if it is, end-users will find its diagnostics to 
be less actionable. We shouldn't break user bots because of compiler bugs.

If, OTOH, you meant that it's easy for users to declare misaligned globals, I'd 
appreciate an example.


https://reviews.llvm.org/D30283



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


[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-03-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D30415#706370, @sfertile wrote:

> > I have a patch to do this now. I'll plan on committing it in a bit.
>
> Is there a way to mark the -f form of the option as deprecated? We should 
> warn and suggest users switch to the -maltivec option for a release to give 
> people a chance to update their builds.


I've added something and committed all of my work here:

echristo@athyra ~/s/l/t/clang> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/cfe/trunk ...
A   test/Driver/unsupported-faltivec.c
M   docs/ClangCommandLineReference.rst
M   docs/LanguageExtensions.rst
M   include/clang/Basic/DiagnosticDriverKinds.td
M   include/clang/Driver/Options.td
M   lib/Basic/Targets.cpp
M   lib/Driver/ToolChains/Arch/PPC.cpp
M   lib/Driver/ToolChains/Clang.cpp
M   lib/Frontend/CompilerInstance.cpp
M   lib/Frontend/CompilerInvocation.cpp
M   test/CodeGen/altivec.c
M   test/CodeGen/builtins-ppc-altivec.c
M   test/CodeGen/builtins-ppc-crypto-disabled.c
M   test/CodeGen/builtins-ppc-crypto.c
M   test/CodeGen/builtins-ppc-error.c
M   test/CodeGen/builtins-ppc-htm.c
M   test/CodeGen/builtins-ppc-p8vector.c
M   test/CodeGen/builtins-ppc-p9vector.c
M   test/CodeGen/builtins-ppc-quadword.c
M   test/CodeGen/builtins-ppc-vsx.c
M   test/CodeGen/ppc64-align-struct.c
M   test/CodeGen/ppc64-vector.c
M   test/CodeGen/ppc64le-aggregates.c
M   test/Driver/ppc-features.cpp
M   test/Headers/altivec-header.c
M   test/Headers/altivec-intrin.c
M   test/Parser/altivec-csk-bool.c
M   test/Parser/altivec.c
M   test/Parser/cxx-altivec.cpp
M   test/Parser/vsx.c
M   test/Sema/altivec-init.c
M   test/Sema/builtins-ppc.c
M   test/SemaCXX/altivec.cpp
M   test/SemaCXX/cxx-altivec.cpp
Committed r298449


https://reviews.llvm.org/D30415



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


r298449 - Remove the -faltivec alias option and replace it with -maltivec everywhere.

2017-03-21 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Mar 21 17:06:18 2017
New Revision: 298449

URL: http://llvm.org/viewvc/llvm-project?rev=298449&view=rev
Log:
Remove the -faltivec alias option and replace it with -maltivec everywhere.
The alias was only ever used on darwin and had some issues there,
and isn't used in practice much. Also fixes a problem with -mno-altivec
not turning off -maltivec.

Also add a diagnostic for faltivec/fno-altivec that directs users to use
maltivec options and include the altivec.h file explicitly.

Added:
cfe/trunk/test/Driver/unsupported-faltivec.c
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-crypto-disabled.c
cfe/trunk/test/CodeGen/builtins-ppc-crypto.c
cfe/trunk/test/CodeGen/builtins-ppc-error.c
cfe/trunk/test/CodeGen/builtins-ppc-htm.c
cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c
cfe/trunk/test/CodeGen/builtins-ppc-p9vector.c
cfe/trunk/test/CodeGen/builtins-ppc-quadword.c
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
cfe/trunk/test/CodeGen/ppc64-align-struct.c
cfe/trunk/test/CodeGen/ppc64-vector.c
cfe/trunk/test/CodeGen/ppc64le-aggregates.c
cfe/trunk/test/Driver/ppc-features.cpp
cfe/trunk/test/Headers/altivec-header.c
cfe/trunk/test/Headers/altivec-intrin.c
cfe/trunk/test/Parser/altivec-csk-bool.c
cfe/trunk/test/Parser/altivec.c
cfe/trunk/test/Parser/cxx-altivec.cpp
cfe/trunk/test/Parser/vsx.c
cfe/trunk/test/Sema/altivec-init.c
cfe/trunk/test/Sema/builtins-ppc.c
cfe/trunk/test/SemaCXX/altivec.cpp
cfe/trunk/test/SemaCXX/cxx-altivec.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=298449&r1=298448&r2=298449&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Mar 21 17:06:18 2017
@@ -1053,7 +1053,7 @@ Enable C++17 aligned allocation function
 
 .. option:: -fallow-unsupported
 
-.. option:: -faltivec, -fno-altivec, -maltivec
+.. option:: -maltivec, -mno-altivec
 
 Enable AltiVec vector initializer syntax
 

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=298449&r1=298448&r2=298449&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Mar 21 17:06:18 2017
@@ -356,7 +356,7 @@ is:
 
 Query for this feature with ``__has_extension(attribute_ext_vector_type)``.
 
-Giving ``-faltivec`` option to clang enables support for AltiVec vector syntax
+Giving ``-maltivec`` option to clang enables support for AltiVec vector syntax
 and functions.  For example:
 
 .. code-block:: c++

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=298449&r1=298448&r2=298449&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar 21 17:06:18 
2017
@@ -85,6 +85,8 @@ def err_drv_clang_unsupported : Error<
   "the clang compiler does not support '%0'">;
 def err_drv_clang_unsupported_opt_cxx_darwin_i386 : Error<
   "the clang compiler does not support '%0' for C++ on Darwin/i386">;
+def err_drv_clang_unsupported_opt_faltivec : Error<
+  "the clang compiler does not support '%0', %1">;
 def err_drv_command_failed : Error<
   "%0 command failed with exit code %1 (use -v to see invocation)">;
 def err_drv_compilationdatabase : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=298449&r1=298448&r2=298449&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 21 17:06:18 2017
@@ -1782,6 +1782,10 @@ def mamdgpu_debugger_abi : Joined<["-"],
   HelpText<"Generate additional code for specified  of debugger ABI 
(AMDGPU only)">,
   MetaVarName<"">;
 
+def faltivec : Flag<["-"], "faltivec">, Group, Flags<[DriverOption]>;
+def fno_altivec : Flag<["-"], "fno-altivec">, Group,

[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D31210#706890, @kzhuravl wrote:

> In https://reviews.llvm.org/D31210#706880, @rampitec wrote:
>
> > I'm concerned about the default address space to be 64 bit. It would move 
> > alloca into generic address space effectively making private address to be 
> > 64 bit.
> >  This may have very undesirable performance implications, like address 
> > arithmetic can become expensive 64 bit and only be truncated at load or 
> > store.
> >  I realize you will use addrspacecast on an alloca's value, though I'm not 
> > sure that is sufficient to mitigate performance hit.
> >  I believe such change shall not be made without a good performance 
> > comparison with the feature enabled, provided the very likely performance 
> > issues.
>
>
> Did not we want to use this: 
> http://lists.llvm.org/pipermail/llvm-dev/2017-March/99.html and use non-0 
> for our allocas?


Our final goal is to let alloca return private pointer. The Clang changes are 
mostly common whether alloca returns generic pointer or private pointer. 
Actually to be able to test the above patch we need to get the changes in Clang 
done first.


https://reviews.llvm.org/D31210



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


r298446 - Add support for -fno-auto-profile and -fno-profile-sample-use

2017-03-21 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Mar 21 16:40:53 2017
New Revision: 298446

URL: http://llvm.org/viewvc/llvm-project?rev=298446&view=rev
Log:
Add support for -fno-auto-profile and -fno-profile-sample-use

Summary: We need to be able to disable samplepgo for specific files by 
supporting -fno-auto-profile and -fno-profile-sample-use

Reviewers: davidxl, dnovillo, echristo

Reviewed By: echristo

Subscribers: echristo, cfe-commits

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=298446&r1=298445&r2=298446&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 21 16:40:53 2017
@@ -613,9 +613,17 @@ def fno_gnu_inline_asm : Flag<["-"], "fn
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable GNU style inline asm">;
 
+def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
+Flags<[CoreOption]>;
+def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, 
Group,
+Flags<[CoreOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fauto_profile : Flag<["-"], "fauto-profile">, Group,
+Alias;
+def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group,
+Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=298446&r1=298445&r2=298446&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Mar 21 16:40:53 2017
@@ -3431,7 +3431,7 @@ void Clang::ConstructJob(Compilation &C,
 
   // Forward -f options with positive and negative forms; we translate
   // these by hand.
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef fname = A->getValue();
 if (!llvm::sys::fs::exists(fname))
   D.Diag(diag::err_drv_no_such_file) << fname;

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=298446&r1=298445&r2=298446&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Mar 21 16:40:53 2017
@@ -407,7 +407,7 @@ void tools::AddGoldPlugin(const ToolChai
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
   D.Diag(diag::err_drv_no_such_file) << FName;
@@ -673,6 +673,22 @@ Arg *tools::getLastProfileUseArg(const A
   return ProfileUseArg;
 }
 
+Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) {
+  auto *ProfileSampleUseArg = Args.getLastArg(
+  options::OPT_fprofile_sample_use, options::OPT_fprofile_sample_use_EQ,
+  options::OPT_fauto_profile, options::OPT_fauto_profile_EQ,
+  options::OPT_fno_profile_sample_use, options::OPT_fno_auto_profile);
+
+  if (ProfileSampleUseArg &&
+  (ProfileSampleUseArg->getOption().matches(
+   options::OPT_fno_profile_sample_use) ||
+   
ProfileSampleUseArg->getOption().matches(options::OPT_fno_auto_profile)))
+return nullptr;
+
+  return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
+ options::OPT_fauto_profile_EQ);
+}
+
 /// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments.  Then,
 /// smooshes them together with platform defaults, to decide whether
 /// this compile should be using PIC mode or not. Returns a tuple of

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.h?rev=298446&r1=298445&r2=298446&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.h Tue Mar 21 16:40:53 2017
@@ -63,6 +63,7 @@ void addOpenMPRuntime(llvm::opt::ArgStri
   const llvm::o

[PATCH] D31213: Add support for -fno-auto-profile and -fno-profile-sample-use

2017-03-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

-eric


https://reviews.llvm.org/D31213



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


[PATCH] D31213: Add support for -fno-auto-profile and -fno-profile-sample-use

2017-03-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 92554.
danielcdh added a comment.

add more test


https://reviews.llvm.org/D31213

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -59,6 +59,13 @@
 // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
 // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s
+// CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof"
+
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use -fauto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile -fprofile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s
+
 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
 // RUN: %clang -### -S -fno-profile-arcs -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s
 // RUN: %clang -### -S -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s
Index: lib/Driver/ToolChains/CommonArgs.h
===
--- lib/Driver/ToolChains/CommonArgs.h
+++ lib/Driver/ToolChains/CommonArgs.h
@@ -63,6 +63,7 @@
   const llvm::opt::ArgList &Args);
 
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
+llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 
 bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
 
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -407,7 +407,7 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
   D.Diag(diag::err_drv_no_such_file) << FName;
@@ -673,6 +673,22 @@
   return ProfileUseArg;
 }
 
+Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) {
+  auto *ProfileSampleUseArg = Args.getLastArg(
+  options::OPT_fprofile_sample_use, options::OPT_fprofile_sample_use_EQ,
+  options::OPT_fauto_profile, options::OPT_fauto_profile_EQ,
+  options::OPT_fno_profile_sample_use, options::OPT_fno_auto_profile);
+
+  if (ProfileSampleUseArg &&
+  (ProfileSampleUseArg->getOption().matches(
+   options::OPT_fno_profile_sample_use) ||
+   ProfileSampleUseArg->getOption().matches(options::OPT_fno_auto_profile)))
+return nullptr;
+
+  return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
+ options::OPT_fauto_profile_EQ);
+}
+
 /// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments.  Then,
 /// smooshes them together with platform defaults, to decide whether
 /// this compile should be using PIC mode or not. Returns a tuple of
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3431,7 +3431,7 @@
 
   // Forward -f options with positive and negative forms; we translate
   // these by hand.
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef fname = A->getValue();
 if (!llvm::sys::fs::exists(fname))
   D.Diag(diag::err_drv_no_such_file) << fname;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -613,9 +613,17 @@
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable GNU style inline asm">;
 
+def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
+Flags<[CoreOption]>;
+def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, Group,
+Flags<[CoreOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fauto_profile : Flag<["-"], "fauto-profile">, Group,
+Alias;
+def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group,
+Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto

r298443 - Apply clang-tidy's performance-unnecessary-value-param to parts of clang.

2017-03-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Mar 21 16:35:04 2017
New Revision: 298443

URL: http://llvm.org/viewvc/llvm-project?rev=298443&view=rev
Log:
Apply clang-tidy's performance-unnecessary-value-param to parts of clang.

No functionality change intended.

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/GeneratePCH.cpp
cfe/trunk/lib/Tooling/Refactoring.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=298443&r1=298442&r2=298443&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Mar 21 16:35:04 2017
@@ -99,7 +99,9 @@ private:
   mutable llvm::Triple EffectiveTriple;
 
   /// Set the toolchain's effective clang triple.
-  void setEffectiveTriple(llvm::Triple ET) const { EffectiveTriple = ET; }
+  void setEffectiveTriple(llvm::Triple ET) const {
+EffectiveTriple = std::move(ET);
+  }
 
   friend class RegisterEffectiveTriple;
 
@@ -476,7 +478,7 @@ class RegisterEffectiveTriple {
 
 public:
   RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
-TC.setEffectiveTriple(T);
+TC.setEffectiveTriple(std::move(T));
   }
 
   ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=298443&r1=298442&r2=298443&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Mar 21 16:35:04 2017
@@ -1585,7 +1585,7 @@ public:
   const LangOptions &LangOpts,
   const TargetOptions &TargetOpts,
   const PreprocessorOptions &PPOpts,
-  std::string ExistingModuleCachePath);
+  StringRef ExistingModuleCachePath);
 
   /// \brief Returns the suggested contents of the predefines buffer,
   /// which contains a (typically-empty) subset of the predefines

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=298443&r1=298442&r2=298443&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Mar 21 16:35:04 2017
@@ -350,7 +350,8 @@ namespace {
   MostDerivedArraySize = 2;
   MostDerivedPathLength = Entries.size();
 }
-void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E, APSInt N);
+void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
+   const APSInt &N);
 /// Add N to the address of this subobject.
 void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N) {
   if (Invalid || !N) return;
@@ -1071,7 +1072,8 @@ bool SubobjectDesignator::checkSubobject
 }
 
 void SubobjectDesignator::diagnosePointerArithmetic(EvalInfo &Info,
-const Expr *E, APSInt N) {
+const Expr *E,
+const APSInt &N) {
   // If we're complaining, we must be able to statically determine the size of
   // the most derived array.
   if (MostDerivedPathLength == Entries.size() && MostDerivedIsArrayElement)
@@ -1296,8 +1298,8 @@ namespace {
 void clearIsNullPointer() {
   IsNullPtr = false;
 }
-void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E, APSInt Index,
-  CharUnits ElementSize) {
+void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E,
+  const APSInt &Index, CharUnits ElementSize) {
   // An index of 0 has no effect. (In C, adding 0 to a null pointer is UB,
   // but we're not required to diagnose it and it's valid in C++.)
   if (!Index)
@@ -8072,7 +8074,8 @@ bool DataRecursiveIntBinOpEvaluator::
   return true;
 }
 
-static void addOrSubLValueAsInteger(APValue &LVal, APSInt Index, bool IsSub) {
+static void addOrSubLValueAsInteger(APValue &LVal, const APSInt &Index,
+bool IsSub) {
   // Compute the new offset in the appropriate width, wrapping at 64 bits.
   // FIXME: When compiling for a 32-bit target, we should use 32-bit
   // offsets.

Modified: cfe/trunk/lib/Basic/

[clang-tools-extra] r298442 - Apply clang-tidy's performance-unnecessary-value-param to clang-tidy.

2017-03-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Mar 21 16:34:58 2017
New Revision: 298442

URL: http://llvm.org/viewvc/llvm-project?rev=298442&view=rev
Log:
Apply clang-tidy's performance-unnecessary-value-param to clang-tidy.

No functionality change intended.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h?rev=298442&r1=298441&r2=298442&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
 Tue Mar 21 16:34:58 2017
@@ -91,7 +91,7 @@ struct DenseMapInfo<
 return Val.first.getRawEncoding() + SecondHash(Val.second);
   }
 
-  static bool isEqual(ClassDefId LHS, ClassDefId RHS) {
+  static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) {
 if (RHS == getEmptyKey())
   return LHS == getEmptyKey();
 if (RHS == getTombstoneKey())

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=298442&r1=298441&r2=298442&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Tue Mar 21 
16:34:58 2017
@@ -352,9 +352,9 @@ void UseAutoCheck::replaceIterators(cons
   << FixItHint::CreateReplacement(Range, "auto");
 }
 
-void UseAutoCheck::replaceExpr(const DeclStmt *D, ASTContext *Context,
-   std::function GetType,
-   StringRef Message) {
+void UseAutoCheck::replaceExpr(
+const DeclStmt *D, ASTContext *Context,
+llvm::function_ref GetType, StringRef Message) {
   const auto *FirstDecl = dyn_cast(*D->decl_begin());
   // Ensure that there is at least one VarDecl within the DeclStmt.
   if (!FirstDecl)

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h?rev=298442&r1=298441&r2=298442&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.h Tue Mar 21 
16:34:58 2017
@@ -26,7 +26,7 @@ public:
 private:
   void replaceIterators(const DeclStmt *D, ASTContext *Context);
   void replaceExpr(const DeclStmt *D, ASTContext *Context,
-   std::function GetType,
+   llvm::function_ref GetType,
StringRef Message);
 
   const bool RemoveStars;

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=298442&r1=298441&r2=298442&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Tue Mar 21 16:34:58 2017
@@ -49,7 +49,7 @@ struct DenseMapInfo<
 return Val.first.getRawEncoding() + SecondHash(Val.second);
   }
 
-  static bool isEqual(NamingCheckId LHS, NamingCheckId RHS) {
+  static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
 if (RHS == getEmptyKey())
   return LHS == getEmptyKey();
 if (RHS == getTombstoneKey())


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


Re: r298392 - [index/AST] Determine if a typedef shares a name and spelling location with its underlying tag type

2017-03-21 Thread Argyrios Kyrtzidis via cfe-commits
Fixed in r298441, thanks!

> On Mar 21, 2017, at 2:05 PM, Vitaly Buka  wrote:
> 
> Could you please take a look at these leaks
> 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3606/steps/check-clang%20asan/logs/stdio
>  
> 
> 
> 
> =
> ==32547==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 24 byte(s) in 1 object(s) allocated from:
> #0 0x57a9a8 in __interceptor_malloc 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64
> #1 0x7f0c8c1de918 in clang::cxstring::createDup(llvm::StringRef) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CXString.cpp:99:40
> #2 0x7f0c8c1e1120 in clang_getTypeSpelling 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CXType.cpp:273:10
> #3 0x5b5a53 in PrintCursor 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:718:24
> #4 0x5b4dc5 in FilteredPrintingVisitor 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1116:5
> #5 0x7f0c8c115829 in clang::cxcursor::CursorVisitor::Visit(CXCursor, 
> bool) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:209:11
> #6 0x7f0c8c11d451 in 
> clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:666:7
> #7 0x7f0c8c11d9fb in 
> clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:627:30
> #8 0x7f0c8c116ecf in 
> clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:532:20
> #9 0x7f0c8c149ad6 in clang_visitChildren 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4172:20
> #10 0x5b8628 in perform_test_load 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1601:5
> #11 0x5b8d4f in perform_test_load_source 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1697:12
> #12 0x5c0e76 in cindextest_main 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:4373:14
> #13 0x5c5a1d in thread_runner 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c::25
> #14 0x7f0c90a47daf in ExecuteOnThread_Dispatch(void*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/Unix/Threading.inc:53:3
> #15 0x7f0c8919b6b9 in start_thread 
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
> 
> SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).
> 
> --
> 
> 
> On Tue, Mar 21, 2017 at 10:08 AM Argyrios Kyrtzidis via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: akirtzidis
> Date: Tue Mar 21 11:56:02 2017
> New Revision: 298392
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298392&view=rev 
> 
> Log:
> [index/AST] Determine if a typedef shares a name and spelling location with 
> its underlying tag type
> 
> In such a case, as when using the NS_ENUM macro, for indexing purposes treat 
> the typedef as 'transparent',
> meaning we treat its references as symbols of the underlying tag symbol.
> Also provide a libclang API to check for such typedefs.
> 
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/Index/IndexDecl.cpp
> cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
> cfe/trunk/test/Index/Core/index-source.m
> cfe/trunk/test/Index/get-cursor.m
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CXType.cpp
> cfe/trunk/tools/libclang/libclang.exports
> 
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=298392&r1=298391&r2=298392&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Tue Mar 21 11:56:02 2017
> @@ -3437,6 +3

[PATCH] D31213: Add support for -fno-auto-profile and -fno-profile-sample-use

2017-03-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Can you add a test for fno-auto-profile?


https://reviews.llvm.org/D31213



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


r298441 - [c-index-test] Fix memory leak in c-index-test tool.

2017-03-21 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Mar 21 16:34:05 2017
New Revision: 298441

URL: http://llvm.org/viewvc/llvm-project?rev=298441&view=rev
Log:
[c-index-test] Fix memory leak in c-index-test tool.

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

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=298441&r1=298440&r2=298441&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Mar 21 16:34:05 2017
@@ -717,6 +717,7 @@ static void PrintCursor(CXCursor Cursor,
   CXType Underlying = clang_getTypedefDeclUnderlyingType(Referenced);
   CXString S = clang_getTypeSpelling(Underlying);
   printf(" (Transparent: %s)", clang_getCString(S));
+  clang_disposeString(S);
 }
   }
 }


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


[PATCH] D31213: Add support for -fno-auto-profile and -fno-profile-sample-use

2017-03-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.

We need to be able to disable samplepgo for specific files by supporting 
-fno-auto-profile and -fno-profile-sample-use


https://reviews.llvm.org/D31213

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -59,6 +59,11 @@
 // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck 
-check-prefix=CHECK-AUTO-PROFILE %s
 // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof 
-fno-profile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE 
%s
+// CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof"
+
+// RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof 
-fno-profile-sample-use -fauto-profile %s 2>&1 | FileCheck 
-check-prefix=CHECK-AUTO-PROFILE %s
+
 // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-ARCS %s
 // RUN: %clang -### -S -fno-profile-arcs -fprofile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-ARCS %s
 // RUN: %clang -### -S -fno-profile-arcs %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-PROFILE-ARCS %s
Index: lib/Driver/ToolChains/CommonArgs.h
===
--- lib/Driver/ToolChains/CommonArgs.h
+++ lib/Driver/ToolChains/CommonArgs.h
@@ -63,6 +63,7 @@
   const llvm::opt::ArgList &Args);
 
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
+llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 
 bool isObjCAutoRefCount(const llvm::opt::ArgList &Args);
 
Index: lib/Driver/ToolChains/CommonArgs.cpp
===
--- lib/Driver/ToolChains/CommonArgs.cpp
+++ lib/Driver/ToolChains/CommonArgs.cpp
@@ -407,7 +407,7 @@
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef FName = A->getValue();
 if (!llvm::sys::fs::exists(FName))
   D.Diag(diag::err_drv_no_such_file) << FName;
@@ -673,6 +673,22 @@
   return ProfileUseArg;
 }
 
+Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) {
+  auto *ProfileSampleUseArg = Args.getLastArg(
+  options::OPT_fprofile_sample_use, options::OPT_fprofile_sample_use_EQ,
+  options::OPT_fauto_profile, options::OPT_fauto_profile_EQ,
+  options::OPT_fno_profile_sample_use, options::OPT_fno_auto_profile);
+
+  if (ProfileSampleUseArg &&
+  (ProfileSampleUseArg->getOption().matches(
+   options::OPT_fno_profile_sample_use) ||
+   
ProfileSampleUseArg->getOption().matches(options::OPT_fno_auto_profile)))
+return nullptr;
+
+  return Args.getLastArg(options::OPT_fprofile_sample_use_EQ,
+ options::OPT_fauto_profile_EQ);
+}
+
 /// Parses the various -fpic/-fPIC/-fpie/-fPIE arguments.  Then,
 /// smooshes them together with platform defaults, to decide whether
 /// this compile should be using PIC mode or not. Returns a tuple of
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3431,7 +3431,7 @@
 
   // Forward -f options with positive and negative forms; we translate
   // these by hand.
-  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+  if (Arg *A = getLastProfileSampleUseArg(Args)) {
 StringRef fname = A->getValue();
 if (!llvm::sys::fs::exists(fname))
   D.Diag(diag::err_drv_no_such_file) << fname;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -613,9 +613,17 @@
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable GNU style inline asm">;
 
+def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group,
+Flags<[CoreOption]>;
+def fno_profile_sample_use : Flag<["-"], "fno-profile-sample-use">, 
Group,
+Flags<[CoreOption]>;
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fauto_profile : Flag<["-"], "fauto-profile">, Group,
+Alias;
+def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group,
+Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,


Index: test/Driver/clang_f_opts.c
===
--

[PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo requested changes to this revision.
echristo added a comment.
This revision now requires changes to proceed.

Why aren't we passing the flags down as a string in the IR?

Needs a testcase: you should only check for IR in clang tests. To make sure 
something is propagated to the other end use an IR test and then use 
llvm-dwarfdump to inspect as an llvm test.

-eric


https://reviews.llvm.org/D30760



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

In https://reviews.llvm.org/D31210#706880, @rampitec wrote:

> I'm concerned about the default address space to be 64 bit. It would move 
> alloca into generic address space effectively making private address to be 64 
> bit.
>  This may have very undesirable performance implications, like address 
> arithmetic can become expensive 64 bit and only be truncated at load or store.
>  I realize you will use addrspacecast on an alloca's value, though I'm not 
> sure that is sufficient to mitigate performance hit.
>  I believe such change shall not be made without a good performance 
> comparison with the feature enabled, provided the very likely performance 
> issues.


Did not we want to use this: 
http://lists.llvm.org/pipermail/llvm-dev/2017-March/99.html and use non-0 
for our allocas?


https://reviews.llvm.org/D31210



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


[PATCH] D30760: Record command lines in objects built by clang

2017-03-21 Thread Zhizhou Yang via Phabricator via cfe-commits
zhizhouy updated this revision to Diff 92546.
zhizhouy marked 3 inline comments as done.
zhizhouy edited the summary of this revision.
zhizhouy added a reviewer: dblaikie.
zhizhouy added a comment.
Herald added a subscriber: mehdi_amini.

Fixed George's comments.

Still need to create a test for this diff.


https://reviews.llvm.org/D30760

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -529,6 +529,7 @@
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
   Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.RecordCmdOpts = Args.getLastArgValue(OPT_record_cmd_opts_EQ);
   Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
   Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2720,7 +2720,16 @@
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();
   }
 
-  // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
+  // Use -grecord-gcc-switches to record command line options from Driver.
+  if (Args.hasArg(options::OPT_grecord_gcc_switches)) {
+SmallString<256> CmdLineOpts("-record-cmd-opts=");
+for (const auto *Arg : Args)
+  CmdLineOpts += Arg->getAsString(Args) + " ";
+CmdLineOpts.pop_back();
+CmdArgs.push_back(Args.MakeArgStringRef(CmdLineOpts));
+  }
+
+  // We ignore flags -gstrict-dwarf for now.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
   // Column info is included by default for everything except PS4 and CodeView.
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -503,7 +503,10 @@
 LangTag = llvm::dwarf::DW_LANG_C89;
   }
 
+  // Producer records current clang version and the command line options from
+  // Driver.
   std::string Producer = getClangFullVersion();
+  Producer += " " + CGM.getCodeGenOpts().RecordCmdOpts;
 
   // Figure out which version of the ObjC runtime we have.
   unsigned RuntimeVers = 0;
Index: include/clang/Frontend/CodeGenOptions.h
===
--- include/clang/Frontend/CodeGenOptions.h
+++ include/clang/Frontend/CodeGenOptions.h
@@ -119,6 +119,9 @@
   /// non-empty.
   std::string DwarfDebugFlags;
 
+  /// The string of command line options from Driver.
+  std::string RecordCmdOpts;
+
   std::map DebugPrefixMap;
 
   /// The ABI to use for passing floating point arguments.
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -144,6 +144,7 @@
   HelpText<"The compilation directory to embed in the debug info.">;
 def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
   HelpText<"The string to embed in the Dwarf debug flags record.">;
+def record_cmd_opts_EQ : Joined<["-"], "record-cmd-opts=">;
 def mno_exec_stack : Flag<["-"], "mnoexecstack">,
   HelpText<"Mark the file as not needing an executable stack">;
 def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -529,6 +529,7 @@
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
   Opts.StructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.RecordCmdOpts = Args.getLastArgValue(OPT_record_cmd_opts_EQ);
   Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
   Opts.NoImplicitFloat = Args.hasArg(OPT_no_implicit_float);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2720,7 +2720,16 @@
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();
   }
 
-  // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
+  // Use -grecord-gcc-switches to record command line options from Driver.
+  if (Args.hasArg(options::OPT_grecord_gcc_switches)) {
+SmallString<256> CmdLineOpts("-record-cmd-opts=");
+for (const auto *Arg : Args)
+  CmdLineOpts += Arg->getAsString(Args) + " ";

[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added a comment.

I'm concerned about the default address space to be 64 bit. It would move 
alloca into generic address space effectively making private address to be 64 
bit.
This may have very undesirable performance implications, like address 
arithmetic can become expensive 64 bit and only be truncated at load or store.
I realize you will use addrspacecast on an alloca's value, though I'm not sure 
that is sufficient to mitigate performance hit.
I believe such change shall not be made without a good performance comparison 
with the feature enabled, provided the very likely performance issues.


https://reviews.llvm.org/D31210



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

getDWARFAddressSpace also needs to be updated.


https://reviews.llvm.org/D31210



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


[PATCH] D31210: [AMDGPU] Add new address space mapping

2017-03-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
Herald added subscribers: Anastasia, tpr, dstuttard, nhaehnle, wdng, kzhuravl.

A new target feature new-addr is added. When it is on, AMDGPU uses new address 
space mapping where generic address space is 0 and private address space is 5. 
The data layout is also changed correspondingly. By default this feature is off.

This is the beginning of an upstreaming effort for changing address space 
mapping of AMDGPU target. Sema/CodeGen changes to make OpenCL/C++ working with 
the new address space mapping will follow.


https://reviews.llvm.org/D31210

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/amdgpu-new-addr.cl

Index: test/CodeGenOpenCL/amdgpu-new-addr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-new-addr.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -triple amdgcn -target-feature "+new-addr" -emit-llvm -o - | FileCheck -check-prefix=NEW %s
+
+// CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+// NEW: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
+void foo(void) {}
+
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1997,16 +1997,6 @@
   return llvm::makeArrayRef(GCCRegNames);
 }
 
-static const unsigned AMDGPUAddrSpaceMap[] = {
-  1,// opencl_global
-  3,// opencl_local
-  2,// opencl_constant
-  4,// opencl_generic
-  1,// cuda_device
-  2,// cuda_constant
-  3 // cuda_shared
-};
-
 // If you edit the description strings, make sure you update
 // getPointerWidthV().
 
@@ -2014,15 +2004,65 @@
   "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
-static const char *const DataLayoutStringSI =
+static const char *const DataLayoutStringSIOld =
   "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
   "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
+static const char *const DataLayoutStringSINew =
+  "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
+  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
+  "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
+
 class AMDGPUTargetInfo final : public TargetInfo {
   static const Builtin::Info BuiltinInfo[];
   static const char * const GCCRegNames[];
 
+  struct AddrSpace {
+unsigned Generic, Global, Local, Constant, Private;
+bool UseNew;
+AddrSpace(bool UseNew_ = false){
+  reset(UseNew_);
+}
+void reset(bool UseNew_) {
+  UseNew = UseNew_;
+  if (UseNew) {
+Generic   = 0;
+Global= 1;
+Local = 3;
+Constant  = 4;
+Private   = 5;
+  } else {
+Generic   = 4;
+Global= 1;
+Local = 3;
+Constant  = 2;
+Private   = 0;
+  }
+}
+const LangAS::Map *getMap() {
+  static LangAS::Map OldMap = {
+  1,  // opencl_global
+  3,  // opencl_local
+  2,  // opencl_constant
+  4,  // opencl_generic
+  1,  // cuda_device
+  2,  // cuda_constant
+  3   // cuda_shared
+  };
+  static LangAS::Map NewMap = {
+  1,  // opencl_global
+  3,  // opencl_local
+  4,  // opencl_constant
+  0,  // opencl_generic
+  1,  // cuda_device
+  4,  // cuda_constant
+  3   // cuda_shared
+  };
+  return UseNew ? &NewMap : &OldMap;
+}
+  };
+
   /// \brief The GPU profiles supported by the AMDGPU target.
   enum GPUKind {
 GK_NONE,
@@ -2044,6 +2084,7 @@
   bool hasFMAF:1;
   bool hasLDEXPF:1;
   bool hasFullSpeedFP32Denorms:1;
+  bool UseNewAddrMap:1;
 
   static bool isAMDGCN(const llvm::Triple &TT) {
 return TT.getArch() == llvm::Triple::amdgcn;
@@ -2056,17 +2097,29 @@
   hasFP64(false),
   hasFMAF(false),
   hasLDEXPF(false),
-  hasFullSpeedFP32Denorms(false){
+  hasFullSpeedFP32Denorms(false),
+  UseNewAddrMap(false){
 if (getTriple().getArch() == llvm::Triple::amdgcn) {
   hasFP64 = true;
   hasFMAF = true;
   hasLDEXPF = true;
 }
+// At this stage, Opt.Features has not been populated yet.
+for (auto &I:Opts.FeaturesAsWritten) {
+  if (I == "+new-addr") {
+UseNewAddrMap = true;
+  } else if (I == "-new-addr") {
+UseNewAddrMap = false;
+  }
+}
+AS.reset(UseNewAddrMap);
 
 resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn ?
-DataLayoutStringSI : DataLayo

RE: r298410 - Correct class-template deprecation behavior

2017-03-21 Thread Yung, Douglas via cfe-commits
Thanks, and yes, the PS4 target has slightly different defaults for both C and 
C++. I should have mentioned that in my original email, but I also was running 
out to lunch. :) Sorry about that.

Douglas Yung

> -Original Message-
> From: Keane, Erich [mailto:erich.ke...@intel.com]
> Sent: Tuesday, March 21, 2017 13:28
> To: Yung, Douglas
> Cc: cfe-commits
> Subject: RE: r298410 - Correct class-template deprecation behavior
> 
> Ended up being simpler than I expected.  I added -r298433  To fix this.
> 
> The issue is that the test had a conditional based on the "C" version, so I
> explicitly added a test for C89 and C99, which the PS4 is apparently not
> defaulting to.
> 
> Thanks!
> -Erich
> 
> 
> -Original Message-
> From: Yung, Douglas [mailto:douglas.y...@sony.com]
> Sent: Tuesday, March 21, 2017 12:59 PM
> To: Keane, Erich 
> Cc: cfe-commits 
> Subject: RE: r298410 - Correct class-template deprecation behavior
> 
> Hi Erich,
> 
> Your change is causing the Sema/attr-deprecated.c test to fail on the PS4 bot
> (http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast/builds/7087). Can you take a look?
> 
> Douglas Yung
> 
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
> > Behalf Of Erich Keane via cfe-commits
> > Sent: Tuesday, March 21, 2017 10:49
> > To: cfe-commits@lists.llvm.org
> > Subject: r298410 - Correct class-template deprecation behavior
> >
> > Author: erichkeane
> > Date: Tue Mar 21 12:49:17 2017
> > New Revision: 298410
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=298410&view=rev
> > Log:
> > Correct class-template deprecation behavior
> >
> > Based on the comment in the test, and my reading of the standard, a
> > deprecated warning should be issued in the following case:
> > template [[deprecated]] class Foo{}; Foo f;
> >
> > This was not the case, because the ClassTemplateSpecializationDecl
> > creation did not also copy the deprecated attribute.
> >
> > Note: I did NOT audit the complete set of attributes to see WHICH ones
> > should be copied, so instead I simply copy ONLY the deprecated attribute.
> >
> > Differential Revision: https://reviews.llvm.org/D27486
> >
> > Modified:
> > cfe/trunk/include/clang/Basic/Attr.td
> > cfe/trunk/include/clang/Sema/Sema.h
> > cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> > cfe/trunk/lib/Sema/SemaTemplate.cpp
> > cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> > cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> > cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
> > cfe/trunk/test/Sema/attr-deprecated.c
> > cfe/trunk/test/SemaCXX/attr-deprecated.cpp
> > cfe/trunk/test/SemaObjC/attr-deprecated.m
> > cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
> > cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
> > cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/Attr.td
> > URL: http://llvm.org/viewvc/llvm-
> > project/cfe/trunk/include/clang/Basic/Attr.td?rev=298410&r1=298409&r2=
> > 298410&v
> > iew=diff
> > ==
> > 
> > --- cfe/trunk/include/clang/Basic/Attr.td (original)
> > +++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 21 12:49:17 2017
> > @@ -302,6 +302,9 @@ class Attr {
> >// Set to true if this attribute can be duplicated on a subject
> > when merging
> >// attributes. By default, attributes are not merged.
> >bit DuplicatesAllowedWhileMerging = 0;
> > +  // Set to true if this attribute is meaningful when applied to or
> > + inherited  // in a class template definition.
> > +  bit MeaningfulToClassTemplateDefinition = 0;
> >// Lists language options, one of which is required to be true for the
> >// attribute to be applicable. If empty, no language options are
> required.
> >list LangOpts = [];
> > @@ -373,6 +376,7 @@ def AbiTag : Attr {
> >let Args = [VariadicStringArgument<"Tags">];
> >let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
> >"ExpectedStructClassVariableFunctionOrInlineNamespace">;
> > +  let MeaningfulToClassTemplateDefinition = 1;
> >let Documentation = [AbiTagsDocs];
> >  }
> >
> > @@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
> >// An optional string argument that enables us to provide a
> >// Fix-It.
> >StringArgument<"Replacement", 1>];
> > +  let MeaningfulToClassTemplateDefinition = 1;
> >let Documentation = [DeprecatedDocs];  }
> >
> > @@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
> >let Args = [EnumArgument<"Visibility", "VisibilityType",
> > ["default", "hidden", "internal", "protected"],
> > ["Default", "Hidden", "Hidden",
> > "Protected"]>];
> > +  let MeaningfulToClassTemplateDefinition = 1;
> >let Documentation = [Undocumente

[libcxx] r298438 - Fix test failure I introduced

2017-03-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar 21 16:05:28 2017
New Revision: 298438

URL: http://llvm.org/viewvc/llvm-project?rev=298438&view=rev
Log:
Fix test failure I introduced

Modified:
libcxx/trunk/include/type_traits

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=298438&r1=298437&r2=298438&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Mar 21 16:05:28 2017
@@ -1947,18 +1947,18 @@ template  using make_unsigned
 
 #ifdef _LIBCPP_HAS_NO_VARIADICS
 
-template <>
-struct _LIBCPP_TEMPLATE_VIS common_type
+template 
+struct _LIBCPP_TEMPLATE_VIS common_type
 {
 public:
-typedef void type;
+typedef typename common_type::type, 
_Vp>::type type;
 };
 
-template 
-struct _LIBCPP_TEMPLATE_VIS common_type
+template <>
+struct _LIBCPP_TEMPLATE_VIS common_type
 {
 public:
-typedef typename common_type::type, 
_Vp>::type type;
+typedef void type;
 };
 
 template 


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


Re: r298392 - [index/AST] Determine if a typedef shares a name and spelling location with its underlying tag type

2017-03-21 Thread Vitaly Buka via cfe-commits
Could you please take a look at these leaks

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/3606/steps/check-clang%20asan/logs/stdio


=
==32547==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x57a9a8 in __interceptor_malloc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:64
#1 0x7f0c8c1de918 in clang::cxstring::createDup(llvm::StringRef)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CXString.cpp:99:40
#2 0x7f0c8c1e1120 in clang_getTypeSpelling
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CXType.cpp:273:10
#3 0x5b5a53 in PrintCursor
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:718:24
#4 0x5b4dc5 in FilteredPrintingVisitor
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1116:5
#5 0x7f0c8c115829 in
clang::cxcursor::CursorVisitor::Visit(CXCursor, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:209:11
#6 0x7f0c8c11d451 in
clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl
const*) 
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:666:7
#7 0x7f0c8c11d9fb in
clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:627:30
#8 0x7f0c8c116ecf in
clang::cxcursor::CursorVisitor::VisitChildren(CXCursor)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:532:20
#9 0x7f0c8c149ad6 in clang_visitChildren
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/libclang/CIndex.cpp:4172:20
#10 0x5b8628 in perform_test_load
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1601:5
#11 0x5b8d4f in perform_test_load_source
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:1697:12
#12 0x5c0e76 in cindextest_main
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c:4373:14
#13 0x5c5a1d in thread_runner
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/tools/c-index-test/c-index-test.c::25
#14 0x7f0c90a47daf in ExecuteOnThread_Dispatch(void*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/Unix/Threading.inc:53:3
#15 0x7f0c8919b6b9 in start_thread
(/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)

SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).

--



On Tue, Mar 21, 2017 at 10:08 AM Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: akirtzidis
> Date: Tue Mar 21 11:56:02 2017
> New Revision: 298392
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298392&view=rev
> Log:
> [index/AST] Determine if a typedef shares a name and spelling location
> with its underlying tag type
>
> In such a case, as when using the NS_ENUM macro, for indexing purposes
> treat the typedef as 'transparent',
> meaning we treat its references as symbols of the underlying tag symbol.
> Also provide a libclang API to check for such typedefs.
>
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/Index/IndexDecl.cpp
> cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
> cfe/trunk/test/Index/Core/index-source.m
> cfe/trunk/test/Index/get-cursor.m
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CXType.cpp
> cfe/trunk/tools/libclang/libclang.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=298392&r1=298391&r2=298392&view=diff
>
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Tue Mar 21 11:56:02 2017
> @@ -3437,6 +3437,16 @@ CINDEX_LINKAGE long long clang_getArrayS
>  CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
>
>  /**
> + * \brief Determine if a typedef is 'transparent' tag.
> + *
> + * A typedef is considered 'transparent' if it shares a name and spelling
> + * location with its underlying tag type, as is the case with the NS_ENUM
> macro.
> + *
> + * \returns non-zero if transparent and zero otherwise.
> + */
> +CINDEX_LINKAGE unsigned clang_Type_isTransparentTagTypedef(CXType T);
> +
> +/**
>   * \brie

[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors

2017-03-21 Thread András Leitereg via Phabricator via cfe-commits
leanil updated this revision to Diff 92542.
leanil added a comment.

Suppress warning only on std::enable_if.
Make note on copy and move constructors.


Repository:
  rL LLVM

https://reviews.llvm.org/D30547

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp
  clang-tidy/misc/ForwardingReferenceOverloadCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
  test/clang-tidy/misc-forwarding-reference-overload.cpp

Index: test/clang-tidy/misc-forwarding-reference-overload.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-forwarding-reference-overload.cpp
@@ -0,0 +1,105 @@
+// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t
+
+namespace std {
+template 
+struct enable_if {};
+
+template 
+struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+template 
+struct enable_if_nice { typedef T type; };
+}
+
+namespace foo {
+template 
+struct enable_if { typedef T type; };
+}
+
+template 
+constexpr bool just_true = true;
+
+class Person {
+public:
+  template 
+  Person(T &&n);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide copy and move constructors [misc-forwarding-reference-overload]
+
+  template 
+  Person(T &&n, int i = 5, ...);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide copy and move constructors [misc-forwarding-reference-overload]
+
+  template ::type>
+  Person(T &&n);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide copy and move constructors [misc-forwarding-reference-overload]
+
+  template 
+  Person(T &&n, typename foo::enable_if::type i = 5, ...);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide copy and move constructors [misc-forwarding-reference-overload]
+
+  Person(const Person &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here
+
+  Person(Person &other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here
+
+  Person(Person &&other) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here
+};
+
+template 
+class Person2 {
+public:
+  // Two parameters without default value, can't act as copy / move constructor.
+  template 
+  Person2(T &&n, V &&m, int i = 5, ...);
+
+  // Guarded with enable_if.
+  template 
+  Person2(T &&n, int i = 5, std::enable_if_t a = 5, ...);
+
+  // Guarded with enable_if.
+  template ::type &>
+  Person2(T &&n);
+
+  // Guarded with enable_if.
+  template 
+  Person2(T &&n, typename std::enable_if>::type **a = nullptr);
+
+  // Guarded with enable_if.
+  template > *&&>
+  Person2(T &&n, double d = 0.0);
+
+  // Not a forwarding reference parameter.
+  template 
+  Person2(const T &&n);
+
+  // Not a forwarding reference parameter.
+  Person2(int &&x);
+
+  // Two parameters without default value, can't act as copy / move constructor.
+  template 
+  Person2(T &&n, int x);
+
+  // Not a forwarding reference parameter.
+  template 
+  Person2(U &&n);
+};
+
+// Copy and move constructors are both disabled.
+class Person3 {
+public:
+  template 
+  Person3(T &&n);
+
+  template 
+  Person3(T &&n, int I = 5, ...);
+
+  Person3(const Person3 &rhs) = delete;
+
+private:
+  Person3(Person3 &&rhs);
+};
Index: docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-forwarding-reference-overload.rst
@@ -0,0 +1,52 @@
+.. title:: clang-tidy - misc-forwarding-reference-overload
+
+misc-forwarding-reference-overload
+==
+
+The check looks for perfect forwarding constructors that can hide copy or move
+constructors. If a non const lvalue reference is passed to the constructor, the 
+forwarding reference parameter will be a better match than the const reference
+parameter of the copy constructor, so the perfect forwarding constructor will be
+called, which can be confusing.
+For detailed description of this issue see: Scott Meyers, Effective Modern C++,
+Item 26.
+
+Consider the following example:
+
+  .. code-block:: c++
+  
+class Person {
+public:
+  // C1: perfect forwarding ctor
+  template
+  explicit Person(T&& n) {}
+
+  // C2: perfect forwarding ctor with parameter default value
+  template
+  explicit Person(T&& n, int x = 1) {}
+  
+  // C3: perfect forwarding ctor guarded with enable_if
+  template,void>>
+  explicit Person(T&& n) {}
+  
+  // (possibly compiler generated) copy ctor
+  Person(const Person& rhs); 
+};
+
+The check warns for constructors C1 and C2, because those can hide cop

RE: r298410 - Correct class-template deprecation behavior

2017-03-21 Thread Keane, Erich via cfe-commits
Ended up being simpler than I expected.  I added -r298433  To fix this.  

The issue is that the test had a conditional based on the "C" version, so I 
explicitly added a test for C89 and C99, which the PS4 is apparently not 
defaulting to.

Thanks!
-Erich


-Original Message-
From: Yung, Douglas [mailto:douglas.y...@sony.com] 
Sent: Tuesday, March 21, 2017 12:59 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: RE: r298410 - Correct class-template deprecation behavior

Hi Erich,

Your change is causing the Sema/attr-deprecated.c test to fail on the PS4 bot 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7087).
 Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On 
> Behalf Of Erich Keane via cfe-commits
> Sent: Tuesday, March 21, 2017 10:49
> To: cfe-commits@lists.llvm.org
> Subject: r298410 - Correct class-template deprecation behavior
> 
> Author: erichkeane
> Date: Tue Mar 21 12:49:17 2017
> New Revision: 298410
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298410&view=rev
> Log:
> Correct class-template deprecation behavior
> 
> Based on the comment in the test, and my reading of the standard, a 
> deprecated warning should be issued in the following case:
> template [[deprecated]] class Foo{}; Foo f;
> 
> This was not the case, because the ClassTemplateSpecializationDecl 
> creation did not also copy the deprecated attribute.
> 
> Note: I did NOT audit the complete set of attributes to see WHICH ones 
> should be copied, so instead I simply copy ONLY the deprecated attribute.
> 
> Differential Revision: https://reviews.llvm.org/D27486
> 
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
> cfe/trunk/test/Sema/attr-deprecated.c
> cfe/trunk/test/SemaCXX/attr-deprecated.cpp
> cfe/trunk/test/SemaObjC/attr-deprecated.m
> cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
> cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Basic/Attr.td?rev=298410&r1=298409&r2=
> 298410&v
> iew=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 21 12:49:17 2017
> @@ -302,6 +302,9 @@ class Attr {
>// Set to true if this attribute can be duplicated on a subject 
> when merging
>// attributes. By default, attributes are not merged.
>bit DuplicatesAllowedWhileMerging = 0;
> +  // Set to true if this attribute is meaningful when applied to or 
> + inherited  // in a class template definition.
> +  bit MeaningfulToClassTemplateDefinition = 0;
>// Lists language options, one of which is required to be true for the
>// attribute to be applicable. If empty, no language options are required.
>list LangOpts = [];
> @@ -373,6 +376,7 @@ def AbiTag : Attr {
>let Args = [VariadicStringArgument<"Tags">];
>let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
>"ExpectedStructClassVariableFunctionOrInlineNamespace">;
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [AbiTagsDocs];
>  }
> 
> @@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
>// An optional string argument that enables us to provide a
>// Fix-It.
>StringArgument<"Replacement", 1>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [DeprecatedDocs];  }
> 
> @@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
>let Args = [EnumArgument<"Visibility", "VisibilityType",
> ["default", "hidden", "internal", "protected"],
> ["Default", "Hidden", "Hidden", 
> "Protected"]>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [Undocumented];  }
> 
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Sema/Sema.h?rev=298410&r1=298409&r2=29
> 8410&vie
> w=diff
> ==
> 
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 21 12:49:17 2017
> @@ -7505,6 +7505,12 @@ public:
>  LateInstantiatedAttrVec *LateAttrs = nullptr,
>  LocalInstantiationScope *OuterMostScope = 
> nullptr);
> 
> +  void
> +  InstantiateAttrsForDecl(const MultiL

[clang-tools-extra] r298434 - Don't make unqualified calls to functions that could well be found via

2017-03-21 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Tue Mar 21 15:15:42 2017
New Revision: 298434

URL: http://llvm.org/viewvc/llvm-project?rev=298434&view=rev
Log:
Don't make unqualified calls to functions that could well be found via
ADL as reasonable extension points.

All of this would be cleaner if this code followed the more usual LLVM
convention of not having deeply nested namespaces inside of .cpp files
and instead having a `using namespace ...;` at the top. Then the static
function would be in the global namespace and easily referred to as
`::join`. Instead we have to write a fairly contrived qualified name.
I figure the authors can clean this up with a less ambiguous name, using
the newly provided LLVM `join` function, or any other solution, but this
at least fixes the build.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp?rev=298434&r1=298433&r2=298434&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
 Tue Mar 21 15:15:42 2017
@@ -182,8 +182,8 @@ void SpecialMemberFunctionsCheck::checkF
 
   if (!MissingMembers.empty())
 diag(ID.first, "class '%0' defines %1 but does not define %2")
-<< ID.second << join(DefinedMembers, " and ")
-<< join(MissingMembers, " or ");
+<< ID.second << cppcoreguidelines::join(DefinedMembers, " and ")
+<< cppcoreguidelines::join(MissingMembers, " or ");
 }
 
 } // namespace cppcoreguidelines


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


r298433 - iFix Test deprecation behavior in C89 mode as a result of r298410

2017-03-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Mar 21 15:14:46 2017
New Revision: 298433

URL: http://llvm.org/viewvc/llvm-project?rev=298433&view=rev
Log:
iFix Test deprecation behavior in C89 mode as a result of r298410

Modified:
cfe/trunk/test/Sema/attr-deprecated.c

Modified: cfe/trunk/test/Sema/attr-deprecated.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-deprecated.c?rev=298433&r1=298432&r2=298433&view=diff
==
--- cfe/trunk/test/Sema/attr-deprecated.c (original)
+++ cfe/trunk/test/Sema/attr-deprecated.c Tue Mar 21 15:14:46 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -std=c89 -verify -fsyntax-only
 
 int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been 
explicitly marked deprecated here}}
 void g() __attribute__((deprecated));// expected-note {{'g' has been 
explicitly marked deprecated here}}
@@ -121,11 +123,12 @@ struct test22 {
   __attribute((deprecated)) foo_dep e, f;
 };
 
-typedef int test23_ty __attribute((deprecated)); // expected-note 
{{'test23_ty' has been explicitly marked deprecated here}}
+typedef int test23_ty __attribute((deprecated)); 
 // Redefining a typedef is a C11 feature.
 #if __STDC_VERSION__ <= 199901L
 // expected-note@-3 {{'test23_ty' has been explicitly marked deprecated here}}
 #else
+// expected-note@-5 {{'test23_ty' has been explicitly marked deprecated here}}
 typedef int test23_ty; 
 #endif
 test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}


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


r298431 - Let llvm.objectsize be conservative with null pointers

2017-03-21 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Tue Mar 21 15:09:35 2017
New Revision: 298431

URL: http://llvm.org/viewvc/llvm-project?rev=298431&view=rev
Log:
Let llvm.objectsize be conservative with null pointers

D28494 adds another parameter to @llvm.objectsize. Clang needs to be
sure to pass that third arg whenever applicable.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGen/alloc-size.c
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/object-size.c
cfe/trunk/test/CodeGen/object-size.cpp
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=298431&r1=298430&r2=298431&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Mar 21 15:09:35 2017
@@ -470,10 +470,13 @@ CodeGenFunction::emitBuiltinObjectSize(c
   assert(Ptr->getType()->isPointerTy() &&
  "Non-pointer passed to __builtin_object_size?");
 
-  // LLVM only supports 0 and 2, make sure that we pass along that as a 
boolean.
-  auto *CI = ConstantInt::get(Builder.getInt1Ty(), (Type & 2) >> 1);
   Value *F = CGM.getIntrinsic(Intrinsic::objectsize, {ResType, 
Ptr->getType()});
-  return Builder.CreateCall(F, {Ptr, CI});
+
+  // LLVM only supports 0 and 2, make sure that we pass along that as a 
boolean.
+  Value *Min = Builder.getInt1((Type & 2) != 0);
+  // For GCC compatability, __builtin_object_size treat NULL as unknown size.
+  Value *NullIsUnknown = Builder.getTrue();
+  return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown});
 }
 
 // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=298431&r1=298430&r2=298431&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Mar 21 15:09:35 2017
@@ -581,10 +581,11 @@ void CodeGenFunction::EmitTypeCheck(Type
 llvm::Type *Tys[2] = { IntPtrTy, Int8PtrTy };
 llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::objectsize, Tys);
 llvm::Value *Min = Builder.getFalse();
+llvm::Value *NullIsUnknown = Builder.getFalse();
 llvm::Value *CastAddr = Builder.CreateBitCast(Ptr, Int8PtrTy);
-llvm::Value *LargeEnough =
-Builder.CreateICmpUGE(Builder.CreateCall(F, {CastAddr, Min}),
-  llvm::ConstantInt::get(IntPtrTy, Size));
+llvm::Value *LargeEnough = Builder.CreateICmpUGE(
+Builder.CreateCall(F, {CastAddr, Min, NullIsUnknown}),
+llvm::ConstantInt::get(IntPtrTy, Size));
 Checks.push_back(std::make_pair(LargeEnough, SanitizerKind::ObjectSize));
   }
 

Modified: cfe/trunk/test/CodeGen/alloc-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alloc-size.c?rev=298431&r1=298430&r2=298431&view=diff
==
--- cfe/trunk/test/CodeGen/alloc-size.c (original)
+++ cfe/trunk/test/CodeGen/alloc-size.c Tue Mar 21 15:09:35 2017
@@ -231,7 +231,7 @@ void test7() {
 void test8() {
   // Non-const pointers aren't currently supported.
   void *buf = my_calloc(100, 5);
-  // CHECK: @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false)
+  // CHECK: @llvm.objectsize.i64.p0i8(i8* %{{.*}}, i1 false, i1 true)
   gi = __builtin_object_size(buf, 0);
   // CHECK: @llvm.objectsize
   gi = __builtin_object_size(buf, 1);

Modified: cfe/trunk/test/CodeGen/catch-undef-behavior.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/catch-undef-behavior.c?rev=298431&r1=298430&r2=298431&view=diff
==
--- cfe/trunk/test/CodeGen/catch-undef-behavior.c (original)
+++ cfe/trunk/test/CodeGen/catch-undef-behavior.c Tue Mar 21 15:09:35 2017
@@ -35,7 +35,7 @@ void foo() {
   union { int i; } u;
 
   // CHECK-COMMON:  %[[I8PTR:.*]] = bitcast i32* %[[PTR:.*]] to i8*
-  // CHECK-COMMON-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* 
%[[I8PTR]], i1 false)
+  // CHECK-COMMON-NEXT: %[[SIZE:.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* 
%[[I8PTR]], i1 false, i1 false)
   // CHECK-COMMON-NEXT: %[[CHECK0:.*]] = icmp uge i64 %[[SIZE]], 4
 
   // CHECK-COMMON:  %[[PTRTOINT:.*]] = ptrtoint {{.*}}* %[[PTR]] to i64

Modified: cfe/trunk/test/CodeGen/object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/object-size.c?rev=298431&r1=298430&r2=298431&view=diff
==
--- cfe/trunk/test/CodeGen/object-size.c (original)
+++ cfe/trunk/test/CodeGen/object-size.c Tue Mar 21 15:09:35 2017
@@ -40,7 +40,7 @@ void test4() {
 // CHECK-LA

RE: r298410 - Correct class-template deprecation behavior

2017-03-21 Thread Keane, Erich via cfe-commits
I saw that, I was digging into it, then went to lunch.  I'm hoping to push a 
fix by EOD if I can.

Thanks for the heads up though!

-Original Message-
From: Yung, Douglas [mailto:douglas.y...@sony.com] 
Sent: Tuesday, March 21, 2017 12:59 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: RE: r298410 - Correct class-template deprecation behavior

Hi Erich,

Your change is causing the Sema/attr-deprecated.c test to fail on the PS4 bot 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7087).
 Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On 
> Behalf Of Erich Keane via cfe-commits
> Sent: Tuesday, March 21, 2017 10:49
> To: cfe-commits@lists.llvm.org
> Subject: r298410 - Correct class-template deprecation behavior
> 
> Author: erichkeane
> Date: Tue Mar 21 12:49:17 2017
> New Revision: 298410
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298410&view=rev
> Log:
> Correct class-template deprecation behavior
> 
> Based on the comment in the test, and my reading of the standard, a 
> deprecated warning should be issued in the following case:
> template [[deprecated]] class Foo{}; Foo f;
> 
> This was not the case, because the ClassTemplateSpecializationDecl 
> creation did not also copy the deprecated attribute.
> 
> Note: I did NOT audit the complete set of attributes to see WHICH ones 
> should be copied, so instead I simply copy ONLY the deprecated attribute.
> 
> Differential Revision: https://reviews.llvm.org/D27486
> 
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
> cfe/trunk/test/Sema/attr-deprecated.c
> cfe/trunk/test/SemaCXX/attr-deprecated.cpp
> cfe/trunk/test/SemaObjC/attr-deprecated.m
> cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
> cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Basic/Attr.td?rev=298410&r1=298409&r2=
> 298410&v
> iew=diff
> ==
> 
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 21 12:49:17 2017
> @@ -302,6 +302,9 @@ class Attr {
>// Set to true if this attribute can be duplicated on a subject 
> when merging
>// attributes. By default, attributes are not merged.
>bit DuplicatesAllowedWhileMerging = 0;
> +  // Set to true if this attribute is meaningful when applied to or 
> + inherited  // in a class template definition.
> +  bit MeaningfulToClassTemplateDefinition = 0;
>// Lists language options, one of which is required to be true for the
>// attribute to be applicable. If empty, no language options are required.
>list LangOpts = [];
> @@ -373,6 +376,7 @@ def AbiTag : Attr {
>let Args = [VariadicStringArgument<"Tags">];
>let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
>"ExpectedStructClassVariableFunctionOrInlineNamespace">;
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [AbiTagsDocs];
>  }
> 
> @@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
>// An optional string argument that enables us to provide a
>// Fix-It.
>StringArgument<"Replacement", 1>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [DeprecatedDocs];  }
> 
> @@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
>let Args = [EnumArgument<"Visibility", "VisibilityType",
> ["default", "hidden", "internal", "protected"],
> ["Default", "Hidden", "Hidden", 
> "Protected"]>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [Undocumented];  }
> 
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Sema/Sema.h?rev=298410&r1=298409&r2=29
> 8410&vie
> w=diff
> ==
> 
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 21 12:49:17 2017
> @@ -7505,6 +7505,12 @@ public:
>  LateInstantiatedAttrVec *LateAttrs = nullptr,
>  LocalInstantiationScope *OuterMostScope = 
> nullptr);
> 
> +  void
> +  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
> +  const Decl *Pattern, Decl *Inst,
> + 

[PATCH] D31168: Set FMF for -ffp-contract=fast rather than a TargetConfig

2017-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I think you can add a test case in this patch (after the llvm changes are 
checked in)?




Comment at: lib/CodeGen/CGExprScalar.cpp:262
+ApplyFPFeatures(llvm::IRBuilderBase &Builder, Expr *E)
+: CGBuilderTy::FastMathFlagGuard(Builder) {
+  if (const auto *BO = dyn_cast(E)) {

Is it necessary to check CXXOperatorCallExpr too here? 

Since CXXOperatorCallExpr has an FPFeatures field too, I was wondering how 
CodeGen was going to use that information.


https://reviews.llvm.org/D31168



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


Re: [PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-03-21 Thread Jonathan Roelofs via cfe-commits



On 3/21/17 1:53 PM, Christian Bruel via Phabricator wrote:

chrib added a comment.

In https://reviews.llvm.org/D31140#706411, @jroelofs wrote:


Can you clarify the logic here? It's my understanding that:

`-fno-exceptions` does *not* imply `-fno-unwind-tables`

however:

`-fno-unwind-tables` *does* imply that exceptions cannot be used on targets 
that require the tables to do unwinding.


Yes, (bad things might happen or (std::terminate will be called, or destructors 
not called.)...

But -f[no]-unwind-tables implies the UWTable attribute, not NoUwind attribute. 
To toggle NoUnwind, use -fno-exceptions

And this is getting worse with .canunwind which means DoesNotThrow :)

in my understanding,  the logic is as follow:

Since "An exception cannot propagate through a function with a nounwind table. The 
exception handling runtime environment terminates the program if it encounters a nounwind 
table during exception processing." (ARM Information Center)

The "nounwind" LLVM attribute, which means "Function does not throw" translates 
as the EXIDX_CANTUNWIND value in the exception table index table which needs to be created for the 
purpose (for the function)


I think the problem is here, actually. "nounwind" implies "does not 
throw", but "does not throw" really should not imply "nounwind". This is 
something that ought to be clarified in the langref with the addition of 
a "does not throw" attribute. Then the optimizer should be fixed to 
deduce "does not throw" instead of "nounwind", and we can let "nounwind" 
continue to imply .cantunwind.




And of course without exception runtime environment (the test here) we don't 
need this table. So I can see 3 cases:

- nounwind set :Generate .cantunwind directive and unwind 
table
- nounwind set but not EH   Do not generate the .cantunwind directive and do 
not emit the unwind table
- uwtable set Need to generate the unwind table (even 
without EH)

The  disable-arm-cantunwind flag means: without EH support if the function does 
not throw, do dot generate the exception tables and the EXIDX_CANTUNWIND value.


I'm not a big fan of this workaround flag. I'd rather see this fixed by 
clarifying/fixing the semantics of the IR.



Jon




https://reviews.llvm.org/D31140





--
Jon Roelofs
jonat...@codesourcery.com
CodeSourcery / Mentor Embedded

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


[PATCH] D30954: Modules: Simulate diagnostic settings for implicit modules

2017-03-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Ping!


https://reviews.llvm.org/D30954



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


r298429 - Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.

2017-03-21 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Tue Mar 21 14:55:46 2017
New Revision: 298429

URL: http://llvm.org/viewvc/llvm-project?rev=298429&view=rev
Log:
Clang change: Do not inline hot callsites for samplepgo in thinlto compile 
phase.

Summary:
Because SamplePGO passes will be invoked twice in ThinLTO build: once at 
compile phase, the other at backend. We want to make sure the IR at the 2nd 
phase matches the hot part in pro
file, thus we do not want to inline hot callsites in the first phase.

Reviewers: tejohnson, eraman

Reviewed By: tejohnson

Subscribers: mehdi_amini, cfe-commits, Prazek

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

Added:
cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=298429&r1=298428&r2=298429&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Mar 21 14:55:46 2017
@@ -318,8 +318,13 @@ void EmitAssemblyHelper::CreatePasses(le
  !CodeGenOpts.DisableLifetimeMarkers);
 PMBuilder.Inliner = 
createAlwaysInlinerLegacyPass(InsertLifetimeIntrinsics);
   } else {
+// We do not want to inline hot callsites for SamplePGO module-summary 
build
+// because profile annotation will happen again in ThinLTO backend, and we
+// want the IR of the hot path to match the profile.
 PMBuilder.Inliner = createFunctionInliningPass(
-CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize);
+CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
+(!CodeGenOpts.SampleProfileFile.empty() &&
+ CodeGenOpts.EmitSummaryIndex));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;

Added: cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof?rev=298429&view=auto
==
--- cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof (added)
+++ cfe/trunk/test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof Tue Mar 21 
14:55:46 2017
@@ -0,0 +1,2 @@
+bar:100:100
+ 2: 2000 foo:2000

Added: cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c?rev=298429&view=auto
==
--- cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c (added)
+++ cfe/trunk/test/CodeGen/pgo-sample-thinlto-summary.c Tue Mar 21 14:55:46 2017
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=INLINE
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
+
+int baz(int);
+int g;
+
+void foo(int n) {
+  for (int i = 0; i < n; i++)
+g += baz(i);
+}
+
+// INLINE-NOT: call{{.*}}foo
+// NOINLINE: call{{.*}}foo
+void bar(int n) {
+  for (int i = 0; i < n; i++)
+foo(i);
+}


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


[PATCH] D31177: [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and objective-c object pointer

2017-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:9431
+ ? 2
+ : 1)) {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))

It wasn't clear to me why the code has to be added to the right hand side of 
the >= operator.

Is it equivalent to adding the following code, which I think is easier to 
understand? I'm assuming you are trying to avoid executing the statement when 
ObjCAutoRefCount is true and either LHSType or RHSType is an objc pointer type.

```
&& (!LangOpts.ObjCAutoRefCount || (!LHSType->isObjCObjectPointerType() && 
!RHSType->isObjCObjectPointerType()))
```


Repository:
  rL LLVM

https://reviews.llvm.org/D31177



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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-21 Thread Dominic Chen via Phabricator via cfe-commits
ddcc added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:60
+// Set timeout to 15000ms = 15s
+Z3_set_param_value(Config, "timeout", "15000");
+  }

xazax.hun wrote:
> Sorry for being a bit late in the party, I was wondering whether this timeout 
> can be a source of non-determinism. The constraint solver might get lucky or 
> unlucky based on the load or the underlying hardware to solve some of the 
> constraints. We might end up with different results over different runs which 
> can be confusing for the users. Is there any other way, to set something like 
> a timeout, like limiting the number of steps inside the solver?
I believe Z3 uses various heuristics internally, so the exact execution trace 
can differ between multiple executions. However, I don't believe that this 
would be a common issue, since queries on fixed-width bitvector are decidable. 
The 15 sec timeout is intended to prevent a single query from stalling the 
static analyzer; I've only experienced this with complex queries over 
floating-point types (e.g. D28953 + D28954 + D28955), which can degenerate to 
bitblasting. I don't have the exact numbers right now, but given that the 200+ 
tests in the testsuite complete in ~90 secs with this patch, the average time 
per test is < 0.5 sec, which includes tens if not hundreds of individual SMT 
queries. As far as I know, this timeout parameter is the only support 
configuration parameter. I'd also like to point out that this solver isn't used 
unless the user both builds with it and specifies it at runtime.


https://reviews.llvm.org/D28952



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


RE: r298410 - Correct class-template deprecation behavior

2017-03-21 Thread Yung, Douglas via cfe-commits
Hi Erich,

Your change is causing the Sema/attr-deprecated.c test to fail on the PS4 bot 
(http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7087).
 Can you take a look?

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Erich Keane via cfe-commits
> Sent: Tuesday, March 21, 2017 10:49
> To: cfe-commits@lists.llvm.org
> Subject: r298410 - Correct class-template deprecation behavior
> 
> Author: erichkeane
> Date: Tue Mar 21 12:49:17 2017
> New Revision: 298410
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298410&view=rev
> Log:
> Correct class-template deprecation behavior
> 
> Based on the comment in the test, and my reading of the standard, a deprecated
> warning should be issued in the following case:
> template [[deprecated]] class Foo{}; Foo f;
> 
> This was not the case, because the ClassTemplateSpecializationDecl creation
> did not also copy the deprecated attribute.
> 
> Note: I did NOT audit the complete set of attributes to see WHICH ones should
> be copied, so instead I simply copy ONLY the deprecated attribute.
> 
> Differential Revision: https://reviews.llvm.org/D27486
> 
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
> cfe/trunk/test/Sema/attr-deprecated.c
> cfe/trunk/test/SemaCXX/attr-deprecated.cpp
> cfe/trunk/test/SemaObjC/attr-deprecated.m
> cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
> cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
> cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Basic/Attr.td?rev=298410&r1=298409&r2=298410&v
> iew=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 21 12:49:17 2017
> @@ -302,6 +302,9 @@ class Attr {
>// Set to true if this attribute can be duplicated on a subject when
> merging
>// attributes. By default, attributes are not merged.
>bit DuplicatesAllowedWhileMerging = 0;
> +  // Set to true if this attribute is meaningful when applied to or
> + inherited  // in a class template definition.
> +  bit MeaningfulToClassTemplateDefinition = 0;
>// Lists language options, one of which is required to be true for the
>// attribute to be applicable. If empty, no language options are required.
>list LangOpts = [];
> @@ -373,6 +376,7 @@ def AbiTag : Attr {
>let Args = [VariadicStringArgument<"Tags">];
>let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
>"ExpectedStructClassVariableFunctionOrInlineNamespace">;
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [AbiTagsDocs];
>  }
> 
> @@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
>// An optional string argument that enables us to provide a
>// Fix-It.
>StringArgument<"Replacement", 1>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [DeprecatedDocs];  }
> 
> @@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
>let Args = [EnumArgument<"Visibility", "VisibilityType",
> ["default", "hidden", "internal", "protected"],
> ["Default", "Hidden", "Hidden", "Protected"]>];
> +  let MeaningfulToClassTemplateDefinition = 1;
>let Documentation = [Undocumented];
>  }
> 
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/include/clang/Sema/Sema.h?rev=298410&r1=298409&r2=298410&vie
> w=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 21 12:49:17 2017
> @@ -7505,6 +7505,12 @@ public:
>  LateInstantiatedAttrVec *LateAttrs = nullptr,
>  LocalInstantiationScope *OuterMostScope = nullptr);
> 
> +  void
> +  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
> +  const Decl *Pattern, Decl *Inst,
> +  LateInstantiatedAttrVec *LateAttrs = nullptr,
> +  LocalInstantiationScope *OuterMostScope =
> + nullptr);
> +
>bool
>InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
> ClassTemplateSpecializationDecl
> *ClassTemplateSpec,
> 
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: htt

[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-03-21 Thread Christian Bruel via Phabricator via cfe-commits
chrib added a comment.

In https://reviews.llvm.org/D31140#706411, @jroelofs wrote:

> Can you clarify the logic here? It's my understanding that:
>
> `-fno-exceptions` does *not* imply `-fno-unwind-tables`
>
> however:
>
> `-fno-unwind-tables` *does* imply that exceptions cannot be used on targets 
> that require the tables to do unwinding.


Yes, (bad things might happen or (std::terminate will be called, or destructors 
not called.)...

But -f[no]-unwind-tables implies the UWTable attribute, not NoUwind attribute. 
To toggle NoUnwind, use -fno-exceptions

And this is getting worse with .canunwind which means DoesNotThrow :)

in my understanding,  the logic is as follow:

Since "An exception cannot propagate through a function with a nounwind table. 
The exception handling runtime environment terminates the program if it 
encounters a nounwind table during exception processing." (ARM Information 
Center)

The "nounwind" LLVM attribute, which means "Function does not throw" translates 
as the EXIDX_CANTUNWIND value in the exception table index table which needs to 
be created for the purpose (for the function)

And of course without exception runtime environment (the test here) we don't 
need this table. So I can see 3 cases:

- nounwind set :Generate .cantunwind directive and unwind 
table
- nounwind set but not EH   Do not generate the .cantunwind directive and do 
not emit the unwind table
- uwtable set Need to generate the unwind table (even 
without EH)

The  disable-arm-cantunwind flag means: without EH support if the function does 
not throw, do dot generate the exception tables and the EXIDX_CANTUNWIND value.


https://reviews.llvm.org/D31140



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


[PATCH] D31202: Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.

2017-03-21 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D31202



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


r298426 - [X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression

2017-03-21 Thread Coby Tayree via cfe-commits
Author: coby
Date: Tue Mar 21 14:33:32 2017
New Revision: 298426

URL: http://llvm.org/viewvc/llvm-project?rev=298426&view=rev
Log:
[X86][MS-compatability][clang] allow MS TYPE/SIZE/LENGTH operators as a part of 
a compound expression

This patch introduces X86AsmParser with the ability to handle the 
aforementioned ops within compound "MS" arithmetical expressions.
Currently - only supported as a stand alone Operand, e.g.:
"TYPE X"
now allowed :
"4 + TYPE X * 128"

LLVM side: https://reviews.llvm.org/D31173
Differential Revision: https://reviews.llvm.org/D31174

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

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=298426&r1=298425&r2=298426&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Tue Mar 21 14:33:32 2017
@@ -201,6 +201,8 @@ void t20() {
 // CHECK: mov eax, $$4
   __asm mov eax, LENGTH _bar
 // CHECK: mov eax, $$2
+  __asm mov eax, [eax + LENGTH foo * 4]
+// CHECK: mov eax, [eax + $$1 * $$4]
 
   __asm mov eax, TYPE foo
 // CHECK: mov eax, $$4
@@ -210,6 +212,8 @@ void t20() {
 // CHECK: mov eax, $$4
   __asm mov eax, TYPE _bar
 // CHECK: mov eax, $$1
+  __asm mov eax, [eax + TYPE foo * 4]
+// CHECK: mov eax, [eax + $$4 * $$4]
 
   __asm mov eax, SIZE foo
 // CHECK: mov eax, $$4
@@ -217,9 +221,12 @@ void t20() {
 // CHECK: mov eax, $$1
   __asm mov eax, SIZE _foo
 // CHECK: mov eax, $$16
+  __asm mov eax, [eax + SIZE _foo * 4]
+// CHECK: mov eax, [eax + $$16 * $$4]
   __asm mov eax, SIZE _bar
 // CHECK: mov eax, $$2
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+
 }
 
 void t21() {


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


[PATCH] D31174: [X86][MS-compatability] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression

2017-03-21 Thread coby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298426: [X86][MS-compatability][clang] allow MS 
TYPE/SIZE/LENGTH operators as a part of… (authored by coby).

Changed prior to commit:
  https://reviews.llvm.org/D31174?vs=92437&id=92529#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31174

Files:
  cfe/trunk/test/CodeGen/ms-inline-asm.c


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -201,6 +201,8 @@
 // CHECK: mov eax, $$4
   __asm mov eax, LENGTH _bar
 // CHECK: mov eax, $$2
+  __asm mov eax, [eax + LENGTH foo * 4]
+// CHECK: mov eax, [eax + $$1 * $$4]
 
   __asm mov eax, TYPE foo
 // CHECK: mov eax, $$4
@@ -210,16 +212,21 @@
 // CHECK: mov eax, $$4
   __asm mov eax, TYPE _bar
 // CHECK: mov eax, $$1
+  __asm mov eax, [eax + TYPE foo * 4]
+// CHECK: mov eax, [eax + $$4 * $$4]
 
   __asm mov eax, SIZE foo
 // CHECK: mov eax, $$4
   __asm mov eax, SIZE bar
 // CHECK: mov eax, $$1
   __asm mov eax, SIZE _foo
 // CHECK: mov eax, $$16
+  __asm mov eax, [eax + SIZE _foo * 4]
+// CHECK: mov eax, [eax + $$16 * $$4]
   __asm mov eax, SIZE _bar
 // CHECK: mov eax, $$2
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+
 }
 
 void t21() {


Index: cfe/trunk/test/CodeGen/ms-inline-asm.c
===
--- cfe/trunk/test/CodeGen/ms-inline-asm.c
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c
@@ -201,6 +201,8 @@
 // CHECK: mov eax, $$4
   __asm mov eax, LENGTH _bar
 // CHECK: mov eax, $$2
+  __asm mov eax, [eax + LENGTH foo * 4]
+// CHECK: mov eax, [eax + $$1 * $$4]
 
   __asm mov eax, TYPE foo
 // CHECK: mov eax, $$4
@@ -210,16 +212,21 @@
 // CHECK: mov eax, $$4
   __asm mov eax, TYPE _bar
 // CHECK: mov eax, $$1
+  __asm mov eax, [eax + TYPE foo * 4]
+// CHECK: mov eax, [eax + $$4 * $$4]
 
   __asm mov eax, SIZE foo
 // CHECK: mov eax, $$4
   __asm mov eax, SIZE bar
 // CHECK: mov eax, $$1
   __asm mov eax, SIZE _foo
 // CHECK: mov eax, $$16
+  __asm mov eax, [eax + SIZE _foo * 4]
+// CHECK: mov eax, [eax + $$16 * $$4]
   __asm mov eax, SIZE _bar
 // CHECK: mov eax, $$2
 // CHECK: "~{eax},~{dirflag},~{fpsr},~{flags}"()
+
 }
 
 void t21() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-03-21 Thread Hal Finkel via cfe-commits


On 03/21/2017 12:19 PM, Ulrich Weigand via Phabricator wrote:

uweigand added a comment.

In https://reviews.llvm.org/D30415#705889, @echristo wrote:


In https://reviews.llvm.org/D30415#705196, @uweigand wrote:


Well, mainline GCC doesn't have -faltivec at all and never had, I think this 
was only an Apple GCC extension ...  Not sure what exactly the semantics of 
that was.


Sure it does and has for years. Check out rs6000/darwin.h :)

FWIW: It turns on maltivec and adds a -include of altivec.h


Huh, I wasn't aware of that feature on Darwin, thanks for pointing it out ...


Nearly all of the code in lib/Driver/ToolChains/Clang.cpp and 
lib/Driver/ToolChains/Arch/PPC.cpp that deal with altivec. Simplifying the 
interface by getting rid of needing to check multiple options.

But why would that code no longer be necessary for -maltivec?  Well, I guess 
I'll wait for your patch ...

If we indeed get rid of -faltivec, I'm wondering whether it would also make 
sense to get rid of -fzvector.  This is just an alias for -mzvector, and it 
isn't supported by GCC either.  I added it only because Richard Smith 
specifically asked for it when I contributed the feature here:
https://reviews.llvm.org/D11001


Perhaps what consistency giveth, consistency shall taketh away.

 -Hal




This should be a -f flag, not a -m flag. (I think we only support -maltivec for 
GCC compatibility.)




https://reviews.llvm.org/D30415





--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory

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


[PATCH] D31202: Clang change: Do not inline hot callsites for samplepgo in thinlto compile phase.

2017-03-21 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
Herald added subscribers: Prazek, mehdi_amini.

Because SamplePGO passes will be invoked twice in ThinLTO build: once at 
compile phase, the other at backend. We want to make sure the IR at the 2nd 
phase matches the hot part in pro
file, thus we do not want to inline hot callsites in the first phase.


https://reviews.llvm.org/D31202

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
  test/CodeGen/pgo-sample-thinlto-summary.c


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- /dev/null
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o 
- 2>&1 | FileCheck %s -check-prefix=INLINE
+// RUN: %clang_cc1 -O2 
-fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm 
-flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
+
+int baz(int);
+int g;
+
+void foo(int n) {
+  for (int i = 0; i < n; i++)
+g += baz(i);
+}
+
+// INLINE-NOT: call{{.*}}foo
+// NOINLINE: call{{.*}}foo
+void bar(int n) {
+  for (int i = 0; i < n; i++)
+foo(i);
+}
Index: test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
===
--- /dev/null
+++ test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
@@ -0,0 +1,2 @@
+bar:100:100
+ 2: 2000 foo:2000
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -318,8 +318,13 @@
  !CodeGenOpts.DisableLifetimeMarkers);
 PMBuilder.Inliner = 
createAlwaysInlinerLegacyPass(InsertLifetimeIntrinsics);
   } else {
+// We do not want to inline hot callsites for SamplePGO module-summary 
build
+// because profile annotation will happen again in ThinLTO backend, and we
+// want the IR of the hot path to match the profile.
 PMBuilder.Inliner = createFunctionInliningPass(
-CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize);
+CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
+(!CodeGenOpts.SampleProfileFile.empty() &&
+ CodeGenOpts.EmitSummaryIndex));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;


Index: test/CodeGen/pgo-sample-thinlto-summary.c
===
--- /dev/null
+++ test/CodeGen/pgo-sample-thinlto-summary.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INLINE
+// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample-thinlto-summary.prof %s -emit-llvm -flto=thin -o - 2>&1 | FileCheck %s -check-prefix=NOINLINE
+// Checks if hot call is inlined by normal compile, but not inlined by
+// thinlto compile.
+
+int baz(int);
+int g;
+
+void foo(int n) {
+  for (int i = 0; i < n; i++)
+g += baz(i);
+}
+
+// INLINE-NOT: call{{.*}}foo
+// NOINLINE: call{{.*}}foo
+void bar(int n) {
+  for (int i = 0; i < n; i++)
+foo(i);
+}
Index: test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
===
--- /dev/null
+++ test/CodeGen/Inputs/pgo-sample-thinlto-summary.prof
@@ -0,0 +1,2 @@
+bar:100:100
+ 2: 2000 foo:2000
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -318,8 +318,13 @@
  !CodeGenOpts.DisableLifetimeMarkers);
 PMBuilder.Inliner = createAlwaysInlinerLegacyPass(InsertLifetimeIntrinsics);
   } else {
+// We do not want to inline hot callsites for SamplePGO module-summary build
+// because profile annotation will happen again in ThinLTO backend, and we
+// want the IR of the hot path to match the profile.
 PMBuilder.Inliner = createFunctionInliningPass(
-CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize);
+CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
+(!CodeGenOpts.SampleProfileFile.empty() &&
+ CodeGenOpts.EmitSummaryIndex));
   }
 
   PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298424 - [CMake] fix CLANG_INCLUDE_DIRS CMake export

2017-03-21 Thread Guillaume Papin via cfe-commits
Author: papin_g
Date: Tue Mar 21 14:17:53 2017
New Revision: 298424

URL: http://llvm.org/viewvc/llvm-project?rev=298424&view=rev
Log:
[CMake] fix CLANG_INCLUDE_DIRS CMake export

Summary:
This change should fixes the export of CLANG_INCLUDE_DIRS variable in 
ClangConfig.cmake.

Unlike for the other variables, CLANG_INSTALL_PREFIX wasn't escaped meaning 
CLANG_INCLUDE_DIRS
resulting in the path "/include" instead of "${CLANG_INSTALL_PREFIX}/include".

Reviewers: beanz

Subscribers: mgorny

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

Modified:
cfe/trunk/cmake/modules/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/CMakeLists.txt?rev=298424&r1=298423&r2=298424&view=diff
==
--- cfe/trunk/cmake/modules/CMakeLists.txt (original)
+++ cfe/trunk/cmake/modules/CMakeLists.txt Tue Mar 21 14:17:53 2017
@@ -42,7 +42,7 @@ set(CLANG_CONFIG_CMAKE_DIR "\${CLANG_INS
 set(CLANG_CONFIG_LLVM_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_EXPORTS_FILE "\${CLANG_CMAKE_DIR}/ClangTargets.cmake")
 set(CLANG_CONFIG_INCLUDE_DIRS
-  "${CLANG_INSTALL_PREFIX}/include"
+  "\${CLANG_INSTALL_PREFIX}/include"
   )
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/ClangConfig.cmake.in


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


[libcxx] r298422 - Fix a couple of 'C++11'-isms from the last checkin, which broke the '03 bot.

2017-03-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar 21 14:12:21 2017
New Revision: 298422

URL: http://llvm.org/viewvc/llvm-project?rev=298422&view=rev
Log:
Fix a couple of 'C++11'-isms from the last checkin, which broke the '03 bot.

Modified:
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=298422&r1=298421&r2=298422&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Mar 21 14:12:21 2017
@@ -1947,6 +1947,13 @@ template  using make_unsigned
 
 #ifdef _LIBCPP_HAS_NO_VARIADICS
 
+template <>
+struct _LIBCPP_TEMPLATE_VIS common_type
+{
+public:
+typedef void type;
+};
+
 template 
 struct _LIBCPP_TEMPLATE_VIS common_type
 {

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_%2B.pass.cpp?rev=298422&r1=298421&r2=298422&view=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
 Tue Mar 21 14:12:21 2017
@@ -37,8 +37,8 @@ int main()
 {
 typedef std::chrono::duration > D10;
 typedef std::chrono::duration > D1;
-D10 zero{0};
-D10 one{1};
+D10 zero(0);
+D10 one(1);
 static_assert( (std::is_same< decltype(+one), decltype(zero-one) 
>::value), "");
 static_assert( (std::is_same< decltype(zero+one), D1>::value), "");
 static_assert( (std::is_same< decltype(+one), D1>::value), "");

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp?rev=298422&r1=298421&r2=298422&view=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
 Tue Mar 21 14:12:21 2017
@@ -37,8 +37,8 @@ int main()
 {
 typedef std::chrono::duration > D10;
 typedef std::chrono::duration > D1;
-D10 zero{0};
-D10 one{1};
+D10 zero(0);
+D10 one(1);
 static_assert( (std::is_same< decltype(-one), decltype(zero-one) 
>::value), "");
 static_assert( (std::is_same< decltype(zero-one), D1>::value), "");
 static_assert( (std::is_same< decltype(-one), D1>::value), "");


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


[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2017-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit in r298421.


https://reviews.llvm.org/D31130



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


[clang-tools-extra] r298421 - Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.

2017-03-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Mar 21 14:01:17 2017
New Revision: 298421

URL: http://llvm.org/viewvc/llvm-project?rev=298421&view=rev
Log:
Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing 
array to pointer decay stemming from system macros.

Patch by Breno Rodrigues Guimaraes.

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=298421&r1=298420&r2=298421&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 Tue Mar 21 14:01:17 2017
@@ -47,6 +47,25 @@ AST_MATCHER_P(Expr, hasParentIgnoringImp
   return InnerMatcher.matches(*E, Finder, Builder);
 }
 
+AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
+  return Node.getCastKind() == CK_ArrayToPointerDecay;
+}
+
+AST_MATCHER(ImplicitCastExpr, sysSymbolDecayInSysHeader) {
+  auto &SM = Finder->getASTContext().getSourceManager();
+  if (SM.isInSystemMacro(Node.getLocStart())) {
+if (isa(Node.getSubExpr()))
+  return true;
+
+if (const auto *SymbolDeclRef = dyn_cast(Node.getSubExpr())) {
+  const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
+  if (SymbolDecl && SM.isInSystemHeader(SymbolDecl->getLocation()))
+return true;
+}
+  }
+  return false;
+}
+
 void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -56,10 +75,12 @@ void ProBoundsArrayToPointerDecayCheck::
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
+  implicitCastExpr(isArrayToPointerDecay(),
+   unless(hasParent(arraySubscriptExpr())),
unless(hasParentIgnoringImpCasts(explicitCastExpr())),
unless(isInsideOfRangeBeginEndStmt()),
-   unless(hasSourceExpression(stringLiteral(
+   unless(hasSourceExpression(stringLiteral())),
+   unless(sysSymbolDecayInSysHeader()))
   .bind("cast"),
   this);
 }
@@ -67,8 +88,6 @@ void ProBoundsArrayToPointerDecayCheck::
 void ProBoundsArrayToPointerDecayCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *MatchedCast = Result.Nodes.getNodeAs("cast");
-  if (MatchedCast->getCastKind() != CK_ArrayToPointerDecay)
-return;
 
   diag(MatchedCast->getExprLoc(), "do not implicitly decay an array into a "
   "pointer; consider using gsl::array_view or "

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp?rev=298421&r1=298420&r2=298421&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 Tue Mar 21 14:01:17 2017
@@ -1,4 +1,5 @@
 // RUN: %check_clang_tidy %s 
cppcoreguidelines-pro-bounds-array-to-pointer-decay %t
+#include 
 #include 
 
 namespace gsl {
@@ -34,6 +35,11 @@ void f() {
 
   for (auto &e : a) // OK, iteration internally decays array to pointer
 e = 1;
+
+  assert(false); // OK, array decay inside system header macro
+
+  assert(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not implicitly decay an array 
into a pointer; consider using gsl::array_view or an explicit cast instead 
[cppcoreguidelines-pro-bounds-array-to-pointer-decay]
 }
 
 const char *g() {


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


[PATCH] D30845: Fix array sizes where address space is not yet known

2017-03-21 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kzhuravl marked an inline comment as done.
Closed by commit rL298420: Fix array sizes where address space is not yet known 
(authored by kzhuravl).

Changed prior to commit:
  https://reviews.llvm.org/D30845?vs=91404&id=92523#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30845

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl


Index: cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm 
-o - %s | FileCheck %s
+
+// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x 
i8] zeroinitializer, align 1
+unsigned char One[6442450944];
+// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x 
i32] zeroinitializer, align 4
+global unsigned int Two[6442450944];
+ 
+kernel void large_globals(unsigned int id) {
+  One[id] = id;
+  Two[id + 1] = id + 1;
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -2692,8 +2692,7 @@
   // Convert the array size into a canonical width matching the pointer size 
for
   // the target.
   llvm::APInt ArySize(ArySizeIn);
-  ArySize =
-ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy)));
+  ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
 
   llvm::FoldingSetNodeID ID;
   ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals);


Index: cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x i8] zeroinitializer, align 1
+unsigned char One[6442450944];
+// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x i32] zeroinitializer, align 4
+global unsigned int Two[6442450944];
+ 
+kernel void large_globals(unsigned int id) {
+  One[id] = id;
+  Two[id + 1] = id + 1;
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -2692,8 +2692,7 @@
   // Convert the array size into a canonical width matching the pointer size for
   // the target.
   llvm::APInt ArySize(ArySizeIn);
-  ArySize =
-ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy)));
+  ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
 
   llvm::FoldingSetNodeID ID;
   ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298420 - Fix array sizes where address space is not yet known

2017-03-21 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Tue Mar 21 13:55:39 2017
New Revision: 298420

URL: http://llvm.org/viewvc/llvm-project?rev=298420&view=rev
Log:
Fix array sizes where address space is not yet known

For variables in generic address spaces, for example:

```
unsigned char V[6442450944];
...
```

the address space is not yet known when we get into
*getConstantArrayType*, it is 0. AMDGCN target's
address space 0 has 32 bits pointers, so when we
call *getPointerWidth* with 0, the array size is
trimmed to 32 bits, which is not right.

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

Added:
cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=298420&r1=298419&r2=298420&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Mar 21 13:55:39 2017
@@ -2692,8 +2692,7 @@ QualType ASTContext::getConstantArrayTyp
   // Convert the array size into a canonical width matching the pointer size 
for
   // the target.
   llvm::APInt ArySize(ArySizeIn);
-  ArySize =
-ArySize.zextOrTrunc(Target->getPointerWidth(getTargetAddressSpace(EltTy)));
+  ArySize = ArySize.zextOrTrunc(Target->getMaxPointerWidth());
 
   llvm::FoldingSetNodeID ID;
   ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, IndexTypeQuals);

Added: cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl?rev=298420&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/amdgcn-large-globals.cl Tue Mar 21 13:55:39 
2017
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -S -emit-llvm 
-o - %s | FileCheck %s
+
+// CHECK: @One = common local_unnamed_addr addrspace(1) global [6442450944 x 
i8] zeroinitializer, align 1
+unsigned char One[6442450944];
+// CHECK: @Two = common local_unnamed_addr addrspace(1) global [6442450944 x 
i32] zeroinitializer, align 4
+global unsigned int Two[6442450944];
+ 
+kernel void large_globals(unsigned int id) {
+  One[id] = id;
+  Two[id + 1] = id + 1;
+}


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


[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 92522.
aaron.ballman added a comment.

Missed a case for `UnaryExprOrTypeTraitExpr`.


https://reviews.llvm.org/D31153

Files:
  include/clang/AST/Expr.h
  include/clang/AST/StmtIterator.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -3899,6 +3899,11 @@
   return child_range(&Argument.Ex, &Argument.Ex + 1);
 }
 
+Stmt::const_child_range UnaryExprOrTypeTraitExpr::children() const {
+  auto Children = const_cast(this)->children();
+  return const_child_range(Children.begin(), Children.end());
+}
+
 AtomicExpr::AtomicExpr(SourceLocation BLoc, ArrayRef args,
QualType t, AtomicOp op, SourceLocation RP)
   : Expr(AtomicExprClass, t, VK_RValue, OK_Ordinary,
Index: include/clang/AST/StmtIterator.h
===
--- include/clang/AST/StmtIterator.h
+++ include/clang/AST/StmtIterator.h
@@ -137,6 +137,10 @@
 
   ConstStmtIterator(const StmtIterator& RHS) :
 StmtIteratorImpl(RHS) {}
+
+  ConstStmtIterator(Stmt * const *S)
+  : StmtIteratorImpl(
+const_cast(S)) {}
 };
 
 } // end namespace clang
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -907,6 +907,10 @@
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   /// The source expression of an opaque value expression is the
   /// expression which originally generated the value.  This is
   /// provided as a convenience for analyses that don't wish to
@@ -1167,6 +1171,10 @@
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   friend TrailingObjects;
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
@@ -1222,6 +1230,9 @@
 
   // Iterators
   child_range children() { return child_range(&FnName, &FnName + 1); }
+  const_child_range children() const {
+return const_child_range(&FnName, &FnName + 1);
+  }
 
   friend class ASTStmtReader;
 };
@@ -1315,6 +1326,9 @@
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 class CharacterLiteral : public Expr {
@@ -1365,6 +1379,9 @@
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 class FloatingLiteral : public Expr, private APFloatStorage {
@@ -1429,6 +1446,9 @@
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 /// ImaginaryLiteral - We support imaginary integer and floating point literals,
@@ -1461,6 +1481,9 @@
 
   // Iterators
   child_range children() { return child_range(&Val, &Val+1); }
+  const_child_range children() const {
+return const_child_range(&Val, &Val + 1);
+  }
 };
 
 /// StringLiteral - This represents a string literal expression, e.g. "foo"
@@ -1628,6 +1651,9 @@
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 /// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
@@ -1669,6 +1695,9 @@
 
   // Iterators
   child_range children() { return child_range(&Val, &Val+1); }
+  const_child_range children() const {
+return const_child_range(&Val, &Val + 1);
+  }
 };
 
 /// UnaryOperator - This represents the unary-expression's (except sizeof and
@@ -1778,6 +1807,9 @@
 
   // Iterators
   child_range children() { return child_range(&Val, &Val+1); }
+  const_child_range children() const {
+return const_child_range(&Val, &Val + 1);
+  }
 };
 
 /// Helper class for OffsetOfExpr.
@@ -1981,6 +2013,11 @@
 Stmt **begin = reinterpret_cast(getTrailingObjects());
 return child_range(begin, begin + NumExprs);
   }
+  const_child_range children() const {
+Stmt *const *begin =
+reinterpret_cast(getTrailingObjects());
+return const_child_range(begin, begin + NumExprs);
+  }
   friend TrailingObjects;
 };
 
@@ -2069,6 +2106,7 @@
 
   // Iterators
   child_range children();
+  const_child_range children() const;
 };
 
 //===--===//
@@ -2153,6 +2191,9 @@
   child_range ch

[PATCH] D30810: Preserve vec3 type.

2017-03-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D30810#706676, @Anastasia wrote:

> In https://reviews.llvm.org/D30810#699428, @Anastasia wrote:
>
> > Would you be able to update ScalarExprEmitter::VisitAsTypeExpr 
> > implementation accordingly to make things consistent?
>
>
> Not sure it got lost somewhere... do you think you could address this too?


I guess due to 4 element alignment the generated casts as vec4 should be fine 
for vec3, but it is worth checking...


https://reviews.llvm.org/D30810



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


[PATCH] D30810: Preserve vec3 type.

2017-03-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D30810#699428, @Anastasia wrote:

> Would you be able to update ScalarExprEmitter::VisitAsTypeExpr implementation 
> accordingly to make things consistent?


Not sure it got lost somewhere... do you think you could address this too?


https://reviews.llvm.org/D30810



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


[PATCH] D30810: Preserve vec3 type.

2017-03-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> Hi Anastasia, Bruno,
> 
> Do you still have other opinion? or Can we go ahead and commit this patch?

I would like to see this patch committed. I see clear evidence of it improving 
existing GPU targets in the master repo as well as outside of the main tree 
implementations. Bruno, do you have any more concerns?


https://reviews.llvm.org/D30810



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


[libcxx] r298418 - Add a bit more to one of the chrono tests

2017-03-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar 21 13:40:46 2017
New Revision: 298418

URL: http://llvm.org/viewvc/llvm-project?rev=298418&view=rev
Log:
Add a bit more to one of the chrono tests

Modified:

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_%2B.pass.cpp?rev=298418&r1=298417&r2=298418&view=diff
==
--- 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
 Tue Mar 21 13:40:46 2017
@@ -32,4 +32,15 @@ int main()
 static_assert(m.count() == m2.count(), "");
 }
 #endif
+
+// P0548
+{
+typedef std::chrono::duration > D10;
+typedef std::chrono::duration > D1;
+D10 zero{0};
+D10 one{1};
+static_assert( (std::is_same< decltype(+one), decltype(zero-one) 
>::value), "");
+static_assert( (std::is_same< decltype(zero+one), D1>::value), "");
+static_assert( (std::is_same< decltype(+one), D1>::value), "");
+}
 }


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


[libcxx] r298416 - Implement P0548: 'common_type and duration' This involves a subtle change in the return type of the unary +/- operators for std::chrono::duration, though I expect that no one will n

2017-03-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Mar 21 13:38:57 2017
New Revision: 298416

URL: http://llvm.org/viewvc/llvm-project?rev=298416&view=rev
Log:
Implement P0548: 'common_type and duration' This involves a subtle change in 
the return type of the unary +/- operators for std::chrono::duration, though I 
expect that no one will notice.

Modified:
libcxx/trunk/include/chrono
libcxx/trunk/include/type_traits

libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp

libcxx/trunk/test/std/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/chrono
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/chrono?rev=298416&r1=298415&r2=298416&view=diff
==
--- libcxx/trunk/include/chrono (original)
+++ libcxx/trunk/include/chrono Tue Mar 21 13:38:57 2017
@@ -48,7 +48,7 @@ class duration
 static_assert(Period::num > 0, "duration period must be positive");
 public:
 typedef Rep rep;
-typedef Period period;
+typedef typename _Period::type period;
 
 constexpr duration() = default;
 template 
@@ -75,8 +75,8 @@ public:
 
 // arithmetic
 
-constexpr duration  operator+() const;
-constexpr duration  operator-() const;
+constexpr common_type::type  operator+() const;
+constexpr common_type::type  operator-() const;
 constexpr duration& operator++();
 constexpr duration  operator++(int);
 constexpr duration& operator--();
@@ -523,7 +523,7 @@ class _LIBCPP_TEMPLATE_VIS duration
 
 public:
 typedef _Rep rep;
-typedef _Period period;
+typedef typename _Period::type period;
 private:
 rep __rep_;
 public:
@@ -565,8 +565,8 @@ public:
 
 // arithmetic
 
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator+() const 
{return *this;}
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator-() const 
{return duration(-__rep_);}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename 
common_type::type operator+() const {return typename 
common_type::type(*this);}
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename 
common_type::type operator-() const {return typename 
common_type::type(-__rep_);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& 
operator++()  {++__rep_; return *this;}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration  
operator++(int)   {return duration(__rep_++);}
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& 
operator--()  {--__rep_; return *this;}

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=298416&r1=298415&r2=298416&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Mar 21 13:38:57 2017
@@ -1958,7 +1958,7 @@ template 
 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, void, void>
 {
 public:
-typedef typename decay<_Tp>::type type;
+typedef typename common_type<_Tp, _Tp>::type type;
 };
 
 template 
@@ -1981,7 +1981,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type
 template 
 struct _LIBCPP_TEMPLATE_VIS common_type<_Tp>
 {
-typedef typename decay<_Tp>::type type;
+typedef typename common_type<_Tp, _Tp>::type type;
 };
 
 // bullet 3 - sizeof...(Tp) == 2

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp?rev=298416&r1=298415&r2=298416&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
 Tue Mar 21 13:38:57 2017
@@ -37,6 +37,12 @@ namespace std
   typedef S type;
 };
 
+//  P0548
+template 
+struct common_type< ::S, ::S > {
+  typedef S type;
+};
+
 template <> struct common_type< ::S, long> {};
 template <> struct common_type > {};
 }
@@ -284,4 +290,19 @@ int main()
   test_bullet_three_two();
   test_bullet_four();
 #endif
+
+//  P0548
+static_assert((std::is_same >::type, 
S >::value), "");
+static_assert((std::is_same, S >::type, 
S >::value), "");
+
+static_assert((std::is_same::type,
int>::value), "");
+static_assert((std::is_same::type,  
int>::value), "");
+static_assert((std::is_same::type,   
int>::value), "");
+static_assert((std::is_same::type, 
int>::value), "");
+
+static_assert((std::is_same::type, 
int>::val

[PATCH] D31134: [Serialization] Serialize DependentSizedExtVectorType

2017-03-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM Alex, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D31134



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


r298414 - Modules: Remove an invalid check in unit tests for r298278

2017-03-21 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Mar 21 13:26:18 2017
New Revision: 298414

URL: http://llvm.org/viewvc/llvm-project?rev=298414&view=rev
Log:
Modules: Remove an invalid check in unit tests for r298278

This is a fixup for the unit tests from r298278 (originally r298165).

Since the buffer that RawB2 pointed at was later deleted, a new call to
getBuffer may very well return a buffer at the same/old address.  Which is
fine.  Just delete the spurious check.

A Windows bot was occasionally hitting this in practice:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/7086

Modified:
cfe/trunk/unittests/Basic/MemoryBufferCacheTest.cpp

Modified: cfe/trunk/unittests/Basic/MemoryBufferCacheTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/MemoryBufferCacheTest.cpp?rev=298414&r1=298413&r2=298414&view=diff
==
--- cfe/trunk/unittests/Basic/MemoryBufferCacheTest.cpp (original)
+++ cfe/trunk/unittests/Basic/MemoryBufferCacheTest.cpp Tue Mar 21 13:26:18 2017
@@ -50,7 +50,6 @@ TEST(MemoryBufferCacheTest, addBuffer) {
 
   // Replace the middle buffer.
   B2 = getBuffer(2);
-  ASSERT_NE(RawB2, B2.get());
   RawB2 = B2.get();
   EXPECT_EQ(RawB2, &Cache.addBuffer("2", std::move(B2)));
 


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


Re: FW: SemaAccess bug (protected members of derived)

2017-03-21 Thread Alex L via cfe-commits
Thanks,

It looks like your solution isn't quite right as it causes Clang to accept
invalid access to protected members, e.g. as tested by
"test/CXX/class.access/class.protected/p1.cpp".

Do you think there's an alternative solution that you could use?

Alex

On 21 March 2017 at 14:48, Dixon Ryan (ETAS/ERS-PD2) 
wrote:

> From path:
>
>
>
> URL: http://llvm.org/svn/llvm-project/cfe/trunk
>
> Relative URL: ^/cfe/trunk
>
>
>
> *From:* Alex L [mailto:arpha...@gmail.com]
> *Sent:* 21 March 2017 14:22
> *To:* Dixon Ryan (ETAS/ERS-PD2) 
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: FW: SemaAccess bug (protected members of derived)
>
>
>
> Thanks, can you please attach a diff that includes both the code change
> and the new test?
>
>
>
> On 21 March 2017 at 14:18, Dixon Ryan (ETAS/ERS-PD2) via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Sending to mailing list.
>
>
>
> *From:* Dixon Ryan (ETAS/ERS-PD2)
> *Sent:* 21 March 2017 14:18
> *To:* 'Alex L' 
> *Subject:* RE: SemaAccess bug (protected members of derived)
>
>
>
> Hello, sorry this is the first time I have done this.
>
>
>
> The test case is attached. It should fail without the patch and then
> should pass with the patch.
>
>
>
>
>
> class cl
>
> {
>
> public:
>
>void myPublic(int x){ }
>
> protected:
>
>void myProtected(int y){ }
>
> };
>
>
>
> class clChild : public cl
>
> {
>
>void myPrivate(int z)
>
>{
>
>   this->
>
>  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:13 %s
> -o - | FileCheck -check-prefix=CHECK-CC1 %s
>
>  // CHECK: COMPLETION: myProtected : [#void#][#cl::#]myProtected(<#int
> y#>)
>
>}
>
> };
>
>
>
>
>
> *From:* Alex L [mailto:arpha...@gmail.com ]
> *Sent:* 21 March 2017 12:17
> *To:* Dixon Ryan (ETAS/ERS-PD2) 
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: SemaAccess bug (protected members of derived)
>
>
>
> Hi,
>
>
>
> Can you please add a suitable test-case? Clang's code-completion tests are
> normally in test/CodeCompletion or test/Index.
>
>
>
> Cheers,
>
> Alex
>
>
>
> On 21 March 2017 at 12:05, Dixon Ryan (ETAS/ERS-PD2) via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> There are a number of users of the clang static analyser back-end for
> intelligent code completion. Irony-Mode for emacs, for example. For a while
> people have been reporting an issue with not getting completions for
> protected members of parent classes and I believe this patch solves the
> bug: simply that the arguments to IsDerivedFromInclusive were the wrong way
> around.
>
>
>
> URL: http://llvm.org/svn/llvm-project/cfe/trunk/lib/Sema
>
> Relative URL: ^/cfe/trunk/lib/Sema
>
>
>
> Index: SemaAccess.cpp
>
> ===
>
> --- SemaAccess.cpp  (revision 297956)
>
> +++ SemaAccess.cpp   (working copy)
>
> @@ -823,7 +823,7 @@
>
>  continue;
>
>}
>
> -  switch (IsDerivedFromInclusive(InstanceContext, ECRecord)) {
>
> +  switch (IsDerivedFromInclusive(ECRecord, InstanceContext)) {
>
>case AR_accessible: return AR_accessible;
>
>case AR_inaccessible: continue;
>
>case AR_dependent: OnFailure = AR_dependent; continue;
>
>
>
> Thank you.
>
>
> ___
> 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
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2017-03-21 Thread Breno Rodrigues Guimaraes via Phabricator via cfe-commits
brenoguim added a comment.

I appreciate it!


https://reviews.llvm.org/D31130



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


[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2017-03-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D31130#706623, @brenoguim wrote:

> Hi @aaron.ballman,
>
> Thanks for the review!
>
> I don't have rights to push this. Who should I contact to push the change in 
> my behalf?


I'm happy to do so on your behalf (it'll happen later this afternoon unless 
someone else beats me to it).


https://reviews.llvm.org/D31130



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


[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros

2017-03-21 Thread Breno Rodrigues Guimaraes via Phabricator via cfe-commits
brenoguim marked 4 inline comments as done.
brenoguim added a comment.

Hi @aaron.ballman,

Thanks for the review!

I don't have rights to push this. Who should I contact to push the change in my 
behalf?


https://reviews.llvm.org/D31130



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


[PATCH] D31179: Objective-C categories should support attributes

2017-03-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/SemaObjC/attr-deprecated.m:124-128
+@interface A(Blah) // no warning
+- (A*)getA;
 @end
 
+@implementation A(Blah) // no warning

aaron.ballman wrote:
> I would have assumed the use in the `@implementation` would have been enough 
> to trigger it, is that not the behavior we'd want?
> 
> If not, can you extend the test to show that a use of the category triggers 
> the deprecation warning? 
I'm not sure. Typically an implementation of a category is located in a 
framework, so even if it's deprecated for the users of a framework, you 
wouldn't really want to get a warning about it when compiling that framework. 
That said there's is a non-default `-Wdeprecated-implementation` warning for 
class implementations, so I think it would make sense to use it for category 
implementations as well. I will add make sure that the warning is emitted when 
committing the patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D31179



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


[PATCH] D27486: Correct class-template deprecation behavior

2017-03-21 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL298410: Correct class-template deprecation behavior 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D27486?vs=84330&id=92514#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27486

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  cfe/trunk/test/Sema/attr-deprecated.c
  cfe/trunk/test/SemaCXX/attr-deprecated.cpp
  cfe/trunk/test/SemaObjC/attr-deprecated.m
  cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
  cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -2451,26 +2451,19 @@
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }
 
-// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
-  emitSourceFileHeader("Template instantiation code for attributes", OS);
-
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-
-  OS << "namespace clang {\n"
- << "namespace sema {\n\n"
- << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, "
- << "Sema &S,\n"
- << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n"
- << "  switch (At->getKind()) {\n";
+void EmitClangAttrTemplateInstantiateHelper(const std::vector &Attrs,
+raw_ostream &OS,
+bool AppliesToDecl) {
 
+  OS << "  switch (At->getKind()) {\n";
   for (const auto *Attr : Attrs) {
 const Record &R = *Attr;
 if (!R.getValueAsBit("ASTNode"))
   continue;
-
 OS << "case attr::" << R.getName() << ": {\n";
-bool ShouldClone = R.getValueAsBit("Clone");
+bool ShouldClone = R.getValueAsBit("Clone") &&
+   (!AppliesToDecl ||
+R.getValueAsBit("MeaningfulToClassTemplateDefinition"));
 
 if (!ShouldClone) {
   OS << "  return nullptr;\n";
@@ -2507,8 +2500,27 @@
   }
   OS << "  } // end switch\n"
  << "  llvm_unreachable(\"Unknown attribute!\");\n"
- << "  return nullptr;\n"
- << "}\n\n"
+ << "  return nullptr;\n";
+}
+
+// Emits code to instantiate dependent attributes on templates.
+void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
+  emitSourceFileHeader("Template instantiation code for attributes", OS);
+
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+
+  OS << "namespace clang {\n"
+ << "namespace sema {\n\n"
+ << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, "
+ << "Sema &S,\n"
+ << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n";
+  EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*AppliesToDecl*/false);
+  OS << "}\n\n"
+ << "Attr *instantiateTemplateAttributeForDecl(const Attr *At,\n"
+ << " ASTContext &C, Sema &S,\n"
+ << "const MultiLevelTemplateArgumentList &TemplateArgs) {\n";
+  EmitClangAttrTemplateInstantiateHelper(Attrs, OS, /*AppliesToDecl*/true);
+  OS << "}\n\n"
  << "} // end namespace sema\n"
  << "} // end namespace clang\n";
 }
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -7505,6 +7505,12 @@
 LateInstantiatedAttrVec *LateAttrs = nullptr,
 LocalInstantiationScope *OuterMostScope = nullptr);
 
+  void
+  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
+  const Decl *Pattern, Decl *Inst,
+  LateInstantiatedAttrVec *LateAttrs = nullptr,
+  LocalInstantiationScope *OuterMostScope = nullptr);
+
   bool
   InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
ClassTemplateSpecializationDecl *ClassTemplateSpec,
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -302,6 +302,9 @@
   // Set to true if this attribute can be duplicated on a subject when merging
   // attributes. By default, attributes are not merged.
   bit DuplicatesAllowedWhileMerging = 0;
+  // Set to true if this attribute is meaningful when applied to or in

r298410 - Correct class-template deprecation behavior

2017-03-21 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Tue Mar 21 12:49:17 2017
New Revision: 298410

URL: http://llvm.org/viewvc/llvm-project?rev=298410&view=rev
Log:
Correct class-template deprecation behavior

Based on the comment in the test, and my reading of the standard, a deprecated 
warning should be issued in the following case:
template [[deprecated]] class Foo{}; Foo f;

This was not the case, because the ClassTemplateSpecializationDecl creation did 
not also copy the deprecated attribute.

Note: I did NOT audit the complete set of attributes to see WHICH ones should 
be copied, so instead I simply copy ONLY the deprecated attribute.

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
cfe/trunk/test/Sema/attr-deprecated.c
cfe/trunk/test/SemaCXX/attr-deprecated.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
cfe/trunk/test/SemaObjC/special-dep-unavail-warning.m
cfe/trunk/test/SemaObjC/warn-deprecated-implementations.m
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=298410&r1=298409&r2=298410&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Mar 21 12:49:17 2017
@@ -302,6 +302,9 @@ class Attr {
   // Set to true if this attribute can be duplicated on a subject when merging
   // attributes. By default, attributes are not merged.
   bit DuplicatesAllowedWhileMerging = 0;
+  // Set to true if this attribute is meaningful when applied to or inherited 
+  // in a class template definition.
+  bit MeaningfulToClassTemplateDefinition = 0;
   // Lists language options, one of which is required to be true for the
   // attribute to be applicable. If empty, no language options are required.
   list LangOpts = [];
@@ -373,6 +376,7 @@ def AbiTag : Attr {
   let Args = [VariadicStringArgument<"Tags">];
   let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
   "ExpectedStructClassVariableFunctionOrInlineNamespace">;
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [AbiTagsDocs];
 }
 
@@ -805,6 +809,7 @@ def Deprecated : InheritableAttr {
   // An optional string argument that enables us to provide a
   // Fix-It.
   StringArgument<"Replacement", 1>];
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [DeprecatedDocs];
 }
 
@@ -1723,6 +1728,7 @@ def Visibility : InheritableAttr {
   let Args = [EnumArgument<"Visibility", "VisibilityType",
["default", "hidden", "internal", "protected"],
["Default", "Hidden", "Hidden", "Protected"]>];
+  let MeaningfulToClassTemplateDefinition = 1;
   let Documentation = [Undocumented];
 }
 

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=298410&r1=298409&r2=298410&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Mar 21 12:49:17 2017
@@ -7505,6 +7505,12 @@ public:
 LateInstantiatedAttrVec *LateAttrs = nullptr,
 LocalInstantiationScope *OuterMostScope = nullptr);
 
+  void
+  InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs,
+  const Decl *Pattern, Decl *Inst,
+  LateInstantiatedAttrVec *LateAttrs = nullptr,
+  LocalInstantiationScope *OuterMostScope = nullptr);
+
   bool
   InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
ClassTemplateSpecializationDecl *ClassTemplateSpec,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=298410&r1=298409&r2=298410&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Mar 21 12:49:17 2017
@@ -6723,6 +6723,7 @@ static void DoEmitAvailabilityWarning(Se
   // Diagnostics for deprecated or unavailable.
   unsigned diag, diag_message, diag_fwdclass_message;
   unsigned diag_available_here = diag::note_availability_specified_here;
+  SourceLocation NoteLocation = D->getLocation();
 
   // Matches 'diag::note_property_attribute' options.
   unsigned property_note_select;
@@ -6745,6 

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

2017-03-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D30009#706515, @aaron.ballman wrote:

> In https://reviews.llvm.org/D30009#706171, @arphaman wrote:
>
> > I would be ok with that. We could merge `apply_to` and `apply_only_to` into 
> > a single `apply_to` matching rule set specifier (it would behave like 
> > `apply_only_to`).
>
>
> That sounds sensible to me.
>
> > I guess one downside would be is that it will become harder to fill out all 
> > the match rules if one wants to apply an attribute to all possible 
> > declarations. I suppose the attribute documentation generator can be 
> > updated to include the full match rule set for each attribute instead of 
> > just yes/no in the `#pragma clang attribute` documentation column.
>
> Okay, so here's a possibly crazy idea (and it may be way too magical): what 
> if `#pragma clang attribute push(foo)` generated the fix-it hint to suggest 
> all of the targets the attribute can apply to? Alternatively, what if any 
> malformed parsing of `#pragma clang attribute push(foo)` automatically do 
> this? We know the user is trying to apply attributes to declarations, and we 
> know which attribute they're trying for, so it somewhat stands to reason that 
> the rest of the syntax can be supplied for them... and we need *something* in 
> apply_to, so why not default to everything?


Something like that should work. Although we probably still want to have them 
in the documentation as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009



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


[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-03-21 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In https://reviews.llvm.org/D30415#705889, @echristo wrote:

> In https://reviews.llvm.org/D30415#705196, @uweigand wrote:
>
> > Well, mainline GCC doesn't have -faltivec at all and never had, I think 
> > this was only an Apple GCC extension ...  Not sure what exactly the 
> > semantics of that was.
>
>
> Sure it does and has for years. Check out rs6000/darwin.h :)
>
> FWIW: It turns on maltivec and adds a -include of altivec.h


Huh, I wasn't aware of that feature on Darwin, thanks for pointing it out ...

> Nearly all of the code in lib/Driver/ToolChains/Clang.cpp and 
> lib/Driver/ToolChains/Arch/PPC.cpp that deal with altivec. Simplifying the 
> interface by getting rid of needing to check multiple options.

But why would that code no longer be necessary for -maltivec?  Well, I guess 
I'll wait for your patch ...

If we indeed get rid of -faltivec, I'm wondering whether it would also make 
sense to get rid of -fzvector.  This is just an alias for -mzvector, and it 
isn't supported by GCC either.  I added it only because Richard Smith 
specifically asked for it when I contributed the feature here:
https://reviews.llvm.org/D11001

> This should be a -f flag, not a -m flag. (I think we only support -maltivec 
> for GCC compatibility.)




https://reviews.llvm.org/D30415



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


[PATCH] D31174: [X86][MS-compatability] allow MS TYPE/SIZE/LENGTH operators as a part of a compound expression

2017-03-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D31174



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


  1   2   >