diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-01-25 01:54:01 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-01-25 01:54:01 +0000 |
commit | 3941b18b8e441c8c466efecd557de60b9a32d10b (patch) | |
tree | 1de7266d1da145299e6fc11abca47169e52b5c03 /lib/CodeGen | |
parent | f01158941ba4560c63150032073bb231ce38999e (diff) |
Make the constant folder aware of
__builtin___CFStringMakeConstantString. (We get into trouble in
GenerateStaticBlockVarDecl if the constant folder isn't accurate.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62949 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 30f8c34c58..9260b11ed3 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -42,8 +42,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { if (E->Evaluate(Result, CGM.getContext())) { if (Result.Val.isInt()) return RValue::get(llvm::ConstantInt::get(Result.Val.getInt())); - assert(Result.Val.isFloat() && "Unsupported constant type"); - return RValue::get(llvm::ConstantFP::get(Result.Val.getFloat())); + else if (Result.Val.isFloat()) + return RValue::get(llvm::ConstantFP::get(Result.Val.getFloat())); } switch (BuiltinID) { diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 0e31cacd1b..716e295f3e 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -625,6 +625,15 @@ public: llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id); return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType())); } + case Expr::CallExprClass: { + CallExpr* CE = cast<CallExpr>(E); + if (CE->isBuiltinCall() != Builtin::BI__builtin___CFStringMakeConstantString) + break; + const Expr *Arg = CE->getArg(0)->IgnoreParenCasts(); + const StringLiteral *Literal = cast<StringLiteral>(Arg); + std::string S(Literal->getStrData(), Literal->getByteLength()); + return CGM.GetAddrOfConstantCFString(S); + } } CGM.ErrorUnsupported(E, "constant l-value expression"); llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType())); |