Re: [PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

2016-05-09 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:686
@@ -685,3 +685,3 @@
 const Expr *ArgExpr = nullptr;
 if (Idx < Call.getNumArgs())
   ArgExpr = Call.getArgExpr(Idx);

This conditional will assert if:
assert(Arg < NumArgs && "Arg access out of range!");

So removing this conditional will assert in the same cases as the assert you 
are adding.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:696
@@ -695,1 +695,3 @@
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+

Asserting might not be the right thing to do here.


http://reviews.llvm.org/D19962



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


r269005 - [Sema] Fix an overload resolution bug with enable_if.

2016-05-09 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon May  9 20:59:34 2016
New Revision: 269005

URL: http://llvm.org/viewvc/llvm-project?rev=269005&view=rev
Log:
[Sema] Fix an overload resolution bug with enable_if.

Currently, if clang::isBetterOverloadCandidate encounters an enable_if
attribute on either candidate that it's inspecting, it will ignore all
lower priority attributes (e.g. pass_object_size). This is problematic
in cases like:

```
void foo(char *c) __attribute__((enable_if(1, "")));
void foo(char *c __attribute__((pass_object_size(0
__attribute__((enable_if(1, "")));
```

...Because we would ignore the pass_object_size attribute in the second
`foo`, and consider any call to `foo` to be ambiguous.

This patch makes overload resolution consult further tiebreakers (e.g.
pass_object_size) if two candidates have equally good enable_if
attributes.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CodeGen/enable_if.c

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=269005&r1=269004&r2=269005&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon May  9 20:59:34 2016
@@ -8503,16 +8503,31 @@ Sema::AddArgumentDependentLookupCandidat
   }
 }
 
-// Determines whether Cand1 is "better" in terms of its enable_if attrs than
-// Cand2 for overloading. This function assumes that all of the enable_if attrs
-// on Cand1 and Cand2 have conditions that evaluate to true.
-//
-// Cand1's set of enable_if attributes are said to be "better" than Cand2's iff
-// Cand1's first N enable_if attributes have precisely the same conditions as
-// Cand2's first N enable_if attributes (where N = the number of enable_if
-// attributes on Cand2), and Cand1 has more than N enable_if attributes.
-static bool hasBetterEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1,
-   const FunctionDecl *Cand2) {
+namespace {
+enum class Comparison { Equal, Better, Worse };
+}
+
+/// Compares the enable_if attributes of two FunctionDecls, for the purposes of
+/// overload resolution.
+///
+/// Cand1's set of enable_if attributes are said to be "better" than Cand2's 
iff
+/// Cand1's first N enable_if attributes have precisely the same conditions as
+/// Cand2's first N enable_if attributes (where N = the number of enable_if
+/// attributes on Cand2), and Cand1 has more than N enable_if attributes.
+///
+/// Note that you can have a pair of candidates such that Cand1's enable_if
+/// attributes are worse than Cand2's, and Cand2's enable_if attributes are
+/// worse than Cand1's.
+static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl 
*Cand1,
+   const FunctionDecl *Cand2) {
+  // Common case: One (or both) decls don't have enable_if attrs.
+  bool Cand1Attr = Cand1->hasAttr();
+  bool Cand2Attr = Cand2->hasAttr();
+  if (!Cand1Attr || !Cand2Attr) {
+if (Cand1Attr == Cand2Attr)
+  return Comparison::Equal;
+return Cand1Attr ? Comparison::Better : Comparison::Worse;
+  }
 
   // FIXME: The next several lines are just
   // specific_attr_iterator but going in declaration order,
@@ -8520,10 +8535,10 @@ static bool hasBetterEnableIfAttrs(const
   auto Cand1Attrs = getOrderedEnableIfAttrs(Cand1);
   auto Cand2Attrs = getOrderedEnableIfAttrs(Cand2);
 
-  // Candidate 1 is better if it has strictly more attributes and
-  // the common sequence is identical.
-  if (Cand1Attrs.size() <= Cand2Attrs.size())
-return false;
+  // It's impossible for Cand1 to be better than (or equal to) Cand2 if Cand1
+  // has fewer enable_if attributes than Cand2.
+  if (Cand1Attrs.size() < Cand2Attrs.size())
+return Comparison::Worse;
 
   auto Cand1I = Cand1Attrs.begin();
   llvm::FoldingSetNodeID Cand1ID, Cand2ID;
@@ -8535,10 +8550,10 @@ static bool hasBetterEnableIfAttrs(const
 Cand1A->getCond()->Profile(Cand1ID, S.getASTContext(), true);
 Cand2A->getCond()->Profile(Cand2ID, S.getASTContext(), true);
 if (Cand1ID != Cand2ID)
-  return false;
+  return Comparison::Worse;
   }
 
-  return true;
+  return Cand1I == Cand1Attrs.end() ? Comparison::Equal : Comparison::Better;
 }
 
 /// isBetterOverloadCandidate - Determines whether the first overload
@@ -8649,10 +8664,11 @@ bool clang::isBetterOverloadCandidate(Se
   }
 
   // Check for enable_if value-based overload resolution.
-  if (Cand1.Function && Cand2.Function &&
-  (Cand1.Function->hasAttr() ||
-   Cand2.Function->hasAttr()))
-return hasBetterEnableIfAttrs(S, Cand1.Function, Cand2.Function);
+  if (Cand1.Function && Cand2.Function) {
+Comparison Cmp = compareEnableIfAttrs(S, Cand1.Function, Cand2.Function);
+if (Cmp != Comparison::Equal)
+  return Cmp == Comparison::Better;
+  }
 
   if (S.getLangOpts().CUDA && Cand1.Function && Cand2.Function) {
 Function

r269000 - [CUDA] Fix flush-denormals.cu test so that it checks what it intends to CHECK.

2016-05-09 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Mon May  9 19:34:50 2016
New Revision: 269000

URL: http://llvm.org/viewvc/llvm-project?rev=269000&view=rev
Log:
[CUDA] Fix flush-denormals.cu test so that it checks what it intends to CHECK.

FileCheck does not evaluate plain CHECKs if you pass -check-prefix; you
have to ask for it explicitly.

Modified:
cfe/trunk/test/CodeGenCUDA/flush-denormals.cu

Modified: cfe/trunk/test/CodeGenCUDA/flush-denormals.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/flush-denormals.cu?rev=269000&r1=268999&r2=269000&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/flush-denormals.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/flush-denormals.cu Mon May  9 19:34:50 2016
@@ -1,7 +1,9 @@
 // RUN: %clang_cc1 -fcuda-is-device \
-// RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | FileCheck %s 
-check-prefix NOFTZ
+// RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
+// RUN:   FileCheck %s -check-prefix CHECK -check-prefix NOFTZ
 // RUN: %clang_cc1 -fcuda-is-device -fcuda-flush-denormals-to-zero \
-// RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | FileCheck %s 
-check-prefix FTZ
+// RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
+// RUN:   FileCheck %s -check-prefix CHECK -check-prefix FTZ
 
 #include "Inputs/cuda.h"
 
@@ -10,7 +12,7 @@
 // -fcuda-flush-denormals-to-zero.  Further, check that we reflect the presence
 // or absence of -fcuda-flush-denormals-to-zero in a module flag.
 
-// CHECK: define void @foo() #0
+// CHECK-LABEL: define void @foo() #0
 extern "C" __device__ void foo() {}
 
 // FTZ: attributes #0 = {{.*}} "nvptx-f32ftz"="true"


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


Re: [PATCH] D16579: Warn if friend function depends on template parameters.

2016-05-09 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1153
@@ +1152,3 @@
+def warn_non_template_friend : Warning<"friend declaration %q0 depends on "
+  "template parameter but is not a template function">,
+   InGroup;

template function -> function template


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1155-1157
@@ +1154,5 @@
+   InGroup;
+def note_non_template_friend : Note<"if this is intentional, add function "
+  "declaration to suppress the warning, if not - make sure the function "
+  "template has already been declared and use '<>'">;
+def note_befriend_template : Note<"to befriend a template specialization, "

Rather than this long conditional note, how about producing two notes here:

  note: declare function outside class template to suppress this warning
  note: use '<>' to befriend a template specialization


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1158-1159
@@ -1152,1 +1157,4 @@
+  "template has already been declared and use '<>'">;
+def note_befriend_template : Note<"to befriend a template specialization, "
+  "use '<>'">;
 

This note should also point out that you need to declare the function template 
prior to the class template.


Comment at: include/clang/Sema/Sema.h:9342
@@ +9341,3 @@
+  /// of proper templates, but they are needed for checks.
+  llvm::DenseSet FriendsOfTemplates;
+

This will produce diagnostics in a nondeterministic order, and you have no need 
of a set because there can never be any duplicates. Just use a `SmallVector`?


Comment at: include/clang/Sema/Sema.h:9342
@@ +9341,3 @@
+  /// of proper templates, but they are needed for checks.
+  llvm::DenseSet FriendsOfTemplates;
+

rsmith wrote:
> This will produce diagnostics in a nondeterministic order, and you have no 
> need of a set because there can never be any duplicates. Just use a 
> `SmallVector`?
You're missing serialization code for this for the PCH / preamble case.


Comment at: include/clang/Sema/Sema.h:9344-9345
@@ +9343,4 @@
+
+  /// \brief Check dependent friends functions for misinterpretation as 
template
+  /// ones.
+  void CheckDependentFriends();

friends -> friend
template ones -> function templates


Comment at: lib/Sema/SemaChecking.cpp:10468
@@ +10467,3 @@
+/// function types.
+class FunctionMatcher : public TypeVisitor {
+  const Type *InstType;

This is a huge amount of complexity and maintenance burden for this check, and 
it still seems to some important cases wrong. Is there a simpler way we can get 
a largely-equivalent result? Or maybe we can just unconditionally produce both 
notes?


Comment at: lib/Sema/SemaChecking.cpp:10700
@@ +10699,2 @@
+  }
+}

`FriendsOfTemplates.clear()` here?


Comment at: lib/Sema/SemaDecl.cpp:8502-8507
@@ -8501,1 +8501,8 @@
 
+  if (isFriend && !NewFD->isInvalidDecl()) {
+if (TemplateParamLists.empty() && !DC->isRecord() &&
+!isFunctionTemplateSpecialization) {
+  FriendsOfTemplates.insert(NewFD);
+}
+  }
+

This should also be conditioned on the function having a dependent type and 
this declaration not being a definition -- this will add all non-template 
friends to `FriendsOfTemplates`, whether they're friends of a class template or 
not.


http://reviews.llvm.org/D16579



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


Re: [Clang] Convergent Attribute

2016-05-09 Thread Hal Finkel via cfe-commits
- Original Message -

> From: "Richard Smith via cfe-commits" 
> To: "Matt Arsenault" 
> Cc: "Clang Commits" 
> Sent: Monday, May 9, 2016 4:45:04 PM
> Subject: Re: [Clang] Convergent Attribute

> On Mon, May 9, 2016 at 2:43 PM, Richard Smith < rich...@metafoo.co.uk
> > wrote:

> > On Sun, May 8, 2016 at 12:43 PM, Matt Arsenault via cfe-commits <
> > cfe-commits@lists.llvm.org > wrote:
> 

> > > > On May 6, 2016, at 18:12, Richard Smith via cfe-commits <
> > > > cfe-commits@lists.llvm.org > wrote:
> > > 
> > 
> 

> > > > On Fri, May 6, 2016 at 4:20 PM, Matt Arsenault via cfe-commits
> > > > <
> > > > cfe-commits@lists.llvm.org > wrote:
> > > 
> > 
> 

> > > > > On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
> > > > 
> > > 
> > 
> 

> > > > > > This example looks wrong to me. It doesn't seem meaningful
> > > > > > for
> > > > > > a
> > > > > > function to be both readonly and convergent, because
> > > > > > convergent
> > > > > > means the call has some side-effect visible to other
> > > > > > threads
> > > > > > and
> > > > > > readonly means the call has no side-effects visible outside
> > > > > > the
> > > > > > function.
> > > > > 
> > > > 
> > > 
> > 
> 

> > > > > This s not correct. It is valid for convergent operations to
> > > > > be
> > > > > readonly/readnone. Barriers are a common case which do have
> > > > > side
> > > > > effects, but there are also classes of GPU instructions which
> > > > > do
> > > > > not
> > > > > access memory and still need the convergent semantics.
> > > > 
> > > 
> > 
> 

> > > > Can you give an example? It's not clear to me how a function
> > > > could
> > > > be
> > > > both convergent and satisfy the readnone requirement that it
> > > > not
> > > > "access[...] any mutable state (e.g. memory, control registers,
> > > > etc)
> > > > visible to caller functions". Synchronizing with other threads
> > > > seems
> > > > like it would cause such a state change in an abstract sense.
> > > > Is
> > > > the
> > > > critical distinction here that the state mutation is visible to
> > > > the
> > > > code that spawned the gang of threads, but not to other threads
> > > > within the gang? (This seems like a bug in the definition of
> > > > readonly if so, because it means that a readonly call whose
> > > > result
> > > > is unused cannot be deleted.)
> > > 
> > 
> 

> > > > I care about this because Clang maps __attribute__((pure)) to
> > > > LLVM
> > > > readonly, and -- irrespective of the LLVM semantics -- a call
> > > > to
> > > > a
> > > > function marked pure is permitted to be deleted if the return
> > > > value
> > > > is unused, or to have multiple calls CSE'd. As a result, inside
> > > > Clang, we use that attribute to determine whether an expression
> > > > has
> > > > side effects, and Clang's reasoning about these things may also
> > > > lead
> > > > to miscompiles if a call to a function marked
> > > > __attribute__((pure,
> > > > convergent)) actually can have a side effect.
> > > > ___
> > > 
> > 
> 
> > > > cfe-commits mailing list
> > > 
> > 
> 
> > > > cfe-commits@lists.llvm.org
> > > 
> > 
> 
> > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > > 
> > 
> 

> > > These are communication operations between lanes that do not
> > > require
> > > synchronization within the wavefront. These are mostly cross lane
> > > communication instructions. An example would be the
> > > amdgcn.mov.dpp
> > > instruction, which reads a register from a neighboring lane, or
> > > the
> > > CUDA warp vote functions.
> > 
> 
> > Those both appear to technically fail to satisfy the requirements
> > of
> > an __attribute__((pure)) function. If I understand correctly, the
> > DPP function effectively stores a value into some state that is
> > shared with another lane (from Clang and LLVM's perspectives, state
> > that is visible to a function evaluation outside the current one),
> > and then reads a value from another such shared storage location.
> > The CUDA warp vote functions effectively store a value into some
> > state that is shared with all other threads in the warp and then
> > read some summary information about the values stored by all the
> > threads. In both cases, the function mutates state that is visible
> > to other functions running on other threads, and so is not
> > __attribute__((pure)) / readonly, as far as I can see.
> 
> (And just to be clear, the fact that no actual storage is used for
> this is irrelevant to the notional semantics of the operation. Note
> that the definition of the pure attribute also covers "control
> registers, etc".)

> > It seems to me that this change weakens the definition of these
> > attributes when combined with the convergent attribute to mean that
> > the function *is* still allowed to store to mutable state that's
> > shared with other lanes / other threads in the same warp, but only
> > via convergent combined store/load primitives. That makes som

Re: [Clang] Convergent Attribute

2016-05-09 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Anastasia Stulova via cfe-commits" 
> To: "Matt Arsenault" , "Ettore Speziale" 
> , "Aaron Ballman"
> 
> Cc: "nd" , "Clang Commits" 
> Sent: Monday, May 9, 2016 12:39:19 PM
> Subject: RE: [Clang] Convergent Attribute
> 
> Since it's not a part of any official spec we could of course make it
> accepted with anything.
> 
> Just out of curiosity what other programming models supported by
> Clang do you think this attribute would be useful for?

CUDA? In any case, I don't see how the restriction helps users, and the 
attribute at the IR level has a well-defined meaning regardless. If a user were 
to have a use case, they'd simply find the restriction arbitrary and 
frustrating.

 -Hal

> 
> Anastasia
> 
> -Original Message-
> From: Matt Arsenault [mailto:matthew.arsena...@amd.com]
> Sent: 07 May 2016 00:37
> To: Anastasia Stulova; Ettore Speziale; Aaron Ballman
> Cc: nd; Clang Commits
> Subject: Re: [Clang] Convergent Attribute
> 
> On 05/06/2016 12:11 PM, Anastasia Stulova via cfe-commits wrote:
> > I was just wondering whether it would make sense to restrict the
> > usage of the attribute to OpenCL language i.e. to add  "let
> > LangOpts = [OpenCL];" in the attribute definition.
> This seems to be a pointless arbitrary restriction to me
> 
> -Matt
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
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


Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Richard Smith via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Committed as http://reviews.llvm.org/rL268988.


http://reviews.llvm.org/D20040



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


r268988 - When forming a fully-qualified type name, put any qualifiers outside/before the

2016-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May  9 18:06:14 2016
New Revision: 268988

URL: http://llvm.org/viewvc/llvm-project?rev=268988&view=rev
Log:
When forming a fully-qualified type name, put any qualifiers outside/before the
nested-name-specifier. Patch by Sterling Augustine!

Modified:
cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp
cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp

Modified: cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp?rev=268988&r1=268987&r2=268988&view=diff
==
--- cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp Mon May  9 18:06:14 2016
@@ -383,10 +383,15 @@ QualType getFullyQualifiedType(QualType
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the QualType outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
+  QT = QualType(QT.getTypePtr(), 0);
   ElaboratedTypeKeyword Keyword = ETK_None;
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
+assert(!QT.hasLocalQualifiers());
 Keyword = ETypeInput->getKeyword();
   }
   // Create a nested name specifier if needed (i.e. if the decl context
@@ -394,28 +399,21 @@ QualType getFullyQualifiedType(QualType
   Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(),
true /*FullyQualified*/);
 
-  // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
-QT = QualType(QT.getTypePtr(), 0);
-  }
-
   // In case of template specializations iterate over the arguments and
   // fully qualify them as well.
   if (isa(QT.getTypePtr()) ||
   isa(QT.getTypePtr())) {
 // We are asked to fully qualify and we have a Record Type (which
-// may pont to a template specialization) or Template
+// may point to a template specialization) or Template
 // Specialization Type. We need to fully qualify their arguments.
 
-Qualifiers Quals = QT.getLocalQualifiers();
 const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr());
-QT = Ctx.getQualifiedType(TypePtr, Quals);
+QT = QualType(TypePtr, 0);
   }
   if (Prefix || Keyword != ETK_None) {
 QT = Ctx.getElaboratedType(Keyword, Prefix, QT);
-QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   }
+  QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   return QT;
 }
 

Modified: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp?rev=268988&r1=268987&r2=268988&view=diff
==
--- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Mon May  9 18:06:14 2016
@@ -88,6 +88,8 @@ TEST(QualTypeNameTest, getFullyQualified
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
+  Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +110,7 @@ TEST(QualTypeNameTest, getFullyQualified
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
@@ -123,6 +126,8 @@ TEST(QualTypeNameTest, getFullyQualified
   "void f() {\n"
   "  struct X {} CheckH;\n"
   "}\n"
+  "struct X;\n"
+  "void f(const ::X* CheckN) {}\n"
   "namespace {\n"
   "  class aClass {};\n"
   "   aClass CheckI;\n"


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


Re: [PATCH] D18182: [test] Don't use UNSUPPORTED in FileCheck prefixes

2016-05-09 Thread Simon Pilgrim via cfe-commits
RKSimon closed this revision.
RKSimon added a comment.

Fixed in http://reviews.llvm.org/rL265218


http://reviews.llvm.org/D18182



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


Re: [PATCH] D19403: Add loop pragma for Loop Distribution

2016-05-09 Thread Adam Nemet via cfe-commits
anemet added a comment.

Ping.

(I am getting a bit concerned that because this was already marked accepted, it 
does not show up @rsmith' active queue...)


http://reviews.llvm.org/D19403



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


Re: [PATCH] D19796: Add new intrinsic support for MONITORX and MWAITX instructions.

2016-05-09 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

LGTM.

Thanks.

-eric


http://reviews.llvm.org/D19796



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


Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Sterling Augustine via cfe-commits
saugustine updated this revision to Diff 56643.
saugustine marked 4 inline comments as done.
saugustine added a comment.

- Address remaining nits from review.


http://reviews.llvm.org/D20040

Files:
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,8 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
+  Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +110,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
@@ -123,6 +126,8 @@
   "void f() {\n"
   "  struct X {} CheckH;\n"
   "}\n"
+  "struct X;\n"
+  "void f(const ::X* CheckN) {}\n"
   "namespace {\n"
   "  class aClass {};\n"
   "   aClass CheckI;\n"
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,39 +383,37 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the QualType outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
+  QT = QualType(QT.getTypePtr(), 0);
   ElaboratedTypeKeyword Keyword = ETK_None;
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
+assert(!QT.hasLocalQualifiers());
 Keyword = ETypeInput->getKeyword();
   }
   // Create a nested name specifier if needed (i.e. if the decl context
   // is not the global scope.
   Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(),
true /*FullyQualified*/);
 
-  // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
-QT = QualType(QT.getTypePtr(), 0);
-  }
-
   // In case of template specializations iterate over the arguments and
   // fully qualify them as well.
   if (isa(QT.getTypePtr()) ||
   isa(QT.getTypePtr())) {
 // We are asked to fully qualify and we have a Record Type (which
-// may pont to a template specialization) or Template
+// may point to a template specialization) or Template
 // Specialization Type. We need to fully qualify their arguments.
 
-Qualifiers Quals = QT.getLocalQualifiers();
 const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr());
-QT = Ctx.getQualifiedType(TypePtr, Quals);
+QT = QualType(TypePtr, 0);
   }
   if (Prefix || Keyword != ETK_None) {
 QT = Ctx.getElaboratedType(Keyword, Prefix, QT);
-QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   }
+  QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   return QT;
 }
 


Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,8 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
+  Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +110,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
@@ -123,6 +126,8 @@
   "void f() {\n"
   "  struct X {} CheckH;\n"
   "}\n"
+  "struct X;\n"
+  "void f(const ::X* CheckN) {}\n"
   "namespace {\n"
   "  class aClass {};\n"
   "   aClass CheckI;\n"
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,39 +383,37 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the QualType outside of the
+  // elaborated type.  R

Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Sterling Augustine via cfe-commits
saugustine added a comment.

Thanks again. I've addressed the last little bits. Mind checking this in for me?


http://reviews.llvm.org/D20040



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


