angelgarcia created this revision. angelgarcia added reviewers: klimek, bkramer. angelgarcia added subscribers: alexfh, cfe-commits.
This fixes https://llvm.org/bugs/show_bug.cgi?id=25082 . http://reviews.llvm.org/D13504 Files: clang-tidy/modernize/UseAutoCheck.cpp test/clang-tidy/modernize-use-auto-new.cpp Index: test/clang-tidy/modernize-use-auto-new.cpp =================================================================== --- test/clang-tidy/modernize-use-auto-new.cpp +++ test/clang-tidy/modernize-use-auto-new.cpp @@ -95,4 +95,7 @@ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new // CHECK-FIXES: auto g = new int*, h = new int_p; } + + // Don't warn when 'auto' is already being used. + auto aut = new MyType(); } Index: clang-tidy/modernize/UseAutoCheck.cpp =================================================================== --- clang-tidy/modernize/UseAutoCheck.cpp +++ clang-tidy/modernize/UseAutoCheck.cpp @@ -222,6 +222,8 @@ has(varDecl()), unless(has(varDecl(anyOf( unless(hasInitializer(ignoringParenImpCasts(cxxNewExpr()))), + // Skip declarations that are already using auto. + hasType(autoType()), // FIXME: TypeLoc information is not reliable where CV // qualifiers are concerned so these types can't be // handled for now.
Index: test/clang-tidy/modernize-use-auto-new.cpp =================================================================== --- test/clang-tidy/modernize-use-auto-new.cpp +++ test/clang-tidy/modernize-use-auto-new.cpp @@ -95,4 +95,7 @@ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new // CHECK-FIXES: auto g = new int*, h = new int_p; } + + // Don't warn when 'auto' is already being used. + auto aut = new MyType(); } Index: clang-tidy/modernize/UseAutoCheck.cpp =================================================================== --- clang-tidy/modernize/UseAutoCheck.cpp +++ clang-tidy/modernize/UseAutoCheck.cpp @@ -222,6 +222,8 @@ has(varDecl()), unless(has(varDecl(anyOf( unless(hasInitializer(ignoringParenImpCasts(cxxNewExpr()))), + // Skip declarations that are already using auto. + hasType(autoType()), // FIXME: TypeLoc information is not reliable where CV // qualifiers are concerned so these types can't be // handled for now.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits