Prevent modernize-use-auto from emitting a warning when 'auto' was already being used.
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=25082 .
Reviewers: bkramer, klimek
Subscribers: cfe-commits, alexfh
Differential Revision: http://reviews.llvm.org/D13504
llvm-svn: 250284
diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
index a940547..1469909 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
@@ -222,6 +222,9 @@
has(varDecl()),
unless(has(varDecl(anyOf(
unless(hasInitializer(ignoringParenImpCasts(cxxNewExpr()))),
+ // Skip declarations that are already using auto.
+ anyOf(hasType(autoType()),
+ hasType(pointerType(pointee(autoType())))),
// FIXME: TypeLoc information is not reliable where CV
// qualifiers are concerned so these types can't be
// handled for now.