From 6de93ff81c5fe89b96a589ef13ea2beb4d7c3775 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 26 Aug 2007 04:17:05 +0000 Subject: [PATCH] Don't make unknown builtins fatal errors yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41419 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGBuiltin.cpp | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp index 769fa5ce3b..833b1882d1 100644 --- a/CodeGen/CGBuiltin.cpp +++ b/CodeGen/CGBuiltin.cpp @@ -15,27 +15,32 @@ #include "CodeGenModule.h" #include "clang/AST/Builtins.h" #include "clang/AST/Expr.h" -#include "llvm/Constant.h" - +#include "llvm/Constants.h" using namespace clang; using namespace CodeGen; -RValue CodeGenFunction::EmitBuiltinExpr(unsigned builtinID, const CallExpr *E) -{ - switch (builtinID) { - case Builtin::BI__builtin___CFStringMakeConstantString: { - const Expr *Arg = E->getArg(0); - - while (const ParenExpr *PE = dyn_cast(Arg)) - Arg = PE->getSubExpr(); - - const StringLiteral *Literal = cast(Arg); - std::string S(Literal->getStrData(), Literal->getByteLength()); - - return RValue::get(CGM.GetAddrOfConstantCFString(S)); - } - default: - assert(0 && "Unknown builtin id"); +RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { + switch (BuiltinID) { + default: + fprintf(stderr, "Unimplemented builtin!!\n"); + E->dump(); + + // Unknown builtin, for now just dump it out and return undef. + if (hasAggregateLLVMType(E->getType())) + return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType()))); + return RValue::get(llvm::UndefValue::get(ConvertType(E->getType()))); + + case Builtin::BI__builtin___CFStringMakeConstantString: { + const Expr *Arg = E->getArg(0); + + while (const ParenExpr *PE = dyn_cast(Arg)) + Arg = PE->getSubExpr(); + + const StringLiteral *Literal = cast(Arg); + std::string S(Literal->getStrData(), Literal->getByteLength()); + + return RValue::get(CGM.GetAddrOfConstantCFString(S)); + } } return RValue::get(0); -- 2.40.0