summaryrefslogtreecommitdiffstats
path: root/clang/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
commit7808c6aa7e929486c289608edb1f9a1efc3e5c8a (patch)
treefac97e82750d941df4f4159cb01fa80856fb44f1 /clang/lib/AST/ASTContext.cpp
parent7964ab5e49d25cfd16c51cee9911f6b036ac488c (diff)
downloadbcm5719-llvm-7808c6aa7e929486c289608edb1f9a1efc3e5c8a.tar.gz
bcm5719-llvm-7808c6aa7e929486c289608edb1f9a1efc3e5c8a.zip
Don't use dyn_cast on a Type* which might not be canonical. Fixes an extremely obscure record layout bug.
llvm-svn: 169467
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a1faaa00ec4..44f13b6906f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud