diff options
author | Chad Rosier <mcrosier@apple.com> | 2013-02-06 00:58:34 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2013-02-06 00:58:34 +0000 |
commit | 5e25301c24c92a9b7018cee20e524c4eb7192bf0 (patch) | |
tree | 9bb64e06ae51b39c4837f19842d6e67250c439f2 /lib/Sema/SemaChecking.cpp | |
parent | 1fc271c38aaa68dce73d6f1bee9f6fd3474e51f0 (diff) |
Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc.
rdar://13153516
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174477 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8db183105e..800f64cd5c 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -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 (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) - return false; + if (const ConstantArrayTypeLoc *CTL = dyn_cast<ConstantArrayTypeLoc>(&TL)) { + const Expr *SizeExpr = dyn_cast<IntegerLiteral>(CTL->getSizeExpr()); + if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) + return false; + } break; } |