[clang-tools-extra] [clang-apply-replacements] Apply format only if --format is specified (PR #70801)

2023-11-23 Thread Malcolm Parsons via cfe-commits

pepsiman wrote:

`createReplacementsForHeaders()` is applying a cleanup without checking the 
`Cleanup` flag.
But clang-apply-replacements always sets `Cleanup` to `true` anyway.
The change looks good to me, but it might be working around a bug elsewhere.

https://github.com/llvm/llvm-project/pull/70801
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5389a05 - [docs] Fix documentation for bugprone-dangling-handle

2021-05-12 Thread Malcolm Parsons via cfe-commits

Author: Malcolm Parsons
Date: 2021-05-12T17:20:15+01:00
New Revision: 5389a05836e74e3acab6dbda7e80ea43e3bc6304

URL: 
https://github.com/llvm/llvm-project/commit/5389a05836e74e3acab6dbda7e80ea43e3bc6304
DIFF: 
https://github.com/llvm/llvm-project/commit/5389a05836e74e3acab6dbda7e80ea43e3bc6304.diff

LOG: [docs] Fix documentation for bugprone-dangling-handle

string_view isn't experimental anymore.
This check has always handled both forms.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-dangling-handle.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-dangling-handle.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-dangling-handle.rst
index 8c2c316c090da..701b67d77acaa 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-dangling-handle.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-dangling-handle.rst
@@ -3,8 +3,7 @@
 bugprone-dangling-handle
 
 
-Detect dangling references in value handles like
-``std::experimental::string_view``.
+Detect dangling references in value handles like ``std::string_view``.
 These dangling references can be a result of constructing handles from 
temporary
 values, where the temporary is destroyed soon after the handle is created.
 
@@ -35,4 +34,5 @@ Options
 .. option:: HandleClasses
 
A semicolon-separated list of class names that should be treated as handles.
-   By default only ``std::experimental::basic_string_view`` is considered.
+   By default only ``std::basic_string_view`` and
+   ``std::experimental::basic_string_view`` are considered.



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


[clang-tools-extra] 35f2c3a - [clang-tidy] cppcoreguidelines-pro-type-member-init: suppress warning for default member funcs

2020-12-20 Thread Malcolm Parsons via cfe-commits

Author: Chris Warner
Date: 2020-12-20T11:22:41Z
New Revision: 35f2c3a8b41fd3b6ef88d013a7c3ed9478b765e4

URL: 
https://github.com/llvm/llvm-project/commit/35f2c3a8b41fd3b6ef88d013a7c3ed9478b765e4
DIFF: 
https://github.com/llvm/llvm-project/commit/35f2c3a8b41fd3b6ef88d013a7c3ed9478b765e4.diff

LOG: [clang-tidy] cppcoreguidelines-pro-type-member-init: suppress warning for 
default member funcs

Modify the cppcoreguidelines-pro-type-member-init checker to ignore warnings 
from the move and copy-constructors when they are compiler defined with `= 
default` outside of the type declaration.

Reported as [LLVM bug 36819](https://bugs.llvm.org/show_bug.cgi?id=36819)

Reviewed By: malcolm.parsons

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index a223d215af1b..67856be843e7 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -297,6 +297,10 @@ void ProTypeMemberInitCheck::check(const 
MatchFinder::MatchResult ) {
 // Skip declarations delayed by late template parsing without a body.
 if (!Ctor->getBody())
   return;
+// Skip out-of-band explicitly defaulted special member functions
+// (except the default constructor).
+if (Ctor->isExplicitlyDefaulted() && !Ctor->isDefaultConstructor())
+  return;
 checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
 checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), 
Ctor);
   } else if (const auto *Record =

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
index 28230dd6952e..403f28baf99d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp
@@ -501,3 +501,19 @@ struct NegativeImplicitInheritedCtor : 
NegativeImplicitInheritedCtorBase {
 void Bug33557() {
   NegativeImplicitInheritedCtor I(5);
 }
+
+struct NegativeDefaultedCtorOutOfDecl {
+  NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &);
+  int F;
+};
+
+NegativeDefaultedCtorOutOfDecl::NegativeDefaultedCtorOutOfDecl(const 
NegativeDefaultedCtorOutOfDecl &) = default;
+
+struct PositiveDefaultConstructorOutOfDecl {
+  PositiveDefaultConstructorOutOfDecl();
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = 
default;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F



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


[clang-tools-extra] 9738c75 - [clang-tidy] Match InitListExpr in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via cfe-commits

Author: Malcolm Parsons
Date: 2020-01-14T15:19:37Z
New Revision: 9738c757bd9bc2fdca935f2b4e356f1d5e5f3682

URL: 
https://github.com/llvm/llvm-project/commit/9738c757bd9bc2fdca935f2b4e356f1d5e5f3682
DIFF: 
https://github.com/llvm/llvm-project/commit/9738c757bd9bc2fdca935f2b4e356f1d5e5f3682.diff

LOG: [clang-tidy] Match InitListExpr in modernize-use-default-member-init

Summary:
modernize-use-default-member-init wasn't warning about redundant initialisers
when the initialiser was an InitListExpr.  Add initListExpr to the matcher.

Fixes: PR44439

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index e99a90ffba57..5d62e5446f6a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -201,7 +201,7 @@ void 
UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr(to(enumConstantDecl(;
+initListExpr(), declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
index 0dffeea1c9b7..196eec91b8e8 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -247,24 +247,24 @@ struct NegativeDefaultArg
 };
 
 struct ExistingChar {
-  ExistingChar(short) : e1(), e2(), e3(), e4() {}
+  ExistingChar(short) : e1(), e2{}, e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(short) :  e4() {}
-  ExistingChar(int) : e1(0), e2(0), e3(0), e4(0) {}
+  ExistingChar(int) : e1(0), e2{0}, e3(0), e4(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(int) :  e4(0) {}
-  ExistingChar(long) : e1('\0'), e2('\0'), e3('\0'), e4('\0') {}
+  ExistingChar(long) : e1('\0'), e2{'\0'}, e3('\0'), e4('\0') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:44: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(long) :  e4('\0') {}
-  ExistingChar(char) : e1('a'), e2('a'), e3('a'), e4('a') {}
+  ExistingChar(char) : e1('a'), e2{'a'}, e3('a'), e4('a') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: member initializer for 'e4' is 
redundant
-  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2('a'), e3('a') {}
+  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2{'a'}, e3('a') {}
   char e1{};
   char e2 = 0;
   char e3 = '\0';
@@ -272,22 +272,22 @@ struct ExistingChar {
 };
 
 struct ExistingInt {
-  ExistingInt(short) : e1(), e2(), e3(), e4(), e5(), e6() {}
+  ExistingInt(short) : e1(), e2{}, e3(), e4(), e5(), e6() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is 
redundant
   // CHECK-FIXES: ExistingInt(short) :  e3(), e4(), e5(), e6() {}
-  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0), e5(0), e6(0) {}
+  ExistingInt(int) : e1(0), e2{0}, e3(0), e4(0), e5(0), e6(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is 
redundant
   // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0), e5(0), e6(0) {}
-  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5), e5(5), e6(5) {}
+  

[clang-tools-extra] 45924eb - [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via cfe-commits

Author: Malcolm Parsons
Date: 2020-01-14T10:05:12Z
New Revision: 45924eb4671692b3fa9fd52fe39c81ec0647a848

URL: 
https://github.com/llvm/llvm-project/commit/45924eb4671692b3fa9fd52fe39c81ec0647a848
DIFF: 
https://github.com/llvm/llvm-project/commit/45924eb4671692b3fa9fd52fe39c81ec0647a848.diff

LOG: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

Summary:
Initialising a pointer from nullptr involves an implicit cast.
Ignore it after getting initialiser from InitListExpr.

Fixes: PR0

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index 1e59acb1ff17..e99a90ffba57 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@ static const Expr *ignoreUnaryPlus(const Expr *E) {
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
index 5af9855835ca..0dffeea1c9b7 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@ struct ExistingInt {
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@ struct ExistingDouble {
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@ struct ExistingBool {
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@ struct ExistingPointer {
   // CHECK-FIXES: ExistingPointer(long) :  e4() {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = 
 };
 



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


[clang-tools-extra] r353554 - [clang-tidy] Don't use assignment for value-initialized enums

2019-02-08 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Feb  8 11:44:42 2019
New Revision: 353554

URL: http://llvm.org/viewvc/llvm-project?rev=353554=rev
Log:
[clang-tidy] Don't use assignment for value-initialized enums

Summary:
The modernize-use-default-member-init check crashes when trying to
create an assignment value for a value-initialized enum because it isn't a
BuiltinType.
An enum cannot be initialized by assigning 0 to it unless a cast is added.
It could be initialized with an enumerator with the value 0, but there might not
be one.
Avoid these issues by ignoring the UseAssignment setting for value-initialized
enums.

Fixes PR35050.

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=353554=353553=353554=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Fri Feb  8 11:44:42 2019
@@ -255,17 +255,20 @@ void UseDefaultMemberInitCheck::checkDef
   CharSourceRange InitRange =
   CharSourceRange::getCharRange(LParenEnd, Init->getRParenLoc());
 
+  bool ValueInit = isa(Init->getInit());
+  bool CanAssign = UseAssignment && (!ValueInit || 
!Init->getInit()->getType()->isEnumeralType());
+
   auto Diag =
   diag(Field->getLocation(), "use default member initializer for %0")
   << Field
-  << FixItHint::CreateInsertion(FieldEnd, UseAssignment ? " = " : "{")
+  << FixItHint::CreateInsertion(FieldEnd, CanAssign ? " = " : "{")
   << FixItHint::CreateInsertionFromRange(FieldEnd, InitRange);
 
-  if (UseAssignment && isa(Init->getInit()))
+  if (CanAssign && ValueInit)
 Diag << FixItHint::CreateInsertion(
 FieldEnd, getValueOfValueInit(Init->getInit()->getType()));
 
-  if (!UseAssignment)
+  if (!CanAssign)
 Diag << FixItHint::CreateInsertion(FieldEnd, "}");
 
   Diag << FixItHint::CreateRemoval(Init->getSourceRange());

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp?rev=353554=353553=353554=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 Fri Feb  8 11:44:42 2019
@@ -166,6 +166,14 @@ struct PositiveEnum {
   // CHECK-FIXES: Enum e = Foo;
 };
 
+struct PositiveValueEnum {
+  PositiveValueEnum() : e() {}
+  // CHECK-FIXES: PositiveValueEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer 
for 'e'
+  // CHECK-FIXES: Enum e{};
+};
+
 struct PositiveString {
   PositiveString() : s("foo") {}
   // CHECK-FIXES: PositiveString()  {}

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=353554=353553=353554=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Fri Feb  8 11:44:42 2019
@@ -165,6 +165,14 @@ struct PositiveEnum {
   // CHECK-FIXES: Enum e{Foo};
 };
 
+struct PositiveValueEnum {
+  PositiveValueEnum() : e() {}
+  // CHECK-FIXES: PositiveValueEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer 
for 'e'
+  // CHECK-FIXES: Enum e{};
+};
+
 struct PositiveString {
   PositiveString() : s("foo") {}
   // CHECK-FIXES: PositiveString()  {}


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


[clang-tools-extra] r353092 - [clang-tidy] Handle unions with existing default-member-init

2019-02-04 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Feb  4 13:09:31 2019
New Revision: 353092

URL: http://llvm.org/viewvc/llvm-project?rev=353092=rev
Log:
[clang-tidy] Handle unions with existing default-member-init

Summary:
clang-tidy's modernize-use-default-member-init was crashing for unions
with an existing default member initializer.

Fixes PR40492

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: JonasToth, riccibruno, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=353092=353091=353092=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Mon Feb  4 13:09:31 2019
@@ -273,7 +273,7 @@ void UseDefaultMemberInitCheck::checkDef
 
 void UseDefaultMemberInitCheck::checkExistingInit(
 const MatchFinder::MatchResult , const CXXCtorInitializer *Init) {
-  const FieldDecl *Field = Init->getMember();
+  const FieldDecl *Field = Init->getAnyMember();
 
   if (!sameValue(Field->getInClassInitializer(), Init->getInit()))
 return;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=353092=353091=353092=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Mon Feb  4 13:09:31 2019
@@ -382,6 +382,16 @@ struct ExistingString {
   const char *e4 = "bar";
 };
 
+struct UnionExisting {
+  UnionExisting() : e(5.0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member initializer for 'e' is 
redundant
+  // CHECK-FIXES: UnionExisting()  {}
+  union {
+int i;
+double e = 5.0;
+  };
+};
+
 template 
 struct NegativeTemplateExisting {
   NegativeTemplateExisting(int) : t(0) {}


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


[clang-tools-extra] r347671 - [clang-tidy] Ignore bool -> single bit bitfield conversion in readability-implicit-bool-conversion

2018-11-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Nov 27 08:23:39 2018
New Revision: 347671

URL: http://llvm.org/viewvc/llvm-project?rev=347671=rev
Log:
[clang-tidy] Ignore bool -> single bit bitfield conversion in 
readability-implicit-bool-conversion

Summary: There is no ambiguity / information loss in this conversion

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
Tue Nov 27 08:23:39 2018
@@ -306,6 +306,11 @@ void ImplicitBoolConversionCheck::regist
   auto boolOpAssignment =
   binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")),
  hasLHS(expr(hasType(booleanType();
+  auto bitfieldAssignment = binaryOperator(
+  hasLHS(memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1));
+  auto bitfieldConstruct = cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
+  withInitializer(equalsBoundNode("implicitCastFromBool")),
+  forField(hasBitWidth(1);
   Finder->addMatcher(
   implicitCastExpr(
   implicitCastFromBool,
@@ -313,14 +318,15 @@ void ImplicitBoolConversionCheck::regist
   // in such context:
   //   bool_expr_a == bool_expr_b
   //   bool_expr_a != bool_expr_b
-  unless(hasParent(binaryOperator(
-  anyOf(boolComparison, boolXor, boolOpAssignment,
+  unless(hasParent(binaryOperator(anyOf(
+  boolComparison, boolXor, boolOpAssignment, 
bitfieldAssignment,
+  implicitCastExpr().bind("implicitCastFromBool"),
+  unless(hasParent(bitfieldConstruct)),
   // Check also for nested casts, for example: bool -> int -> float.
   anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
 anything()),
   unless(isInTemplateInstantiation()),
-  unless(hasAncestor(functionTemplateDecl(
-  .bind("implicitCastFromBool"),
+  unless(hasAncestor(functionTemplateDecl(,
   this);
 }
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-implicit-bool-conversion.rst
 Tue Nov 27 08:23:39 2018
@@ -74,7 +74,8 @@ In general, the following conversion typ
 
 - pointer/pointer to member/``nullptr``/``NULL`` to boolean,
 
-- boolean expression/literal to integer,
+- boolean expression/literal to integer (conversion from boolean to a single
+  bit bitfield is explicitly allowed),
 
 - boolean expression/literal to floating.
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp?rev=347671=347670=347671=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-conversion.cpp
 Tue Nov 27 08:23:39 2018
@@ -444,14 +444,27 @@ struct S {
   int a;
   int b : 1;
   int c : 2;
+
+  S(bool a, bool b, bool c) : a(a), b(b), c(c) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: implicit conversion bool -> 
'int'
+  // CHECK-MESSAGES: :[[@LINE-2]]:45: warning: implicit conversion bool -> 
'int'
+  // CHECK-FIXES: S(bool a, bool b, bool c) : a(static_cast(a)), b(b), 
c(static_cast(c)) {}
 };
 
-bool f(const S& s) {
+bool f(S& s) {
   functionTaking(s.a);
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: implicit conversion 'int' -> 
bool
   // CHECK-FIXES: functionTaking(s.a != 0);
   functionTaking(s.b);
   // CHECK-FIXES: functionTaking(s.b);
+  s.a = true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: implicit conversion bool -> 'int'
+  // CHECK-FIXES: 

Re: r337152 - [Sema] Reword warning for constant captures that are not required

2018-07-17 Thread Malcolm Parsons via cfe-commits
On Mon, 16 Jul 2018 at 10:57, Benjamin Kramer via cfe-commits
 wrote:
> -  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
> expected-warning{{lambda capture 'i' is not required to be captured for this 
> use}}
> +  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
> expected-warning{{lambda capture of constant 'i' is not required for this 
> use}}

i is not a constant:

  int i = 0;

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


r331361 - [analyzer] Fix filename in cross-file HTML report

2018-05-02 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed May  2 07:26:12 2018
New Revision: 331361

URL: http://llvm.org/viewvc/llvm-project?rev=331361=rev
Log:
[analyzer] Fix filename in cross-file HTML report

Summary:
The filename is currently taken from the start of the path, while the
line and column are taken from the end of the path.
This didn't matter until cross-file path reporting was added.

Reviewers: george.karpenkov, dcoughlin, vlad.tsyrklevich

Reviewed By: george.karpenkov, vlad.tsyrklevich

Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/test/Coverage/html-multifile-diagnostics.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=331361=331360=331361=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Wed May  2 07:26:12 
2018
@@ -321,7 +321,9 @@ std::string HTMLDiagnostics::GenerateHTM
 return {};
 
   // Add CSS, header, and footer.
-  const FileEntry* Entry = SMgr.getFileEntryForID(FileIDs[0]);
+  FileID FID =
+  path.back()->getLocation().asLocation().getExpansionLoc().getFileID();
+  const FileEntry* Entry = SMgr.getFileEntryForID(FID);
   FinalizeHTML(D, R, SMgr, path, FileIDs[0], Entry, declName);
 
   std::string file;

Modified: cfe/trunk/test/Coverage/html-multifile-diagnostics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/html-multifile-diagnostics.c?rev=331361=331360=331361=diff
==
--- cfe/trunk/test/Coverage/html-multifile-diagnostics.c (original)
+++ cfe/trunk/test/Coverage/html-multifile-diagnostics.c Wed May  2 07:26:12 
2018
@@ -4,6 +4,8 @@
 
 // REQUIRES: staticanalyzer
 
+// CHECK: 
+
 // CHECK: Annotated Source Code
 
 // Make sure it's generated as multi-file HTML output


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


r330112 - Clean carriage returns from lib/ and include/. NFC.

2018-04-16 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Apr 16 01:31:08 2018
New Revision: 330112

URL: http://llvm.org/viewvc/llvm-project?rev=330112=rev
Log:
Clean carriage returns from lib/ and include/. NFC.

Summary:
Clean carriage returns from lib/ and include/. NFC.
(I have to make this change locally in order for `git diff` to show sane output 
after I edit a file, so I might as well ask for it to be committed. I don't 
have commit privs myself.)
(Without this patch, `git rebase`ing any change involving SemaDeclCXX.cpp is a 
real nightmare. :( So while I have no right to ask for this to be committed, 
geez would it make my workflow easier if it were.)

Here's the command I used to reformat things. (Requires bash and OSX/FreeBSD 
sed.)

git grep -l $'\r' lib include | xargs sed -i -e $'s/\r//'
find lib include -name '*-e' -delete

Reviewers: malcolm.parsons

Reviewed By: malcolm.parsons

Subscribers: emaste, krytarowski, cfe-commits

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

Patch by Arthur O'Dwyer.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=330112=330111=330112=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Mon Apr 16 01:31:08 2018
@@ -2213,14 +2213,14 @@ void ASTDumper::VisitArrayInitIndexExpr(
 }
 
 void ASTDumper::VisitUnaryOperator(const UnaryOperator *Node) {
-  VisitExpr(Node);
-  OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
- << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
-  if (!Node->canOverflow())
-OS << " cannot overflow";
-}
-
-void ASTDumper::VisitUnaryExprOrTypeTraitExpr(
+  VisitExpr(Node);
+  OS << " " << (Node->isPostfix() ? "postfix" : "prefix")
+ << " '" << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
+  if (!Node->canOverflow())
+OS << " cannot overflow";
+}
+
+void ASTDumper::VisitUnaryExprOrTypeTraitExpr(
 const UnaryExprOrTypeTraitExpr *Node) {
   VisitExpr(Node);
   switch(Node->getKind()) {

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=330112=330111=330112=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Apr 16 01:31:08 2018
@@ -3328,12 +3328,12 @@ static bool handleAssignment(EvalInfo 
   }
 
   CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType);
-  return Obj && modifySubobject(Info, E, Obj, LVal.Designator, Val);
-}
-
-namespace {
-struct CompoundAssignSubobjectHandler {
-  EvalInfo 
+  return Obj && modifySubobject(Info, E, Obj, LVal.Designator, Val);
+}
+
+namespace {
+struct CompoundAssignSubobjectHandler {
+  EvalInfo 
   const Expr *E;
   QualType PromotedLHSType;
   BinaryOperatorKind Opcode;
@@ -3449,13 +3449,13 @@ static bool handleCompoundAssignment(
   return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
 }
 
-namespace {
-struct IncDecSubobjectHandler {
-  EvalInfo 
-  const UnaryOperator *E;
-  AccessKinds AccessKind;
-  APValue *Old;
-
+namespace {
+struct IncDecSubobjectHandler {
+  EvalInfo 
+  const UnaryOperator *E;
+  AccessKinds AccessKind;
+  APValue *Old;
+
   typedef bool result_type;
 
   bool checkConst(QualType QT) {
@@ -3521,20 +3521,20 @@ struct IncDecSubobjectHandler {
 }
 
 bool WasNegative = Value.isNegative();
-if (AccessKind == AK_Increment) {
-  ++Value;
-
-  if (!WasNegative && Value.isNegative() && E->canOverflow()) {
-APSInt ActualValue(Value, /*IsUnsigned*/true);
-return HandleOverflow(Info, E, ActualValue, SubobjType);
-  }
-} else {
-  --Value;
-
-  if (WasNegative && !Value.isNegative() && E->canOverflow()) {
-unsigned BitWidth = Value.getBitWidth();
-APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false);
-ActualValue.setBit(BitWidth);
+if (AccessKind == AK_Increment) {
+  ++Value;
+
+  if (!WasNegative && Value.isNegative() && E->canOverflow()) {
+APSInt ActualValue(Value, /*IsUnsigned*/true);
+return HandleOverflow(Info, E, ActualValue, SubobjType);
+  }
+} else {
+  --Value;
+
+  if (WasNegative && !Value.isNegative() && E->canOverflow()) {
+unsigned BitWidth = Value.getBitWidth();
+APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false);
+ActualValue.setBit(BitWidth);
 return HandleOverflow(Info, E, 

Re: r330068 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-04-14 Thread Malcolm Parsons via cfe-commits
On Sat, 14 Apr 2018, 14:16 Kim Gräsman,  wrote:

> That would be a nice outcome of all the "run-tools-on-llvm" changes if any
> problems were filed as bugs on the tools. We have a number of them filed on
> iwyu, and they make for nice, concrete bugs to troubleshoot even if we
> don't always know how to fix them.
>
> For this specific clang-tidy issue, do you have any ideas for how to tell
> this loop apart from any other? I'm guessing the container is modified
> while iterating... Or do you mean skip all non-iterator loops?
>

Non-iterator, mutable container, size checked each iteration.

Clang-tidy could suggest modernisation, but not automatically fix.

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


Re: r330068 - [Serialization] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-04-14 Thread Malcolm Parsons via cfe-commits
On Sat, 14 Apr 2018, 04:22 Richard Trieu via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> I was tracking down a similar issue to the lldb issue before noticing the
> change was reverted.  The bad change that lead to it is:
>
>  // Load pending declaration chains.
> -for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
> -  loadPendingDeclChain(PendingDeclChains[I].first,
> PendingDeclChains[I].second);
> +for (const auto  : PendingDeclChains)
> +  loadPendingDeclChain(I.first, I.second);
>  PendingDeclChains.clear();
>
> Although the two looks like similar, the vector PendingDeclChains is a
> class member and gets new elements during loop runs.  Once enough elements
> are added to the vector, it get reallocated to a larger memory, but the
> loop is still trying to process the old, now freed, memory.  Using an index
> and checking the size every loop is the right way to process this vector.
>

Should clang-tidy handle this type of loop differently?

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


r329914 - Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-04-12 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Apr 12 07:48:48 2018
New Revision: 329914

URL: http://llvm.org/viewvc/llvm-project?rev=329914=rev
Log:
Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

Summary:
This patch adds two new diagnostics, which are off by default:

**-Wreturn-std-move**

This diagnostic is enabled by `-Wreturn-std-move`, `-Wmove`, or `-Wall`.
Diagnose cases of `return x` or `throw x`, where `x` is the name of a local 
variable or parameter, in which a copy operation is performed when a move 
operation would have been available. The user probably expected a move, but 
they're not getting a move, perhaps because the type of "x" is different from 
the return type of the function.
A place where this comes up in the wild is `stdext::inplace_function` 
which implements conversion via a conversion operator rather than a converting 
constructor; see https://github.com/WG21-SG14/SG14/issues/125#issue-297201412
Another place where this has come up in the wild, but where the fix ended up 
being different, was

try { ... } catch (ExceptionType ex) {
throw ex;
}

where the appropriate fix in that case was to replace `throw ex;` with 
`throw;`, and incidentally to catch by reference instead of by value. (But one 
could contrive a scenario where the slicing was intentional, in which case 
throw-by-move would have been the appropriate fix after all.)
Another example (intentional slicing to a base class) is dissected in 
https://github.com/accuBayArea/Slides/blob/master/slides/2018-03-07.pdf

**-Wreturn-std-move-in-c++11**

This diagnostic is enabled only by the exact spelling 
`-Wreturn-std-move-in-c++11`.
Diagnose cases of "return x;" or "throw x;" which in this version of Clang *do* 
produce moves, but which prior to Clang 3.9 / GCC 5.1 produced copies instead. 
This is useful in codebases which care about portability to those older 
compilers.
The name "-in-c++11" is not technically correct; what caused the 
version-to-version change in behavior here was actually CWG 1579, not C++14. I 
think it's likely that codebases that need portability to GCC 4.9-and-earlier 
may understand "C++11" as a colloquialism for "older compilers." The wording of 
this diagnostic is based on feedback from @rsmith.

**Discussion**

Notice that this patch is kind of a negative-space version of Richard Trieu's 
`-Wpessimizing-move`. That diagnostic warns about cases of `return 
std::move(x)` that should be `return x` for speed. These diagnostics warn about 
cases of `return x` that should be `return std::move(x)` for speed. (The two 
diagnostics' bailiwicks do not overlap: we don't have to worry about a `return` 
statement flipping between the two states indefinitely.)

I propose to write a paper for San Diego that would relax the implicit-move 
rules so that in C++2a the user //would// see the moves they expect, and the 
diagnostic could be re-worded in a later version of Clang to suggest explicit 
`std::move` only "in C++17 and earlier." But in the meantime (and/or forever if 
that proposal is not well received), this diagnostic will be useful to detect 
accidental copy operations.

Reviewers: rtrieu, rsmith

Reviewed By: rsmith

Subscribers: lebedev.ri, Rakete, rsmith, cfe-commits

Tags: #clang

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

Patch by Arthur O'Dwyer.

Added:
cfe/trunk/test/SemaCXX/warn-return-std-move.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=329914=329913=329914=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Apr 12 07:48:48 2018
@@ -383,7 +383,11 @@ def DeprecatedObjCIsaUsage : DiagGroup<"
 def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">;
 def Packed : DiagGroup<"packed">;
 def Padded : DiagGroup<"padded">;
+
 def PessimizingMove : DiagGroup<"pessimizing-move">;
+def ReturnStdMoveInCXX11 : DiagGroup<"return-std-move-in-c++11">;
+def ReturnStdMove : DiagGroup<"return-std-move">;
+
 def PointerArith : DiagGroup<"pointer-arith">;
 def PoundWarning : DiagGroup<"#warnings">;
 def PoundPragmaMessage : DiagGroup<"#pragma-messages">,
@@ -723,7 +727,12 @@ def IntToVoidPointerCast : DiagGroup<"in
 def IntToPointerCast : DiagGroup<"int-to-pointer-cast",
  [IntToVoidPointerCast]>;
 
-def Move : DiagGroup<"move", [PessimizingMove, RedundantMove, SelfMove]>;
+def Move : DiagGroup<"move", [
+PessimizingMove,
+RedundantMove,
+ReturnStdMove,
+SelfMove
+  ]>;
 
 def Extra : DiagGroup<"extra", [
 

[clang-tools-extra] r329813 - [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Apr 11 07:39:17 2018
New Revision: 329813

URL: http://llvm.org/viewvc/llvm-project?rev=329813=rev
Log:
[clang-apply-replacements] Convert tooling::Replacements to 
tooling::AtomicChange for conflict resolving of changes, code cleanup, and code 
formatting.

Summary:
By converting Replacements by AtomicChange, clang-apply-replacements is able 
like clang-tidy to automatically cleanup and format changes.
This should permits to close this ticket: 
https://bugs.llvm.org/show_bug.cgi?id=35051 and attempt to follow hints from 
https://reviews.llvm.org/D43500 comments.

Reviewers: klimek, ioeric

Reviewed By: ioeric

Subscribers: malcolm.parsons, mgorny, cfe-commits

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

Patch by Jeremy Demeule.

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/identical.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/expected.txt

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/identical.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/order-dependent.cpp
Removed:

clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt

clang-tools-extra/trunk/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=329813=329812=329813=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 Wed Apr 11 07:39:17 2018
@@ -18,6 +18,7 @@
 
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -29,15 +30,8 @@ namespace clang {
 class DiagnosticsEngine;
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // end namespace format
-
 namespace replace {
 
-/// \brief Collection of source ranges.
-typedef std::vector RangeVector;
-
 /// \brief Collection of TranslationUnitReplacements.
 typedef std::vector 
TUReplacements;
 
@@ -47,10 +41,10 @@ typedef std::vector TURepla
 /// \brief Collection of TranslationUniDiagnostics.
 typedef std::vector TUDiagnostics;
 
-/// \brief Map mapping file name to Replacements targeting that file.
+/// \brief Map mapping file name to a set of AtomicChange targeting that file.
 typedef llvm::DenseMap>
-FileToReplacementsMap;
+   std::vector>
+FileToChangesMap;
 
 /// \brief Recursively descends through a directory structure rooted at \p
 /// Directory and attempts to deserialize *.yaml files as
@@ -77,65 +71,39 @@ std::error_code collectReplacementsFromD
 const llvm::StringRef Directory, TUDiagnostics ,
 TUReplacementFiles , clang::DiagnosticsEngine );
 
-/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
-/// in \c TUs. If conflicts occur, no Replacements are applied.
+/// \brief Deduplicate, check for conflicts, and extract all Replacements 
stored
+/// in \c TUs. Conflicting replacements are skipped.
 ///
-/// \post For all (key,value) in GroupedReplacements, value[i].getOffset() <=
+/// \post For all (key,value) in FileChanges, value[i].getOffset() <=
 /// value[i+1].getOffset().
 ///
 /// \param[in] TUs Collection of TranslationUnitReplacements or
-/// TranslationUnitDiagnostics to merge,
-/// 

r323316 - Fix typos of occurred and occurrence

2018-01-24 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Jan 24 02:26:09 2018
New Revision: 323316

URL: http://llvm.org/viewvc/llvm-project?rev=323316=rev
Log:
Fix typos of occurred and occurrence

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
cfe/trunk/include/clang/Tooling/Core/Diagnostic.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/test/Driver/hexagon-hvx.c
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=323316=323315=323316=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Jan 24 02:26:09 2018
@@ -1590,7 +1590,7 @@ the configuration (without a prefix: ``A
   precedence over a matching enclosing function name for determining the
   language of the raw string contents.
 
-  If a canonical delimiter is specified, occurences of other delimiters for
+  If a canonical delimiter is specified, occurrences of other delimiters for
   the same language will be updated to the canonical if possible.
 
   There should be at most one specification per language and each delimiter

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=323316=323315=323316=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Wed Jan 24 02:26:09 2018
@@ -351,7 +351,7 @@ struct FilenamePatternConstraint {
 /// Analyzes the pattern of the referenced variables in a statement.
 class VariablePattern {
 
-  /// Describes an occurence of a variable reference in a statement.
+  /// Describes an occurrence of a variable reference in a statement.
   struct VariableOccurence {
 /// The index of the associated VarDecl in the Variables vector.
 size_t KindID;
@@ -362,7 +362,7 @@ class VariablePattern {
 : KindID(KindID), Mention(Mention) {}
   };
 
-  /// All occurences of referenced variables in the order of appearance.
+  /// All occurrences of referenced variables in the order of appearance.
   std::vector Occurences;
   /// List of referenced variables in the order of appearance.
   /// Every item in this list is unique.

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=323316=323315=323316=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Jan 24 02:26:09 2018
@@ -1395,7 +1395,7 @@ struct FormatStyle {
   /// precedence over a matching enclosing function name for determining the
   /// language of the raw string contents.
   ///
-  /// If a canonical delimiter is specified, occurences of other delimiters for
+  /// If a canonical delimiter is specified, occurrences of other delimiters 
for
   /// the same language will be updated to the canonical if possible.
   ///
   /// There should be at most one specification per language and each delimiter

Modified: cfe/trunk/include/clang/Lex/VariadicMacroSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/VariadicMacroSupport.h?rev=323316=323315=323316=diff
==
--- cfe/trunk/include/clang/Lex/VariadicMacroSupport.h (original)
+++ cfe/trunk/include/clang/Lex/VariadicMacroSupport.h Wed Jan 24 02:26:09 2018
@@ -55,7 +55,7 @@ namespace clang {
 
 /// Client code should call this function as soon as the Preprocessor has
 /// either completed lexing the macro's definition tokens, or an error
-/// occured and the context is being exited.  This function is idempotent
+/// occurred and the context is being exited.  This function is idempotent
 /// (might be explicitly called, and then reinvoked via the destructor).
 void exitScope() {
   Ident__VA_ARGS__->setIsPoisoned(true);

Modified: cfe/trunk/include/clang/Tooling/Core/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Diagnostic.h?rev=323316=323315=323316=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Diagnostic.h Wed Jan 24 02:26:09 2018
@@ -33,7 +33,7 @@ struct DiagnosticMessage {
   DiagnosticMessage(llvm::StringRef Message = "");
 
   /// \brief 

[clang-tools-extra] r323227 - [clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init if using C++2a

2018-01-23 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Jan 23 09:13:57 2018
New Revision: 323227

URL: http://llvm.org/viewvc/llvm-project?rev=323227=rev
Log:
[clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init if 
using C++2a

Summary:
C++2a allows bitfields to have default member initializers.
Add support for this to clang-tidy's cppcoreguidelines-pro-type-member-init 
check.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: klimek, nemanjai, xazax.hun, kbarton, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp
Modified:

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

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=323227=323226=323227=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Jan 23 09:13:57 2018
@@ -404,8 +404,9 @@ void ProTypeMemberInitCheck::checkMissin
   return;
 // Don't suggest fixes for enums because we don't know a good default.
 // Don't suggest fixes for bitfields because in-class initialization is not
-// possible.
-if (F->getType()->isEnumeralType() || F->isBitField())
+// possible until C++2a.
+if (F->getType()->isEnumeralType() ||
+(!getLangOpts().CPlusPlus2a && F->isBitField()))
   return;
 if (!F->getParent()->isUnion() || UnionsSeen.insert(F->getParent()).second)
   FieldsToFix.insert(F);

Added: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp?rev=323227=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx2a.cpp
 Tue Jan 23 09:13:57 2018
@@ -0,0 +1,19 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-std=c++2a -fno-delayed-template-parsing
+
+struct PositiveBitfieldMember {
+  PositiveBitfieldMember() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: F
+  unsigned F : 5;
+  // CHECK-FIXES: unsigned F : 5{};
+};
+
+struct NegativeUnnamedBitfieldMember {
+  NegativeUnnamedBitfieldMember() {}
+  unsigned : 5;
+};
+
+struct NegativeInitializedBitfieldMembers {
+  NegativeInitializedBitfieldMembers() : F(3) { G = 2; }
+  unsigned F : 5;
+  unsigned G : 5;
+};

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=323227=323226=323227=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Tue Jan 23 09:13:57 2018
@@ -474,6 +474,7 @@ struct PositiveBitfieldMember {
   PositiveBitfieldMember() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these fields: F
   unsigned F : 5;
+  // CHECK-FIXES-NOT: unsigned F : 5{};
 };
 
 struct NegativeUnnamedBitfieldMember {


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


[clang-tools-extra] r323208 - [clang-tidy] Handle bitfields in modernize-use-default-member-init if using C++2a

2018-01-23 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Jan 23 07:32:42 2018
New Revision: 323208

URL: http://llvm.org/viewvc/llvm-project?rev=323208=rev
Log:
[clang-tidy] Handle bitfields in modernize-use-default-member-init if using 
C++2a

Summary:
C++2a allows bitfields to have default member initializers.
Add support for this to clang-tidy's modernize-use-default-member-init check.

Reviewers: aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: klimek, xazax.hun, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=323208=323207=323208=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Tue Jan 23 07:32:42 2018
@@ -167,7 +167,9 @@ void UseDefaultMemberInitCheck::register
   isDefaultConstructor(), unless(isInstantiated()),
   forEachConstructorInitializer(
   cxxCtorInitializer(
-  forField(unless(anyOf(isBitField(),
+  forField(unless(anyOf(getLangOpts().CPlusPlus2a
+? unless(anything())
+: isBitField(),
 hasInClassInitializer(anything()),
 hasParent(recordDecl(isUnion()),
   isWritten(), withInitializer(ignoringImplicit(Init)))

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp?rev=323208=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
 Tue Jan 23 07:32:42 2018
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- 
-std=c++2a
+
+struct PositiveBitField
+{
+  PositiveBitField() : i(6) {}
+  // CHECK-FIXES: PositiveBitField()  {}
+  int i : 5;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer 
for 'i' [modernize-use-default-member-init]
+  // CHECK-FIXES: int i : 5{6};
+};


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


r320396 - [Sema] Fix crash in unused-lambda-capture warning for VLAs

2017-12-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Dec 11 10:00:36 2017
New Revision: 320396

URL: http://llvm.org/viewvc/llvm-project?rev=320396=rev
Log:
[Sema] Fix crash in unused-lambda-capture warning for VLAs

Summary:
Clang was crashing when diagnosing an unused-lambda-capture for a VLA because
From.getVariable() is null for the capture of a VLA bound.
Warning about the VLA bound capture is not helpful, so only warn for the VLA
itself.

Fixes: PR3

Reviewers: aaron.ballman, dim, rsmith

Reviewed By: aaron.ballman, dim

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=320396=320395=320396=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Mon Dec 11 10:00:36 2017
@@ -560,6 +560,7 @@ public:
 void markUsed(bool IsODRUse) { (IsODRUse ? ODRUsed : NonODRUsed) = true; }
 
 VarDecl *getVariable() const {
+  assert(isVariableCapture());
   return VarAndNestedAndThis.getPointer();
 }
 

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=320396=320395=320396=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Mon Dec 11 10:00:36 2017
@@ -1481,6 +1481,9 @@ void Sema::DiagnoseUnusedLambdaCapture(c
   if (CaptureHasSideEffects(From))
 return;
 
+  if (From.isVLATypeCapture())
+return;
+
   auto diag = Diag(From.getLocation(), diag::warn_unused_lambda_capture);
   if (From.isThisCapture())
 diag << "'this'";

Modified: cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp?rev=320396=320395=320396=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp Mon Dec 11 10:00:36 
2017
@@ -191,3 +191,12 @@ void test_templated() {
 void test_use_template() {
   test_templated(); // expected-note{{in instantiation of function 
template specialization 'test_templated' requested here}}
 }
+
+namespace pr3 {
+int a;
+void b() {
+  int c[a];
+  auto vla_used = [] { return c[0]; };
+  auto vla_unused = [] {}; // expected-warning{{lambda capture 'c' is not 
used}}
+}
+} // namespace pr3


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


[clang-tools-extra] r319174 - [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw

2017-11-28 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Nov 28 06:57:47 2017
New Revision: 319174

URL: http://llvm.org/viewvc/llvm-project?rev=319174=rev
Log:
[clang-tidy] Ignore ExprWithCleanups when looking for else-after-throw

Summary:
The readability-else-after-return check was not warning about
an else after a throw of an exception that had arguments that needed
to be cleaned up.

Reviewers: aaron.ballman, alexfh, djasper

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, klimek, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp?rev=319174=319173=319174=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ElseAfterReturnCheck.cpp Tue 
Nov 28 06:57:47 2017
@@ -21,7 +21,8 @@ namespace readability {
 void ElseAfterReturnCheck::registerMatchers(MatchFinder *Finder) {
   const auto ControlFlowInterruptorMatcher =
   stmt(anyOf(returnStmt().bind("return"), continueStmt().bind("continue"),
- breakStmt().bind("break"), cxxThrowExpr().bind("throw")));
+ breakStmt().bind("break"),
+ expr(ignoringImplicit(cxxThrowExpr().bind("throw");
   Finder->addMatcher(
   compoundStmt(forEach(
   ifStmt(hasThen(stmt(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp?rev=319174=319173=319174=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-else-after-return.cpp 
Tue Nov 28 06:57:47 2017
@@ -1,5 +1,16 @@
 // RUN: %check_clang_tidy %s readability-else-after-return %t -- -- -std=c++11 
-fexceptions
 
+namespace std {
+struct string {
+  string(const char *);
+  ~string();
+};
+} // namespace std
+
+struct my_exception {
+  my_exception(const std::string );
+};
+
 void f(int a) {
   if (a > 0)
 return;
@@ -85,5 +96,12 @@ void foo() {
 // CHECK-FIXES: {{^}}} // comment-9
   x++;
 }
+if (x) {
+  throw my_exception("foo");
+} else { // comment-10
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use 'else' after 'throw'
+// CHECK-FIXES: {{^}}} // comment-10
+  x++;
+}
   }
 }


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


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

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

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

Modified:
cfe/trunk/docs/ClangFormat.rst

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


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


Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-09-19 Thread Malcolm Parsons via cfe-commits
On 16 August 2017 at 02:49, Richard Smith via cfe-commits
 wrote:

> +  /// \brief \c true if a defaulted destructor for this class would be 
> deleted.
> +  bool defaultedDestructorIsDeleted() const {
> +return !data().DefaultedDestructorIsDeleted;
> +  }

Is the ! intentional?

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


r309667 - [ASTMatchers] Allow forField to match indirect fields.

2017-08-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Aug  1 02:53:55 2017
New Revision: 309667

URL: http://llvm.org/viewvc/llvm-project?rev=309667=rev
Log:
[ASTMatchers] Allow forField to match indirect fields.

This is needed for PR32966.

Reviewed by alexfh.

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=309667=309666=309667=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue Aug  1 02:53:55 2017
@@ -3237,7 +3237,7 @@ AST_MATCHER_P(CXXConstructorDecl, hasAny
 /// with forField matching foo_
 AST_MATCHER_P(CXXCtorInitializer, forField,
   internal::Matcher, InnerMatcher) {
-  const FieldDecl *NodeAsDecl = Node.getMember();
+  const FieldDecl *NodeAsDecl = Node.getAnyMember();
   return (NodeAsDecl != nullptr &&
   InnerMatcher.matches(*NodeAsDecl, Finder, Builder));
 }

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=309667=309666=309667=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Tue Aug  1 
02:53:55 2017
@@ -785,14 +785,18 @@ TEST(HasAnyConstructorInitializer, ForFi
   static const char Code[] =
 "class Baz { };"
   "class Foo {"
-  "  Foo() : foo_() { }"
+  "  Foo() : foo_(), bar_() { }"
   "  Baz foo_;"
-  "  Baz bar_;"
+  "  struct {"
+  "Baz bar_;"
+  "  };"
   "};";
   EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 forField(hasType(recordDecl(hasName("Baz";
   EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 forField(hasName("foo_"));
+  EXPECT_TRUE(matches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
+forField(hasName("bar_"));
   EXPECT_TRUE(notMatches(Code, cxxConstructorDecl(hasAnyConstructorInitializer(
 forField(hasType(recordDecl(hasName("Bar";
 }


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


[clang-tools-extra] r309668 - [clang-tidy] Handle anonymous structs/unions in member init checks.

2017-08-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Aug  1 02:54:05 2017
New Revision: 309668

URL: http://llvm.org/viewvc/llvm-project?rev=309668=rev
Log:
[clang-tidy] Handle anonymous structs/unions in member init checks.

Use getAnyMember() instead of getMember() to avoid crash on anonymous
structs/unions.
Don't warn about initializing members of an anonymous union.

Fixes PR32966.

Reviewed by alexfh.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=309668=309667=309668=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Tue Aug  1 02:54:05 2017
@@ -166,21 +166,22 @@ void UseDefaultMemberInitCheck::register
   cxxConstructorDecl(
   isDefaultConstructor(), unless(isInstantiated()),
   forEachConstructorInitializer(
-  allOf(forField(unless(anyOf(isBitField(),
-  hasInClassInitializer(anything(),
-cxxCtorInitializer(isWritten(),
-   withInitializer(ignoringImplicit(Init)))
-.bind("default",
+  cxxCtorInitializer(
+  forField(unless(anyOf(isBitField(),
+hasInClassInitializer(anything()),
+hasParent(recordDecl(isUnion()),
+  isWritten(), withInitializer(ignoringImplicit(Init)))
+  .bind("default"))),
   this);
 
   Finder->addMatcher(
   cxxConstructorDecl(
   unless(ast_matchers::isTemplateInstantiation()),
   forEachConstructorInitializer(
-  allOf(forField(hasInClassInitializer(anything())),
-cxxCtorInitializer(isWritten(),
-   withInitializer(ignoringImplicit(Init)))
-.bind("existing",
+  cxxCtorInitializer(forField(hasInClassInitializer(anything())),
+ isWritten(),
+ withInitializer(ignoringImplicit(Init)))
+  .bind("existing"))),
   this);
 }
 
@@ -197,7 +198,7 @@ void UseDefaultMemberInitCheck::check(co
 
 void UseDefaultMemberInitCheck::checkDefaultInit(
 const MatchFinder::MatchResult , const CXXCtorInitializer *Init) {
-  const FieldDecl *Field = Init->getMember();
+  const FieldDecl *Field = Init->getAnyMember();
 
   SourceLocation StartLoc = Field->getLocStart();
   if (StartLoc.isMacroID() && IgnoreMacros)

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp?rev=309668=309667=309668=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
Tue Aug  1 02:54:05 2017
@@ -39,7 +39,8 @@ void RedundantMemberInitCheck::registerM
   forEachConstructorInitializer(
   cxxCtorInitializer(isWritten(),
  withInitializer(ignoringImplicit(Construct)),
- unless(forField(hasType(isConstQualified()
+ unless(forField(hasType(isConstQualified(,
+ 
unless(forField(hasParent(recordDecl(isUnion())
   .bind("init"))),
   this);
 }
@@ -52,7 +53,7 @@ void RedundantMemberInitCheck::check(con
   Construct->getArg(0)->isDefaultArgument()) {
 if (Init->isAnyMemberInitializer()) {
   diag(Init->getSourceLocation(), "initializer for member %0 is redundant")
-  << Init->getMember()
+  << Init->getAnyMember()
   << FixItHint::CreateRemoval(Init->getSourceRange());
 } else {
   diag(Init->getSourceLocation(),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=309668=309667=309668=diff
==
--- 

r302440 - [AST] Fix copy error in comment. NFC.

2017-05-08 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon May  8 11:43:29 2017
New Revision: 302440

URL: http://llvm.org/viewvc/llvm-project?rev=302440=rev
Log:
[AST] Fix copy error in comment. NFC.

Modified:
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=302440=302439=302440=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon May  8 11:43:29 2017
@@ -2478,7 +2478,7 @@ public:
   void setCapturedVLAType(const VariableArrayType *VLAType);
 
   /// getParent - Returns the parent of this field declaration, which
-  /// is the struct in which this method is defined.
+  /// is the struct in which this field is defined.
   const RecordDecl *getParent() const {
 return cast(getDeclContext());
   }


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


Re: [clang-tools-extra] r296867 - [clang-tidy] Fix modernize-use-emplace docs

2017-03-03 Thread Malcolm Parsons via cfe-commits
On 3 March 2017 at 12:42, Piotr Padlewski via cfe-commits
 wrote:
>  w.emplace_back(std::make_pair(21L, 37L);

Unbalanced ().

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


r296602 - [Sema] Improve side effect checking for unused-lambda-capture warning

2017-03-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Mar  1 04:23:38 2017
New Revision: 296602

URL: http://llvm.org/viewvc/llvm-project?rev=296602=rev
Log:
[Sema] Improve side effect checking for unused-lambda-capture warning

Summary:
Don't warn about unused lambda captures that involve copying a
value of a type that cannot be trivially copied and destroyed.

Fixes PR31977

Reviewers: rsmith, aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=296602=296601=296602=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Mar  1 04:23:38 2017
@@ -5340,6 +5340,9 @@ public:
   ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body,
  Scope *CurScope);
 
+  /// \brief Does copying/destroying the captured variable have side effects?
+  bool CaptureHasSideEffects(const sema::LambdaScopeInfo::Capture );
+
   /// \brief Diagnose if an explicit lambda capture is unused.
   void DiagnoseUnusedLambdaCapture(const sema::LambdaScopeInfo::Capture );
 

Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=296602=296601=296602=diff
==
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Wed Mar  1 04:23:38 2017
@@ -1438,13 +1438,35 @@ mapImplicitCaptureStyle(CapturingScopeIn
   llvm_unreachable("Unknown implicit capture style");
 }
 
-void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture ) {
+bool Sema::CaptureHasSideEffects(const LambdaScopeInfo::Capture ) {
   if (!From.isVLATypeCapture()) {
 Expr *Init = From.getInitExpr();
 if (Init && Init->HasSideEffects(Context))
-  return;
+  return true;
   }
 
+  if (!From.isCopyCapture())
+return false;
+
+  const QualType T = From.isThisCapture()
+ ? getCurrentThisType()->getPointeeType()
+ : From.getCaptureType();
+
+  if (T.isVolatileQualified())
+return true;
+
+  const Type *BaseT = T->getBaseElementTypeUnsafe();
+  if (const CXXRecordDecl *RD = BaseT->getAsCXXRecordDecl())
+return !RD->isCompleteDefinition() || !RD->hasTrivialCopyConstructor() ||
+   !RD->hasTrivialDestructor();
+
+  return false;
+}
+
+void Sema::DiagnoseUnusedLambdaCapture(const LambdaScopeInfo::Capture ) {
+  if (CaptureHasSideEffects(From))
+return;
+
   auto diag = Diag(From.getLocation(), diag::warn_unused_lambda_capture);
   if (From.isThisCapture())
 diag << "'this'";

Modified: cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp?rev=296602=296601=296602=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp Wed Mar  1 04:23:38 
2017
@@ -1,10 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-lambda-capture 
-Wused-but-marked-unused -Wno-uninitialized -verify -std=c++1z %s
 
 class NonTrivialConstructor {
 public:
   NonTrivialConstructor() {}
 };
 
+class NonTrivialCopyConstructor {
+public:
+  NonTrivialCopyConstructor() = default;
+  NonTrivialCopyConstructor(const NonTrivialCopyConstructor &) {}
+};
+
 class NonTrivialDestructor {
 public:
   ~NonTrivialDestructor() {}
@@ -57,14 +63,67 @@ void test() {
 auto explicit_by_value_used = [i] { return i + 1; };
 auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda 
capture 'i' is not used}}
   };
+
+  Trivial trivial;
+  auto explicit_by_value_trivial = [trivial] {}; // expected-warning{{lambda 
capture 'trivial' is not used}}
+
+  NonTrivialConstructor cons;
+  auto explicit_by_value_non_trivial_constructor = [cons] {}; // 
expected-warning{{lambda capture 'cons' is not used}}
+
+  NonTrivialCopyConstructor copy_cons;
+  auto explicit_by_value_non_trivial_copy_constructor = [copy_cons] {};
+
+  NonTrivialDestructor dest;
+  auto explicit_by_value_non_trivial_destructor = [dest] {};
+
+  volatile int v;
+  auto explicit_by_value_volatile = [v] {};
 }
 
-class Foo
-{
+class TrivialThis : Trivial {
   void test() {
 auto explicit_this_used = [this] { return i; };
 auto explicit_this_used_void = [this] { (void)this; };
 auto explicit_this_unused = [this] {}; // expected-warning{{lambda capture 
'this' is not 

[clang-tools-extra] r295192 - [clang-tidy] Don't delay parsing of templates in test for misc-unconventional-assign-operator

2017-02-15 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Feb 15 10:32:55 2017
New Revision: 295192

URL: http://llvm.org/viewvc/llvm-project?rev=295192=rev
Log:
[clang-tidy] Don't delay parsing of templates in test for 
misc-unconventional-assign-operator

Modified:

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=295192=295191=295192=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
Wed Feb 15 10:32:55 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- 
-std=c++11 -isystem %S/Inputs/Headers -fno-delayed-template-parsing
 
 namespace std {
 template 


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


[clang-tools-extra] r295176 - [clang-tidy] Don't warn about call to unresolved operator*

2017-02-15 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Feb 15 08:01:41 2017
New Revision: 295176

URL: http://llvm.org/viewvc/llvm-project?rev=295176=rev
Log:
[clang-tidy] Don't warn about call to unresolved operator*

Summary:
The misc-unconventional-assign-operator check had a false positive
warning when the 'operator*' in 'return *this' was unresolved.

Change matcher to allow calls to unresolved operator.

Fixes PR31531.

Reviewers: alexfh, aaron.ballman

Subscribers: JDevlieghere, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp?rev=295176=295175=295176=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp 
Wed Feb 15 08:01:41 2017
@@ -58,7 +58,10 @@ void UnconventionalAssignOperatorCheck::
   this);
 
   const auto IsBadReturnStatement = 
returnStmt(unless(has(ignoringParenImpCasts(
-  unaryOperator(hasOperatorName("*"), hasUnaryOperand(cxxThisExpr()));
+  anyOf(unaryOperator(hasOperatorName("*"), 
hasUnaryOperand(cxxThisExpr())),
+cxxOperatorCallExpr(argumentCountIs(1),
+callee(unresolvedLookupExpr()),
+hasArgument(0, cxxThisExpr(;
   const auto IsGoodAssign = cxxMethodDecl(IsAssign, HasGoodReturnType);
 
   Finder->addMatcher(returnStmt(IsBadReturnStatement, 
forFunction(IsGoodAssign))

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=295176=295175=295176=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp 
Wed Feb 15 08:01:41 2017
@@ -87,3 +87,25 @@ public:
 return n;
   }
 };
+
+namespace pr31531 {
+enum E { e };
+// This declaration makes the 'return *this' below have an unresolved operator
+// in the class template, but not in an instantiation.
+E operator*(E, E);
+
+template 
+struct UnresolvedOperator {
+  UnresolvedOperator =(const UnresolvedOperator &) { return *this; }
+};
+
+UnresolvedOperator UnresolvedOperatorInt;
+
+template 
+struct Template {
+  Template =(const Template &) { return this; }
+  // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: operator=() should always 
return '*this'
+};
+
+Template TemplateInt;
+}


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


[clang-tools-extra] r292786 - [clang-tidy] Ignore implicit functions in performance-unnecessary-value-param

2017-01-23 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Jan 23 07:18:08 2017
New Revision: 292786

URL: http://llvm.org/viewvc/llvm-project?rev=292786=rev
Log:
[clang-tidy] Ignore implicit functions in performance-unnecessary-value-param

Summary:
The performance-unnecessary-value-param check mangled inherited
constructors, as the constructors' parameters do not have useful source
locations. Fix this by ignoring implicit functions.

Fixes PR31684.

Reviewers: flx, alexfh, aaron.ballman

Subscribers: madsravn, JDevlieghere, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=292786=292785=292786=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Mon Jan 23 07:18:08 2017
@@ -74,7 +74,7 @@ void UnnecessaryValueParamCheck::registe
   Finder->addMatcher(
   functionDecl(hasBody(stmt()), isDefinition(),
unless(cxxMethodDecl(anyOf(isOverride(), isFinal(,
-   unless(isInstantiated()),
+   unless(anyOf(isInstantiated(), isImplicit())),
has(typeLoc(forEach(ExpensiveValueParamDecl))),
decl().bind("functionDecl")),
   this);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=292786=292785=292786=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
Mon Jan 23 07:18:08 2017
@@ -331,3 +331,20 @@ template 
 struct NegativeFinalImpl : public NegativeDependentTypeInterface {
   void Method(ExpensiveToCopyType E) final {}
 };
+
+struct PositiveConstructor {
+  PositiveConstructor(ExpensiveToCopyType E) : E(E) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:43: warning: the parameter 'E' is copied
+  // CHECK-FIXES: PositiveConstructor(const ExpensiveToCopyType& E) : E(E) {}
+
+  ExpensiveToCopyType E;
+};
+
+struct NegativeUsingConstructor : public PositiveConstructor {
+  using PositiveConstructor::PositiveConstructor;
+};
+
+void fun() {
+  ExpensiveToCopyType E;
+  NegativeUsingConstructor S(E);
+}


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


Re: r291905 - [Sema] Add warning for unused lambda captures

2017-01-22 Thread Malcolm Parsons via cfe-commits
On 20 January 2017 at 21:32, Nico Weber  wrote:
> This warns about code like
>
>   constexpr int foo = 4;
>   []() { use(foo); }
>
> That's correct, but removing  then makes MSVC complain about this code
> like "error C3493: 'foo' cannot be implicitly captured because no default
> capture mode has been specified". A workaround is to make foo static const
> instead of constexpr.
>
> This seems like an MSVC bug, but it's still a bit annoying that clang now
> suggests doing things that won't build in other compilers. Any ideas what to
> do about this?

Should Clang care about the behaviour of other compilers that don't
follow the standard?

You could:
Disable the warning on the command line.
Disable the warning with a pragma.
Cast foo to void inside the lambda.
Only capture foo when building with MSVC.
Stop building with MSVC.
Complain to Microsoft.

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


r292595 - Fix documentation typo.

2017-01-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 20 03:54:26 2017
New Revision: 292595

URL: http://llvm.org/viewvc/llvm-project?rev=292595=rev
Log:
Fix documentation typo.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=292595=292594=292595=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Fri Jan 20 03:54:26 2017
@@ -5419,7 +5419,7 @@ alignof.
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtforFunctionMatcherhttp://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDecl
 InnerMatcher
-Matches declaration of 
the function the statemenet belongs to
+Matches declaration of 
the function the statement belongs to
 
 Given:
 F operator=(const F o) {

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=292595=292594=292595=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Jan 20 03:54:26 2017
@@ -5507,7 +5507,7 @@ AST_MATCHER_FUNCTION(internal::Matcherhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292498 - [Sema] Reword unused lambda capture warning

2017-01-19 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 19 11:19:22 2017
New Revision: 292498

URL: http://llvm.org/viewvc/llvm-project?rev=292498=rev
Log:
[Sema] Reword unused lambda capture warning

Summary:
The warning doesn't know why the variable was looked up but not
odr-used, so reword it to not claim that it was used in an unevaluated
context.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=292498=292497=292498=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 19 11:19:22 
2017
@@ -320,7 +320,7 @@ def warn_unneeded_member_function : Warn
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
 def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
-  "%select{used|required to be captured for use in an unevaluated context}1">,
+  "%select{used|required to be captured for this use}1">,
   InGroup, DefaultIgnore;
 
 def warn_parameter_size: Warning<

Modified: cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp?rev=292498=292497=292498=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp Thu Jan 19 11:19:22 
2017
@@ -22,6 +22,7 @@ int side_effect() {
 
 void test() {
   int i = 0;
+  const int k = 0;
 
   auto captures_nothing = [] {};
 
@@ -34,8 +35,9 @@ void test() {
   auto explicit_by_value_used = [i] { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 
'i' is not used}}
-  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
-  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for this 
use}}
+  auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not required to be captured for this 
use}}
+  auto explicit_by_value_unused_const = [k] { return k + 1; }; // 
expected-warning{{lambda capture 'k' is not required to be captured for this 
use}}
 
   auto explicit_by_reference_used = [] { i++; };
   auto explicit_by_reference_unused = [] {}; // expected-warning{{lambda 
capture 'i' is not used}}
@@ -70,6 +72,7 @@ class Foo
 template 
 void test_templated() {
   int i = 0;
+  const int k = 0;
 
   auto captures_nothing = [] {};
 
@@ -82,8 +85,9 @@ void test_templated() {
   auto explicit_by_value_used = [i] { return i + 1; };
   auto explicit_by_value_used_void = [i] { (void)i; };
   auto explicit_by_value_unused = [i] {}; // expected-warning{{lambda capture 
'i' is not used}}
-  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for use in 
an unevaluated context}}
+  auto explicit_by_value_unused_sizeof = [i] { return sizeof(i); }; // 
expected-warning{{lambda capture 'i' is not required to be captured for this 
use}}
   auto explicit_by_value_unused_decltype = [i] { decltype(i) j = 0; }; // 
expected-warning{{lambda capture 'i' is not used}}
+  auto explicit_by_value_unused_const = [k] { return k + 1; }; // 
expected-warning{{lambda capture 'k' is not required to be captured for this 
use}}
 
   auto explicit_by_reference_used = [] { i++; };
   auto explicit_by_reference_unused = [] {}; // expected-warning{{lambda 
capture 'i' is not used}}


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


[clang-tools-extra] r292484 - [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

2017-01-19 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 19 07:38:19 2017
New Revision: 292484

URL: http://llvm.org/viewvc/llvm-project?rev=292484=rev
Log:
[docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

Summary:
Docs for clang::Decl and clang::TemplateSpecializationType have
not been generated since LLVM_ALIGNAS was added to them.

Tell Doxygen to expand LLVM_ALIGNAS to nothing as described at
https://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html

Reviewers: aaron.ballman, klimek, alexfh

Subscribers: ioeric, cfe-commits

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

Modified:
clang-tools-extra/trunk/docs/doxygen.cfg.in

Modified: clang-tools-extra/trunk/docs/doxygen.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/doxygen.cfg.in?rev=292484=292483=292484=diff
==
--- clang-tools-extra/trunk/docs/doxygen.cfg.in (original)
+++ clang-tools-extra/trunk/docs/doxygen.cfg.in Thu Jan 19 07:38:19 2017
@@ -1891,7 +1891,7 @@ ENABLE_PREPROCESSING   = YES
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-MACRO_EXPANSION= NO
+MACRO_EXPANSION= YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
 # the macro expansion is limited to the macros specified with the PREDEFINED 
and
@@ -1899,7 +1899,7 @@ MACRO_EXPANSION= NO
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
 
 # If the SEARCH_INCLUDES tag is set to YES the includes files in the
 # INCLUDE_PATH will be searched if a #include is found.
@@ -1932,7 +1932,7 @@ INCLUDE_FILE_PATTERNS  =
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED =
+PREDEFINED = LLVM_ALIGNAS(x)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
@@ -1944,7 +1944,7 @@ PREDEFINED =
 EXPAND_AS_DEFINED  =
 
 # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor 
will
-# remove all refrences to function-like macros that are alone on a line, have 
an
+# remove all references to function-like macros that are alone on a line, have 
an
 # all uppercase name, and do not end with a semicolon. Such function macros are
 # typically used for boiler-plate code, and will confuse the parser if not
 # removed.


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


Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 13:16, Aaron Ballman  wrote:
> I wasn't thinking about that kind of odr-unuse when reviewing your
> patch, so I am starting to think that perhaps it's not worth
> distinguishing unevaluated contexts or not in the diagnostic. :-( If
> we could do it, then great (we seem to be able to do it for regular
> variable use: http://coliru.stacked-crooked.com/a/4bde9b5daf48956a),
> but if not, then I think we should just go back to the original
> wording that says it's not required to be captured (in all cases, not
> distinguishing odr-use) and put in a FIXME with the test cases that
> could have an improved diagnostic (including the test case talked
> about here, which we should add). What do you think?

The warning can distinguish:
* not looked up
* looked up
* looked up and used

It doesn't know why a variable was looked up but not used.

You suggested the wording "not required to be captured for this use"
earlier in this thread; is that better?

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


Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 12:49, Aaron Ballman  wrote:
> You are correct, it is not an odr use. MSVC is wrong to require the capture.

Should the warning be rephrased?

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


r292477 - [docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

2017-01-19 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 19 03:27:45 2017
New Revision: 292477

URL: http://llvm.org/viewvc/llvm-project?rev=292477=rev
Log:
[docs] Tell Doxygen to expand LLVM_ALIGNAS to nothing

Summary:
Docs for clang::Decl and clang::TemplateSpecializationType have
not been generated since LLVM_ALIGNAS was added to them.

Tell Doxygen to expand LLVM_ALIGNAS to nothing as described at
https://www.stack.nl/~dimitri/doxygen/manual/preprocessing.html

Reviewers: aaron.ballman, klimek, alexfh

Subscribers: ioeric, cfe-commits

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

Modified:
cfe/trunk/docs/doxygen.cfg.in

Modified: cfe/trunk/docs/doxygen.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/doxygen.cfg.in?rev=292477=292476=292477=diff
==
--- cfe/trunk/docs/doxygen.cfg.in (original)
+++ cfe/trunk/docs/doxygen.cfg.in Thu Jan 19 03:27:45 2017
@@ -1885,7 +1885,7 @@ ENABLE_PREPROCESSING   = YES
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-MACRO_EXPANSION= NO
+MACRO_EXPANSION= YES
 
 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
 # the macro expansion is limited to the macros specified with the PREDEFINED 
and
@@ -1893,7 +1893,7 @@ MACRO_EXPANSION= NO
 # The default value is: NO.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-EXPAND_ONLY_PREDEF = NO
+EXPAND_ONLY_PREDEF = YES
 
 # If the SEARCH_INCLUDES tag is set to YES the includes files in the
 # INCLUDE_PATH will be searched if a #include is found.
@@ -1925,7 +1925,7 @@ INCLUDE_FILE_PATTERNS  =
 # recursively expanded use the := operator instead of the = operator.
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
-PREDEFINED =
+PREDEFINED = LLVM_ALIGNAS(x)=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The


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


Re: [PATCH] D28467: [Sema] Add warning for unused lambda captures

2017-01-19 Thread Malcolm Parsons via cfe-commits
On 19 January 2017 at 03:47, Aaron Ballman  wrote:
> It is not used in an unevaluated context -- that is a bug.

It is an evaluated expression, but is it odr-used?

C++14 [basic.def.odr] p3:

A variable x whose name appears as a potentially-evaluated expression
ex is odr-used by ex unless applying the lvalue-to-rvalue conversion
(4.1) to x yields a constant expression (5.20) that does not invoke
any nontrivial functions and, if x is an object, ex is an element of
the set of potential results of an expression e, where either the
lvalue-to-rvalue conversion (4.1) is applied to e, or e is a
discarded-value expression (Clause 5). ...

5.20 [expr.const] p3:

An integral constant expression is an expression of integral or
unscoped enumeration type, implicitly converted to a prvalue, where
the converted expression is a core constant expression. [ Note: Such
expressions may be used as array bounds (8.3.4, 5.3.4), as bit-field
lengths (9.6), as enumerator initializers if the underlying type is
not fixed (7.2), and as alignments (7.6.2). — end note ]

I read that as kDelta is not odr-used.

GCC and ICC don't require kDelta to be captured either.

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


[clang-tools-extra] r291941 - Remove unused lambda captures. NFC

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 13:02:50 2017
New Revision: 291941

URL: http://llvm.org/viewvc/llvm-project?rev=291941=rev
Log:
Remove unused lambda captures. NFC

Modified:
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp?rev=291941=291940=291941=diff
==
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp Fri Jan 13 
13:02:50 2017
@@ -207,8 +207,8 @@ runClangMoveOnCode(const move::MoveDefin
   std::vector> FileToSourceText = {
   {TestHeaderName, Header}, {TestCCName, CC}};
 
-  auto CreateFiles = [, , ](
-  llvm::StringRef Name, llvm::StringRef Code) {
+  auto CreateFiles = [, ](llvm::StringRef Name,
+   llvm::StringRef Code) {
 if (!Name.empty()) {
   FileToFileID[Name] = Context.createInMemoryFile(Name, Code);
 }


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


[clang-tools-extra] r291940 - Remove unused lambda captures. NFC

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 12:56:04 2017
New Revision: 291940

URL: http://llvm.org/viewvc/llvm-project?rev=291940=rev
Log:
Remove unused lambda captures. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=291940=291939=291940=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Jan 13 12:56:04 2017
@@ -487,7 +487,7 @@ runClangTidy(std::unique_ptrhttp://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291905 - [Sema] Add warning for unused lambda captures

2017-01-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Fri Jan 13 09:01:06 2017
New Revision: 291905

URL: http://llvm.org/viewvc/llvm-project?rev=291905=rev
Log:
[Sema] Add warning for unused lambda captures

Summary:
Warn when a lambda explicitly captures something that is not used in its body.

The warning is part of -Wunused and can be enabled with -Wunused-lambda-capture.

Reviewers: rsmith, arphaman, jbcoe, aaron.ballman

Subscribers: Quuxplusone, arphaman, cfe-commits

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

Added:
cfe/trunk/test/SemaCXX/warn-unused-lambda-capture.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/ScopeInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
cfe/trunk/test/SemaCXX/uninitialized.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=291905=291904=291905=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jan 13 09:01:06 2017
@@ -480,6 +480,7 @@ def UnusedFunction : DiagGroup<"unused-f
 def UnusedMemberFunction : DiagGroup<"unused-member-function",
  [UnneededMemberFunction]>;
 def UnusedLabel : DiagGroup<"unused-label">;
+def UnusedLambdaCapture : DiagGroup<"unused-lambda-capture">;
 def UnusedParameter : DiagGroup<"unused-parameter">;
 def UnusedResult : DiagGroup<"unused-result">;
 def PotentiallyEvaluatedExpression : 
DiagGroup<"potentially-evaluated-expression">;
@@ -617,8 +618,9 @@ def Unused : DiagGroup<"unused",
[UnusedArgument, UnusedFunction, UnusedLabel,
 // UnusedParameter, (matches GCC's behavior)
 // UnusedMemberFunction, (clean-up llvm before 
enabling)
-UnusedPrivateField, UnusedLocalTypedef,
-UnusedValue, UnusedVariable, UnusedPropertyIvar]>,
+UnusedPrivateField, UnusedLambdaCapture,
+UnusedLocalTypedef, UnusedValue, UnusedVariable,
+UnusedPropertyIvar]>,
 DiagCategory<"Unused Entity Issue">;
 
 // Format settings.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=291905=291904=291905=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jan 13 09:01:06 
2017
@@ -316,6 +316,9 @@ def warn_unneeded_member_function : Warn
   InGroup, DefaultIgnore;
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
+def warn_unused_lambda_capture: Warning<"lambda capture %0 is not "
+  "%select{used|required to be captured for use in an unevaluated context}1">,
+  InGroup, DefaultIgnore;
 
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=291905=291904=291905=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Jan 13 09:01:06 2017
@@ -452,6 +452,14 @@ public:
 /// non-static data member that would hold the capture.
 QualType CaptureType;
 
+/// \brief Whether an explicit capture has been odr-used in the body of the
+/// lambda.
+bool ODRUsed;
+
+/// \brief Whether an explicit capture has been non-odr-used in the body of
+/// the lambda.
+bool NonODRUsed;
+
   public:
 Capture(VarDecl *Var, bool Block, bool ByRef, bool IsNested,
 SourceLocation Loc, SourceLocation EllipsisLoc,
@@ -460,7 +468,8 @@ public:
   InitExprAndCaptureKind(
   Cpy, !Var ? Cap_VLA : Block ? Cap_Block : ByRef ? Cap_ByRef
   : Cap_ByCopy),
-  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType) {}
+  Loc(Loc), EllipsisLoc(EllipsisLoc), CaptureType(CaptureType),
+  ODRUsed(false), NonODRUsed(false) {}
 

[clang-tools-extra] r291796 - [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

2017-01-12 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 12 13:20:35 2017
New Revision: 291796

URL: http://llvm.org/viewvc/llvm-project?rev=291796=rev
Log:
[clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value

Summary:
rL270567 excluded trivially copyable types from being moved by
modernize-pass-by-value, but it didn't exclude references to them.
Change types used in the tests to not be trivially copyable.

Reviewers: madsravn, aaron.ballman, alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Thu Jan 
12 13:20:35 2017
@@ -188,7 +188,8 @@ void PassByValueCheck::check(const Match
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
   // copyable type will cause a problem with misc-move-const-arg
-  if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+  if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
+  *Result.Context))
 return;
 
   auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use 
std::move");

Modified: 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h?rev=291796=291795=291796=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h 
Thu Jan 12 13:20:35 2017
@@ -1,4 +1,7 @@
 class ThreadId {
+public:
+  ThreadId(const ThreadId &) {}
+  ThreadId(ThreadId &&) {}
 };
 
 struct A {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp 
Thu Jan 12 13:20:35 2017
@@ -3,6 +3,6 @@
 // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s 
-check-prefix=CHECK-FIXES
 
 #include "pass-by-value-header.h"
-// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
+// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move 
[modernize-pass-by-value]
 // CHECK-FIXES: #include 
 // CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp?rev=291796=291795=291796=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
 Thu Jan 12 13:20:35 2017
@@ -6,6 +6,8 @@
 #include HEADER
 
 struct A {
+  A(const A &) {}
+  A(A &&) {}
 };
 
 struct B {

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=291796=291795=291796=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Thu Jan 
12 13:20:35 2017
@@ -2,8 +2,15 @@
 
 namespace {
 // POD types are trivially move constructible.
+struct POD {
+  int a, b, c;
+};
+
 struct Movable {
   int a, b, c;
+  Movable() = default;
+  Movable(const Movable &) {}
+  Movable(Movable &&) {}
 };
 
 struct NotMovable {
@@ -147,7 +154,8 @@ template  struct N {
 // Test with value parameter.
 struct O {
   O(Movable M) : M(M) {}
-  // CHECK-FIXES: 

r291771 - Tracking exception specification source locations

2017-01-12 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Jan 12 10:11:28 2017
New Revision: 291771

URL: http://llvm.org/viewvc/llvm-project?rev=291771=rev
Log:
Tracking exception specification source locations

Summary:
We do not currently track the source locations for exception specifications such
that their source range can be queried through the AST. This leads to trying to
write more complex code to determine the source range for uses like FixItHints
(see D18575 for an example). In addition to use within tools like clang-tidy, I
think this information may become more important to track as exception
specifications become more integrated into the type system.

Patch by Don Hinton.

Reviewers: rsmith

Subscribers: malcolm.parsons, sbarzowski, alexfh, hintonda, cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/unittests/AST/SourceLocationTest.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=291771=291770=291771=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Jan 12 10:11:28 2017
@@ -2061,6 +2061,10 @@ public:
   /// limited representation in the AST.
   SourceRange getReturnTypeSourceRange() const;
 
+  /// \brief Attempt to compute an informative source range covering the
+  /// function exception specification, if any.
+  SourceRange getExceptionSpecSourceRange() const;
+
   /// \brief Determine the type of an expression that calls this function.
   QualType getCallResultType() const {
 assert(getType()->getAs() && "Expected a FunctionType!");

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=291771=291770=291771=diff
==
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Thu Jan 12 10:11:28 2017
@@ -1351,6 +1351,19 @@ class FunctionTypeLoc : public ConcreteT
FunctionTypeLoc,
FunctionType,
FunctionLocInfo> {
+  bool hasExceptionSpec() const {
+if (auto *FPT = dyn_cast(getTypePtr())) {
+  return FPT->hasExceptionSpec();
+}
+return false;
+  }
+
+  SourceRange *getExceptionSpecRangePtr() const {
+assert(hasExceptionSpec() && "No exception spec range");
+// After the Info comes the ParmVarDecl array, and after that comes the
+// exception specification information.
+return (SourceRange *)(getParmArray() + getNumParams());
+  }
 public:
   SourceLocation getLocalRangeBegin() const {
 return getLocalData()->LocalRangeBegin;
@@ -1384,6 +1397,16 @@ public:
 return SourceRange(getLParenLoc(), getRParenLoc());
   }
 
+  SourceRange getExceptionSpecRange() const {
+if (hasExceptionSpec())
+  return *getExceptionSpecRangePtr();
+return SourceRange();
+  }
+  void setExceptionSpecRange(SourceRange R) {
+if (hasExceptionSpec())
+  *getExceptionSpecRangePtr() = R;
+  }
+
   ArrayRef getParams() const {
 return llvm::makeArrayRef(getParmArray(), getNumParams());
   }
@@ -1416,12 +1439,15 @@ public:
 setLocalRangeEnd(Loc);
 for (unsigned i = 0, e = getNumParams(); i != e; ++i)
   setParam(i, nullptr);
+if (hasExceptionSpec())
+  setExceptionSpecRange(Loc);
   }
 
   /// \brief Returns the size of the type source info data block that is
   /// specific to this type.
   unsigned getExtraLocalDataSize() const {
-return getNumParams() * sizeof(ParmVarDecl *);
+unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
+return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
   }
 
   unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); 
}

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=291771=291770=291771=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Jan 12 10:11:28 2017
@@ -2990,6 +2990,18 @@ SourceRange FunctionDecl::getReturnTypeS
   return RTRange;
 }
 
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+  const TypeSourceInfo *TSI = getTypeSourceInfo();
+  if (!TSI)
+return SourceRange();
+  FunctionTypeLoc FTL =
+TSI->getTypeLoc().IgnoreParens().getAs();
+  if (!FTL)
+return SourceRange();

r291667 - Remove repeated word in comment (NFC)

2017-01-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Jan 11 05:23:22 2017
New Revision: 291667

URL: http://llvm.org/viewvc/llvm-project?rev=291667=rev
Log:
Remove repeated word in comment (NFC)

Modified:
cfe/trunk/lib/Parse/ParseExprCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=291667=291666=291667=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Wed Jan 11 05:23:22 2017
@@ -735,7 +735,7 @@ ExprResult Parser::TryParseLambdaExpress
 ///sometimes skip the initializers for init-captures and not fully
 ///populate \p Intro. This flag will be set to \c true if we do so.
 /// \return A DiagnosticID if it hit something unexpected. The location for
-/// for the diagnostic is that of the current token.
+/// the diagnostic is that of the current token.
 Optional Parser::ParseLambdaIntroducer(LambdaIntroducer ,
  bool *SkippedInits) {
   typedef Optional DiagResult;


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


[clang-tools-extra] r290972 - [clang-tidy] Ignore default arguments in modernize-default-member-init

2017-01-04 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Jan  4 11:33:55 2017
New Revision: 290972

URL: http://llvm.org/viewvc/llvm-project?rev=290972=rev
Log:
[clang-tidy] Ignore default arguments in modernize-default-member-init

Summary:
Default member initializers cannot refer to constructor parameters, but 
modernize-default-member-init was trying to when the default constructor had 
default arguments.

Change the check to ignore default arguments to the default constructor.

Fixes PR31524.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits, JDevlieghere, Eugene.Zelenko

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290972=290971=290972=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Wed Jan  4 11:33:55 2017
@@ -158,7 +158,7 @@ void UseDefaultMemberInitCheck::register
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr());
+declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=290972=290971=290972=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Wed Jan  4 11:33:55 2017
@@ -221,6 +221,12 @@ struct NegativeNotDefaultInt
   int i;
 };
 
+struct NegativeDefaultArg
+{
+  NegativeDefaultArg(int i = 4) : i(i) {}
+  int i;
+};
+
 struct ExistingChar {
   ExistingChar(short) : e1(), e2(), e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]


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


[clang-tools-extra] r290883 - [clang-tidy] Handle constructors in performance-unnecessary-value-param

2017-01-03 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Jan  3 06:10:44 2017
New Revision: 290883

URL: http://llvm.org/viewvc/llvm-project?rev=290883=rev
Log:
[clang-tidy] Handle constructors in performance-unnecessary-value-param

Summary:
modernize-pass-by-value doesn't warn about value parameters that
cannot be moved, so performance-unnecessary-value-param should.

Reviewers: aaron.ballman, flx, alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.h

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=290883=290882=290883=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Tue Jan  3 06:10:44 2017
@@ -47,14 +47,14 @@ bool isReferencedOutsideOfCallExpr(const
   return !Matches.empty();
 }
 
-bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+bool hasLoopStmtAncestor(const DeclRefExpr , const Decl ,
  ASTContext ) {
   auto Matches =
-  match(findAll(declRefExpr(
+  match(decl(forEachDescendant(declRefExpr(
 equalsNode(),
 unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
-  whileStmt(), doStmt())),
-Stmt, Context);
+  whileStmt(), doStmt(,
+Decl, Context);
   return Matches.empty();
 }
 
@@ -72,7 +72,7 @@ void UnnecessaryValueParamCheck::registe
  unless(referenceType(),
   decl().bind("param"));
   Finder->addMatcher(
-  functionDecl(isDefinition(),
+  functionDecl(hasBody(stmt()), isDefinition(),
unless(cxxMethodDecl(anyOf(isOverride(), isFinal(,
unless(isInstantiated()),
has(typeLoc(forEach(ExpensiveValueParamDecl))),
@@ -89,22 +89,13 @@ void UnnecessaryValueParamCheck::check(c
   bool IsConstQualified =
   Param->getType().getCanonicalType().isConstQualified();
 
-  // Skip declarations delayed by late template parsing without a body.
-  if (!Function->getBody())
-return;
-
-  // Do not trigger on non-const value parameters when:
-  // 1. they are in a constructor definition since they can likely trigger
-  //modernize-pass-by-value which will suggest to move the argument.
-  if (!IsConstQualified && (llvm::isa(Function) ||
-!Function->doesThisDeclarationHaveABody()))
-return;
-
   auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
-  *Param, *Function->getBody(), *Result.Context);
+  *Param, *Function, *Result.Context);
   auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs(
-  *Param, *Function->getBody(), *Result.Context);
-  // 2. they are not only used as const.
+  *Param, *Function, *Result.Context);
+
+  // Do not trigger on non-const value parameters when they are not only used 
as
+  // const.
   if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs))
 return;
 
@@ -113,20 +104,18 @@ void UnnecessaryValueParamCheck::check(c
   // move assignment operator and is only referenced once when copy-assigned.
   // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
   // copy.
-  if (!IsConstQualified) {
+  if (!IsConstQualified && AllDeclRefExprs.size() == 1) {
 auto CanonicalType = Param->getType().getCanonicalType();
-if (AllDeclRefExprs.size() == 1 &&
-!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
- *Result.Context) &&
+const auto   = **AllDeclRefExprs.begin();
+
+if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
-  **AllDeclRefExprs.begin(), *Function->getBody(),
-  *Result.Context)) ||
+  DeclRefExpr, *Function, *Result.Context)) ||
  (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
   utils::decl_ref_expr::isCopyAssignmentArgument(
-  **AllDeclRefExprs.begin(), *Function->getBody(),
-  *Result.Context {
-  handleMoveFix(*Param, 

[clang-tools-extra] r290633 - [clang-tidy] Make 2 checks register matchers for C++ only.

2016-12-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 27 16:14:40 2016
New Revision: 290633

URL: http://llvm.org/viewvc/llvm-project?rev=290633=rev
Log:
[clang-tidy] Make 2 checks register matchers for C++ only.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=290633=290632=290633=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Tue 
Dec 27 16:14:40 2016
@@ -22,6 +22,9 @@ static const char SpecialFunction[] = "S
 static const char DeletedNotPublic[] = "DeletedNotPublic";
 
 void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
   auto PrivateSpecialFn = cxxMethodDecl(
   isPrivate(),
   anyOf(cxxConstructorDecl(anyOf(isDefaultConstructor(),

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp?rev=290633=290632=290633=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantMemberInitCheck.cpp 
Tue Dec 27 16:14:40 2016
@@ -22,6 +22,9 @@ namespace tidy {
 namespace readability {
 
 void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
   auto Construct =
   cxxConstructExpr(
   hasDeclaration(cxxConstructorDecl(hasParent(


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


[clang-tools-extra] r290630 - [clang-tidy] Replace dead link in modernize-pass-by-value doc

2016-12-27 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 27 16:01:37 2016
New Revision: 290630

URL: http://llvm.org/viewvc/llvm-project?rev=290630=rev
Log:
[clang-tidy] Replace dead link in modernize-pass-by-value doc

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst?rev=290630=290629=290630=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst 
Tue Dec 27 16:01:37 2016
@@ -150,7 +150,7 @@ Example:
 
   For more information about the pass-by-value idiom, read: `Want Speed? Pass 
by Value`_.
 
-  .. _Want Speed? Pass by Value: 
http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
+  .. _Want Speed? Pass by Value: 
https://web.archive.org/web/20140205194657/http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
 
 Options
 ---


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


[clang-tools-extra] r290493 - [clang-tidy] Remove local hasInClassInitializer matcher. NFC

2016-12-24 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Sat Dec 24 08:30:29 2016
New Revision: 290493

URL: http://llvm.org/viewvc/llvm-project?rev=290493=rev
Log:
[clang-tidy] Remove local hasInClassInitializer matcher. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290493=290492=290493=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Sat Dec 24 08:30:29 2016
@@ -146,10 +146,6 @@ void UseDefaultMemberInitCheck::storeOpt
   Options.store(Opts, "UseAssignment", UseAssignment);
 }
 
-AST_MATCHER(FieldDecl, hasInClassInitializer) {
-  return Node.hasInClassInitializer();
-}
-
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)
 return;
@@ -167,18 +163,19 @@ void UseDefaultMemberInitCheck::register
   Finder->addMatcher(
   cxxConstructorDecl(
   isDefaultConstructor(), unless(isInstantiated()),
-  forEachConstructorInitializer(allOf(
-  forField(unless(anyOf(isBitField(), hasInClassInitializer(,
-  cxxCtorInitializer(isWritten(),
- withInitializer(ignoringImplicit(Init)))
-  .bind("default",
+  forEachConstructorInitializer(
+  allOf(forField(unless(anyOf(isBitField(),
+  hasInClassInitializer(anything(),
+cxxCtorInitializer(isWritten(),
+   withInitializer(ignoringImplicit(Init)))
+.bind("default",
   this);
 
   Finder->addMatcher(
   cxxConstructorDecl(
   unless(ast_matchers::isTemplateInstantiation()),
   forEachConstructorInitializer(
-  allOf(forField(hasInClassInitializer()),
+  allOf(forField(hasInClassInitializer(anything())),
 cxxCtorInitializer(isWritten(),
withInitializer(ignoringImplicit(Init)))
 .bind("existing",


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


r290492 - [ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.

2016-12-24 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Sat Dec 24 07:35:14 2016
New Revision: 290492

URL: http://llvm.org/viewvc/llvm-project?rev=290492=rev
Log:
[ASTMatchers] Add hasInClassInitializer traversal matcher for FieldDecl.

Summary:
I needed to know whether a FieldDecl had an in-class
initializer for D26453. I used a narrowing matcher there, but a
traversal matcher might be generally useful.

Reviewers: sbenza, bkramer, klimek, aaron.ballman

Subscribers: aaron.ballman, Prazek, cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=290492=290491=290492=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Sat Dec 24 07:35:14 2016
@@ -4751,6 +4751,22 @@ would only match the declaration for a.
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html;>FieldDeclhasInClassInitializerMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr 
InnerMatcher
+Matches 
non-static data members that have an in-class initializer.
+
+Given
+  class C {
+int a = 2;
+int b = 3;
+int c;
+  };
+fieldDecl(hasInClassInitializer(integerLiteral(equals(2
+  matches 'int a;' but not 'int b;'.
+fieldDecl(hasInClassInitializer(anything()))
+  matches 'int a;' and 'int b;' but not 'int c;'.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ForStmt.html;>ForStmthasBodyMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt 
InnerMatcher
 Matches a 'for', 'while', 
'do while' statement or a function
 definition that has a given body.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=290492=290491=290492=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Dec 24 07:35:14 2016
@@ -551,6 +551,27 @@ AST_MATCHER_P(FieldDecl, hasBitWidth, un
  Node.getBitWidthValue(Finder->getASTContext()) == Width;
 }
 
+/// \brief Matches non-static data members that have an in-class initializer.
+///
+/// Given
+/// \code
+///   class C {
+/// int a = 2;
+/// int b = 3;
+/// int c;
+///   };
+/// \endcode
+/// fieldDecl(hasInClassInitializer(integerLiteral(equals(2
+///   matches 'int a;' but not 'int b;'.
+/// fieldDecl(hasInClassInitializer(anything()))
+///   matches 'int a;' and 'int b;' but not 'int c;'.
+AST_MATCHER_P(FieldDecl, hasInClassInitializer, internal::Matcher,
+  InnerMatcher) {
+  const Expr *Initializer = Node.getInClassInitializer();
+  return (Initializer != nullptr &&
+  InnerMatcher.matches(*Initializer, Finder, Builder));
+}
+
 /// \brief Matches a declaration that has been implicitly added
 /// by the compiler (eg. implicit default/copy constructors).
 AST_MATCHER(Decl, isImplicit) {

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=290492=290491=290492=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sat Dec 24 07:35:14 2016
@@ -232,6 +232,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasFalseExpression);
   REGISTER_MATCHER(hasGlobalStorage);
   REGISTER_MATCHER(hasImplicitDestinationType);
+  REGISTER_MATCHER(hasInClassInitializer);
   REGISTER_MATCHER(hasIncrement);
   REGISTER_MATCHER(hasIndex);
   REGISTER_MATCHER(hasInitializer);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=290492=290491=290492=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Sat Dec 24 
07:35:14 2016
@@ -1404,6 +1404,16 @@ TEST(Member, BitFields) {
   fieldDecl(isBitField(), hasBitWidth(2), hasName("a";
 }
 
+TEST(Member, InClassInitializer) {
+  EXPECT_TRUE(
+  matches("class C { int a = 2; int b; };",
+  fieldDecl(hasInClassInitializer(integerLiteral(equals(2))),
+hasName("a";
+  EXPECT_TRUE(
+  notMatches("class C { int a = 2; int b; };",
+ 

r290491 - [ASTMatchers] Fix doc for hasBitWidth

2016-12-24 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Sat Dec 24 07:22:26 2016
New Revision: 290491

URL: http://llvm.org/viewvc/llvm-project?rev=290491=rev
Log:
[ASTMatchers] Fix doc for hasBitWidth

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=290491=290490=290491=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Sat Dec 24 07:22:26 2016
@@ -2430,7 +2430,8 @@ designatorCountIs(2)
 
 
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html;>FieldDeclhasBitWidthunsigned Width
-Matches non-static data 
members that are bit-fields.
+Matches non-static data 
members that are bit-fields of the specified
+bit width.
 
 Given
   class C {
@@ -2438,7 +2439,7 @@ Given
 int b : 4;
 int c : 2;
   };
-fieldDecl(isBitField())
+fieldDecl(hasBitWidth(2))
   matches 'int a;' and 'int c;' but not 'int b;'.
 
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=290491=290490=290491=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Dec 24 07:22:26 2016
@@ -533,7 +533,8 @@ AST_MATCHER(FieldDecl, isBitField) {
   return Node.isBitField();
 }
 
-/// \brief Matches non-static data members that are bit-fields.
+/// \brief Matches non-static data members that are bit-fields of the specified
+/// bit width.
 ///
 /// Given
 /// \code
@@ -543,7 +544,7 @@ AST_MATCHER(FieldDecl, isBitField) {
 /// int c : 2;
 ///   };
 /// \endcode
-/// fieldDecl(isBitField())
+/// fieldDecl(hasBitWidth(2))
 ///   matches 'int a;' and 'int c;' but not 'int b;'.
 AST_MATCHER_P(FieldDecl, hasBitWidth, unsigned, Width) {
   return Node.isBitField() &&


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


[clang-tools-extra] r290210 - Comment out char16_t and char32_t tests

2016-12-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 20 16:57:21 2016
New Revision: 290210

URL: http://llvm.org/viewvc/llvm-project?rev=290210=rev
Log:
Comment out char16_t and char32_t tests

Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp?rev=290210=290209=290210=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
 Tue Dec 20 16:57:21 2016
@@ -5,7 +5,7 @@ struct S {
 };
 
 struct PositiveValueChar {
-  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
   // CHECK-FIXES: PositiveValueChar()  {}
   const char c0;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer 
for 'c0' [modernize-use-default-member-init]
@@ -13,12 +13,12 @@ struct PositiveValueChar {
   wchar_t c1;
   // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer 
for 'c1'
   // CHECK-FIXES: wchar_t c1 = L'\0';
-  char16_t c2;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
-  // CHECK-FIXES: char16_t c2 = u'\0';
-  char32_t c3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
-  // CHECK-FIXES: char32_t c3 = U'\0';
+  // FIXME: char16_t c2;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
+  // C HECK-FIXES: char16_t c2 = u'\0';
+  // FIXME: char32_t c3;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
+  // C HECK-FIXES: char32_t c3 = U'\0';
 };
 
 struct PositiveChar {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=290210=290209=290210=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp 
Tue Dec 20 16:57:21 2016
@@ -4,7 +4,7 @@ struct S {
 };
 
 struct PositiveValueChar {
-  PositiveValueChar() : c0(), c1(), c2(), c3() {}
+  PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
   // CHECK-FIXES: PositiveValueChar()  {}
   const char c0;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer 
for 'c0' [modernize-use-default-member-init]
@@ -12,12 +12,12 @@ struct PositiveValueChar {
   wchar_t c1;
   // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer 
for 'c1'
   // CHECK-FIXES: wchar_t c1{};
-  char16_t c2;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
-  // CHECK-FIXES: char16_t c2{};
-  char32_t c3;
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
-  // CHECK-FIXES: char32_t c3{};
+  // FIXME: char16_t c2;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c2'
+  // C HECK-FIXES: char16_t c2{};
+  // FIXME: char32_t c3;
+  // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer 
for 'c3'
+  // C HECK-FIXES: char32_t c3{};
 };
 
 struct PositiveChar {


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


Re: [clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via cfe-commits
On 20 December 2016 at 22:32, Aaron Ballman <aa...@aaronballman.com> wrote:
> On Tue, Dec 20, 2016 at 4:26 PM, Malcolm Parsons via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>> Author: malcolm.parsons
>> Date: Tue Dec 20 15:26:07 2016
>> New Revision: 290202
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
>> Log:
>> [clang-tidy] Add modernize-use-default-member-init check
>>
>> Summary: Fixes PR18858
>
> This appears to have broken one of the bots:
>
> http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/33046

error: unknown type name 'char16_t'
error: unknown type name 'char32_t'

I see commented tests in other clang-tidy tests:

// TODO: enable these tests once all supported compilers
// support char16_t and char32_t (VS2013 does not)

// disabled for now until it is clear
// how to enable them in the test
//} catch (const char16_t*) {

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


[clang-tools-extra] r290202 - [clang-tidy] Add modernize-use-default-member-init check

2016-12-20 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 20 15:26:07 2016
New Revision: 290202

URL: http://llvm.org/viewvc/llvm-project?rev=290202=rev
Log:
[clang-tidy] Add modernize-use-default-member-init check

Summary: Fixes PR18858

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: JDevlieghere, Eugene.Zelenko, Prazek, mgorny, cfe-commits, 
modocache

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=290202=290201=290202=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Tue Dec 20 
15:26:07 2016
@@ -16,6 +16,7 @@ add_clang_library(clangTidyModernizeModu
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
+  UseDefaultMemberInitCheck.cpp
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=290202=290201=290202=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Tue 
Dec 20 15:26:07 2016
@@ -22,6 +22,7 @@
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
+#include "UseDefaultMemberInitCheck.h"
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
@@ -56,6 +57,8 @@ public:
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
+CheckFactories.registerCheck(
+"modernize-use-default-member-init");
 CheckFactories.registerCheck("modernize-use-emplace");
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=290202=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Tue Dec 20 15:26:07 2016
@@ -0,0 +1,241 @@
+//===--- UseDefaultMemberInitCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseDefaultMemberInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+static StringRef getValueOfValueInit(const QualType InitType) {
+  switch (InitType->getScalarTypeKind()) {
+  case Type::STK_CPointer:
+  case Type::STK_BlockPointer:
+  case Type::STK_ObjCObjectPointer:
+  case Type::STK_MemberPointer:
+return "nullptr";
+
+  case Type::STK_Bool:
+return "false";
+
+  case Type::STK_Integral:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::Char_U:
+case BuiltinType::UChar:
+case BuiltinType::Char_S:
+case BuiltinType::SChar:
+  return "'\\0'";
+case BuiltinType::WChar_U:
+case BuiltinType::WChar_S:
+  return "L'\\0'";
+case BuiltinType::Char16:
+  return "u'\\0'";
+case BuiltinType::Char32:
+  return "U'\\0'";
+default:
+  return "0";
+}
+
+  case Type::STK_Floating:
+switch (InitType->getAs()->getKind()) {
+case BuiltinType::Half:
+case BuiltinType::Float:
+  return "0.0f";
+default:
+  return "0.0";
+

[clang-tools-extra] r290051 - [clang-tidy] Remove duplicated check from move-constructor-init

2016-12-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Sat Dec 17 14:23:14 2016
New Revision: 290051

URL: http://llvm.org/viewvc/llvm-project?rev=290051=rev
Log:
[clang-tidy] Remove duplicated check from move-constructor-init

Summary:
An addition to the move-constructor-init check was duplicating the
modernize-pass-by-value check.
Remove the additional check and UseCERTSemantics option.
Run the move-constructor-init test with both checks enabled.
Fix modernize-pass-by-value false-positive when initializing a base
class.
Add option to modernize-pass-by-value to only warn about parameters
that are already values.

Reviewers: alexfh, flx, aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.h

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-constructor-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=290051=290050=290051=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Sat Dec 17 
14:23:14 2016
@@ -67,11 +67,6 @@ public:
 // MSC
 CheckFactories.registerCheck("cert-msc30-c");
   }
-  ClangTidyOptions getModuleOptions() override {
-ClangTidyOptions Options;
-Options.CheckOptions["cert-oop11-cpp.UseCERTSemantics"] = "1";
-return Options;
-  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=290051=290050=290051=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Sat 
Dec 17 14:23:14 2016
@@ -21,30 +21,11 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
-namespace {
-
-unsigned int
-parmVarDeclRefExprOccurences(const ParmVarDecl ,
- const CXXConstructorDecl ,
- ASTContext ) {
-  unsigned int Occurrences = 0;
-  auto AllDeclRefs =
-  findAll(declRefExpr(to(parmVarDecl(equalsNode();
-  Occurrences += match(AllDeclRefs, *ConstructorDecl.getBody(), 
Context).size();
-  for (const auto *Initializer : ConstructorDecl.inits()) {
-Occurrences += match(AllDeclRefs, *Initializer->getInit(), Context).size();
-  }
-  return Occurrences;
-}
-
-} // namespace
-
 MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IncludeStyle(utils::IncludeSorter::parseIncludeStyle(
-  Options.get("IncludeStyle", "llvm"))),
-  UseCERTSemantics(Options.get("UseCERTSemantics", 0) != 0) {}
+  Options.get("IncludeStyle", "llvm"))) {}
 
 void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
@@ -63,68 +44,9 @@ void MoveConstructorInitCheck::registerM
 .bind("ctor")
 .bind("move-init",
   this);
-
-  auto NonConstValueMovableAndExpensiveToCopy =
-  qualType(allOf(unless(pointerType()), unless(isConstQualified()),
- hasDeclaration(cxxRecordDecl(hasMethod(cxxConstructorDecl(
- isMoveConstructor(), unless(isDeleted()),
- matchers::isExpensiveToCopy()));
-
-  // This checker is also used to implement cert-oop11-cpp, but when using that
-  // form of the checker, we do not want to diagnose movable parameters.
-  if (!UseCERTSemantics) {
-Finder->addMatcher(
-cxxConstructorDecl(
-allOf(
-unless(isMoveConstructor()),
-hasAnyConstructorInitializer(withInitializer(cxxConstructExpr(
-hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
-hasArgument(
-0,
-declRefExpr(
-to(parmVarDecl(

[clang-tools-extra] r289797 - [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-15 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec 15 04:19:56 2016
New Revision: 289797

URL: http://llvm.org/viewvc/llvm-project?rev=289797=rev
Log:
[clang-tidy] Enhance modernize-use-auto to templated function casts

Summary:
Use auto when declaring variables that are initialized by calling a templated
function that returns its explicit first argument.

Fixes PR26763.

Reviewers: aaron.ballman, alexfh, staronj, Prazek

Subscribers: Eugene.Zelenko, JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=289797=289796=289797=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Thu Dec 15 
04:19:56 2016
@@ -24,6 +24,7 @@ namespace {
 const char IteratorDeclStmtId[] = "iterator_decl";
 const char DeclWithNewId[] = "decl_new";
 const char DeclWithCastId[] = "decl_cast";
+const char DeclWithTemplateCastId[] = "decl_template";
 
 /// \brief Matches variable declarations that have explicit initializers that
 /// are not initializer lists.
@@ -169,6 +170,14 @@ AST_MATCHER(Decl, isFromStdNamespace) {
   return (Info && Info->isStr("std"));
 }
 
+/// Matches declaration reference or member expressions with explicit template
+/// arguments.
+AST_POLYMORPHIC_MATCHER(hasExplicitTemplateArgs,
+AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr,
+MemberExpr)) {
+  return Node.hasExplicitTemplateArgs();
+}
+
 /// \brief Returns a DeclarationMatcher that matches standard iterators nested
 /// inside records with a standard container name.
 DeclarationMatcher standardIterator() {
@@ -240,18 +249,38 @@ StatementMatcher makeDeclWithCastMatcher
   .bind(DeclWithCastId);
 }
 
+StatementMatcher makeDeclWithTemplateCastMatcher() {
+  auto ST =
+  substTemplateTypeParmType(hasReplacementType(equalsBoundNode("arg")));
+
+  auto ExplicitCall =
+  anyOf(has(memberExpr(hasExplicitTemplateArgs())),
+has(ignoringImpCasts(declRefExpr(hasExplicitTemplateArgs();
+
+  auto TemplateArg =
+  hasTemplateArgument(0, refersToType(qualType().bind("arg")));
+
+  auto TemplateCall = callExpr(
+  ExplicitCall,
+  callee(functionDecl(TemplateArg,
+  returns(anyOf(ST, pointsTo(ST), references(ST));
+
+  return declStmt(unless(has(varDecl(
+  
unless(hasInitializer(ignoringImplicit(TemplateCall)))
+  .bind(DeclWithTemplateCastId);
+}
+
 StatementMatcher makeCombinedMatcher() {
   return declStmt(
   // At least one varDecl should be a child of the declStmt to ensure
   // it's a declaration list and avoid matching other declarations,
   // e.g. using directives.
-  has(varDecl()),
+  has(varDecl(unless(isImplicit(,
   // Skip declarations that are already using auto.
   unless(has(varDecl(anyOf(hasType(autoType()),
-   hasType(pointerType(pointee(autoType(,
-   hasType(referenceType(pointee(autoType(,
+   
hasType(qualType(hasDescendant(autoType(,
   anyOf(makeIteratorDeclMatcher(), makeDeclWithNewMatcher(),
-makeDeclWithCastMatcher()));
+makeDeclWithCastMatcher(), makeDeclWithTemplateCastMatcher()));
 }
 
 } // namespace
@@ -389,6 +418,8 @@ void UseAutoCheck::replaceExpr(const Dec
 
   // Space after 'auto' to handle cases where the '*' in the pointer type is
   // next to the identifier. This avoids changing 'int *p' into 'autop'.
+  // FIXME: This doesn't work for function pointers because the variable name
+  // is inside the type.
   Diag << FixItHint::CreateReplacement(Range, RemoveStars ? "auto " : "auto")
<< StarRemovals;
 }
@@ -411,6 +442,17 @@ void UseAutoCheck::check(const MatchFind
 },
 "use auto when initializing with a cast to avoid duplicating the type "
 "name");
+  } else if (const auto *Decl =
+ Result.Nodes.getNodeAs(DeclWithTemplateCastId)) {
+replaceExpr(
+Decl, Result.Context,
+[](const Expr *Expr) {
+  return cast(Expr->IgnoreImplicit())
+  ->getDirectCallee()
+  ->getReturnType();
+},
+"use auto when initializing with a template cast to avoid duplicating "
+"the 

[clang-tools-extra] r289524 - [clang-tidy] Add check for redundant function pointer dereferences

2016-12-13 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec 13 02:04:11 2016
New Revision: 289524

URL: http://llvm.org/viewvc/llvm-project?rev=289524=rev
Log:
[clang-tidy] Add check for redundant function pointer dereferences

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: mgorny, JDevlieghere, cfe-commits

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

Added:

clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp

clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-function-ptr-dereference.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-function-ptr-dereference.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=289524=289523=289524=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Tue Dec 13 
02:04:11 2016
@@ -17,6 +17,7 @@ add_clang_library(clangTidyReadabilityMo
   ReadabilityTidyModule.cpp
   RedundantControlFlowCheck.cpp
   RedundantDeclarationCheck.cpp
+  RedundantFunctionPtrDereferenceCheck.cpp
   RedundantMemberInitCheck.cpp
   RedundantStringCStrCheck.cpp
   RedundantSmartptrGetCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=289524=289523=289524=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Tue Dec 13 02:04:11 2016
@@ -24,6 +24,7 @@
 #include "NonConstParameterCheck.h"
 #include "RedundantControlFlowCheck.h"
 #include "RedundantDeclarationCheck.h"
+#include "RedundantFunctionPtrDereferenceCheck.h"
 #include "RedundantMemberInitCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
@@ -59,6 +60,8 @@ public:
 "readability-inconsistent-declaration-parameter-name");
 CheckFactories.registerCheck(
 "readability-misplaced-array-index");
+CheckFactories.registerCheck(
+"readability-redundant-function-ptr-dereference");
 CheckFactories.registerCheck(
 "readability-redundant-member-init");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp?rev=289524=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
 Tue Dec 13 02:04:11 2016
@@ -0,0 +1,37 @@
+//===--- RedundantFunctionPtrDereferenceCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantFunctionPtrDereferenceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void RedundantFunctionPtrDereferenceCheck::registerMatchers(MatchFinder 
*Finder) {
+  Finder->addMatcher(unaryOperator(hasOperatorName("*"),
+   has(implicitCastExpr(
+   
hasCastKind(CK_FunctionToPointerDecay
+ .bind("op"),
+ this);
+}
+
+void RedundantFunctionPtrDereferenceCheck::check(const 
MatchFinder::MatchResult ) {
+  const auto *Operator = Result.Nodes.getNodeAs("op");
+  diag(Operator->getOperatorLoc(),
+   "redundant repeated dereference of function pointer")
+  << FixItHint::CreateRemoval(Operator->getOperatorLoc());
+}
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang

Added: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.h
URL: 

r289042 - [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

2016-12-08 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  8 05:46:22 2016
New Revision: 289042

URL: http://llvm.org/viewvc/llvm-project?rev=289042=rev
Log:
[ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

Summary: Needed for https://reviews.llvm.org/D27166

Reviewers: sbenza, bkramer, klimek

Subscribers: aemerson, cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=289042=289041=289042=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Dec  8 05:46:22 2016
@@ -5421,6 +5421,20 @@ sizeof.
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html;>SubstTemplateTypeParmTypehasReplacementTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>Type
+Matches template 
type parameter substitutions that have a replacement
+type that matches the provided matcher.
+
+Given
+  template typename T
+  double F(T t);
+  int i;
+  double j = F(i);
+
+substTemplateTypeParmType(hasReplacementType(type())) matches int
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html;>SwitchStmtforEachSwitchCaseMatcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html;>SwitchCase
 InnerMatcher
 Matches each case 
or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=289042=289041=289042=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Dec  8 05:46:22 2016
@@ -5019,6 +5019,22 @@ AST_MATCHER_P(ElaboratedType, namesType,
 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
 AST_TYPE_MATCHER(SubstTemplateTypeParmType, substTemplateTypeParmType);
 
+/// \brief Matches template type parameter substitutions that have a 
replacement
+/// type that matches the provided matcher.
+///
+/// Given
+/// \code
+///   template 
+///   double F(T t);
+///   int i;
+///   double j = F(i);
+/// \endcode
+///
+/// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
+AST_TYPE_TRAVERSE_MATCHER(
+hasReplacementType, getReplacementType,
+AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType));
+
 /// \brief Matches template type parameter types.
 ///
 /// Example matches T, but not int.

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=289042=289041=289042=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Dec  8 05:46:22 2016
@@ -252,6 +252,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReplacementType);
   REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=289042=289041=289042=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Thu Dec  8 
05:46:22 2016
@@ -2204,5 +2204,22 @@ TEST(Matcher, HasAnyDeclaration) {
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, 
substTemplateTypeParmType(hasReplacementType(
+   qualType(asString("double"));
+  EXPECT_TRUE(
+  notMatches("template"
+ "double F();"
+ "double j = F<5>();",
+ substTemplateTypeParmType(hasReplacementType(qualType();
+}
+
 

r288976 - [RecursiveASTVisitor] Improve post-order traversal unit test

2016-12-07 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Dec  7 14:38:20 2016
New Revision: 288976

URL: http://llvm.org/viewvc/llvm-project?rev=288976=rev
Log:
[RecursiveASTVisitor] Improve post-order traversal unit test

Modified:
cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp

Modified: cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp?rev=288976=288975=288976=diff
==
--- cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp (original)
+++ cfe/trunk/unittests/AST/PostOrderASTVisitor.cpp Wed Dec  7 14:38:20 2016
@@ -81,7 +81,7 @@ TEST(RecursiveASTVisitor, PostOrderTrave
   auto ASTUnit = tooling::buildASTFromCode(
 "class A {"
 "  class B {"
-"int foo() { while(4) { int i = 9; int j = -i; } return (1 + 3) + 2; }"
+"int foo() { while(4) { int i = 9; int j = -5; } return (1 + 3) + 2; }"
 "  };"
 "};"
   );
@@ -91,9 +91,9 @@ TEST(RecursiveASTVisitor, PostOrderTrave
   RecordingVisitor Visitor(true);
   Visitor.TraverseTranslationUnitDecl(TU);
 
-  std::vector expected = {
-"4", "9", "i", "-", "j", "1", "3", "+", "2", "+", "return", "A::B::foo", 
"A::B", "A"
-  };
+  std::vector expected = {"4", "9",  "i", "5","-",
+   "j", "1",  "3", "+","2",
+   "+", "return", "A::B::foo", "A::B", 
"A"};
   // Compare the list of actually visited nodes
   // with the expected list of visited nodes.
   ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());


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


Re: r288923 - [RecursiveASTVisitor] Fix post-order traversal of UnaryOperator

2016-12-07 Thread Malcolm Parsons via cfe-commits
On 7 December 2016 at 17:56, Richard Smith <rich...@metafoo.co.uk> wrote:
> On 7 Dec 2016 9:49 am, "Malcolm Parsons via cfe-commits"
> <cfe-commits@lists.llvm.org> wrote:
>
> Author: malcolm.parsons
> Date: Wed Dec  7 11:39:04 2016
> New Revision: 288923
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288923=rev
> Log:
> [RecursiveASTVisitor] Fix post-order traversal of UnaryOperator
>
> Reviewers: aaron.ballman, klimek, doug.gregor, teemperor, rsmith
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D26742
>
> @@ -87,7 +92,7 @@ TEST(RecursiveASTVisitor, PostOrderTrave
>Visitor.TraverseTranslationUnitDecl(TU);
>
>std::vector expected = {
> -"4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B",
> "A"
> +"4", "9", "i", "-",

> Why does "i" not show up here twice? Do we not include DeclRefExprs in this
> list? It looks like we're not testing the relative order of the unary
> operator and its operand here.

The test doesn't define VisitDeclRefExpr.

I can add it if you like.

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


Re: Fix some misc-move-forwarding-reference warnings

2016-12-06 Thread Malcolm Parsons via cfe-commits
On 2 December 2016 at 17:13, Michael Sharpe via cfe-commits
 wrote:
> The attached patch fixes a couple of incorrect uses of std::move as revealed
> by clang-tidy.

LGTM.

Committed as r288813.

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


r288813 - Fix two clang-tidy misc-move-forwarding-reference warnings

2016-12-06 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Tue Dec  6 08:49:18 2016
New Revision: 288813

URL: http://llvm.org/viewvc/llvm-project?rev=288813=rev
Log:
Fix two clang-tidy misc-move-forwarding-reference warnings

Patch by Michael Sharpe.

Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=288813=288812=288813=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Dec  6 08:49:18 2016
@@ -1057,7 +1057,7 @@ QualType simpleTransform(ASTContext 
   SplitQualType splitType = type.split();
 
   // Visit the type itself.
-  SimpleTransformVisitor visitor(ctx, std::move(f));
+  SimpleTransformVisitor visitor(ctx, std::forward(f));
   QualType result = visitor.Visit(splitType.Ty);
   if (result.isNull())
 return result;

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=288813=288812=288813=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Dec  6 08:49:18 2016
@@ -1941,7 +1941,7 @@ static T *buildByrefHelpers(CodeGenModul
   generator.CopyHelper = buildByrefCopyHelper(CGM, byrefInfo, generator);
   generator.DisposeHelper = buildByrefDisposeHelper(CGM, byrefInfo, generator);
 
-  T *copy = new (CGM.getContext()) T(std::move(generator));
+  T *copy = new (CGM.getContext()) T(std::forward(generator));
   CGM.ByrefHelpersCache.InsertNode(copy, insertPos);
   return copy;
 }


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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-02 Thread Malcolm Parsons via cfe-commits
On 2 December 2016 at 10:29, Mads Ravn  wrote:
> alexfh suggested that fixits seemed easy to implement. I am having a few
> doubts as to how I would make fixits for case 1 & 2. How important would it
> be to implement fixits at this point?

Add a FIXME comment if they're difficult.

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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-02 Thread Malcolm Parsons via cfe-commits
On 2 December 2016 at 09:50, Mads Ravn  wrote:
>> Comment at: test/clang-tidy/misc-string-compare.cpp:9
>> +  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: do not use compare to test
>> equality of strings; use the string equality operator instead
>> [misc-string-compare]
> What do you mean by this comment?

I was replying to my previous line comment, but the line that was
commented on has changed since.

My comment was:

There's still no test for the single parameter c-string overload.

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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via cfe-commits
On 1 Dec 2016 8:37 p.m., "Mads Ravn"  wrote:
> I see the idea for the fixit clearly for case 3 & 4. Just erase
.compare(str2) and replace 0 with str2. I have a quick question though:
Given the declRefExpr().bind("str2"), how do I read the name of it in
clang-tidy? Or should I just bind 0 as well and then create replacement
with str where const auto str = Result.Nodes.getNodeAs("str2") ?

You could use
FixItHint::CreateInsertionFromRange to copy str2 to 0, or leave str2 where
it is, remove the binary operator and create a new one between the strings.

> Where I seem to find a little trouble is how to fixit case 1 & 2 now that
they are reduced to one case. How do I check whether or not there is a
unary operator in front of the implicitCast?

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


[clang-tools-extra] r288384 - Add a blank line to make sphinx happy.

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:38:54 2016
New Revision: 288384

URL: http://llvm.org/viewvc/llvm-project?rev=288384=rev
Log:
Add a blank line to make sphinx happy.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst?rev=288384=288383=288384=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst 
Thu Dec  1 11:38:54 2016
@@ -1,4 +1,5 @@
 :orphan:
+
 .. title:: clang-tidy - modernize-use-default
 .. meta::
:http-equiv=refresh: 5;URL=modernize-use-equals-default.html


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


[clang-tools-extra] r288375 - [clang-tidy] Rename modernize-use-default to modernize-use-equals-default

2016-12-01 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  1 11:24:42 2016
New Revision: 288375

URL: http://llvm.org/viewvc/llvm-project?rev=288375=rev
Log:
[clang-tidy] Rename modernize-use-default to modernize-use-equals-default

Reviewers: angelgarcia, aaron.ballman, alexfh

Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.h
  - copied, changed from r288258, 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-default.rst
  - copied, changed from r288258, 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp
  - copied, changed from r288258, 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Removed:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Thu Dec  1 11:24:42 2016
@@ -226,8 +226,13 @@ def update_checks_list(clang_tidy_path):
   def format_link(doc_file):
 check_name = doc_file.replace('.rst', '')
 with open(os.path.join(docs_dir, doc_file), 'r') as doc:
+  content = doc.read()
+  match = re.search('.*:orphan:.*', content)
+  if match:
+return ''
+
   match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*',
-doc.read())
+content)
   if match:
 return '   %(check)s (redirects to %(target)s) <%(check)s>\n' % {
 'check': check_name,

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu Dec  1 
11:24:42 2016
@@ -16,8 +16,8 @@ add_clang_library(clangTidyModernizeModu
   ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp
-  UseDefaultCheck.cpp
   UseEmplaceCheck.cpp
+  UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=288375=288374=288375=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Thu 
Dec  1 11:24:42 2016
@@ -22,8 +22,8 @@
 #include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
-#include "UseDefaultCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
@@ -56,8 +56,8 @@ public:
 CheckFactories.registerCheck("modernize-use-auto");
 CheckFactories.registerCheck(
 "modernize-use-bool-literals");
-CheckFactories.registerCheck("modernize-use-default");

Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-01 Thread Malcolm Parsons via cfe-commits
On 1 December 2016 at 16:42, Mads Ravn  wrote:
> I have now implemented your suggestions - all but the fixit one. If I have
> added bindings for str1 and str2 in ast matcher, how would I go about
> creating a replacement for the entire implicitCastExpr or binaryOperator? I
> can't find any example in the code for clang-tidy to suggest how I would
> build a new node for the AST. Or I am looking at it from a wrong direction?

You create insertions, removals and replacements that affect the source code.
The AST is not changed.

Fix-it hints are documented here:
http://clang.llvm.org/docs/InternalsManual.html#fix-it-hints

Source locations and ranges are documented here:
http://clang.llvm.org/docs/InternalsManual.html#sourcelocation

To turn str1.compare(str2) into str1 == str2 you need to replace
".compare(" with " == " and remove ")".

You can get the SourceLocation of the . by calling getOperatorLoc() on
the MemberExpr.
You can tell if you have a . or an -> by calling isArrow() on the MemberExpr.
You can get the SourceLocation of the ) by calling getRParenLoc() on
the CXXMemberCallExpr.

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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-11-30 Thread Malcolm Parsons via cfe-commits
On 30 November 2016 at 17:18, Mads Ravn  wrote:
> So remove the ifStmt from the third and fourth case?

I was thinking all cases.
Can the first case be restricted to casts to bool?
If not, keep the cast to int case with an ifStmt and add a cast to bool case.
Does it matter whether the cast is implicit?

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


r288025 - [Sema] Set range end of constructors and destructors in template instantiations

2016-11-28 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Mon Nov 28 05:11:34 2016
New Revision: 288025

URL: http://llvm.org/viewvc/llvm-project?rev=288025=rev
Log:
[Sema] Set range end of constructors and destructors in template instantiations

Summary:
clang-tidy checks frequently use source ranges of functions.
The source range of constructors and destructors in template instantiations
is currently a single token.
The factory method for constructors and destructors does not allow the
end source location to be specified.
Set end location manually after creating instantiation.

Reviewers: aaron.ballman, rsmith, arphaman

Subscribers: arphaman, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/Misc/ast-dump-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=288025=288024=288025=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Nov 28 05:11:34 2016
@@ -1871,11 +1871,13 @@ TemplateDeclInstantiator::VisitCXXMethod
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,

Modified: cfe/trunk/test/Misc/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-decl.cpp?rev=288025=288024=288025=diff
==
--- cfe/trunk/test/Misc/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-decl.cpp Mon Nov 28 05:11:34 2016
@@ -223,6 +223,10 @@ namespace testClassTemplateDecl {
   class D { };
 
   template class TestClassTemplate {
+  public:
+TestClassTemplate();
+~TestClassTemplate();
+int j();
 int i;
   };
 
@@ -252,10 +256,18 @@ namespace testClassTemplateDecl {
 // CHECK-NEXT:   TemplateTypeParmDecl
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: TemplateArgument{{.*}}A
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
 // CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
@@ -269,11 +281,19 @@ namespace testClassTemplateDecl {
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}C
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}D
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplatePartialSpecializationDecl{{.*}} class 
TestClassTemplatePartial


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-22 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26137#602591, @Alpha wrote:

> This shouldn't affect diagnostics without fixes. If there is no fix, there 
> won't be anything to export, and the diagnostic just behaves normally.


That's a shame; I need a machine readable report of all diagnostics.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-22 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 78867.
malcolm.parsons added a comment.

Mention in release notes.


https://reviews.llvm.org/D26453

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  clang-tidy/misc/MoveConstructorInitCheck.h
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/misc-move-constructor-init.rst
  docs/clang-tidy/checks/modernize-pass-by-value.rst
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -1,4 +1,7 @@
-// RUN: %check_clang_tidy %s misc-move-constructor-init %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \
+// RUN: -- -std=c++11 -isystem %S/Inputs/Headers
 
 #include 
 
@@ -28,8 +31,8 @@
   D() : B() {}
   D(const D ) : B(RHS) {}
   // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init]
-  // CHECK-MESSAGES: 23:3: note: copy constructor being called
-  // CHECK-MESSAGES: 24:3: note: candidate move constructor here
+  // CHECK-MESSAGES: 26:3: note: copy constructor being called
+  // CHECK-MESSAGES: 27:3: note: candidate move constructor here
   D(D &) : B(RHS) {}
 };
 
@@ -96,7 +99,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
@@ -121,6 +124,7 @@
 };
 
 struct NegativeNotPassedByValue {
+  // This const ref constructor isn't warned about because the ValuesOnly option is set.
   NegativeNotPassedByValue(const Movable ) : M_(M) {}
   NegativeNotPassedByValue(const Movable M) : M_(M) {}
   NegativeNotPassedByValue(Movable ) : M_(M) {}
Index: docs/clang-tidy/checks/modernize-pass-by-value.rst
===
--- docs/clang-tidy/checks/modernize-pass-by-value.rst
+++ docs/clang-tidy/checks/modernize-pass-by-value.rst
@@ -159,3 +159,8 @@
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
+
+.. option:: ValuesOnly
+
+   When non-zero, the check only warns about copied parameters that are already
+   passed by value. Default is `0`.
Index: docs/clang-tidy/checks/misc-move-constructor-init.rst
===
--- docs/clang-tidy/checks/misc-move-constructor-init.rst
+++ docs/clang-tidy/checks/misc-move-constructor-init.rst
@@ -9,20 +9,10 @@
 initializing a member or base class through a copy constructor instead of a
 move constructor.
 
-It also flags constructor arguments that are passed by value, have a non-deleted
-move-constructor and are assigned to a class field by copy construction.
-
 Options
 ---
 
 .. option:: IncludeStyle
 
A string specifying which include-style is used, `llvm` or `google`. Default
is `llvm`.
-
-.. option:: UseCERTSemantics
-
-   When non-zero, the check conforms to the behavior expected by the CERT secure
-   coding recommendation
-   `OOP11-CPP `_.
-   Default is `0` for misc-move-constructor-init and `1` for cert-oop11-cpp.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -67,6 +67,11 @@
 
   Flags classes where some, but not all, special member functions are user-defined.
 
+- The UseCERTSemantics option for the `misc-move-constructor-init
+  `_ check
+  has been removed as it duplicated the `modernize-pass-by-value
+  `_ check.
+
 - New `misc-move-forwarding-reference
   `_ check
 
@@ -87,6 +92,11 @@
   `_
   now handle calls to the smart pointer's ``reset()`` method.
 
+- The `modernize-pass-by-value
+  `_ check
+  now has a ValuesOnly option to only warn about parameters 

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-22 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

What happens to diagnostics without fixes? e.g. from the 
readability-function-size check.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-11-20 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 78663.
malcolm.parsons added a comment.

Use llvm_unreachable.
Ignore template instantiations.


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,220 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i' [modernize-use-default-member-init]
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j' [modernize-use-default-member-init]
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd' [modernize-use-default-member-init]
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f' [modernize-use-default-member-init]
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e' [modernize-use-default-member-init]
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+template 
+struct NegativeTemplate {
+NegativeTemplate() : t() {}
+T t;
+};
+
+NegativeTemplate nti;
+NegativeTemplate ntd;
+
+struct NegativeDefaultMember {
+  NegativeDefaultMember() {}
+  int i = 2;
+};
+
+struct NegativeClass : S {
+  NegativeClass() : s() {}
+  S s;
+};
+
+struct NegativeBase : S {
+  NegativeBase() : S() {}
+};
+
+struct NegativeDefaultOtherMember{
+  NegativeDefaultOtherMember() : i(3) {}
+  int i = 4;
+};
+
+struct NegativeUnion {
+  NegativeUnion() : d(5.0) {}
+  union {
+int i;
+double d;
+  };
+};
+
+struct NegativeBitField
+{
+  NegativeBitField() : i(6) {}
+  int i : 5;
+};
+
+struct NegativeNotDefaultInt
+{
+  NegativeNotDefaultInt(int) : i(7) {}
+  int i;
+};
+
+struct ExistingInt {
+  ExistingInt(short) : e1(), e2(), e3(), e4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(short) :  e3(), e4() {}
+  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0) {}
+  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member 

[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

Does `Sema::CheckLiteralOperatorDeclaration` need to check 
`StringLiteralParser::isValidUDSuffix`?


https://reviews.llvm.org/D26829



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


[PATCH] D26849: [Sema] Set range end of constructors and destructors in template instantiations

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 78522.
malcolm.parsons added a comment.

Add test.


https://reviews.llvm.org/D26849

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/Misc/ast-dump-decl.cpp


Index: test/Misc/ast-dump-decl.cpp
===
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -223,6 +223,10 @@
   class D { };
 
   template class TestClassTemplate {
+  public:
+TestClassTemplate();
+~TestClassTemplate();
+int j();
 int i;
   };
 
@@ -252,10 +256,18 @@
 // CHECK-NEXT:   TemplateTypeParmDecl
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: TemplateArgument{{.*}}A
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
 // CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
@@ -269,11 +281,19 @@
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}C
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT:   TemplateArgument{{.*}}D
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT:   AccessSpecDecl{{.*}} public
+// CHECK-NEXT:   CXXConstructorDecl{{.*}} 
+// CHECK-NEXT:   CXXDestructorDecl{{.*}} 
+// CHECK-NEXT:   CXXMethodDecl{{.*}} 
 // CHECK-NEXT:   FieldDecl{{.*}} i
 
 // CHECK:  ClassTemplatePartialSpecializationDecl{{.*}} class 
TestClassTemplatePartial
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,


Index: test/Misc/ast-dump-decl.cpp
===
--- test/Misc/ast-dump-decl.cpp
+++ test/Misc/ast-dump-decl.cpp
@@ -223,6 +223,10 @@
   class D { };
 
   template class TestClassTemplate {
+  public:
+TestClassTemplate();
+~TestClassTemplate();
+int j();
 int i;
   };
 
@@ -252,10 +256,18 @@
 // CHECK-NEXT:   TemplateTypeParmDecl
 // CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 
 // CHECK-NEXT: FieldDecl{{.*}} i
 // CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
 // CHECK-NEXT: TemplateArgument{{.*}}A
 // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
+// CHECK-NEXT: AccessSpecDecl{{.*}} public
+// CHECK-NEXT: CXXConstructorDecl{{.*}} 
+// CHECK-NEXT: CXXDestructorDecl{{.*}} 
+// CHECK-NEXT: CXXMethodDecl{{.*}} 

[PATCH] D26847: Fix Internal Compiler Error compiling Clang with the latest version of MSVC

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

This file doesn't exist in clang.
Did you mean to report this to swift-clang?


Repository:
  rL LLVM

https://reviews.llvm.org/D26847



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


[PATCH] D26849: [Sema] Set range end of constructors and destructors in template instantiations

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, rsmith.
malcolm.parsons added a subscriber: cfe-commits.

clang-tidy checks frequently use source ranges of functions.
The source range of constructors and destructors in template instantiations
is currently a single token.
The factory method for constructors and destructors does not allow the 
end source location to be specified.
Set end location manually after creating instantiation.


https://reviews.llvm.org/D26849

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,


Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1871,11 +1871,13 @@
 Constructor->isExplicit(),
 Constructor->isInlineSpecified(),
 false, Constructor->isConstexpr());
+Method->setRangeEnd(Constructor->getLocEnd());
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Destructor->isInlineSpecified(),
false);
+Method->setRangeEnd(Destructor->getLocEnd());
   } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
 Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26829: [clang] Allow lexer to handle string_view literals

2016-11-18 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

@mclow.lists is working on this in https://reviews.llvm.org/D26667.
The review comments from that apply here too.


https://reviews.llvm.org/D26829



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


r287258 - Fixes for r287241. Use placement new. Apply clang-format.

2016-11-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 17 15:00:09 2016
New Revision: 287258

URL: http://llvm.org/viewvc/llvm-project?rev=287258=rev
Log:
Fixes for r287241. Use placement new. Apply clang-format.

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=287258=287257=287258=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu Nov 17 15:00:09 2016
@@ -2039,7 +2039,8 @@ void Parser::HandleMemberFunctionDeclDel
 LateMethod->DefaultArgs.reserve(FTI.NumParams);
 for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
   LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
-FTI.Params[ParamIdx].Param, 
std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
+  FTI.Params[ParamIdx].Param,
+  std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
   }
 }
 

Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=287258=287257=287258=diff
==
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Thu Nov 17 15:00:09 2016
@@ -223,15 +223,11 @@ DeclaratorChunk DeclaratorChunk::getFunc
 if (!TheDeclarator.InlineStorageUsed &&
 NumParams <= llvm::array_lengthof(TheDeclarator.InlineParams)) {
   I.Fun.Params = TheDeclarator.InlineParams;
-  // Zero the memory block so that unique pointers are initialized
-  // properly.
-  memset(I.Fun.Params, 0, sizeof(Params[0]) * NumParams);
+  new (I.Fun.Params) ParamInfo[NumParams];
   I.Fun.DeleteParams = false;
   TheDeclarator.InlineStorageUsed = true;
 } else {
-  // Call the version of new that zeroes memory so that unique pointers
-  // are initialized properly.
-  I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams]();
+  I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
   I.Fun.DeleteParams = true;
 }
 for (unsigned i = 0; i < NumParams; i++)

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=287258=287257=287258=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Nov 17 15:00:09 2016
@@ -395,7 +395,8 @@ void Sema::CheckExtraCXXDefaultArguments
++argIdx) {
 ParmVarDecl *Param = cast(chunk.Fun.Params[argIdx].Param);
 if (Param->hasUnparsedDefaultArg()) {
-  std::unique_ptr Toks = 
std::move(chunk.Fun.Params[argIdx].DefaultArgTokens);
+  std::unique_ptr Toks =
+  std::move(chunk.Fun.Params[argIdx].DefaultArgTokens);
   SourceRange SR;
   if (Toks->size() > 1)
 SR = SourceRange((*Toks)[1].getLocation(),


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


[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-17 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287241: Use unique_ptr for cached tokens for default 
arguments in C++. (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26435?vs=78375=78380#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26435

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Index: cfe/trunk/include/clang/Sema/DeclSpec.h
===
--- cfe/trunk/include/clang/Sema/DeclSpec.h
+++ cfe/trunk/include/clang/Sema/DeclSpec.h
@@ -1188,14 +1188,14 @@
 /// declaration of a member function), it will be stored here as a
 /// sequence of tokens to be parsed once the class definition is
 /// complete. Non-NULL indicates that there is a default argument.
-CachedTokens *DefaultArgTokens;
+std::unique_ptr DefaultArgTokens;
 
 ParamInfo() = default;
 ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
   Decl *param,
-  CachedTokens *DefArgTokens = nullptr)
+  std::unique_ptr DefArgTokens = nullptr)
   : Ident(ident), IdentLoc(iloc), Param(param),
-DefaultArgTokens(DefArgTokens) {}
+DefaultArgTokens(std::move(DefArgTokens)) {}
   };
 
   struct TypeAndRange {
@@ -1310,10 +1310,8 @@
 ///
 /// This is used in various places for error recovery.
 void freeParams() {
-  for (unsigned I = 0; I < NumParams; ++I) {
-delete Params[I].DefaultArgTokens;
-Params[I].DefaultArgTokens = nullptr;
-  }
+  for (unsigned I = 0; I < NumParams; ++I)
+Params[I].DefaultArgTokens.reset();
   if (DeleteParams) {
 delete[] Params;
 DeleteParams = false;
Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -1017,17 +1017,17 @@
   /// (C++ [class.mem]p2).
   struct LateParsedDefaultArgument {
 explicit LateParsedDefaultArgument(Decl *P,
-   CachedTokens *Toks = nullptr)
-  : Param(P), Toks(Toks) { }
+   std::unique_ptr Toks = nullptr)
+  : Param(P), Toks(std::move(Toks)) { }
 
 /// Param - The parameter declaration for this parameter.
 Decl *Param;
 
 /// Toks - The sequence of tokens that comprises the default
 /// argument expression, not including the '=' or the terminating
 /// ')' or ','. This will be NULL for parameters that have no
 /// default argument.
-CachedTokens *Toks;
+std::unique_ptr Toks;
   };
 
   /// LateParsedMethodDeclaration - A method declaration inside a class that
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -2039,7 +2039,7 @@
 LateMethod->DefaultArgs.reserve(FTI.NumParams);
 for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
   LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
-FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens));
+FTI.Params[ParamIdx].Param, std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
   }
 }
 
Index: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
===
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
@@ -319,7 +319,8 @@
 // Introduce the parameter into scope.
 bool HasUnparsed = Param->hasUnparsedDefaultArg();
 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
-if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
+std::unique_ptr Toks = std::move(LM.DefaultArgs[I].Toks);
+if (Toks) {
   // Mark the end of the default argument so that we know when to stop when
   // we parse it later on.
   Token LastDefaultArgToken = Toks->back();
@@ -377,9 +378,6 @@
 
   if (Tok.is(tok::eof) && Tok.getEofData() == Param)
 ConsumeAnyToken();
-
-  delete Toks;
-  LM.DefaultArgs[I].Toks = nullptr;
 } else if (HasUnparsed) {
   assert(Param->hasInheritedDefaultArg());
   FunctionDecl *Old = cast(LM.Method)->getPreviousDecl();
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -6022,7 +6022,7 @@
 
 // DefArgToks is used when the parsing of default arguments needs
 // to be delayed.
-CachedTokens *DefArgToks = nullptr;
+std::unique_ptr DefArgToks;
 
 // If no 

r287241 - Use unique_ptr for cached tokens for default arguments in C++.

2016-11-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 17 11:52:58 2016
New Revision: 287241

URL: http://llvm.org/viewvc/llvm-project?rev=287241=rev
Log:
Use unique_ptr for cached tokens for default arguments in C++.

Summary:
This changes pointers to cached tokens for default arguments in C++ from raw 
pointers to unique_ptrs.  There was a fixme in the code where the cached tokens 
are created  about using a smart pointer.

The change is straightforward, though I did have to track down and fix a memory 
corruption caused by the change.  memcpy was being used to copy parameter 
information.  This duplicated the unique_ptr, which led to the cached token 
buffer being deleted prematurely.

Patch by David Tarditi!

Reviewers: malcolm.parsons

Subscribers: arphaman, malcolm.parsons, cfe-commits

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

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=287241=287240=287241=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Nov 17 11:52:58 2016
@@ -1017,8 +1017,8 @@ private:
   /// (C++ [class.mem]p2).
   struct LateParsedDefaultArgument {
 explicit LateParsedDefaultArgument(Decl *P,
-   CachedTokens *Toks = nullptr)
-  : Param(P), Toks(Toks) { }
+   std::unique_ptr Toks = 
nullptr)
+  : Param(P), Toks(std::move(Toks)) { }
 
 /// Param - The parameter declaration for this parameter.
 Decl *Param;
@@ -1027,7 +1027,7 @@ private:
 /// argument expression, not including the '=' or the terminating
 /// ')' or ','. This will be NULL for parameters that have no
 /// default argument.
-CachedTokens *Toks;
+std::unique_ptr Toks;
   };
 
   /// LateParsedMethodDeclaration - A method declaration inside a class that

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=287241=287240=287241=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Thu Nov 17 11:52:58 2016
@@ -1188,14 +1188,14 @@ struct DeclaratorChunk {
 /// declaration of a member function), it will be stored here as a
 /// sequence of tokens to be parsed once the class definition is
 /// complete. Non-NULL indicates that there is a default argument.
-CachedTokens *DefaultArgTokens;
+std::unique_ptr DefaultArgTokens;
 
 ParamInfo() = default;
 ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
   Decl *param,
-  CachedTokens *DefArgTokens = nullptr)
+  std::unique_ptr DefArgTokens = nullptr)
   : Ident(ident), IdentLoc(iloc), Param(param),
-DefaultArgTokens(DefArgTokens) {}
+DefaultArgTokens(std::move(DefArgTokens)) {}
   };
 
   struct TypeAndRange {
@@ -1310,10 +1310,8 @@ struct DeclaratorChunk {
 ///
 /// This is used in various places for error recovery.
 void freeParams() {
-  for (unsigned I = 0; I < NumParams; ++I) {
-delete Params[I].DefaultArgTokens;
-Params[I].DefaultArgTokens = nullptr;
-  }
+  for (unsigned I = 0; I < NumParams; ++I)
+Params[I].DefaultArgTokens.reset();
   if (DeleteParams) {
 delete[] Params;
 DeleteParams = false;

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=287241=287240=287241=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Nov 17 11:52:58 2016
@@ -319,7 +319,8 @@ void Parser::ParseLexedMethodDeclaration
 // Introduce the parameter into scope.
 bool HasUnparsed = Param->hasUnparsedDefaultArg();
 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
-if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
+std::unique_ptr Toks = std::move(LM.DefaultArgs[I].Toks);
+if (Toks) {
   // Mark the end of the default argument so that we know when to stop when
   // we parse it later on.
   Token LastDefaultArgToken = Toks->back();
@@ -377,9 +378,6 @@ void Parser::ParseLexedMethodDeclaration
 
   if (Tok.is(tok::eof) && Tok.getEofData() == Param)
 ConsumeAnyToken();
-
-  delete Toks;
-  LM.DefaultArgs[I].Toks = 

[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-17 Thread Malcolm Parsons via cfe-commits
malcolm.parsons accepted this revision.
malcolm.parsons added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D26435



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-11-17 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 78363.
malcolm.parsons added a comment.

Remove doubled spaces


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,202 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i' [modernize-use-default-member-init]
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j' [modernize-use-default-member-init]
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd' [modernize-use-default-member-init]
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f' [modernize-use-default-member-init]
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e' [modernize-use-default-member-init]
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+struct NegativeMemberInit {
+  NegativeMemberInit() {}
+  int i = 2;
+};
+
+struct NegativeClass : S {
+  NegativeClass() : s() {}
+  S s;
+};
+
+struct NegativeBase : S {
+  NegativeBase() : S() {}
+};
+
+struct NegativeDefaultOtherMember{
+  NegativeDefaultOtherMember() : i(3) {}
+  int i = 4;
+};
+
+struct NegativeUnion {
+  NegativeUnion() : d(5.0) {}
+  union {
+int i;
+double d;
+  };
+};
+
+struct NegativeBitField
+{
+  NegativeBitField() : i(6) {}
+  int i : 5;
+};
+
+struct NegativeNotDefaultInt
+{
+  NegativeNotDefaultInt(int) : i(7) {}
+  int i;
+};
+
+struct ExistingInt {
+  ExistingInt(short) : e1(), e2(), e3(), e4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(short) :  e3(), e4() {}
+  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0) {}
+  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member initializer for 'e3' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: member initializer for 'e4' is redundant 

[clang-tools-extra] r287226 - [docs] Remove doubled spaces

2016-11-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 17 08:26:45 2016
New Revision: 287226

URL: http://llvm.org/viewvc/llvm-project?rev=287226=rev
Log:
[docs] Remove doubled spaces

Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

Modified:
clang-tools-extra/trunk/docs/ModularizeUsage.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-sizeof-expression.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-raw-string-literal.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-faster-string-find.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/docs/index.rst
clang-tools-extra/trunk/docs/modularize.rst
clang-tools-extra/trunk/docs/pp-trace.rst

Modified: clang-tools-extra/trunk/docs/ModularizeUsage.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ModularizeUsage.rst?rev=287226=287225=287226=diff
==
--- clang-tools-extra/trunk/docs/ModularizeUsage.rst (original)
+++ clang-tools-extra/trunk/docs/ModularizeUsage.rst Thu Nov 17 08:26:45 2016
@@ -10,9 +10,9 @@ specific to modularize, which are descri
 `Modularize Command Line Options`.
 
  specifies the path of a file name for an
-existing module map.  The module map must be well-formed in
-terms of syntax.  Modularize will extract the header file names
-from the map.  Only normal headers are checked, assuming headers
+existing module map. The module map must be well-formed in
+terms of syntax. Modularize will extract the header file names
+from the map. Only normal headers are checked, assuming headers
 marked "private", "textual", or "exclude" are not to be checked
 as a top-level include, assuming they either are included by
 other headers which are checked, or they are not suitable for
@@ -32,7 +32,7 @@ but must be on the same line. For exampl
 
 Note that unless a ``-prefix (header path)`` option is specified,
 non-absolute file paths in the header list file will be relative
-to the header list file directory.  Use -prefix to specify a different
+to the header list file directory. Use -prefix to specify a different
 directory.
 
  is a place-holder for regular Clang
@@ -53,24 +53,24 @@ Modularize Command Line Options
 
   Prepend the given path to non-absolute file paths in the header list file.
   By default, headers are assumed to be relative to the header list file
-  directory.  Use ``-prefix`` to specify a different directory.
+  directory. Use ``-prefix`` to specify a different directory.
 
 .. option:: -module-map-path=
 
-  Generate a module map and output it to the given file.  See the description
+  Generate a module map and output it to the given file. See the description
   in :ref:`module-map-generation`.
   
 .. option:: -problem-files-list=
 
-  For use only with module map assistant.  Input list of files that
-  have problems with respect to modules.  These will still be
+  For use only with module map assistant. Input list of files that
+  have problems with respect to modules. These will still be
   included in the generated module map, but will be marked as
   "excluded" headers.
 
 .. option:: -root-module=
 
   Put modules generated by the -module-map-path option in an enclosing
-  module with the given name.  See the description in 
:ref:`module-map-generation`.
+  module with the given name. See the description in 
:ref:`module-map-generation`.
 
 .. option:: -block-check-header-list-only
 
@@ -93,6 +93,6 @@ Modularize Command Line Options
   and a combined list with problem files preceded by a '#'.
   This can be used to quickly determine which files have problems.
   The latter combined list might be useful in starting to modularize
-  a set of headers.  You can start with a full list of headers,
+  a set of headers. You can start with a full list of headers,
   use -display-file-lists option, and then use the combined list as
   your intermediate list, uncommenting-out headers as you fix them.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst?rev=287226=287225=287226=diff
==
--- 

[PATCH] D26798: [docs] Remove doubled spaces

2016-11-17 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287226: [docs] Remove doubled spaces (authored by 
malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26798?vs=78361=78362#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26798

Files:
  clang-tools-extra/trunk/docs/ModularizeUsage.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-sizeof-expression.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-raw-string-literal.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-faster-string-find.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst
  clang-tools-extra/trunk/docs/clang-tidy/index.rst
  clang-tools-extra/trunk/docs/include-fixer.rst
  clang-tools-extra/trunk/docs/index.rst
  clang-tools-extra/trunk/docs/modularize.rst
  clang-tools-extra/trunk/docs/pp-trace.rst

Index: clang-tools-extra/trunk/docs/modularize.rst
===
--- clang-tools-extra/trunk/docs/modularize.rst
+++ clang-tools-extra/trunk/docs/modularize.rst
@@ -18,7 +18,7 @@
 map.
 
 :program:`modularize` also has an assistant mode option for generating
-a module map file based on the provided header list.  The generated file
+a module map file based on the provided header list. The generated file
 is a functional module map that can be used as a starting point for a
 module.map file.
 
@@ -115,10 +115,10 @@
 =
 
 The coverage check uses the Clang library to read and parse the
-module map file.  Starting at the module map file directory, or just the
+module map file. Starting at the module map file directory, or just the
 include paths, if specified, it will collect the names of all the files it
 considers headers (no extension, .h, or .inc--if you need more, modify the
-isHeader function).  It then compares the headers against those referenced
+isHeader function). It then compares the headers against those referenced
 in the module map, either explicitly named, or implicitly named via an
 umbrella directory or umbrella file, as parsed by the ModuleMap object.
 If headers are found which are not referenced or covered by an umbrella
@@ -128,7 +128,7 @@
 
 Note that in the case of umbrella headers, this tool invokes the compiler
 to preprocess the file, and uses a callback to collect the header files
-included by the umbrella header or any of its nested includes.  If any
+included by the umbrella header or any of its nested includes. If any
 front end options are needed for these compiler invocations, these
 can be included on the command line after the module map file argument.
 
@@ -154,10 +154,10 @@
 
 If you specify the ``-module-map-path=``,
 :program:`modularize` will output a module map based on the input header list.
-A module will be created for each header.  Also, if the header in the header
+A module will be created for each header. Also, if the header in the header
 list is a partial path, a nested module hierarchy will be created in which a
 module will be created for each subdirectory component in the header path,
-with the header itself represented by the innermost module.  If other headers
+with the header itself represented by the innermost module. If other headers
 use the same subdirectories, they will be enclosed in these same modules also.
 
 For example, for the header list::
@@ -258,8 +258,8 @@
 to be included first.
 
 The module map format defines some keywords which can't be used in module
-names.  If a header has one of these names, an underscore ('_') will be
-prepended to the name.  For example, if the header name is ``header.h``,
+names. If a header has one of these names, an underscore ('_') will be
+prepended to the name. For example, if the header name is ``header.h``,
 because ``header`` is a keyword, the module name will be ``_header``.
 For a list of the module map keywords, please see:
 `Lexical structure `_
Index: clang-tools-extra/trunk/docs/pp-trace.rst
===
--- clang-tools-extra/trunk/docs/pp-trace.rst
+++ clang-tools-extra/trunk/docs/pp-trace.rst
@@ -8,11 +8,11 @@
:hidden:
 
 :program:`pp-trace` is a standalone tool that traces preprocessor
-activity.  It's also used as a test of Clang's PPCallbacks interface.
+activity. It's also used as a test of Clang's PPCallbacks interface.
 It runs a given source file through the Clang preprocessor, displaying
 

[PATCH] D26798: [docs] Remove doubled spaces

2016-11-17 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added a reviewer: aaron.ballman.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

https://reviews.llvm.org/D26798

Files:
  docs/ModularizeUsage.rst
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-cstyle-cast.rst
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  docs/clang-tidy/checks/misc-sizeof-expression.rst
  docs/clang-tidy/checks/modernize-raw-string-literal.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  docs/clang-tidy/checks/modernize-use-default.rst
  docs/clang-tidy/checks/modernize-use-emplace.rst
  docs/clang-tidy/checks/performance-faster-string-find.rst
  docs/clang-tidy/checks/readability-braces-around-statements.rst
  docs/clang-tidy/index.rst
  docs/include-fixer.rst
  docs/index.rst
  docs/modularize.rst
  docs/pp-trace.rst

Index: docs/pp-trace.rst
===
--- docs/pp-trace.rst
+++ docs/pp-trace.rst
@@ -8,11 +8,11 @@
:hidden:
 
 :program:`pp-trace` is a standalone tool that traces preprocessor
-activity.  It's also used as a test of Clang's PPCallbacks interface.
+activity. It's also used as a test of Clang's PPCallbacks interface.
 It runs a given source file through the Clang preprocessor, displaying
 selected information from callback functions overridden in a
 `PPCallbacks `_
-derivation.  The output is in a high-level YAML format, described in
+derivation. The output is in a high-level YAML format, described in
 :ref:`OutputFormat`.
 
 .. _Usage:
@@ -43,8 +43,8 @@
 .. option:: -ignore 
 
   This option specifies a comma-separated list of names of callbacks
-  that shouldn't be traced.  It can be used to eliminate unwanted
-  trace output.  The callback names are the name of the actual
+  that shouldn't be traced. It can be used to eliminate unwanted
+  trace output. The callback names are the name of the actual
   callback function names in the PPCallbacks class:
 
   * FileChanged
@@ -80,16 +80,16 @@
 
 .. option:: -output 
 
-  By default, pp-trace outputs the trace information to stdout.  Use this
+  By default, pp-trace outputs the trace information to stdout. Use this
   option to output the trace information to a file.
 
 .. _OutputFormat:
 
 pp-trace Output Format
 ==
 
-The pp-trace output is formatted as YAML.  See http://yaml.org/ for general
-YAML information.  It's arranged as a sequence of information about the
+The pp-trace output is formatted as YAML. See http://yaml.org/ for general
+YAML information. It's arranged as a sequence of information about the
 callback call, including the callback name and argument information, for
 example:::
 
@@ -135,9 +135,9 @@
 callback function parameter.
 
 The Argument Value Syntax field describes the values that will be displayed
-for the argument value.  It uses an ad hoc representation that mixes literal
-and symbolic representations.  Enumeration member symbols are shown as the
-actual enum member in a (member1|member2|...) form.  A name in parentheses
+for the argument value. It uses an ad hoc representation that mixes literal
+and symbolic representations. Enumeration member symbols are shown as the
+actual enum member in a (member1|member2|...) form. A name in parentheses
 can either represent a place holder for the described value, or confusingly,
 it might be a literal, such as (null), for a null pointer.
 Locations are shown as quoted only to avoid confusing the documentation generator.
@@ -154,18 +154,18 @@
 
 
 FileChanged is called when the preprocessor enters or exits a file, both the
-top level file being compiled, as well as any #include directives.  It will
+top level file being compiled, as well as any #include directives. It will
 also be called as a result of a system header pragma or in internal renaming
 of a file.
 
 Argument descriptions:
 
 ==   ==   == ==
 Argument NameArgument Value SyntaxClang C++ Type Description   
 ==   ==   == ==
-Loc  "(file):(line):(col)"SourceLocation The location of the directive.
-Reason   (EnterFile|ExitFile|SystemHeaderPragma|RenameFile)   PPCallbacks::FileChangeReason  Reason for change.
-FileType (C_User|C_System|C_ExternCSystem)SrcMgr::CharacteristicKind Include type. 
+Loc  "(file):(line):(col)"SourceLocation The location of the 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-11-17 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: docs/clang-tidy/checks/modernize-use-default-member-init.rst:7
+This check converts a default constructor's member initializers into default
+member initializers.  Other member initializers that match the default
+member initializer are removed.  This can reduce repeated code or allow use of

Eugene.Zelenko wrote:
> Please fix double spaces. Same below.
If you like, but what harm are they causing?


Repository:
  rL LLVM

https://reviews.llvm.org/D26750



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


[PATCH] D26751: [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

2016-11-17 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287221: [clang-tidy] Ignore template instantiations in 
modernize-use-equals-delete check (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26751?vs=78202=78344#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26751

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
@@ -22,6 +22,32 @@
   // CHECK-FIXES: ~PositivePrivate() = delete;
 };
 
+template
+struct PositivePrivateTemplate {
+private:
+  PositivePrivateTemplate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate() = delete;
+  PositivePrivateTemplate(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(const PositivePrivateTemplate &) = 
delete;
+  PositivePrivateTemplate =(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate =(const 
PositivePrivateTemplate &) = delete;
+  PositivePrivateTemplate(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(PositivePrivateTemplate &&) = delete;
+  PositivePrivateTemplate =(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate =(PositivePrivateTemplate 
&&) = delete;
+  ~PositivePrivateTemplate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: ~PositivePrivateTemplate() = delete;
+};
+
+template struct PositivePrivateTemplate;
+template struct PositivePrivateTemplate;
+
 struct NegativePublic {
   NegativePublic(const NegativePublic &);
 };
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -34,6 +34,7 @@
   cxxMethodDecl(
   PrivateSpecialFn,
   unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+   ast_matchers::isTemplateInstantiation(),
// Ensure that all methods except private special member
// functions are defined.
hasParent(cxxRecordDecl(hasMethod(unless(


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
@@ -22,6 +22,32 @@
   // CHECK-FIXES: ~PositivePrivate() = delete;
 };
 
+template
+struct PositivePrivateTemplate {
+private:
+  PositivePrivateTemplate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate() = delete;
+  PositivePrivateTemplate(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(const PositivePrivateTemplate &) = delete;
+  PositivePrivateTemplate =(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate =(const PositivePrivateTemplate &) = delete;
+  PositivePrivateTemplate(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(PositivePrivateTemplate &&) = delete;
+  PositivePrivateTemplate =(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: 

[clang-tools-extra] r287221 - [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

2016-11-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 17 05:40:02 2016
New Revision: 287221

URL: http://llvm.org/viewvc/llvm-project?rev=287221=rev
Log:
[clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

Summary: Template instantiations were causing misplaced fixits.

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: hokein, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=287221=287220=287221=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Thu 
Nov 17 05:40:02 2016
@@ -34,6 +34,7 @@ void UseEqualsDeleteCheck::registerMatch
   cxxMethodDecl(
   PrivateSpecialFn,
   unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+   ast_matchers::isTemplateInstantiation(),
// Ensure that all methods except private special member
// functions are defined.
hasParent(cxxRecordDecl(hasMethod(unless(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp?rev=287221=287220=287221=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp Thu 
Nov 17 05:40:02 2016
@@ -22,6 +22,32 @@ private:
   // CHECK-FIXES: ~PositivePrivate() = delete;
 };
 
+template
+struct PositivePrivateTemplate {
+private:
+  PositivePrivateTemplate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate() = delete;
+  PositivePrivateTemplate(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(const PositivePrivateTemplate &) = 
delete;
+  PositivePrivateTemplate =(const PositivePrivateTemplate &);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate =(const 
PositivePrivateTemplate &) = delete;
+  PositivePrivateTemplate(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate(PositivePrivateTemplate &&) = delete;
+  PositivePrivateTemplate =(PositivePrivateTemplate &&);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: PositivePrivateTemplate =(PositivePrivateTemplate 
&&) = delete;
+  ~PositivePrivateTemplate();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit 
calling of a special member function [modernize-use-equals-delete]
+  // CHECK-FIXES: ~PositivePrivateTemplate() = delete;
+};
+
+template struct PositivePrivateTemplate;
+template struct PositivePrivateTemplate;
+
 struct NegativePublic {
   NegativePublic(const NegativePublic &);
 };


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


[PATCH] D26751: [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check

2016-11-17 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/modernize/UseEqualsDeleteCheck.cpp:37
   unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+   ast_matchers::isTemplateInstantiation(),
// Ensure that all methods except private special member

hokein wrote:
> Can we remove `ast_matchers::`?
No, there's a collision with 
`isTemplateInstantiation(TemplateSpecializationKind Kind)`.


https://reviews.llvm.org/D26751



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


[PATCH] D26741: [clang-tidy] Changes to modernize-use-default check

2016-11-17 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287215: [clang-tidy] Changes to modernize-use-default check 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26741?vs=78164=78328#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26741

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -249,11 +249,14 @@
   if (!Body)
 return;
 
-  // If there are comments inside the body, don't do the change.
-  if (!SpecialFunctionDecl->isCopyAssignmentOperator() &&
-  !bodyEmpty(Result.Context, Body))
+  // If there is code inside the body, don't warn.
+  if (!SpecialFunctionDecl->isCopyAssignmentOperator() && !Body->body_empty())
 return;
 
+  // If there are comments inside the body, don't do the change.
+  bool ApplyFix = SpecialFunctionDecl->isCopyAssignmentOperator() ||
+  bodyEmpty(Result.Context, Body);
+
   std::vector RemoveInitializers;
 
   if (const auto *Ctor = dyn_cast(SpecialFunctionDecl)) {
@@ -277,10 +280,18 @@
 SpecialFunctionName = "copy-assignment operator";
   }
 
-  diag(SpecialFunctionDecl->getLocStart(),
-   "use '= default' to define a trivial " + SpecialFunctionName)
-  << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
-  << RemoveInitializers;
+  // The location of the body is more useful inside a macro as spelling and
+  // expansion locations are reported.
+  SourceLocation Location = SpecialFunctionDecl->getLocation();
+  if (Location.isMacroID())
+Location = Body->getLocStart();
+
+  auto Diag = diag(Location, "use '= default' to define a trivial " +
+ SpecialFunctionName);
+
+  if (ApplyFix)
+Diag << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
+ << RemoveInitializers;
 }
 
 } // namespace modernize
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
@@ -92,10 +92,10 @@
 class KW {
 public:
   explicit KW() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use '= default'
   // CHECK-FIXES: explicit KW() = default;
   virtual ~KW() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use '= default'
   // CHECK-FIXES: virtual ~KW() = default;
 };
 
@@ -134,11 +134,11 @@
 
 template 
 TempODef::TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
 // CHECK-FIXES: TempODef::TempODef() = default;
 template 
 TempODef::~TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
 // CHECK-FIXES: TempODef::~TempODef() = default;
 
 template class TempODef;
@@ -178,9 +178,11 @@
   Comments() {
 // Don't erase comments inside the body.
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
   ~Comments() {
 // Don't erase comments inside the body.
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
 };
 
 // Try-catch.
@@ -195,3 +197,13 @@
 };
 OTC::OTC() try {} catch(...) {}
 OTC::~OTC() try {} catch(...) {}
+
+#define STRUCT_WITH_DEFAULT(_base, _type) \
+  struct _type {  \
+_type() {}\
+_base value;  \
+  };
+
+STRUCT_WITH_DEFAULT(unsigned char, Hex8Default)
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor
+// CHECK-MESSAGES: :[[@LINE-6]]:13: note:
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp

[clang-tools-extra] r287215 - [clang-tidy] Changes to modernize-use-default check

2016-11-17 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov 17 03:14:04 2016
New Revision: 287215

URL: http://llvm.org/viewvc/llvm-project?rev=287215=rev
Log:
[clang-tidy] Changes to modernize-use-default check

Summary:
Warn about special member functions that only contain a comment.
Report the location of the special member function, unless it is
defined in a macro.  Reporting the location of the body in a macro is
more helpful as it causes the macro expansion location to be reported too.

Fixes PR30920.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=287215=287214=287215=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Thu Nov 17 
03:14:04 2016
@@ -249,11 +249,14 @@ void UseDefaultCheck::check(const MatchF
   if (!Body)
 return;
 
-  // If there are comments inside the body, don't do the change.
-  if (!SpecialFunctionDecl->isCopyAssignmentOperator() &&
-  !bodyEmpty(Result.Context, Body))
+  // If there is code inside the body, don't warn.
+  if (!SpecialFunctionDecl->isCopyAssignmentOperator() && !Body->body_empty())
 return;
 
+  // If there are comments inside the body, don't do the change.
+  bool ApplyFix = SpecialFunctionDecl->isCopyAssignmentOperator() ||
+  bodyEmpty(Result.Context, Body);
+
   std::vector RemoveInitializers;
 
   if (const auto *Ctor = dyn_cast(SpecialFunctionDecl)) {
@@ -277,10 +280,18 @@ void UseDefaultCheck::check(const MatchF
 SpecialFunctionName = "copy-assignment operator";
   }
 
-  diag(SpecialFunctionDecl->getLocStart(),
-   "use '= default' to define a trivial " + SpecialFunctionName)
-  << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
-  << RemoveInitializers;
+  // The location of the body is more useful inside a macro as spelling and
+  // expansion locations are reported.
+  SourceLocation Location = SpecialFunctionDecl->getLocation();
+  if (Location.isMacroID())
+Location = Body->getLocStart();
+
+  auto Diag = diag(Location, "use '= default' to define a trivial " +
+ SpecialFunctionName);
+
+  if (ApplyFix)
+Diag << FixItHint::CreateReplacement(Body->getSourceRange(), "= default;")
+ << RemoveInitializers;
 }
 
 } // namespace modernize

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp?rev=287215=287214=287215=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-copy.cpp Thu 
Nov 17 03:14:04 2016
@@ -7,13 +7,13 @@ struct OL {
   int Field;
 };
 OL::OL(const OL ) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a 
trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a 
trivial copy constructor [modernize-use-default]
 // CHECK-FIXES: OL::OL(const OL )  = default;
 OL ::operator=(const OL ) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a 
trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a 
trivial copy-assignment operator [modernize-use-default]
 // CHECK-FIXES: OL ::operator=(const OL ) = default;
 
 // Inline.
@@ -25,7 +25,7 @@ struct IL {
 Field = Other.Field;
 return *this;
   }
-  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use '= default'
   // CHECK-FIXES: IL =(const IL ) = default;
   int Field;
 };
@@ -110,7 +110,7 @@ struct Empty {
   Empty =(const Empty &);
 };
 Empty ::operator=(const Empty ) { return *this; }
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use '= default'
 // CHECK-FIXES: Empty ::operator=(const Empty ) = default;
 
 // Bit fields.
@@ -137,7 +137,7 @@ BF ::operator=(const BF ) {
   Field4 = Other.Field4;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-7]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: use '= default'
 // CHECK-FIXES: BF ::operator=(const 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-11-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, Eugene.Zelenko, alexfh.
malcolm.parsons added a subscriber: cfe-commits.
Herald added subscribers: modocache, mgorny.

Fixes PR18858


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,202 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i' [modernize-use-default-member-init]
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j' [modernize-use-default-member-init]
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd' [modernize-use-default-member-init]
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f' [modernize-use-default-member-init]
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a' [modernize-use-default-member-init]
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q' [modernize-use-default-member-init]
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e' [modernize-use-default-member-init]
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+struct NegativeMemberInit {
+  NegativeMemberInit() {}
+  int i = 2;
+};
+
+struct NegativeClass : S {
+  NegativeClass() : s() {}
+  S s;
+};
+
+struct NegativeBase : S {
+  NegativeBase() : S() {}
+};
+
+struct NegativeDefaultOtherMember{
+  NegativeDefaultOtherMember() : i(3) {}
+  int i = 4;
+};
+
+struct NegativeUnion {
+  NegativeUnion() : d(5.0) {}
+  union {
+int i;
+double d;
+  };
+};
+
+struct NegativeBitField
+{
+  NegativeBitField() : i(6) {}
+  int i : 5;
+};
+
+struct NegativeNotDefaultInt
+{
+  NegativeNotDefaultInt(int) : i(7) {}
+  int i;
+};
+
+struct ExistingInt {
+  ExistingInt(short) : e1(), e2(), e3(), e4() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(short) :  e3(), e4() {}
+  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
+  // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant [modernize-use-default-member-init]
+  // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0) {}
+  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member initializer for 'e3' is redundant 

[PATCH] D26742: [RecursiveASTVisitor] Fix post-order traversal of UnaryOperator

2016-11-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, klimek, teemperor, doug.gregor.
malcolm.parsons added a subscriber: cfe-commits.

https://reviews.llvm.org/D26742

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/AST/PostOrderASTVisitor.cpp


Index: unittests/AST/PostOrderASTVisitor.cpp
===
--- unittests/AST/PostOrderASTVisitor.cpp
+++ unittests/AST/PostOrderASTVisitor.cpp
@@ -34,6 +34,11 @@
 
 bool shouldTraversePostOrder() const { return VisitPostOrder; }
 
+bool VisitUnaryOperator(UnaryOperator *Op) {
+  VisitedNodes.push_back(Op->getOpcodeStr(Op->getOpcode()));
+  return true;
+}
+
 bool VisitBinaryOperator(BinaryOperator *Op) {
   VisitedNodes.push_back(Op->getOpcodeStr());
   return true;
@@ -76,7 +81,7 @@
   auto ASTUnit = tooling::buildASTFromCode(
 "class A {"
 "  class B {"
-"int foo() { while(4) { int i = 9; } return (1 + 3) + 2; }"
+"int foo() { while(4) { int i = 9; int j = -i; } return (1 + 3) + 2; }"
 "  };"
 "};"
   );
@@ -87,7 +92,7 @@
   Visitor.TraverseTranslationUnitDecl(TU);
 
   std::vector expected = {
-"4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A"
+"4", "9", "i", "-", "j", "1", "3", "+", "2", "+", "return", "A::B::foo", 
"A::B", "A"
   };
   // Compare the list of actually visited nodes
   // with the expected list of visited nodes.
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -357,7 +357,8 @@
 #define OPERATOR(NAME) 
\
   bool TraverseUnary##NAME(UnaryOperator *S,   
\
DataRecursionQueue *Queue = nullptr) {  
\
-TRY_TO(WalkUpFromUnary##NAME(S));  
\
+if (!getDerived().shouldTraversePostOrder())   
\
+  TRY_TO(WalkUpFromUnary##NAME(S));
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
 return true;   
\
   }
\


Index: unittests/AST/PostOrderASTVisitor.cpp
===
--- unittests/AST/PostOrderASTVisitor.cpp
+++ unittests/AST/PostOrderASTVisitor.cpp
@@ -34,6 +34,11 @@
 
 bool shouldTraversePostOrder() const { return VisitPostOrder; }
 
+bool VisitUnaryOperator(UnaryOperator *Op) {
+  VisitedNodes.push_back(Op->getOpcodeStr(Op->getOpcode()));
+  return true;
+}
+
 bool VisitBinaryOperator(BinaryOperator *Op) {
   VisitedNodes.push_back(Op->getOpcodeStr());
   return true;
@@ -76,7 +81,7 @@
   auto ASTUnit = tooling::buildASTFromCode(
 "class A {"
 "  class B {"
-"int foo() { while(4) { int i = 9; } return (1 + 3) + 2; }"
+"int foo() { while(4) { int i = 9; int j = -i; } return (1 + 3) + 2; }"
 "  };"
 "};"
   );
@@ -87,7 +92,7 @@
   Visitor.TraverseTranslationUnitDecl(TU);
 
   std::vector expected = {
-"4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A"
+"4", "9", "i", "-", "j", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A"
   };
   // Compare the list of actually visited nodes
   // with the expected list of visited nodes.
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -357,7 +357,8 @@
 #define OPERATOR(NAME) \
   bool TraverseUnary##NAME(UnaryOperator *S,   \
DataRecursionQueue *Queue = nullptr) {  \
-TRY_TO(WalkUpFromUnary##NAME(S));  \
+if (!getDerived().shouldTraversePostOrder())   \
+  TRY_TO(WalkUpFromUnary##NAME(S));\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  \
 return true;   \
   }\
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26741: [clang-tidy] Changes to modernize-use-default check

2016-11-16 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh.
malcolm.parsons added a subscriber: cfe-commits.

Warn about special member functions that only contain a comment.
Report the location of the special member function, unless it is
defined in a macro.  Reporting the location of the body in a macro is
more helpful as it causes the macro expansion location to be reported too.

Fixes PR30920.


https://reviews.llvm.org/D26741

Files:
  clang-tidy/modernize/UseDefaultCheck.cpp
  test/clang-tidy/modernize-use-default-copy.cpp
  test/clang-tidy/modernize-use-default.cpp

Index: test/clang-tidy/modernize-use-default.cpp
===
--- test/clang-tidy/modernize-use-default.cpp
+++ test/clang-tidy/modernize-use-default.cpp
@@ -8,10 +8,10 @@
 };
 
 OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
 // CHECK-FIXES: OL::OL() = default;
 OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial destructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
 // CHECK-FIXES: OL::~OL() = default;
 
 // Inline definitions.
@@ -92,10 +92,10 @@
 class KW {
 public:
   explicit KW() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use '= default'
   // CHECK-FIXES: explicit KW() = default;
   virtual ~KW() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use '= default'
   // CHECK-FIXES: virtual ~KW() = default;
 };
 
@@ -134,11 +134,11 @@
 
 template 
 TempODef::TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
 // CHECK-FIXES: TempODef::TempODef() = default;
 template 
 TempODef::~TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
 // CHECK-FIXES: TempODef::~TempODef() = default;
 
 template class TempODef;
@@ -178,9 +178,11 @@
   Comments() {
 // Don't erase comments inside the body.
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
   ~Comments() {
 // Don't erase comments inside the body.
   }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
 };
 
 // Try-catch.
@@ -195,3 +197,13 @@
 };
 OTC::OTC() try {} catch(...) {}
 OTC::~OTC() try {} catch(...) {}
+
+#define STRUCT_WITH_DEFAULT(_base, _type) \
+  struct _type {  \
+_type() {}\
+_base value;  \
+  };
+
+STRUCT_WITH_DEFAULT(unsigned char, Hex8Default)
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor
+// CHECK-MESSAGES: :[[@LINE-6]]:13: note:
Index: test/clang-tidy/modernize-use-default-copy.cpp
===
--- test/clang-tidy/modernize-use-default-copy.cpp
+++ test/clang-tidy/modernize-use-default-copy.cpp
@@ -7,13 +7,13 @@
   int Field;
 };
 OL::OL(const OL ) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
 // CHECK-FIXES: OL::OL(const OL )  = default;
 OL ::operator=(const OL ) {
   Field = Other.Field;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-4]]:1: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
+// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
 // CHECK-FIXES: OL ::operator=(const OL ) = default;
 
 // Inline.
@@ -25,7 +25,7 @@
 Field = Other.Field;
 return *this;
   }
-  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use '= default'
+  // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use '= default'
   // CHECK-FIXES: IL =(const IL ) = default;
   int Field;
 };
@@ -110,7 +110,7 @@
   Empty =(const Empty &);
 };
 Empty ::operator=(const Empty ) { return *this; }
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use '= default'
 // CHECK-FIXES: Empty ::operator=(const Empty ) = default;
 
 // Bit fields.
@@ -137,7 +137,7 @@
   Field4 = Other.Field4;
   return *this;
 }
-// CHECK-MESSAGES: :[[@LINE-7]]:1: warning: use '= default'
+// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: use '= default'
 // CHECK-FIXES: BF ::operator=(const BF ) = default;
 
 // Base classes.
@@ -153,7 +153,7 @@
   BF::operator=(Other);
 

[clang-tools-extra] r287091 - [clang-tidy] Handle template instantiations in modenize-use-default check

2016-11-16 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Nov 16 03:51:40 2016
New Revision: 287091

URL: http://llvm.org/viewvc/llvm-project?rev=287091=rev
Log:
[clang-tidy] Handle template instantiations in modenize-use-default check

Summary:
Duplicate fixes were being created for explicit template instantiations
of out-of-line constructors or destructors.

Fixes PR30921.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=287091=287090=287091=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Wed Nov 16 
03:51:40 2016
@@ -241,6 +241,7 @@ void UseDefaultCheck::check(const MatchF
   if (SpecialFunctionDecl->isDeleted() ||
   SpecialFunctionDecl->isExplicitlyDefaulted() ||
   SpecialFunctionDecl->isLateTemplateParsed() ||
+  SpecialFunctionDecl->isTemplateInstantiation() ||
   !SpecialFunctionDecl->isUserProvided() || 
!SpecialFunctionDecl->hasBody())
 return;
 

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp?rev=287091=287090=287091=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp Wed Nov 
16 03:51:40 2016
@@ -124,6 +124,26 @@ public:
   // CHECK-FIXES: ~Temp() = default;
 };
 
+// Class template out of line with explicit instantiation.
+template 
+class TempODef {
+public:
+  TempODef();
+  ~TempODef();
+};
+
+template 
+TempODef::TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::TempODef() = default;
+template 
+TempODef::~TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::~TempODef() = default;
+
+template class TempODef;
+template class TempODef;
+
 // Non user-provided constructor/destructor.
 struct Imp {
   int Int;


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


[PATCH] D26582: [clang-tidy] Handle template instantiations in modenize-use-default check

2016-11-16 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287091: [clang-tidy] Handle template instantiations in 
modenize-use-default check (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26582?vs=77728=78151#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26582

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -124,6 +124,26 @@
   // CHECK-FIXES: ~Temp() = default;
 };
 
+// Class template out of line with explicit instantiation.
+template 
+class TempODef {
+public:
+  TempODef();
+  ~TempODef();
+};
+
+template 
+TempODef::TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::TempODef() = default;
+template 
+TempODef::~TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::~TempODef() = default;
+
+template class TempODef;
+template class TempODef;
+
 // Non user-provided constructor/destructor.
 struct Imp {
   int Int;
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -241,6 +241,7 @@
   if (SpecialFunctionDecl->isDeleted() ||
   SpecialFunctionDecl->isExplicitlyDefaulted() ||
   SpecialFunctionDecl->isLateTemplateParsed() ||
+  SpecialFunctionDecl->isTemplateInstantiation() ||
   !SpecialFunctionDecl->isUserProvided() || 
!SpecialFunctionDecl->hasBody())
 return;
 


Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -124,6 +124,26 @@
   // CHECK-FIXES: ~Temp() = default;
 };
 
+// Class template out of line with explicit instantiation.
+template 
+class TempODef {
+public:
+  TempODef();
+  ~TempODef();
+};
+
+template 
+TempODef::TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::TempODef() = default;
+template 
+TempODef::~TempODef() {}
+// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use '= default'
+// CHECK-FIXES: TempODef::~TempODef() = default;
+
+template class TempODef;
+template class TempODef;
+
 // Non user-provided constructor/destructor.
 struct Imp {
   int Int;
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -241,6 +241,7 @@
   if (SpecialFunctionDecl->isDeleted() ||
   SpecialFunctionDecl->isExplicitlyDefaulted() ||
   SpecialFunctionDecl->isLateTemplateParsed() ||
+  SpecialFunctionDecl->isTemplateInstantiation() ||
   !SpecialFunctionDecl->isUserProvided() || !SpecialFunctionDecl->hasBody())
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-15 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26435#595282, @dtarditi wrote:

> What platform/OS did you build on?


I build release with asserts on 64 bit Linux. My host compiler is gcc.


https://reviews.llvm.org/D26435



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


[PATCH] D26453: [clang-tidy] Remove duplicated check from move-constructor-init

2016-11-15 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26453#596254, @aaron.ballman wrote:

> (This part of the check is one half modernization, one half performance, and 
> one half correctness, depending on which lens you view the code through.)


The performance part should be handled by performance-unnecessary-value-param.
It should warn in this situation, but not create a fix that would conflict with 
modernize-pass-by-value's fix.


https://reviews.llvm.org/D26453



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


  1   2   3   4   >