]> granicus.if.org Git - clang/commitdiff
Attempt to fix clang bootstrap (broken by r162425).
authorEli Friedman <eli.friedman@gmail.com>
Thu, 23 Aug 2012 11:27:56 +0000 (11:27 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 23 Aug 2012 11:27:56 +0000 (11:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162440 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBuiltin.cpp

index 4ea2908c544a60e8b8fc09c81783828102d2d7b9..b55137094e7db7a79a1c7a94b1dcb9a3a715eb29 100644 (file)
@@ -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);
     }
   }