diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-10 23:43:44 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-06-10 23:43:44 +0000 |
commit | d7e1fe40e15ea5e077628daf6b742bb69eab65a7 (patch) | |
tree | 074f346edcb027050abb2f4129991cf70df61d45 /clang/lib/AST/ASTContext.cpp | |
parent | f6d7030f0f99de010dbf2737dc4a58b234e0f4b6 (diff) | |
download | bcm5719-llvm-d7e1fe40e15ea5e077628daf6b742bb69eab65a7.tar.gz bcm5719-llvm-d7e1fe40e15ea5e077628daf6b742bb69eab65a7.zip |
Teach __alignof__ to look through arrays before performing the
preferred-alignment transformations. Corrects alignof(T[]) to return
alignof(T) in all cases, as required by relevant standards.
llvm-svn: 210609
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f78f2a90a5b..eaf77e96254 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1328,15 +1328,6 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const { MinWidth <= getTypeSize(cast<ConstantArrayType>(arrayType))) Align = std::max(Align, Target->getLargeArrayAlign()); } - - // Keep track of extra alignment requirements on the array itself, then - // work with the element type. - // - // FIXME: Computing the preferred type alignment for the array element - // type should not be necessary, but getPreferredTypeAlign returns the - // wrong thing in some cases (such as 'long long[]' on x86_64). - Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr())); - T = BaseT; } Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr())); if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { @@ -1788,6 +1779,7 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const { const TypedefType *TT = T->getAs<TypedefType>(); // Double and long long should be naturally aligned if possible. + T = T->getBaseElementTypeUnsafe(); if (const ComplexType *CT = T->getAs<ComplexType>()) T = CT->getElementType().getTypePtr(); if (T->isSpecificBuiltinType(BuiltinType::Double) || |