[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks, looks better now, but still a few comments, mostly nits.




Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:701
+  const ASTContext::DynTypedNodeList  = Context->getParents(*DeclRef);
+  if (!Parents.empty()) {
+const Stmt *ST = Parents[0].get();

Please use early return:

  if (Parents.empty())
return false;



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:702
+  if (!Parents.empty()) {
+const Stmt *ST = Parents[0].get();
+// Ignore ImplicitCastExpr if we find one.

Same here:
  if (!ST)
return false;



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:710
+}
+if (ST && isa(ST))
+  return true;

And here just `return ST && isa(ST);`



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:810
 SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+bool LambdaDeclRef = isLambda(DeclRef, Result.Context);
+if (LambdaDeclRef) {

Let's drop this variable. The code is going to be simpler without it:

  if (isLambda(DeclRef, Result.Context)) {
StringRef CaptureText = ...;
if (CaptureText != "=" && CaptureText != "&") {
  addUsage(...);
  return;
}
  }



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:812
+if (LambdaDeclRef) {
+  std::string captureText =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(Range),

Lexer::getSourceText returns a StringRef, there's no need to copy its contents.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:812
+if (LambdaDeclRef) {
+  std::string captureText =
+  Lexer::getSourceText(CharSourceRange::getTokenRange(Range),

alexfh wrote:
> Lexer::getSourceText returns a StringRef, there's no need to copy its 
> contents.
nit: CaptureText



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:815
+   *Result.SourceManager, getLangOpts());
+  if (!(captureText == "=" || captureText == "&"))
+LambdaDeclRef = false;

I find it easier to understand, if negation is propagated through the 
parentheses:

  if (captureText != "=" && captureText != "&")




Comment at: test/clang-tidy/readability-identifier-naming.cpp:506
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local 
variable 'Columns'

alexfh wrote:
> If the formatting is not critical for the logic of the test, please 
> clang-format the new test code.
nit: The formatting is still off here, e.g. missing spaces around the equals 
sign.



Comment at: test/clang-tidy/readability-identifier-naming.cpp:508
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local 
variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr = [&]{

Let's make the CHECK-FIXES lines unique to reduce the chance of mixing them up 
and to make identifying broken test cases easier. One way to do this is to make 
the variable names distinct, another way is to add unique trailing comments 
both in the code and in the CHECK-FIXES patterns.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-04-05 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D59540#1456011 , @MyDeveloperDay 
wrote:

> friendly ping


Sorry for the delay. Feel free to ping earlier. And more frequently :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-04-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

friendly ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 5 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: test/clang-tidy/readability-identifier-naming.cpp:509
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();

alexfh wrote:
> Please add more tests with
>   1) by value automatic captures
>   2) manual captures by value
>   3) manual captures by reference
>   4) nested lambdas capturing the same variable
> 
> A bit more nested code inside the lambda would also be interesting (where the 
> use of the variable would be wrapped in a couple of compound statements).
Think i've covered the cases you wanted here, if you can think of another drop 
the code into a comment and I'll add it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 191365.
MyDeveloperDay added a comment.

Address review comments
This may not be a more satisfactory solution  but it at least now covers the 
other cases raised by @JonasToth 
Add more tests around this area.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -501,3 +501,159 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+
+bool LambdaCaptureTest() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr = [&]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest1() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr = [=]{
+return Columns;
+  // CHECK-FIXES: {{^}}return columns;
+  }();
+
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest2() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = []{
+// CHECK-FIXES: {{^}}  auto ptr = []{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest3() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest4() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [&]{
+if (true)
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest5() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [](bool Columns) {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for parameter 'Columns'
+// CHECK-FIXES: {{^}}  auto ptr = [](bool a_columns) {
+return Columns;
+// CHECK-FIXES: {{^}}return a_columns;
+  };
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest6() {
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Columns]() ->bool {
+// CHECK-FIXES: {{^}}  auto ptr = [columns]() ->bool {
+  [=]() -> bool {
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+};
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  };
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest7() {
+  int  a;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [, a]{
+// CHECK-FIXES: {{^}}  auto ptr = [, a]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest8() {
+  int a;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [a, Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [a, columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool LambdaCaptureTest9() {
+  int Rows;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for local variable 'Rows'
+// CHECK-FIXES: {{^}}  int rows;
+  bool Columns = false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns = false;
+  auto ptr = [Rows, Columns]{
+// CHECK-FIXES: {{^}}  auto ptr = [rows, columns]{
+return Columns;
+// CHECK-FIXES: {{^}}return columns;
+  }();
+  return Columns;
+// 

[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:790
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
-SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+const auto  = Result.Context->getParents(*DeclRef);
+bool LambdaDeclRef = false;

Type is not obvious, so auto should not be used.



Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:797
+  if (ST && isa(ST)) {
+const auto  = Result.Context->getParents(*ST);
+if (!CastParents.empty())

Type is not obvious, so auto should not be used.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks for fixing this! Could you expand the test a bit? See the inline comment.




Comment at: test/clang-tidy/readability-identifier-naming.cpp:506
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local 
variable 'Columns'

If the formatting is not critical for the logic of the test, please 
clang-format the new test code.



Comment at: test/clang-tidy/readability-identifier-naming.cpp:509
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();

Please add more tests with
  1) by value automatic captures
  2) manual captures by value
  3) manual captures by reference
  4) nested lambdas capturing the same variable

A bit more nested code inside the lambda would also be interesting (where the 
use of the variable would be wrapped in a couple of compound statements).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 191311.
MyDeveloperDay added a comment.

Minor modification to improve the `[=]` case

`[]` and `[Columns]` are not yet fixed and will not be correctly 
renamed to `[]` and `[columns]`

But at least they are left unaltered


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp

Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -501,3 +501,43 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo1() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[=]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[=]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo2() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[]{return Columns;}();
+// XXX_CHECK-FIXES: {{^}}  auto ptr=[]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
+
+bool Foo3() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[Columns]{return Columns;}();
+// XXX_CHECK-FIXES: {{^}}  auto ptr=[columns]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -396,7 +396,7 @@
 
   if (isa(D) && NamingStyles[SK_ObjcIvar])
 return SK_ObjcIvar;
-  
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 
@@ -506,7 +506,7 @@
   return SK_ParameterPack;
 
 if (!Type.isNull() && Type.getTypePtr()->isAnyPointerType() && NamingStyles[SK_PointerParameter])
-return SK_PointerParameter;
+  return SK_PointerParameter;
 
 if (NamingStyles[SK_Parameter])
   return SK_Parameter;
@@ -557,7 +557,7 @@
 
 if (Decl->isStaticLocal() && NamingStyles[SK_StaticVariable])
   return SK_StaticVariable;
- 
+
 if (Decl->isLocalVarDecl() && Type.getTypePtr()->isAnyPointerType() && NamingStyles[SK_LocalPointer])
   return SK_LocalPointer;
 
@@ -787,10 +787,28 @@
   }
 
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
-SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+const auto  = Result.Context->getParents(*DeclRef);
+bool LambdaDeclRef = false;
+
+if (!Parents.empty()) {
+  const Stmt *ST = Parents[0].get();
+  // Step over the ImplicitCastExpr
+  if (ST && isa(ST)) {
+const auto  = Result.Context->getParents(*ST);
+if (!CastParents.empty())
+  ST = CastParents[0].get();
+  }
+
+  if (ST && isa(ST))
+LambdaDeclRef = true;
+}
+
+if (!LambdaDeclRef) {
+  SourceRange Range = DeclRef->getNameInfo().getSourceRange();
+  addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
+   Result.SourceManager);
+  return;
+}
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay planned changes to this revision.
MyDeveloperDay added a comment.

In D59540#1434837 , @JonasToth wrote:

> What happens on `[=]() ...`, direct capture `[]()...` and 
> `[Columns]()...`?


Thanks for the review... in answer to your question.. not great!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

What happens on `[=]() ...`, direct capture `[]()...` and 
`[Columns]()...`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59540/new/

https://reviews.llvm.org/D59540



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


[PATCH] D59540: [clang-tidy] [PR41119] readability-identifier-naming incorrectly fixes lambda capture

2019-03-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: JonasToth, aaron.ballman, alexfh, 
michaelplatings.
MyDeveloperDay added a project: clang-tools-extra.
Herald added subscribers: jdoerfert, xazax.hun.

While testing clang-tidy for D59251: [Documentation] Proposal for plan to 
change variable names  I found that a lambda 
capture could get incorrectly get transformed by readability-identifier-naming 
when run with -fix

The following code:

  bool foo() {
bool Columns=false;
auto ptr=[&] {
return Columns;
  }();
return true;
  }

would get transformed to  (replace `[&]` with `[columns]`

  bool foo() {
bool columns=false;
auto ptr=[columns] {
return columns;
  }();
return true;
  }

This is caused by the presence of a declrefexpr in the LambdaExpr, seeming 
having the location of the [&] (line 3 column 13), but also having the Name 
"Columns"

| -DeclRefExpr  'bool' lvalue Var 0x55f0145f1c80 'Columns' 'bool' |
|



  LambdaExpr  '(lambda at line:3:12)'
|-CXXRecordDecl  col:12 implicit class definition
| |-DefinitionData lambda pass_in_registers 
trivially_copyable can_const_default_init
| | |-DefaultConstructor
| | |-CopyConstructor simple trivial has_const_param 
needs_implicit implicit_has_const_param
| | |-MoveConstructor exists simple trivial needs_implicit
| | |-CopyAssignment trivial has_const_param needs_implicit 
implicit_has_const_param
| | |-MoveAssignment
| | `-Destructor simple irrelevant trivial
| |-FieldDecl  col:18 implicit 'bool &'
| |-CXXMethodDecl  line:3:12 used 
operator() 'auto () const -> bool' inline
| | `-CompoundStmt 
| |   `-ReturnStmt 
| | `-ImplicitCastExpr  'bool' 
| |   `-DeclRefExpr  'bool' lvalue Var 
0x55f0145f1c80 'Columns' 'bool'
| `-CXXDestructorDecl  col:12 implicit 
referenced ~ 'void () noexcept' inline default trivial
|-DeclRefExpr  'bool' lvalue Var 0x55f0145f1c80 
'Columns' 'bool'
`-CompoundStmt 
  `-ReturnStmt 
`-ImplicitCastExpr  'bool' 
  `-DeclRefExpr  'bool' lvalue Var 
0x55f0145f1c80 'Columns' 'bool'

The following code tries to detect the DeclRefExpr in the LambdaExpr, and not 
add this to the usage map

This issue is logged as https://bugs.llvm.org/show_bug.cgi?id=41119

I have retested this against lib/Clang/Format and this issue is resolved.

  // Don't use this Format, if the difference between the longest and shortest
  // element in a column exceeds a threshold to avoid excessive spaces.
  if ([&] {
for (unsigned i = 0; i < columns - 1; ++i)
  if (format.ColumnSizes[i] - minSizeInColumn[i] > 10)
return true;
return false;
  }())
continue;




https://reviews.llvm.org/D59540

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -501,3 +501,13 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+
+bool Foo() {
+  bool Columns=false;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for local 
variable 'Columns'
+// CHECK-FIXES: {{^}}  bool columns=false;
+  auto ptr=[&]{return Columns;}();
+// CHECK-FIXES: {{^}}  auto ptr=[&]{return columns;}();
+  return Columns;
+// CHECK-FIXES: {{^}}  return columns;
+}
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -787,10 +787,22 @@
   }
 
   if (const auto *DeclRef = Result.Nodes.getNodeAs("declRef")) {
-SourceRange Range = DeclRef->getNameInfo().getSourceRange();
-addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
- Result.SourceManager);
-return;
+const auto  = Result.Context->getParents(*DeclRef);
+bool LambdaDeclRef = false;
+
+if (!Parents.empty()) {
+  const Stmt *ST = Parents[0].get();
+
+  if (ST && isa(ST))
+LambdaDeclRef = true;
+}
+
+if (!LambdaDeclRef) {
+  SourceRange Range = DeclRef->getNameInfo().getSourceRange();
+  addUsage(NamingCheckFailures, DeclRef->getDecl(), Range,
+   Result.SourceManager);
+  return;
+}
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {


Index: