Author: angelgarcia Date: Wed Oct 14 04:29:55 2015 New Revision: 250284 URL: http://llvm.org/viewvc/llvm-project?rev=250284&view=rev Log: 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 Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.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=250284&r1=250283&r2=250284&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Wed Oct 14 04:29:55 2015 @@ -222,6 +222,9 @@ StatementMatcher makeDeclWithNewMatcher( 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. Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp?rev=250284&r1=250283&r2=250284&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp Wed Oct 14 04:29:55 2015 @@ -95,4 +95,9 @@ void auto_new() { // 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(); + auto *paut = new MyType(); + const auto *pcaut = new MyType(); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits