aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-30 17:32:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-30 17:32:17 +0000
commit18857644059c45da6776f1a288eec7b4cf3a844a (patch)
tree92c2a1d55ece4e06a43deb571d1d9a99d392c672 /lib/AST/ExprConstant.cpp
parent5b2bad017b5f86c83aeb80d186696a4c8d59f68f (diff)
Properly compute the alignment of typedefs that make use of the
"aligned" attribute. Previously, we were skipping over these attributes when we jumped directly to the canonical type. Now, ASTContext::getTypeInfo walks through typedefs and other "non-canonical" types manually, looking for "aligned" attributes on typedefs. As part of this change, I moved the GNU-specific logic (such as determining the alignment of void or of a function pointer) out of the expression evaluator and into ASTContext::getTypeInfo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index fce59133c1..5d92e99a06 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -1021,32 +1021,11 @@ bool IntExprEvaluator::VisitConditionalOperator(const ConditionalOperator *E) {
}
unsigned IntExprEvaluator::GetAlignOfType(QualType T) {
- const Type *Ty = Info.Ctx.getCanonicalType(T).getTypePtr();
-
- // __alignof__(void) = 1 as a gcc extension.
- if (Ty->isVoidType())
- return 1;
-
- // GCC extension: alignof(function) = 4.
- // FIXME: AlignOf shouldn't be unconditionally 4! It should listen to the
- // attribute(align) directive.
- if (Ty->isFunctionType())
- return 4;
-
- if (const ExtQualType *EXTQT = dyn_cast<ExtQualType>(Ty))
- return GetAlignOfType(QualType(EXTQT->getBaseType(), 0));
-
- // alignof VLA/incomplete array.
- if (const ArrayType *VAT = dyn_cast<ArrayType>(Ty))
- return GetAlignOfType(VAT->getElementType());
-
- // sizeof (objc class)?
- if (isa<ObjCInterfaceType>(Ty))
- return 1; // FIXME: This probably isn't right.
-
// Get information about the alignment.
unsigned CharSize = Info.Ctx.Target.getCharWidth();
- return Info.Ctx.getPreferredTypeAlign(Ty) / CharSize;
+
+ // FIXME: Why do we ask for the preferred alignment?
+ return Info.Ctx.getPreferredTypeAlign(T.getTypePtr()) / CharSize;
}
unsigned IntExprEvaluator::GetAlignOfExpr(const Expr *E) {