r268982 - [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-09 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon May  9 17:09:56 2016
New Revision: 268982

URL: http://llvm.org/viewvc/llvm-project?rev=268982&view=rev
Log:
[CUDA] Restrict init of local __shared__ variables to empty constructors only.

Allow only empty constructors for local __shared__ variables in a way
identical to restrictions imposed on dynamic initializers for global
variables on device.

Differential Revision: http://reviews.llvm.org/D20039

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCUDA/address-spaces.cu
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=268982&r1=268981&r2=268982&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon May  9 17:09:56 2016
@@ -371,8 +371,15 @@ void CodeGenFunction::EmitStaticVarDecl(
 
   llvm::GlobalVariable *var =
 cast(addr->stripPointerCasts());
+
+  // CUDA's local and local static __shared__ variables should not
+  // have any non-empty initializers. This is ensured by Sema.
+  // Whatever initializer such variable may have when it gets here is
+  // a no-op and should not be emitted.
+  bool isCudaSharedVar = getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+ D.hasAttr();
   // If this value has an initializer, emit it.
-  if (D.getInit())
+  if (D.getInit() && !isCudaSharedVar)
 var = AddInitializerToStaticVarDecl(D, var);
 
   var->setAlignment(alignment.getQuantity());
@@ -1874,4 +1881,3 @@ void CodeGenModule::EmitOMPDeclareReduct
 return;
   getOpenMPRuntime().emitUserDefinedReduction(CGF, D);
 }
-

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268982&r1=268981&r2=268982&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May  9 17:09:56 2016
@@ -10414,14 +10414,15 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 
   // Perform check for initializers of device-side global variables.
   // CUDA allows empty constructors as initializers (see E.2.3.1, CUDA
-  // 7.5). CUDA also allows constant initializers for __constant__ and
-  // __device__ variables.
+  // 7.5). We must also apply the same checks to all __shared__
+  // variables whether they are local or not. CUDA also allows
+  // constant initializers for __constant__ and __device__ variables.
   if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
 const Expr *Init = VD->getInit();
-const bool IsGlobal = VD->hasGlobalStorage() && !VD->isStaticLocal();
-if (Init && IsGlobal &&
+if (Init && VD->hasGlobalStorage() &&
 (VD->hasAttr() || VD->hasAttr() ||
  VD->hasAttr())) {
+  assert((!VD->isStaticLocal() || VD->hasAttr()));
   bool AllowedInit = false;
   if (const CXXConstructExpr *CE = dyn_cast(Init))
 AllowedInit =

Modified: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/address-spaces.cu?rev=268982&r1=268981&r2=268982&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu Mon May  9 17:09:56 2016
@@ -25,8 +25,6 @@ struct MyStruct {
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @b = addrspace(3) global float undef
-// CHECK: @c = addrspace(3) global %struct.c undef
-// CHECK  @d = addrspace(3) global %struct.d undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)
@@ -94,32 +92,3 @@ __device__ float *func5() {
 }
 // CHECK: define float* @_Z5func5v()
 // CHECK: ret float* addrspacecast (float addrspace(3)* @b to float*)
-
-struct StructWithCtor {
-  __device__ StructWithCtor(): data(1) {}
-  __device__ StructWithCtor(const StructWithCtor &second): data(second.data) {}
-  __device__ int getData() { return data; }
-  int data;
-};
-
-__device__ int construct_shared_struct() {
-// CHECK-LABEL: define i32 @_Z23construct_shared_structv()
-  __shared__ StructWithCtor s;
-// CHECK: call void @_ZN14StructWithCtorC1Ev(%struct.StructWithCtor* 
addrspacecast (%struct.StructWithCtor addrspace(3)* 
@_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
-  __shared__ StructWithCtor t(s);
-// CHECK: call void @_ZN14StructWithCtorC1ERKS_(%struct.StructWithCtor* 
addrspacecast (%struct.StructWithCtor addrspace(3)* 
@_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*), 
%struct.StructWithCtor* dereferenceable(4) addrspacecast 
(%struct.StructWithCtor addrspace(3)* @_Z

Re: [PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-09 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268982: [CUDA] Restrict init of local __shared__ variables 
to empty constructors only. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20039?vs=56619&id=56642#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20039

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCUDA/address-spaces.cu
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -63,6 +63,8 @@
 
 // static in-class field initializer.  NVCC does not allow it, but
 // clang generates static initializer for this, so we'll accept it.
+// We still can't use it on __shared__ vars as they don't allow *any*
+// initializers.
 struct NCFS {
   int ncfs = 3;
 };
@@ -367,8 +369,13 @@
   T_B_NEC t_b_nec;
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
-  static __shared__ UC s_uc;
+  static __shared__ EC s_ec;
+  static __shared__ ETC s_etc;
 #if ERROR_CASE
+  static __shared__ NCFS s_ncfs;
+  // expected-error@-1 {{initialization is not supported for __shared__ variables.}}
+  static __shared__ UC s_uc;
+  // expected-error@-1 {{initialization is not supported for __shared__ variables.}}
   static __device__ int ds;
   // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
   static __constant__ int dc;
@@ -394,7 +401,8 @@
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
-// CHECK:   call void @_ZN2UCC1Ev(%struct.UC* addrspacecast (%struct.UC addrspace(3)* @_ZZ2dfvE4s_uc to %struct.UC*))
+// CHECK-NOT: call void @_ZN2ECC1Ev(%struct.EC* addrspacecast (%struct.EC addrspace(3)* @_ZZ2dfvE4s_ec to %struct.EC*))
+// CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*))
 // CHECK: ret void
 
 // We should not emit global init function.
Index: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
===
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu
@@ -25,8 +25,6 @@
 // CHECK: @_ZZ5func3vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @_ZZ5func4vE1a = internal addrspace(3) global float 0.00e+00
 // CHECK: @b = addrspace(3) global float undef
-// CHECK: @c = addrspace(3) global %struct.c undef
-// CHECK  @d = addrspace(3) global %struct.d undef
 
 __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @i to i32*)
@@ -94,32 +92,3 @@
 }
 // CHECK: define float* @_Z5func5v()
 // CHECK: ret float* addrspacecast (float addrspace(3)* @b to float*)
-
-struct StructWithCtor {
-  __device__ StructWithCtor(): data(1) {}
-  __device__ StructWithCtor(const StructWithCtor &second): data(second.data) {}
-  __device__ int getData() { return data; }
-  int data;
-};
-
-__device__ int construct_shared_struct() {
-// CHECK-LABEL: define i32 @_Z23construct_shared_structv()
-  __shared__ StructWithCtor s;
-// CHECK: call void @_ZN14StructWithCtorC1Ev(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
-  __shared__ StructWithCtor t(s);
-// CHECK: call void @_ZN14StructWithCtorC1ERKS_(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*), %struct.StructWithCtor* dereferenceable(4) addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
-  return t.getData();
-// CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
-}
-
-// Make sure we allow __shared__ structures with default or empty constructors.
-struct c {
-  int i;
-};
-__shared__ struct c c;
-
-struct d {
-  int i;
-  d() {}
-};
-__shared__ struct d d;
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -10414,14 +10414,15 @@
 
   // Perform check for initializers of device-side global variables.
   // CUDA allows empty constructors as initializers (see E.2.3.1, CUDA
-  // 7.5). CUDA also allows constant initializers for __constant__ and
-  // __device__ variables.
+  // 7.5). We must also apply the same checks to all __shared__
+  // variables whether they are local or not. CUDA also allows
+  // constant initializers for __constan

Re: [PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-09 Thread Artem Belevich via cfe-commits
tra added a comment.

In http://reviews.llvm.org/D20039#424067, @jlebar wrote:

> While I think this is 100% the right thing to do, I am worried about breaking 
> existing targets.  Maybe we need an escape valve, at least until we get that 
> sorted out?  Unless you're pretty confident this isn't happening / will be 
> easy enough to fix.


While empty constructors for __shared__ variables are not unusual, I haven't 
seen any non-empty constructors in practice.
Considering that such constructor would crash clang until this patch, it would 
be hard to miss such cases.

Escape hatch would require to make clang to do something reasonable. 
Currently llvm crashes because we attempt to generate a load from a guard 
variable using atomic load instruction that's not supported by NVPTX backend. 
Even if it was supported, we'd also need to implement 
_cxa_guard_acquire/release.

We can disable thread-safe guard variants. This will be broken, too, because 
there will be many per-block instances of the variable, but only one global 
guard.

We can spend an effort to do the same thing as nvcc -- no guard of any kind, 
ctor/dtor on function entry/exit and compiler warning about guaranteed data 
race, but I don't see much point doing *that*.

IMO fixing the source code to initialize static variable explicitly would be 
the right thing to do.


http://reviews.llvm.org/D20039



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


Re: [PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-09 Thread Justin Lebar via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Art makes the good point that any code which is broken by this change is itself 
currently racy at the very best.  And we have a way to fix any code which hits 
this new error (just manually initialize your shared variable using placement 
new from within thread 0).  So, lgtm.


http://reviews.llvm.org/D20039



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


Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM with a couple of minor tweaks, thanks!



Comment at: lib/Tooling/Core/QualTypeNames.cpp:400-401
@@ -395,8 +399,4 @@
true /*FullyQualified*/);
 
-  // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
-QT = QualType(QT.getTypePtr(), 0);
-  }
+  QT = QualType(QT.getTypePtr(), 0);
 

Sure, building the elaborated type should still be conditional on there being 
one to build :)

`const X *` looks correct to me for your new example (I think with the old code 
we'd have got just `X *`).


Comment at: lib/Tooling/Core/QualTypeNames.cpp:401
@@ -396,7 +400,3 @@
 
-  // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
-QT = QualType(QT.getTypePtr(), 0);
-  }
+  QT = QualType(QT.getTypePtr(), 0);
 

Please move this up to immediately after line 389, so that we have a single 
point where we split `QT` into a type pointer and qualifiers.


Comment at: lib/Tooling/Core/QualTypeNames.cpp:408
@@ -407,3 +407,3 @@
 // We are asked to fully qualify and we have a Record Type (which
 // may pont to a template specialization) or Template
 // Specialization Type. We need to fully qualify their arguments.

Maybe pont -> point while you're here :)


Comment at: lib/Tooling/Core/QualTypeNames.cpp:412
@@ -412,3 +411,3 @@
 const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr());
-QT = Ctx.getQualifiedType(TypePtr, Quals);
+QT = Ctx.getQualifiedType(TypePtr, Qualifiers());
   }

`QT = QualType(TypePtr, 0);` would be fine here.


http://reviews.llvm.org/D20040



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


Some of the builders will go off-line for short time during the current week

2016-05-09 Thread Galina Kistanova via cfe-commits
Hello everyone,

In the nearest time I am going to take few builders off line one by one for
short time for upgrades.
Thank you for understanding.

Thanks

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


Re: [Clang] Convergent Attribute

2016-05-09 Thread Richard Smith via cfe-commits
On Mon, May 9, 2016 at 2:43 PM, Richard Smith  wrote:

> On Sun, May 8, 2016 at 12:43 PM, Matt Arsenault via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On May 6, 2016, at 18:12, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> On Fri, May 6, 2016 at 4:20 PM, Matt Arsenault via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
>>>
 This example looks wrong to me. It doesn't seem meaningful for a
 function to be both readonly and convergent, because convergent means the
 call has some side-effect visible to other threads and readonly means the
 call has no side-effects visible outside the function.

>>> This s not correct. It is valid for convergent operations to be
>>> readonly/readnone. Barriers are a common case which do have side effects,
>>> but there are also classes of GPU instructions which do not access memory
>>> and still need the convergent semantics.
>>>
>>
>> Can you give an example? It's not clear to me how a function could be
>> both convergent and satisfy the readnone requirement that it not
>> "access[...] any mutable state (e.g. memory, control registers, etc)
>> visible to caller functions". Synchronizing with other threads seems like
>> it would cause such a state change in an abstract sense. Is the critical
>> distinction here that the state mutation is visible to the code that
>> spawned the gang of threads, but not to other threads within the gang?
>> (This seems like a bug in the definition of readonly if so, because it
>> means that a readonly call whose result is unused cannot be deleted.)
>>
>> I care about this because Clang maps __attribute__((pure)) to LLVM
>> readonly, and -- irrespective of the LLVM semantics -- a call to a function
>> marked pure is permitted to be deleted if the return value is unused, or to
>> have multiple calls CSE'd. As a result, inside Clang, we use that attribute
>> to determine whether an expression has side effects, and Clang's reasoning
>> about these things may also lead to miscompiles if a call to a function
>> marked __attribute__((pure, convergent)) actually can have a side effect.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>> These are communication operations between lanes that do not require
>> synchronization within the wavefront. These are mostly cross lane
>> communication instructions. An example would be the amdgcn.mov.dpp
>> instruction, which reads a register from a neighboring lane, or the CUDA
>> warp vote functions.
>>
>
> Those both appear to technically fail to satisfy the requirements of an
> __attribute__((pure)) function. If I understand correctly, the DPP function
> effectively stores a value into some state that is shared with another lane
> (from Clang and LLVM's perspectives, state that is visible to a function
> evaluation outside the current one), and then reads a value from another
> such shared storage location. The CUDA warp vote functions effectively
> store a value into some state that is shared with all other threads in the
> warp and then read some summary information about the values stored by all
> the threads. In both cases, the function mutates state that is visible to
> other functions running on other threads, and so is not
> __attribute__((pure)) / readonly, as far as I can see.
>

(And just to be clear, the fact that no actual storage is used for this is
irrelevant to the notional semantics of the operation. Note that the
definition of the pure attribute also covers "control registers, etc".)


> It seems to me that this change weakens the definition of these attributes
> when combined with the convergent attribute to mean that the function *is*
> still allowed to store to mutable state that's shared with other lanes /
> other threads in the same warp, but only via convergent combined store/load
> primitives. That makes some sense, given that the behavior of the
> *execution* model does not (necessarily) treat each notional lane as a
> separate thread, and from that perspective the instruction can be viewed as
> operating on a vector and communicating only with itself, but it doesn't
> match the current definitions of the semantics of these attributes (which
> are specified in terms of the *source* model, in which each notional lane
> is a separate invocation of the function). So I'd like at least for some
> documentation to be added for our "pure" and "const" attributes, saying
> something like "if this is combined with the "convergent" attribute, the
> function may still communicate with other lanes through convergent
> operations, even though such communication notionally involves modification
> of mutable state visible to the other lanes". I'd suggest a similar change
> also be made to LLVM's LangRef.
>
>
> I've checked through how clang is u

Re: [Clang] Convergent Attribute

2016-05-09 Thread Richard Smith via cfe-commits
On Sun, May 8, 2016 at 12:43 PM, Matt Arsenault via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On May 6, 2016, at 18:12, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> On Fri, May 6, 2016 at 4:20 PM, Matt Arsenault via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On 05/06/2016 02:42 PM, David Majnemer via cfe-commits wrote:
>>
>>> This example looks wrong to me. It doesn't seem meaningful for a
>>> function to be both readonly and convergent, because convergent means the
>>> call has some side-effect visible to other threads and readonly means the
>>> call has no side-effects visible outside the function.
>>>
>> This s not correct. It is valid for convergent operations to be
>> readonly/readnone. Barriers are a common case which do have side effects,
>> but there are also classes of GPU instructions which do not access memory
>> and still need the convergent semantics.
>>
>
> Can you give an example? It's not clear to me how a function could be both
> convergent and satisfy the readnone requirement that it not "access[...]
> any mutable state (e.g. memory, control registers, etc) visible to caller
> functions". Synchronizing with other threads seems like it would cause such
> a state change in an abstract sense. Is the critical distinction here that
> the state mutation is visible to the code that spawned the gang of threads,
> but not to other threads within the gang? (This seems like a bug in the
> definition of readonly if so, because it means that a readonly call whose
> result is unused cannot be deleted.)
>
> I care about this because Clang maps __attribute__((pure)) to LLVM
> readonly, and -- irrespective of the LLVM semantics -- a call to a function
> marked pure is permitted to be deleted if the return value is unused, or to
> have multiple calls CSE'd. As a result, inside Clang, we use that attribute
> to determine whether an expression has side effects, and Clang's reasoning
> about these things may also lead to miscompiles if a call to a function
> marked __attribute__((pure, convergent)) actually can have a side effect.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
> These are communication operations between lanes that do not require
> synchronization within the wavefront. These are mostly cross lane
> communication instructions. An example would be the amdgcn.mov.dpp
> instruction, which reads a register from a neighboring lane, or the CUDA
> warp vote functions.
>

Those both appear to technically fail to satisfy the requirements of an
__attribute__((pure)) function. If I understand correctly, the DPP function
effectively stores a value into some state that is shared with another lane
(from Clang and LLVM's perspectives, state that is visible to a function
evaluation outside the current one), and then reads a value from another
such shared storage location. The CUDA warp vote functions effectively
store a value into some state that is shared with all other threads in the
warp and then read some summary information about the values stored by all
the threads. In both cases, the function mutates state that is visible to
other functions running on other threads, and so is not
__attribute__((pure)) / readonly, as far as I can see.

It seems to me that this change weakens the definition of these attributes
when combined with the convergent attribute to mean that the function *is*
still allowed to store to mutable state that's shared with other lanes /
other threads in the same warp, but only via convergent combined store/load
primitives. That makes some sense, given that the behavior of the
*execution* model does not (necessarily) treat each notional lane as a
separate thread, and from that perspective the instruction can be viewed as
operating on a vector and communicating only with itself, but it doesn't
match the current definitions of the semantics of these attributes (which
are specified in terms of the *source* model, in which each notional lane
is a separate invocation of the function). So I'd like at least for some
documentation to be added for our "pure" and "const" attributes, saying
something like "if this is combined with the "convergent" attribute, the
function may still communicate with other lanes through convergent
operations, even though such communication notionally involves modification
of mutable state visible to the other lanes". I'd suggest a similar change
also be made to LLVM's LangRef.


I've checked through how clang is using the "pure" attribute, and it seems
like it should mostly do the right thing in this case. There are a few
places where (using your amdgcn.mov.dpp example) we would cause a dpp
instruction to be emitted where the source code called the relevant
operation from within an operand that we do not notionally evaluate (for
instance, the operand of a __assume or __builtin_object_size). Cont

Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Sterling Augustine via cfe-commits
saugustine added a comment.

Thanks for the reviews. I believe I have addressed all issues. Take another 
look when you get the chance.



Comment at: lib/Tooling/Core/QualTypeNames.cpp:401-403
@@ -397,6 +400,5 @@
   // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
+  if (Prefix || Keyword != ETK_None) {
 QT = QualType(QT.getTypePtr(), 0);
   }
 

rsmith wrote:
> I find the way this code ensures that we preserve the qualifiers to be a 
> little subtle. It's not obvious to me that this does the right thing for a 
> case like
> 
> struct X;
> void f(const ::X x) {}
> 
> ... where we have an `ElaboratedType` with no keyword, and for which we will 
> generate an empty `Prefix` -- it looks like we would lose the `const` on line 
> 392 and never add it back.
> 
> Can you remove and re-add the qualifiers unconditionally? (That is, move this 
> removal of qualifiers from `QT` to after line 389, and move line 419 outside 
> the `if`.) I think that'll make the logic clearer.
We can remove and put them back unconditionally, but we still need to condition 
getting a new elaborated type, because an assertion prevents creating an 
elaborated type without a prefix of an empty keyword.

I'm not sure what you expect on the new example, but I have added it as a test 
case (as a pointer because the struct is incomplete). The result we produce in 
this case is "const X *", which I think is correct.


Comment at: unittests/Tooling/QualTypeNamesTest.cpp:91
@@ -90,2 +90,3 @@
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
   Visitor.runOver(

dblaikie wrote:
> What does this produce without your change? (what's the change causing to 
> happen?)
Without the change, we get "A::B::Class0 *"  with no "const".


http://reviews.llvm.org/D20040



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


Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Sterling Augustine via cfe-commits
saugustine updated this revision to Diff 56634.
saugustine marked an inline comment as done.
saugustine added a comment.

- Handle elaborated types even more cleanly.


http://reviews.llvm.org/D20040

Files:
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,8 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
+  Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +110,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
@@ -123,6 +126,8 @@
   "void f() {\n"
   "  struct X {} CheckH;\n"
   "}\n"
+  "struct X;\n"
+  "void f(const ::X* CheckN) {}\n"
   "namespace {\n"
   "  class aClass {};\n"
   "   aClass CheckI;\n"
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,22 +383,22 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the QualType outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
   ElaboratedTypeKeyword Keyword = ETK_None;
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
+assert(!QT.hasLocalQualifiers());
 Keyword = ETypeInput->getKeyword();
   }
   // Create a nested name specifier if needed (i.e. if the decl context
   // is not the global scope.
   Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(),
true /*FullyQualified*/);
 
-  // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
-QT = QualType(QT.getTypePtr(), 0);
-  }
+  QT = QualType(QT.getTypePtr(), 0);
 
   // In case of template specializations iterate over the arguments and
   // fully qualify them as well.
@@ -408,14 +408,13 @@
 // may pont to a template specialization) or Template
 // Specialization Type. We need to fully qualify their arguments.
 
-Qualifiers Quals = QT.getLocalQualifiers();
 const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr());
-QT = Ctx.getQualifiedType(TypePtr, Quals);
+QT = Ctx.getQualifiedType(TypePtr, Qualifiers());
   }
   if (Prefix || Keyword != ETK_None) {
 QT = Ctx.getElaboratedType(Keyword, Prefix, QT);
-QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   }
+  QT = Ctx.getQualifiedType(QT, PrefixQualifiers);
   return QT;
 }
 


Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -88,6 +88,8 @@
   "Foo::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
+  Visitor.ExpectedQualTypeNames["CheckN"] = "const X *";
   Visitor.runOver(
   "int CheckInt;\n"
   "template \n"
@@ -108,6 +110,7 @@
   "  AnotherClass> CheckC);\n"
   "   void Function2(Template0,\n"
   "Template0 > CheckD);\n"
+  "   void Function3(const B::Class0* CheckM);\n"
   "  }\n"
   "template class Variadic {};\n"
   "Variadic, "
@@ -123,6 +126,8 @@
   "void f() {\n"
   "  struct X {} CheckH;\n"
   "}\n"
+  "struct X;\n"
+  "void f(const ::X* CheckN) {}\n"
   "namespace {\n"
   "  class aClass {};\n"
   "   aClass CheckI;\n"
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -383,22 +383,22 @@
   }
 
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the QualType outside of the
+  // elaborated type.  Retrieve them before descending into the
+  // elaborated type.
+  Qualifiers PrefixQualifiers = QT.getLocalQualifiers();
   ElaboratedTypeKey

Re: [Clang] Convergent Attribute

2016-05-09 Thread Matt Arsenault via cfe-commits

> On May 9, 2016, at 10:39, Anastasia Stulova via cfe-commits 
>  wrote:
> 
> Since it's not a part of any official spec we could of course make it 
> accepted with anything.
> 
> Just out of curiosity what other programming models supported by Clang do you 
> think this attribute would be useful for?
> 
> Anastasia

