Skip to content

Commit 06a48a6

Browse files
committed
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
1 parent 566e407 commit 06a48a6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4587,11 +4587,15 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size,
45874587

45884588
// Don't consider sizes resulting from macro expansions or template argument
45894589
// substitution to form C89 tail-padded arrays.
4590-
ConstantArrayTypeLoc TL =
4591-
cast<ConstantArrayTypeLoc>(FD->getTypeSourceInfo()->getTypeLoc());
4592-
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
4593-
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
4594-
return false;
4590+
4591+
TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
4592+
if (TInfo) {
4593+
ConstantArrayTypeLoc TL =
4594+
cast<ConstantArrayTypeLoc>(TInfo->getTypeLoc());
4595+
const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
4596+
if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
4597+
return false;
4598+
}
45954599

45964600
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
45974601
if (!RD) return false;

0 commit comments

Comments
 (0)