summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-08-07 18:08:19 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-08-07 18:08:19 +0000
commit885727581c10332bef9e97f247d3ed9e5e974d40 (patch)
treeb0cf4e349a3a2361d0a47143f2bde723dbf542e4 /clang/lib/AST/ASTContext.cpp
parent50985962d6ecbac43ac9e1f20aa52efd2e2f5b2b (diff)
downloadbcm5719-llvm-885727581c10332bef9e97f247d3ed9e5e974d40.tar.gz
bcm5719-llvm-885727581c10332bef9e97f247d3ed9e5e974d40.zip
Correctly allign arrays on 32 bit systems.
Before this patch we would align long long int big[1024]; to 4 bytes on 32 bit systems. The problem is that we were only looking at the element type when getLargeArrayMinWidth returned non zero. llvm-svn: 187897
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 65e5e6daaa5..c4bda1f14a7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1286,13 +1286,14 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool RefAsPointee) const {
// Adjust alignments of declarations with array type by the
// large-array alignment on the target.
unsigned MinWidth = Target->getLargeArrayMinWidth();
- const ArrayType *arrayType;
- if (MinWidth && (arrayType = getAsArrayType(T))) {
- if (isa<VariableArrayType>(arrayType))
- Align = std::max(Align, Target->getLargeArrayAlign());
- else if (isa<ConstantArrayType>(arrayType) &&
- MinWidth <= getTypeSize(cast<ConstantArrayType>(arrayType)))
- Align = std::max(Align, Target->getLargeArrayAlign());
+ if (const ArrayType *arrayType = getAsArrayType(T)) {
+ if (MinWidth) {
+ if (isa<VariableArrayType>(arrayType))
+ Align = std::max(Align, Target->getLargeArrayAlign());
+ else if (isa<ConstantArrayType>(arrayType) &&
+ MinWidth <= getTypeSize(cast<ConstantArrayType>(arrayType)))
+ Align = std::max(Align, Target->getLargeArrayAlign());
+ }
// Walk through any array types while we're at it.
T = getBaseElementType(arrayType);
OpenPOWER on IntegriCloud