From: Fariborz Jahanian Date: Thu, 5 Jul 2012 19:34:20 +0000 (+0000) Subject: objective-c++ parsing. Turn off delayed parsing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39700f81c5b42e6be93be10275602915f872fc86;p=clang objective-c++ parsing. Turn off delayed parsing of out-of-line c++ method definition which happens to be inside an objc class implementation until I can figure out how to do it. This is to fix a broken project. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159772 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index a96e29556b..d91457c0d6 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1322,7 +1322,9 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, // Look at the next token to make sure that this isn't a function // declaration. We have to check this because __attribute__ might be the // start of a function definition in GCC-extended K&R C. - !isDeclarationAfterDeclarator()) { + !isDeclarationAfterDeclarator() && + (!CurParsedObjCImpl || Tok.isNot(tok::l_brace) || + (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()))) { if (isStartOfFunctionDefinition(D)) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index c2c4c90090..4cc5fdeae0 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -773,9 +773,7 @@ bool Parser::isDeclarationAfterDeclarator() { Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def (getLangOpts().CPlusPlus && - Tok.is(tok::l_paren)) || // int X(0) -> not a function def [C++] - (CurParsedObjCImpl && - Tok.is(tok::l_brace)); // C-function nested in an @implementation + Tok.is(tok::l_paren)); // int X(0) -> not a function def [C++] } /// \brief Determine whether the current token, if it occurs after a diff --git a/test/SemaObjCXX/delay-parsing-cfunctions.mm b/test/SemaObjCXX/delay-parsing-cfunctions.mm index 8e9c319a0e..fbdf8bad0a 100644 --- a/test/SemaObjCXX/delay-parsing-cfunctions.mm +++ b/test/SemaObjCXX/delay-parsing-cfunctions.mm @@ -3,6 +3,7 @@ struct X { X(); +void SortWithCollator(); }; @interface MyClass @@ -39,5 +40,5 @@ static int test() { int x{17}; X::X() = default; - +void X::SortWithCollator() {} @end