aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Driver/RewriteTest.cpp34
-rw-r--r--Parse/ParseObjc.cpp5
-rw-r--r--Parse/Parser.cpp2
-rw-r--r--include/clang/Parse/Parser.h2
4 files changed, 24 insertions, 19 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index ff9bf2f924..9e17a6ef8c 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -91,7 +91,7 @@ namespace {
void RewriteObjcMethodDecl(ObjcMethodDecl *MDecl, std::string &ResultStr);
void RewriteCategoryDecl(ObjcCategoryDecl *Dcl);
void RewriteProtocolDecl(ObjcProtocolDecl *Dcl);
- void RewriteMethods(int nMethods, ObjcMethodDecl **Methods);
+ void RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods);
void RewriteProperties(int nProperties, ObjcPropertyDecl **Properties);
void RewriteFunctionDecl(FunctionDecl *FD);
void RewriteObjcQualifiedInterfaceTypes(
@@ -189,7 +189,11 @@ void RewriteTest::HandleDeclInMainFile(Decl *D) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
if (Stmt *Body = FD->getBody())
FD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
-
+
+ if (ObjcMethodDecl *MD = dyn_cast<ObjcMethodDecl>(D)) {
+ if (Stmt *Body = MD->getBody())
+ MD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
+ }
if (ObjcImplementationDecl *CI = dyn_cast<ObjcImplementationDecl>(D))
ClassImplementation.push_back(CI);
else if (ObjcCategoryImplDecl *CI = dyn_cast<ObjcCategoryImplDecl>(D))
@@ -325,7 +329,7 @@ void RewriteTest::RewriteForwardClassDecl(ObjcClassDecl *ClassDecl) {
typedefString.c_str(), typedefString.size());
}
-void RewriteTest::RewriteMethods(int nMethods, ObjcMethodDecl **Methods) {
+void RewriteTest::RewriteMethodDeclarations(int nMethods, ObjcMethodDecl **Methods) {
for (int i = 0; i < nMethods; i++) {
ObjcMethodDecl *Method = Methods[i];
SourceLocation Loc = Method->getLocStart();
@@ -354,10 +358,10 @@ void RewriteTest::RewriteCategoryDecl(ObjcCategoryDecl *CatDecl) {
// FIXME: handle category headers that are declared across multiple lines.
Rewrite.ReplaceText(LocStart, 0, "// ", 3);
- RewriteMethods(CatDecl->getNumInstanceMethods(),
- CatDecl->getInstanceMethods());
- RewriteMethods(CatDecl->getNumClassMethods(),
- CatDecl->getClassMethods());
+ RewriteMethodDeclarations(CatDecl->getNumInstanceMethods(),
+ CatDecl->getInstanceMethods());
+ RewriteMethodDeclarations(CatDecl->getNumClassMethods(),
+ CatDecl->getClassMethods());
// Lastly, comment out the @end.
Rewrite.ReplaceText(CatDecl->getAtEndLoc(), 0, "// ", 3);
}
@@ -368,10 +372,10 @@ void RewriteTest::RewriteProtocolDecl(ObjcProtocolDecl *PDecl) {
// FIXME: handle protocol headers that are declared across multiple lines.
Rewrite.ReplaceText(LocStart, 0, "// ", 3);
- RewriteMethods(PDecl->getNumInstanceMethods(),
- PDecl->getInstanceMethods());
- RewriteMethods(PDecl->getNumClassMethods(),
- PDecl->getClassMethods());
+ RewriteMethodDeclarations(PDecl->getNumInstanceMethods(),
+ PDecl->getInstanceMethods());
+ RewriteMethodDeclarations(PDecl->getNumClassMethods(),
+ PDecl->getClassMethods());
// Lastly, comment out the @end.
Rewrite.ReplaceText(PDecl->getAtEndLoc(), 0, "// ", 3);
}
@@ -533,10 +537,10 @@ void RewriteTest::RewriteInterfaceDecl(ObjcInterfaceDecl *ClassDecl) {
ResultStr.c_str(), ResultStr.size());
RewriteProperties(ClassDecl->getNumPropertyDecl(),
ClassDecl->getPropertyDecl());
- RewriteMethods(ClassDecl->getNumInstanceMethods(),
- ClassDecl->getInstanceMethods());
- RewriteMethods(ClassDecl->getNumClassMethods(),
- ClassDecl->getClassMethods());
+ RewriteMethodDeclarations(ClassDecl->getNumInstanceMethods(),
+ ClassDecl->getInstanceMethods());
+ RewriteMethodDeclarations(ClassDecl->getNumClassMethods(),
+ ClassDecl->getClassMethods());
// Lastly, comment out the @end.
Rewrite.ReplaceText(ClassDecl->getAtEndLoc(), 0, "// ", 3);
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp
index 19d32bd486..2152601094 100644
--- a/Parse/ParseObjc.cpp
+++ b/Parse/ParseObjc.cpp
@@ -1139,7 +1139,7 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
/// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
///
-void Parser::ParseObjCMethodDefinition() {
+Parser::DeclTy *Parser::ParseObjCMethodDefinition() {
DeclTy *MDecl = ParseObjCMethodPrototype(ObjcImpDecl);
// parse optional ';'
if (Tok.is(tok::semi))
@@ -1154,7 +1154,7 @@ void Parser::ParseObjCMethodDefinition() {
// If we didn't find the '{', bail out.
if (Tok.isNot(tok::l_brace))
- return;
+ return 0;
}
SourceLocation BraceLoc = Tok.getLocation();
@@ -1176,6 +1176,7 @@ void Parser::ParseObjCMethodDefinition() {
// TODO: Pass argument information.
Actions.ActOnFinishFunctionBody(MDecl, FnBody.Val);
+ return MDecl;
}
Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index bc8d0d0c30..b571703a3a 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -331,7 +331,7 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
case tok::minus:
case tok::plus:
if (getLang().ObjC1)
- ParseObjCMethodDefinition();
+ return ParseObjCMethodDefinition();
else {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index 3660e643bb..57fd4e1e79 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -300,7 +300,7 @@ private:
void ParseObjCPropertyAttribute(ObjcDeclSpec &DS);
DeclTy *ParseObjCPropertyDecl(DeclTy *interfaceDecl, SourceLocation AtLoc);
- void ParseObjCMethodDefinition();
+ DeclTy *ParseObjCMethodDefinition();
//===--------------------------------------------------------------------===//
// C99 6.5: Expressions.