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
This commit is contained in:
parent
baf573eb4c
commit
2df36481b6
|
@ -222,6 +222,9 @@ StatementMatcher makeDeclWithNewMatcher() {
|
||||||
has(varDecl()),
|
has(varDecl()),
|
||||||
unless(has(varDecl(anyOf(
|
unless(has(varDecl(anyOf(
|
||||||
unless(hasInitializer(ignoringParenImpCasts(cxxNewExpr()))),
|
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
|
// FIXME: TypeLoc information is not reliable where CV
|
||||||
// qualifiers are concerned so these types can't be
|
// qualifiers are concerned so these types can't be
|
||||||
// handled for now.
|
// handled for now.
|
||||||
|
|
|
@ -95,4 +95,9 @@ void auto_new() {
|
||||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
|
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
|
||||||
// CHECK-FIXES: auto g = new int*, h = new int_p;
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue