Make it actually compile on Solaris.
[oota-llvm.git] / lib / VMCore / Constants.cpp
index 77aa23135e5bb6fc2af199099d8ace61f35927e3..b5831ae26ea9e6a8f9dd45f6750f036532e195d0 100644 (file)
@@ -1244,6 +1244,15 @@ Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
   return ConstantExpr::getCast(C, Ty);
 }
 
+Constant *ConstantExpr::getSizeOf(const Type *Ty) {
+  // sizeof is implemented as: (unsigned) gep (Ty*)null, 1
+  return getCast(
+    getGetElementPtr(
+      getNullValue(PointerType::get(Ty)),
+      std::vector<Constant*>(1, ConstantInt::get(Type::UIntTy, 1))),
+    Type::UIntTy);
+}
+
 Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
                               Constant *C1, Constant *C2) {
   if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)