aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-12-06 03:04:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-12-06 03:04:50 +0000
commitd5e839429771ad4d1a8b3db598cbbc6d93621f75 (patch)
tree6b52ca0523078ccfc70127f5c37520484bfaab93 /lib/AST/ASTContext.cpp
parentc213262e4a98fa16fd9acc099297f361fed0fda1 (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.cpp3
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;
}