aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-10-31 04:38:33 +0000
committerSteve Naroff <snaroff@apple.com>2007-10-31 04:38:33 +0000
commit9165ad378f8d25eb5c378a8e9540089afce421ff (patch)
tree5a38ffa38b63b63d0c4cff4164f2a1527e20bbe4
parent8baaca50f07d0c10bba69c8d88c1b9078c92d06d (diff)
Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43543 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/RewriteTest.cpp37
-rw-r--r--Lex/Preprocessor.cpp2
-rw-r--r--clang.xcodeproj/project.pbxproj1
3 files changed, 35 insertions, 5 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 8f3b754195..788b522612 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -64,6 +64,8 @@ namespace {
void RewriteProtocolDecl(ObjcProtocolDecl *Dcl);
void RewriteMethods(int nMethods, ObjcMethodDecl **Methods);
void RewriteFunctionDecl(FunctionDecl *FD);
+ bool functionReferencesAnyObjcQualifiedInterfaceTypes(
+ const FunctionTypeProto *proto);
// Expression Rewriting.
Stmt *RewriteFunctionBody(Stmt *S);
@@ -402,12 +404,41 @@ CallExpr *RewriteTest::SynthesizeCallToFunctionDecl(
return new CallExpr(ICE, args, nargs, FT->getResultType(), SourceLocation());
}
+bool RewriteTest::functionReferencesAnyObjcQualifiedInterfaceTypes(
+ const FunctionTypeProto *proto) {
+ const PointerType *pType = proto->getResultType()->getAsPointerType();
+ if (pType) {
+ Type *pointeeType = pType->getPointeeType().getTypePtr();
+ if (isa<ObjcQualifiedInterfaceType>(pointeeType))
+ return true; // we have "Class <Protocol> *".
+ }
+ // Now check arguments.
+ for (unsigned i = 0; i < proto->getNumArgs(); i++) {
+ pType = proto->getArgType(i)->getAsPointerType();
+ if (pType) {
+ Type *pointeeType = pType->getPointeeType().getTypePtr();
+ if (isa<ObjcQualifiedInterfaceType>(pointeeType))
+ return true;
+ }
+ }
+ // FIXME: we don't currently represent "id <Protocol>" in the type system.
+ return false;
+}
+
void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) {
// declared in <objc/objc.h>
- if (strcmp(FD->getName(), "sel_getUid") == 0)
+ if (strcmp(FD->getName(), "sel_getUid") == 0) {
SelGetUidFunctionDecl = FD;
-
- // FIXME: Check if any types are isa<ObjcQualifiedInterfaceType> (yuck).
+ return;
+ }
+ // Check for ObjC 'id' and class types that have been adorned with protocol
+ // information (id<p>, C<p>*). The protocol references need to be rewritten!
+ const FunctionType *funcType = FD->getType()->getAsFunctionType();
+ assert(funcType && "missing function type");
+ const FunctionTypeProto *proto = dyn_cast<FunctionTypeProto>(funcType);
+ if (proto && functionReferencesAnyObjcQualifiedInterfaceTypes(proto)) {
+ // FIXME: Rewrite function decl...
+ }
}
// SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index 784fb19e49..04b2a80f02 100644
--- a/Lex/Preprocessor.cpp
+++ b/Lex/Preprocessor.cpp
@@ -369,6 +369,7 @@ static void InitializePredefinedMacros(Preprocessor &PP,
DefineBuiltinMacro(Buf, "__OBJC__=1");
if (PP.getLangOptions().ObjC2)
DefineBuiltinMacro(Buf, "__OBJC2__=1");
+
if (PP.getLangOptions().ObjC1) {
const char *ObjcType;
// Predefine all the ObjC goodies (traditionally declared in <objc/objc.h>).
@@ -396,7 +397,6 @@ static void InitializePredefinedMacros(Preprocessor &PP,
ObjcType = "extern SEL sel_getUid(const char *str);\n";
Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
}
-
// Add __builtin_va_list typedef.
{
const char *VAList = PP.getTargetInfo().getVAListDeclaration();
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index fe4cf8d85b..de41b4628d 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -756,7 +756,6 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";