Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc.

rdar://13153516

llvm-svn: 174477
This commit is contained in:
Chad Rosier 2013-02-06 00:58:34 +00:00
parent 906ba47143
commit 7029992807
1 changed files with 5 additions and 4 deletions

View File

@ -5777,10 +5777,11 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size,
TInfo = TDL->getTypeSourceInfo();
continue;
}
ConstantArrayTypeLoc CTL = cast<ConstantArrayTypeLoc>(TL);
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(CTL.getSizeExpr());
if (const ConstantArrayTypeLoc *CTL = dyn_cast<ConstantArrayTypeLoc>(&TL)) {
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(CTL->getSizeExpr());
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
return false;
}
break;
}