forked from OSchip/llvm-project
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:
parent
566e40775b
commit
06a48a62b3
|
@ -4587,11 +4587,15 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size,
|
||||||
|
|
||||||
// Don't consider sizes resulting from macro expansions or template argument
|
// Don't consider sizes resulting from macro expansions or template argument
|
||||||
// substitution to form C89 tail-padded arrays.
|
// substitution to form C89 tail-padded arrays.
|
||||||
|
|
||||||
|
TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
|
||||||
|
if (TInfo) {
|
||||||
ConstantArrayTypeLoc TL =
|
ConstantArrayTypeLoc TL =
|
||||||
cast<ConstantArrayTypeLoc>(FD->getTypeSourceInfo()->getTypeLoc());
|
cast<ConstantArrayTypeLoc>(TInfo->getTypeLoc());
|
||||||
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
|
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
|
||||||
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
|
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
|
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
|
||||||
if (!RD) return false;
|
if (!RD) return false;
|
||||||
|
|
Loading…
Reference in New Issue