From 4cc2cfd48d7c2d11141871cad590db7b52ce00a0 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 10 Apr 2009 04:47:03 +0000 Subject: [PATCH] Use the same alignment for reference declarations as for pointer declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68761 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 7da1bf080c..17f3d431e8 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -306,8 +306,11 @@ unsigned ASTContext::getDeclAlignInBytes(const Decl *D) { if (const ValueDecl *VD = dyn_cast(D)) { QualType T = VD->getType(); - // Incomplete or function types default to 1. - if (!T->isIncompleteType() && !T->isFunctionType()) { + if (const ReferenceType* RT = T->getAsReferenceType()) { + unsigned AS = RT->getPointeeType().getAddressSpace(); + Align = Target.getPointerWidth(AS); + } else if (!T->isIncompleteType() && !T->isFunctionType()) { + // Incomplete or function types default to 1. while (isa(T) || isa(T)) T = cast(T)->getElementType(); -- 2.40.0