From d2cf348f0df76bf1745f131db2ceeb59f23a7305 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Fri, 4 May 2012 18:22:53 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156186 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaChecking.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 4504a6a1e1..44f4ac671f 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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. - ConstantArrayTypeLoc TL = - cast(FD->getTypeSourceInfo()->getTypeLoc()); - const Expr *SizeExpr = dyn_cast(TL.getSizeExpr()); - if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) - return false; + + TypeSourceInfo *TInfo = FD->getTypeSourceInfo(); + if (TInfo) { + ConstantArrayTypeLoc TL = + cast(TInfo->getTypeLoc()); + const Expr *SizeExpr = dyn_cast(TL.getSizeExpr()); + if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) + return false; + } const RecordDecl *RD = dyn_cast(FD->getDeclContext()); if (!RD) return false; -- 2.50.1