SV: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-10 Thread Daniel Marjamäki via cfe-commits

That is intentional.. you can't get overflow with / , % , & , | , etc...

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: Richard [legal...@xmission.com]
Skickat: den 10 februari 2016 07:28
Till: Daniel Marjamäki; aaron.ball...@gmail.com; ale...@google.com
Kopia: legal...@xmission.com; eugene.zele...@gmail.com; 
cfe-commits@lists.llvm.org
Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

LegalizeAdulthood added inline comments.


Comment at: 
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp:21-23
@@ +20,5 @@
+void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
+  auto Calc = expr(anyOf(binaryOperator(anyOf(
+ hasOperatorName("+"), hasOperatorName("-"),
+ hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),

Sorry for the late observation, but why doesn't this check for `%` and `/` 
operators?


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


SV: [clang-tools-extra] r260225 - [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work on various bots

2016-02-10 Thread Daniel Marjamäki via cfe-commits

Hello!

> I'm not sure this is a good fix. What was the specific issue (and on which 
> buildbots)?

Ok.

The buildbots said:

FileCheck error: 
'/home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/tools/clang/tools/extra/test/clang-tidy/Output/misc-misplaced-widening-cast.cpp.tmp.cpp.msg'
 is empty.

My check only warns when there is a widening cast. If sizeof(int)==sizeof(long) 
then there is no warning for a int=>long conversion. In my testcases I tested 
various int=>long conversions.

These are the failed builds:

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/187
http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/6265
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9641
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9691

Best regards,
Daniel Marjamäki

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: Alexander Kornienko [ale...@google.com]
Skickat: den 9 februari 2016 17:41
Till: Daniel Marjamäki
Kopia: cfe-commits
Ämne: Re: [clang-tools-extra] r260225 - [clang-tidy] Add -target in 
misc-misplaced-widening-cast test so it will work on various bots

I'm not sure this is a good fix. What was the specific issue (and on which 
buildbots)?

On Tue, Feb 9, 2016 at 4:43 PM, Daniel Marjamaki via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: danielmarjamaki
Date: Tue Feb  9 09:43:05 2016
New Revision: 260225

URL: http://llvm.org/viewvc/llvm-project?rev=260225&view=rev
Log:
[clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work 
on various bots

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp?rev=260225&r1=260224&r2=260225&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp 
Tue Feb  9 09:43:05 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t
+// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -- -target 
x86_64-unknown-unknown

 void assign(int a, int b) {
   long l;


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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-10 Thread Daniel Marjamäki via cfe-commits
danielmarjamaki added inline comments.


Comment at: 
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp:21-23
@@ +20,5 @@
+void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
+  auto Calc = expr(anyOf(binaryOperator(anyOf(
+ hasOperatorName("+"), hasOperatorName("-"),
+ hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),

LegalizeAdulthood wrote:
> Sorry for the late observation, but why doesn't this check for `%` and `/` 
> operators?
That is intentional.. you can't get overflow with / , % , & , | , etc...


Repository:
  rL LLVM

http://reviews.llvm.org/D16310



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


Re: r260277 - Simplify and rename ASTMatchFinder's getCXXRecordDecl to make it more obvious

2016-02-10 Thread Manuel Klimek via cfe-commits
On Tue, Feb 9, 2016 at 10:03 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Feb  9 14:59:05 2016
> New Revision: 260277
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260277&view=rev
> Log:
> Simplify and rename ASTMatchFinder's getCXXRecordDecl to make it more
> obvious
> what it's actually trying to do.
>
> Modified:
> cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
>
> Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=260277&r1=260276&r2=260277&view=diff
>
> ==
> --- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
> +++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Tue Feb  9 14:59:05 2016
> @@ -744,46 +744,25 @@ private:
>MemoizationMap ResultCache;
>  };
>
> -static CXXRecordDecl *getAsCXXRecordDecl(const Type *TypeNode) {
> -  // Type::getAs<...>() drills through typedefs.
> -  if (TypeNode->getAs() != nullptr ||
> -  TypeNode->getAs() != nullptr ||
> -  TypeNode->getAs() != nullptr)
> -// Dependent names and template TypeNode parameters will be matched
> when
> -// the template is instantiated.
> -return nullptr;
> -  TemplateSpecializationType const *TemplateType =
> -  TypeNode->getAs();
> -  if (!TemplateType) {
> -return TypeNode->getAsCXXRecordDecl();
> -  }
> -  if (TemplateType->getTemplateName().isDependent())
> -// Dependent template specializations will be matched when the
> -// template is instantiated.
> -return nullptr;
> -
> -  // For template specialization types which are specializing a template
> -  // declaration which is an explicit or partial specialization of another
> -  // template declaration, getAsCXXRecordDecl() returns the corresponding
> -  // ClassTemplateSpecializationDecl.
> -  //
> -  // For template specialization types which are specializing a template
> -  // declaration which is neither an explicit nor partial specialization
> of
> -  // another template declaration, getAsCXXRecordDecl() returns NULL and
> -  // we get the CXXRecordDecl of the templated declaration.
> -  CXXRecordDecl *SpecializationDecl = TemplateType->getAsCXXRecordDecl();
> -  if (SpecializationDecl) {
> -return SpecializationDecl;
> -  }
> -  NamedDecl *Templated =
> -
> TemplateType->getTemplateName().getAsTemplateDecl()->getTemplatedDecl();
> -  if (CXXRecordDecl *TemplatedRecord =
> dyn_cast(Templated)) {
> -return TemplatedRecord;
> -  }
> -  // Now it can still be that we have an alias template.
> -  TypeAliasDecl *AliasDecl = dyn_cast(Templated);
> -  assert(AliasDecl);
> -  return getAsCXXRecordDecl(AliasDecl->getUnderlyingType().getTypePtr());
> +static CXXRecordDecl *
> +getAsCXXRecordDeclOrPrimaryTemplate(const Type *TypeNode) {
> +  if (auto *RD = TypeNode->getAsCXXRecordDecl())
> +return RD;
> +
> +  // Find the innermost TemplateSpecializationType that isn't an alias
> template.
> +  auto *TemplateType = TypeNode->getAs();
> +  while (TemplateType && TemplateType->isTypeAlias())
> +TemplateType =
> +
> TemplateType->getAliasedType()->getAs();
> +
> +  // If this is the name of a (dependent) template specialization, use the
> +  // definition of the template, even though it might be specialized
> later.
> +  if (TemplateType)
> +if (auto *ClassTemplate = dyn_cast_or_null(
> +  TemplateType->getTemplateName().getAsTemplateDecl()))
> +  return ClassTemplate->getTemplatedDecl();
> +
> +  return nullptr;
>  }
>
>  // Returns true if the given class is directly or indirectly derived
> @@ -800,7 +779,10 @@ bool MatchASTVisitor::classIsDerivedFrom
>  if (typeHasMatchingAlias(TypeNode, Base, Builder))
>return true;
>
> -CXXRecordDecl *ClassDecl = getAsCXXRecordDecl(TypeNode);
> +// FIXME: Going to the primary template here isn't really correct, but
> +// unfortunately we accept a Decl matcher for the base class not a
> Type
> +// matcher, so it's the best thing we can do with our current


Why not? Specifically, it seems to match what the user wants in most cases.
Now, I'm all for also exposing a more complex interface to the user, where
they can / have to control exactly where to dive into the primary
templates, but experience shows that this is really hard for anybody who's
not a C++ expert to understand, and the current behavior here matches what
people expect when they want to match classes in the inheritance hierarchy.


> interface.
> +CXXRecordDecl *ClassDecl =
> getAsCXXRecordDeclOrPrimaryTemplate(TypeNode);
>  if (!ClassDecl)
>continue;
>  if (ClassDecl == Declaration) {
>
>
> ___
> 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@l

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-02-10 Thread Nemanja Ivanovic via cfe-commits
nemanjai added inline comments.


Comment at: lib/Basic/TargetInfo.cpp:231
@@ +230,3 @@
+if (hasFloat128Type() &&
+&getFloat128Format() == &llvm::APFloat::IEEEquad)
+  return Float128;

hubert.reinterpretcast wrote:
> Is it necessary to check that `__float128` is IEEE quad here? Unlike the long 
> double cases, `__float128` really better be 128 bits.
It would indeed be weird if it wasn't so. I can remove the second condition in 
that if.


Comment at: lib/Sema/SemaExpr.cpp:1169
@@ +1168,3 @@
+  if (LHSElemType == S.Context.Float128Ty &&
+  RHSElemType == S.Context.LongDoubleTy)
+return true;

hubert.reinterpretcast wrote:
> I do not believe that the width of `long double` is sufficiently established 
> to be the same as that of `__float128` in this context.
This would certainly cause any attempts to convert between some different 
implementation of **`long double` **(i.e. the Intel 80-bit type). I believe 
that this behaviour is desired in all cases where **`long double`** and 
**`double`** have a different representation. Namely, we do not currently have 
any support for converting between **`fp128`** and anything that has precision 
>= **`double`** that is not actually **`double`**.

What I propose to do here and in other locations where we diagnose conversions 
between the two types is that the check is:
- One type is `__float128`
- The other is `long double`
- The representation of `long double` is not `llvm::APFloat::IEEEdouble`

Basically in this function, the early exit path would be:
- representations are the same or
- representation of `long double` is `llvm::APFloat::IEEEdouble`


Comment at: lib/Sema/SemaExpr.cpp:1341
@@ +1340,3 @@
+  // Diagnose builtin types that have the same size and different 
representation
+  // as conversions between such type currently can't be handled.
+  if (sameWidthDifferentRepresentation(*this, LHSType, RHSType))

hubert.reinterpretcast wrote:
> s/such type/such types;
Oops, I dropped the s. I'll fix it.


Comment at: lib/Sema/SemaOverload.cpp:1655
@@ -1654,1 +1654,3 @@
   } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
+// FIXME: disable conversions between long double and __float128 if
+// their representation is different until there is back end support

hubert.reinterpretcast wrote:
> Is conversion between `long double` and `__float128` the correct 
> characterization of the missing back-end support? (as opposed to conversion 
> between `PPCDoubleDouble` and `IEEEquad`)
Well, the same issue exists with `x86_fp80`. We don't have libcalls set up for 
handling that either. Of course the intended semantics and the comment are 
still not quite correct here. Really, what I think we should be after is 
catching attempts to convert between `__float128` and `long double` on targets 
where `long double` is not actually just `double`.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-02-10 Thread Andy Gibbs via cfe-commits
AndyG removed reviewers: dblaikie, rsmith.
AndyG updated this revision to Diff 47426.
AndyG added a comment.

All strings matching the highest uncovered argument are now highlighted in the 
diagnostic.


http://reviews.llvm.org/D15636

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -86,6 +86,19 @@
   printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
   printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
   printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
+  printf(0 ? "yes %s" : "no %d", 1); // no-warning
+  printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}}
+
+  printf(0 ? "yes" : "no %d", 1); // no-warning
+  printf(0 ? "yes %d" : "no", 1); // expected-warning{{data argument not used by format string}}
+  printf(1 ? "yes" : "no %d", 1); // expected-warning{{data argument not used by format string}}
+  printf(1 ? "yes %d" : "no", 1); // no-warning
+  printf(i ? "yes" : "no %d", 1); // no-warning
+  printf(i ? "yes %s" : "no %d", 1); // expected-warning{{format specifies type 'char *'}}
+  printf(i ? "yes" : "no %d", 1, 2); // expected-warning{{data argument not used by format string}}
+
+  printf(i ? "%*s" : "-", i, s); // no-warning
+  printf(i ? "yes" : 0 ? "no %*d" : "dont know %d", 1, 2); // expected-warning{{data argument not used by format string}}
 }
 
 void check_writeback_specifier()
@@ -519,7 +532,7 @@
 
   // Make sure that the "format string is defined here" note is not emitted
   // when the original string is within the argument expression.
-  printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
+  printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}}
 
   const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
   printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3233,6 +3233,16 @@
 }
 
 namespace {
+struct UncoveredArgHandler {
+  enum { Unknown = -1, AllCovered = -2 };
+  signed FirstUncoveredArg;
+  SmallVector DiagnosticExprs;
+
+  UncoveredArgHandler() : FirstUncoveredArg(Unknown) { }
+  void Diagnose(Sema &S, bool IsFunctionCall, const Expr *ArgExpr);
+  void Update(signed NewFirstUncoveredArg, const Expr *StrExpr);
+};
+
 enum StringLiteralCheckType {
   SLCT_NotALiteral,
   SLCT_UncheckedLiteral,
@@ -3249,7 +3259,8 @@
   bool HasVAListArg, unsigned format_idx,
   unsigned firstDataArg, Sema::FormatStringType Type,
   Sema::VariadicCallType CallType, bool InFunctionCall,
-  llvm::SmallBitVector &CheckedVarArgs) {
+  llvm::SmallBitVector &CheckedVarArgs,
+  UncoveredArgHandler &UncoveredArg) {
  tryAgain:
   if (E->isTypeDependent() || E->isValueDependent())
 return SLCT_NotALiteral;
@@ -3270,17 +3281,39 @@
 // completely checked only if both sub-expressions were checked.
 const AbstractConditionalOperator *C =
 cast(E);
-StringLiteralCheckType Left =
-checkFormatStringExpr(S, C->getTrueExpr(), Args,
-  HasVAListArg, format_idx, firstDataArg,
-  Type, CallType, InFunctionCall, CheckedVarArgs);
-if (Left == SLCT_NotALiteral)
-  return SLCT_NotALiteral;
+
+// Determine whether it is necessary to check both sub-expressions, for
+// example, because the condition expression is a constant that can be
+// evaluated at compile time.
+bool CheckLeft = true, CheckRight = true;
+
+bool Cond;
+if (C->getCond()->EvaluateAsBooleanCondition(Cond, S.getASTContext())) {
+  if (Cond)
+CheckRight = false;
+  else
+CheckLeft = false;
+}
+
+StringLiteralCheckType Left;
+if (!CheckLeft)
+  Left = SLCT_UncheckedLiteral;
+else {
+  Left = checkFormatStringExpr(S, C->getTrueExpr(), Args,
+   HasVAListArg, format_idx, firstDataArg,
+   Type, CallType, InFunctionCall,
+   CheckedVarArgs, UncoveredArg);
+  if (Left == SLCT_NotALiteral || !CheckRight)
+return Left;
+}
+
 StringLiteralCheckType Right =
 checkFormatStringExpr(S, C->getFalseExpr(), Args,
   HasVAListArg, format_idx, firstDataArg,
-  Type, CallType, InFunctionCall, CheckedVarArgs);
-retu

RE: [PATCH] D17021: Adding doxygen comments to the LLVM intrinsics (part 5, f16cintrin.h)

2016-02-10 Thread Romanova, Katya via cfe-commits
My apologies…

From: David Blaikie [mailto:dblai...@gmail.com]
Sent: Tuesday, February 09, 2016 4:42 PM
To: reviews+d17021+public+89c4dbb2f75e8...@reviews.llvm.org; Romanova, Katya
Cc: Gao, Yunzhong; Robinson, Paul; Eric Christopher; Dmitri Gribenko; Craig 
Topper; Jonathan Roelofs; cfe-commits
Subject: Re: [PATCH] D17021: Adding doxygen comments to the LLVM intrinsics 
(part 5, f16cintrin.h)

It's best not to commit things without approval once they've been sent for 
review (the assumption being that if you asked for review it's because the 
change needed review - time doesn't change that fact) - if approval was given 
off-list (eg: on IRC) it's best to mention who gave it & where (& ideally the 
person should provide it on-list just for record keeping)

On Tue, Feb 9, 2016 at 4:16 PM, Katya Romanova via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260333: This patch adds doxygen comments for all the 
intrinsincs in the header file… (authored by kromanova).

Changed prior to commit:
  http://reviews.llvm.org/D17021?vs=47299&id=47394#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17021

Files:
  cfe/trunk/lib/Headers/f16cintrin.h


___
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


r260370 - Fix PR26543: add a check for definition in CXXRecordDecl.

2016-02-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 10 04:50:12 2016
New Revision: 260370

URL: http://llvm.org/viewvc/llvm-project?rev=260370&view=rev
Log:
Fix PR26543: add a check for definition in CXXRecordDecl.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=260370&r1=260369&r2=260370&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Feb 10 04:50:12 2016
@@ -669,7 +669,8 @@ DSAStackTy::DSAVarData DSAStackTy::getTo
 if (auto *CTD = CTSD->getSpecializedTemplate())
   RD = CTD->getTemplatedDecl();
   if (IsConstant &&
-  !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasMutableFields())) {
+  !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasDefinition() &&
+RD->hasMutableFields())) {
 // Variables with const-qualified type having no mutable member may be
 // listed in a firstprivate clause, even if they are static data members.
 DSAVarData DVarTemp = hasDSA(D, MatchesAnyClause(OMPC_firstprivate),

Modified: cfe/trunk/test/OpenMP/parallel_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_messages.cpp?rev=260370&r1=260369&r2=260370&view=diff
==
--- cfe/trunk/test/OpenMP/parallel_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_messages.cpp Wed Feb 10 04:50:12 2016
@@ -5,7 +5,12 @@ void foo() {
 
 #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma 
omp parallel'}}
 
+struct S;
+S& bar();
 int main(int argc, char **argv) {
+  S &s = bar();
+  #pragma omp parallel
+  (void)&s;
   #pragma omp parallel { // expected-warning {{extra tokens at the end of 
'#pragma omp parallel' are ignored}}
   foo();
   #pragma omp parallel ( // expected-warning {{extra tokens at the end of 
'#pragma omp parallel' are ignored}}


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


Re: SV: [clang-tools-extra] r260225 - [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work on various bots

2016-02-10 Thread Alexander Kornienko via cfe-commits
Makes sense. I wonder though whether the check should attempt to be
platform-independent and warn regardless of whether int and long have the
same bit width. What do you think?
On Feb 10, 2016 9:35 AM, "Daniel Marjamäki" 
wrote:

>
> Hello!
>
> > I'm not sure this is a good fix. What was the specific issue (and on
> which buildbots)?
>
> Ok.
>
> The buildbots said:
>
> FileCheck error:
> '/home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/tools/clang/tools/extra/test/clang-tidy/Output/misc-misplaced-widening-cast.cpp.tmp.cpp.msg'
> is empty.
>
> My check only warns when there is a widening cast. If
> sizeof(int)==sizeof(long) then there is no warning for a int=>long
> conversion. In my testcases I tested various int=>long conversions.
>
> These are the failed builds:
>
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/187
> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/6265
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9641
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9691
>
> Best regards,
> Daniel Marjamäki
>
>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: daniel.marjam...@evidente.se
>
> www.evidente.se
>
> 
> Från: Alexander Kornienko [ale...@google.com]
> Skickat: den 9 februari 2016 17:41
> Till: Daniel Marjamäki
> Kopia: cfe-commits
> Ämne: Re: [clang-tools-extra] r260225 - [clang-tidy] Add -target in
> misc-misplaced-widening-cast test so it will work on various bots
>
> I'm not sure this is a good fix. What was the specific issue (and on which
> buildbots)?
>
> On Tue, Feb 9, 2016 at 4:43 PM, Daniel Marjamaki via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> Author: danielmarjamaki
> Date: Tue Feb  9 09:43:05 2016
> New Revision: 260225
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260225&view=rev
> Log:
> [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will
> work on various bots
>
> Modified:
>
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp?rev=260225&r1=260224&r2=260225&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> Tue Feb  9 09:43:05 2016
> @@ -1,4 +1,4 @@
> -// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t
> +// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- --
> -target x86_64-unknown-unknown
>
>  void assign(int a, int b) {
>long l;
>
>
> ___
> 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


r260373 - Fix assertion "Chunk.Kind == DeclaratorChunk::Function" with attributed type.

2016-02-10 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Wed Feb 10 05:23:48 2016
New Revision: 260373

URL: http://llvm.org/viewvc/llvm-project?rev=260373&view=rev
Log:
Fix assertion "Chunk.Kind == DeclaratorChunk::Function" with attributed type.

This patch is to upgrade FunctionTypeUnwrapper for correct processing of
AttributedType. Fixes PR25786.
Patch by Alexander Makarov.

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

Added:
cfe/trunk/test/CodeGen/pr25786.c
cfe/trunk/test/Sema/pr25786.c
Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=260373&r1=260372&r2=260373&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Feb 10 05:23:48 2016
@@ -5370,6 +5370,7 @@ namespace {
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5402,6 +5403,9 @@ namespace {
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5450,6 +5454,9 @@ namespace {
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);

Added: cfe/trunk/test/CodeGen/pr25786.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pr25786.c?rev=260373&view=auto
==
--- cfe/trunk/test/CodeGen/pr25786.c (added)
+++ cfe/trunk/test/CodeGen/pr25786.c Wed Feb 10 05:23:48 2016
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)

Added: cfe/trunk/test/Sema/pr25786.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr25786.c?rev=260373&view=auto
==
--- cfe/trunk/test/Sema/pr25786.c (added)
+++ cfe/trunk/test/Sema/pr25786.c Wed Feb 10 05:23:48 2016
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {}
+#endif


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


Re: [PATCH] D15373: Fix for bug 25786 - Assertion "Chunk.Kind == DeclaratorChunk::Function" failed with regparm attribute.

2016-02-10 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260373: Fix assertion "Chunk.Kind == 
DeclaratorChunk::Function" with attributed type. (authored by dzobnin).

Changed prior to commit:
  http://reviews.llvm.org/D15373?vs=45179&id=47434#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15373

Files:
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGen/pr25786.c
  cfe/trunk/test/Sema/pr25786.c

Index: cfe/trunk/test/CodeGen/pr25786.c
===
--- cfe/trunk/test/CodeGen/pr25786.c
+++ cfe/trunk/test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: cfe/trunk/test/Sema/pr25786.c
===
--- cfe/trunk/test/Sema/pr25786.c
+++ cfe/trunk/test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning 
{{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {}
+#endif
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5370,6 +5370,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5402,6 +5403,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->getEquivalentType();
+  Stack.push_back(Attributed);
 } else {
   const Type *DTy = Ty->getUnqualifiedDesugaredType();
   if (Ty == DTy) {
@@ -5450,6 +5454,9 @@
 // information.
 return wrap(C, Old->getUnqualifiedDesugaredType(), I);
 
+  case Attributed:
+return wrap(C, cast(Old)->getEquivalentType(), I);
+
   case Parens: {
 QualType New = wrap(C, cast(Old)->getInnerType(), I);
 return C.getParenType(New);


Index: cfe/trunk/test/CodeGen/pr25786.c
===
--- cfe/trunk/test/CodeGen/pr25786.c
+++ cfe/trunk/test/CodeGen/pr25786.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-OK
+
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {
+}
+// CHECK: @pf = common global void (...)* null
+// CHECK: define void @foo(i32 %a)
+
+// CHECK-OK: @pf = common global void (...)* null
+// CHECK-OK: define x86_stdcallcc void @foo(i32 inreg %a)
Index: cfe/trunk/test/Sema/pr25786.c
===
--- cfe/trunk/test/Sema/pr25786.c
+++ cfe/trunk/test/Sema/pr25786.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DTEST -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-linux-gnu -fsyntax-only -verify %s
+
+#if TEST
+void (__attribute__((regparm(3), stdcall)) *pf) (); //expected-warning {{calling convention 'stdcall' ignored for this target}}
+void (__attribute__((regparm(2), stdcall)) foo)(int a) { //expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+#else
+//expected-no-diagnostics
+void (__attribute__((regparm(3), stdcall)) *pf) ();
+void (__attribute__((regparm(2), stdcall)) foo)(int a) {}
+#endif
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5370,6 +5370,7 @@
   struct FunctionTypeUnwrapper {
 enum WrapKind {
   Desugar,
+  Attributed,
   Parens,
   Pointer,
   BlockPointer,
@@ -5402,6 +5403,9 @@
 } else if (isa(Ty)) {
   T = cast(Ty)->getPointeeType();
   Stack.push_back(Reference);
+} else if (isa(Ty)) {
+  T = cast(Ty)->get

r260374 - [OPENMP 4.5] Initial support for data members in 'firstprivate' clause.

2016-02-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 10 05:29:16 2016
New Revision: 260374

URL: http://llvm.org/viewvc/llvm-project?rev=260374&view=rev
Log:
[OPENMP 4.5] Initial support for data members in 'firstprivate' clause.
OpenMP 4.5 allows privatization of non-static data members of current
class in non-static member functions.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/parallel_ast_print.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=260374&r1=260373&r2=260374&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Feb 10 05:29:16 2016
@@ -1432,8 +1432,7 @@ public:
 // OpenMP [2.9.3.6, Restrictions, p.2]
 //  A list item that appears in a reduction clause of the innermost
 //  enclosing worksharing or parallel construct may not be accessed in
-//  an
-//  explicit task.
+//  an  explicit task.
 DVar =
 Stack->hasInnermostDSA(FD, MatchesAnyClause(OMPC_reduction),
[](OpenMPDirectiveKind K) -> bool {
@@ -7018,6 +7017,32 @@ ExprResult Sema::getOpenMPCapturedExpr(V
   return Res;
 }
 
+static std::pair getPrivateItem(Sema &S, Expr *RefExpr) {
+  if (RefExpr->isTypeDependent() || RefExpr->isValueDependent() ||
+  RefExpr->containsUnexpandedParameterPack())
+return std::make_pair(nullptr, true);
+
+  SourceLocation ELoc = RefExpr->getExprLoc();
+  SourceRange SR = RefExpr->getSourceRange();
+  // OpenMP [3.1, C/C++]
+  //  A list item is a variable name.
+  // OpenMP  [2.9.3.3, Restrictions, p.1]
+  //  A variable that is part of another variable (as an array or
+  //  structure element) cannot appear in a private clause.
+  RefExpr = RefExpr->IgnoreParens();
+  auto *DE = dyn_cast_or_null(RefExpr);
+  auto *ME = dyn_cast_or_null(RefExpr);
+  if ((!DE || !isa(DE->getDecl())) &&
+  (S.getCurrentThisType().isNull() || !ME ||
+   !isa(ME->getBase()->IgnoreParenImpCasts()) ||
+   !isa(ME->getMemberDecl( {
+S.Diag(ELoc, diag::err_omp_expected_var_name_member_expr)
+<< (S.getCurrentThisType().isNull() ? 0 : 1) << SR;
+return std::make_pair(nullptr, false);
+  }
+  return std::make_pair(DE ? DE->getDecl() : ME->getMemberDecl(), false);
+}
+
 OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef VarList,
   SourceLocation StartLoc,
   SourceLocation LParenLoc,
@@ -7026,32 +7051,17 @@ OMPClause *Sema::ActOnOpenMPPrivateClaus
   SmallVector PrivateCopies;
   for (auto &RefExpr : VarList) {
 assert(RefExpr && "NULL expr in OpenMP private clause.");
-if (RefExpr->isTypeDependent() || RefExpr->isValueDependent() ||
-RefExpr->containsUnexpandedParameterPack()) {
+auto Res = getPrivateItem(*this, RefExpr);
+if (Res.second) {
   // It will be analyzed later.
   Vars.push_back(RefExpr);
   PrivateCopies.push_back(nullptr);
-  continue;
 }
+ValueDecl *D = Res.first;
+if (!D)
+  continue;
 
 SourceLocation ELoc = RefExpr->getExprLoc();
-// OpenMP [3.1, C/C++]
-//  A list item is a variable name.
-// OpenMP  [2.9.3.3, Restrictions, p.1]
-//  A variable that is part of another variable (as an array or
-//  structure element) cannot appear in a private clause.
-auto *DE = dyn_cast_or_null(RefExpr->IgnoreParens());
-auto *ME = dyn_cast_or_null(RefExpr->IgnoreParens());
-if ((!DE || !isa(DE->getDecl())) &&
-(getCurrentThisType().isNull() || !ME ||
- !isa(ME->getBase()->IgnoreParenImpCasts()) ||
- !isa(ME->getMemberDecl( {
-  Diag(ELoc, diag::err_omp_expected_var_name_member_expr)
-  << (getCurrentThisType().isNull() ? 0 : 1)
-  << RefExpr->getSourceRange();
-  continue;
-}
-ValueDecl *D = DE ? DE->getDecl() : ME->getMemberDecl();
 QualType Type = D->getType();
 auto *VD = dyn_cast(D);
 
@@ -7161,46 +7171,28 @@ OMPClause *Sema::ActOnOpenMPFirstprivate
 
   for (auto &RefExpr : VarList) {
 assert(RefExpr && "NULL expr in OpenMP firstprivate clause.");
-if (isa(RefExpr)) {
+auto Res = getPrivateItem(*this, RefExpr);
+if (Res.second) {
   // It will be analyzed later.
   Vars.push_back(RefExpr);
   PrivateCopies.push_back(nullptr);
   Inits.push_back(nullptr);
-  continue;
 }
+ValueDecl *D = Res.first;
+if (!D)
+  continue;
 
 SourceLocation ELoc =
 IsImplicitClause ? ImplicitClauseLoc : RefExpr->getExprLoc();
-// OpenMP [2.1, C/C++]
-//  A list item is a variable name.
-// OpenMP  [2.9.3.3, Restrictions, p.1]
-//  A variable that is part of another variable (as an array or
-//  structure element) cannot appear in a private clause.
-DeclRefExpr *DE = dyn_cast_o

Re: [PATCH] D16851: Update of "GCC extensions not implemented yet" in Clang User's Manual

2016-02-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

Ping


http://reviews.llvm.org/D16851



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


Re: [PATCH] D15647: [X86] Fix stack alignment for MCU target (Clang part)

2016-02-10 Thread Andrey Turetskiy via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260376: [X86] Fix stack alignment for MCU target (Clang 
part), by Anton Nadolskiy. (authored by aturetsk).

Changed prior to commit:
  http://reviews.llvm.org/D15647?vs=43788&id=47440#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15647

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/iamcu-abi.c

Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -940,6 +940,9 @@
 return false;
   }
 
+  /// \brief Whether target allows to overalign ABI-specified prefered alignment
+  virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
+
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
 return PointerWidth;
Index: cfe/trunk/test/CodeGen/iamcu-abi.c
===
--- cfe/trunk/test/CodeGen/iamcu-abi.c
+++ cfe/trunk/test/CodeGen/iamcu-abi.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: target datalayout = "e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"
+// CHECK: target triple = "i386-pc-elfiamcu"
+
+
+void food(double *d);
+void fooll(long long *ll);
+void fooull(unsigned long long *ull);
+void foold(long double *ld);
+
+// CHECK-LABEL: define void @testdouble()
+// CHECK: alloca double, align 4
+void testdouble() {
+  double d = 2.0;
+  food(&d);
+}
+
+// CHECK-LABEL: define void @testlonglong()
+// CHECK: alloca i64, align 4
+void testlonglong() {
+  long long ll = 2;
+  fooll(&ll);
+}
+
+// CHECK-LABEL: define void @testunsignedlonglong()
+// CHECK: alloca i64, align 4
+void testunsignedlonglong() {
+  unsigned long long ull = 2;
+  fooull(&ull);	
+}
+
+// CHECK-LABEL: define void @testlongdouble()
+// CHECK: alloca double, align 4
+void testlongdouble() {
+  long double ld = 2.0;
+  foold(&ld);
+}
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -3807,6 +3807,8 @@
   : WindowsX86_32TargetInfo(Triple) {
 LongDoubleWidth = LongDoubleAlign = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+DataLayoutString =
+"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3926,6 +3928,10 @@
 Builder.defineMacro("__iamcu");
 Builder.defineMacro("__iamcu__");
   }
+
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 // RTEMS Target
@@ -7491,6 +7497,9 @@
 // R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
 return (RegNo < 2)? RegNo : -1;
   }
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -1904,8 +1904,8 @@
   if (T->isMemberPointerType())
 return getPreferredTypeAlign(getPointerDiffType().getTypePtr());
 
-  if (Target->getTriple().getArch() == llvm::Triple::xcore)
-return ABIAlign;  // Never overalign on XCore.
+  if (!Target->allowsLargerPreferedTypeAlignment())
+return ABIAlign;
 
   // Double and long long should be naturally aligned if possible.
   if (const ComplexType *CT = T->getAs())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260376 - [X86] Fix stack alignment for MCU target (Clang part), by Anton Nadolskiy.

2016-02-10 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Wed Feb 10 05:58:46 2016
New Revision: 260376

URL: http://llvm.org/viewvc/llvm-project?rev=260376&view=rev
Log:
[X86] Fix stack alignment for MCU target (Clang part), by Anton Nadolskiy.

This patch fixes stack alignments for MCU (should be aligned to 4 bytes).

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


Added:
cfe/trunk/test/CodeGen/iamcu-abi.c   (with props)
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=260376&r1=260375&r2=260376&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Feb 10 05:58:46 2016
@@ -940,6 +940,9 @@ public:
 return false;
   }
 
+  /// \brief Whether target allows to overalign ABI-specified prefered 
alignment
+  virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
+
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
 return PointerWidth;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=260376&r1=260375&r2=260376&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Feb 10 05:58:46 2016
@@ -1904,8 +1904,8 @@ unsigned ASTContext::getPreferredTypeAli
   if (T->isMemberPointerType())
 return getPreferredTypeAlign(getPointerDiffType().getTypePtr());
 
-  if (Target->getTriple().getArch() == llvm::Triple::xcore)
-return ABIAlign;  // Never overalign on XCore.
+  if (!Target->allowsLargerPreferedTypeAlignment())
+return ABIAlign;
 
   // Double and long long should be naturally aligned if possible.
   if (const ComplexType *CT = T->getAs())

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=260376&r1=260375&r2=260376&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Feb 10 05:58:46 2016
@@ -3807,6 +3807,8 @@ public:
   : WindowsX86_32TargetInfo(Triple) {
 LongDoubleWidth = LongDoubleAlign = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+DataLayoutString =
+"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3926,6 +3928,10 @@ public:
 Builder.defineMacro("__iamcu");
 Builder.defineMacro("__iamcu__");
   }
+
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 // RTEMS Target
@@ -7491,6 +7497,9 @@ public:
 // R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
 return (RegNo < 2)? RegNo : -1;
   }
+  bool allowsLargerPreferedTypeAlignment() const override {
+return false;
+  }
 };
 
 const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {

Added: cfe/trunk/test/CodeGen/iamcu-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/iamcu-abi.c?rev=260376&view=auto
==
--- cfe/trunk/test/CodeGen/iamcu-abi.c (added)
+++ cfe/trunk/test/CodeGen/iamcu-abi.c Wed Feb 10 05:58:46 2016
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-pc-elfiamcu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: target datalayout = 
"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32"
+// CHECK: target triple = "i386-pc-elfiamcu"
+
+
+void food(double *d);
+void fooll(long long *ll);
+void fooull(unsigned long long *ull);
+void foold(long double *ld);
+
+// CHECK-LABEL: define void @testdouble()
+// CHECK: alloca double, align 4
+void testdouble() {
+  double d = 2.0;
+  food(&d);
+}
+
+// CHECK-LABEL: define void @testlonglong()
+// CHECK: alloca i64, align 4
+void testlonglong() {
+  long long ll = 2;
+  fooll(&ll);
+}
+
+// CHECK-LABEL: define void @testunsignedlonglong()
+// CHECK: alloca i64, align 4
+void testunsignedlonglong() {
+  unsigned long long ull = 2;
+  fooull(&ull);
+}
+
+// CHECK-LABEL: define void @testlongdouble()
+// CHECK: alloca double, align 4
+void testlongdouble() {
+  long double ld = 2.0;
+  foold(&ld);
+}

Propchange: cfe/trunk/test/CodeGen/iamcu-abi.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/CodeGen/iamcu-abi.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/CodeGen/iamcu-abi.c
--

Re: [PATCH] D15920: [CMake] Add option to switch default C++ stdlib

2016-02-10 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld updated this revision to Diff 47441.
Hahnfeld added a comment.

Address reviewers' comments:

- check for valid `CLANG_DEFAULT_CXX_STDLIB`
- generalize for `Darwin` and `Bitrig` by introducing `GetDefaultCXXStdlibType`
- fallback to `CLANG_DEFAULT_CXX_STDLIB` if user choice is incorrect


http://reviews.llvm.org/D15920

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  include/clang/Config/config.h.in
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/android-standalone.cpp
  test/Driver/darwin-iphone-defaults.m
  test/Driver/darwin-objc-gc.m
  test/Driver/darwin-sanitizer-ld.c
  test/Driver/gcc-toolchain.cpp
  test/Driver/linux-header-search.cpp
  test/Driver/mips-cs.cpp
  test/Driver/mips-fsf.cpp
  test/Driver/mips-img.cpp
  test/Driver/sanitizer-ld.c
  test/Driver/windows-cross.c
  unittests/libclang/LibclangTest.cpp

Index: unittests/libclang/LibclangTest.cpp
===
--- unittests/libclang/LibclangTest.cpp
+++ unittests/libclang/LibclangTest.cpp
@@ -485,7 +485,7 @@
   WriteFile(Clang, "");
 
   const char *Argv[] = {Clang.c_str(), "-target", "arm-linux-gnueabi",
-"--gcc-toolchain="};
+"-stdlib=libstdc++", "--gcc-toolchain="};
 
   EXPECT_EQ(CXError_Success,
 clang_parseTranslationUnit2FullArgv(Index, Filename.c_str(), Argv,
Index: test/Driver/windows-cross.c
===
--- test/Driver/windows-cross.c
+++ test/Driver/windows-cross.c
@@ -1,9 +1,9 @@
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-BASIC
 
 // CHECK-BASIC: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -o /dev/null %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
 
 // CHECK-RTLIB: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" "mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/crtbegin.obj" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" "-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
@@ -33,7 +33,7 @@
 
 // CHECK-STANDALONE: armv7-windows-itanium-ld" "--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-shared" "-Bdynamic" "--enable-auto-image-base" "--entry" "_DllMainCRTStartup" "--allow-multiple-definition" "-o" "shared.dll" "--out-implib" "shared.lib" "{{.*}}.o"
 
-// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %/Inputs/Windows/ARM/8.1/usr/bin -shared -o shared.dll -x c++ %s 2>&1 \
+// RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %/Inputs/Windows/ARM/8.1/usr/bin -stdlib=libstdc++ -shared -o shared.dll -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-LIBSTDCXX
 
 // CHECK-LIBSTDCXX:  "-internal-isystem" "{{.*}}/usr/include/c++" "-internal-isystem" "{{.*}}/usr/include/c++/armv7--windows-itanium" "-internal-isystem" "{{.*}}/usr/include/c++/backwards"
Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -76,7 +76,7 @@
 // CHECK-ASAN-FREEBSD-LDL-NOT: "-ldl"
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -fsanitize=address \
+// RUN: -target i386-unknown-linux -stdlib=libstdc++ -fsanitize=address \
 // RUN: -resource-dir=%S/Inputs/empty_resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
@@ -93,8 +93,8 @@
 // CHECK-ASAN-LINUX-CXX: "-ldl"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
-// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: -lstdc++ -static 2>&1 \
+// RUN: -target i386-unknown-linux -stdlib=

RE: [clang-tools-extra] r260225 - [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work on various bots

2016-02-10 Thread Daniel Marjamäki via cfe-commits

Hello!

That would make some sense to me.

To catch portability issues users could use different relevant targets. Do you 
know if some do that?

Best regards,
Daniel Marjamäki

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: Alexander Kornienko [ale...@google.com]
Skickat: den 10 februari 2016 12:23
Till: Daniel Marjamäki
Kopia: cfe-commits
Ämne: Re: SV: [clang-tools-extra] r260225 - [clang-tidy] Add -target in 
misc-misplaced-widening-cast test so it will work on various bots

Makes sense. I wonder though whether the check should attempt to be 
platform-independent and warn regardless of whether int and long have the same 
bit width. What do you think?

On Feb 10, 2016 9:35 AM, "Daniel Marjamäki" 
mailto:daniel.marjam...@evidente.se>> wrote:

Hello!

> I'm not sure this is a good fix. What was the specific issue (and on which 
> buildbots)?

Ok.

The buildbots said:

FileCheck error: 
'/home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/tools/clang/tools/extra/test/clang-tidy/Output/misc-misplaced-widening-cast.cpp.tmp.cpp.msg'
 is empty.

My check only warns when there is a widening cast. If sizeof(int)==sizeof(long) 
then there is no warning for a int=>long conversion. In my testcases I tested 
various int=>long conversions.

These are the failed builds:

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/187
http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/6265
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9641
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9691

Best regards,
Daniel Marjamäki

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 
62
E-mail: 
daniel.marjam...@evidente.se

www.evidente.se


Från: Alexander Kornienko [ale...@google.com]
Skickat: den 9 februari 2016 17:41
Till: Daniel Marjamäki
Kopia: cfe-commits
Ämne: Re: [clang-tools-extra] r260225 - [clang-tidy] Add -target in 
misc-misplaced-widening-cast test so it will work on various bots

I'm not sure this is a good fix. What was the specific issue (and on which 
buildbots)?

On Tue, Feb 9, 2016 at 4:43 PM, Daniel Marjamaki via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>>
 wrote:
Author: danielmarjamaki
Date: Tue Feb  9 09:43:05 2016
New Revision: 260225

URL: http://llvm.org/viewvc/llvm-project?rev=260225&view=rev
Log:
[clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work 
on various bots

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp?rev=260225&r1=260224&r2=260225&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp 
Tue Feb  9 09:43:05 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t
+// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- -- -target 
x86_64-unknown-unknown

 void assign(int a, int b) {
   long l;


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


Re: [PATCH] D15920: [CMake] Add option to switch default C++ stdlib

2016-02-10 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.

In http://reviews.llvm.org/D15920#347352, @beanz wrote:

> Is it correct to assume that all the test case changes are needed just to 
> make the tests pass if you set CLANG_DEFAULT_CXX_STDLIB=libc++?
>
> [...]


Yes, most of the tests check for the correct `libstdc++` include paths which 
are not met with `libc++`.



Comment at: lib/Driver/ToolChain.cpp:549-550
@@ -536,9 +548,4 @@
+
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) 
const{
-  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
-StringRef Value = A->getValue();
-if (Value == "libc++")
-  return ToolChain::CST_Libcxx;
-if (Value == "libstdc++")
-  return ToolChain::CST_Libstdcxx;
-getDriver().Diag(diag::err_drv_invalid_stdlib_name)
-  << A->getAsString(Args);
+  ToolChain::CXXStdlibType Type;
+  bool HasValidType = false;

I have moved the behaviour from `Darwin::TranslateArgs` to 
`Darwin::GetDefaultCXXStdlibType` and added this method for `Bitrig` as well 
(which was straightforward). `MIPS` only allows `libc++` so there is nothing 
the user can choose from...

I would have also liked to implement this for `FreeBSD` and `NetBSD` but their 
default library is dependent on the system version. While this wouldn't be a 
problem and could be implemented in `GetDefaultCXXStdlibType`, this would still 
be overriden by `CLANG_DEFAULT_CXX_STDLIB` which unfortunately fails the tests 
in `test/Driver/{freebsd.c,netbsd.c}`. Is it ok to leave this for now?


http://reviews.llvm.org/D15920



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


Re: [PATCH] D16524: [clang-format-vs] Fix sort include main include: Use current path for the '-assume-filename'

2016-02-10 Thread Daniel Jasper via cfe-commits
djasper added a subscriber: djasper.
djasper closed this revision.
djasper added a comment.

Submitted as r260378.


http://reviews.llvm.org/D16524



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


r260378 - clang-format sort include use the source file name to determine the

2016-02-10 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Wed Feb 10 06:42:58 2016
New Revision: 260378

URL: http://llvm.org/viewvc/llvm-project?rev=260378&view=rev
Log:
clang-format sort include use the source file name to determine the
"main include" that will be the 1st include (category 0).

Because the clang-format visual studio extension does not pass the file
name and use the standard input, sort include cannot find a "main
include":

Testing fix on llvm\tools\clang\lib\Format\Format.cpp:
Original file:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio
clang-format:
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Format/Format.h"
  #include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Test 2 with main header not at the start:
Original file:
  ...
  #include "clang/Format/Format.h"
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Without fix, selecting the includes and running visual studio
clang-format:
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Format/Format.h"
  #include "clang/Lex/Lexer.h"

With fix, selecting the includes and running visual studio clang-format:
  #include "clang/Format/Format.h"
  ...
  #include "clang/Basic/SourceManager.h"
  #include "clang/Lex/Lexer.h"

Patch by Jean-Philippe Dufraigne, thank you.
Review: http://reviews.llvm.org/D16524

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs?rev=260378&r1=260377&r2=260378&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs Wed Feb 
10 06:42:58 2016
@@ -202,9 +202,10 @@ namespace LLVM.ClangFormat
 if (start >= text.Length && text.Length > 0)
 start = text.Length - 1;
 string path = GetDocumentParent(view);
+string filePath = GetDocumentPath(view);
 try
 {
-var root = XElement.Parse(RunClangFormat(text, start, length, 
path));
+var root = XElement.Parse(RunClangFormat(text, start, length, 
path, filePath));
 var edit = view.TextBuffer.CreateEdit();
 foreach (XElement replacement in 
root.Descendants("replacement"))
 {
@@ -237,7 +238,7 @@ namespace LLVM.ClangFormat
 /// 
 /// Formats the text range starting at offset of the given length.
 /// 
-private string RunClangFormat(string text, int offset, int length, 
string path)
+private string RunClangFormat(string text, int offset, int length, 
string path, string filePath)
 {
 string vsixPath = Path.GetDirectoryName(
 typeof(ClangFormatPackage).Assembly.Location);
@@ -257,6 +258,8 @@ namespace LLVM.ClangFormat
 if (GetSortIncludes())
   process.StartInfo.Arguments += " -sort-includes ";
 string assumeFilename = GetAssumeFilename();
+if (string.IsNullOrEmpty(assumeFilename))
+assumeFilename = filePath;
 if (!string.IsNullOrEmpty(assumeFilename))
   process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;
@@ -355,5 +358,15 @@ namespace LLVM.ClangFormat
 }
 return null;
 }
+
+private string GetDocumentPath(IWpfTextView view)
+{
+ITextDocument document;
+if 
(view.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document))
+{
+return document.FilePath;
+}
+return null;
+}
 }
 }


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


r260379 - Reapply the patch of r260376.

2016-02-10 Thread Andrey Turetskiy via cfe-commits
Author: aturetsk
Date: Wed Feb 10 06:56:10 2016
New Revision: 260379

URL: http://llvm.org/viewvc/llvm-project?rev=260379&view=rev
Log:
Reapply the patch of r260376.


Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=260379&r1=260378&r2=260379&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Feb 10 06:56:10 2016
@@ -3807,8 +3807,6 @@ public:
   : WindowsX86_32TargetInfo(Triple) {
 LongDoubleWidth = LongDoubleAlign = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
-DataLayoutString =
-"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32";
   }
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
@@ -3913,6 +3911,8 @@ public:
   MCUX86_32TargetInfo(const llvm::Triple &Triple) : X86_32TargetInfo(Triple) {
 LongDoubleWidth = 64;
 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
+DataLayoutString =
+"e-m:e-p:32:32-i64:32-f64:32-f128:32-n8:16:32-a:0:32-S32";
 UserLabelPrefix = "";
 WIntType = UnsignedInt;
   }


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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-10 Thread Aaron Ballman via cfe-commits
On Wed, Feb 10, 2016 at 3:23 AM, Daniel Marjamäki
 wrote:
>
> That is intentional.. you can't get overflow with / , % , & , | , etc...

You can get overflow with / and %. Consider:

int i = INT_MIN / -1; // similar for %

~Aaron

>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: daniel.marjam...@evidente.se
>
> www.evidente.se
>
> 
> Från: Richard [legal...@xmission.com]
> Skickat: den 10 februari 2016 07:28
> Till: Daniel Marjamäki; aaron.ball...@gmail.com; ale...@google.com
> Kopia: legal...@xmission.com; eugene.zele...@gmail.com; 
> cfe-commits@lists.llvm.org
> Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast
>
> LegalizeAdulthood added inline comments.
>
> 
> Comment at: 
> clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp:21-23
> @@ +20,5 @@
> +void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
> +  auto Calc = expr(anyOf(binaryOperator(anyOf(
> + hasOperatorName("+"), hasOperatorName("-"),
> + hasOperatorName("*"), hasOperatorName("<<"))),
> + unaryOperator(hasOperatorName("~"))),
> 
> Sorry for the late observation, but why doesn't this check for `%` and `/` 
> operators?
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16310
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-10 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: docs/clang-tidy/checks/misc-suspicious-semicolon.rst:35
@@ +34,3 @@
+
+if(x >= y);
+x -= y;

hokein wrote:
> The doc needs to be updated.
> 
> With your latest patch, this is also a warning case.
The documentation implies that this is a warning case but I will make it 
clearer to be less confusing.


http://reviews.llvm.org/D16535



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-10 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 47446.
xazax.hun added a comment.

- Documentation clarification.


http://reviews.llvm.org/D16535

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousSemicolonCheck.cpp
  clang-tidy/misc/SuspiciousSemicolonCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-semicolon.rst
  test/clang-tidy/misc-suspicious-semicolon.cpp

Index: test/clang-tidy/misc-suspicious-semicolon.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-semicolon.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s misc-suspicious-semicolon %t
+
+int x = 5;
+
+void nop();
+
+void correct1()
+{
+	if(x < 5) nop();
+}
+
+void correct2()
+{
+	if(x == 5)
+		nop();
+}
+
+void correct3()
+{
+	if(x > 5)
+	{
+		nop();
+	}
+}
+
+void fail1()
+{
+  if(x > 5); nop();
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [misc-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) nop();
+}
+
+void fail2()
+{
+	if(x == 5);
+		nop();
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: warning: potentially unintended semicolon [misc-suspicious-semicolon]
+  // CHECK-FIXES: if(x == 5){{$}}
+}
+
+void fail3()
+{
+	if(x < 5);
+	{
+		nop();
+	}
+  // CHECK-MESSAGES: :[[@LINE-4]]:11: warning: potentially unintended semicolon
+  // CHECK-FIXES: if(x < 5){{$}}
+}
+
+void correct4()
+{
+  while(x % 5 == 1);
+  nop();
+}
+
+void correct5()
+{
+	for(int i = 0; i < x; ++i)
+		;
+}
+
+void fail4()
+{
+	for(int i = 0; i < x; ++i);
+		nop();
+  // CHECK-MESSAGES: :[[@LINE-2]]:28: warning: potentially unintended semicolon
+  // CHECK-FIXES: for(int i = 0; i < x; ++i){{$}}
+}
+
+void fail5()
+{
+	if(x % 5 == 1);
+	  nop();
+  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: potentially unintended semicolon
+  // CHECK-FIXES: if(x % 5 == 1){{$}}
+}
+
+void fail6() {
+  int a = 0;
+  if (a != 0) {
+  } else if (a != 1);
+a = 2;
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: potentially unintended semicolon
+  // CHECK-FIXES: } else if (a != 1){{$}}
+}
+
+void fail7() {
+  if (true)
+;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: potentially unintended semicolon
+}
+
+void correct6()
+{
+	do; while(false);
+}
+
+int correct7()
+{
+  int t_num = 0;
+  char c = 'b';
+  char *s = "a";
+  if (s == "(" || s != "'" || c == '"') {
+t_num += 3;
+return (c == ')' && c == '\'');
+  }
+
+  return 0;
+}
+
+void correct8() {
+  if (true)
+;
+  else {
+  }
+}
Index: docs/clang-tidy/checks/misc-suspicious-semicolon.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-suspicious-semicolon.rst
@@ -0,0 +1,72 @@
+.. title:: clang-tidy - misc-suspicious-semicolon
+
+misc-suspicious-semicolon
+=
+
+Finds most instances of stray semicolons that unexpectedly alter the meaning of
+the code. More specifically, it looks for `if`, `while`, `for` and `for-range`
+statements whose body is a single semicolon, and then analyzes the context of
+the code (e.g. indentation) in an attempt to determine whether that is
+intentional.
+
+  .. code-block:: c++
+
+if(x < y);
+{
+  x++;
+}
+
+Here the body of the `if` statement consists of only the semicolon at the end of
+the first line, and `x` will be incremented regardless of the condition.
+
+
+  .. code-block:: c++
+
+while((line = readLine(file)) != NULL);
+  processLine(line);
+
+As a result of this code, `processLine()` will only be called once, when the
+`while` loop with the empty body exits with `line == NULL`. The indentation of
+the code indicates the intention of the programmer.
+
+
+  .. code-block:: c++
+
+if(x >= y);
+x -= y;
+
+While the indentation does not imply any nesting, there is simply no valid
+reason to have an `if` statement with an empty body (but it can make sense for
+a loop). So this check issues a warning for the code above.
+
+To solve the issue remove the stray semicolon or in case the empty body is
+intentional, reflect this using code indentation or put the semicolon in a new
+line. For example:
+
+  .. code-block:: c++
+
+while(readWhitespace());
+  Token t = readNextToken();
+
+Here the second line is indented in a way that suggests that it is meant to be
+the body of the `while` loop - whose body is in fact empty, becasue of the
+semicolon at the end of the first line.
+
+Either remove the indentation from the second line:
+
+  .. code-block:: c++
+
+while(readWhitespace());
+Token t = readNextToken();
+
+... or move the semicolon from the end of the first line to a new line:
+
+  .. code-block:: c++
+
+while(readWhitespace())
+  ;
+
+  Token t = readNextToken();
+
+In this case the check will assume that you know what you are doing, and will
+not raise a warning.
Index: docs/clang-tidy/checks/list.rst
==

Re: r260277 - Simplify and rename ASTMatchFinder's getCXXRecordDecl to make it more obvious

2016-02-10 Thread Manuel Klimek via cfe-commits
On Wed, Feb 10, 2016 at 10:04 AM Manuel Klimek  wrote:

> On Tue, Feb 9, 2016 at 10:03 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Feb  9 14:59:05 2016
>> New Revision: 260277
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=260277&view=rev
>> Log:
>> Simplify and rename ASTMatchFinder's getCXXRecordDecl to make it more
>> obvious
>> what it's actually trying to do.
>>
>> Modified:
>> cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
>>
>> Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=260277&r1=260276&r2=260277&view=diff
>>
>> ==
>> --- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
>> +++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Tue Feb  9 14:59:05 2016
>> @@ -744,46 +744,25 @@ private:
>>MemoizationMap ResultCache;
>>  };
>>
>> -static CXXRecordDecl *getAsCXXRecordDecl(const Type *TypeNode) {
>> -  // Type::getAs<...>() drills through typedefs.
>> -  if (TypeNode->getAs() != nullptr ||
>> -  TypeNode->getAs() != nullptr
>> ||
>> -  TypeNode->getAs() != nullptr)
>> -// Dependent names and template TypeNode parameters will be matched
>> when
>> -// the template is instantiated.
>> -return nullptr;
>> -  TemplateSpecializationType const *TemplateType =
>> -  TypeNode->getAs();
>> -  if (!TemplateType) {
>> -return TypeNode->getAsCXXRecordDecl();
>> -  }
>> -  if (TemplateType->getTemplateName().isDependent())
>> -// Dependent template specializations will be matched when the
>> -// template is instantiated.
>> -return nullptr;
>> -
>> -  // For template specialization types which are specializing a template
>> -  // declaration which is an explicit or partial specialization of
>> another
>> -  // template declaration, getAsCXXRecordDecl() returns the corresponding
>> -  // ClassTemplateSpecializationDecl.
>> -  //
>> -  // For template specialization types which are specializing a template
>> -  // declaration which is neither an explicit nor partial specialization
>> of
>> -  // another template declaration, getAsCXXRecordDecl() returns NULL and
>> -  // we get the CXXRecordDecl of the templated declaration.
>> -  CXXRecordDecl *SpecializationDecl = TemplateType->getAsCXXRecordDecl();
>> -  if (SpecializationDecl) {
>> -return SpecializationDecl;
>> -  }
>> -  NamedDecl *Templated =
>> -
>> TemplateType->getTemplateName().getAsTemplateDecl()->getTemplatedDecl();
>> -  if (CXXRecordDecl *TemplatedRecord =
>> dyn_cast(Templated)) {
>> -return TemplatedRecord;
>> -  }
>> -  // Now it can still be that we have an alias template.
>> -  TypeAliasDecl *AliasDecl = dyn_cast(Templated);
>> -  assert(AliasDecl);
>> -  return getAsCXXRecordDecl(AliasDecl->getUnderlyingType().getTypePtr());
>> +static CXXRecordDecl *
>> +getAsCXXRecordDeclOrPrimaryTemplate(const Type *TypeNode) {
>> +  if (auto *RD = TypeNode->getAsCXXRecordDecl())
>> +return RD;
>> +
>> +  // Find the innermost TemplateSpecializationType that isn't an alias
>> template.
>> +  auto *TemplateType = TypeNode->getAs();
>> +  while (TemplateType && TemplateType->isTypeAlias())
>> +TemplateType =
>> +
>> TemplateType->getAliasedType()->getAs();
>> +
>> +  // If this is the name of a (dependent) template specialization, use
>> the
>> +  // definition of the template, even though it might be specialized
>> later.
>> +  if (TemplateType)
>> +if (auto *ClassTemplate = dyn_cast_or_null(
>> +  TemplateType->getTemplateName().getAsTemplateDecl()))
>> +  return ClassTemplate->getTemplatedDecl();
>> +
>> +  return nullptr;
>>  }
>>
>>  // Returns true if the given class is directly or indirectly derived
>> @@ -800,7 +779,10 @@ bool MatchASTVisitor::classIsDerivedFrom
>>  if (typeHasMatchingAlias(TypeNode, Base, Builder))
>>return true;
>>
>> -CXXRecordDecl *ClassDecl = getAsCXXRecordDecl(TypeNode);
>> +// FIXME: Going to the primary template here isn't really correct,
>> but
>> +// unfortunately we accept a Decl matcher for the base class not a
>> Type
>> +// matcher, so it's the best thing we can do with our current
>
>
> Why not? Specifically, it seems to match what the user wants in most
> cases. Now, I'm all for also exposing a more complex interface to the user,
> where they can / have to control exactly where to dive into the primary
> templates, but experience shows that this is really hard for anybody who's
> not a C++ expert to understand, and the current behavior here matches what
> people expect when they want to match classes in the inheritance hierarchy.
>

Read up on the other thread, and understand your concern now.
The problem in matchers is:
a) we want to be able to match primary templates, even if they're not
instantiated
b) the most common pattern to match on is names

In
template class X : pu

RE: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-10 Thread Daniel Marjamäki via cfe-commits

> You can get overflow with / and %. Consider:
>
> int i = INT_MIN / -1; // similar for %

you are right, I did not think of that. 

imho overflow still seems unlikely for / and %.

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: Aaron Ballman [aaron.ball...@gmail.com]
Skickat: den 10 februari 2016 14:12
Till: Daniel Marjamäki
Kopia: reviews+d16310+public+4a30d2d495388...@reviews.llvm.org; 
ale...@google.com; legal...@xmission.com; eugene.zele...@gmail.com; 
cfe-commits@lists.llvm.org
Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

On Wed, Feb 10, 2016 at 3:23 AM, Daniel Marjamäki
 wrote:
>
> That is intentional.. you can't get overflow with / , % , & , | , etc...

You can get overflow with / and %. Consider:

int i = INT_MIN / -1; // similar for %

~Aaron

>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: daniel.marjam...@evidente.se
>
> www.evidente.se
>
> 
> Från: Richard [legal...@xmission.com]
> Skickat: den 10 februari 2016 07:28
> Till: Daniel Marjamäki; aaron.ball...@gmail.com; ale...@google.com
> Kopia: legal...@xmission.com; eugene.zele...@gmail.com; 
> cfe-commits@lists.llvm.org
> Ämne: Re: [PATCH] D16310: new clang-tidy checker misc-long-cast
>
> LegalizeAdulthood added inline comments.
>
> 
> Comment at: 
> clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp:21-23
> @@ +20,5 @@
> +void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
> +  auto Calc = expr(anyOf(binaryOperator(anyOf(
> + hasOperatorName("+"), hasOperatorName("-"),
> + hasOperatorName("*"), hasOperatorName("<<"))),
> + unaryOperator(hasOperatorName("~"))),
> 
> Sorry for the late observation, but why doesn't this check for `%` and `/` 
> operators?
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D16310
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r260381 - Limit catopen usage to unix-like OSes

2016-02-10 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Wed Feb 10 07:47:25 2016
New Revision: 260381

URL: http://llvm.org/viewvc/llvm-project?rev=260381&view=rev
Log:
Limit catopen usage to unix-like OSes

Operating systems that are not unix-like are unlikely to have access to
catopen. Instead of black-listing each one, we now filter out all non-unix
operating systems first. We then exclude the unix-like operating systems
that don't have catopen. _WIN32 counts as a unix-like operating system
because of cygwin.

http://reviews.llvm.org/D16639

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=260381&r1=260380&r2=260381&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb 10 07:47:25 2016
@@ -719,10 +719,12 @@ template  struct __static_asse
 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
 #endif
 
-#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \
-!defined(__CloudABI__)
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+// Most unix variants have catopen.  These are the specific ones that don't.
+#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
 #define _LIBCPP_HAS_CATOPEN 1
 #endif
+#endif
 
 #ifdef __FreeBSD__
 #define _DECLARE_C99_LDBL_MATH 1


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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-10 Thread Haojian Wu via cfe-commits
hokein added a comment.

LGTM, thanks for working on this! Ping @alexfh


http://reviews.llvm.org/D16535



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


Re: [PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-10 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 47448.
congliu marked 2 inline comments as done.
congliu added a comment.

- Generate a single warning for multiple template instantiations.


http://reviews.llvm.org/D16922

Files:
  clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tidy/misc/VirtualNearMissCheck.h
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -16,22 +16,57 @@
   // overriden by this class.
   virtual void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
+  // CHECK-FIXES: virtual void func();
 
   void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   void func22(); // Should not warn.
 
   void gunk(); // Should not warn: gunk is override.
 
   void fun();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   Derived &operator==(const Base &); // Should not warn: operators are ignored.
 
   virtual NoDefinedClass2 *f1(); // Should not crash: non-defined class return type is ignored.
 };
 
+template 
+struct TBase {
+  virtual void tfunc(T t);
+};
+
+template 
+struct TDerived : TBase {
+  virtual void tfunk(T t);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'TDerived::tfunk' has {{.*}} 'TBase::tfunc'
+  // CHECK-FIXES: struct TDerived : TBase {
+  // CHECK-FIXES-NEXT: virtual void tfunc(T t);
+};
+
+TDerived T1;
+TDerived T2;
+
+// Should not fix macro definition
+#define MACRO1 void funcM()
+// CHECK-FIXES: #define MACRO1 void funcM()
+#define MACRO2(m) void m()
+// CHECK-FIXES: #define MACRO2(m) void m()
+
+struct DerivedMacro : Base {
+  MACRO1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::funcM' has {{.*}} 'Base::func'
+  // CHECK-FIXES: MACRO1;
+
+  MACRO2(func3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::func3' has {{.*}} 'Base::func'
+  // CHECK-FIXES: MACRO2(func);
+};
+
 typedef Derived derived_type;
 
 class Father {
@@ -58,32 +93,40 @@
 
   virtual void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 'Father::func'
+  // CHECK-FIXES: virtual void func();
 
   int methoe(int x, char **strs); // Should not warn: parameter types don't match.
 
   int methoe(int x);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x);
 
   void methof(int x, const char **strs); // Should not warn: return types don't match.
 
   int methoh(int x, const char **strs);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x, const char **strs);
 
   virtual Child *creat(int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 'Father::create'
+  // CHECK-FIXES: virtual Child *create(int i);
 
   virtual Derived &&generat();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate'
+  // CHECK-FIXES: virtual Derived &&generate();
 
   int decaz(const char str[]);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay'
+  // CHECK-FIXES: int decay(const char str[]);
 
   operator bool();
 
   derived_type *canonica(derived_type D);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::canonica' has {{.*}} 'Father::canonical'
+  // CHECK-FIXES: derived_type *canonical(derived_type D);
 
 private:
   void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func'
+  // CHECK-FIXES: void func();
 };
Index: clang-tidy/misc/VirtualNearMissCheck.h
===
--- clang-tidy/misc/VirtualNearMissCheck.h
+++ clang-tidy/misc/VirtualNearMissCheck.h
@@ -12,7 +12,7 @@
 
 #include "../ClangTidy.h"
 #include 
-#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -46,7 +46,7 @@
   bool isOverriddenByDerivedClass(const CXXMethodDecl *BaseMD,
   const CXXRecordDecl *DerivedRD);
 
-  /// key: the unique ID of a method;
+  /// key: the unique ID of a method
   /// value: whether the method is possible to be overridden.
   std::map PossibleMap;
 
@@ -56,6 +56,9 @@
   std::map, bool>
   OverriddenMap;
 
+  /// key: the source location id of a generated warning
+  std::unordered_set WarningSet;
+
   const unsigned EditDistanceThreshold = 1;
 };
 
Index: clang-tidy/misc/VirtualNearMissCheck.cpp
===
--- clang-tidy/misc/VirtualNear

Re: Patch for Bug 26283: float.h is missing mandatory C11 fp macros like DBL_DECIMAL_DIG and LDBL_DECIMAL_DIG

2016-02-10 Thread Jorge Teixeira via cfe-commits
Richard,

Can you be more specific?

I assume you mean something like my newly attached .h file that tests
very basic implementation compliance (i.e., it's required, but not
sufficient), but I would need a bit more guidance about the structure
of the file, how to perform the tests, and where to exactly place and
name the file within test/Headers.

I some sort of template exists, or if someone else takes point and
makes it, I can "port" the attached p11 test cases. I am unsure of how
to perform a more normative compliance - for example, to assert that
LDBL_DECIMAL_DIG is 21 on x86-64 and that indeed those many digits are
guaranteed to be correct, etc. This is probably not possible / does
not make sense.

JT

On Tue, Feb 9, 2016 at 3:58 PM, Richard Smith  wrote:
> Patch looks good. Please also add a testcase to test/Headers.
>
> On Tue, Feb 9, 2016 at 12:08 PM, Hubert Tong via cfe-commits
>  wrote:
>> I see no immediate issue with this patch, but I am not one of the usual
>> reviewers for this part of the code base.
>>
>> -- HT
>>
>>
>> On Tue, Feb 9, 2016 at 2:56 PM, Jorge Teixeira 
>> wrote:
>>>
>>> Thanks Hubert. Somehow I omitted that prefix when typing the macros,
>>> and I did not noticed it when I was testing because on my arch
>>> DECIMAL_DIG is defined to be the LDBL version...
>>>
>>> Updated patch is attached.
>>>
>>> JT
>>>
>>> On Tue, Feb 9, 2016 at 1:41 PM, Hubert Tong
>>>  wrote:
>>> > There is a __LDBL_DECIMAL_DIG__ predefined macro. __DECIMAL_DIG__ will
>>> > not
>>> > always be the same as __LDBL_DECIMAL_DIG__.
>>> >
>>> > -- HT
>>> >
>>> > On Mon, Feb 8, 2016 at 11:26 PM, Jorge Teixeira via cfe-commits
>>> >  wrote:
>>> >>
>>> >> Hi, I filed the bug (https://llvm.org/bugs/show_bug.cgi?id=26283) some
>>> >> time ago and nobody picked it up, so here is a trivial patch exposing
>>> >> the missing macros, that to the best of my ability were already
>>> >> present as the internal underscored versions.
>>> >>
>>> >> Perhaps a more general bug about C11 floating point (lack of)
>>> >> conformance should be filed, so that some form of unit test/macro
>>> >> validation could be worked on, but this patch does scratch my current
>>> >> itch.
>>> >>
>>> >> Successfully tested on x86-64 Xubuntu 14.04 with clang 3.8 from the
>>> >> ppa, patched with the attached diff.
>>> >>
>>> >> First contribution, so feel free to suggest improvements or point to
>>> >> more detailed step-by-step instructions/guidelines.
>>> >>
>>> >> Cheers,
>>> >>
>>> >> JT
>>> >>
>>> >> ___
>>> >> 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
>>
/* From N1570 draft of C11 Std. */
/* 5.2.4.2.2p11, pp. 30 */

#include 
#if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)

#ifndef	FLT_RADIX
	#error "Macro FLT_RADIX missing"
#elif	FLT_RADIX < 2
	# error "Macro FLT_RADIX invalid"
#endif


#ifndef FLT_MANT_DIG
	#error "Macro FLT_MANT_DIG missing"
#elif	FLT_MANT_DIG < 1
	# error "Macro FLT_MANT_DIG invalid"
#endif
#ifndef DBL_MANT_DIG
	#error "Macro DBL_MANT_DIG missing"
#elif	DBL_MANT_DIG < 1
	# error "Macro DBL_MANT_DIG invalid"
#endif
#ifndef LDBL_MANT_DIG
	#error "Macro LDBL_MANT_DIG missing"
#elif	LDBL_MANT_DIG < 1
	# error "Macro LDBL_MANT_DIG invalid"
#endif
#if (FLT_MANT_DIG > DBL_MANT_DIG) || (DBL_MANT_DIG > LDBL_MANT_DIG)
	#error "Macro(s) FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG invalid"
#endif


#ifndef FLT_DECIMAL_DIG
	#error "Macro FLT_DECIMAL_DIG missing"
#elif	FLT_DECIMAL_DIG < 6
	# error "Macro FLT_DECIMAL_DIG invalid"
#endif
#ifndef DBL_DECIMAL_DIG
	#error "Macro DBL_DECIMAL_DIG missing"
#elif	DBL_DECIMAL_DIG < 10
	# error "Macro DBL_DECIMAL_DIG invalid"
#endif
#ifndef LDBL_DECIMAL_DIG
	#error "Macro LDBL_DECIMAL_DIG missing"
#elif	LDBL_DECIMAL_DIG < 10
	# error "Macro LDBL_DECIMAL_DIG invalid"
#endif
#if (FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG)
	#error "Macro(s) FLT_DECIMAL_DIG, DBL_DECIMAL_DIG, LDBL_DECIMAL_DIG invalid"
#endif


#ifndef	DECIMAL_DIG
	#error "Macro DECIMAL_DIG missing"
#elif	DECIMAL_DIG < 10
	# error "Macro DECIMAL_DIG invalid"
#endif


#ifndef FLT_DIG
	#error "Macro FLT_DIG missing"
#elif	FLT_DIG < 6
	# error "Macro FLT_DIG invalid"
#endif
#ifndef DBL_DIG
	#error "Macro DBL_DIG missing"
#elif	DBL_DIG < 10
	# error "Macro DBL_DIG invalid"
#endif
#ifndef LDBL_DIG
	#error "Macro LDBL_DIG missing"
#elif	LDBL_DIG < 10
	# error "Macro LDBL_DIG invalid"
#endif
#if (FLT_DIG > DBL_DIG) || (DBL_DIG > LDBL_DIG)
	#error "Macro(s) FLT_DIG, DBL_DIG, LDBL_DIG invalid"
#endif


#ifndef FLT_MIN_EXP
	#error "Macro _MIN_EXP missing"
#elif	FLT_MIN_EXP > -2
	# error "Macro _MIN_EXP invalid"
#endif
#ifndef DBL_MIN_EXP
	#error "Macro DBL_MIN_EXP missing"
#elif	DBL_MIN_EXP

[PATCH] D17049: [CMake] don't build libLTO when LLVM_ENABLE_PIC is OFF

2016-02-10 Thread Igor Sugak via cfe-commits
sugak created this revision.
sugak added a reviewer: beanz.
sugak added subscribers: hans, cfe-commits.
Herald added a subscriber: joker.eph.

When cmake is run with `-DLLVM_ENABLE_PIC=OFF`, build fails while
linking shared library libLTO.so, because its dependencies are built
with -fno-PIC. More details here: https://llvm.org/bugs/show_bug.cgi?id=26484.
This diff reverts r252652 (git 9fd4377ddb83aee3c049dc8757e7771edbb8ee71),
which removed check `NOT LLVM_ENABLE_PIC` before enabling build for libLTO.so.

I've verified that when cmake is run with `-DLLVM_ENABLE_PIC=ON`, libLTO.so is
still generated, as well as when this option is not specified and the default
value (ON) is used. Tested both on master and release_38.

http://reviews.llvm.org/D17049

Files:
  tools/CMakeLists.txt

Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -25,7 +25,7 @@
   set(LLVM_TOOL_LLVM_JITLISTENER_BUILD Off)
 endif()
 
-if(CYGWIN)
+if(CYGWIN OR NOT LLVM_ENABLE_PIC)
   set(LLVM_TOOL_LTO_BUILD Off)
   set(LLVM_TOOL_LLVM_LTO_BUILD Off)
 endif()


Index: tools/CMakeLists.txt
===
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -25,7 +25,7 @@
   set(LLVM_TOOL_LLVM_JITLISTENER_BUILD Off)
 endif()
 
-if(CYGWIN)
+if(CYGWIN OR NOT LLVM_ENABLE_PIC)
   set(LLVM_TOOL_LTO_BUILD Off)
   set(LLVM_TOOL_LLVM_LTO_BUILD Off)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Sidney San Martín via cfe-commits
sidney added a comment.

Quick note: this is my first contribution, born from the Clang/LLVM sprint last 
weekend. Marshall helped me get started.


http://reviews.llvm.org/D17043



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


[PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Sidney San Martín via cfe-commits
sidney created this revision.
sidney added reviewers: mclow.lists, alexfh.
sidney added a subscriber: cfe-commits.

Currently has a whitelist of methods like std::vector::empty() which,
in a standalone statement, likely won't do what the programmer wants.

The whitelist is brittle (Did I misspell a method? Does a container
other than std::vector have a base class like std::__vector_base?) and
unlikely to be maintained, so two directions for improvement could be:

1. Use the compiler to determine whether a method has side effects.

2. Annotate methods without side effects. A newly-added method is more
likely to end up with the annotation than in this check's whitelist.

...but this might be a good start.

Project from 
https://trello.com/c/4sbyrOSv/15-clang-checker-check-that-the-result-of-library-calls-w-o-side-effects-are-used

http://reviews.llvm.org/D17043

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/NoSideEffectsCheck.cpp
  clang-tidy/misc/NoSideEffectsCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-no-side-effects.rst
  test/clang-tidy/misc-no-side-effects.cpp

Index: test/clang-tidy/misc-no-side-effects.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-no-side-effects.cpp
@@ -0,0 +1,18 @@
+// RUN: %check_clang_tidy %s misc-no-side-effects %t
+#include 
+
+class derivedVector: public std::vector {};
+class customVector { public: bool empty() { return false; } };
+
+int main() {
+
+  std::vector{}.empty();
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: method 'empty' has no side effects and its return value is not used [misc-no-side-effects]
+  derivedVector{}.empty();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: method 'empty' has no side effects and its return value is not used [misc-no-side-effects]
+
+  // A future version of this checker might catch this one either by
+  // determining that the method has no side effects or by an annotation, but
+  // the current one should not.
+  customVector{}.empty();
+}
Index: docs/clang-tidy/checks/misc-no-side-effects.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-no-side-effects.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - misc-no-side-effects
+
+misc-no-side-effects
+
+
+Warn when specific methods without side effects (e.g. ``v.empty()``) are called
+and the return value ignored: the programmer might think that it does have side
+effects (e.g. emptying the container).
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -56,6 +56,7 @@
misc-misplaced-widening-cast
misc-move-constructor-init
misc-new-delete-overloads
+   misc-no-side-effects
misc-noexcept-move-constructor
misc-non-copyable-objects
misc-sizeof-container
Index: clang-tidy/misc/NoSideEffectsCheck.h
===
--- /dev/null
+++ clang-tidy/misc/NoSideEffectsCheck.h
@@ -0,0 +1,37 @@
+//===--- NoSideEffectsCheck.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_MISC_NO_SIDE_EFFECTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NO_SIDE_EFFECTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds calls of side-effect-free methods on STL containers that ignore
+/// the return value. This could catch mistakes like using .empty() to
+/// (try to) empty a container.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-no-side-effects.html
+class NoSideEffectsCheck : public ClangTidyCheck {
+public:
+  NoSideEffectsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NO_SIDE_EFFECTS_H
Index: clang-tidy/misc/NoSideEffectsCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/NoSideEffectsCheck.cpp
@@ -0,0 +1,120 @@
+//===--- NoSideEffectsCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===-

Re: [PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-10 Thread Cong Liu via cfe-commits
congliu added a comment.

The strategy has changed. Now this check does not ignore template in 
instantiation, instead, it generate a single warning for some instantiation and 
ignore others, so that fix is able to apply.
We do this to walk around the function copied from ASTMatchFinder, since it's 
incorrect for some tricky situation. And make sense to analyse overriding only 
when there is fully instantiation of the primary template.


http://reviews.llvm.org/D16922



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


Re: [clang-tools-extra] r260225 - [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will work on various bots

2016-02-10 Thread Alexander Kornienko via cfe-commits
On Wed, Feb 10, 2016 at 1:15 PM, Daniel Marjamäki <
daniel.marjam...@evidente.se> wrote:

>
> Hello!
>
> That would make some sense to me.
>
> To catch portability issues users could use different relevant targets. Do
> you know if some do that?
>

They could, but I'm not sure it's a widespread practice to run analysis
tools for multiple targets. It's less convenient, requires more resources
and something one has specifically set up their development process for. So
I think, if this diagnostic could consider a conversion from "int" to
"long" (as well as short->int, long->long long, etc.) always a widening
conversion and vice versa, it might be useful. I don't know whether it will
significantly increase the number of false positives though, but we could
try. What do you think?



>
> Best regards,
> Daniel Marjamäki
>
>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: daniel.marjam...@evidente.se
>
> www.evidente.se
>
> 
> Från: Alexander Kornienko [ale...@google.com]
> Skickat: den 10 februari 2016 12:23
> Till: Daniel Marjamäki
> Kopia: cfe-commits
> Ämne: Re: SV: [clang-tools-extra] r260225 - [clang-tidy] Add -target in
> misc-misplaced-widening-cast test so it will work on various bots
>
> Makes sense. I wonder though whether the check should attempt to be
> platform-independent and warn regardless of whether int and long have the
> same bit width. What do you think?
>
> On Feb 10, 2016 9:35 AM, "Daniel Marjamäki"  > wrote:
>
> Hello!
>
> > I'm not sure this is a good fix. What was the specific issue (and on
> which buildbots)?
>
> Ok.
>
> The buildbots said:
>
> FileCheck error:
> '/home/linaro/buildbot/clang-cmake-thumbv7-a15/stage1/tools/clang/tools/extra/test/clang-tidy/Output/misc-misplaced-widening-cast.cpp.tmp.cpp.msg'
> is empty.
>
> My check only warns when there is a widening cast. If
> sizeof(int)==sizeof(long) then there is no warning for a int=>long
> conversion. In my testcases I tested various int=>long conversions.
>
> These are the failed builds:
>
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/187
> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/6265
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9641
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/9691
>
> Best regards,
> Daniel Marjamäki
>
>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> 
> E-mail: daniel.marjam...@evidente.se daniel.marjam...@evidente.se>
>
> www.evidente.se
>
> 
> Från: Alexander Kornienko [ale...@google.com]
> Skickat: den 9 februari 2016 17:41
> Till: Daniel Marjamäki
> Kopia: cfe-commits
> Ämne: Re: [clang-tools-extra] r260225 - [clang-tidy] Add -target in
> misc-misplaced-widening-cast test so it will work on various bots
>
> I'm not sure this is a good fix. What was the specific issue (and on which
> buildbots)?
>
> On Tue, Feb 9, 2016 at 4:43 PM, Daniel Marjamaki via cfe-commits <
> cfe-commits@lists.llvm.org cfe-commits@lists.llvm.org>> wrote:
> Author: danielmarjamaki
> Date: Tue Feb  9 09:43:05 2016
> New Revision: 260225
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260225&view=rev
> Log:
> [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will
> work on various bots
>
> Modified:
>
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp?rev=260225&r1=260224&r2=260225&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> (original)
> +++
> clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast.cpp
> Tue Feb  9 09:43:05 2016
> @@ -1,4 +1,4 @@
> -// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t
> +// RUN: %check_clang_tidy %s misc-misplaced-widening-cast %t -- --
> -target x86_64-unknown-unknown
>
>  void assign(int a, int b) {
>long l;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org cfe-commits@lists.llvm.org

[PATCH] D17072: Return immediatedly if Method is null, otherwise you'll get a crash when dyn_cast is called with a nullptr

2016-02-10 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added reviewers: doug.gregor, rnk.
hintonda added a subscriber: cfe-commits.

Fixes crash referenced in PR25181 where dyn_cast is called on a null instance 
of LM.Method.

http://reviews.llvm.org/D17072

Files:
  lib/Parse/ParseCXXInlineMethods.cpp

Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,7 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if(!LM.Method) return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);


Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,7 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if(!LM.Method) return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

> The strategy has changed. Now this check does not ignore template in 
> instantiation, instead, it generate a 

>  single warning for some instantiation and ignore others, so that fix is able 
> to apply.


I'm not sure this is the right thing to do, since there might be a case when 
the presence of the pattern we consider a bug depends on the instantiation:

  struct A {
virtual void func() = 0;
  };
  struct B {
virtual void funk();
  };
  template
  struct D : public T {
virtual void func() {...}
  };
  void f() {
A *da = new D;
da->func();
B *db = new D; // If the check applies a fix issued when inspecting this 
instantiation, it will break the code on the previous line.
  }

We still might want to warn in this case though.



Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:253
@@ +252,3 @@
+SourceLocation Loc = DerivedMD->getLocStart();
+if (WarningSet.find(Loc.getRawEncoding()) != WarningSet.end())
+  continue;

This should be done using a single lookup:

  if (!WarningSet.insert(Loc).second)
continue;


Comment at: clang-tidy/misc/VirtualNearMissCheck.h:49
@@ -48,3 +48,3 @@
 
-  /// key: the unique ID of a method;
+  /// key: the unique ID of a method
   /// value: whether the method is possible to be overridden.

The "unique ID of a method" would better be described as a "pointer to the 
method definition" or "pointer to the canonical declaration of the method" 
depending on what is actually used as a key.

Also, please use proper capitalization and punctuation ("Key", and the trailing 
period).


Comment at: clang-tidy/misc/VirtualNearMissCheck.h:59
@@ -58,1 +58,3 @@
 
+  /// key: the source location id of a generated warning
+  std::unordered_set WarningSet;

Please use proper capitalization and punctuation. Also, I'd just say that we 
keep source locations of issued warnings to avoid duplicate warnings caused by 
multiple instantiations.


Comment at: clang-tidy/misc/VirtualNearMissCheck.h:60
@@ +59,3 @@
+  /// key: the source location id of a generated warning
+  std::unordered_set WarningSet;
+

You don't need to `getRawEncoding`. This can be a `std::set` or 
even better a `llvm::SmallPtrSet`, for example.


http://reviews.llvm.org/D16922



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


Re: [PATCH] D16535: [clang-tidy] Check to find unintended semicolons that changes the semantics.

2016-02-10 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thanks!

Could you run the check on LLVM and post here a summary of results: how many 
warnings are generated, whether there are any false positives (based on a 
reasonably-sized random sample, if there are too many warnings to inspect all 
relevant code), etc.


http://reviews.llvm.org/D16535



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


Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-10 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/unroll-hint-cl20.cl:1
@@ +1,2 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+

Could we just combine this with test/SemaOpenCL/unroll-hint.cl.

You can have two RUN lines and pass something like -DCL20 in one of them (for 
CL2.0). It will then allow you to #ifdef the CL2.0 code. You can see the 
example in:

  test/Parser/opencl-atomics-cl20.cl


http://reviews.llvm.org/D16686



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


Re: [PATCH] D17069: [clang-tidy] Fix an assert failure in 'readability-braces-around-statements' check.

2016-02-10 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good with one possible improvement. Thank you!



Comment at: clang-tidy/readability/BracesAroundStatementsCheck.cpp:181
@@ +180,3 @@
+  // IfStmt. Avoid triggering assert failure.
+  if (isa(S->getCond()))
+return SourceLocation();

Maybe just replace the assertion with

  if (!CondEndLoc.isValid())
return SourceLocation();

?


Repository:
  rL LLVM

http://reviews.llvm.org/D17069



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


Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers

2016-02-10 Thread Alexander Kornienko via cfe-commits
On Wed, Feb 10, 2016 at 7:19 AM, Richard via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> [Please reply *only* to the list and do not include my email directly
> in the To: or Cc: of your reply; otherwise I will not see your reply.
> Thanks.]
>
> In article ,
> Richard via cfe-commits  writes:
>
> > make check-all passes for me.  I don't see what the problem is in the
> logs
> > either.
>
> OK, I found the problem.  Once again, StringRef bites me on the behind.
>
> I have updated the review in phabricator with the corrected code.
> (The review was closed, so apparently it didn't post to the list
> when I updated it on phabricator?)
>
> I surmised that the buildbots do a release build and when I did
> check-clang-tools in release, I was able to reproduce the failure.
> clang-tidy seg-faults.
>

An effective way to detect this kind of an error early in the process is to
enable ASan in your build (cmake -DLLVM_USE_SANITIZER=Address ...). It
might make sense to enable UBSan as well
(-DLLVM_USE_SANITIZER=Address;Undefined).


>
> It would be nice if we could get the build log output to record that
> fact in the log.  I suspect it is the way that clang-tidy is invoked
> by the check_clang_tidy.py python script.  Somehow the offending SEGV
> message is suppressed.
>

Yeah, that's very unfortunate. I didn't find a way to make the script
output this (or similar) message.


> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>  The Computer Graphics Museum 
>  The Terminals Wiki 
>   Legalize Adulthood! (my blog) 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17072: Return immediatedly if Method is null, otherwise you'll get a crash when dyn_cast is called with a nullptr

2016-02-10 Thread David Majnemer via cfe-commits
This needs a testcase added to the tests directory.

On Wednesday, February 10, 2016, don hinton via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hintonda created this revision.
> hintonda added reviewers: doug.gregor, rnk.
> hintonda added a subscriber: cfe-commits.
>
> Fixes crash referenced in PR25181 where dyn_cast is called on a null
> instance of LM.Method.
>
> http://reviews.llvm.org/D17072
>
> Files:
>   lib/Parse/ParseCXXInlineMethods.cpp
>
> Index: lib/Parse/ParseCXXInlineMethods.cpp
> ===
> --- lib/Parse/ParseCXXInlineMethods.cpp
> +++ lib/Parse/ParseCXXInlineMethods.cpp
> @@ -293,6 +293,7 @@
>  }
>
>  void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM)
> {
> +  if(!LM.Method) return;


Please format this line with clang-format.


>// If this is a member template, introduce the template parameter scope.
>ParseScope TemplateScope(this, Scope::TemplateParamScope,
> LM.TemplateScope);
>TemplateParameterDepthRAII
> CurTemplateDepthTracker(TemplateParameterDepth);
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16040: [OpenCL] Refine OpenCLImageAccessAttr to OpenCLAccessAttr

2016-02-10 Thread Xiuli PAN via cfe-commits
pxli168 updated this revision to Diff 47455.
pxli168 marked 5 inline comments as done.

http://reviews.llvm.org/D16040

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenFunction.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/Parser/opencl-image-access.cl
  test/SemaOpenCL/invalid-access-qualifier.cl
  test/SemaOpenCL/invalid-kernel-attrs.cl

Index: test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- test/SemaOpenCL/invalid-kernel-attrs.cl
+++ test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -28,8 +28,8 @@
 
 void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
   int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
-  read_only int i; // expected-error {{'read_only' attribute only applies to parameters}}
-  __write_only int j; // expected-error {{'__write_only' attribute only applies to parameters}}
+  read_only image1d_t i; // expected-error {{'read_only' attribute only applies to parameters}}
+  __write_only image2d_t j; // expected-error {{'__write_only' attribute only applies to parameters}}
 }
 
 kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
Index: test/SemaOpenCL/invalid-access-qualifier.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-access-qualifier.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -cl-std=CL2.0 -DCL20 %s
+
+void test1(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}}
+
+void test2(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+void test3(read_only read_only image1d_t i){} // expected-error{{multiple access qualifiers}}
+
+#ifdef CL20
+void test4(read_write pipe int i){} // expected-error{{access qualifier read_write can not be used for 'pipe'}}
+#else
+void test4(read_write image1d_t i){} // expected-error{{access qualifier read_write can not be used for 'image1d_t' earlier than OpenCL2.0 version}}
+#endif
Index: test/Parser/opencl-image-access.cl
===
--- test/Parser/opencl-image-access.cl
+++ test/Parser/opencl-image-access.cl
@@ -1,14 +1,19 @@
-// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify -cl-std=CL2.0 -DCL20 
+// expected-no-diagnostics
 
 __kernel void f__ro(__read_only image2d_t a) { }
 
 __kernel void f__wo(__write_only image2d_t a) { }
 
+#if CL20
 __kernel void f__rw(__read_write image2d_t a) { }
-
+#endif
 
 __kernel void fro(read_only image2d_t a) { }
 
 __kernel void fwo(write_only image2d_t a) { }
 
+#if CL20
 __kernel void frw(read_write image2d_t a) { }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -6225,6 +6225,17 @@
   CurType = S.Context.getVectorType(CurType, numElts, VecKind);
 }
 
+/// Handle OpenCL Access Qualifier Attribute
+static void HandleOpenCLAccessAttr(QualType &CurType, const AttributeList &Attr,
+   Sema &S) {
+  // OpenCL v2.0 s6.6 - Access qualifier can used only for image and pipe type
+  if (!(CurType->isImageType() || CurType->isPipeType())) {
+S.Diag(Attr.getLoc(), diag::err_opencl_invalid_access_qualifier);
+Attr.setInvalid();
+return;
+  }
+}
+
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
  TypeAttrLocation TAL, AttributeList *attrs) {
   // Scan through and apply attributes to this type where it makes sense.  Some
@@ -6320,9 +6331,8 @@
VectorType::NeonPolyVector);
   attr.setUsedAsTypeAttr();
   break;
-case AttributeList::AT_OpenCLImageAccess:
-  // FIXME: there should be some type checking happening here, I would
-  // imagine, but the original handler's checking was entirely superfluous.
+case AttributeList::AT_OpenCLAccess:
+  HandleOpenCLAccessAttr(type, attr, state.getSema());
   attr.setUsedAsTypeAttr();
   break;
 
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5042,6 +5042,40 @@
   return false;
 }
 
+static void handleOpenCLAccessAttr(Sema &S, Decl *D,
+   const AttributeList &Attr) {
+  if (D->isInvalidDecl())
+return;
+
+  // Check if there is only one access qualifier
+  if (D->hasAttr()) {
+S.Diag(D->getLocation(), diag::err_opencl_multiple_access_qualifiers)
+<< D->getSourceRange();
+D->setInvalidDecl(true);
+ret

Re: [PATCH] D17072: Return immediatedly if Method is null, otherwise you'll get a crash when dyn_cast is called with a nullptr

2016-02-10 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 47456.
hintonda added a comment.

- Reformatted change with clang-format


http://reviews.llvm.org/D17072

Files:
  lib/Parse/ParseCXXInlineMethods.cpp

Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,8 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if (!LM.Method)
+return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);


Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,8 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if (!LM.Method)
+return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-02-10 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: lib/Sema/SemaExpr.cpp:1169
@@ +1168,3 @@
+  if (LHSElemType == S.Context.Float128Ty &&
+  RHSElemType == S.Context.LongDoubleTy)
+return true;

nemanjai wrote:
> hubert.reinterpretcast wrote:
> > I do not believe that the width of `long double` is sufficiently 
> > established to be the same as that of `__float128` in this context.
> This would certainly cause any attempts to convert between some different 
> implementation of **`long double` **(i.e. the Intel 80-bit type). I believe 
> that this behaviour is desired in all cases where **`long double`** and 
> **`double`** have a different representation. Namely, we do not currently 
> have any support for converting between **`fp128`** and anything that has 
> precision >= **`double`** that is not actually **`double`**.
> 
> What I propose to do here and in other locations where we diagnose 
> conversions between the two types is that the check is:
> - One type is `__float128`
> - The other is `long double`
> - The representation of `long double` is not `llvm::APFloat::IEEEdouble`
> 
> Basically in this function, the early exit path would be:
> - representations are the same or
> - representation of `long double` is `llvm::APFloat::IEEEdouble`
This really sounds like a property of the target. The situation described in 
D15120#inline-141210 is similar.

I would not want to do a virtual function call without early exits here. So, 
perhaps the `TargetInfo` should be queried only at the point where we would 
otherwise return `true`.

I can't say that I like the name of this function now. Perhaps 
`unsupportedTypeConversion`?


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


Re: [PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for working on this check!

I'd like to note that there is a library-side way to mitigate this issue using 
the `[[clang::warn_unused_result]]` attribute on `vector::empty()` and similar 
methods:

  $ cat q.cc
  #if defined(__clang__)
  # if __cplusplus >= 201103L && __has_feature(cxx_attributes)
  #  define CLANG_WARN_UNUSED_RESULT [[clang::warn_unused_result]]
  # else
  #  define CLANG_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  # endif
  #else
  # define CLANG_WARN_UNUSED_RESULT
  #endif
  
  struct Vector {
CLANG_WARN_UNUSED_RESULT bool empty() const;
  };
  
  void f() {
Vector v;
v.empty();
  }
  $ clang_check q.cc -- -std=c++11
  q.cc:17:3: warning: ignoring return value of function declared with 
warn_unused_result attribute [-Wunused-result]
v.empty();
^~~
  1 warning generated.

It would be super-awesome, if someone could add appropriate annotations to all 
methods without side effects in libc++ ;)



Comment at: clang-tidy/misc/NoSideEffectsCheck.cpp:42
@@ +41,3 @@
+
+  std::string QualName;
+  llvm::raw_string_ostream OS{QualName};

I think, there's a slightly more effective way of doing this in 
clang-tidy/readability/ContainerSizeEmptyCheck.cpp. Also, Samuel is working on 
a hasAnyName matcher that would allow checking whether a declaration name is 
one of the declaration names in a list.


Comment at: clang-tidy/misc/NoSideEffectsCheck.cpp:52
@@ +51,3 @@
+AST_MATCHER(CXXMethodDecl, isAPurelyInformationalMethod) {
+  static const std::unordered_set whitelist{
+"get_allocator",

Can we assume that all const methods shouldn't be called without using their 
result? This will make this list much shorter.


Comment at: clang-tidy/misc/NoSideEffectsCheck.cpp:113
@@ +112,3 @@
+
+  diag(Call->getCallee()->getExprLoc(), "method '%0' has no side effects and 
its return value is not used")
+<< Call->getMethodDecl()->getName()

The line violates 80-columns limit. There are other formatting issues as well, 
so I suggest just running clang-format on the file.


Comment at: docs/clang-tidy/checks/list.rst:59
@@ -58,2 +58,3 @@
misc-new-delete-overloads
+   misc-no-side-effects
misc-noexcept-move-constructor

Maybe "misc-unused-result" (like a similar -Wunused-result warning that can be 
used for the same purpose, if the methods are properly annotated)?


Comment at: test/clang-tidy/misc-no-side-effects.cpp:2
@@ +1,3 @@
+// RUN: %check_clang_tidy %s misc-no-side-effects %t
+#include 
+

We don't use actual library headers in tests for multiple reasons (longer 
testing times, changing the system library can break tests, we can't test 
different libraries that way, some testing setups don't support this, etc.). 
Instead, we use stubs that model the part of the API required for testing.


http://reviews.llvm.org/D17043



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


[PATCH] D17075: [AST] Added SubstTemplateTypeParm, DependentNameType, DependentSizedArrayType import functions in the ASTImporter.

2016-02-10 Thread Elisavet Sakellari via cfe-commits
esakella created this revision.
esakella added reviewers: klimek, bkramer, rsmith, spyffe.
esakella added subscribers: karies, cfe-commits.
Herald added subscribers: rengolin, aemerson.

Implemented the 

VisitSubstTemplateTypeParmType
VisitDependentNameType
VisitDependentSizedArrayType 

functions in the ASTImporter class and also added the necessary tests. 

Also made a necessary change in the VisitFunctionDecl function to support the 
dependent name type parameters. 

http://reviews.llvm.org/D17075

Files:
  lib/AST/ASTImporter.cpp
  test/ASTMerge/Inputs/class-template1.cpp
  test/ASTMerge/Inputs/class-template2.cpp

Index: test/ASTMerge/Inputs/class-template2.cpp
===
--- test/ASTMerge/Inputs/class-template2.cpp
+++ test/ASTMerge/Inputs/class-template2.cpp
@@ -33,3 +33,30 @@
 struct X0 {
   float member;
 };
+
+//Substituted template type parameter import test
+template
+struct X7 {
+  T t;
+};
+
+X7 x;
+
+//Dependent name type import test
+struct X9 {
+ struct X10 { };
+};
+
+template
+struct X8 {
+  struct T::X10* t;
+  void f(struct T::X10* v){ }
+};
+
+X8 x8;
+
+//Dependent sized array import test
+template
+struct X11 {
+  T data[S];
+};
Index: test/ASTMerge/Inputs/class-template1.cpp
===
--- test/ASTMerge/Inputs/class-template1.cpp
+++ test/ASTMerge/Inputs/class-template1.cpp
@@ -32,3 +32,30 @@
 struct X0 {
   int member;
 };
+
+//Substituted template type parameter import test
+template
+struct X7 {
+  T t;
+};
+
+extern X7 x;
+
+//Dependent name type import test
+struct X9 {
+ struct X10 { };
+};
+
+template
+struct X8 {
+  struct T::X10* t;
+  void f(struct T::X10* v){ }
+};
+
+extern X8 x8;
+
+//Dependent sized array import test
+template
+struct X11 {
+  T data[S];
+};
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -49,7 +49,7 @@
 QualType VisitConstantArrayType(const ConstantArrayType *T);
 QualType VisitIncompleteArrayType(const IncompleteArrayType *T);
 QualType VisitVariableArrayType(const VariableArrayType *T);
-// FIXME: DependentSizedArrayType
+QualType VisitDependentSizedArrayType(const DependentSizedArrayType *T);
 // FIXME: DependentSizedExtVectorType
 QualType VisitVectorType(const VectorType *T);
 QualType VisitExtVectorType(const ExtVectorType *T);
@@ -69,10 +69,10 @@
 QualType VisitEnumType(const EnumType *T);
 QualType VisitAttributedType(const AttributedType *T);
 // FIXME: TemplateTypeParmType
-// FIXME: SubstTemplateTypeParmType
+QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T);
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
-// FIXME: DependentNameType
+QualType VisitDependentNameType(const DependentNameType *T);
 // FIXME: DependentTemplateSpecializationType
 QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
 QualType VisitObjCObjectType(const ObjCObjectType *T);
@@ -1613,6 +1613,19 @@
   Brackets);
 }
 
+QualType ASTNodeImporter::VisitDependentSizedArrayType(
+   const DependentSizedArrayType *T) {
+  QualType ToType = Importer.Import(T->getElementType());
+  if (ToType.isNull())
+return QualType();
+
+  return
+Importer.getToContext().getDependentSizedArrayType(ToType, T->getSizeExpr(),
+   T->getSizeModifier(),
+T->getIndexTypeCVRQualifiers(),
+   T->getBracketsRange());
+}
+
 QualType ASTNodeImporter::VisitVectorType(const VectorType *T) {
   QualType ToElementType = Importer.Import(T->getElementType());
   if (ToElementType.isNull())
@@ -1776,6 +1789,18 @@
   return Importer.getToContext().getTagDeclType(ToDecl);
 }
 
+QualType ASTNodeImporter::VisitSubstTemplateTypeParmType(
+  const SubstTemplateTypeParmType *T) {
+
+  QualType ToType =  Importer.Import(T->getReplacementType());
+  if (ToType.isNull())
+return QualType();
+
+  return Importer.getToContext().getSubstTemplateTypeParmType(
+ T->getReplacedParameter(),
+ T->getReplacementType());
+}
+
 QualType ASTNodeImporter::VisitAttributedType(const AttributedType *T) {
   QualType FromModifiedType = T->getModifiedType();
   QualType FromEquivalentType = T->getEquivalentType();
@@ -1838,6 +1863,21 @@
ToQualifier, ToNamedType);
 }
 
+QualType ASTNodeImporter::VisitDependentNameType(const DependentNameType *T) {
+  NestedNameSpecifier *T

Re: [PATCH] D16686: [OpenCL] Generate metadata for opencl_unroll_hint attribute

2016-02-10 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 47460.
yaxunl added a comment.

merge two sema tests as one as Anastasia suggested.


http://reviews.llvm.org/D16686

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/CodeGen/CGLoopInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaStmtAttr.cpp
  test/CodeGenOpenCL/unroll-hint.cl
  test/Parser/opencl-unroll-hint.cl
  test/SemaOpenCL/unroll-hint.cl

Index: test/SemaOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/SemaOpenCL/unroll-hint.cl
@@ -0,0 +1,30 @@
+//RUN: %clang_cc1 -O0 -fsyntax-only -verify %s
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify -DCL20 %s
+
+kernel void D (global int *x) {
+  int i = 10;
+#ifndef CL20
+  // expected-error@+2 {{'opencl_unroll_hint' attribute requires OpenCL version 2.0 or above}}
+#endif
+  __attribute__((opencl_unroll_hint))
+  do {
+  } while(i--);
+}
+
+#ifdef CL20
+kernel void C (global int *x) {
+  int I = 3;
+  __attribute__((opencl_unroll_hint(I))) // expected-error {{'opencl_unroll_hint' attribute requires an integer constant}}
+  while (I--);
+}
+
+kernel void E() {
+  __attribute__((opencl_unroll_hint(2,4))) // expected-error {{'opencl_unroll_hint' attribute takes no more than 1 argument}}
+  for(int i=0; i<100; i++);
+}
+
+kernel void F() {
+  __attribute__((opencl_unroll_hint(-1))) // expected-error {{'opencl_unroll_hint' attribute requires a positive integral compile time constant expression}}
+  for(int i=0; i<100; i++);
+}
+#endif
Index: test/Parser/opencl-unroll-hint.cl
===
--- /dev/null
+++ test/Parser/opencl-unroll-hint.cl
@@ -0,0 +1,8 @@
+//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
+
+kernel void B (global int *x) {
+  __attribute__((opencl_unroll_hint(42)))
+  if (x[0]) // expected-error {{OpenCL only supports 'opencl_unroll_hint' attribute on for, while, and do statements}}
+x[0] = 15;
+}
+
Index: test/CodeGenOpenCL/unroll-hint.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/unroll-hint.cl
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s
+
+/*** for ***/
+void for_count()
+{
+// CHECK-LABEL: for_count
+__attribute__((opencl_unroll_hint(8)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_COUNT:.*]]
+}
+
+void for_disable()
+{
+// CHECK-LABEL: for_disable
+__attribute__((opencl_unroll_hint(1)))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_DISABLE:.*]]
+}
+
+void for_full()
+{
+// CHECK-LABEL: for_full
+__attribute__((opencl_unroll_hint))
+for( int i = 0; i < 1000; ++i);
+// CHECK: br label %{{.*}}, !llvm.loop ![[FOR_FULL:.*]]
+}
+
+/*** while ***/
+void while_count()
+{
+// CHECK-LABEL: while_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_COUNT:.*]]
+}
+
+void while_disable()
+{
+// CHECK-LABEL: while_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_DISABLE:.*]]
+}
+
+void while_full()
+{
+// CHECK-LABEL: while_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+while(i-->0);
+// CHECK: br label %{{.*}}, !llvm.loop ![[WHILE_FULL:.*]]
+}
+
+/*** do ***/
+void do_count()
+{
+// CHECK-LABEL: do_count
+int i = 1000;
+__attribute__((opencl_unroll_hint(8)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_COUNT:.*]]
+}
+
+void do_disable()
+{
+// CHECK-LABEL: do_disable
+int i = 1000;
+__attribute__((opencl_unroll_hint(1)))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_DISABLE:.*]]
+}
+
+void do_full()
+{
+// CHECK-LABEL: do_full
+int i = 1000;
+__attribute__((opencl_unroll_hint))
+do {} while(i--> 0);
+// CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !llvm.loop ![[DO_FULL:.*]]
+}
+
+
+// CHECK: ![[FOR_COUNT]] =  distinct !{![[FOR_COUNT]],  ![[COUNT:.*]]}
+// CHECK: ![[COUNT]] =  !{!"llvm.loop.unroll.count", i32 8}
+// CHECK: ![[FOR_DISABLE]]   =  distinct !{![[FOR_DISABLE]],  ![[DISABLE:.*]]}
+// CHECK: ![[DISABLE]]   =  !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[FOR_FULL]]  =  distinct !{![[FOR_FULL]],  ![[FULL:.*]]}
+// CHECK: ![[FULL]]  =  !{!"llvm.loop.unroll.full"}
+// CHECK: ![[WHILE_COUNT]]   =  distinct !{![[WHILE_COUNT]],![[COUNT]]}
+// CHECK: ![[WHILE_DISABLE]] =  distinct !{![[WHILE_DISABLE]],  ![[DISABLE]]}
+// CHECK: ![[WHILE_FULL]]=  distinct !{![[WHILE_FULL]], ![[FULL]]}
+// CHECK: ![[DO_COUN

Re: [PATCH] D16922: [clang-tidy] Added check-fixes for misc-virtual-near-miss.

2016-02-10 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 47461.
congliu marked 3 inline comments as done.
congliu added a comment.

- Allowed warnings but disallowed fix for template instantiations.
- Updated tests.


http://reviews.llvm.org/D16922

Files:
  clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tidy/misc/VirtualNearMissCheck.h
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- test/clang-tidy/misc-virtual-near-miss.cpp
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -16,22 +16,58 @@
   // overriden by this class.
   virtual void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::funk' has a similar name and the same signature as virtual method 'Base::func'; did you mean to override it? [misc-virtual-near-miss]
+  // CHECK-FIXES: virtual void func();
 
   void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::func2' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   void func22(); // Should not warn.
 
   void gunk(); // Should not warn: gunk is override.
 
   void fun();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Derived::fun' has {{.*}} 'Base::func'
+  // CHECK-FIXES: void func();
 
   Derived &operator==(const Base &); // Should not warn: operators are ignored.
 
   virtual NoDefinedClass2 *f1(); // Should not crash: non-defined class return type is ignored.
 };
 
+template 
+struct TBase {
+  virtual void tfunc(T t);
+};
+
+template 
+struct TDerived : TBase {
+  virtual void tfunk(T t);
+  // Should not apply fix for template.
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: method 'TDerived::tfunk' has {{.*}} 'TBase::tfunc'
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: method 'TDerived::tfunk' has {{.*}} 'TBase::tfunc'
+  // CHECK-FIXES: virtual void tfunk(T t);
+};
+
+TDerived T1;
+TDerived T2;
+
+// Should not fix macro definition
+#define MACRO1 void funcM()
+// CHECK-FIXES: #define MACRO1 void funcM()
+#define MACRO2(m) void m()
+// CHECK-FIXES: #define MACRO2(m) void m()
+
+struct DerivedMacro : Base {
+  MACRO1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::funcM' has {{.*}} 'Base::func'
+  // CHECK-FIXES: MACRO1;
+
+  MACRO2(func3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'DerivedMacro::func3' has {{.*}} 'Base::func'
+  // CHECK-FIXES: MACRO2(func);
+};
+
 typedef Derived derived_type;
 
 class Father {
@@ -58,32 +94,40 @@
 
   virtual void func2();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::func2' has {{.*}} 'Father::func'
+  // CHECK-FIXES: virtual void func();
 
   int methoe(int x, char **strs); // Should not warn: parameter types don't match.
 
   int methoe(int x);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoe' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x);
 
   void methof(int x, const char **strs); // Should not warn: return types don't match.
 
   int methoh(int x, const char **strs);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::methoh' has {{.*}} 'Mother::method'
+  // CHECK-FIXES: int method(int x, const char **strs);
 
   virtual Child *creat(int i);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::creat' has {{.*}} 'Father::create'
+  // CHECK-FIXES: virtual Child *create(int i);
 
   virtual Derived &&generat();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::generat' has {{.*}} 'Father::generate'
+  // CHECK-FIXES: virtual Derived &&generate();
 
   int decaz(const char str[]);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay'
+  // CHECK-FIXES: int decay(const char str[]);
 
   operator bool();
 
   derived_type *canonica(derived_type D);
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::canonica' has {{.*}} 'Father::canonical'
+  // CHECK-FIXES: derived_type *canonical(derived_type D);
 
 private:
   void funk();
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func'
+  // CHECK-FIXES: void func();
 };
Index: clang-tidy/misc/VirtualNearMissCheck.h
===
--- clang-tidy/misc/VirtualNearMissCheck.h
+++ clang-tidy/misc/VirtualNearMissCheck.h
@@ -12,7 +12,6 @@
 
 #include "../ClangTidy.h"
 #include 
-#include 
 
 namespace clang {
 namespace tidy {
@@ -46,12 +45,12 @@
   bool isOverriddenByDerivedClass(const CXXMethodDecl *BaseMD,
   const CXXRecordDecl *DerivedRD);
 
-  /// key: the unique ID of a method;
-  /// value: whether the method is possible to be overridden.
+  /// Key: the unique ID of a method.
+  /// Value: whether the method is possible to be overridden.
   std::map PossibleMap;
 
-  /// key: 
-  /// value: whether the base method is overridden by some method in the derived
+  /// Key: 
+  /// Value: whether the base method is overridden by some method in the derived
 

[PATCH] D17076: [OPENMP] firstprivate clause for target

2016-02-10 Thread Carlo Bertolli via cfe-commits
carlo.bertolli created this revision.
carlo.bertolli added reviewers: ABataev, fraggamuffin, kkwli0.
carlo.bertolli added subscribers: sfantao, arpith-jacob, cfe-commits.
carlo.bertolli set the repository for this revision to rL LLVM.

Very simple but necessary extension to target directive with firstprivate 
clause from OpenMP 4.5

Repository:
  rL LLVM

http://reviews.llvm.org/D17076

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_firstprivate_messages.cpp

Index: test/OpenMP/target_firstprivate_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_firstprivate_messages.cpp
@@ -0,0 +1,196 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+};
+const S3 ca[5];
+class S4 {
+  int a;
+  S4();
+
+public:
+  S4(int v) : a(v) {
+#pragma omp target firstprivate(a) firstprivate(this->a)
+for (int k = 0; k < v; ++k)
+  ++this->a;
+  }
+};
+class S5 {
+  int a;
+  S5() : a(0) {}
+
+public:
+  S5(int v) : a(v) {}
+  S5 &operator=(S5 &s) {
+#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}
+for (int k = 0; k < s.a; ++k)
+  ++s.a;
+return *this;
+  }
+};
+
+template 
+class S6 {
+public:
+  T a;
+
+  S6() : a(0) {}
+  S6(T v) : a(v) {
+#pragma omp target firstprivate(a) firstprivate(this->a)
+for (int k = 0; k < v; ++k)
+  ++this->a;
+  }
+  S6 &operator=(S6 &s) {
+#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}}
+for (int k = 0; k < s.a; ++k)
+  ++s.a;
+return *this;
+  }
+};
+
+template 
+class S7 : public T {
+  T a;
+  S7() : a(0) {}
+
+public:
+  S7(T v) : a(v) {
+#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(T::a)
+for (int k = 0; k < a.a; ++k)
+  ++this->a.a;
+  }
+  S7 &operator=(S7 &s) {
+#pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) firstprivate(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
+for (int k = 0; k < s.a.a; ++k)
+  ++s.a.a;
+return *this;
+  }
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+
+template 
+int foomain(I argc, C **argv) {
+  I e(4);
+  I g(5);
+  int i;
+  int &j = i;
+#pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+{}
+#pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
+#pragma omp target firstprivate() // expected-error {{expected expression}}
+{}
+#pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
+#pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
+#pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+{}
+#pragma omp target firstprivate(argc)
+{}
+#pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
+{}
+#pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+{}
+#pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}}
+{}
+#pragma omp target firstprivate(e, g)
+{}
+#pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
+{}
+#pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
+#pragma omp parallel
+  {
+int v = 0;
+int i;
+  }
+#pragma omp parallel shared(i)
+#pragma omp parallel firstprivate(i)
+#pragma omp target firstprivate(j)
+{}
+#pragma omp target firstprivate(i)
+  {}
+  return 0;
+}
+
+void bar(S4 a[2]) {
+#pragma omp parallel
+#pragma omp target firstprivate(a)
+  {}
+}
+
+namespace A {
+double x;
+#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
+}
+namespace B {
+using A::x;
+}
+
+int main(int argc, char **argv) {
+  S4 e(4);
+  S5 g(5);
+  S6 s6(0.0) , s6_0(1.0);
+  S7 > s7(0.0) , s7_0(1.0);
+  int i;
+  int &j = i;
+#pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}}
+{}
+#pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
+#pragma omp target firstprivate() // expected-error {{expected expression}}
+{}
+#pragma omp target firstprivate(argc // expected-error {{ex

Re: [PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Sidney San Martín via cfe-commits
sidney added a comment.

In http://reviews.llvm.org/D17043#348525, @alexfh wrote:

> I'd like to note that there is a library-side way to mitigate this issue 
> using the `[[clang::warn_unused_result]]` attribute on `vector::empty()` and 
> similar methods:


Using an attribute sounds much better than this kind of check and I'd be fine 
with throwing this patch out completely. IMHO the diagnostic is bad, though. A 
message like this:

>   q.cc:17:3: warning: ignoring return value of function declared with 
> warn_unused_result attribute [-Wunused-result]

> v.empty();

> ^~~

> 


…is way too literal. It could indicate two completely different issues:

1. `empty()` just tells you whether the container is empty.
2. `empty()` has side effects and returns a value which should never be ignored 
(like recv, send, and scanf).

Searching for this warning (https://www.google.com/search?q="Wunused-result";) 
turns up tons of confusion.

I'm not an expert on attributes. Is there a way to attach metadata (like a 
subtype, or a string description), so that calls without side effects could 
have a diagnostic more like the one I wrote, and things like `recv(2)` and 
`scanf(3)` could have rich messages?

I'm going to hold of on addressing any of your other comments until I hear 
back. Thanks for the review!


http://reviews.llvm.org/D17043



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


Re: [PATCH] D16310: new clang-tidy checker misc-long-cast

2016-02-10 Thread Richard via cfe-commits

In article ,
Daniel Marjamäki  writes:

> > You can get overflow with / and %. Consider:
> >
> > int i = INT_MIN / -1; // similar for %
> 
> you are right, I did not think of that. 
> 
> imho overflow still seems unlikely for / and %.

I thought the whole point was to flag instances where the presence
of a cast indicated a suspicion of intent that wasn't being satisfied?

In other words, overflow may be unlikely but doesn't the presence of
the cast indicate the same suspicious intent?
-- 
"The Direct3D Graphics Pipeline" free book 
 The Computer Graphics Museum 
 The Terminals Wiki 
  Legalize Adulthood! (my blog) 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Need to use function "getAsCXXRecordDecl" of ASTMatchFinder.cpp in a clang-tidy check

2016-02-10 Thread Cong Liu via cfe-commits
Hi Richard,

You are right. Actually I just need to consider the cases that there are
full instantiations of the primary template. I have changed the strategy
and not use that function.

Thanks a lot!
Cong

On Wed, Feb 10, 2016 at 2:17 AM, Richard Smith 
wrote:

> On Tue, Feb 9, 2016 at 4:15 PM, Cong Liu  wrote:
> > Hi Richard,
> >
> > Thank you for your reply. Yes, the case I need to deal with is like what
> you
> > said:
> >>
> >> If you want to make the assumption that the primary template will be
> >> used for an unknown specialization, you'll need something like that
> >> function in ASTMatchFinder.
> >
> >
> > For example,
> >
> >   template 
> >   struct Base {};
> >   template 
> >   struct Derived : Base{};
> >
> >   Derived T1;
> >
> > In this case, I need to firstly get the CXXBaseSpecifier from line 4,
> then
> > get the QualType of primary template (Base), then get its declaration.
> > For this case, that function in ASTMatchFinder works but
> > Type::getAsCXXRecordDecl does not.
> >
> > So, what do you suggest?
>
> Using that may not be correct when analysing virtual function
> overrides. Consider this:
>
> template struct Base {
>   virtual void f(T);
> };
> template<> struct Base {
>   virtual void f();
> };
> template::value> struct Derived :
> Base {
>   virtual void f();
> };
> template struct Derived : Base {
>   virtual void f(T);
> };
>
> Here, it would be wrong to report that the Derived primary template
> fails to override a virtual function from the Base primary template,
> as the Derived primary template is actually only ever used when T ==
> void, and there's a specialization of the Base template for that case.
> I have no idea whether that's acceptable for your check.
>
> In principle, I'm fine with us moving the functionality in
> ASTMatchFinder (that I recently renamed to
> getAsCXXRecordDeclOrPrimaryTemplate to better express its purpose) to
> somewhere more central, but my concern is that most uses of it will in
> fact be subtle bugs.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260388 - [MS ABI] Never reference dllimport'd vtables

2016-02-10 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Wed Feb 10 11:40:47 2016
New Revision: 260388

URL: http://llvm.org/viewvc/llvm-project?rev=260388&view=rev
Log:
[MS ABI] Never reference dllimport'd vtables

Referencing a dllimported vtable is impossible in a constexpr
constructor.  It would be friendlier to C++ programmers if we
synthesized a copy of the vftable which referenced imported virtual
functions.  This would let us initialize the object in a way which
preserves both the intent to import functionality from another DLL while
also making constexpr work.

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

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=260388&r1=260387&r2=260388&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Feb 10 11:40:47 2016
@@ -2599,7 +2599,10 @@ void MicrosoftMangleContextImpl::mangleC
   // NOTE:  here is always 'B' (const). 
   // is always '6' for vftables.
   MicrosoftCXXNameMangler Mangler(*this, Out);
-  Mangler.getStream() << "\01??_7";
+  if (Derived->hasAttr())
+Mangler.getStream() << "\01??_S";
+  else
+Mangler.getStream() << "\01??_7";
   Mangler.mangleName(Derived);
   Mangler.getStream() << "6B"; // '6' for vftable, 'B' for const.
   for (const CXXRecordDecl *RD : BasePath)

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=260388&r1=260387&r2=260388&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Wed Feb 10 11:40:47 2016
@@ -2548,7 +2548,6 @@ public:
 // Only include the RTTI component if we know that we will provide a
 // definition of the vftable.
 HasRTTIComponent = Context.getLangOpts().RTTIData &&
-   !MostDerivedClass->hasAttr() &&
MostDerivedClass->getTemplateSpecializationKind() !=
TSK_ExplicitInstantiationDeclaration;
 

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=260388&r1=260387&r2=260388&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Feb 10 11:40:47 2016
@@ -1673,7 +1673,16 @@ llvm::GlobalVariable *MicrosoftCXXABI::g
   SmallString<256> VFTableName;
   mangleVFTableName(getMangleContext(), RD, VFPtr, VFTableName);
 
-  llvm::GlobalValue::LinkageTypes VFTableLinkage = CGM.getVTableLinkage(RD);
+  // Classes marked __declspec(dllimport) need vftables generated on the
+  // import-side in order to support features like constexpr.  No other
+  // translation unit relies on the emission of the local vftable, translation
+  // units are expected to generate them as needed.
+  //
+  // Because of this unique behavior, we maintain this logic here instead of
+  // getVTableLinkage.
+  llvm::GlobalValue::LinkageTypes VFTableLinkage =
+  RD->hasAttr() ? llvm::GlobalValue::LinkOnceODRLinkage
+   : CGM.getVTableLinkage(RD);
   bool VFTableComesFromAnotherTU =
   llvm::GlobalValue::isAvailableExternallyLinkage(VFTableLinkage) ||
   llvm::GlobalValue::isExternalLinkage(VFTableLinkage);
@@ -1746,9 +1755,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::g
   if (C)
 VTable->setComdat(C);
 
-  if (RD->hasAttr())
-VFTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
-  else if (RD->hasAttr())
+  if (RD->hasAttr())
 VFTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
 
   VFTablesMap[ID] = VFTable;

Modified: cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp?rev=260388&r1=260387&r2=260388&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp Wed Feb 10 11:40:47 2016
@@ -4,7 +4,8 @@
 struct __declspec(dllimport) S {
   virtual void f() {}
 } s;
-// MSVC-DAG: @"\01??_7S@@6B@" = available_externally dllimport
+// MSVC: [[VF_S:.*]] = private unnamed_addr constant [2 x i8*]
+// MSVC-DAG: @"\01??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds 
([2 x i8*], [2 x i8*]* [[VF_S]], i32 0, i32 1)
 // MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
 /

Re: [PATCH] D17061: [MS ABI] Never reference dllimport'd vtables

2016-02-10 Thread David Majnemer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260388: [MS ABI] Never reference dllimport'd vtables 
(authored by majnemer).

Changed prior to commit:
  http://reviews.llvm.org/D17061?vs=47407&id=47473#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17061

Files:
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/VTableBuilder.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
  cfe/trunk/test/CodeGenCXX/dllimport.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
===
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
@@ -4,8 +4,6 @@
 // RTTI-DAG: $"\01??_7S@@6B@" = comdat largest
 // RTTI-DAG: $"\01??_7V@@6B@" = comdat largest
 
-// RTTI-NOT: @"\01??_R4U@@6B@"
-
 struct S {
   virtual ~S();
 } s;
@@ -19,9 +17,10 @@
   virtual ~U();
 } u;
 
-// RTTI-DAG: @"\01??_7U@@6B@" = available_externally dllimport unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GU@@UAEPAXI@Z" to i8*)]
+// RTTI-DAG: [[VTABLE_U:@.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast ({{.*}} @"\01??_R4U@@6B@" to i8*), i8* bitcast ({{.*}} @"\01??_GU@@UAEPAXI@Z" to i8*)]
+// RTTI-DAG: @"\01??_SU@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* [[VTABLE_U]], i32 0, i32 1)
 
-// NO-RTTI-DAG: @"\01??_7U@@6B@" = available_externally dllimport unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GU@@UAEPAXI@Z" to i8*)]
+// NO-RTTI-DAG: @"\01??_SU@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GU@@UAEPAXI@Z" to i8*)]
 
 struct __declspec(dllexport) V {
   virtual ~V();
Index: cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
@@ -4,7 +4,8 @@
 struct __declspec(dllimport) S {
   virtual void f() {}
 } s;
-// MSVC-DAG: @"\01??_7S@@6B@" = available_externally dllimport
+// MSVC: [[VF_S:.*]] = private unnamed_addr constant [2 x i8*]
+// MSVC-DAG: @"\01??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* [[VF_S]], i32 0, i32 1)
 // MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R2S@@8" = linkonce_odr
Index: cfe/trunk/test/CodeGenCXX/dllimport.cpp
===
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp
@@ -614,7 +614,7 @@
 struct __declspec(dllimport) W { virtual void foo() {} };
 USECLASS(W)
 // vftable:
-// MO1-DAG: @"\01??_7W@@6B@" = available_externally dllimport unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
+// MO1-DAG: @"\01??_SW@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
 // GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)]
 
 struct __declspec(dllimport) KeyFuncClass {
Index: cfe/trunk/lib/AST/VTableBuilder.cpp
===
--- cfe/trunk/lib/AST/VTableBuilder.cpp
+++ cfe/trunk/lib/AST/VTableBuilder.cpp
@@ -2548,7 +2548,6 @@
 // Only include the RTTI component if we know that we will provide a
 // definition of the vftable.
 HasRTTIComponent = Context.getLangOpts().RTTIData &&
-   !MostDerivedClass->hasAttr() &&
MostDerivedClass->getTemplateSpecializationKind() !=
TSK_ExplicitInstantiationDeclaration;
 
Index: cfe/trunk/lib/AST/MicrosoftMangle.cpp
===
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp
@@ -2599,7 +2599,10 @@
   // NOTE:  here is always 'B' (const). 
   // is always '6' for vftables.
   MicrosoftCXXNameMangler Mangler(*this, Out);
-  Mangler.getStream() << "\01??_7";
+  if (Derived->hasAttr())
+Mangler.getStream() << "\01??_S";
+  else
+Mangler.getStream() << "\01??_7";
   Mangler.mangleName(Derived);
   Mangler.getStream() << "6B"; // '6' for vftable, 'B' for const.
   for (const CXXRecordDecl *RD : BasePath)
Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1673,7 +1673,16 @@
   SmallString<256> VFTableName;
   mangleVFTableName(getMangleContext(), RD, VFPtr, VFTableName);
 
-  llvm::GlobalValue::LinkageTypes VFTableLinkage = CGM.getVTableLinkage(RD);
+  // Class

Re: [PATCH] D16846: PR26449: Fixes for bugs in __builtin_classify_type implementation

2016-02-10 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 47475.
andreybokhanko added a comment.

John, thanks for the re-review! -- I did as you advised, and added *a lot* of 
switches. :-)

Patch updated; please re-review again.


http://reviews.llvm.org/D16846

Files:
  lib/AST/ExprConstant.cpp
  test/Sema/builtin-classify-type.c
  test/SemaCXX/builtin-classify-type.cpp

Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6185,7 +6185,8 @@
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static int EvaluateBuiltinClassifyType(const CallExpr *E) {
+static int EvaluateBuiltinClassifyType(const CallExpr *E,
+   const LangOptions &LangOpts) {
   // The following enum mimics the values returned by GCC.
   // FIXME: Does GCC differ between lvalue and rvalue references here?
   enum gcc_type_class {
@@ -6205,37 +6206,130 @@
   if (E->getNumArgs() == 0)
 return no_type_class;
 
-  QualType ArgTy = E->getArg(0)->getType();
-  if (ArgTy->isVoidType())
-return void_type_class;
-  else if (ArgTy->isEnumeralType())
-return enumeral_type_class;
-  else if (ArgTy->isBooleanType())
-return boolean_type_class;
-  else if (ArgTy->isCharType())
-return string_type_class; // gcc doesn't appear to use char_type_class
-  else if (ArgTy->isIntegerType())
-return integer_type_class;
-  else if (ArgTy->isPointerType())
+  QualType CanTy = E->getArg(0)->getType().getCanonicalType();
+  const BuiltinType *BT = dyn_cast(CanTy);
+
+  switch (CanTy->getTypeClass()) {
+#define TYPE(ID, BASE)
+#define DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_TYPE(ID, BASE) case Type::ID:
+#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(ID, BASE) case Type::ID:
+#include "clang/AST/TypeNodes.def"
+  break;
+
+  case Type::Builtin:
+switch (BT->getKind()) {
+#define BUILTIN_TYPE(ID, SINGLETON_ID)
+#define SIGNED_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return integer_type_class;
+#define FLOATING_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: return real_type_class;
+#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) case BuiltinType::ID: break;
+#include "clang/AST/BuiltinTypes.def"
+case BuiltinType::Void:
+  return void_type_class;
+
+case BuiltinType::Bool:
+  return boolean_type_class;
+
+case BuiltinType::Char_U: // gcc doesn't appear to use char_type_class
+case BuiltinType::UChar:
+case BuiltinType::UShort:
+case BuiltinType::UInt:
+case BuiltinType::ULong:
+case BuiltinType::ULongLong:
+case BuiltinType::UInt128:
+  return integer_type_class;
+
+case BuiltinType::NullPtr:
+  return pointer_type_class;
+
+case BuiltinType::WChar_U:
+case BuiltinType::Char16:
+case BuiltinType::Char32:
+case BuiltinType::ObjCId:
+case BuiltinType::ObjCClass:
+case BuiltinType::ObjCSel:
+case BuiltinType::OCLImage1d:
+case BuiltinType::OCLImage1dArray:
+case BuiltinType::OCLImage2d:
+case BuiltinType::OCLImage2dArray:
+case BuiltinType::OCLImage1dBuffer:
+case BuiltinType::OCLImage2dDepth:
+case BuiltinType::OCLImage2dArrayDepth:
+case BuiltinType::OCLImage2dMSAA:
+case BuiltinType::OCLImage2dArrayMSAA:
+case BuiltinType::OCLImage2dMSAADepth:
+case BuiltinType::OCLImage2dArrayMSAADepth:
+case BuiltinType::OCLImage3d:
+case BuiltinType::OCLSampler:
+case BuiltinType::OCLEvent:
+case BuiltinType::OCLClkEvent:
+case BuiltinType::OCLQueue:
+case BuiltinType::OCLNDRange:
+case BuiltinType::OCLReserveID:
+case BuiltinType::Dependent:
+  llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
+};
+
+  case Type::Enum:
+return LangOpts.CPlusPlus ? enumeral_type_class : integer_type_class;
+break;
+
+  case Type::Pointer:
 return pointer_type_class;
-  else if (ArgTy->isReferenceType())
-return reference_type_class;
-  else if (ArgTy->isRealType())
-return real_type_class;
-  else if (ArgTy->isComplexType())
+break;
+
+  case Type::MemberPointer:
+if (CanTy->isMemberDataPointerType())
+  return offset_type_class;
+else {
+  assert(CanTy->isMemberFunctionPointerType());
+  return method_type_class;
+}
+
+  case Type::Complex:
 return complex_type_class;
-  else if (ArgTy->isFunctionType())
-return function_type_class;
-  else if (ArgTy->isStructureOrClassType())
-return record_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else if (ArgTy->isArrayType())
-return array_type_class;
-  else if (ArgTy->isUnionType())
-return union_type_class;
-  else  // FIXME: offset_type_class, method_type_class, & lang_type_class?
+
+  case Type::FunctionNoProto:
+  case Type::FunctionProto:
+return LangOpts.CPlusPlus ? function_type_class : pointer_type_class;
+
+  case Type::Record:
+

Re: [libcxx] r260337 - Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from

2016-02-10 Thread Tim Northover via cfe-commits
Hi Richard,

On 9 February 2016 at 16:59, Richard Smith via cfe-commits
 wrote:
> Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
>  and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from  to
> provide a const-correct overload set even when the underlying C library does
> not.

This seems to have caused breakage on one of compiler-rt's tests on
Darwin: lib/asan/test/asan_str_test.cc if I'm reading the runes
correctly. See 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/10117/
for example.

I'm not quite sure what's going on, but it seems to involve enable_if
disabling some overload checks, leading to an inconsistent set of
possible functions. That's probably an independent bug in clang
(there's certainly no mangling to support it in Itanium), but I
suspect libc++ shouldn't be trying to produce such combinations
anyway.

The smallest test case with the essential Clang details I've found is:

char *foo(const char *);
char *foo(char *);
__attribute__ ((__enable_if__(true, ""))) const char *foo(const char *);

void test(char *(*)(const char *));
void test(char *(*)(char *));

void func(char *in) {
  test(&foo);
}

Do you have any ideas on what to do, because I'm a bit stuck I'm
afraid. I can give you preprocessed source if you're struggling to
reproduce the issue (it's 2.4MB for the default 7ish for
-frewrite-includes).

Cheers.

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


Re: [PATCH] D17060: [Clang] Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes

2016-02-10 Thread Hans Wennborg via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rL LLVM

http://reviews.llvm.org/D17060



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


r260411 - Silence some MSVC false positive warnings about integer zexts and falling off the end of a covered switch

2016-02-10 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Feb 10 13:09:15 2016
New Revision: 260411

URL: http://llvm.org/viewvc/llvm-project?rev=260411&view=rev
Log:
Silence some MSVC false positive warnings about integer zexts and falling off 
the end of a covered switch

Modified:
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=260411&r1=260410&r2=260411&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Feb 10 13:09:15 2016
@@ -2311,7 +2311,7 @@ struct ResetGuardBit final : EHScopeStac
 CGBuilderTy &Builder = CGF.Builder;
 llvm::LoadInst *LI = Builder.CreateLoad(Guard);
 llvm::ConstantInt *Mask =
-llvm::ConstantInt::get(CGF.IntTy, ~(1U << GuardNum));
+llvm::ConstantInt::get(CGF.IntTy, ~(1ULL << GuardNum));
 Builder.CreateStore(Builder.CreateAnd(LI, Mask), Guard);
   }
 };

Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=260411&r1=260410&r2=260411&view=diff
==
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Wed Feb 10 13:09:15 2016
@@ -309,7 +309,7 @@ StringRef CodeCompletionTUInfo::getParen
 if (!Interface) {
   // Assign an empty StringRef but with non-null data to distinguish
   // between empty because we didn't process the DeclContext yet.
-  CachedParentName = StringRef((const char *)~0U, 0);
+  CachedParentName = StringRef((const char *)(uintptr_t)~0U, 0);
   return StringRef();
 }
 

Modified: cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp?rev=260411&r1=260410&r2=260411&view=diff
==
--- cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp Wed Feb 10 13:09:15 2016
@@ -243,6 +243,7 @@ static NestedNameSpecifier *getFullyQual
   return Scope;
 }
   }
+  llvm_unreachable("bad NNS kind");
 }
 
 /// \brief Create a nested name specifier for the declaring context of


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


r260414 - Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes.

2016-02-10 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Feb 10 13:11:58 2016
New Revision: 260414

URL: http://llvm.org/viewvc/llvm-project?rev=260414&view=rev
Log:
Fix some Clang-tidy readability-redundant-control-flow warnings; other minor 
fixes.

Differential revision: http://reviews.llvm.org/D17060

Modified:
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/lib/AST/CommentLexer.cpp
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/tools/libclang/CXSourceLocation.cpp

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h?rev=260414&r1=260413&r2=260414&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h Wed Feb 10 
13:11:58 2016
@@ -58,18 +58,15 @@ private:
   llvm::BumpPtrAllocator *Allocator;
 };
 
-
 } // end namespace til
 } // end namespace threadSafety
 } // end namespace clang
 
-
 inline void *operator new(size_t Sz,
   clang::threadSafety::til::MemRegionRef &R) {
   return R.allocate(Sz);
 }
 
-
 namespace clang {
 namespace threadSafety {
 
@@ -80,7 +77,6 @@ using clang::SourceLocation;
 
 namespace til {
 
-
 // A simple fixed size array class that does not manage its own memory,
 // suitable for use with bump pointer allocation.
 template  class SimpleArray {
@@ -117,7 +113,6 @@ public:
 Data = A.allocateT(Ncp);
 Capacity = Ncp;
 memcpy(Data, Odata, sizeof(T) * Size);
-return;
   }
 
   // Reserve space for at least N more items.
@@ -221,10 +216,8 @@ private:
   size_t Capacity;
 };
 
-
 }  // end namespace til
 
-
 // A copy on write vector.
 // The vector can be in one of three states:
 // * invalid -- no operations are permitted.
@@ -346,13 +339,11 @@ private:
   VectorData *Data;
 };
 
-
 inline std::ostream& operator<<(std::ostream& ss, const StringRef str) {
   return ss.write(str.data(), str.size());
 }
 
-
 } // end namespace threadSafety
 } // end namespace clang
 
-#endif  // LLVM_CLANG_THREAD_SAFETY_UTIL_H
+#endif // LLVM_CLANG_THREAD_SAFETY_UTIL_H

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=260414&r1=260413&r2=260414&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Wed Feb 10 13:11:58 2016
@@ -177,7 +177,7 @@ protected:
   }
 };
 
-}
+} // end anonymous namespace
 
 ObjCMigrateAction::ObjCMigrateAction(
   std::unique_ptr 
WrappedAction,
@@ -307,7 +307,6 @@ namespace {
 }
 return true;
   }
-  
 
 class ObjCMigrator : public RecursiveASTVisitor {
   ObjCMigrateASTConsumer &Consumer;
@@ -370,7 +369,7 @@ public:
 return true;
   }
 };
-}
+} // end anonymous namespace
 
 void ObjCMigrateASTConsumer::migrateDecl(Decl *D) {
   if (!D)
@@ -1106,7 +1105,6 @@ static bool AvailabilityAttrsMatch(Attr
   versionsMatch(Deprecated1, Deprecated2) &&
   versionsMatch(Obsoleted1, Obsoleted2) &&
   IsUnavailable1 == IsUnavailable2);
-  
 }
 
 static bool MatchTwoAttributeLists(const AttrVec &Attrs1, const AttrVec 
&Attrs2,
@@ -1511,7 +1509,6 @@ void ObjCMigrateASTConsumer::AddCFAnnota
   }
 }
 
-
 ObjCMigrateASTConsumer::CF_BRIDGING_KIND
   ObjCMigrateASTConsumer::migrateAddFunctionAnnotation(
   ASTContext &Ctx,
@@ -1685,7 +1682,6 @@ void ObjCMigrateASTConsumer::migrateAddM
   return;
 }
   }
-  return;
 }
 
 namespace {
@@ -1702,7 +1698,7 @@ public:
 return true;
   }
 };
-} // anonymous namespace
+} // end anonymous namespace
 
 static bool hasSuperInitCall(const ObjCMethodDecl *MD) {
   return !SuperInitC

Re: [PATCH] D15040: [ARM] Add command-line options for ARMv8.2-A

2016-02-10 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Looks reasonable to me now.

Tim.


http://reviews.llvm.org/D15040



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


Re: [PATCH] D17060: [Clang] Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes

2016-02-10 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260414: Fix some Clang-tidy 
readability-redundant-control-flow warnings; other minor… (authored by 
eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D17060?vs=47415&id=47492#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17060

Files:
  cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyUtil.h
  cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
  cfe/trunk/lib/AST/ASTDiagnostic.cpp
  cfe/trunk/lib/AST/CommentLexer.cpp
  cfe/trunk/lib/AST/CommentSema.cpp
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
  cfe/trunk/lib/CodeGen/CGObjCMac.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  cfe/trunk/tools/libclang/CXSourceLocation.cpp

Index: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp
@@ -576,7 +576,6 @@
 return CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(CGM.Int32Ty, params, false),
   "objc_exception_match");
-
   }
 
   /// SetJmpFn - LLVM _setjmp function.
