[cfe-commits] r41419 - /cfe/trunk/CodeGen/CGBuiltin.cpp

Chris Lattner sabre at nondot.org
Sat Aug 25 21:17:05 PDT 2007


Author: lattner
Date: Sat Aug 25 23:17:05 2007
New Revision: 41419

URL: http://llvm.org/viewvc/llvm-project?rev=41419&view=rev
Log:
Don't make unknown builtins fatal errors yet.

Modified:
    cfe/trunk/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=41419&r1=41418&r2=41419&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Sat Aug 25 23:17:05 2007
@@ -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<const ParenExpr>(Arg))
-        Arg = PE->getSubExpr();
-      
-      const StringLiteral *Literal = cast<const StringLiteral>(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<ParenExpr>(Arg))
+      Arg = PE->getSubExpr();
+    
+    const StringLiteral *Literal = cast<StringLiteral>(Arg);
+    std::string S(Literal->getStrData(), Literal->getByteLength());
+    
+    return RValue::get(CGM.GetAddrOfConstantCFString(S));
+  }      
   }
       
   return RValue::get(0);





More information about the cfe-commits mailing list