I’m not sure of any real uses for it

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


Buildbot numbers for the last week of 5/01/2016 - 5/07/2016

2016-05-09 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 5/01/2016 - 5/07/2016.

Thanks

Galina


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 52 |
25 |48.1
 clang-ppc64le-linux-lnt| 70 |
26 |37.1
 lldb-x86_64-darwin-13.4|136 |
45 |33.1
 sanitizer-x86_64-linux-bootstrap   | 51 |
13 |25.5
 lldb-windows7-android  |130 |
31 |23.8
 clang-x86-win2008-selfhost |104 |
24 |23.1
 clang-native-aarch64-full  | 19
|   4 |21.1
 clang-cmake-thumbv7-a15-full-sh| 24
|   5 |20.8
 sanitizer-ppc64le-linux| 43
|   8 |18.6
 clang-x64-ninja-win7   | 34
|   6 |17.6
 clang-ppc64be-linux-multistage |119 |
18 |15.1
 clang-cmake-aarch64-full   | 54
|   8 |14.8
 sanitizer-x86_64-linux |102 |
14 |13.7
 clang-cmake-armv7-a15-selfhost | 31
|   4 |12.9
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions  | 17
|   2 |11.8
 clang-cmake-mips   | 99 |
11 |11.1
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian| 18
|   2 |11.1
 clang-hexagon-elf  | 92 |
10 |10.9
 clang-s390x-linux  |249 |
26 |10.4
 clang-cmake-armv7-a15  |163 |
16 | 9.8
 lldb-x86_64-ubuntu-14.04-android   |133 |
13 | 9.8
 clang-ppc64be-linux-lnt|227 |
22 | 9.7
 clang-x86_64-linux-selfhost-modules|251 |
24 | 9.6
 clang-cmake-mipsel | 21
|   2 | 9.5
 clang-cmake-thumbv7-a15|190 |
18 | 9.5
 llvm-mips-linux| 63
|   6 | 9.5
 sanitizer-x86_64-linux-fast|180 |
17 | 9.4
 clang-ppc64le-linux|192 |
18 | 9.4
 llvm-clang-lld-x86_64-debian-fast  |171 |
16 | 9.4
 clang-ppc64be-linux|285 |
26 | 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-unstable-abi  | 22
|   2 | 9.1
 clang-cmake-aarch64-quick  |177 |
16 | 9.0
 libcxx-libcxxabi-arm-linux | 23
|   2 | 8.7
 clang-cmake-aarch64-42vma  |162 |
14 | 8.6
 clang-x86_64-debian-fast   |141 |
12 | 8.5
 clang-cmake-armv7-a15-full |106
|   9 | 8.5
 clang-atom-d525-fedora-rel | 72
|   6 | 8.3
 llvm-hexagon-elf   |100
|   8 | 8.0
 clang-bpf-build|348 |
28 | 8.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 25
|   2 | 8.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 25
|   2 | 8.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 25
|   2 | 8.0
 clang-cmake-armv7-a15-selfhost-neon| 25
|   2 | 8.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11 | 26
|   2 | 7.7
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14 | 26
|   2 | 7.7
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 26
|   2 | 7.7
 libcxx-libcxxabi-x86_64-l

Buildbot numbers for week of 4/24/2016 - 4/30/2016

2016-05-09 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for week of 4/24/2016 - 4/30/2016.

Thanks

Galina


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):

 buildername| builds |
changes | status change ratio
++-+-
 perf-x86_64-penryn-O3-polly| 51 |
30 |58.8
 lldb-x86_64-darwin-13.4|126 |
55 |43.7
 lldb-windows7-android  | 98 |
35 |35.7
 clang-ppc64le-linux-lnt| 78 |
19 |24.4
 clang-ppc64be-linux-multistage | 75 |
15 |20.0
 clang-cmake-armv7-a15-selfhost | 34
|   6 |17.6
 clang-x86-win2008-selfhost | 98 |
17 |17.3
 sanitizer-x86_64-linux-bootstrap   | 52
|   9 |17.3
 clang-cmake-armv7-a15-selfhost-neon| 24
|   4 |16.7
 sanitizer-x86_64-linux |122 |
20 |16.4
 perf-x86_64-penryn-O3-polly-before-vectorizer  | 13
|   2 |15.4
 clang-ppc64be-linux-lnt|230 |
35 |15.2
 sanitizer-ppc64be-linux| 84 |
12 |14.3
 perf-x86_64-penryn-O3-polly-fast   | 28
|   4 |14.3
 libcxx-libcxxabi-x86_64-linux-debian   | 15
|   2 |13.3
 llvm-clang-lld-x86_64-debian-fast  |190 |
24 |12.6
 libcxx-libcxxabi-arm-linux | 17
|   2 |11.8
 llvm-mips-linux| 61
|   7 |11.5
 perf-x86_64-penryn-O3  | 53
|   6 |11.3
 clang-cmake-armv7-a15-full | 91 |
10 |11.0
 clang-ppc64be-linux|305 |
33 |10.8
 clang-x86_64-linux-selfhost-modules|244 |
26 |10.7
 lldb-x86_64-ubuntu-14.04-android   |126 |
13 |10.3
 clang-cmake-mips   | 99 |
10 |10.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan  | 20
|   2 |10.0
 clang-cmake-mipsel | 10
|   1 |10.0
 clang-ppc64le-linux|220 |
22 |10.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03 | 20
|   2 |10.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11   | 21
|   2 | 9.5
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan  | 21
|   2 | 9.5
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan  | 22
|   2 | 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14 | 22
|   2 | 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx1z | 22
|   2 | 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11 | 22
|   2 | 9.1
 clang-cmake-armv7-a15  |155 |
14 | 9.0
 clang-s390x-linux  |270 |
24 | 8.9
 clang-cmake-thumbv7-a15-full-sh| 24
|   2 | 8.3
 sanitizer-x86_64-linux-fast|197 |
15 | 7.6
 clang-cmake-aarch64-full   | 54
|   4 | 7.4
 lld-x86_64-darwin13|331 |
24 | 7.3
 clang-x64-ninja-win7   |236 |
16 | 6.8
 clang-cmake-aarch64-42vma  |177 |
12 | 6.8
 clang-x86_64-debian-fast   |152 |
10 | 6.6
 clang-cmake-thumbv7-a15|186 |
12 | 6.5
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast   |507 |
33 | 6.5
 clang-cmake-aarch64-quick  |184 |
12 | 6.5
 lldb-x86_64-ubuntu-14.04-cmake  

Re: [PATCH] D20039: [CUDA] Restrict init of local __shared__ variables to empty constructors only.

2016-05-09 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 56619.
tra added a comment.

Reworded comments.

Removed tests that no longer apply as we don't generate constructors for static 
local variables on device side.
Empty constructor cases are already covered by 
test/CodeGenCUDA/device-var-init.cu.


http://reviews.llvm.org/D20039

Files:
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/address-spaces.cu
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -63,6 +63,8 @@
 
 // static in-class field initializer.  NVCC does not allow it, but
 // clang generates static initializer for this, so we'll accept it.
+// We still can't use it on __shared__ vars as they don't allow *any*
+// initializers.
 struct NCFS {
   int ncfs = 3;
 };
@@ -367,8 +369,13 @@
   T_B_NEC t_b_nec;
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
+  static __shared__ EC s_ec;
+  static __shared__ ETC s_etc;
+#if ERROR_CASE
+  static __shared__ NCFS s_ncfs;
+  // expected-error@-1 {{initialization is not supported for __shared__ variables.}}
   static __shared__ UC s_uc;
-#if ERROR_CASE
+  // expected-error@-1 {{initialization is not supported for __shared__ variables.}}
   static __device__ int ds;
   // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
   static __constant__ int dc;
@@ -394,7 +401,8 @@
 // CHECK:   call void @_ZN7T_B_NECC1Ev(%struct.T_B_NEC* %t_b_nec)
 // CHECK:   call void @_ZN7T_F_NECC1Ev(%struct.T_F_NEC* %t_f_nec)
 // CHECK:   call void @_ZN8T_FA_NECC1Ev(%struct.T_FA_NEC* %t_fa_nec)
-// CHECK:   call void @_ZN2UCC1Ev(%struct.UC* addrspacecast (%struct.UC addrspace(3)* @_ZZ2dfvE4s_uc to %struct.UC*))
+// CHECK-NOT: call void @_ZN2ECC1Ev(%struct.EC* addrspacecast (%struct.EC addrspace(3)* @_ZZ2dfvE4s_ec to %struct.EC*))
+// CHECK-NOT: call void @_ZN3ETCC1IJEEEDpT_(%struct.ETC* addrspacecast (%struct.ETC addrspace(3)* @_ZZ2dfvE5s_etc to %struct.ETC*))
 // CHECK: ret void
 
 // We should not emit global init function.
Index: test/CodeGenCUDA/address-spaces.cu
===
--- test/CodeGenCUDA/address-spaces.cu
+++ test/CodeGenCUDA/address-spaces.cu
@@ -94,32 +94,3 @@
 }
 // CHECK: define float* @_Z5func5v()
 // CHECK: ret float* addrspacecast (float addrspace(3)* @b to float*)
-
-struct StructWithCtor {
-  __device__ StructWithCtor(): data(1) {}
-  __device__ StructWithCtor(const StructWithCtor &second): data(second.data) {}
-  __device__ int getData() { return data; }
-  int data;
-};
-
-__device__ int construct_shared_struct() {
-// CHECK-LABEL: define i32 @_Z23construct_shared_structv()
-  __shared__ StructWithCtor s;
-// CHECK: call void @_ZN14StructWithCtorC1Ev(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
-  __shared__ StructWithCtor t(s);
-// CHECK: call void @_ZN14StructWithCtorC1ERKS_(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*), %struct.StructWithCtor* dereferenceable(4) addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1s to %struct.StructWithCtor*))
-  return t.getData();
-// CHECK: call i32 @_ZN14StructWithCtor7getDataEv(%struct.StructWithCtor* addrspacecast (%struct.StructWithCtor addrspace(3)* @_ZZ23construct_shared_structvE1t to %struct.StructWithCtor*))
-}
-
-// Make sure we allow __shared__ structures with default or empty constructors.
-struct c {
-  int i;
-};
-__shared__ struct c c;
-
-struct d {
-  int i;
-  d() {}
-};
-__shared__ struct d d;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10414,14 +10414,15 @@
 
   // Perform check for initializers of device-side global variables.
   // CUDA allows empty constructors as initializers (see E.2.3.1, CUDA
-  // 7.5). CUDA also allows constant initializers for __constant__ and
-  // __device__ variables.
+  // 7.5). We must also apply the same checks to all __shared__
+  // variables whether they are local or not. CUDA also allows
+  // constant initializers for __constant__ and __device__ variables.
   if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
 const Expr *Init = VD->getInit();
-const bool IsGlobal = VD->hasGlobalStorage() && !VD->isStaticLocal();
-if (Init && IsGlobal &&
+if (Init && VD->hasGlobalStorage() &&
 (VD->hasAttr() || VD->hasAttr() ||
  VD->hasAttr())) {
+  assert((!VD->isStaticLocal() || VD->hasAttr()));
   bool AllowedInit = false;
   if (const CXXConstructExpr *CE = dyn_cast(Init))
 AllowedInit =
Index: lib/CodeGen/CGDecl.cpp
===

Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-09 Thread Vedran Miletić via cfe-commits
rivanvx added a comment.

Thanks for the reviews!


http://reviews.llvm.org/D19780



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


Re: [PATCH] D20034: [CUDA] Only __shared__ variables can be static local on device side.

2016-05-09 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268962: [CUDA] Only __shared__ variables can be static local 
on device side. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D20034?vs=56610&id=56611#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20034

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCUDA/address-spaces.cu
  cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6554,7 +6554,9 @@
 "__device__, __constant__, and __shared__ variables.">;
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
-
+def err_device_static_local_var : Error<
+"Within a __device__/__global__ function, "
+"only __shared__ variables may be marked \"static\"">;
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
   "%select{function|block|method|constructor}2; expected type from format "
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
Index: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
===
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu
@@ -38,14 +38,6 @@
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @k to i32*)
   k++;
 
-  static int li;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @_ZZ3foovE2li to 
i32*)
-  li++;
-
-  __constant__ int lj;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(4)* @_ZZ3foovE2lj to 
i32*)
-  lj++;
-
   __shared__ int lk;
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @_ZZ3foovE2lk to 
i32*)
   lk++;
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -10391,15 +10391,24 @@
 }
   }
 
-  // Static locals inherit dll attributes from their function.
   if (VD->isStaticLocal()) {
 if (FunctionDecl *FD =
 dyn_cast_or_null(VD->getParentFunctionOrMethod())) {
+  // Static locals inherit dll attributes from their function.
   if (Attr *A = getDLLAttr(FD)) {
 auto *NewAttr = cast(A->clone(getASTContext()));
 NewAttr->setInherited(true);
 VD->addAttr(NewAttr);
   }
+  // CUDA E.2.9.4: Within the body of a __device__ or __global__
+  // function, only __shared__ variables may be declared with
+  // static storage class.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (FD->hasAttr() || FD->hasAttr()) &&
+  !VD->hasAttr()) {
+Diag(VD->getLocation(), diag::err_device_static_local_var);
+VD->setInvalidDecl();
+  }
 }
   }
 


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6554,7 +6554,9 @@
 "__device__, __constant__, and __shared__ variables.">;
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
-
+def err_device_static_local_var : Error<
+"Within a __device__/__global__ function, "
+"only __shared__ variables may be marked \"static\"">;
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
   "%select{function|block|method|constructor}2; expected type from format "
Index: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
===
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if E

r268962 - [CUDA] Only __shared__ variables can be static local on device side.

2016-05-09 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon May  9 14:36:08 2016
New Revision: 268962

URL: http://llvm.org/viewvc/llvm-project?rev=268962&view=rev
Log:
[CUDA] Only __shared__ variables can be static local on device side.

According to CUDA programming guide (v7.5):
> E.2.9.4: Within the body of a device or global function, only
> shared variables may be declared with static storage class.

Differential Revision: http://reviews.llvm.org/D20034

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCUDA/address-spaces.cu
cfe/trunk/test/CodeGenCUDA/device-var-init.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268962&r1=268961&r2=268962&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  9 14:36:08 
2016
@@ -6554,7 +6554,9 @@ def err_dynamic_var_init : Error<
 "__device__, __constant__, and __shared__ variables.">;
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
-
+def err_device_static_local_var : Error<
+"Within a __device__/__global__ function, "
+"only __shared__ variables may be marked \"static\"">;
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
   "%select{function|block|method|constructor}2; expected type from format "

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=268962&r1=268961&r2=268962&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May  9 14:36:08 2016
@@ -10391,15 +10391,24 @@ Sema::FinalizeDeclaration(Decl *ThisDecl
 }
   }
 
-  // Static locals inherit dll attributes from their function.
   if (VD->isStaticLocal()) {
 if (FunctionDecl *FD =
 dyn_cast_or_null(VD->getParentFunctionOrMethod())) {
+  // Static locals inherit dll attributes from their function.
   if (Attr *A = getDLLAttr(FD)) {
 auto *NewAttr = cast(A->clone(getASTContext()));
 NewAttr->setInherited(true);
 VD->addAttr(NewAttr);
   }
+  // CUDA E.2.9.4: Within the body of a __device__ or __global__
+  // function, only __shared__ variables may be declared with
+  // static storage class.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (FD->hasAttr() || FD->hasAttr()) &&
+  !VD->hasAttr()) {
+Diag(VD->getLocation(), diag::err_device_static_local_var);
+VD->setInvalidDecl();
+  }
 }
   }
 

Modified: cfe/trunk/test/CodeGenCUDA/address-spaces.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/address-spaces.cu?rev=268962&r1=268961&r2=268962&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/address-spaces.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/address-spaces.cu Mon May  9 14:36:08 2016
@@ -38,14 +38,6 @@ __device__ void foo() {
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @k to i32*)
   k++;
 
-  static int li;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @_ZZ3foovE2li to 
i32*)
-  li++;
-
-  __constant__ int lj;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(4)* @_ZZ3foovE2lj to 
i32*)
-  lj++;
-
   __shared__ int lk;
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @_ZZ3foovE2lk to 
i32*)
   lk++;

Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=268962&r1=268961&r2=268962&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Mon May  9 14:36:08 2016
@@ -368,6 +368,14 @@ __device__ void df() {
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)


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


Re: [PATCH] D20034: [CUDA] Only __shared__ variables can be static local on device side.

2016-05-09 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 56610.
tra added a comment.

Updated tests in CodeGenCUDA/address-spaces.cu


http://reviews.llvm.org/D20034

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/address-spaces.cu
  test/CodeGenCUDA/device-var-init.cu

Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only 
__shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
Index: test/CodeGenCUDA/address-spaces.cu
===
--- test/CodeGenCUDA/address-spaces.cu
+++ test/CodeGenCUDA/address-spaces.cu
@@ -38,14 +38,6 @@
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @k to i32*)
   k++;
 
-  static int li;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @_ZZ3foovE2li to 
i32*)
-  li++;
-
-  __constant__ int lj;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(4)* @_ZZ3foovE2lj to 
i32*)
-  lj++;
-
   __shared__ int lk;
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @_ZZ3foovE2lk to 
i32*)
   lk++;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -10391,15 +10391,24 @@
 }
   }
 
-  // Static locals inherit dll attributes from their function.
   if (VD->isStaticLocal()) {
 if (FunctionDecl *FD =
 dyn_cast_or_null(VD->getParentFunctionOrMethod())) {
+  // Static locals inherit dll attributes from their function.
   if (Attr *A = getDLLAttr(FD)) {
 auto *NewAttr = cast(A->clone(getASTContext()));
 NewAttr->setInherited(true);
 VD->addAttr(NewAttr);
   }
+  // CUDA E.2.9.4: Within the body of a __device__ or __global__
+  // function, only __shared__ variables may be declared with
+  // static storage class.
+  if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
+  (FD->hasAttr() || FD->hasAttr()) &&
+  !VD->hasAttr()) {
+Diag(VD->getLocation(), diag::err_device_static_local_var);
+VD->setInvalidDecl();
+  }
 }
   }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6554,7 +6554,9 @@
 "__device__, __constant__, and __shared__ variables.">;
 def err_shared_var_init : Error<
 "initialization is not supported for __shared__ variables.">;
-
+def err_device_static_local_var : Error<
+"Within a __device__/__global__ function, "
+"only __shared__ variables may be marked \"static\"">;
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "
   "%select{function|block|method|constructor}2; expected type from format "


Index: test/CodeGenCUDA/device-var-init.cu
===
--- test/CodeGenCUDA/device-var-init.cu
+++ test/CodeGenCUDA/device-var-init.cu
@@ -368,6 +368,14 @@
   T_F_NEC t_f_nec;
   T_FA_NEC t_fa_nec;
   static __shared__ UC s_uc;
+#if ERROR_CASE
+  static __device__ int ds;
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+  static __constant__ int dc;
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+  static int v;
+  // expected-error@-1 {{Within a __device__/__global__ function, only __shared__ variables may be marked "static"}}
+#endif
 }
 
 // CHECK:   call void @_ZN2ECC1Ev(%struct.EC* %ec)
Index: test/CodeGenCUDA/address-spaces.cu
===
--- test/CodeGenCUDA/address-spaces.cu
+++ test/CodeGenCUDA/address-spaces.cu
@@ -38,14 +38,6 @@
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @k to i32*)
   k++;
 
-  static int li;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(1)* @_ZZ3foovE2li to i32*)
-  li++;
-
-  __constant__ int lj;
-  // CHECK: load i32, i32* addrspacecast (i32 addrspace(4)* @_ZZ3foovE2lj to i32*)
-  lj++;
-
   __shared__ int lk;
   // CHECK: load i32, i32* addrspacecast (i32 addrspace(3)* @_ZZ3foovE2lk to i32*)
   lk++;
Index: lib/Sema/Sem

r268956 - [Myriad] Use Generic_ELF::addClangTargetOptions()

2016-05-09 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Mon May  9 14:09:59 2016
New Revision: 268956

URL: http://llvm.org/viewvc/llvm-project?rev=268956&view=rev
Log:
[Myriad] Use Generic_ELF::addClangTargetOptions()

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268956&r1=268955&r2=268956&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon May  9 14:09:59 2016
@@ -4401,7 +4401,7 @@ void XCoreToolChain::AddCXXStdlibLibArgs
 
 MyriadToolChain::MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
  const ArgList &Args)
