[cfe-commits] r44580 - /cfe/trunk/Driver/RewriteTest.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Dec 4 13:47:43 PST 2007


Author: fjahanian
Date: Tue Dec  4 15:47:40 2007
New Revision: 44580

URL: http://llvm.org/viewvc/llvm-project?rev=44580&view=rev
Log:
Don't assert if objc.h not declared when rewriting.

Modified:
    cfe/trunk/Driver/RewriteTest.cpp

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44580&r1=44579&r2=44580&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Tue Dec  4 15:47:40 2007
@@ -157,6 +157,7 @@
     void SynthMsgSendSuperStretFunctionDecl();
     void SynthGetClassFunctionDecl();
     void SynthCFStringFunctionDecl();
+    void SynthSelGetUidFunctionDecl();
       
     // Metadata emission.
     void RewriteObjcClassMetaData(ObjcImplementationDecl *IDecl,
@@ -1012,6 +1013,20 @@
   }
 }
 
+// SynthSelGetUidFunctionDecl - SEL sel_registerName(const char *str);
+void RewriteTest::SynthSelGetUidFunctionDecl() {
+  IdentifierInfo *SelGetUidIdent = &Context->Idents.get("sel_registerName");
+  llvm::SmallVector<QualType, 16> ArgTys;
+  ArgTys.push_back(Context->getPointerType(
+    Context->CharTy.getQualifiedType(QualType::Const)));
+  QualType getFuncType = Context->getFunctionType(Context->getObjcSelType(),
+                                                   &ArgTys[0], ArgTys.size(),
+                                                   false /*isVariadic*/);
+  SelGetUidFunctionDecl = new FunctionDecl(SourceLocation(), 
+                                           SelGetUidIdent, getFuncType,
+                                           FunctionDecl::Extern, false, 0);
+}
+
 void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) {
   // declared in <objc/objc.h>
   if (strcmp(FD->getName(), "sel_registerName") == 0) {
@@ -1251,7 +1266,8 @@
 }
 
 Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
-  assert(SelGetUidFunctionDecl && "Can't find sel_registerName() decl");
+  if (!SelGetUidFunctionDecl)
+    SynthSelGetUidFunctionDecl();
   if (!MsgSendFunctionDecl)
     SynthMsgSendFunctionDecl();
   if (!MsgSendSuperFunctionDecl)





More information about the cfe-commits mailing list