aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2007-12-04 21:47:40 +0000
committerFariborz Jahanian <fjahanian@apple.com>2007-12-04 21:47:40 +0000
commita70711b296953bfe2fc17351f3908dcc417c404a (patch)
tree693d61aa4e35f4eda46d41fecd25e18f6f7160ac /Driver/RewriteTest.cpp
parente21272fbdbfbf5bf3461d3e9b42279f4d47caa42 (diff)
Don't assert if objc.h not declared when rewriting.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index dcd09af9b3..0e93d3176d 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -157,6 +157,7 @@ namespace {
void SynthMsgSendSuperStretFunctionDecl();
void SynthGetClassFunctionDecl();
void SynthCFStringFunctionDecl();
+ void SynthSelGetUidFunctionDecl();
// Metadata emission.
void RewriteObjcClassMetaData(ObjcImplementationDecl *IDecl,
@@ -1012,6 +1013,20 @@ void RewriteTest::RewriteObjcQualifiedInterfaceTypes(
}
}
+// 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 @@ QualType RewriteTest::getSuperStructType() {
}
Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
- assert(SelGetUidFunctionDecl && "Can't find sel_registerName() decl");
+ if (!SelGetUidFunctionDecl)
+ SynthSelGetUidFunctionDecl();
if (!MsgSendFunctionDecl)
SynthMsgSendFunctionDecl();
if (!MsgSendSuperFunctionDecl)