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 &Parents = 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: 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; +}