Fix use-auto-check.

Summary: Fix a bug where use-auto check would crash when the definition of a type is in the same statement than its instantiation with new.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D12551

llvm-svn: 246638
This commit is contained in:
Angel Garcia Gomez 2015-09-02 10:20:00 +00:00
parent 1e583704f5
commit e6035de11e
2 changed files with 3 additions and 1 deletions

View File

@ -298,7 +298,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {
}
void UseAutoCheck::replaceNew(const DeclStmt *D, ASTContext *Context) {
const auto *FirstDecl = cast<VarDecl>(*D->decl_begin());
const auto *FirstDecl = dyn_cast<VarDecl>(*D->decl_begin());
// Ensure that there is at least one VarDecl within the DeclStmt.
if (!FirstDecl)
return;

View File

@ -37,6 +37,8 @@ void auto_new() {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
// CHECK-FIXES: auto volatile vol = new MyType();
struct SType {} *stype = new SType;
int (**func)(int, int) = new (int(*[5])(int,int));
int *array = new int[5];