@@ -600,7 +599,6 @@
 /// modern abi
 class ObjCNonFragileABITypesHelper : public ObjCCommonTypesHelper {
 public:
-
   // MethodListnfABITy - LLVM for struct _method_list_t
   llvm::StructType *MethodListnfABITy;
 
@@ -1509,12 +1507,15 @@
   llvm::Constant *GetSetStructFunction() override {
 return ObjCTypes.getCopyStructFn();
   }
+
   llvm::Constant *GetGetStructFunction() override {
 return ObjCTypes.getCopyStructFn();
   }
+
   llvm::Constant *GetCppAtomicObjectSetFunction() override {
 return ObjCTypes.getCppAtomicObjectFunction();
   }
+
   llvm::Constant *GetCppAtomicObjectGetFunction() override {
 return ObjCTypes.getCppAtomicObjectFunction();
   }
@@ -2030,6 +2031,7 @@
 bool IsDisordered = false;
 
 llvm::SmallVector IvarsInfo;
+
   public:
 IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin,
   CharUnits instanceEnd, bool forStrongLayout)
@@ -2065,7 +2067,7 @@
   printf("\n");
 }
   };
-}
+} // end anonymous namespace
 
 llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM,
 const CGBlockInfo &blockInfo) {
@@ -2144,7 +2146,6 @@
   }
 }
 
-
 /// getBlockCaptureLifetime - This routine returns life time of the captured
 /// block variable for the purpose of block layout meta-data generation. FQT is
 /// the type of the variable captured in the block.
@@ -2632,7 +2633,6 @@
   return getBitmapBlockLayout(false);
 }
 
-
 llvm::Constant *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM,
   QualType T) {
   assert(CGM.getLangOpts().getGC() == LangOptions::NonGC);
@@ -3640,13 +3640,15 @@
 llvm::Constant *CGObjCMac::GetGetStructFunction() {
   return ObjCTypes.getCopyStructFn();
 }
+
 llvm::Constant *CGObjCMac::GetSetStructFunction() {
   return ObjCTypes.getCopyStructFn();
 }
 
 llvm::Constant *CGObjCMac::GetCppAtomicObjectGetFunction() {
   return ObjCTypes.getCppAtomicObjectFunction();
 }
+
 llvm::Constant *CGObjCMac::GetCppAtomicObjectSetFunction() {
   return ObjCTypes.getCppAtomicObjectFunction();
 }
@@ -3744,7 +3746,7 @@
 void emitWriteHazard();
 void emitHazardsInNewBlocks();
   };
-}
+} // end anonymous namespace
 
 /// Create the fragile-ABI read and write hazards based on the current
 /// state of the function, which is presumed to be immediately prior
@@ -4365,7 +4367,6 @@
   llvm::Value *args[] = { src, dst.getPointer() };
   CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(),
   args, "weakassign");
-  return;
 }
 
 /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object.
@@ -4391,7 +4392,6 @@
   else
 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(),
 args, "threadlocalassign");
-  return;
 }
 
 /// EmitObjCIvarAssign - Code gen for assigning to a __strong object.
@@ -4413,7 +4413,6 @@
   dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
   llvm::Value *args[] = { src, dst.getPointer(), ivarOf

Re: [PATCH] D17085: Test commit, fixed "clang" to "Clang" in docs

2016-02-10 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

LGTM


http://reviews.llvm.org/D17085



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


r260420 - [analyzer] Windows: launch scan-build from an arbitrary location.

2016-02-10 Thread Anton Yartsev via cfe-commits
Author: ayartsev
Date: Wed Feb 10 13:46:41 2016
New Revision: 260420

URL: http://llvm.org/viewvc/llvm-project?rev=260420&view=rev
Log:
[analyzer] Windows: launch scan-build from an arbitrary location.

The following batch files allow to launch scan-build from an arbitrary location 
if path to clang\tools\scan-build-py\bin is added to %PATH%.

Added:
cfe/trunk/tools/scan-build-py/bin/analyze-build.bat
cfe/trunk/tools/scan-build-py/bin/analyze-c++.bat
cfe/trunk/tools/scan-build-py/bin/analyze-cc.bat
cfe/trunk/tools/scan-build-py/bin/intercept-build.bat
cfe/trunk/tools/scan-build-py/bin/intercept-c++.bat
cfe/trunk/tools/scan-build-py/bin/intercept-cc.bat
cfe/trunk/tools/scan-build-py/bin/scan-build.bat

Added: cfe/trunk/tools/scan-build-py/bin/analyze-build.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/analyze-build.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/analyze-build.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/analyze-build.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0analyze-build %*

Added: cfe/trunk/tools/scan-build-py/bin/analyze-c++.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/analyze-c%2B%2B.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/analyze-c++.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/analyze-c++.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0analyze-c++ %*

Added: cfe/trunk/tools/scan-build-py/bin/analyze-cc.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/analyze-cc.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/analyze-cc.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/analyze-cc.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0analyze-cc %*

Added: cfe/trunk/tools/scan-build-py/bin/intercept-build.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/intercept-build.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/intercept-build.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/intercept-build.bat Wed Feb 10 13:46:41 
2016
@@ -0,0 +1 @@
+python %~dp0intercept-build %*

Added: cfe/trunk/tools/scan-build-py/bin/intercept-c++.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/intercept-c%2B%2B.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/intercept-c++.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/intercept-c++.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0intercept-c++ %*

Added: cfe/trunk/tools/scan-build-py/bin/intercept-cc.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/intercept-cc.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/intercept-cc.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/intercept-cc.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0intercept-cc %*

Added: cfe/trunk/tools/scan-build-py/bin/scan-build.bat
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/bin/scan-build.bat?rev=260420&view=auto
==
--- cfe/trunk/tools/scan-build-py/bin/scan-build.bat (added)
+++ cfe/trunk/tools/scan-build-py/bin/scan-build.bat Wed Feb 10 13:46:41 2016
@@ -0,0 +1 @@
+python %~dp0scan-build %*


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


Re: [PATCH] D16971: Fixed crash when partial specialization is missing required parameters

2016-02-10 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 47499.
hintonda added a comment.

- Added test for PR26077


http://reviews.llvm.org/D16971

Files:
  lib/Sema/SemaTemplate.cpp
  test/SemaCXX/pr26077-crash-on-invalid.cpp

Index: test/SemaCXX/pr26077-crash-on-invalid.cpp
===
--- /dev/null
+++ test/SemaCXX/pr26077-crash-on-invalid.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR26077).
+
+class DB {};
+
+template  class RemovePolicy : public T {};
+
+template >
+  class Crash : T, Policy {};
+
+template 
+class Crash : public DB, public Policy { // expected-error {{partial 
specialization of 'Crash' does not use any of its template parameters}}
+public:
+  Crash(){}
+};
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2542,7 +2542,7 @@
 InstantiationDependent)) {
   Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
   << VarTemplate->getDeclName();
-  IsPartialSpecialization = false;
+  return true;
 }
 
 if (isSameAsPrimaryTemplate(VarTemplate->getTemplateParameters(),
@@ -6286,7 +6286,7 @@
  InstantiationDependent)) {
   Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
 << ClassTemplate->getDeclName();
-  isPartialSpecialization = false;
+  return true;
 }
   }
 


Index: test/SemaCXX/pr26077-crash-on-invalid.cpp
===
--- /dev/null
+++ test/SemaCXX/pr26077-crash-on-invalid.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR26077).
+
+class DB {};
+
+template  class RemovePolicy : public T {};
+
+template >
+  class Crash : T, Policy {};
+
+template 
+class Crash : public DB, public Policy { // expected-error {{partial specialization of 'Crash' does not use any of its template parameters}}
+public:
+  Crash(){}
+};
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2542,7 +2542,7 @@
 InstantiationDependent)) {
   Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
   << VarTemplate->getDeclName();
-  IsPartialSpecialization = false;
+  return true;
 }
 
 if (isSameAsPrimaryTemplate(VarTemplate->getTemplateParameters(),
@@ -6286,7 +6286,7 @@
  InstantiationDependent)) {
   Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
 << ClassTemplate->getDeclName();
-  isPartialSpecialization = false;
+  return true;
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17072: Return immediatedly if Method is null, otherwise you'll get a crash when dyn_cast is called with a nullptr

2016-02-10 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 47501.
hintonda added a comment.

- Added test for PR25181


http://reviews.llvm.org/D17072

Files:
  lib/Parse/ParseCXXInlineMethods.cpp
  test/SemaCXX/pr25181-crash-on-invalid.cpp

Index: test/SemaCXX/pr25181-crash-on-invalid.cpp
===
--- /dev/null
+++ test/SemaCXX/pr25181-crash-on-invalid.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR25181).
+
+template  class Foo { // expected-note {{template parameter is 
declared here}}
+  template  // expected-error {{declaration of 'T' shadows 
template parameter}}
+  void Foo::method(T *) const throw() {} // expected-error {{nested name 
specifier 'Foo::' for declaration does not refer into a class, class 
template or class template partial specialization}}
+};
Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,8 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if (!LM.Method)
+return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);


Index: test/SemaCXX/pr25181-crash-on-invalid.cpp
===
--- /dev/null
+++ test/SemaCXX/pr25181-crash-on-invalid.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// Don't crash (PR25181).
+
+template  class Foo { // expected-note {{template parameter is declared here}}
+  template  // expected-error {{declaration of 'T' shadows template parameter}}
+  void Foo::method(T *) const throw() {} // expected-error {{nested name specifier 'Foo::' for declaration does not refer into a class, class template or class template partial specialization}}
+};
Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -293,6 +293,8 @@
 }
 
 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
+  if (!LM.Method)
+return;
   // If this is a member template, introduce the template parameter scope.
   ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
   TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17072: Return immediatedly if Method is null, otherwise you'll get a crash when dyn_cast is called with a nullptr

2016-02-10 Thread don hinton via cfe-commits
hintonda added a comment.

I don't have commit access, so if this patch is accepted, could someone please 
commit it for me?


http://reviews.llvm.org/D17072



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


Re: [PATCH] D16971: Fixed crash when partial specialization is missing required parameters

2016-02-10 Thread don hinton via cfe-commits
hintonda added a comment.

I don't have commit access, so if this patch is accepted, could someone please 
commit it for me?


http://reviews.llvm.org/D16971



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


Re: [libcxx] r260337 - Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from

2016-02-10 Thread Richard Smith via cfe-commits
On Wed, Feb 10, 2016 at 10:32 AM, Tim Northover  wrote:
> Hi Richard,
>
> On 9 February 2016 at 16:59, Richard Smith via cfe-commits
>  wrote:
>> Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
>>  and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from  
>> to
>> provide a const-correct overload set even when the underlying C library does
>> not.
>
> This seems to have caused breakage on one of compiler-rt's tests on
> Darwin: lib/asan/test/asan_str_test.cc if I'm reading the runes
> correctly. See 
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/10117/
> for example.
>
> I'm not quite sure what's going on, but it seems to involve enable_if
> disabling some overload checks, leading to an inconsistent set of
> possible functions. That's probably an independent bug in clang
> (there's certainly no mangling to support it in Itanium), but I
> suspect libc++ shouldn't be trying to produce such combinations
> anyway.
>
> The smallest test case with the essential Clang details I've found is:
>
> char *foo(const char *);
> char *foo(char *);
> __attribute__ ((__enable_if__(true, ""))) const char *foo(const char *);
>
> void test(char *(*)(const char *));
> void test(char *(*)(char *));
>
> void func(char *in) {
>   test(&foo);
> }
>
> Do you have any ideas on what to do, because I'm a bit stuck I'm
> afraid. I can give you preprocessed source if you're struggling to
> reproduce the issue (it's 2.4MB for the default 7ish for
> -frewrite-includes).

Thanks for the reduction. I've been trying to reproduce this, but
compiler-rt won't build for me (apparently something has broken in its
support for libc++ since I last used it -- it's passing -stdlib=libc++
to compile actions but not to the link).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r260337 - Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from

2016-02-10 Thread Richard Smith via cfe-commits
OK, got the build working. This should be fixed in r260425. Please let
me know if you're still seeing failures.

On Wed, Feb 10, 2016 at 11:59 AM, Richard Smith  wrote:
> On Wed, Feb 10, 2016 at 10:32 AM, Tim Northover  
> wrote:
>> Hi Richard,
>>
>> On 9 February 2016 at 16:59, Richard Smith via cfe-commits
>>  wrote:
>>> Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
>>>  and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from  
>>> to
>>> provide a const-correct overload set even when the underlying C library does
>>> not.
>>
>> This seems to have caused breakage on one of compiler-rt's tests on
>> Darwin: lib/asan/test/asan_str_test.cc if I'm reading the runes
>> correctly. See 
>> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/10117/
>> for example.
>>
>> I'm not quite sure what's going on, but it seems to involve enable_if
>> disabling some overload checks, leading to an inconsistent set of
>> possible functions. That's probably an independent bug in clang
>> (there's certainly no mangling to support it in Itanium), but I
>> suspect libc++ shouldn't be trying to produce such combinations
>> anyway.
>>
>> The smallest test case with the essential Clang details I've found is:
>>
>> char *foo(const char *);
>> char *foo(char *);
>> __attribute__ ((__enable_if__(true, ""))) const char *foo(const char *);
>>
>> void test(char *(*)(const char *));
>> void test(char *(*)(char *));
>>
>> void func(char *in) {
>>   test(&foo);
>> }
>>
>> Do you have any ideas on what to do, because I'm a bit stuck I'm
>> afraid. I can give you preprocessed source if you're struggling to
>> reproduce the issue (it's 2.4MB for the default 7ish for
>> -frewrite-includes).
>
> Thanks for the reduction. I've been trying to reproduce this, but
> compiler-rt won't build for me (apparently something has broken in its
> support for libc++ since I last used it -- it's passing -stdlib=libc++
> to compile actions but not to the link).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17091: [analyzer][scan-build-py] Non-existing directory for scan-build output.

2016-02-10 Thread Anton Yartsev via cfe-commits
ayartsev created this revision.
ayartsev added a reviewer: rizsotto.mailinglist.
ayartsev added a subscriber: cfe-commits.

Attached patch makes scan-build successfully accept non-existing output 
directories provided via "-o" option. The directory is created in this case. 
This behavior is conforming to the old perl scan-build implementation. Please 
review.

http://reviews.llvm.org/D17091

Files:
  tools/scan-build-py/libscanbuild/report.py

Index: tools/scan-build-py/libscanbuild/report.py
===
--- tools/scan-build-py/libscanbuild/report.py
+++ tools/scan-build-py/libscanbuild/report.py
@@ -35,7 +35,12 @@
 keep -- a boolean value to keep or delete the empty report directory. """
 
 stamp = time.strftime('scan-build-%Y-%m-%d-%H%M%S-', time.localtime())
-name = tempfile.mkdtemp(prefix=stamp, dir=hint)
+
+parentdir = os.path.abspath(hint);
+if not os.path.exists(parentdir):
+os.makedirs(parentdir)
+
+name = tempfile.mkdtemp(prefix=stamp, dir=parentdir)
 
 logging.info('Report directory created: %s', name)
 


Index: tools/scan-build-py/libscanbuild/report.py
===
--- tools/scan-build-py/libscanbuild/report.py
+++ tools/scan-build-py/libscanbuild/report.py
@@ -35,7 +35,12 @@
 keep -- a boolean value to keep or delete the empty report directory. """
 
 stamp = time.strftime('scan-build-%Y-%m-%d-%H%M%S-', time.localtime())
-name = tempfile.mkdtemp(prefix=stamp, dir=hint)
+
+parentdir = os.path.abspath(hint);
+if not os.path.exists(parentdir):
+os.makedirs(parentdir)
+
+name = tempfile.mkdtemp(prefix=stamp, dir=parentdir)
 
 logging.info('Report directory created: %s', name)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r260431 - Recommit r260012 - Cleanup node-type handling in the unordered containers.

2016-02-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 10 14:46:23 2016
New Revision: 260431

URL: http://llvm.org/viewvc/llvm-project?rev=260431&view=rev
Log:
Recommit r260012 - Cleanup node-type handling in the unordered containers.

This time I kept  working!

This patch is the first in a series of patches that's meant to better
support unordered_map. unordered_map has a special "value_type" that
differs from pair. In order to meet the EmplaceConstructible
and CopyInsertable requirements we need to teach __hash_table about this
special value_type.

This patch creates a "__hash_node_types" traits class that contains
all of the typedefs needed by the unordered containers and it's iterators.
These typedefs include ones for each node type and  node pointer type,
as well as special typedefs for "unordered_map"'s value type.

As a result of this change all of the unordered containers now all support
incomplete types.

As a drive-by fix I changed the difference_type in __hash_table to always
be ptrdiff_t. There is a corresponding change to size_type but it cannot
take affect until an ABI break.

This patch will be followed up shortly with fixes for various unordered_map
bugs and problems.

Added:
libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp
libcxx/trunk/test/std/containers/unord/iterator_difference_type.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.map/incomplete_type.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multimap/incomplete.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/incomplete.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/incomplete.pass.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__hash_table
libcxx/trunk/include/ext/hash_map
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=260431&r1=260430&r2=260431&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb 10 14:46:23 2016
@@ -42,6 +42,7 @@
 // Fix undefined behavior in how std::list stores it's linked nodes.
 #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
 #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
+#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
 #endif
 
 #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=260431&r1=260430&r2=260431&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Wed Feb 10 14:46:23 2016
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include <__undef_min_max>
 #include <__undef___deallocate>
@@ -49,10 +50,10 @@ struct __hash_node
  typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, 
_VoidPtr> >::type
  >
 {
-typedef _Tp value_type;
+typedef _Tp __node_value_type;
 
 size_t __hash_;
-value_type __value_;
+__node_value_type __value_;
 };
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -77,23 +78,126 @@ __next_hash_pow2(size_t __n)
 }
 
 template  class 
__hash_table;
+
+template   class _LIBCPP_TYPE_VIS_ONLY __hash_iterator;
 template  class _LIBCPP_TYPE_VIS_ONLY 
__hash_const_iterator;
+template   class _LIBCPP_TYPE_VIS_ONLY 
__hash_local_iterator;
+template  class _LIBCPP_TYPE_VIS_ONLY 
__hash_const_local_iterator;
 template  class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
 template  class _LIBCPP_TYPE_VIS_ONLY 
__hash_map_const_iterator;
 
+#if __cplusplus >= 201103L
+template 
+union __hash_value_type;
+#else
+template 
+struct __hash_value_type;
+#endif
+
+template 
+struct __key_value_types {
+  static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
+  typedef _Tp key_type;
+  typedef _Tp __node_value_type;
+  typedef _Tp __container_value_type;
+  static const bool __is_map = false;
+};
+
+template 
+struct __key_value_types<__hash_value_type<_Key, _Tp> > {
+  typedef _Key key_type;
+  typedef _Tp  mapped_type;
+  typedef __hash_value_type<_Key, _Tp> __node_value_type;
+  typedef pair__container_value_type;
+  typedef __container_value_type   __map_value_type;
+  static const bool __is_map = true;
+};
+
+template ,
+  bool = _KVTypes::__is_map>
+struct __map_pointer_types {};
+
+template 
+struct __map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+  typedef typename _KVTypes::__map_value_type   _Mv;
+  typedef typename __rebind_pointer<_AllocPtr, _Mv>::type
+   
__map_value_type_pointer;
+  typedef typename __rebind_pointer<_AllocPtr, c

Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-10 Thread Eric Fiselier via cfe-commits
(Re-adding the list)

Re-committed as r260431. Let me know if there is any more breakage.

@Tim Are these tests in the clang test suite? Marshall and I were just
talking about removing  all together.
Could you explain who still uses it?


On Mon, Feb 8, 2016 at 4:52 PM, Eric Fiselier  wrote:

> Hey Tim,
>
> Sorry about the breakage. I've reverted the commit in r260172. I'll make
> sure that gnu_cxx::hash_map continues to work before recommitting.
>
> /Eric
>
>
> On Mon, Feb 8, 2016 at 2:23 PM, Tim Northover 
> wrote:
>
>> Hi Eric,
>>
>> On 6 February 2016 at 16:36, Eric Fiselier via cfe-commits
>>  wrote:
>> > Cleanup node-type handling in the unordered containers
>>
>> This seems to have broken __gnu_cxx::hash_map (used by hash.cpp and
>> hash2.cpp in the test-suite). A smaller reproducer is:
>>
>> #include 
>> typedef __gnu_cxx::hash_map> char*> > HM;
>> int foo(HM &h) {
>>   return h["wibble"];
>> }
>>
>> I don't suppose you could take a look? Or is that already planned and
>> what you're talking about with:
>>
>> > This patch will be followed up shortly with fixes for various
>> unordered_map
>> > fixes.
>>
>> Cheers.
>>
>> Tim.
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-10 Thread Tim Northover via cfe-commits
On 10 February 2016 at 12:52, Eric Fiselier  wrote:
> @Tim Are these tests in the clang test suite?

Yep, at http://llvm.org/git/test-suite.git.

> Marshall and I were just talking about removing  all together. 
> Could you explain who still uses it?

In the test-suite, it looks like it's just these two micro-benchmarks.
I doubt anyone would complain about converting them to use
std::unordered_map (especially since the underlying implementation
seems to be shared anyway).

Outside that, we seem to have a handful of internal users and Bob may
have ABI backwards-compatibility concerns (or not). I've added him
explicitly.

Cheers.

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


Re: [PATCH] D16738: Fix invalid casts in .

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

LGTM. Thanks for putting up with my pickyness.  It looks like there are 
exception safety issues with the order of `__f_ = __as_base(&__buf_)` and 
`__f->__f_..__clone(__f)` in a bunch of places but those are existing and so 
I'll fix them separately.

Also we are not applying this fix to the C++03 versions of std::function, but 
I'm OK with that because I want those versions to die.


Repository:
  rL LLVM

http://reviews.llvm.org/D16738



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


Re: [PATCH] D17085: Test commit, fixed "clang" to "Clang" in docs

2016-02-10 Thread Mandeep Singh Grang via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260433: Test commit, fixed "clang" to "Clang" in docs 
(authored by mgrang).

Changed prior to commit:
  http://reviews.llvm.org/D17085?vs=47493&id=47510#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17085

Files:
  cfe/trunk/www/index.html

Index: cfe/trunk/www/index.html
===
--- cfe/trunk/www/index.html
+++ cfe/trunk/www/index.html
@@ -93,7 +93,7 @@
be a production quality C, Objective-C, C++ and Objective-C++ compiler when 
targeting X86-32, X86-64, and ARM (other targets may have caveats, but are 
usually easy to fix).  If you are looking for source analysis or
-   source-to-source transformation tools, clang is probably a great
+   source-to-source transformation tools, Clang is probably a great
solution for you.  Clang supports C++11, please see the C++ status page for more
information.
@@ -104,14 +104,14 @@
   
   Start by getting the code, building it, and
  playing with it.  This will show you the sorts of things we can do
- today and will let you have the "clang experience" first hand: hopefully
+ today and will let you have the "Clang experience" first hand: hopefully
  it will "resonate" with you. :)
   
   Once you've done that, please consider getting
- involved in the clang community.  The clang developers include 
numerous
+ involved in the clang community.  The Clang developers include 
numerous
  volunteer contributors with a variety of backgrounds.  If you're 
  interested in
- following the development of clang, signing up for a mailing list is a 
good
+ following the development of Clang, signing up for a mailing list is a 
good
  way to learn about how the project works.
 
 


Index: cfe/trunk/www/index.html
===
--- cfe/trunk/www/index.html
+++ cfe/trunk/www/index.html
@@ -93,7 +93,7 @@
be a production quality C, Objective-C, C++ and Objective-C++ compiler when 
targeting X86-32, X86-64, and ARM (other targets may have caveats, but are 
usually easy to fix).  If you are looking for source analysis or
-   source-to-source transformation tools, clang is probably a great
+   source-to-source transformation tools, Clang is probably a great
solution for you.  Clang supports C++11, please see the C++ status page for more
information.
@@ -104,14 +104,14 @@
   
   Start by getting the code, building it, and
  playing with it.  This will show you the sorts of things we can do
- today and will let you have the "clang experience" first hand: hopefully
+ today and will let you have the "Clang experience" first hand: hopefully
  it will "resonate" with you. :)
   
   Once you've done that, please consider getting
- involved in the clang community.  The clang developers include numerous
+ involved in the clang community.  The Clang developers include numerous
  volunteer contributors with a variety of backgrounds.  If you're 
  interested in
- following the development of clang, signing up for a mailing list is a good
+ following the development of Clang, signing up for a mailing list is a good
  way to learn about how the project works.
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260433 - Test commit, fixed "clang" to "Clang" in docs

2016-02-10 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Wed Feb 10 15:06:10 2016
New Revision: 260433

URL: http://llvm.org/viewvc/llvm-project?rev=260433&view=rev
Log:
Test commit, fixed "clang" to "Clang" in docs

Reviewers: weimingz

Subscribers: cfe-commits

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

Modified:
cfe/trunk/www/index.html

Modified: cfe/trunk/www/index.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=260433&r1=260432&r2=260433&view=diff
==
--- cfe/trunk/www/index.html (original)
+++ cfe/trunk/www/index.html Wed Feb 10 15:06:10 2016
@@ -93,7 +93,7 @@
be a production quality C, Objective-C, C++ and Objective-C++ compiler when 
targeting X86-32, X86-64, and ARM (other targets may have caveats, but are 
usually easy to fix).  If you are looking for source analysis or
-   source-to-source transformation tools, clang is probably a great
+   source-to-source transformation tools, Clang is probably a great
solution for you.  Clang supports C++11, please see the C++ status page for more
information.
@@ -104,14 +104,14 @@
   
   Start by getting the code, building it, and
  playing with it.  This will show you the sorts of things we can do
- today and will let you have the "clang experience" first hand: hopefully
+ today and will let you have the "Clang experience" first hand: hopefully
  it will "resonate" with you. :)
   
   Once you've done that, please consider getting
- involved in the clang community.  The clang developers include 
numerous
+ involved in the clang community.  The Clang developers include 
numerous
  volunteer contributors with a variety of backgrounds.  If you're 
  interested in
- following the development of clang, signing up for a mailing list is a 
good
+ following the development of Clang, signing up for a mailing list is a 
good
  way to learn about how the project works.
 
 


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


Re: [PATCH] D15095: Accept "-Weverything" in pragma clang diagnostic ...

2016-02-10 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava added a reviewer: rsmith.
Sunil_Srivastava updated this revision to Diff 47509.
Sunil_Srivastava added a comment.

Changed the test, but the compiler code is still same, pending reply from 
Richard Smith


http://reviews.llvm.org/D15095

Files:
  lib/Basic/Diagnostic.cpp
  test/Preprocessor/pragma_diagnostic.c
  test/Preprocessor/pushable-diagnostics.c

Index: test/Preprocessor/pushable-diagnostics.c
===
--- test/Preprocessor/pushable-diagnostics.c
+++ test/Preprocessor/pushable-diagnostics.c
@@ -15,3 +15,27 @@
 int c = 'df';  // expected-warning{{multi-character character constant}}
 
 #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could 
not pop, no matching push}}
+
+// Test -Weverything
+
+void ppo0(){} // first verify that we do not give anything on this
+#pragma clang diagnostic push // now push
+
+#pragma clang diagnostic warning "-Weverything" 
+void ppr1(){} // expected-warning {{no previous prototype for function 'ppr1'}}
+
+#pragma clang diagnostic push // push again
+#pragma clang diagnostic ignored "-Weverything"  // Set to ignore in this 
level.
+void pps2(){}
+#pragma clang diagnostic warning "-Weverything"  // Set to warning in this 
level.
+void ppt2(){} // expected-warning {{no previous prototype for function 'ppt2'}}
+#pragma clang diagnostic error "-Weverything"  // Set to error in this level.
+void ppt3(){} // expected-error {{no previous prototype for function 'ppt3'}}
+#pragma clang diagnostic pop // pop should go back to warning level
+
+void pps1(){} // expected-warning {{no previous prototype for function 'pps1'}}
+
+
+#pragma clang diagnostic pop // Another pop should disble it again
+void ppu(){}
+
Index: test/Preprocessor/pragma_diagnostic.c
===
--- test/Preprocessor/pragma_diagnostic.c
+++ test/Preprocessor/pragma_diagnostic.c
@@ -30,3 +30,18 @@
 
 #pragma GCC diagnostic error "-Winvalid-name"  // expected-warning {{unknown 
warning group '-Winvalid-name', ignored}}
 
+
+// Testing pragma clang diagnostic with -Weverything
+void ppo(){} // First test that we do not diagnose on this.
+
+#pragma clang diagnostic warning "-Weverything"
+void ppp(){} // expected-warning {{no previous prototype for function 'ppp'}}
+
+#pragma clang diagnostic ignored "-Weverything" // Reset it.
+void ppq(){}
+
+#pragma clang diagnostic error "-Weverything" // Now set to error
+void ppr(){} // expected-error {{no previous prototype for function 'ppr'}}
+
+#pragma clang diagnostic warning "-Weverything" // This should not be effective
+void pps(){} // expected-error {{no previous prototype for function 'pps'}}
Index: lib/Basic/Diagnostic.cpp
===
--- lib/Basic/Diagnostic.cpp
+++ lib/Basic/Diagnostic.cpp
@@ -248,6 +248,14 @@
 bool DiagnosticsEngine::setSeverityForGroup(diag::Flavor Flavor,
 StringRef Group, diag::Severity 
Map,
 SourceLocation Loc) {
+  // Special handling for pragma clang diagnostic ... "-Weverything"
+  // There is no formal group named "everything", so there has to be a special
+  // case for it.
+  if (Group == "everything") {
+   setSeverityForAll(Flavor, Map, Loc);
+   return false;
+  }
+
   // Get the diagnostics in this group.
   SmallVector GroupDiags;
   if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))


Index: test/Preprocessor/pushable-diagnostics.c
===
--- test/Preprocessor/pushable-diagnostics.c
+++ test/Preprocessor/pushable-diagnostics.c
@@ -15,3 +15,27 @@
 int c = 'df';  // expected-warning{{multi-character character constant}}
 
 #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}}
+
+// Test -Weverything
+
+void ppo0(){} // first verify that we do not give anything on this
+#pragma clang diagnostic push // now push
+
+#pragma clang diagnostic warning "-Weverything" 
+void ppr1(){} // expected-warning {{no previous prototype for function 'ppr1'}}
+
+#pragma clang diagnostic push // push again
+#pragma clang diagnostic ignored "-Weverything"  // Set to ignore in this level.
+void pps2(){}
+#pragma clang diagnostic warning "-Weverything"  // Set to warning in this level.
+void ppt2(){} // expected-warning {{no previous prototype for function 'ppt2'}}
+#pragma clang diagnostic error "-Weverything"  // Set to error in this level.
+void ppt3(){} // expected-error {{no previous prototype for function 'ppt3'}}
+#pragma clang diagnostic pop // pop should go back to warning level
+
+void pps1(){} // expected-warning {{no previous prototype for function 'pps1'}}
+
+
+#pragma clang diagnostic pop // Another pop should disble it again
+void ppu(){}
+
Index: test/Preprocessor/pragma_diagnostic.c
==

Re: [PATCH] D15095: Accept "-Weverything" in pragma clang diagnostic ...

2016-02-10 Thread Sunil Srivastava via cfe-commits
Sunil_Srivastava added a comment.

Richard, Your comment and my concern about the getDiagnosticsInGroup is still 
visible in the greyed out area.

Given that do you still want to modify getDiagnosticsInGroup ?

I have removed the separate test and added the new tests to existing files, as 
you suggested.


http://reviews.llvm.org/D15095



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


Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-10 Thread Bob Wilson via cfe-commits

> On Feb 10, 2016, at 12:59 PM, Tim Northover  wrote:
> 
> On 10 February 2016 at 12:52, Eric Fiselier  wrote:
>> @Tim Are these tests in the clang test suite?
> 
> Yep, at http://llvm.org/git/test-suite.git.
> 
>> Marshall and I were just talking about removing  all together. 
>> Could you explain who still uses it?
> 
> In the test-suite, it looks like it's just these two micro-benchmarks.
> I doubt anyone would complain about converting them to use
> std::unordered_map (especially since the underlying implementation
> seems to be shared anyway).
> 
> Outside that, we seem to have a handful of internal users and Bob may
> have ABI backwards-compatibility concerns (or not). I've added him
> explicitly.

I will defer to Duncan on that question.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17043#348569, @sidney wrote:

> In http://reviews.llvm.org/D17043#348525, @alexfh wrote:
>
> > I'd like to note that there is a library-side way to mitigate this issue 
> > using the `[[clang::warn_unused_result]]` attribute on `vector::empty()` 
> > and similar methods:
>
>
> Using an attribute sounds much better than this kind of check and I'd be fine 
> with throwing this patch out completely. IMHO the diagnostic is bad, though. 
> A message like this:
>
> >   q.cc:17:3: warning: ignoring return value of function declared with 
> > warn_unused_result attribute [-Wunused-result]
>
> > v.empty();
>
> > ^~~
>
> > 
>
>
> …is way too literal. It could indicate two completely different issues:
>
> 1. `empty()` just tells you whether the container is empty.
> 2. `empty()` has side effects and returns a value which should never be 
> ignored (like recv, send, and scanf).
>
>   Searching for this warning 
> (https://www.google.com/search?q="Wunused-result";) turns up tons of confusion.
>
>   I'm not an expert on attributes. Is there a way to attach metadata (like a 
> subtype, or a string description), so that calls without side effects could 
> have a diagnostic more like the one I wrote, and things like `recv(2)` and 
> `scanf(3)` could have rich messages?


The attribute can have arguments (e.g. `[[deprecated("use some other API")]] 
void f();`), so if there is a good reason, an argument (e.g. a custom message) 
can be added to the `warn_unused_result` attribute. Richard might have thoughts 
on the matter.

> I'm going to hold of on addressing any of your other comments until I hear 
> back. Thanks for the review!





http://reviews.llvm.org/D17043



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


r260435 - [clang-cl] /Z7 now generates normal debug info, not just line info

2016-02-10 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed Feb 10 15:28:38 2016
New Revision: 260435

URL: http://llvm.org/viewvc/llvm-project?rev=260435&view=rev
Log:
[clang-cl] /Z7 now generates normal debug info, not just line info

Previously LLVM could not process any debug info we produced, so it
didn't make sense to spend time generating it. Now that it has primitive
support for local variable info, it does make sense to generate normal
debug info.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=260435&r1=260434&r2=260435&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Feb 10 15:28:38 2016
@@ -5890,11 +5890,8 @@ void Clang::AddClangCLArgs(const ArgList
 
   // Emit CodeView if -Z7 is present.
   *EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
-  bool EmitDwarf = Args.hasArg(options::OPT_gdwarf);
-  // If we are emitting CV but not DWARF, don't build information that LLVM
-  // can't yet process.
-  if (*EmitCodeView && !EmitDwarf)
-*DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+  if (*EmitCodeView)
+*DebugInfoKind = codegenoptions::LimitedDebugInfo;
   if (*EmitCodeView)
 CmdArgs.push_back("-gcodeview");
 

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=260435&r1=260434&r2=260435&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Wed Feb 10 15:28:38 2016
@@ -379,11 +379,11 @@
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
-// Zi: "-debug-info-kind=line-tables-only"
+// Zi: "-debug-info-kind=limited"
 
 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
 // Z7: "-gcodeview"
-// Z7: "-debug-info-kind=line-tables-only"
+// Z7: "-debug-info-kind=limited"
 
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
 // BreproDefault: "-mincremental-linker-compatible"


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


Re: [PATCH] D5238: [analyzer] Detect duplicate [super dealloc] calls

2016-02-10 Thread Devin Coughlin via cfe-commits
dcoughlin updated this revision to Diff 47514.
dcoughlin added a comment.

Address more of Anna's comments.

- Add a more explicit comment about checker in header comment
- Changed the checker to always use the receiver symbol rather than the self 
symbol for clarity.
- Rework SuperDeallocBRVisitor::VisitNode() to add a note on the node where 
state transitioned from not having CalledSuperDealloc for the receiver symbol 
to having it set.
- Reworded diagnostic text.

I didn't extend Gabor's function helper to Objective-C. I'll do that in a later 
patch.


http://reviews.llvm.org/D5238

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
  test/Analysis/DeallocUseAfterFreeErrors.m

Index: test/Analysis/DeallocUseAfterFreeErrors.m
===
--- /dev/null
+++ test/Analysis/DeallocUseAfterFreeErrors.m
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s
+
+void clang_analyzer_warnIfReached();
+
+#define nil ((id)0)
+
+typedef unsigned long NSUInteger;
+@protocol NSObject
+- (instancetype)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject  { }
+- (void)dealloc;
+- (instancetype)init;
+@end
+
+typedef struct objc_selector *SEL;
+
+//======
+//  
+//  Check that 'self' is not referenced after calling '[super dealloc]'.
+
+@interface SuperDeallocThenReleaseIvarClass : NSObject {
+  NSObject *_ivar;
+}
+@end
+
+@implementation SuperDeallocThenReleaseIvarClass
+- (instancetype)initWithIvar:(NSObject *)ivar {
+  self = [super init];
+  if (!self)
+return nil;
+  _ivar = [ivar retain];
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  [_ivar release];
+}
+@end
+
+@interface SuperDeallocThenAssignNilToIvarClass : NSObject {
+  NSObject *_delegate;
+}
+@end
+
+@implementation SuperDeallocThenAssignNilToIvarClass
+- (instancetype)initWithDelegate:(NSObject *)delegate {
+  self = [super init];
+  if (!self)
+return nil;
+  _delegate = delegate;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  _delegate = nil;
+}
+@end
+
+@interface SuperDeallocThenReleasePropertyClass : NSObject { }
+@property (retain) NSObject *ivar;
+@end
+
+@implementation SuperDeallocThenReleasePropertyClass
+- (instancetype)initWithProperty:(NSObject *)ivar {
+  self = [super init];
+  if (!self)
+return nil;
+  self.ivar = ivar;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  self.ivar = nil;
+}
+@end
+
+@interface SuperDeallocThenAssignNilToPropertyClass : NSObject { }
+@property (assign) NSObject *delegate;
+@end
+
+@implementation SuperDeallocThenAssignNilToPropertyClass
+- (instancetype)initWithDelegate:(NSObject *)delegate {
+  self = [super init];
+  if (!self)
+return nil;
+  self.delegate = delegate;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  self.delegate = nil;
+}
+@end
+
+@interface SuperDeallocThenCallInstanceMethodClass : NSObject { }
+- (void)_invalidate;
+@end
+
+@implementation SuperDeallocThenCallInstanceMethodClass
+- (void)_invalidate {
+}
+- (void)dealloc {
+  [super dealloc];
+  [self _invalidate];
+}
+@end
+
+@interface SuperDeallocThenCallNonObjectiveCMethodClass : NSObject { }
+@end
+
+static void _invalidate(NSObject *object) {
+  (void)object;
+}
+
+@implementation SuperDeallocThenCallNonObjectiveCMethodClass
+- (void)dealloc {
+  [super dealloc];
+  _invalidate(self);
+}
+@end
+
+@interface TwoSuperDeallocCallsClass : NSObject {
+  NSObject *_ivar;
+}
+- (void)_invalidate;
+@end
+
+@implementation TwoSuperDeallocCallsClass
+- (void)_invalidate {
+}
+- (void)dealloc {
+  if (_ivar) {
+[_ivar release];
+[super dealloc];
+return;
+  }
+  [super dealloc];
+  [self _invalidate];
+}
+@end
+
+//======
+// Warn about calling [super dealloc] twice due to missing return statement.
+
+@interface MissingReturnCausesDoubleSuperDeallocClass : NSObject {
+  NSObject *_ivar;
+}
+@end
+
+@implementation MissingReturnCausesDoubleSuperDeallocClass
+- (void)dealloc {
+  if (_ivar) { // expected-note {{Taking true branch}}
+[_ivar release];
+[super dealloc]; // expected-note {{[super dealloc] called here}}
+// return;
+  }
+  [super dealloc]; // expected-warning{{[super dealloc] called again}}
+  // expected-note@-1{{[super dealloc] called again}}
+}
+@end
+
+//======
+// Warn about calling [super dealloc] twice in two different methods.
+
+@interface SuperDeallocInOtherMethodClass : NSObject {
+  NSObject *_ivar;
+}
+- (void)_cleanup;
+@end
+
+@implementation SuperDeallocInOtherMethodClass
+- (void)_cleanup {
+  [_ivar release];
+  [super dealloc]; // expected-note {{[super 

Re: [PATCH] D5238: [analyzer] Detect duplicate [super dealloc] calls

2016-02-10 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In http://reviews.llvm.org/D5238#348199, @zaks.anna wrote:

> Looks good, below are some comments which are mostly nits.
>
> What's the plan for bringing this out of alpha? Is it pending evaluation on 
> real code?


I will first extend this checker to check for uses of self after dealloc and 
then evaluate.


http://reviews.llvm.org/D5238



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


Re: [PATCH] D15095: Accept "-Weverything" in pragma clang diagnostic ...

2016-02-10 Thread Richard Smith via cfe-commits
rsmith added a comment.

There seem to be two principled approaches here:

1. `DiagnosticsEngine` has a `Group` named `"everything"` (all of its interface 
supports that group, and from the point of view of someone using 
`DiagnosticsEngine` it behaves like any other group), or
2. There is no such group, and everyone calling into `DiagnosticsEngine` treats 
it as a special case if they want to allow it.

This patch is more ad-hoc: some of the `DiagnosticsEngine` interface would 
allow `"everything"`, but other parts would reject it, and we would still have 
a special case for `"everything"` in `clang::ProcessWarningOptions`. That 
results in a confusing interface contract for `DiagnosticsEngine`.

Can you move the special case code out of `DiagnosticsEngine` and into the 
pragma handler for now?


http://reviews.llvm.org/D15095



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


Re: [PATCH] D17043: Check that the result of a library call w/o side effects is used

2016-02-10 Thread Sidney San Martín via cfe-commits
sidney added a comment.

In http://reviews.llvm.org/D17043#348982, @alexfh wrote:

> The attribute can have arguments (e.g. `[[deprecated("use some other API")]] 
> void f();`), so if there is a good reason, an argument (e.g. a custom 
> message) can be added to the `warn_unused_result` attribute. Richard might 
> have thoughts on the matter.


Ah, nice! It looks like the format is fairly flexible, too. Maybe it could take 
presets like `warn_unused_result(no_side_effects)` for common cases in addition 
to a string for a custom one? I'd be happy to try to work on this once there's 
a consensus on how/if it should work.



Comment at: clang-tidy/misc/NoSideEffectsCheck.cpp:52
@@ +51,3 @@
+AST_MATCHER(CXXMethodDecl, isAPurelyInformationalMethod) {
+  static const std::unordered_set whitelist{
+"get_allocator",

alexfh wrote:
> Can we assume that all const methods shouldn't be called without using their 
> result? This will make this list much shorter.
Good idea. I originally considered making a check that just looks for const 
methods with unused return values, but Marshall reminded me that const methods 
in third party code might have side effects. Now that this patch is restricted 
to STL containers it's safe, though.


http://reviews.llvm.org/D17043



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


Re: [libcxx] r260337 - Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from

2016-02-10 Thread Tim Northover via cfe-commits
On 10 February 2016 at 12:06, Richard Smith  wrote:
> OK, got the build working. This should be fixed in r260425. Please let
> me know if you're still seeing failures.

Thanks Richard, that did it.

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


[libcxx] r260441 - Fix invalid casts in .

2016-02-10 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Wed Feb 10 15:53:28 2016
New Revision: 260441

URL: http://llvm.org/viewvc/llvm-project?rev=260441&view=rev
Log:
Fix invalid casts in .

static_cast of a pointer to object before the start of the object's
lifetime has undefined behavior.

This code triggers CFI warnings.

This change replaces C-style casts with reinterpret_cast, which is
fine per the standard, add applies an attribute to silence CFI (which
barks on reinterpret_cast, too).

Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/functional

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=260441&r1=260440&r2=260441&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Feb 10 15:53:28 2016
@@ -180,6 +180,12 @@
 # endif
 #endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
 
+#if __has_attribute(__no_sanitize__)
+#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
+#else
+#define _LIBCPP_NO_CFI
+#endif
+
 #ifdef _WIN32
 
 // only really useful for a DLL

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=260441&r1=260440&r2=260441&view=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Wed Feb 10 15:53:28 2016
@@ -1564,6 +1564,10 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp
 typename aligned_storage<3*sizeof(void*)>::type __buf_;
 __base* __f_;
 
+_LIBCPP_NO_CFI static __base *__as_base(void *p) {
+  return reinterpret_cast<__base*>(p);
+}
+
 template ::value &&
 __invokable<_Fp&, _ArgTypes...>::value>
 struct __callable;
@@ -1660,9 +1664,9 @@ function<_Rp(_ArgTypes...)>::function(co
 {
 if (__f.__f_ == 0)
 __f_ = 0;
-else if (__f.__f_ == (const __base*)&__f.__buf_)
+else if ((void *)__f.__f_ == &__f.__buf_)
 {
-__f_ = (__base*)&__buf_;
+__f_ = __as_base(&__buf_);
 __f.__f_->__clone(__f_);
 }
 else
@@ -1676,9 +1680,9 @@ function<_Rp(_ArgTypes...)>::function(al
 {
 if (__f.__f_ == 0)
 __f_ = 0;
-else if (__f.__f_ == (const __base*)&__f.__buf_)
+else if ((void *)__f.__f_ == &__f.__buf_)
 {
-__f_ = (__base*)&__buf_;
+__f_ = __as_base(&__buf_);
 __f.__f_->__clone(__f_);
 }
 else
@@ -1690,9 +1694,9 @@ function<_Rp(_ArgTypes...)>::function(fu
 {
 if (__f.__f_ == 0)
 __f_ = 0;
-else if (__f.__f_ == (__base*)&__f.__buf_)
+else if ((void *)__f.__f_ == &__f.__buf_)
 {
-__f_ = (__base*)&__buf_;
+__f_ = __as_base(&__buf_);
 __f.__f_->__clone(__f_);
 }
 else
@@ -1709,9 +1713,9 @@ function<_Rp(_ArgTypes...)>::function(al
 {
 if (__f.__f_ == 0)
 __f_ = 0;
-else if (__f.__f_ == (__base*)&__f.__buf_)
+else if ((void *)__f.__f_ == &__f.__buf_)
 {
-__f_ = (__base*)&__buf_;
+__f_ = __as_base(&__buf_);
 __f.__f_->__clone(__f_);
 }
 else
@@ -1736,8 +1740,7 @@ function<_Rp(_ArgTypes...)>::function(_F
 typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF;
 if (sizeof(_FF) <= sizeof(__buf_) && 
is_nothrow_copy_constructible<_Fp>::value)
 {
-__f_ = (__base*)&__buf_;
-::new (__f_) _FF(_VSTD::move(__f));
+__f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f));
 }
 else
 {
@@ -1766,8 +1769,7 @@ function<_Rp(_ArgTypes...)>::function(al
 if (sizeof(_FF) <= sizeof(__buf_) && 
 is_nothrow_copy_constructible<_Fp>::value && 
is_nothrow_copy_constructible<_Ap>::value)
 {
-__f_ = (__base*)&__buf_;
-::new (__f_) _FF(_VSTD::move(__f), _Alloc(__a));
+__f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a));
 }
 else
 {
@@ -1791,16 +1793,16 @@ template
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
 {
-if (__f_ == (__base*)&__buf_)
+if ((void *)__f_ == &__buf_)
 __f_->destroy();
 else if (__f_)
 __f_->destroy_deallocate();
 __f_ = 0;
 if (__f.__f_ == 0)
 __f_ = 0;
-else if (__f.__f_ == (__base*)&__f.__buf_)
+else if ((void *)__f.__f_ == &__f.__buf_)
 {
-__f_ = (__base*)&__buf_;
+__f_ = __as_base(&__buf_);
 __f.__f_->__clone(__f_);
 }
 else
@@ -1815,7 +1817,7 @@ template
 function<_Rp(_ArgTypes...)>&
 function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
 {
-if (__f_ == (__base*)&__buf_)
+if ((void *)__f_ == &__buf_)
 __f_->destroy();
 else if (__f_)
 __f_->destroy_deallocate();
@@ -1840,7 +1842,7 @@ function<_Rp(_A

Re: [PATCH] D16738: Fix invalid casts in .

2016-02-10 Thread Evgeniy Stepanov via cfe-commits
eugenis closed this revision.
eugenis added a comment.

Thanks for the review!
Committed as r260441.


Repository:
  rL LLVM

http://reviews.llvm.org/D16738



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


[libcxx] r260443 - Remove changes that snuck in within r260431

2016-02-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Wed Feb 10 15:58:36 2016
New Revision: 260443

URL: http://llvm.org/viewvc/llvm-project?rev=260443&view=rev
Log:
Remove changes that snuck in within r260431

Modified:
libcxx/trunk/include/unordered_map

Modified: libcxx/trunk/include/unordered_map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=260443&r1=260442&r2=260443&view=diff
==
--- libcxx/trunk/include/unordered_map (original)
+++ libcxx/trunk/include/unordered_map Wed Feb 10 15:58:36 2016
@@ -384,7 +384,6 @@ template ::__map_value_type _PairT;
 public:
 _LIBCPP_INLINE_VISIBILITY
 __unordered_map_hasher()
@@ -414,8 +413,6 @@ template 
 {
 _Hash __hash_;
-
-typedef typename __key_value_types<_Cp>::__map_value_type _PairT;
 public:
 _LIBCPP_INLINE_VISIBILITY
 __unordered_map_hasher()
@@ -457,7 +454,6 @@ template ::__map_value_type _PairT;
 public:
 _LIBCPP_INLINE_VISIBILITY
 __unordered_map_equal()
@@ -490,8 +486,6 @@ template 
 {
 _Pred __pred_;
-
-typedef typename __key_value_types<_Cp>::__map_value_type _PairT;
 public:
 _LIBCPP_INLINE_VISIBILITY
 __unordered_map_equal()
@@ -512,9 +506,6 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 bool operator()(const _Key& __x, const _Cp& __y) const
 {return __pred_(__x, __y.__cc.first);}
-  _LIBCPP_INLINE_VISIBILITY
-bool operator()(const _Key& __x, const _PairT& __y) const
-{return __pred_(__x, __y.first);}
 void swap(__unordered_map_equal&__y)
 _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
 {


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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-02-10 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 47520.
jlebar added a comment.

Per IRL discussion with echristo, updated so that we just bail as soon as one
subjob fails.


http://reviews.llvm.org/D16514

Files:
  lib/Driver/Compilation.cpp

Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
-if (ActionFailed(*AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 


Index: lib/Driver/Compilation.cpp
===
--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
-if (ActionFailed(*AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-10 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-10, at 13:25, Bob Wilson  wrote:
> 
> 
>> On Feb 10, 2016, at 12:59 PM, Tim Northover  wrote:
>> 
>> On 10 February 2016 at 12:52, Eric Fiselier  wrote:
>>> @Tim Are these tests in the clang test suite?
>> 
>> Yep, at http://llvm.org/git/test-suite.git.
>> 
>>> Marshall and I were just talking about removing  all 
>>> together. Could you explain who still uses it?
>> 
>> In the test-suite, it looks like it's just these two micro-benchmarks.
>> I doubt anyone would complain about converting them to use
>> std::unordered_map (especially since the underlying implementation
>> seems to be shared anyway).
>> 
>> Outside that, we seem to have a handful of internal users and Bob may
>> have ABI backwards-compatibility concerns (or not). I've added him
>> explicitly.
> 
> I will defer to Duncan on that question.

Removing ext/hash_map and ext/hash_set is a great idea.  I don't have
any ABI concerns with removing them, since they are both header-only.

Unfortunately, we still have users on libstdc++ that use ext/hash_set
and ext/hash_map, and deleting these would make migration to libc++
harder.  Can we hold off a little longer?  Feel free to file a PR and
assign it to me.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-02-10 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.

This works for me and I can't think of anything it's going to break so LGTM.

Thanks!

-eric


http://reviews.llvm.org/D16514



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


Re: [PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.

2016-02-10 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260448: Bail on compilation as soon as a job fails. 
(authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D16514?vs=47520&id=47525#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16514

Files:
  cfe/trunk/lib/Driver/Compilation.cpp

Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
-if (ActionFailed(*AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 


Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -163,39 +163,17 @@
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
-if (ActionFailed(*AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260448 - Bail on compilation as soon as a job fails.

2016-02-10 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Wed Feb 10 16:17:00 2016
New Revision: 260448

URL: http://llvm.org/viewvc/llvm-project?rev=260448&view=rev
Log:
Bail on compilation as soon as a job fails.

Previously we attempted to be smart; if one job failed, we'd run all
jobs that didn't depend on the failing job.

Problem is, this doesn't work well for e.g. CUDA compilation without
-save-temps.  In this case, the device-side and host-side Assemble
actions (which actually are responsible for preprocess, compile,
backend, and assemble, since we're not saving temps) are necessarily
distinct.  So our clever heuristic doesn't help us, and we repeat every
error message once for host and once for each device arch.

The main effect of this change, other than fixing CUDA, is that if you
pass multiple cc files to one instance of clang and you get a compile
error, we'll stop when the first cc1 job fails.

Reviewers: tra, echristo

Subscribers: jhen, cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=260448&r1=260447&r2=260448&view=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Feb 10 16:17:00 2016
@@ -163,39 +163,17 @@ int Compilation::ExecuteCommand(const Co
   return ExecutionFailed ? 1 : Res;
 }
 
-typedef SmallVectorImpl< std::pair > FailingCommandList;
-
-static bool ActionFailed(const Action *A,
- const FailingCommandList &FailingCommands) {
-
-  if (FailingCommands.empty())
-return false;
-
-  for (FailingCommandList::const_iterator CI = FailingCommands.begin(),
- CE = FailingCommands.end(); CI != CE; ++CI)
-if (A == &(CI->second->getSource()))
-  return true;
-
-  for (Action::const_iterator AI = A->begin(), AE = A->end(); AI != AE; ++AI)
-if (ActionFailed(*AI, FailingCommands))
-  return true;
-
-  return false;
-}
-
-static bool InputsOk(const Command &C,
- const FailingCommandList &FailingCommands) {
-  return !ActionFailed(&C.getSource(), FailingCommands);
-}
-
-void Compilation::ExecuteJobs(const JobList &Jobs,
-  FailingCommandList &FailingCommands) const {
+void Compilation::ExecuteJobs(
+const JobList &Jobs,
+SmallVectorImpl> &FailingCommands) const {
   for (const auto &Job : Jobs) {
-if (!InputsOk(Job, FailingCommands))
-  continue;
 const Command *FailingCommand = nullptr;
-if (int Res = ExecuteCommand(Job, FailingCommand))
+if (int Res = ExecuteCommand(Job, FailingCommand)) {
   FailingCommands.push_back(std::make_pair(Res, FailingCommand));
+  // Bail as soon as one command fails, so we don't output duplicate error
+  // messages if we die on e.g. the same file.
+  return;
+}
   }
 }
 


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


[PATCH] D17100: Remove unused ToolChain arg from Driver::ConstructPhaseAction and BuildAction.

2016-02-10 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: echristo.
jlebar added a subscriber: cfe-commits.

Actions don't depend on the toolchain; they get bound to a particular
toolchain via BindArch.

No functional changes.

http://reviews.llvm.org/D17100

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -510,8 +510,7 @@
   if (TC.getTriple().isOSBinFormatMachO())
 BuildUniversalActions(*C, C->getDefaultToolChain(), Inputs);
   else
-BuildActions(*C, C->getDefaultToolChain(), C->getArgs(), Inputs,
- C->getActions());
+BuildActions(*C, C->getArgs(), Inputs, C->getActions());
 
   if (CCCPrintPhases) {
 PrintActions(*C);
@@ -625,7 +624,7 @@
   if (TC.getTriple().isOSBinFormatMachO())
 BuildUniversalActions(C, TC, Inputs);
   else
-BuildActions(C, TC, C.getArgs(), Inputs, C.getActions());
+BuildActions(C, C.getArgs(), Inputs, C.getActions());
 
   BuildJobs(C);
 
@@ -1036,7 +1035,7 @@
 Archs.push_back(Args.MakeArgString(TC.getDefaultUniversalArchName()));
 
   ActionList SingleActions;
-  BuildActions(C, TC, Args, BAInputs, SingleActions);
+  BuildActions(C, Args, BAInputs, SingleActions);
 
   // Add in arch bindings for every top level action, as well as lipo and
   // dsymutil steps if needed.
@@ -1322,8 +1321,7 @@
   assert(C.getCudaDeviceToolChain() &&
  "Missing toolchain for device-side compilation.");
   ActionList CudaDeviceActions;
-  C.getDriver().BuildActions(C, *C.getCudaDeviceToolChain(), Args,
- CudaDeviceInputs, CudaDeviceActions);
+  C.getDriver().BuildActions(C, Args, CudaDeviceInputs, CudaDeviceActions);
   assert(GpuArchList.size() == CudaDeviceActions.size() &&
  "Failed to create actions for all devices");
 
@@ -1387,9 +1385,8 @@
   ActionList({FatbinAction}));
 }
 
-void Driver::BuildActions(Compilation &C, const ToolChain &TC,
-  DerivedArgList &Args, const InputList &Inputs,
-  ActionList &Actions) const {
+void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
+  const InputList &Inputs, ActionList &Actions) const {
   llvm::PrettyStackTraceString CrashInfo("Building compilation actions");
 
   if (!SuppressMissingInputWarning && Inputs.empty()) {
@@ -1516,7 +1513,7 @@
 continue;
 
   // Otherwise construct the appropriate action.
-  Current = ConstructPhaseAction(C, TC, Args, Phase, Current);
+  Current = ConstructPhaseAction(C, Args, Phase, Current);
 
   if (InputType == types::TY_CUDA && Phase == CudaInjectionPhase) {
 Current = buildCudaActions(C, Args, InputArg, Current, Actions);
@@ -1553,9 +1550,8 @@
   Args.ClaimAllArgs(options::OPT_cuda_host_only);
 }
 
-Action *Driver::ConstructPhaseAction(Compilation &C, const ToolChain &TC,
- const ArgList &Args, phases::ID Phase,
- Action *Input) const {
+Action *Driver::ConstructPhaseAction(Compilation &C, const ArgList &Args,
+ phases::ID Phase, Action *Input) const {
   llvm::PrettyStackTraceString CrashInfo("Constructing phase actions");
   // Build the appropriate action.
   switch (Phase) {
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -299,12 +299,10 @@
   /// given arguments, which are only done for a single architecture.
   ///
   /// \param C - The compilation that is being built.
-  /// \param TC - The default host tool chain.
   /// \param Args - The input arguments.
   /// \param Actions - The list to store the resulting actions onto.
-  void BuildActions(Compilation &C, const ToolChain &TC,
-llvm::opt::DerivedArgList &Args, const InputList &Inputs,
-ActionList &Actions) const;
+  void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args,
+const InputList &Inputs, ActionList &Actions) const;
 
   /// BuildUniversalActions - Construct the list of actions to perform
   /// for the given arguments, which may require a universal build.
@@ -376,9 +374,8 @@
   /// ConstructAction - Construct the appropriate action to do for
   /// \p Phase on the \p Input, taking in to account arguments
   /// like -fsyntax-only or --analyze.
-  Action *ConstructPhaseAction(Compilation &C, const ToolChain &TC,
-   const llvm::opt::ArgList &Args, phases::ID Phase,
-   Action *Input) const;
+  Action *ConstructPhaseAction(Compilation &C, const llvm::opt::ArgList &Args,
+   phases::ID Phase, Action *Input) const;
 
   /// BuildJobsForAction - Construct the jobs to pe

r260449 - Revert r260388 "[MS ABI] Never reference dllimport'd vtables"

2016-02-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Feb 10 16:18:37 2016
New Revision: 260449

URL: http://llvm.org/viewvc/llvm-project?rev=260449&view=rev
Log:
Revert r260388 "[MS ABI] Never reference dllimport'd vtables"

This caused the compiler to fail with "invalid linkage type
for global declaration" (PR26569).

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=260449&r1=260448&r2=260449&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed Feb 10 16:18:37 2016
@@ -2599,10 +2599,7 @@ void MicrosoftMangleContextImpl::mangleC
   // NOTE:  here is always 'B' (const). 
   // is always '6' for vftables.
   MicrosoftCXXNameMangler Mangler(*this, Out);
-  if (Derived->hasAttr())
-Mangler.getStream() << "\01??_S";
-  else
-Mangler.getStream() << "\01??_7";
+  Mangler.getStream() << "\01??_7";
   Mangler.mangleName(Derived);
   Mangler.getStream() << "6B"; // '6' for vftable, 'B' for const.
   for (const CXXRecordDecl *RD : BasePath)

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=260449&r1=260448&r2=260449&view=diff
==
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Wed Feb 10 16:18:37 2016
@@ -2548,6 +2548,7 @@ public:
 // Only include the RTTI component if we know that we will provide a
 // definition of the vftable.
 HasRTTIComponent = Context.getLangOpts().RTTIData &&
+   !MostDerivedClass->hasAttr() &&
MostDerivedClass->getTemplateSpecializationKind() !=
TSK_ExplicitInstantiationDeclaration;
 

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=260449&r1=260448&r2=260449&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Feb 10 16:18:37 2016
@@ -1673,16 +1673,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::g
   SmallString<256> VFTableName;
   mangleVFTableName(getMangleContext(), RD, VFPtr, VFTableName);
 
-  // Classes marked __declspec(dllimport) need vftables generated on the
-  // import-side in order to support features like constexpr.  No other
-  // translation unit relies on the emission of the local vftable, translation
-  // units are expected to generate them as needed.
-  //
-  // Because of this unique behavior, we maintain this logic here instead of
-  // getVTableLinkage.
-  llvm::GlobalValue::LinkageTypes VFTableLinkage =
-  RD->hasAttr() ? llvm::GlobalValue::LinkOnceODRLinkage
-   : CGM.getVTableLinkage(RD);
+  llvm::GlobalValue::LinkageTypes VFTableLinkage = CGM.getVTableLinkage(RD);
   bool VFTableComesFromAnotherTU =
   llvm::GlobalValue::isAvailableExternallyLinkage(VFTableLinkage) ||
   llvm::GlobalValue::isExternalLinkage(VFTableLinkage);
@@ -1755,7 +1746,9 @@ llvm::GlobalVariable *MicrosoftCXXABI::g
   if (C)
 VTable->setComdat(C);
 
-  if (RD->hasAttr())
+  if (RD->hasAttr())
+VFTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+  else if (RD->hasAttr())
 VFTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
 
   VFTablesMap[ID] = VFTable;

Modified: cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp?rev=260449&r1=260448&r2=260449&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-rtti.cpp Wed Feb 10 16:18:37 2016
@@ -4,8 +4,7 @@
 struct __declspec(dllimport) S {
   virtual void f() {}
 } s;
-// MSVC: [[VF_S:.*]] = private unnamed_addr constant [2 x i8*]
-// MSVC-DAG: @"\01??_SS@@6B@" = unnamed_addr alias i8*, getelementptr inbounds 
([2 x i8*], [2 x i8*]* [[VF_S]], i32 0, i32 1)
+// MSVC-DAG: @"\01??_7S@@6B@" = available_externally dllimport
 // MSVC-DAG: @"\01??_R0?AUS@@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R1A@?0A@EA@S@@8" = linkonce_odr
 // MSVC-DAG: @"\01??_R2S@@8" = linkonce_odr

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=260449&r1=260448&r2=260449&view=diff

Re: r260388 - [MS ABI] Never reference dllimport'd vtables

2016-02-10 Thread Hans Wennborg via cfe-commits
On Wed, Feb 10, 2016 at 9:40 AM, David Majnemer via cfe-commits
 wrote:
> Author: majnemer
> Date: Wed Feb 10 11:40:47 2016
> New Revision: 260388
>
> URL: http://llvm.org/viewvc/llvm-project?rev=260388&view=rev
> Log:
> [MS ABI] Never reference dllimport'd vtables
>
> Referencing a dllimported vtable is impossible in a constexpr
> constructor.  It would be friendlier to C++ programmers if we
> synthesized a copy of the vftable which referenced imported virtual
> functions.  This would let us initialize the object in a way which
> preserves both the intent to import functionality from another DLL while
> also making constexpr work.
>
> Differential Revision: http://reviews.llvm.org/D17061

I reverted this in r260449 as it caused PR26569.

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


Re: [libcxx] r260012 - Cleanup node-type handling in the unordered containers

2016-02-10 Thread Eric Fiselier via cfe-commits
> Can we hold off a little longer?

Yes we can. The entire point of the AFAIK was to encourage migration to
libc++ so it makes some
sense to keep them while they still serve this purpose.

When you say "a little longer" what sort of timeline do you have in mind?

It would be nice to get rid of these in the *long term*, but they aren't in
danger ATM.

/Eric


On Wed, Feb 10, 2016 at 3:17 PM, Duncan P. N. Exon Smith <
dexonsm...@apple.com> wrote:

>
> > On 2016-Feb-10, at 13:25, Bob Wilson  wrote:
> >
> >
> >> On Feb 10, 2016, at 12:59 PM, Tim Northover 
> wrote:
> >>
> >> On 10 February 2016 at 12:52, Eric Fiselier  wrote:
> >>> @Tim Are these tests in the clang test suite?
> >>
> >> Yep, at http://llvm.org/git/test-suite.git.
> >>
> >>> Marshall and I were just talking about removing  all
> together. Could you explain who still uses it?
> >>
> >> In the test-suite, it looks like it's just these two micro-benchmarks.
> >> I doubt anyone would complain about converting them to use
> >> std::unordered_map (especially since the underlying implementation
> >> seems to be shared anyway).
> >>
> >> Outside that, we seem to have a handful of internal users and Bob may
> >> have ABI backwards-compatibility concerns (or not). I've added him
> >> explicitly.
> >
> > I will defer to Duncan on that question.
>
> Removing ext/hash_map and ext/hash_set is a great idea.  I don't have
> any ABI concerns with removing them, since they are both header-only.
>
> Unfortunately, we still have users on libstdc++ that use ext/hash_set
> and ext/hash_map, and deleting these would make migration to libc++
> harder.  Can we hold off a little longer?  Feel free to file a PR and
> assign it to me.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17103: [CUDA] Don't crash when trying to printf a non-scalar object.

2016-02-10 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added reviewers: majnemer, rnk.
jlebar added subscribers: tra, jhen, cfe-commits.

We can't do the right thing, since there's no right thing to do, but at
least we can not crash the compiler.

http://reviews.llvm.org/D17103

Files:
  lib/CodeGen/CGCUDABuiltin.cpp
  test/CodeGenCUDA/printf.cu

Index: test/CodeGenCUDA/printf.cu
===
--- test/CodeGenCUDA/printf.cu
+++ test/CodeGenCUDA/printf.cu
@@ -41,3 +41,12 @@
 printf("%d", 42);
   }
 }
+
+// Check that we don't crash when asked to printf a non-scalar arg.
+struct Struct {
+  int x;
+  int y;
+};
+__device__ void PrintfNonScalar() {
+  printf("%d", Struct());
+}
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -83,6 +83,11 @@
E->arguments(), E->getDirectCallee(),
/* ParamsToSkip = */ 0);
 
+  // We don't know how to emit non-scalar varargs, so just remove them.
+  Args.erase(std::remove_if(Args.begin() + 1, Args.end(),
+[](const CallArg &A) { return !A.RV.isScalar(); }),
+ Args.end());
+
   // Construct and fill the args buffer that we'll pass to vprintf.
   llvm::Value *BufferPtr;
   if (Args.size() <= 1) {


Index: test/CodeGenCUDA/printf.cu
===
--- test/CodeGenCUDA/printf.cu
+++ test/CodeGenCUDA/printf.cu
@@ -41,3 +41,12 @@
 printf("%d", 42);
   }
 }
+
+// Check that we don't crash when asked to printf a non-scalar arg.
+struct Struct {
+  int x;
+  int y;
+};
+__device__ void PrintfNonScalar() {
+  printf("%d", Struct());
+}
Index: lib/CodeGen/CGCUDABuiltin.cpp
===
--- lib/CodeGen/CGCUDABuiltin.cpp
+++ lib/CodeGen/CGCUDABuiltin.cpp
@@ -83,6 +83,11 @@
E->arguments(), E->getDirectCallee(),
/* ParamsToSkip = */ 0);
 
+  // We don't know how to emit non-scalar varargs, so just remove them.
+  Args.erase(std::remove_if(Args.begin() + 1, Args.end(),
+[](const CallArg &A) { return !A.RV.isScalar(); }),
+ Args.end());
+
   // Construct and fill the args buffer that we'll pass to vprintf.
   llvm::Value *BufferPtr;
   if (Args.size() <= 1) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >