diff options
author | Anders Carlsson <andersca@mac.com> | 2008-02-06 07:23:14 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-02-06 07:23:14 +0000 |
commit | 87a98759d683d9ed23e09744207a4428c4ed5ace (patch) | |
tree | fb2463cbb25064ffd26abf2ae3afc6bf0888469e /CodeGen/CGExprConstant.cpp | |
parent | 3a31d60cffedfb7c9e6d129a5c9ba15fa74f179a (diff) |
Add pointer + int (and vice versa) to the constant emitter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46812 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGExprConstant.cpp')
-rw-r--r-- | CodeGen/CGExprConstant.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp index 85f0697348..8c319a0eb3 100644 --- a/CodeGen/CGExprConstant.cpp +++ b/CodeGen/CGExprConstant.cpp @@ -385,8 +385,16 @@ public: if (!E->getType()->isPointerType()) return llvm::ConstantExpr::getAdd(LHS, RHS); - assert(0 && "Unhandled bin add types!"); - return 0; + llvm::Constant *Ptr, *Idx; + if (isa<llvm::PointerType>(LHS->getType())) { // pointer + int + Ptr = LHS; + Idx = RHS; + } else { // int + pointer + Ptr = RHS; + Idx = LHS; + } + + return llvm::ConstantExpr::getGetElementPtr(Ptr, &Idx, 1); } llvm::Constant *VisitBinAnd(const BinaryOperator *E) { |