-: Generic_GCC(D, Triple, Args) {
+: Generic_ELF(D, Triple, Args) {
   // If a target of 'sparc-myriad-elf' is specified to clang, it wants to use
   // 'sparc-myriad--elf' (note the unknown OS) as the canonical triple.
   // This won't work to find gcc. Instead we give the installation detector an

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=268956&r1=268955&r2=268956&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon May  9 14:09:59 2016
@@ -1093,7 +1093,7 @@ public:
 
 /// MyriadToolChain - A tool chain using either clang or the external compiler
 /// installed by the Movidius SDK to perform all subcommands.
-class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_GCC {
+class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
 public:
   MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=268956&r1=268955&r2=268956&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Mon May  9 14:09:59 2016
@@ -77,3 +77,7 @@
 
 // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck 
-check-prefix=G_SPARC %s
 // G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2"
+
+// RUN: %clang -### -c %s -target sparc-myriad-elf -fuse-init-array 2>&1 \
+// RUN: | FileCheck -check-prefix=USE-INIT-ARRAY %s
+// USE-INIT-ARRAY-NOT: argument unused


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


Re: [PATCH] D16579: Warn if friend function depends on template parameters.

2016-05-09 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 56607.
sepavloff added a comment.

Changed implementation of friend function set.

Friend functions declared in template classes are not added to redeclaration 
chains,
but access to them is needed to make some checks. This change allows using the
set of friend functions not only to emit particular warning but also to serve 
as a
registry of file-level friend functions.


http://reviews.llvm.org/D16579

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  test/CXX/drs/dr3xx.cpp
  test/CXX/drs/dr5xx.cpp
  test/SemaCXX/friend.cpp
  test/SemaCXX/overload-call.cpp

Index: test/SemaCXX/overload-call.cpp
===
--- test/SemaCXX/overload-call.cpp
+++ test/SemaCXX/overload-call.cpp
@@ -574,13 +574,15 @@
   // Ensure that overload resolution attempts to complete argument types when
   // performing ADL.
   template struct S {
-friend int f(const S&);
+friend int f(const S&);  // expected-warning{{friend declaration 'IncompleteArg::f' depends on template parameter but is not a template function}}
+ // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
   };
   extern S s;
   int k = f(s);
 
   template struct Op {
-friend bool operator==(const Op &, const Op &);
+friend bool operator==(const Op &, const Op &);  // expected-warning{{friend declaration 'IncompleteArg::operator==' depends on template parameter but is not a template function}}
+ // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
   };
   extern Op op;
   bool b = op == op;
Index: test/SemaCXX/friend.cpp
===
--- test/SemaCXX/friend.cpp
+++ test/SemaCXX/friend.cpp
@@ -363,3 +363,102 @@
   f_pr6954(5); // expected-error{{undeclared identifier 'f_pr6954'}}
 }
 
+
+template void pr23342_func(T x);
+template
+struct pr23342_C1 {
+  friend void pr23342_func<>(T x);
+  friend bool func(T x);  // expected-warning{{friend declaration 'func' depends on template parameter but is not a template function}}
+  // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
+  friend bool func2(int x);
+  template friend bool func3(T2 x);
+  friend T func4();  // expected-warning{{friend declaration 'func4' depends on template parameter but is not a template function}}
+ // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
+};
+
+namespace pr23342 {
+
+template
+struct C1 {
+  friend void pr23342_func<>(T x);
+  friend bool func(T x);  // expected-warning{{friend declaration 'pr23342::func' depends on template parameter but is not a template function}}
+  // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
+  friend bool func2(int x);
+  template friend bool func3(T2 x);
+  friend T func4();// expected-warning{{friend declaration 'pr23342::func4' depends on template parameter but is not a template function}}
+   // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
+};
+
+template 
+struct Arg {
+  friend bool operator==(const Arg& lhs, T rhs) {
+   return false;
+  }
+  friend bool operator!=(const Arg& lhs, T rhs);  // expected-warning{{friend declaration 'pr23342::operator!=' depends on template parameter but is not a template function}}
+   // expected-note@-1{{to befriend a template specialization, use '<>'}}
+};
+template 
+bool operator!=(const Arg& lhs, T rhs) {
+  return true;
+}
+bool foo() {
+  Arg arg;
+  return (arg == 42) || (arg != 42);
+}
+
+
+template class C0 {
+  friend void func0(C0 &);  // expected-warning{{friend declaration 'pr23342::func0' depends on template parameter but is not a template function}}
+   // expected-note@-1{{if this is intentional, add function declaration to suppress the warning, if not - make sure the function template has already been declared and use '<>'}}
+};
+
+template class C0a {
+  friend void func0a(C0a &);  // expected-warning{{friend declaration 'pr23342::func0a

Re: [PATCH] D19684: Power9 - Support for -mcpu=pwr9 in the front end

2016-05-09 Thread Nemanja Ivanovic via cfe-commits
nemanjai closed this revision.
nemanjai added a comment.

Committed revision 268951.


Repository:
  rL LLVM

http://reviews.llvm.org/D19684



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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-09 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 56605.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Generate calls to void addr* to_addr(void*) with bitcasts.


http://reviews.llvm.org/D19932

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Decl.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/to_addr_builtin.cl
  test/SemaOpenCL/to_addr_builtin.cl

Index: test/SemaOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  constant int *con;
+
+  glob = to_global(glob, loc);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+#endif
+
+  int x;
+  glob = to_global(x);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument x to function: 'to_global'}}
+#endif
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{invalid argument con to function: 'to_global'}}
+#endif
+
+  loc = to_global(glob);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+  // expected-error@-2{{'to_global' needs OpenCL version 2.0 or above}}
+#else
+  // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
+#endif
+
+}
Index: test/CodeGenOpenCL/to_addr_builtin.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/to_addr_builtin.cl
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+// CHECK: %[[A:.*]] = type { float, float, float }
+typedef struct {
+  float x,y,z;
+} A;
+typedef private A *PA;
+typedef global A *GA;
+
+void test(void) {
+  global int *glob;
+  local int *loc;
+  private int *priv;
+  generic int *gen;
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(glob);
+  
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(loc);
+ 
+  //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(priv);
+ 
+  //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)*
+  glob = to_global(gen);
+  
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(glob);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(loc);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(priv);
+
+  //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)*
+  loc = to_local(gen);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
+  priv = to_private(glob);
+
+  //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)*
+  //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]])
+  //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
+  priv = to_priva

r268951 - [Power9] Enable -mcpu=pwr9 (-mcpu=power9) in the front end

2016-05-09 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Mon May  9 13:58:02 2016
New Revision: 268951

URL: http://llvm.org/viewvc/llvm-project?rev=268951&view=rev
Log:
[Power9] Enable -mcpu=pwr9 (-mcpu=power9) in the front end

This patch corresponds to review:
http://reviews.llvm.org/D19684

It simply adds the handling for the option and the corresponding macros.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=268951&r1=268950&r2=268951&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon May  9 13:58:02 2016
@@ -851,8 +851,9 @@ public:
 ArchDefinePwr6x = 1 << 10,
 ArchDefinePwr7  = 1 << 11,
 ArchDefinePwr8  = 1 << 12,
-ArchDefineA2= 1 << 13,
-ArchDefineA2q   = 1 << 14
+ArchDefinePwr9  = 1 << 13,
+ArchDefineA2= 1 << 14,
+ArchDefineA2q   = 1 << 15
   } ArchDefineTypes;
 
   // Note: GCC recognizes the following additional cpus:
@@ -901,6 +902,8 @@ public:
   .Case("pwr7", true)
   .Case("power8", true)
   .Case("pwr8", true)
+  .Case("power9", true)
+  .Case("pwr9", true)
   .Case("powerpc", true)
   .Case("ppc", true)
   .Case("powerpc64", true)
@@ -1195,6 +1198,10 @@ void PPCTargetInfo::getTargetDefines(con
 .Case("pwr8",  ArchDefineName | ArchDefinePwr7 | ArchDefinePwr6x
  | ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
  | ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
+.Case("pwr9",  ArchDefineName | ArchDefinePwr8 | ArchDefinePwr7
+ | ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x
+ | ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
+ | ArchDefinePpcsq)
 .Case("power3",  ArchDefinePpcgr)
 .Case("power4",  ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
 .Case("power5",  ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
@@ -1212,6 +1219,10 @@ void PPCTargetInfo::getTargetDefines(con
 .Case("power8",  ArchDefinePwr8 | ArchDefinePwr7 | ArchDefinePwr6x
| ArchDefinePwr6 | ArchDefinePwr5x | ArchDefinePwr5
| ArchDefinePwr4 | ArchDefinePpcgr | ArchDefinePpcsq)
+.Case("power9",  ArchDefinePwr9 | ArchDefinePwr8 | ArchDefinePwr7
+   | ArchDefinePwr6x | ArchDefinePwr6 | ArchDefinePwr5x
+   | ArchDefinePwr5 | ArchDefinePwr4 | ArchDefinePpcgr
+   | ArchDefinePpcsq)
 .Default(ArchDefineNone);
 
   if (defs & ArchDefineName)
@@ -1240,6 +1251,8 @@ void PPCTargetInfo::getTargetDefines(con
 Builder.defineMacro("_ARCH_PWR7");
   if (defs & ArchDefinePwr8)
 Builder.defineMacro("_ARCH_PWR8");
+  if (defs & ArchDefinePwr9)
+Builder.defineMacro("_ARCH_PWR9");
   if (defs & ArchDefineA2)
 Builder.defineMacro("_ARCH_A2");
   if (defs & ArchDefineA2q) {
@@ -1339,6 +1352,7 @@ bool PPCTargetInfo::initFeatureMap(
 .Case("pwr6", true)
 .Case("pwr7", true)
 .Case("pwr8", true)
+.Case("pwr9", true)
 .Case("ppc64", true)
 .Case("ppc64le", true)
 .Default(false);
@@ -1346,28 +1360,34 @@ bool PPCTargetInfo::initFeatureMap(
   Features["qpx"] = (CPU == "a2q");
   Features["crypto"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Default(false);
   Features["power8-vector"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Default(false);
   Features["bpermd"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Case("pwr7", true)
 .Default(false);
   Features["extdiv"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Case("pwr7", true)
 .Default(false);
   Features["direct-move"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Default(false);
   Features["vsx"] = llvm::StringSwitch(CPU)
 .Case("ppc64le", true)
+.Case("pwr9", true)
 .Case("pwr8", true)
 .Case("pwr7", true)
 .Default(false);

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=268951&r1=268950&r2=268951&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon May  9 13:58:02 2016
@@ -1479,6 +1479,7 @@ static std::string getPPCTargetCPU(const
 .Case("power6x", "pwr6x")
 .Case("power7", "pwr7")
 .Case("power8", "pwr8")
+.Case("power9", "pwr9")
 .Case("pwr3", "pwr3")
 .Case("pwr

Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.


Comment at: unittests/Tooling/QualTypeNamesTest.cpp:91
@@ -90,2 +90,3 @@
   Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias";
+  Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *";
   Visitor.runOver(

What does this produce without your change? (what's the change causing to 
happen?)


http://reviews.llvm.org/D20040



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


r268947 - [cmake] Enable zlib support for Apple stage2 builds

2016-05-09 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon May  9 13:40:09 2016
New Revision: 268947

URL: http://llvm.org/viewvc/llvm-project?rev=268947&view=rev
Log:
[cmake] Enable zlib support for Apple stage2 builds

This allows llvm-profdata to interact with profiles containing
compressed name data.

rdar://problem/26122944

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=268947&r1=268946&r2=268947&view=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon May  9 13:40:09 2016
@@ -10,7 +10,7 @@ set(CLANG_TOOL_SCAN_BUILD_BUILD OFF CACH
 set(CLANG_TOOL_SCAN_VIEW_BUILD OFF CACHE BOOL "")
 set(CLANG_LINKS_TO_CREATE clang++ cc c++ CACHE STRING "")
 set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
-set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")


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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-09 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 56603.
jlebar added a comment.

Remove static_asserts.


http://reviews.llvm.org/D19990

Files:
  include/clang/Basic/BuiltinsNVPTX.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_intrinsics.h
  lib/Headers/__clang_cuda_runtime_wrapper.h
  test/CodeGen/builtins-nvptx.c

Index: test/CodeGen/builtins-nvptx.c
===
--- test/CodeGen/builtins-nvptx.c
+++ test/CodeGen/builtins-nvptx.c
@@ -1,6 +1,8 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
-// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | FileCheck %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP32 %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -fcuda-is-device -S -emit-llvm -o - -x cuda %s | \
+// RUN:   FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
 
 #define __device__ __attribute__((device))
 #define __global__ __attribute__((global))
@@ -280,3 +282,103 @@
 
   // CHECK: ret
 }
+
+// CHECK-LABEL: nvvm_ldg
+__device__ void nvvm_ldg(const void *p) {
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  // CHECK: call i8 @llvm.nvvm.ldg.global.i.i8.p0i8(i8* {{%[0-9]+}}, i32 1)
+  __nvvm_ldg_c((const char *)p);
+  __nvvm_ldg_uc((const unsigned char *)p);
+
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  // CHECK: call i16 @llvm.nvvm.ldg.global.i.i16.p0i16(i16* {{%[0-9]+}}, i32 2)
+  __nvvm_ldg_s((const short *)p);
+  __nvvm_ldg_us((const unsigned short *)p);
+
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // CHECK: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_i((const int *)p);
+  __nvvm_ldg_ui((const unsigned int *)p);
+
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP32: call i32 @llvm.nvvm.ldg.global.i.i32.p0i32(i32* {{%[0-9]+}}, i32 4)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  // LP64: call i64 @llvm.nvvm.ldg.global.i.i64.p0i64(i64* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_l((const long *)p);
+  __nvvm_ldg_ul((const unsigned long *)p);
+
+  // CHECK: call float @llvm.nvvm.ldg.global.f.f32.p0f32(float* {{%[0-9]+}}, i32 4)
+  __nvvm_ldg_f((const float *)p);
+  // CHECK: call double @llvm.nvvm.ldg.global.f.f64.p0f64(double* {{%[0-9]+}}, i32 8)
+  __nvvm_ldg_d((const double *)p);
+
+  // In practice, the pointers we pass to __ldg will be aligned as appropriate
+  // for the CUDA N vector types (e.g. short4), which are not the same as
+  // the LLVM vector types.  However, each LLVM vector type has an alignment
+  // less than or equal to its corresponding CUDA type, so we're OK.
+  //
+  // PTX Interoperability section 2.2: "For a vector with an even number of
+  // elements, its alignment is set to number of elements times the alignment of
+  // its member: n*alignof(t)."
+
+  // CHECK: call <2 x i8> @llvm.nvvm.ldg.global.i.v2i8.p0v2i8(<2 x i8>* {{%[0-9]+}}, i32 2)
+  // CHECK: call <2 x i8> @llvm.nvvm.ldg.global.i.v2i8.p0v2i8(<2 x i8>* {{%[0-9]+}}, i32 2)
+  typedef char char2 __attribute__((ext_vector_type(2)));
+  typedef unsigned char uchar2 __attribute__((ext_vector_type(2)));
+  __nvvm_ldg_c2((const char2 *)p);
+  __nvvm_ldg_uc2((const uchar2 *)p);
+
+  // CHECK: call <4 x i8> @llvm.nvvm.ldg.global.i.v4i8.p0v4i8(<4 x i8>* {{%[0-9]+}}, i32 4)
+  // CHECK: call <4 x i8> @llvm.nvvm.ldg.global.i.v4i8.p0v4i8(<4 x i8>* {{%[0-9]+}}, i32 4)
+  typedef char char4 __attribute__((ext_vector_type(4)));
+  typedef unsigned char uchar4 __attribute__((ext_vector_type(4)));
+  __nvvm_ldg_c4((const char4 *)p);
+  __nvvm_ldg_uc4((const uchar4 *)p);
+
+  // CHECK: call <2 x i16> @llvm.nvvm.ldg.global.i.v2i16.p0v2i16(<2 x i16>* {{%[0-9]+}}, i32 4)
+  // CHECK: call <2 x i16> @llvm.nvvm.ldg.global.i.v2i16.p0v2i16(<2 x i16>* {{%[0-9]+}}, i32 4)
+  typedef short short2 __attribute__((ext_vector_type(2)));
+  typedef unsigned short ushort2 __attribute__((ext_vector_type(2)));
+  __nvvm_ldg_s2((const short2 *)p);
+  __nvvm_ldg_us2((const ushort2 *)p);
+
+  // CHECK: call <4 x i16> @llvm.nvvm.ldg.global.i.v4i16.p0v4i16(<4 x i16>* {{%[0-9]+}}, i32 8)
+  // CHECK: call <4 x i16> @llvm.nvvm.ldg.global.i.v4i16.p0v4i16(<4 x i16>* {{%[0-9]+}}, i32 8)
+  typedef short short4 __attribute__((ext_vector_type(4)));
+  typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));
+  __nvvm_ldg_s4((const short4 *)p);
+  __nvvm_ldg_us4((const ushort4 *)p);
+
+  // CHECK: call <2 x i32> @llvm.nvvm.ldg.global.i.v2i32.p0v2i32(<2 x i32>* {{%[0-9]+}}, i32 8)
+  // CHECK: call <2 x i32> @llvm.nvvm.ldg.global.i.v2i32.p0v2i32(<2 x i32>* {{%[0-9]+}}, i32 8)
+  typedef int 

Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-09 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Art pointed out that static_assert is c++11-only.

I'll just remove them and make a note to move them into the CUDA test-suite 
stuff Art is working on.


http://reviews.llvm.org/D19990



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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-09 Thread Artem Belevich via cfe-commits
tra added a comment.

OK. Let's stick with __ldg for now.


http://reviews.llvm.org/D19990



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


Re: [Clang] Convergent Attribute

2016-05-09 Thread Ettore Speziale via cfe-commits
Hello,

> On 05/06/2016 12:11 PM, Anastasia Stulova via cfe-commits wrote:
>> I was just wondering whether it would make sense to restrict the usage of 
>> the attribute to OpenCL language i.e. to add  "let LangOpts = [OpenCL];" in 
>> the attribute definition.
> This seems to be a pointless arbitrary restriction to me

Updated the patch based on the review comments:

* allow the [[clang::convergent]] attribute spelling
* used a better example in the documentation

Thanks

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--



convergent.diff
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.

2016-05-09 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: lib/Tooling/Core/QualTypeNames.cpp:386
@@ -385,2 +385,3 @@
   NestedNameSpecifier *Prefix = nullptr;
-  Qualifiers PrefixQualifiers;
+  // Local qualifiers are attached to the Qualtype outside of the
+  // elaborated type.  Retrieve them before descending into the

Qualtype -> QualType


Comment at: lib/Tooling/Core/QualTypeNames.cpp:392
@@ -388,3 +391,3 @@
   if (const auto *ETypeInput = dyn_cast(QT.getTypePtr())) {
 QT = ETypeInput->getNamedType();
 Keyword = ETypeInput->getKeyword();

Maybe add an assert that `QT` is unqualified here?


Comment at: lib/Tooling/Core/QualTypeNames.cpp:401-403
@@ -397,6 +400,5 @@
   // move the qualifiers on the outer type (avoid 'std::const string'!)
-  if (Prefix) {
-PrefixQualifiers = QT.getLocalQualifiers();
+  if (Prefix || Keyword != ETK_None) {
 QT = QualType(QT.getTypePtr(), 0);
   }
 

I find the way this code ensures that we preserve the qualifiers to be a little 
subtle. It's not obvious to me that this does the right thing for a case like

struct X;
void f(const ::X x) {}

... where we have an `ElaboratedType` with no keyword, and for which we will 
generate an empty `Prefix` -- it looks like we would lose the `const` on line 
392 and never add it back.

Can you remove and re-add the qualifiers unconditionally? (That is, move this 
removal of qualifiers from `QT` to after line 389, and move line 419 outside 
the `if`.) I think that'll make the logic clearer.


Comment at: lib/Tooling/Core/QualTypeNames.cpp:413-415
@@ -410,5 +412,5 @@
 
 Qualifiers Quals = QT.getLocalQualifiers();
 const Type *TypePtr = getFullyQualifiedTemplateType(Ctx, QT.getTypePtr());
 QT = Ctx.getQualifiedType(TypePtr, Quals);
   }

With the change suggested above, you should be able to delete the handling of 
qualifiers here.


http://reviews.llvm.org/D20040



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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-09 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Please, move cfe-commits to Subscribers list!


http://reviews.llvm.org/D19780



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


Re: [PATCH] D19780: Output OpenCL version in Clang diagnostics

2016-05-09 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


http://reviews.llvm.org/D19780



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


Re: [PATCH] D19932: [OpenCL] Add to_{global|local|private} builtin functions.

2016-05-09 Thread Yaxun Liu via cfe-commits
yaxunl marked 4 inline comments as done.


Comment at: test/SemaOpenCL/to_addr_builtin.cl:24
@@ +23,3 @@
+
+  glob = to_global(con);
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0

pxli168 wrote:
> should this return a NULL or a build error?
the function is declared as
  global gentype* to_addr(generic gentype*);
since constant pointer cannot be implicitly casted to a generic pointer (OpenCL 
v2.0 s6.5.5), this should cause a compilation error.


http://reviews.llvm.org/D19932



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


RE: [Clang] Convergent Attribute

2016-05-09 Thread Anastasia Stulova via cfe-commits
Since it's not a part of any official spec we could of course make it accepted 
with anything.

Just out of curiosity what other programming models supported by Clang do you 
think this attribute would be useful for?

Anastasia

-Original Message-
From: Matt Arsenault [mailto:matthew.arsena...@amd.com] 
Sent: 07 May 2016 00:37
To: Anastasia Stulova; Ettore Speziale; Aaron Ballman
Cc: nd; Clang Commits
Subject: Re: [Clang] Convergent Attribute

On 05/06/2016 12:11 PM, Anastasia Stulova via cfe-commits wrote:
> I was just wondering whether it would make sense to restrict the usage of the 
> attribute to OpenCL language i.e. to add  "let LangOpts = [OpenCL];" in the 
> attribute definition.
This seems to be a pointless arbitrary restriction to me

-Matt

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


Re: [PATCH] D19990: [CUDA] Implement __ldg using intrinsics.

2016-05-09 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Art pointed me to the fact that CUDA 8 adds a bunch more load intrinsics, and I 
said ohmygosh maybe we *do* want to do the variadic intrinsic thing here.

But now looking at how __builtin_add_overflow is implemented, we'd need special 
sema checking to make it work.  We would also need some sort of argument 
promotion logic to make the value and pointer into the same types.  In both 
cases it seems like maybe it's better to leave this stuff to clang, rather than 
trying to write a buggy implementation ourselves?

Even with the many new load intrinsics, listing all the intrinsics is a 
relatively small part of the code required.  The majority of the code necessary 
is in our CUDA header, but even with a variadic builtin, that would be hard to 
reduce without some serious template magic, and that would be doubly difficult 
to do without exposing crummy diagnostics to users.

What do you all think?


http://reviews.llvm.org/D19990



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


Re: [PATCH] D19866: [Analyzer] Correct stack address escape diagnostic

2016-05-09 Thread Phil Camp via cfe-commits
FlameTop updated this revision to Diff 56591.
FlameTop added a comment.

Thank you for your review. I have removed the changes to the bug description. 
Apologies, I did not realize it would alter the hash.


http://reviews.llvm.org/D19866

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  llvm/tools/clang/test/Analysis/stackaddrleak.c

Index: llvm/tools/clang/test/Analysis/stackaddrleak.c
===
--- llvm/tools/clang/test/Analysis/stackaddrleak.c
+++ llvm/tools/clang/test/Analysis/stackaddrleak.c
@@ -19,7 +19,7 @@
   p = (const char *) __builtin_alloca(12);
 } // expected-warning{{Address of stack memory allocated by call to alloca() 
on line 19 is still referred to by the global variable 'p' upon returning to 
the caller.  This will be a dangling reference}}
 
-// PR 7383 - previosly the stack address checker would crash on this example
+// PR 7383 - previously the stack address checker would crash on this example
 //  because it would attempt to do a direct load from 'pr7383_list'. 
 static int pr7383(__const char *__)
 {
@@ -33,7 +33,7 @@
   int x;
   a = &x;
   b = &x;
-} // expected-warning{{Address of stack memory associated with local variable 
'x' is still referred to by the global variable 'a' upon returning}} 
expected-warning{{Address of stack memory associated with local variable 'x' is 
still referred to by the global variable 'b' upon returning}}
+} // expected-warning{{Address of stack memory associated with local variable 
'x' is still referred to by the static variable 'a' upon returning}} 
expected-warning{{Address of stack memory associated with local variable 'x' is 
still referred to by the static variable 'b' upon returning}}
 
 intptr_t returnAsNonLoc() {
   int x;
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -236,7 +236,12 @@
 SmallString<512> buf;
 llvm::raw_svector_ostream os(buf);
 SourceRange range = genName(os, cb.V[i].second, Ctx.getASTContext());
-os << " is still referred to by the global variable '";
+os << " is still referred to by the ";
+if (isa(cb.V[i].first->getMemorySpace()))
+  os << "static";
+else
+  os << "global";
+os << " variable '";
 const VarRegion *VR = cast(cb.V[i].first->getBaseRegion());
 os << *VR->getDecl()
<< "' upon returning to the caller.  This will be a dangling reference";


Index: llvm/tools/clang/test/Analysis/stackaddrleak.c
===
--- llvm/tools/clang/test/Analysis/stackaddrleak.c
+++ llvm/tools/clang/test/Analysis/stackaddrleak.c
@@ -19,7 +19,7 @@
   p = (const char *) __builtin_alloca(12);
 } // expected-warning{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller.  This will be a dangling reference}}
 
-// PR 7383 - previosly the stack address checker would crash on this example
+// PR 7383 - previously the stack address checker would crash on this example
 //  because it would attempt to do a direct load from 'pr7383_list'. 
 static int pr7383(__const char *__)
 {
@@ -33,7 +33,7 @@
   int x;
   a = &x;
   b = &x;
-} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'b' upon returning}}
+} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'b' upon returning}}
 
 intptr_t returnAsNonLoc() {
   int x;
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -236,7 +236,12 @@
 SmallString<512> buf;
 llvm::raw_svector_ostream os(buf);
 SourceRange range = genName(os, cb.V[i].second, Ctx.getASTContext());
-os << " is still referred to by the global variable '";
+os << " is still referred to by the ";
+if (isa(cb.V[i].first->getMemorySpace()))
+  os << "static";
+else
+  os << "global";
+os << " variable '";
 const VarRegion *VR = cast(cb.V[i].first->getBaseRegion());
 os << *VR->getDecl()
<< "' upon returning to the caller.  This will be a dangling reference";

Re: [PATCH] D20011: [OpenMP 4.5] Parse+Sema for '#pragma omp declare target' clauses

2016-05-09 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268925: [OpenMP] Parse+Sema for '#pragma omp declare target' 
syntax version 4.5 (authored by dpolukhin).

Changed prior to commit:
  http://reviews.llvm.org/D20011?vs=56387&id=56582#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20011

Files:
  cfe/trunk/include/clang/AST/ASTMutationListener.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTWriter.h
  cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
  cfe/trunk/lib/Parse/ParseOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_target_messages.cpp

Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -1101,6 +1101,23 @@
 return false;
   }
 };
+
+class VarOrFuncDeclFilterCCC : public CorrectionCandidateCallback {
+private:
+  Sema &SemaRef;
+
+public:
+  explicit VarOrFuncDeclFilterCCC(Sema &S) : SemaRef(S) {}
+  bool ValidateCandidate(const TypoCorrection &Candidate) override {
+NamedDecl *ND = Candidate.getCorrectionDecl();
+if (isa(ND) || isa(ND)) {
+  return SemaRef.isDeclInScope(ND, SemaRef.getCurLexicalContext(),
+   SemaRef.getCurScope());
+}
+return false;
+  }
+};
+
 } // namespace
 
 ExprResult Sema::ActOnOpenMPIdExpression(Scope *CurScope,
@@ -10752,6 +10769,52 @@
   IsInOpenMPDeclareTargetContext = false;
 }
 
+void
+Sema::ActOnOpenMPDeclareTargetName(Scope *CurScope, CXXScopeSpec &ScopeSpec,
+   const DeclarationNameInfo &Id,
+   OMPDeclareTargetDeclAttr::MapTypeTy MT,
+   NamedDeclSetType &SameDirectiveDecls) {
+  LookupResult Lookup(*this, Id, LookupOrdinaryName);
+  LookupParsedName(Lookup, CurScope, &ScopeSpec, true);
+
+  if (Lookup.isAmbiguous())
+return;
+  Lookup.suppressDiagnostics();
+
+  if (!Lookup.isSingleResult()) {
+if (TypoCorrection Corrected =
+CorrectTypo(Id, LookupOrdinaryName, CurScope, nullptr,
+llvm::make_unique(*this),
+CTK_ErrorRecovery)) {
+  diagnoseTypo(Corrected, PDiag(diag::err_undeclared_var_use_suggest)
+  << Id.getName());
+  checkDeclIsAllowedInOpenMPTarget(nullptr, Corrected.getCorrectionDecl());
+  return;
+}
+
+Diag(Id.getLoc(), diag::err_undeclared_var_use) << Id.getName();
+return;
+  }
+
+  NamedDecl *ND = Lookup.getAsSingle();
+  if (isa(ND) || isa(ND)) {
+if (!SameDirectiveDecls.insert(cast(ND->getCanonicalDecl(
+  Diag(Id.getLoc(), diag::err_omp_declare_target_multiple) << Id.getName();
+
+if (!ND->hasAttr()) {
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(Context, MT);
+  ND->addAttr(A);
+  if (ASTMutationListener *ML = Context.getASTMutationListener())
+ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
+  checkDeclIsAllowedInOpenMPTarget(nullptr, ND);
+} else if (ND->getAttr()->getMapType() != MT) {
+  Diag(Id.getLoc(), diag::err_omp_declare_target_to_and_link)
+  << Id.getName();
+}
+  } else
+Diag(Id.getLoc(), diag::err_omp_invalid_target_decl) << Id.getName();
+}
+
 static void checkDeclInTargetContext(SourceLocation SL, SourceRange SR,
  Sema &SemaRef, Decl *D) {
   if (!D)
@@ -10765,9 +10828,11 @@
 // If this is an implicit variable that is legal and we do not need to do
 // anything.
 if (cast(D)->isImplicit()) {
-  D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(SemaRef.Context));
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+  D->addAttr(A);
   if (ASTMutationListener *ML = SemaRef.Context.getASTMutationListener())
-ML->DeclarationMarkedOpenMPDeclareTarget(D);
+ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
   return;
 }
 
@@ -10780,9 +10845,11 @@
 // target region (it can be e.g. a lambda) that is legal and we do not need
 // to do anything else.
 if (LD == D) {
-  D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(SemaRef.Context));
+  Attr *A = OMPDeclareTargetDeclAttr::CreateImplicit(
+  SemaRef.Context, OMPDeclareTargetDeclAttr::MT_To);
+  D->addAttr(A);
   if (ASTMutationListener *ML = SemaRef.Context.getASTMutationListener())
-ML->DeclarationMarkedOpenMPDeclareTarget(D);
+ML->DeclarationMarkedOpenMPDeclareTarget(D, 

r268925 - [OpenMP] Parse+Sema for '#pragma omp declare target' syntax version 4.5

2016-05-09 Thread Dmitry Polukhin via cfe-commits
Author: dpolukhin
Date: Mon May  9 09:59:13 2016
New Revision: 268925

URL: http://llvm.org/viewvc/llvm-project?rev=268925&view=rev
Log:
[OpenMP] Parse+Sema for '#pragma omp declare target' syntax version 4.5

Support OpenMP version 4.5 syntax for #pragma omp declare target.

Syntax:
  #pragma omp declare target (extended-list) new-line
or
  #pragma omp declare target clause[ [,] clause ... ] new-line

Where clause is one of the following:
  to(extended-list)
  link(list)

Differential Revision: http://reviews.llvm.org/D20011

Modified:
cfe/trunk/include/clang/AST/ASTMutationListener.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_target_ast_print.cpp
cfe/trunk/test/OpenMP/declare_target_messages.cpp

Modified: cfe/trunk/include/clang/AST/ASTMutationListener.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTMutationListener.h?rev=268925&r1=268924&r2=268925&view=diff
==
--- cfe/trunk/include/clang/AST/ASTMutationListener.h (original)
+++ cfe/trunk/include/clang/AST/ASTMutationListener.h Mon May  9 09:59:13 2016
@@ -111,7 +111,9 @@ public:
   /// previously marked as declaretarget.
   ///
   /// \param D the declaration marked OpenMP declaretarget.
-  virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D) {}
+  /// \param Attr the added attribute.
+  virtual void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
+const Attr *Attr) {}
 
   /// \brief A definition has been made visible by being redefined locally.
   ///

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=268925&r1=268924&r2=268925&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon May  9 09:59:13 2016
@@ -2345,8 +2345,17 @@ def OMPDeclareTargetDecl : Attr {
   let Spellings = [Pragma<"omp", "declare target">];
   let SemaHandler = 0;
   let Documentation = [OMPDeclareTargetDocs];
+  let Args = [
+EnumArgument<"MapType", "MapTypeTy",
+ [ "to", "link" ],
+ [ "MT_To", "MT_Link" ]>
+  ];
   let AdditionalMembers = [{
-void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) 
const {}
+void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) 
const {
+  // Use fake syntax because it is for testing and debugging purpose only.
+  if (getMapType() != MT_To)
+OS << ConvertMapTypeTyToStr(getMapType()) << " ";
+}
   }];
 }
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=268925&r1=268924&r2=268925&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May  9 09:59:13 
2016
@@ -967,6 +967,8 @@ def err_omp_declare_simd_inbranch_notinb
   "unexpected '%0' clause, '%1' is specified already">;
 def err_expected_end_declare_target : Error<
   "expected '#pragma omp end declare target'">;
+def err_omp_declare_target_unexpected_clause: Error<
+  "unexpected '%0' clause, only 'to' or 'link' clauses expected">;
 
 // Pragma loop support.
 def err_pragma_loop_missing_argument : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268925&r1=268924&r2=268925&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  9 09:59:13 
2016
@@ -7984,6 +7984,12 @@ def warn_omp_alignment_not_power_of_two
   InGroup;
 def err_omp_enclosed_declare_target : Error<
   "declare target region may not be enclosed within another declare target 
region">;
+def err_omp_invalid_target_decl : Error<
+  "%0 used in declare target directive is not a variable or a function name">;
+def err_omp_declare_target_multiple : Error<
+  "%0 appears multiple times in clauses on the same declare target directive">;
+def err_omp_declare_target_to_and_link : Error<
+  "%0 must not ap

Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-09 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 56581.
DmitryPolukhin added a comment.

- fixed tests for i686 when function may have hidden parameter


http://reviews.llvm.org/D18035

Files:
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/mangle-abi-tag.cpp
  test/SemaCXX/attr-abi-tag-syntax.cpp

Index: test/SemaCXX/attr-abi-tag-syntax.cpp
===
--- test/SemaCXX/attr-abi-tag-syntax.cpp
+++ test/SemaCXX/attr-abi-tag-syntax.cpp
@@ -16,28 +16,18 @@
 // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
 
 inline namespace N __attribute__((__abi_tag__)) {}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
 
 } // namespcace N2
 
 __attribute__((abi_tag("B", "A"))) extern int a1;
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-2 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "B"))) extern int a1;
 // expected-note@-1 {{previous declaration is here}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 __attribute__((abi_tag("A", "C"))) extern int a1;
 // expected-error@-1 {{'abi_tag' C missing in original declaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
 
 extern int a2;
 // expected-note@-1 {{previous declaration is here}}
 __attribute__((abi_tag("A")))extern int a2;
 // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
-// FIXME: remove this warning as soon as attribute fully supported.
-// expected-warning@-3 {{'abi_tag' attribute ignored}}
Index: test/CodeGenCXX/mangle-abi-tag.cpp
===
--- /dev/null
+++ test/CodeGenCXX/mangle-abi-tag.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s
+
+struct __attribute__((abi_tag("A", "B"))) A { };
+
+struct B: A { };
+
+template
+
+struct C {
+};
+
+struct D { A* p; };
+
+template
+struct __attribute__((abi_tag("C", "D"))) E {
+};
+
+struct __attribute__((abi_tag("A", "B"))) F { };
+
+A a1;
+// CHECK: @_Z2a1B1AB1B =
+
+__attribute__((abi_tag("C", "D")))
+A a2;
+// CHECK: @_Z2a2B1AB1BB1CB1D =
+
+B a3;
+// CHECK: @a3 =
+
+C a4;
+// CHECK: @_Z2a4B1AB1B =
+
+D a5;
+// CHECK: @a5 =
+
+E a6;
+// CHECK: @_Z2a6B1CB1D =
+
+E a7;
+// CHECK: @_Z2a7B1AB1BB1CB1D =
+
+template<>
+struct E {
+  static float a8;
+};
+float E::a8;
+// CHECK: @_ZN1EB1CB1DIfE2a8E =
+
+template<>
+struct E {
+  static bool a9;
+};
+bool E::a9;
+// CHECK: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
+
+struct __attribute__((abi_tag("A", "B"))) A10 {
+  virtual ~A10() {}
+} a10;
+// vtable
+// CHECK: @_ZTV3A10B1AB1B =
+// typeinfo
+// CHECK: @_ZTI3A10B1AB1B =
+
+// Local variables from f13.
+// f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
+// guard variable for f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
+// CHECK-DAG: @_ZGVZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
+
+__attribute__ ((abi_tag("C", "D")))
+void* f1() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f1B1CB1Dv(
+
+__attribute__ ((abi_tag("C", "D")))
+A* f2() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
+
+B* f3() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f3v(
+
+C* f4() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f4B1AB1Bv(
+
+D* f5() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f5v(
+
+E* f6() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f6B1CB1Dv(
+
+E* f7() {
+  return 0;
+}
+// CHECK: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(
+
+void f8(E*) {
+}
+// CHECK: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(
+
+inline namespace Names1 __attribute__((__abi_tag__)) {
+class C1 {};
+}
+C1 f9() { return C1(); }
+// CHECK: @_Z2f9B6Names1v(
+
+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
+class C2 {};
+}
+C2 f10() { return C2(); }
+// CHECK: @_Z3f10B4Tag1B4Tag2v(
+
+void __attribute__((abi_tag("A"))) f11(A) {}
+// f11[abi:A](A[abi:A][abi:B])
+// CHECK: define {{.*}} @_Z3f11B1A1AB1AB1B(
+
+A f12(A) { return A(); }
+// f12(A[abi:A][abi:B])
+// CHECK: define {{.*}} @_Z3f121AB1AB1B(
+
+inline void f13() {
+  struct L {
+static E* foo() {
+  static A10 a;
+  return 0;
+}
+  };
+  L::foo();
+}
+void f11_test() {
+  f13();
+}
+// f13()::L::foo[abi:C][abi:D]()
+// CHECK: define linkonce_odr %struct.E* @_ZZ3f13vEN1L3fooB1CB1DEv(
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4700,10 +4700,6 @@
   D->addAttr(::new (S.Conte

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.


Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.cpp:27
@@ +26,3 @@
+  SmallVector Matches;
+  if (!llvm::Regex(IWYUPragma).match(Text, &Matches))
+return false;

bkramer wrote:
> Isn't this regex just a complex way to write Text.find(IWYUPragma)?
Oh, didn't notice that. Yeah, we can use the `find` to handle the case.for now.


http://reviews.llvm.org/D19816



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


Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56579.
hokein marked an inline comment as done.
hokein added a comment.

Address comments.


http://reviews.llvm.org/D19816

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  include-fixer/find-all-symbols/CMakeLists.txt
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  include-fixer/find-all-symbols/FindAllSymbols.h
  include-fixer/find-all-symbols/HeaderMapCollector.h
  include-fixer/find-all-symbols/PragmaCommentHandler.cpp
  include-fixer/find-all-symbols/PragmaCommentHandler.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
  test/clang-tidy/misc-unused-using-decls.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -8,11 +8,14 @@
 //===--===//
 
 #include "FindAllSymbols.h"
+#include "HeaderMapCollector.h"
+#include "PragmaCommentHandler.h"
 #include "SymbolInfo.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -62,6 +65,41 @@
   std::vector Symbols;
 };
 
+class TestFindAllSymbolsAction : public clang::ASTFrontendAction {
+public:
+  TestFindAllSymbolsAction(FindAllSymbols::ResultReporter *Reporter)
+  : MatchFinder(), Collector(), Handler(&Collector),
+Matcher(Reporter, &Collector) {
+Matcher.registerMatchers(&MatchFinder);
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+StringRef InFile) override {
+Compiler.getPreprocessor().addCommentHandler(&Handler);
+return MatchFinder.newASTConsumer();
+  }
+
+private:
+  ast_matchers::MatchFinder MatchFinder;
+  HeaderMapCollector Collector;
+  PragmaCommentHandler Handler;
+  FindAllSymbols Matcher;
+};
+
+class TestFindAllSymbolsActionFactory
+: public clang::tooling::FrontendActionFactory {
+public:
+  TestFindAllSymbolsActionFactory(MockReporter *Reporter)
+  : Reporter(Reporter) {}
+  clang::FrontendAction *create() override {
+return new TestFindAllSymbolsAction(Reporter);
+  }
+
+private:
+  MockReporter *const Reporter;
+};
+
 class FindAllSymbolsTest : public ::testing::Test {
 public:
   bool hasSymbol(const SymbolInfo &Symbol) {
@@ -73,18 +111,16 @@
   }
 
   bool runFindAllSymbols(StringRef Code) {
-FindAllSymbols matcher(&Reporter);
-clang::ast_matchers::MatchFinder MatchFinder;
-matcher.registerMatchers(&MatchFinder);
-
 llvm::IntrusiveRefCntPtr InMemoryFileSystem(
 new vfs::InMemoryFileSystem);
 llvm::IntrusiveRefCntPtr Files(
 new FileManager(FileSystemOptions(), InMemoryFileSystem));
 
 std::string FileName = "symbol.cc";
-std::unique_ptr Factory =
-clang::tooling::newFrontendActionFactory(&MatchFinder);
+
+std::unique_ptr Factory(
+new TestFindAllSymbolsActionFactory(&Reporter));
+
 tooling::ToolInvocation Invocation(
 {std::string("find_all_symbols"), std::string("-fsyntax-only"),
  FileName},
@@ -371,5 +407,20 @@
   }
 }
 
+TEST_F(FindAllSymbolsTest, IWYUPrivatePragmaTest) {
+  static const char Code[] = R"(
+// IWYU pragma: private, include "bar.h"
+struct Bar {
+};
+  )";
+  runFindAllSymbols(Code);
+
+  {
+SymbolInfo Symbol =
+CreateSymbolInfo("Bar", SymbolInfo::Class, "bar.h", 3, {});
+EXPECT_TRUE(hasSymbol(Symbol));
+  }
+}
+
 } // namespace find_all_symbols
 } // namespace clang
Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -10,6 +10,21 @@
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,12 +39,25 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::UsedInstance;
+using n::UsedFunc;
+using n::UsedTemplateFunc;
+using n::UnusedInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+using n::Un

Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-09 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 56573.

http://reviews.llvm.org/D19865

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -338,3 +338,10 @@
   WeirdCopyCtorType neg_weird_1(orig, false);
   WeirdCopyCtorType neg_weird_2(orig, true);
 }
+
+void WarningOnlyMultiDeclStmt() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy = orig, copy2;
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.h
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.h
+++ clang-tidy/performance/UnnecessaryCopyInitialization.h
@@ -33,9 +33,10 @@
 
 private:
   void handleCopyFromMethodReturn(const VarDecl &Var, const Stmt &BlockStmt,
-  ASTContext &Context);
+  bool IssueFix, ASTContext &Context);
   void handleCopyFromLocalVar(const VarDecl &NewVar, const VarDecl &OldVar,
-  const Stmt &BlockStmt, ASTContext &Context);
+  const Stmt &BlockStmt, bool IssueFix,
+  ASTContext &Context);
 };
 
 } // namespace performance
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -20,10 +20,6 @@
 
 void recordFixes(const VarDecl &Var, ASTContext &Context,
  DiagnosticBuilder &Diagnostic) {
-  // Do not propose fixes in macros since we cannot place them correctly.
-  if (Var.getLocation().isMacroID())
-return;
-
   Diagnostic << utils::fixit::changeVarDeclToReference(Var, Context);
   if (!Var.getType().isLocalConstQualified())
 Diagnostic << utils::fixit::changeVarDeclToConst(Var);
@@ -57,14 +53,16 @@
   auto localVarCopiedFrom = [](const internal::Matcher &CopyCtorArg) {
 return compoundStmt(
forEachDescendant(
-   varDecl(hasLocalStorage(),
-   hasType(matchers::isExpensiveToCopy()),
-   hasInitializer(cxxConstructExpr(
-  hasDeclaration(cxxConstructorDecl(
-  isCopyConstructor())),
-  hasArgument(0, CopyCtorArg))
-  .bind("ctorCall")))
-   .bind("newVarDecl")))
+   declStmt(
+   has(varDecl(hasLocalStorage(),
+   hasType(matchers::isExpensiveToCopy()),
+   hasInitializer(
+   cxxConstructExpr(
+   hasDeclaration(cxxConstructorDecl(
+   isCopyConstructor())),
+   hasArgument(0, CopyCtorArg))
+   .bind("ctorCall")))
+   .bind("newVarDecl"))).bind("declStmt")))
 .bind("blockStmt");
   };
 
@@ -84,6 +82,11 @@
   const auto *OldVar = Result.Nodes.getNodeAs("oldVarDecl");
   const auto *BlockStmt = Result.Nodes.getNodeAs("blockStmt");
   const auto *CtorCall = Result.Nodes.getNodeAs("ctorCall");
+  // Do not propose fixes if the DeclStmt has multiple VarDecls or in macros
+  // since we cannot place them correctly.
+  bool IssueFix =
+  Result.Nodes.getNodeAs("declStmt")->isSingleDecl() &&
+  !NewVar->getLocation().isMacroID();
 
   // A constructor that looks like T(const T& t, bool arg = false) counts as a
   // copy only when it is called with default arguments for the arguments after
@@ -93,14 +96,16 @@
   return;
 
   if (OldVar == nullptr) {
-handleCopyFromMethodReturn(*NewVar, *BlockStmt, *Result.Context);
+handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, *Result.Context);
   } else {
-handleCopyFromLocalVar(*NewVar, *OldVar, *BlockStmt, *Result.Context);
+handleCopyFromLocalVar(*NewVar, *OldVar, *BlockStmt, IssueFix,
+   *Result.Context);
   }
 }
 
 void UnnecessaryCopyInitialization::handleCopyFromMethodReturn

Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-09 Thread Felix Berger via cfe-commits
flx added a comment.

In http://reviews.llvm.org/D19865#423140, @flx wrote:

> In http://reviews.llvm.org/D19865#419905, @flx wrote:
>
> > In http://reviews.llvm.org/D19865#419830, @alexfh wrote:
> >
> > > Is it a workaround to avoid breaking the code by incorrect fixes?
> >
> >
> > Yes. We can't simply change the type of DeclStmt when we only look one of 
> > the VarDecls and how it is initialized.
>
>
> Also, all tests still pass. Alex, do you have any particular concern with 
> this approach?




