From: Fariborz Jahanian Date: Tue, 11 Dec 2007 19:56:36 +0000 (+0000) Subject: Refactor Rewritetest::RewriteObjcQualifiedInterfaceTypes in preparation for more X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e66894c3dea9aeab4403e67bf5baabc20da61cb3;p=clang Refactor Rewritetest::RewriteObjcQualifiedInterfaceTypes in preparation for more general use. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44876 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 3ec5a10b2c..77adafecba 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -147,8 +147,7 @@ namespace { void RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods); void RewriteProperties(int nProperties, ObjcPropertyDecl **Properties); void RewriteFunctionDecl(FunctionDecl *FD); - void RewriteObjcQualifiedInterfaceTypes( - const FunctionTypeProto *proto, FunctionDecl *FD); + void RewriteObjcQualifiedInterfaceTypes(Decl *Dcl); bool needToScanForQualifiers(QualType T); ObjcInterfaceDecl *isSuperReceiver(Expr *recExpr); QualType getSuperStructType(); @@ -991,9 +990,18 @@ bool RewriteTest::needToScanForQualifiers(QualType T) { return false; } -void RewriteTest::RewriteObjcQualifiedInterfaceTypes( - const FunctionTypeProto *proto, FunctionDecl *FD) { +void RewriteTest::RewriteObjcQualifiedInterfaceTypes(Decl *Dcl) { + FunctionDecl *FD = dyn_cast(Dcl); + if (!FD) + return; + // Check for ObjC 'id' and class types that have been adorned with protocol + // information (id

, C

*). The protocol references need to be rewritten! + const FunctionType *funcType = FD->getType()->getAsFunctionType(); + assert(funcType && "missing function type"); + const FunctionTypeProto *proto = dyn_cast(funcType); + if (!proto) + return; if (needToScanForQualifiers(proto->getResultType())) { // Since types are unique, we need to scan the buffer. SourceLocation Loc = FD->getLocation(); @@ -1069,12 +1077,7 @@ void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) { SelGetUidFunctionDecl = FD; return; } - // Check for ObjC 'id' and class types that have been adorned with protocol - // information (id

, C

*). The protocol references need to be rewritten! - const FunctionType *funcType = FD->getType()->getAsFunctionType(); - assert(funcType && "missing function type"); - if (const FunctionTypeProto *proto = dyn_cast(funcType)) - RewriteObjcQualifiedInterfaceTypes(proto, FD); + RewriteObjcQualifiedInterfaceTypes(FD); } // SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);