IsTailPaddedMemberArray uses a FieldDecl's

getTypeSourceInfo() without checking for NULL.
FieldDecls may have NULL TypeSourceInfo, and in
fact some FieldDecls generated by Clang -- and
all FieldDecls generated by LLDB -- have no
TypeSourceInfo.

This patch makes IsTailPaddedMemberArray check
for NULL.

llvm-svn: 156186
This commit is contained in:
Sean Callanan 2012-05-04 18:22:53 +00:00
parent 566e40775b
commit 06a48a62b3
1 changed files with 9 additions and 5 deletions

View File

@ -4587,11 +4587,15 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size,
// Don't consider sizes resulting from macro expansions or template argument
// substitution to form C89 tail-padded arrays.
TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
if (TInfo) {
ConstantArrayTypeLoc TL =
cast<ConstantArrayTypeLoc>(FD->getTypeSourceInfo()->getTypeLoc());
cast<ConstantArrayTypeLoc>(TInfo->getTypeLoc());
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
return false;
}
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
if (!RD) return false;