diff options
Diffstat (limited to 'CodeGen/CGExprConstant.cpp')
-rw-r--r-- | CodeGen/CGExprConstant.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp index 3b1c62bb16..e03db991c4 100644 --- a/CodeGen/CGExprConstant.cpp +++ b/CodeGen/CGExprConstant.cpp @@ -235,6 +235,15 @@ public: llvm::Constant *VisitUnaryAddrOf(const UnaryOperator *E) { return EmitLValue(E->getSubExpr()); } + llvm::Constant *VisitUnaryOffsetOf(const UnaryOperator *E) { + int64_t Val = E->evaluateOffsetOf(CGM.getContext()); + + assert(E->getType()->isIntegerType() && "Result type must be an integer!"); + + uint32_t ResultWidth = static_cast<uint32_t>( + CGM.getContext().getTypeSize(E->getType(), SourceLocation())); + return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Val)); + } // Binary operators llvm::Constant *VisitBinOr(const BinaryOperator *E) { |