In http://reviews.llvm.org/D19865#423286, @alexfh wrote:

> In http://reviews.llvm.org/D19865#423140, @flx wrote:
>
> > In http://reviews.llvm.org/D19865#419905, @flx wrote:
> >
> > > In http://reviews.llvm.org/D19865#419830, @alexfh wrote:
> > >
> > > > Is it a workaround to avoid breaking the code by incorrect fixes?
> > >
> > >
> > > Yes. We can't simply change the type of DeclStmt when we only look one of 
> > > the VarDecls and how it is initialized.
> >
> >
> > Also, all tests still pass. Alex, do you have any particular concern with 
> > this approach?
>
>
> Even if we can't easily provide an automated fix (we could teach the check to 
> split declarations, but it might not worth the effort), we could still emit a 
> warning. WDYT?


Sounds good. Done. We now still issue the warning, but don't issue fixes when 
it's not a single decl.


http://reviews.llvm.org/D19865



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


Re: [PATCH] D20066: [include-fixer] Autodetect yaml databases in parent directories.

2016-05-09 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268920: [include-fixer] Autodetect yaml databases in parent 
directories. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D20066?vs=56570&id=56575#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20066

Files:
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp

Index: clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp
===
--- clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp
@@ -0,0 +1,12 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/foo/bar
+// RUN: cp %p/Inputs/fake_yaml_db.yaml %T/find_all_symbols_db.yaml
+// RUN: cd %T/foo
+// RUN: sed -e 's#//.*$##' %s > bar/test.cpp
+// RUN: clang-include-fixer -db=yaml bar/test.cpp --
+// RUN: FileCheck %s -input-file=bar/test.cpp
+
+// CHECK: #include "foo.h"
+// CHECK: b::a::foo f;
+
+b::a::foo f;
Index: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
===
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
@@ -8,27 +8,43 @@
 //===--===//
 
 #include "YamlXrefsDB.h"
-
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 
 using clang::find_all_symbols::SymbolInfo;
 
 namespace clang {
 namespace include_fixer {
 
-YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
-  int ReadFD = 0;
-  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
-return;
-  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+llvm::ErrorOr>
+YamlXrefsDB::createFromFile(llvm::StringRef FilePath) {
+  auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
   if (!Buffer)
-return;
-  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
-  Buffer.get()->getBuffer());
+return Buffer.getError();
+
+  return std::unique_ptr(
+  new YamlXrefsDB(clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer(;
+}
+
+llvm::ErrorOr>
+YamlXrefsDB::createFromDirectory(llvm::StringRef Directory,
+ llvm::StringRef Name) {
+  // Walk upwards from Directory, looking for files.
+  for (llvm::SmallString<128> PathStorage = Directory; !Directory.empty();
+   Directory = llvm::sys::path::parent_path(Directory)) {
+assert(Directory.size() <= PathStorage.size());
+PathStorage.resize(Directory.size()); // Shrink to parent.
+llvm::sys::path::append(PathStorage, Name);
+if (auto DB = createFromFile(PathStorage))
+  return DB;
+  }
+  return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
 std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -73,8 +73,26 @@
 break;
   }
   case yaml: {
-XrefsDBMgr->addXrefsDB(
-llvm::make_unique(Input));
+llvm::ErrorOr> DB(nullptr);
+if (!Input.empty()) {
+  DB = include_fixer::YamlXrefsDB::createFromFile(Input);
+} else {
+  // If we don't have any input file, look in the directory of the first
+  // file and its parents.
+  SmallString<128> AbsolutePath(
+  tooling::getAbsolutePath(options.getSourcePathList().front()));
+  StringRef Directory = llvm::sys::path::parent_path(AbsolutePath);
+  DB = include_fixer::YamlXrefsDB::createFromDirectory(
+  Directory, "find_all_symbols_db.yaml");
+}
+
+if (!DB) {
+  llvm::errs() << "Couldn't find YAML db: " << DB.getError().message()
+   << '\n';
+  return 1;
+}
+
+XrefsDBMgr->addXrefsDB(std::move(*DB));
 break;
   }
   }
Index: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
===
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
@@ -12,6 +12,7 @@
 
 #include "XrefsDB.h"
 #include "find-all-symbols/SymbolInfo.h"
+#include "llvm/Support/ErrorOr.h"
 #include 
 #include 
 
@@ -21,12 +22,20 @@
 /// Yaml format database.
 class YamlXrefsDB : public XrefsDB {
 public:
-  YamlXrefsDB(llvm::StringRef FilePath);
+  /// Create a new Yaml db from a file.
+  static llvm::ErrorOr>
+  c

[clang-tools-extra] r268920 - [include-fixer] Autodetect yaml databases in parent directories.

2016-05-09 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon May  9 09:14:55 2016
New Revision: 268920

URL: http://llvm.org/viewvc/llvm-project?rev=268920&view=rev
Log:
[include-fixer] Autodetect yaml databases in parent directories.

This looks for find_all_symbols_db.yaml in all parent directories of the
source file (like we do for compile_commands.json) so we don't have to
pass the path manually.

Differential Revision: http://reviews.llvm.org/D20066

Added:
clang-tools-extra/trunk/test/include-fixer/yamldb_autodetect.cpp
Modified:
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp?rev=268920&r1=268919&r2=268920&view=diff
==
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp Mon May  9 09:14:55 
2016
@@ -8,10 +8,11 @@
 
//===--===//
 
 #include "YamlXrefsDB.h"
-
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 
@@ -20,15 +21,30 @@ using clang::find_all_symbols::SymbolInf
 namespace clang {
 namespace include_fixer {
 
-YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
-  int ReadFD = 0;
-  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
-return;
-  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+llvm::ErrorOr>
+YamlXrefsDB::createFromFile(llvm::StringRef FilePath) {
+  auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
   if (!Buffer)
-return;
-  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
-  Buffer.get()->getBuffer());
+return Buffer.getError();
+
+  return std::unique_ptr(
+  new YamlXrefsDB(clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer(;
+}
+
+llvm::ErrorOr>
+YamlXrefsDB::createFromDirectory(llvm::StringRef Directory,
+ llvm::StringRef Name) {
+  // Walk upwards from Directory, looking for files.
+  for (llvm::SmallString<128> PathStorage = Directory; !Directory.empty();
+   Directory = llvm::sys::path::parent_path(Directory)) {
+assert(Directory.size() <= PathStorage.size());
+PathStorage.resize(Directory.size()); // Shrink to parent.
+llvm::sys::path::append(PathStorage, Name);
+if (auto DB = createFromFile(PathStorage))
+  return DB;
+  }
+  return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
 std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {

Modified: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h?rev=268920&r1=268919&r2=268920&view=diff
==
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h Mon May  9 09:14:55 2016
@@ -12,6 +12,7 @@
 
 #include "XrefsDB.h"
 #include "find-all-symbols/SymbolInfo.h"
+#include "llvm/Support/ErrorOr.h"
 #include 
 #include 
 
@@ -21,12 +22,20 @@ namespace include_fixer {
 /// Yaml format database.
 class YamlXrefsDB : public XrefsDB {
 public:
-  YamlXrefsDB(llvm::StringRef FilePath);
+  /// Create a new Yaml db from a file.
+  static llvm::ErrorOr>
+  createFromFile(llvm::StringRef FilePath);
+  /// Look for a file called \c Name in \c Directory and all parent 
directories.
+  static llvm::ErrorOr>
+  createFromDirectory(llvm::StringRef Directory, llvm::StringRef Name);
 
   std::vector
   search(llvm::StringRef Identifier) override;
 
 private:
+  explicit YamlXrefsDB(std::vector 
Symbols)
+  : Symbols(std::move(Symbols)) {}
+
   std::vector Symbols;
 };
 

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=268920&r1=268919&r2=268920&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Mon May  9 
09:14:55 2016
@@ -73,8 +73,26 @@ int includeFixerMain(int argc, const cha
 break;
   }
   case yaml: {
-XrefsDBMgr->addXrefsDB(
-llvm::make_unique(Input));
+llvm::ErrorOr> DB(nullptr);
+if (!Input.empty()) {
+  DB = include_fixer::YamlXrefsDB::createFromFile(Input);
+} else {
+  // If we don't have any input file, look in the directory of the first
+  // f

Re: [PATCH] D20066: [include-fixer] Autodetect yaml databases in parent directories.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D20066



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.

2016-05-09 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In http://reviews.llvm.org/D18369#424347, @pxli168 wrote:

> In http://reviews.llvm.org/D18369#422367, @yaxunl wrote:
>
> > In http://reviews.llvm.org/D18369#421963, @pxli168 wrote:
> >
> > > If we want to save some space, could we use some macro to expand the 
> > > gentype or some script to expand the gentype into each types when the 
> > > clang is build?
> >
> >
> > We need to balance between space and readability. When I absorbed 
> > __attribute__((overloadable)) into __const_func to save space, it did not 
> > sacrifice readability. However using macro with gentype will cause the 
> > header file more difficult to read.
>
>
> But I don't think this kind of so long header is easy to read, it contains 
> full pages of the same function with different types and it is hard to see if 
> anyone is missing or find where these functions end. In spec builtin 
> functions can be represented by
>
> > gentype ctz (gentype x)
>
> >  gentype max (gentype x, gentype y)
>
> >  gentype max (gentype x, sgentype y)
>
>
> If we could use some macro or script to generate the actual builtin 
> functions, it seems more likely spec and clear to read, also will avoid 
> missing or typo.


For simple cases, we could define something like this:

#define MATH_FUN(F) \
float F(float x); \
double F(double x); \
half F(half x);

MATH_FUN(sin)
MATH_FUN(cos)

It could be concise without sacrificing much clarity. However, for more 
complicated patterns, like

uchar8 __const_func convert_uchar8_rtn(int8);

It seems hard to balance between readability and brevity. Mostly it will ends 
up with multiple layers of macros calling each other, and the original function 
declarations obscured. This also opens Pandora's box of subjectivity of 
readability.

I think using macro and not using macro both have advantages and disadvantages. 
That's why I did not take efforts to change one representation to another.

It will take considerable efforts to define all builtin functions as macros, 
whereas this review already dragged too long.

Anastasia, what's your suggestion? Thanks.


http://reviews.llvm.org/D18369



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


[PATCH] D20066: [include-fixer] Autodetect yaml databases in parent directories.

2016-05-09 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: hokein.
bkramer added a subscriber: cfe-commits.

This looks for find_all_symbols_db.yaml in all parent directories of the
source file (like we do for compile_commands.json) so we don't have to
pass the path manually.

http://reviews.llvm.org/D20066

Files:
  include-fixer/YamlXrefsDB.cpp
  include-fixer/YamlXrefsDB.h
  include-fixer/tool/ClangIncludeFixer.cpp
  test/include-fixer/yamldb_autodetect.cpp

Index: test/include-fixer/yamldb_autodetect.cpp
===
--- /dev/null
+++ test/include-fixer/yamldb_autodetect.cpp
@@ -0,0 +1,12 @@
+// REQUIRES: shell
+// RUN: mkdir -p %T/foo/bar
+// RUN: cp %p/Inputs/fake_yaml_db.yaml %T/find_all_symbols_db.yaml
+// RUN: cd %T/foo
+// RUN: sed -e 's#//.*$##' %s > bar/test.cpp
+// RUN: clang-include-fixer -db=yaml bar/test.cpp --
+// RUN: FileCheck %s -input-file=bar/test.cpp
+
+// CHECK: #include "foo.h"
+// CHECK: b::a::foo f;
+
+b::a::foo f;
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -73,8 +73,26 @@
 break;
   }
   case yaml: {
-XrefsDBMgr->addXrefsDB(
-llvm::make_unique(Input));
+llvm::ErrorOr> DB(nullptr);
+if (!Input.empty()) {
+  DB = include_fixer::YamlXrefsDB::createFromFile(Input);
+} else {
+  // If we don't have any input file, look in the directory of the first
+  // file and its parents.
+  SmallString<128> AbsolutePath(
+  tooling::getAbsolutePath(options.getSourcePathList().front()));
+  StringRef Directory = llvm::sys::path::parent_path(AbsolutePath);
+  DB = include_fixer::YamlXrefsDB::createFromDirectory(
+  Directory, "find_all_symbols_db.yaml");
+}
+
+if (!DB) {
+  llvm::errs() << "Couldn't find YAML db: " << DB.getError().message()
+   << '\n';
+  return 1;
+}
+
+XrefsDBMgr->addXrefsDB(std::move(*DB));
 break;
   }
   }
Index: include-fixer/YamlXrefsDB.h
===
--- include-fixer/YamlXrefsDB.h
+++ include-fixer/YamlXrefsDB.h
@@ -12,6 +12,7 @@
 
 #include "XrefsDB.h"
 #include "find-all-symbols/SymbolInfo.h"
+#include "llvm/Support/ErrorOr.h"
 #include 
 #include 
 
@@ -21,12 +22,20 @@
 /// Yaml format database.
 class YamlXrefsDB : public XrefsDB {
 public:
-  YamlXrefsDB(llvm::StringRef FilePath);
+  /// Create a new Yaml db from a file.
+  static llvm::ErrorOr>
+  createFromFile(llvm::StringRef FilePath);
+  /// Look for a file called \c Name in \c Directory and all parent directories.
+  static llvm::ErrorOr>
+  createFromDirectory(llvm::StringRef Directory, llvm::StringRef Name);
 
   std::vector
   search(llvm::StringRef Identifier) override;
 
 private:
+  explicit YamlXrefsDB(std::vector Symbols)
+  : Symbols(std::move(Symbols)) {}
+
   std::vector Symbols;
 };
 
Index: include-fixer/YamlXrefsDB.cpp
===
--- include-fixer/YamlXrefsDB.cpp
+++ include-fixer/YamlXrefsDB.cpp
@@ -8,27 +8,43 @@
 //===--===//
 
 #include "YamlXrefsDB.h"
-
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Errc.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 
 using clang::find_all_symbols::SymbolInfo;
 
 namespace clang {
 namespace include_fixer {
 
-YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
-  int ReadFD = 0;
-  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
-return;
-  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+llvm::ErrorOr>
+YamlXrefsDB::createFromFile(llvm::StringRef FilePath) {
+  auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
   if (!Buffer)
-return;
-  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
-  Buffer.get()->getBuffer());
+return Buffer.getError();
+
+  return std::unique_ptr(
+  new YamlXrefsDB(clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer(;
+}
+
+llvm::ErrorOr>
+YamlXrefsDB::createFromDirectory(llvm::StringRef Directory,
+ llvm::StringRef Name) {
+  // Walk upwards from Directory, looking for files.
+  for (llvm::SmallString<128> PathStorage = Directory; !Directory.empty();
+   Directory = llvm::sys::path::parent_path(Directory)) {
+assert(Directory.size() <= PathStorage.size());
+PathStorage.resize(Directory.size()); // Shrink to parent.
+llvm::sys::path::append(PathStorage, Name);
+if (auto DB = createFromFile(PathStorage))
+  return DB;
+  }
+  return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
 }
 
 std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {
___

Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-05-09 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


http://reviews.llvm.org/D19322



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


Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-09 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268919: [clang-tidy] new google-default-arguments check 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19534?vs=56529&id=56569#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19534

Files:
  clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
  clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/google-default-arguments.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/google-default-arguments.cpp

Index: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  DefaultArgumentsCheck.cpp
   ExplicitConstructorCheck.cpp
   ExplicitMakePairCheck.cpp
   GlobalNamesInHeadersCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+/// Checks that default parameters are not given for virtual methods.
+///
+/// See https://google.github.io/styleguide/cppguide.html#Default_Arguments
+class DefaultArgumentsCheck : public ClangTidyCheck {
+public:
+  DefaultArgumentsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace google
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
Index: clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
 #include "GlobalNamesInHeadersCheck.h"
@@ -42,6 +43,8 @@
 "google-build-namespaces");
 CheckFactories.registerCheck(
 "google-build-using-namespace");
+CheckFactories.registerCheck(
+"google-default-arguments");
 CheckFactories.registerCheck(
 "google-explicit-constructor");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
@@ -0,0 +1,36 @@
+//===--- DefaultArgumentsCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DefaultArgumentsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+void DefaultArgumentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxMethodDecl(anyOf(isOverride(), isVirtual()),
+hasAnyParameter(parmVarDecl(hasInitializer(expr()
+  .bind("Decl"),
+  this);
+}
+
+void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("Decl");
+  diag(MatchedDecl->g

[clang-tools-extra] r268919 - [clang-tidy] new google-default-arguments check

2016-05-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon May  9 08:43:58 2016
New Revision: 268919

URL: http://llvm.org/viewvc/llvm-project?rev=268919&view=rev
Log:
[clang-tidy] new google-default-arguments check

Summary:
To check the google style guide rule here:
https://google.github.io/styleguide/cppguide.html#Default_Arguments

Patch by Clement Courbet!

Reviewers: hokein

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19534

Added:
clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/google-default-arguments.rst
clang-tools-extra/trunk/test/clang-tidy/google-default-arguments.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/google/GoogleTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt?rev=268919&r1=268918&r2=268919&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/google/CMakeLists.txt Mon May  9 
08:43:58 2016
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyGoogleModule
   AvoidCStyleCastsCheck.cpp
+  DefaultArgumentsCheck.cpp
   ExplicitConstructorCheck.cpp
   ExplicitMakePairCheck.cpp
   GlobalNamesInHeadersCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp?rev=268919&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.cpp Mon May 
 9 08:43:58 2016
@@ -0,0 +1,36 @@
+//===--- DefaultArgumentsCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DefaultArgumentsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+void DefaultArgumentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxMethodDecl(anyOf(isOverride(), isVirtual()),
+hasAnyParameter(parmVarDecl(hasInitializer(expr()
+  .bind("Decl"),
+  this);
+}
+
+void DefaultArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedDecl = Result.Nodes.getNodeAs("Decl");
+  diag(MatchedDecl->getLocation(),
+   "default arguments on virtual or override methods are prohibited");
+}
+
+} // namespace google
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h?rev=268919&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/google/DefaultArgumentsCheck.h Mon May  
9 08:43:58 2016
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCheck.h - clang-tidy*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+/// Checks that default parameters are not given for virtual methods.
+///
+/// See https://google.github.io/styleguide/cppguide.html#Default_Arguments
+class DefaultArgumentsCheck : public ClangTidyCheck {
+public:
+  DefaultArgumentsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace google
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H

Modified: 

Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268917: Support variables and functions types in 
misc-unused-using-decls. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D20018?vs=56566&id=56568#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20018

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -10,6 +10,32 @@
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+class G { public: static void func() {} };
+class H { public: static int i; };
+class I {
+ public:
+  static int ii;
+};
+
+class Base {
+ public:
+  void f();
+};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,12 +50,37 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::G;
+using n::H;
+using n::I;
+int I::ii = 1;
+class Derived : public n::Base {
+ public:
+  using Base::f;
+};
+using n::UsedInstance;
+using n::UsedFunc;
+using n::UsedTemplateFunc;
+using n::UnusedInstance; // UnusedInstance
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-FIXES: {{^}}// UnusedInstance
+using n::UnusedFunc; // UnusedFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-FIXES: {{^}}// UnusedFunc
+using n::cout;
+using n::endl;
 
 // - Usages -
 void f(B b);
 void g() {
   vector data;
   D::i = 1;
   F f;
+  void (*func)() = &G::func;
+  int *i = &H::i;
+  UsedInstance.i;
+  UsedFunc();
+  UsedTemplateFunc();
+  cout << endl;
 }
 
Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -23,6 +23,7 @@
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
+  Finder->addMatcher(declRefExpr().bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -34,8 +35,13 @@
 const auto *TargetDecl =
 Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
 
-// FIXME: Handle other target types.
-if (!isa(TargetDecl) && !isa(TargetDecl))
+// Ignores using-declarations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;
+
+if (!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl))
   return;
 
 FoundDecls[TargetDecl] = Using;
@@ -57,10 +63,26 @@
 if (const auto *Specialization =
 dyn_cast(Used))
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used);
+return;
   }
+
+  if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+  else
+removeFromFoundDecls(FD);
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD);
+}
+  }
+}
+
+void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  auto I = FoundDecls.find(D->getCanonicalDecl());
+  if (I != FoundDecls.end())
+I->second = nullptr;
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -30,6 +30,8 @@
   void onEndOfTranslationUnit() override;
 
 private:
+  void removeFromFoundDecls(const Decl *D);
+
   llvm::DenseMap FoundDecls;
   llvm::DenseMap FoundRanges;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.or

[clang-tools-extra] r268917 - Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon May  9 08:37:12 2016
New Revision: 268917

URL: http://llvm.org/viewvc/llvm-project?rev=268917&view=rev
Log:
Support variables and functions types in misc-unused-using-decls.

Summary: Fix PR27429.

Reviewers: djasper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20018

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=268917&r1=268916&r2=268917&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Mon May  
9 08:37:12 2016
@@ -23,6 +23,7 @@ void UnusedUsingDeclsCheck::registerMatc
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
+  Finder->addMatcher(declRefExpr().bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -34,8 +35,13 @@ void UnusedUsingDeclsCheck::check(const
 const auto *TargetDecl =
 Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
 
-// FIXME: Handle other target types.
-if (!isa(TargetDecl) && !isa(TargetDecl))
+// Ignores using-declarations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;
+
+if (!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl))
   return;
 
 FoundDecls[TargetDecl] = Using;
@@ -57,10 +63,26 @@ void UnusedUsingDeclsCheck::check(const
 if (const auto *Specialization =
 dyn_cast(Used))
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used);
+return;
   }
+
+  if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+  else
+removeFromFoundDecls(FD);
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD);
+}
+  }
+}
+
+void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  auto I = FoundDecls.find(D->getCanonicalDecl());
+  if (I != FoundDecls.end())
+I->second = nullptr;
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h?rev=268917&r1=268916&r2=268917&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.h Mon May  9 
08:37:12 2016
@@ -30,6 +30,8 @@ public:
   void onEndOfTranslationUnit() override;
 
 private:
+  void removeFromFoundDecls(const Decl *D);
+
   llvm::DenseMap FoundDecls;
   llvm::DenseMap FoundRanges;
 };

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=268917&r1=268916&r2=268917&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Mon May 
 9 08:37:12 2016
@@ -10,6 +10,32 @@ class D;
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+class G { public: static void func() {} };
+class H { public: static int i; };
+class I {
+ public:
+  static int ii;
+};
+
+class Base {
+ public:
+  void f();
+};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,6 +50,25 @@ using n::E; // E
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::G;
+using n::H;
+using n::I;
+int I::ii = 1;
+class Derived : public n::Base {
+ public:
+  using Base::f;

Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D20018



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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56566.
hokein added a comment.

Address remaining comments.


http://reviews.llvm.org/D20018

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -10,6 +10,32 @@
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+class G { public: static void func() {} };
+class H { public: static int i; };
+class I {
+ public:
+  static int ii;
+};
+
+class Base {
+ public:
+  void f();
+};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,12 +50,37 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::G;
+using n::H;
+using n::I;
+int I::ii = 1;
+class Derived : public n::Base {
+ public:
+  using Base::f;
+};
+using n::UsedInstance;
+using n::UsedFunc;
+using n::UsedTemplateFunc;
+using n::UnusedInstance; // UnusedInstance
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-FIXES: {{^}}// UnusedInstance
+using n::UnusedFunc; // UnusedFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-FIXES: {{^}}// UnusedFunc
+using n::cout;
+using n::endl;
 
 // - Usages -
 void f(B b);
 void g() {
   vector data;
   D::i = 1;
   F f;
+  void (*func)() = &G::func;
+  int *i = &H::i;
+  UsedInstance.i;
+  UsedFunc();
+  UsedTemplateFunc();
+  cout << endl;
 }
 
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -30,6 +30,8 @@
   void onEndOfTranslationUnit() override;
 
 private:
+  void removeFromFoundDecls(const Decl *D);
+
   llvm::DenseMap FoundDecls;
   llvm::DenseMap FoundRanges;
 };
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -23,6 +23,7 @@
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
+  Finder->addMatcher(declRefExpr().bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -34,8 +35,13 @@
 const auto *TargetDecl =
 Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
 
-// FIXME: Handle other target types.
-if (!isa(TargetDecl) && !isa(TargetDecl))
+// Ignores using-declarations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;
+
+if (!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl))
   return;
 
 FoundDecls[TargetDecl] = Using;
@@ -57,10 +63,26 @@
 if (const auto *Specialization =
 dyn_cast(Used))
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used);
+return;
   }
+
+  if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+  else
+removeFromFoundDecls(FD);
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD);
+}
+  }
+}
+
+void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  auto I = FoundDecls.find(D->getCanonicalDecl());
+  if (I != FoundDecls.end())
+I->second = nullptr;
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] Proper detection and handling of RHEL and variants

2016-05-09 Thread Rafael Espíndola via cfe-commits
r268914.

Thanks,
Rafael

On 26 March 2016 at 20:35, Michael Lampe  wrote:
> New patch attached. I've also removed RHEL4 which is now four years past EOL
> and certainly incapable of building or running any recent version of
> llvm/clang.
>
> -Michael
>
>
> Rafael Espíndola wrote:
>>
>> -  if (IsRedhat(Distro))
>> +  if (Distro == Fedora || Distro == RHEL7)
>>
>> RHEL8 will probably use --no-add-needed.
>>
>> Can you change this to "if (IsRedhat(Distro) && !old_rhel_distro) "?
>>
>> Cheers,
>> Rafael
>>
>>
>> On 22 March 2016 at 22:07, Michael Lampe via cfe-commits
>>  wrote:
>>>
>>> - Don't consider "/etc/lsb-release" to be Ubuntu only.
>>> - Detect SL, too.
>>> - Only add "--no-add-needed" for RHEL7 (or Fedora), not for RHEL6 (that's
>>> what the compilers shipped with RHEL do).
>>>
>>>
>>> ___
>>> 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


r268914 - Proper detection and handling of RHEL and variants.

2016-05-09 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon May  9 08:13:50 2016
New Revision: 268914

URL: http://llvm.org/viewvc/llvm-project?rev=268914&view=rev
Log:
Proper detection and handling of RHEL and variants.

- Don't consider "/etc/lsb-release" to be Ubuntu only.
- Detect SL, too.
- Only add "--no-add-needed" for RHEL7 (or Fedora), not for RHEL6
  (that's what the compilers shipped with RHEL do).
- removed RHEL4 which is now four years past EOL and certainly incapable
  of building or running any recent version of llvm/clang.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268914&r1=268913&r2=268914&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon May  9 08:13:50 2016
@@ -3421,7 +3421,6 @@ enum Distro {
   DebianJessie,
   DebianStretch,
   Exherbo,
-  RHEL4,
   RHEL5,
   RHEL6,
   RHEL7,
@@ -3448,7 +3447,7 @@ enum Distro {
 };
 
 static bool IsRedhat(enum Distro Distro) {
-  return Distro == Fedora || (Distro >= RHEL4 && Distro <= RHEL7);
+  return Distro == Fedora || (Distro >= RHEL5 && Distro <= RHEL7);
 }
 
 static bool IsOpenSUSE(enum Distro Distro) { return Distro == OpenSUSE; }
@@ -3490,7 +3489,8 @@ static Distro DetectDistro(const Driver
   .Case("wily", UbuntuWily)
   .Case("xenial", UbuntuXenial)
   .Default(UnknownDistro);
-return Version;
+if (Version != UnknownDistro)
+  return Version;
   }
 
   File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
@@ -3499,15 +3499,14 @@ static Distro DetectDistro(const Driver
 if (Data.startswith("Fedora release"))
   return Fedora;
 if (Data.startswith("Red Hat Enterprise Linux") ||
-Data.startswith("CentOS")) {
+Data.startswith("CentOS") ||
+Data.startswith("Scientific Linux")) {
   if (Data.find("release 7") != StringRef::npos)
 return RHEL7;
   else if (Data.find("release 6") != StringRef::npos)
 return RHEL6;
   else if (Data.find("release 5") != StringRef::npos)
 return RHEL5;
-  else if (Data.find("release 4") != StringRef::npos)
-return RHEL4;
 }
 return UnknownDistro;
   }
@@ -3732,11 +3731,11 @@ Linux::Linux(const Driver &D, const llvm
   ExtraOpts.push_back("--hash-style=both");
   }
 
-  if (IsRedhat(Distro))
+  if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
 ExtraOpts.push_back("--no-add-needed");
 
   if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro) ||
-  (IsRedhat(Distro) && Distro != RHEL4 && Distro != RHEL5) ||
+  (IsRedhat(Distro) && Distro != RHEL5) ||
   (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
 ExtraOpts.push_back("--build-id");
 


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


Re: [PATCH] D18182: [test] Don't use UNSUPPORTED in FileCheck prefixes

2016-05-09 Thread Simon Pilgrim via cfe-commits
RKSimon added a subscriber: RKSimon.
RKSimon added a comment.

This appears to have been fixed in http://reviews.llvm.org/rL265218


http://reviews.llvm.org/D18182



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


Re: [PATCH] RHEL: Look in more places to find g++ headers and runtime

2016-05-09 Thread Rafael Espíndola via cfe-commits
r268912.

Thanks,
Rafael


On 6 May 2016 at 17:06, Michael Lampe  wrote:
> No, I'm hoping on someone else to commit this. (You?)
>
> Same with this one:
>
> https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg18696.html
>
> -Michael
>
>
> Rafael Espíndola wrote:
>>
>> LGTM. Do you have commit access?
>>
>> Cheers,
>> Rafael
>>
>>
>> On 11 April 2016 at 14:49, Michael Lampe 
>> wrote:
>>>
>>> New patch attached.
>>>
>>> -Michael
>>>
>>>
>>> Rafael Espíndola wrote:


 LGTM with a comment saying why it is needed.

 Cheers,
 Rafael


 On 22 March 2016 at 23:02, Michael Lampe via cfe-commits
  wrote:
>
>
> Some distros with ten years of support ship an old gcc but later offer
> more
> recent versions for installation in parallel. These versions are
> typically
> not only needed for the compilation of llvm/clang, but also to properly
> use
> the clang binary that comes out.
>
> Clang already searches /usr at runtime for the most recent installation
> of
> gcc. This patch appends paths for add-on installations of gcc in RHEL.
>
>
> ___
> 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


r268912 - RHEL: Look in more places to find g++ headers and runtime.

2016-05-09 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon May  9 08:03:10 2016
New Revision: 268912

URL: http://llvm.org/viewvc/llvm-project?rev=268912&view=rev
Log:
RHEL: Look in more places to find g++ headers and runtime.

Some distros with ten years of support ship an old gcc but later offer
more recent versions for installation in parallel. These versions are
typically not only needed for the compilation of llvm/clang, but also to
properly use the clang binary that comes out.

Clang already searches /usr at runtime for the most recent installation
of gcc. This patch appends paths for add-on installations of gcc in
RHEL.

Patch by Michael Lampe.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=268912&r1=268911&r2=268912&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon May  9 08:03:10 2016
@@ -1410,9 +1410,17 @@ void Generic_GCC::GCCInstallationDetecto
 // Then look for gcc installed alongside clang.
 Prefixes.push_back(D.InstalledDir + "/..");
 
-// And finally in /usr.
-if (D.SysRoot.empty())
+// Then look for distribution supplied gcc installations.
+if (D.SysRoot.empty()) {
+  // Look for RHEL devtoolsets.
+  Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-2/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-1.1/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-1.0/root/usr");
+  // And finally in /usr.
   Prefixes.push_back("/usr");
+}
   }
 
   // Loop over the various components which exist and select the best GCC


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


r268910 - [clang][AVX512] completing missing intrinsics [vmin/vmax].

2016-05-09 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon May  9 07:38:49 2016
New Revision: 268910

URL: http://llvm.org/viewvc/llvm-project?rev=268910&view=rev
Log:
[clang][AVX512] completing missing intrinsics [vmin/vmax].

Differential Revision: http://reviews.llvm.org/D20062


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268910&r1=268909&r2=268910&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon May  9 07:38:49 2016
@@ -735,6 +735,27 @@ _mm512_max_pd(__m512d __A, __m512d __B)
  _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_max_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B)
+{
+  return (__m512d) __builtin_ia32_maxpd512_mask ((__v8df) __A,
+  (__v8df) __B,
+  (__v8df) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_maskz_max_pd (__mmask8 __U, __m512d __A, __m512d __B)
+{
+  return (__m512d) __builtin_ia32_maxpd512_mask ((__v8df) __A,
+  (__v8df) __B,
+  (__v8df)
+  _mm512_setzero_pd (),
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
 static  __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_max_ps(__m512 __A, __m512 __B)
 {
@@ -746,6 +767,27 @@ _mm512_max_ps(__m512 __A, __m512 __B)
 _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask_max_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B)
+{
+  return (__m512) __builtin_ia32_maxps512_mask ((__v16sf) __A,
+ (__v16sf) __B,
+ (__v16sf) __W,
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_maskz_max_ps (__mmask16 __U, __m512 __A, __m512 __B)
+{
+  return (__m512) __builtin_ia32_maxps512_mask ((__v16sf) __A,
+ (__v16sf) __B,
+ (__v16sf)
+ _mm512_setzero_ps (),
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_max_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) {
   return (__m128) __builtin_ia32_maxss_round_mask ((__v4sf) __A,
@@ -858,6 +900,27 @@ _mm512_min_pd(__m512d __A, __m512d __B)
  _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_min_pd (__m512d __W, __mmask8 __U, __m512d __A, __m512d __B)
+{
+  return (__m512d) __builtin_ia32_minpd512_mask ((__v8df) __A,
+  (__v8df) __B,
+  (__v8df) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_maskz_min_pd (__mmask8 __U, __m512d __A, __m512d __B)
+{
+  return (__m512d) __builtin_ia32_minpd512_mask ((__v8df) __A,
+  (__v8df) __B,
+  (__v8df)
+  _mm512_setzero_pd (),
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
 static  __inline__ __m512 __DEFAULT_FN_ATTRS
 _mm512_min_ps(__m512 __A, __m512 __B)
 {
@@ -869,6 +932,27 @@ _mm512_min_ps(__m512 __A, __m512 __B)
 _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask_min_ps (__m512 __W, __mmask16 __U, __m512 __A, __m512 __B)
+{
+  return (__m512) __builtin_ia32_minps512_mask ((__v16sf) __A,
+ (__v16sf) __B,
+ (__v16sf) __W,
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_maskz_min_ps (__mmask16 __U, __m512 __A, __m512 __B)
+{
+  return (__m512) __builtin_ia32_minps512_mask ((__v16sf) __A,
+ (__v16sf) __B,
+ (__v16sf)
+ _mm512_setzero_ps (),
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_min_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) {
   return (__m128) __builtin_ia32_minss_round_mask ((__v4sf) __A,

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268910&r1=268909&r2=268910&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon May  9 07:38:49 2016
@@ -5966,3 +5966,61 @@ __m512i test_mm512_mask_cvtps_epu32 (__m
   return _mm512_mask_cvtps_epu32( __W, __U, __A);
 }
 
+
+__m512d test_mm512_mask_

Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.



Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:39
@@ +38,3 @@
+// Ignores using-declarations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;

Ack. I think this is actually ok for now. 


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:66
@@ -59,4 +65,3 @@
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used->getCanonicalDecl());
+return;

Maybe the ->getCanonicalDecl() should be moved into removeFromFoundDecls?


http://reviews.llvm.org/D20018



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


Re: [PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

2016-05-09 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 56556.
apelete added a comment.

[scan-build] fix warnings emitted on Clang StaticAnalyzer code base

- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp: factorize assert and check on 
'!Diags.empty' condition.


http://reviews.llvm.org/D19962

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -294,9 +294,8 @@
   SmallVector Fids;
   const SourceManager* SM = nullptr;
 
-  if (!Diags.empty())
-SM = &Diags.front()->path.front()->getLocation().getManager();
-
+  assert(!Diags.empty() && "cannot iterate through empty PathDiagnostic");
+  SM = &Diags.front()->path.front()->getLocation().getManager();
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =


Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -294,9 +294,8 @@
   SmallVector Fids;
   const SourceManager* SM = nullptr;
 
-  if (!Diags.empty())
-SM = &Diags.front()->path.front()->getLocation().getManager();
-
+  assert(!Diags.empty() && "cannot iterate through empty PathDiagnostic");
+  SM = &Diags.front()->path.front()->getLocation().getManager();
 
   for (std::vector::iterator DI = Diags.begin(),
DE = Diags.end(); DI != DE; ++DI) {
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -693,6 +693,8 @@
 !Param->getType()->isReferenceType())
   continue;
 
+assert(ArgExpr && "cannot get the type of a NULL expression");
+
 NullConstraint Nullness = getNullConstraint(*ArgSVal, State);
 
 Nullability RequiredNullability =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19962: [scan-build] fix warnings emitted on Clang StaticAnalyzer code base

2016-05-09 Thread Apelete Seketeli via cfe-commits
apelete added inline comments.


Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:300
@@ -299,2 +299,3 @@
 
+  assert(SM && "SourceManager is NULL, cannot iterate through the 
diagnostics");
 

dblaikie wrote:
> This assertion seems to be equivalent to replacing the prior 'if' with an 
> assertion of the same condition, no? Is that correct? (& if it is, we should 
> just do that)
You're right, I overlooked the simplification.
Will fix in next revision.


http://reviews.llvm.org/D19962



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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56555.
hokein marked 2 inline comments as done.
hokein added a comment.

Update.


http://reviews.llvm.org/D20018

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -10,6 +10,32 @@
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+class G { public: static void func() {} };
+class H { public: static int i; };
+class I {
+ public:
+  static int ii;
+};
+
+class Base {
+ public:
+  void f();
+};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,12 +50,37 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::G;
+using n::H;
+using n::I;
+int I::ii = 1;
+class Derived : public Base {
+ public:
+  using Base::f;
+};
+using n::UsedInstance;
+using n::UsedFunc;
+using n::UsedTemplateFunc;
+using n::UnusedInstance; // UnusedInstance
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-FIXES: {{^}}// UnusedInstance
+using n::UnusedFunc; // UnusedFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-FIXES: {{^}}// UnusedFunc
+using n::cout;
+using n::endl;
 
 // - Usages -
 void f(B b);
 void g() {
   vector data;
   D::i = 1;
   F f;
+  void (*func)() = &G::func;
+  int *i = &H::i;
+  UsedInstance.i;
+  UsedFunc();
+  UsedTemplateFunc();
+  cout << endl;
 }
 
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -30,6 +30,8 @@
   void onEndOfTranslationUnit() override;
 
 private:
+  void removeFromFoundDecls(const Decl *D);
+
   llvm::DenseMap FoundDecls;
   llvm::DenseMap FoundRanges;
 };
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -23,6 +23,7 @@
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
+  Finder->addMatcher(declRefExpr().bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -34,8 +35,13 @@
 const auto *TargetDecl =
 Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
 
-// FIXME: Handle other target types.
-if (!isa(TargetDecl) && !isa(TargetDecl))
+// Ignores using-declarations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;
+
+if (!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl))
   return;
 
 FoundDecls[TargetDecl] = Using;
@@ -57,10 +63,26 @@
 if (const auto *Specialization =
 dyn_cast(Used))
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used->getCanonicalDecl());
+return;
   }
+
+  if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT->getCanonicalDecl());
+  else
+removeFromFoundDecls(FD->getCanonicalDecl());
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD->getCanonicalDecl());
+}
+  }
+}
+
+void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  auto I = FoundDecls.find(D);
+  if (I != FoundDecls.end())
+I->second = nullptr;
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:39
@@ +38,3 @@
+// Ignores using-declrations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;

djasper wrote:
> We should also ignore using declarations in function context (Koenig 
> lookup..).
If we ignore them in function context, we will also skip the following case:

```
namespace a {
class A {};
};

void func() {
  using a::A; // unused-using decls.
}
```


http://reviews.llvm.org/D20018



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


Re: [PATCH] D19960: [scan-build] fix warnings emitted on Clang CodeGen code base

2016-05-09 Thread Apelete Seketeli via cfe-commits
apelete added inline comments.


Comment at: lib/CodeGen/CGDebugInfo.cpp:1317
@@ -1316,2 +1316,3 @@
   }
+  assert(V && "constant must be not NULL at this point");
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(

dblaikie wrote:
> It looks like this assertion could actually be a different assertion a little 
> higher up.
> 
> For 'V' to be non-null, one of the if/else if chain above must fire.
> 
> So change the last else if to an else, and the dyn_cast to a cast, and the 
> cast will fail an internal assertion if it's not valid (& the analyzer can 
> easily then see that at least one of the assignments to V happens - whether 
> or not the analyzer assumes that all the initializers of V are non-null, 
> that's a separate issue...)
I do not understand what you are suggesting here.
Are you suggesting I should try those changes and see for myself that at least 
one of the assignments to V actually happens (which would mean that the warning 
is a false positive), or are you suggesting that the right way to fix it is to 
remove the assert and replace the last 'else if' construct with an 'else' ?


Comment at: lib/CodeGen/CodeGenModule.cpp:2302
@@ -2301,2 +2301,3 @@
  unsigned AddrSpace) {
+  assert(D && "variable declaration must be not NULL");
   if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {

dblaikie wrote:
> Again, a bit confused about whether you're proposing fixing nearly every 
> pointer parameter in Clang and LLVM to assert non-null... I think we'd need a 
> discussion about what that looks like.
Sorry my intentions were not clear.
The only function pointer parameters I'm asserting are the ones that trigger a 
warning when running scan-build.
This might not be the right way to fix the issue, I will be waiting for you 
advice in that case (please have a look at my reply to your concern on the 
mailing list).


http://reviews.llvm.org/D19960



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


Re: [PATCH] D19796: Add new intrinsic support for MONITORX and MWAITX instructions.

2016-05-09 Thread Ganesh Gopalasubramanian via cfe-commits
GGanesh added a comment.

PING!


http://reviews.llvm.org/D19796



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


[clang-tools-extra] r268905 - Trying to fix docs.

2016-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon May  9 05:56:57 2016
New Revision: 268905

URL: http://llvm.org/viewvc/llvm-project?rev=268905&view=rev
Log:
Trying to fix docs.

Modified:

clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp?rev=268905&r1=268904&r2=268905&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
Mon May  9 05:56:57 2016
@@ -1,4 +1,4 @@
-//===--- UnconventionalUnconventionalAssignOperatorCheck.cpp - clang-tidy 
-*- C++ -*-===//
+//===--- UnconventionalAssignOperatorCheck.cpp - clang-tidy -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h?rev=268905&r1=268904&r2=268905&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.h 
Mon May  9 05:56:57 2016
@@ -1,4 +1,4 @@
-//===--- UnconventionalUnconventionalAssignOperatorCheck.h - clang-tidy 
---*- C++ -*-===//
+//===--- UnconventionalAssignOperatorCheck.h - clang-tidy ---*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=268905&r1=268904&r2=268905&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon May  9 05:56:57 2016
@@ -237,7 +237,8 @@ identified.  The improvements since the
   Finds static function and variable definitions in anonymous namespace.
 
 - New `misc-unconventional-assign-operator
-  
`_
 check replacing old `misc-assign-operator-signature` check
+  
`_
+  check replacing the *misc-assign-operator-signature* check.
 
   Does not only checks for correct signature but also for correct ``return``
   statements (returning ``*this``)


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


r268903 - [Clang][AVX512] completing missing intrinsics [CVT]

2016-05-09 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon May  9 05:32:51 2016
New Revision: 268903

URL: http://llvm.org/viewvc/llvm-project?rev=268903&view=rev
Log:
[Clang][AVX512] completing missing intrinsics [CVT]

Differential Revision: http://reviews.llvm.org/D20056


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268903&r1=268902&r2=268903&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon May  9 05:32:51 2016
@@ -2705,6 +2705,24 @@ _mm512_cvttps_epu32(__m512 __A)
   _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_cvttps_epu32 (__m512i __W, __mmask16 __U, __m512 __A)
+{
+  return (__m512i) __builtin_ia32_cvttps2udq512_mask ((__v16sf) __A,
+   (__v16si) __W,
+   (__mmask16) __U,
+   _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvttps_epu32 (__mmask16 __U, __m512 __A)
+{
+  return (__m512i) __builtin_ia32_cvttps2udq512_mask ((__v16sf) __A,
+   (__v16si) _mm512_setzero_si512 (),
+   (__mmask16) __U,
+   _MM_FROUND_CUR_DIRECTION);
+}
+
 #define _mm512_cvt_roundepi32_ps(A, R) __extension__ ({ \
   (__m512)__builtin_ia32_cvtdq2ps512_mask((__v16si)(A), \
   (__v16sf)_mm512_setzero_ps(), \
@@ -2715,15 +2733,85 @@ _mm512_cvttps_epu32(__m512 __A)
(__v16sf)_mm512_setzero_ps(), \
(__mmask16)-1, (R)); })
 
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_cvtepu32_ps (__m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtudq2ps512_mask ((__v16si) __A,
+ (__v16sf) _mm512_undefined_ps (),
+ (__mmask16) -1,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepu32_ps (__m512 __W, __mmask16 __U, __m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtudq2ps512_mask ((__v16si) __A,
+ (__v16sf) __W,
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtepu32_ps (__mmask16 __U, __m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtudq2ps512_mask ((__v16si) __A,
+ (__v16sf) _mm512_setzero_ps (),
+ (__mmask16) __U,
+ _MM_FROUND_CUR_DIRECTION);
+}
+
 static __inline __m512d __DEFAULT_FN_ATTRS
 _mm512_cvtepi32_pd(__m256i __A)
 {
   return (__m512d) __builtin_ia32_cvtdq2pd512_mask ((__v8si) __A,
-(__v8df)
+(__v8df) 
 _mm512_setzero_pd (),
 (__mmask8) -1);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepi32_pd (__m512d __W, __mmask8 __U, __m256i __A)
+{
+  return (__m512d) __builtin_ia32_cvtdq2pd512_mask ((__v8si) __A,
+(__v8df) __W,
+(__mmask8) __U);
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtepi32_pd (__mmask8 __U, __m256i __A)
+{
+  return (__m512d) __builtin_ia32_cvtdq2pd512_mask ((__v8si) __A,
+(__v8df) _mm512_setzero_pd (),
+(__mmask8) __U);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_cvtepi32_ps (__m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtdq2ps512_mask ((__v16si) __A,
+(__v16sf) _mm512_undefined_ps (),
+(__mmask16) -1,
+_MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepi32_ps (__m512 __W, __mmask16 __U, __m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtdq2ps512_mask ((__v16si) __A,
+(__v16sf) __W,
+(__mmask16) __U,
+_MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtepi32_ps (__mmask16 __U, __m512i __A)
+{
+  return (__m512) __builtin_ia32_cvtdq2ps512_mask ((__v16si) __A,
+(__v16sf) _mm512_setzero_ps (),
+(__mmask16) __U,
+_MM_FROUND_CUR_DIRECTION);
+}
+
 static __inline __m512d __DEFAULT_FN_ATTRS
 _mm512_cvtepu32_pd(__m256i __A)
 {
@@ -2733,33 +2821,101 @@ _mm512_cvtepu32_pd(__m256i __A)
 (__mmask8) -1);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_cvtepu32_pd (__m512d __W, __mmask8 __U, __m256i __A)
+{
+  return (__m512d) __builtin_ia32_cvtudq2pd512_mask ((__v8si) __A,
+  (__v8df) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtepu32_pd (__mmask8 __U, __m256i __A)
+{
+  return (__m512d) __builtin_ia32_cvtudq2pd512_mask ((__v8si) __

Re: [PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

2016-05-09 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D19993



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


Re: [PATCH] D19804: Make clang-format cleaner remove redundant commas/colons in constructor initializer list.

2016-05-09 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1821
@@ +1820,3 @@
+  if (Line->Affected)
+checkConstructorInitList(*Line);
+}

djasper wrote:
> Why are we restricting this to constructor initializers? I think we should 
> directly be more generic and clean up different lists. Also, as an idea? 
> Could we make this very generic and implement a function that analyzes a line 
> for a specific sequence of tokens? E.g., I would assume that then the current 
> checkConstructorInitList() could be written as:
> 
>   cleanupLeft(tok::comma, tok::comma);
>   cleanupLeft(tok::comma, tok::l_brace);
>   cleanupRight(tok::colon, tok::comma);
>   cleanupLeft(tok::colon, tok::l_brace);
> 
> With cleanupLeft/Right meaning: Find this sequence of tokens (ignoring 
> comments) and then clean up the left or the right side.
> 
> Not sure about the exact names of functions etc. What do you think?
I think having a generic `cleanupLeft(tok::comma, tok::comma)` is a great idea; 
however, the other three functions seem a little too generic since they'd 
probably only be used in constructor initializers? E.g. an expression like 
`condition ? something : { list }` would be a false positive for 
`cleanupLeft(tok::colon, tok::l_brace)`, and `[{...}, {...}]` might be a false 
positive for `cleanupLeft(tok::comma, tok::l_brace)`. Also, it seems to me that 
`cleanupRight(tok::colon, tok::comma)` would only happen in constructor 
initializers?

I think a mixed solution might work as well. For example, we can run 
`cleanupLeft(tok::comma, tok::comma)` across all tokens in the code, and then 
for constructor initializers specifically, we handle redundant colon and 
trailing comma. What do you think?

As for comments, we can probably handle them after all cleanup is done.


http://reviews.llvm.org/D19804



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


[clang-tools-extra] r268899 - Fix docs.

2016-05-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon May  9 05:00:52 2016
New Revision: 268899

URL: http://llvm.org/viewvc/llvm-project?rev=268899&view=rev
Log:
Fix docs.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst?rev=268899&r1=268898&r2=268899&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-unconventional-assign-operator.rst
 Mon May  9 05:00:52 2016
@@ -1,7 +1,7 @@
 .. title:: clang-tidy - misc-unconventional-assign-operator
 
 misc-unconventional-assign-operator
-
+===
 
 
 Finds declarations of assign operators with the wrong return and/or argument


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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.cpp:39
@@ +38,3 @@
+// Ignores using-declrations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;

We should also ignore using declarations in function context (Koenig lookup..).


Comment at: clang-tidy/misc/UnusedUsingDeclsCheck.h:33
@@ -32,2 +32,3 @@
 private:
+  void removeFromFoundDecls(const Decl *D);
   llvm::DenseMap FoundDecls;

nit: Add an empty line after this.


Comment at: test/clang-tidy/misc-unused-using-decls.cpp:27
@@ +26,3 @@
+ public:
+  using Base::f;
+};

Move this into the "Using declarations" section.


http://reviews.llvm.org/D20018



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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein added a comment.

I ran the check on LLVM project. The check found 8 hits: 
http://reviews.llvm.org/D20060 (Check all of them, no false positives).


http://reviews.llvm.org/D20018



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


Re: [PATCH] D20018: Support variables and functions types in misc-unused-using-decls.

2016-05-09 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 56540.
hokein marked 5 inline comments as done.
hokein added a comment.

- Address review comments.
- Ignore using-declarations defined in class definition.


http://reviews.llvm.org/D20018

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.h
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -10,6 +10,37 @@
 class D { public: static int i; };
 template  class E {};
 template  class F {};
+class G { public: static void func() {} };
+class H { public: static int i; };
+class I {
+ public:
+  static int ii;
+};
+
+class Base {
+ public:
+  void f();
+};
+
+class Derived : public Base {
+ public:
+  using Base::f;
+};
+
+D UsedInstance;
+D UnusedInstance;
+
+int UsedFunc() { return 1; }
+int UnusedFunc() { return 1; }
+template  int UsedTemplateFunc() { return 1; }
+template  int UnusedTemplateFunc() { return 1; }
+
+class ostream {
+public:
+  ostream &operator<<(ostream &(*PF)(ostream &));
+};
+extern ostream cout;
+ostream &endl(ostream &os);
 }
 
 // - Using declarations -
@@ -24,12 +55,33 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
 // CHECK-FIXES: {{^}}// E
 using n::F;
+using n::G;
+using n::H;
+using n::I;
+int I::ii = 1;
+using n::UsedInstance;
+using n::UsedFunc;
+using n::UsedTemplateFunc;
+using n::UnusedInstance; // UnusedInstance
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
+// CHECK-FIXES: {{^}}// UnusedInstance
+using n::UnusedFunc; // UnusedFunc
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
+// CHECK-FIXES: {{^}}// UnusedFunc
+using n::cout;
+using n::endl;
 
 // - Usages -
 void f(B b);
 void g() {
   vector data;
   D::i = 1;
   F f;
+  void (*func)() = &G::func;
+  int *i = &H::i;
+  UsedInstance.i;
+  UsedFunc();
+  UsedTemplateFunc();
+  cout << endl;
 }
 
Index: clang-tidy/misc/UnusedUsingDeclsCheck.h
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.h
+++ clang-tidy/misc/UnusedUsingDeclsCheck.h
@@ -30,6 +30,7 @@
   void onEndOfTranslationUnit() override;
 
 private:
+  void removeFromFoundDecls(const Decl *D);
   llvm::DenseMap FoundDecls;
   llvm::DenseMap FoundRanges;
 };
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -23,6 +23,7 @@
   auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(recordType(DeclMatcher)), this);
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
+  Finder->addMatcher(declRefExpr().bind("used"), this);
 }
 
 void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -34,8 +35,13 @@
 const auto *TargetDecl =
 Using->shadow_begin()->getTargetDecl()->getCanonicalDecl();
 
-// FIXME: Handle other target types.
-if (!isa(TargetDecl) && !isa(TargetDecl))
+// Ignores using-declrations defined in class definition.
+if (isa(TargetDecl->getDeclContext()))
+  return;
+
+if (!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl) && !isa(TargetDecl) &&
+!isa(TargetDecl))
   return;
 
 FoundDecls[TargetDecl] = Using;
@@ -57,10 +63,26 @@
 if (const auto *Specialization =
 dyn_cast(Used))
   Used = Specialization->getSpecializedTemplate();
-auto I = FoundDecls.find(Used->getCanonicalDecl());
-if (I != FoundDecls.end())
-  I->second = nullptr;
+removeFromFoundDecls(Used->getCanonicalDecl());
+return;
   }
+
+  if (const auto *DRE = Result.Nodes.getNodeAs("used")) {
+if (const auto *FD = dyn_cast(DRE->getDecl())) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT->getCanonicalDecl());
+  else
+removeFromFoundDecls(FD->getCanonicalDecl());
+} else if (const auto *VD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(VD->getCanonicalDecl());
+}
+  }
+}
+
+void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
+  auto I = FoundDecls.find(D);
+  if (I != FoundDecls.end())
+I->second = nullptr;
 }
 
 void UnusedUsingDeclsCheck::onEndOfTranslationUnit() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19913: Added static creators that create complete instances of SymbolInfo.

2016-05-09 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/find-all-symbols/SymbolInfo.h:98-101
@@ +97,6 @@
+
+  static SymbolInfo
+  CreateFunctionSymbolInfo(const std::string &Name, const std::string 
&FilePath,
+   const std::vector &Contexts, int 
LineNumber,
+   const FunctionInfo &FuncInfo);
+

klimek wrote:
> hokein wrote:
> > However, changing `SymbolInfo` to class requires us to add many 
> > setters/getters in it.
> > 
> > Currently the `SymbolInfo` is like `ClangTidyOptions` structure. 
> So, multiple thoughts:
> - generally, I think symbol info would better be an immutable type; that 
> would mean that we wouldn't have setters, just getters, and initialize 
> everything in the constructor
> - afaik llvm/clang style  doesn't require accessors just because something is 
> a class
> - I believe ClangTidyOptions is a very different use case
> 
But this change would also affect the way SymbolInfo is constructed in 
FindAllSymbol - class members are retrieved from AST in different locations, 
and we'd need to store fields in many temp variables, which might be 
troublesome in this case as well as some other cases. With a `struct` 
implementation plus static creatrors, we can have some flexibility. But I'm not 
sure if this makes sense from design perspective. 


http://reviews.llvm.org/D19913



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


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-05-09 Thread Axel Naumann via cfe-commits
karies added a comment.

Regarding the concerns raised by @akyrtzi : maybe it's a question of making the 
completer interface useful at low cost (with filtering for generic use cases 
and less ASTReading) versus not breaking existing use cases (fuzzy match). 
Would you still object to this change if the filtering could be disabled in the 
CodeCompleteConsumer?


Repository:
  rL LLVM

http://reviews.llvm.org/D17820



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


r268898 - Enable support for __float128 in Clang and enable it on pertinent platforms

2016-05-09 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Mon May  9 03:52:33 2016
New Revision: 268898

URL: http://llvm.org/viewvc/llvm-project?rev=268898&view=rev
Log:
Enable support for __float128 in Clang and enable it on pertinent platforms

This patch corresponds to reviews:
http://reviews.llvm.org/D15120
http://reviews.llvm.org/D19125

It adds support for the __float128 keyword, literals and target feature to
enable it. Based on the latter of the two aforementioned reviews, this feature
is enabled on Linux on i386/X86 as well as SystemZ.
This is also the second attempt in commiting this feature. The first attempt
did not enable it on required platforms which caused failures when compiling
type_traits with -std=gnu++11.

If you see failures with compiling this header on your platform after this
commit, it is likely that your platform needs to have this feature enabled.

Added:
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
cfe/trunk/test/Sema/float128-ld-incompatibility.cpp
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/test/Sema/128bitfloat.cpp
cfe/trunk/test/Sema/attr-mode.c
cfe/trunk/test/SemaCXX/deleted-operator.cpp
cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=268898&r1=268897&r2=268898&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon May  9 03:52:33 2016
@@ -1731,6 +1731,7 @@ TypeKind.DEPENDENT = TypeKind(26)
 TypeKind.OBJCID = TypeKind(27)
 TypeKind.OBJCCLASS = TypeKind(28)
 TypeKind.OBJCSEL = TypeKind(29)
+TypeKind.FLOAT128 = TypeKind(30)
 TypeKind.COMPLEX = TypeKind(100)
 TypeKind.POINTER = TypeKind(101)
 TypeKind.BLOCKPOINTER = TypeKind(102)

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=268898&r1=268897&r2=268898&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon May  9 03:52:33 2016
@@ -2929,6 +2929,7 @@ enum CXTypeKind {
   CXType_ObjCId = 27,
   CXType_ObjCClass = 28,
   CXType_ObjCSel = 29,
+  CXType_Float128 = 30,
   CXType_FirstBuiltin = CXType_Void,
   CXType_LastBuiltin  = CXType_ObjCSel,
 

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=268898&r1=268897&r2=268898&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon May  9 03:52:33 2016
@@ -215,9 +215,6 @@ class ASTContext : public RefCountedBase
   /// \brief The typedef for the __uint128_t type.
   mutable TypedefDecl *UInt128Decl;
 
-  /// \brief The typedef for the __float128 stub type.
-  mutable TypeDecl

Re: [PATCH] D20059: clang-rename tests: move the run lines to the top of the test files

2016-05-09 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268897: clang-rename tests: move the run lines to the top of 
the test files (authored by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D20059?vs=56537&id=56538#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20059

Files:
  clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
  clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
  clang-tools-extra/trunk/test/clang-rename/VarTest.cpp

Index: clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
@@ -1,8 +1,8 @@
-namespace A { int foo;  // CHECK: int hector;
-}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+namespace A { int foo;  // CHECK: int hector;
+}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;
Index: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
@@ -1,9 +1,9 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 int main()
 {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -1,12 +1,12 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla
 {
   int foo; // CHECK: hector;
 public:
   Cla();
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 Cla::Cla()
   : foo(0) // CHECK: hector(0)


Index: clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
@@ -1,8 +1,8 @@
-namespace A { int foo;  // CHECK: int hector;
-}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+namespace A { int foo;  // CHECK: int hector;
+}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;
Index: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
@@ -1,9 +1,9 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 int main()
 {
Index: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
@@ -1,12 +1,12 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla
 {
   int foo; // CHECK: hector;
 public:
   Cla();
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 Cla::Cla()
   : foo(0) // CHECK: hector(0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r268897 - clang-rename tests: move the run lines to the top of the test files

2016-05-09 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon May  9 03:47:18 2016
New Revision: 268897

URL: http://llvm.org/viewvc/llvm-project?rev=268897&view=rev
Log:
clang-rename tests: move the run lines to the top of the test files

Summary: To be consistent with the other tests.

Reviewers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D20059

Modified:
clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
clang-tools-extra/trunk/test/clang-rename/VarTest.cpp

Modified: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp?rev=268897&r1=268896&r2=268897&view=diff
==
--- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp (original)
+++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp Mon May  9 03:47:18 
2016
@@ -1,9 +1,9 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 int main()
 {

Modified: clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp?rev=268897&r1=268896&r2=268897&view=diff
==
--- clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp (original)
+++ clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp Mon May  9 03:47:18 
2016
@@ -1,12 +1,12 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla
 {
   int foo; // CHECK: hector;
 public:
   Cla();
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 Cla::Cla()
   : foo(0) // CHECK: hector(0)

Modified: clang-tools-extra/trunk/test/clang-rename/VarTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/VarTest.cpp?rev=268897&r1=268896&r2=268897&view=diff
==
--- clang-tools-extra/trunk/test/clang-rename/VarTest.cpp (original)
+++ clang-tools-extra/trunk/test/clang-rename/VarTest.cpp Mon May  9 03:47:18 
2016
@@ -1,8 +1,8 @@
-namespace A { int foo;  // CHECK: int hector;
-}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+namespace A { int foo;  // CHECK: int hector;
+}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;


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


Re: [PATCH] D20059: clang-rename tests: move the run lines to the top of the test files

2016-05-09 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D20059



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


[PATCH] D20059: clang-rename tests: move the run lines to the top of the test files

2016-05-09 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: cfe-commits, klimek.

To be consistent with the other tests.

http://reviews.llvm.org/D20059

Files:
  test/clang-rename/ClassTest.cpp
  test/clang-rename/FieldTest.cpp
  test/clang-rename/VarTest.cpp

Index: test/clang-rename/VarTest.cpp
===
--- test/clang-rename/VarTest.cpp
+++ test/clang-rename/VarTest.cpp
@@ -1,8 +1,8 @@
-namespace A { int foo;  // CHECK: int hector;
-}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+namespace A { int foo;  // CHECK: int hector;
+}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;
Index: test/clang-rename/FieldTest.cpp
===
--- test/clang-rename/FieldTest.cpp
+++ test/clang-rename/FieldTest.cpp
@@ -1,12 +1,12 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla
 {
   int foo; // CHECK: hector;
 public:
   Cla();
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 Cla::Cla()
   : foo(0) // CHECK: hector(0)
Index: test/clang-rename/ClassTest.cpp
===
--- test/clang-rename/ClassTest.cpp
+++ test/clang-rename/ClassTest.cpp
@@ -1,9 +1,9 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 int main()
 {


Index: test/clang-rename/VarTest.cpp
===
--- test/clang-rename/VarTest.cpp
+++ test/clang-rename/VarTest.cpp
@@ -1,8 +1,8 @@
-namespace A { int foo;  // CHECK: int hector;
-}
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+namespace A { int foo;  // CHECK: int hector;
+}
 int foo;  // CHECK: int foo;
 int bar = foo; // CHECK: bar = foo;
 int baz = A::foo; // CHECK: baz = A::hector;
Index: test/clang-rename/FieldTest.cpp
===
--- test/clang-rename/FieldTest.cpp
+++ test/clang-rename/FieldTest.cpp
@@ -1,12 +1,12 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla
 {
   int foo; // CHECK: hector;
 public:
   Cla();
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=18 -new-name=hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 Cla::Cla()
   : foo(0) // CHECK: hector(0)
Index: test/clang-rename/ClassTest.cpp
===
--- test/clang-rename/ClassTest.cpp
+++ test/clang-rename/ClassTest.cpp
@@ -1,9 +1,9 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {
 };
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=6 -new-name=Hector %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 int main()
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20054: Fix spurious warnings about unused private field

2016-05-09 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268895: Fix spurious warnings about unused private field 
(authored by ogoffart).

Changed prior to commit:
  http://reviews.llvm.org/D20054?vs=56514&id=56530#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20054

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp

Index: cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
===
--- cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
+++ cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
@@ -128,6 +128,7 @@
 int *use = &by_reference_;
 int test[2];
 test[as_array_index_] = 42;
+int EverythingUsed::*ptr = &EverythingUsed::by_pointer_to_member_;
   }
 
   template
@@ -142,6 +143,7 @@
   int by_template_function_;
   int as_array_index_;
   int by_initializer_;
+  int by_pointer_to_member_;
 };
 
 class HasFeatureTest {
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -1736,10 +1736,12 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  // Just in case we're building an illegal pointer-to-member.
-  FieldDecl *FD = dyn_cast(D);
-  if (FD && FD->isBitField())
-E->setObjectKind(OK_BitField);
+  if (FieldDecl *FD = dyn_cast(D)) {
+UnusedPrivateFields.remove(FD);
+// Just in case we're building an illegal pointer-to-member.
+if (FD->isBitField())
+  E->setObjectKind(OK_BitField);
+  }
 
   return E;
 }


Index: cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
===
--- cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
+++ cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
@@ -128,6 +128,7 @@
 int *use = &by_reference_;
 int test[2];
 test[as_array_index_] = 42;
+int EverythingUsed::*ptr = &EverythingUsed::by_pointer_to_member_;
   }
 
   template
@@ -142,6 +143,7 @@
   int by_template_function_;
   int as_array_index_;
   int by_initializer_;
+  int by_pointer_to_member_;
 };
 
 class HasFeatureTest {
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -1736,10 +1736,12 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  // Just in case we're building an illegal pointer-to-member.
-  FieldDecl *FD = dyn_cast(D);
-  if (FD && FD->isBitField())
-E->setObjectKind(OK_BitField);
+  if (FieldDecl *FD = dyn_cast(D)) {
+UnusedPrivateFields.remove(FD);
+// Just in case we're building an illegal pointer-to-member.
+if (FD->isBitField())
+  E->setObjectKind(OK_BitField);
+  }
 
   return E;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268895 - Fix spurious warnings about unused private field

2016-05-09 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Mon May  9 02:09:51 2016
New Revision: 268895

URL: http://llvm.org/viewvc/llvm-project?rev=268895&view=rev
Log:
Fix spurious warnings about unused private field

If the address of a field is taken as a pointer to member, we should
not warn that the field is not used.

Normaly, yse of fields are done from MemberExpr, but in case of pointer to
member, it is in a DeclRefExpr

Differential Revision: http://reviews.llvm.org/D20054

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=268895&r1=268894&r2=268895&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon May  9 02:09:51 2016
@@ -1736,10 +1736,12 @@ Sema::BuildDeclRefExpr(ValueDecl *D, Qua
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  // Just in case we're building an illegal pointer-to-member.
-  FieldDecl *FD = dyn_cast(D);
-  if (FD && FD->isBitField())
-E->setObjectKind(OK_BitField);
+  if (FieldDecl *FD = dyn_cast(D)) {
+UnusedPrivateFields.remove(FD);
+// Just in case we're building an illegal pointer-to-member.
+if (FD->isBitField())
+  E->setObjectKind(OK_BitField);
+  }
 
   return E;
 }

Modified: cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp?rev=268895&r1=268894&r2=268895&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp Mon May  9 02:09:51 
2016
@@ -128,6 +128,7 @@ class EverythingUsed {
 int *use = &by_reference_;
 int test[2];
 test[as_array_index_] = 42;
+int EverythingUsed::*ptr = &EverythingUsed::by_pointer_to_member_;
   }
 
   template
@@ -142,6 +143,7 @@ class EverythingUsed {
   int by_template_function_;
   int as_array_index_;
   int by_initializer_;
+  int by_pointer_to_member_;
 };
 
 class HasFeatureTest {


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