diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-06 03:04:50 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-12-06 03:04:50 +0000 |
commit | d5e839429771ad4d1a8b3db598cbbc6d93621f75 (patch) | |
tree | 6b52ca0523078ccfc70127f5c37520484bfaab93 /lib/AST/ASTContext.cpp | |
parent | c213262e4a98fa16fd9acc099297f361fed0fda1 (diff) |
Don't use dyn_cast on a Type* which might not be canonical. Fixes an extremely obscure record layout bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a1faaa00ec..44f13b6906 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3994,7 +3994,8 @@ ASTContext::getConstantArrayElementCount(const ConstantArrayType *CA) const { uint64_t ElementCount = 1; do { ElementCount *= CA->getSize().getZExtValue(); - CA = dyn_cast<ConstantArrayType>(CA->getElementType()); + CA = dyn_cast_or_null<ConstantArrayType>( + CA->getElementType()->getAsArrayTypeUnsafe()); } while (CA); return ElementCount; } |