summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-06 07:26:43 +0000
committerChris Lattner <sabre@nondot.org>2008-10-06 07:26:43 +0000
commita97132a9c44d31dafa81db000340caed6218cee5 (patch)
treebca75815d6c9c582efb78ba74d368700dcba9356 /clang/lib/CodeGen/CGExprConstant.cpp
parent2c091b1ead0c834a63a1c9fbdb5a17537ae65fb7 (diff)
downloadbcm5719-llvm-a97132a9c44d31dafa81db000340caed6218cee5.tar.gz
bcm5719-llvm-a97132a9c44d31dafa81db000340caed6218cee5.zip
Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue. Implement this in codegen by moving the code out of CGBuiltin into EmitConstantExpr. llvm-svn: 57163
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 50f0d122405..69abbcc984c 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -617,6 +617,24 @@ public:
return llvm::ConstantFP::get(Result.getFloat());
}
+ // Handle __builtin___CFStringMakeConstantString.
+ if (E->isBuiltinCall() ==Builtin::BI__builtin___CFStringMakeConstantString){
+ const Expr *Arg = E->getArg(0);
+
+ while (1) {
+ if (const ParenExpr *PE = dyn_cast<ParenExpr>(Arg))
+ Arg = PE->getSubExpr();
+ else if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(Arg))
+ Arg = CE->getSubExpr();
+ else
+ break;
+ }
+
+ const StringLiteral *Literal = cast<StringLiteral>(Arg);
+ std::string S(Literal->getStrData(), Literal->getByteLength());
+ return CGM.GetAddrOfConstantCFString(S);
+ }
+
CGM.ErrorUnsupported(E, "constant call expression");
return llvm::Constant::getNullValue(ConvertType(E->getType()));
}
OpenPOWER on IntegriCloud