diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-08-23 11:27:56 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-08-23 11:27:56 +0000 |
commit | 8e4c189e6502cffb760b33f092e65effb1d10092 (patch) | |
tree | 7c47110937840a154511837eec8a4589bd768c6e /lib/CodeGen | |
parent | a8eaf008e92759142982f7b40720b2b2674bd663 (diff) |
Attempt to fix clang bootstrap (broken by r162425).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162440 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 4ea2908c54..b55137094e 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1486,13 +1486,33 @@ CodeGenFunction::EmitPointerWithAlignment(const Expr *Addr) { return Ptr; } else if (ICE->getCastKind() == CK_ArrayToPointerDecay) { LValue LV = EmitLValue(ICE->getSubExpr()); - return std::make_pair(LV.getAddress(), LV.getAlignment().getQuantity()); + unsigned Align = LV.getAlignment().getQuantity(); + if (!Align) { + // FIXME: Once LValues are fixed to always set alignment, + // zap this code. + QualType PtTy = ICE->getSubExpr()->getType(); + if (!PtTy->isIncompleteType()) + Align = getContext().getTypeAlignInChars(PtTy).getQuantity(); + else + Align = 1; + } + return std::make_pair(LV.getAddress(), Align); } } if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(Addr)) { if (UO->getOpcode() == UO_AddrOf) { LValue LV = EmitLValue(UO->getSubExpr()); - return std::make_pair(LV.getAddress(), LV.getAlignment().getQuantity()); + unsigned Align = LV.getAlignment().getQuantity(); + if (!Align) { + // FIXME: Once LValues are fixed to always set alignment, + // zap this code. + QualType PtTy = UO->getSubExpr()->getType(); + if (!PtTy->isIncompleteType()) + Align = getContext().getTypeAlignInChars(PtTy).getQuantity(); + else + Align = 1; + } + return std::make_pair(LV.getAddress(), Align); } } |