diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-06 00:42:20 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-06 00:42:20 +0000 |
commit | 8a10d9fcb5a207a519be95ff9281c3536f79cf03 (patch) | |
tree | 44f556d37108e2c2ccb22a26de05512d9307f359 /lib/Parse/Parser.cpp | |
parent | 8d3ba23f2d9e6c87794d059412a0808c9cbacb25 (diff) |
Added a new memberfor Parser, to be used soon
for doing delayed parsing of c++ method defined in
objc class implementations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r-- | lib/Parse/Parser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 4cc5fdeae0..0703133849 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -797,6 +797,27 @@ bool Parser::isStartOfFunctionDefinition(const ParsingDeclarator &Declarator) { Tok.is(tok::kw_try); // X() try { ... } } +/// \brief Determine whether the current token, if it occurs after a +/// a function declarator, indicates the start of a function definition +/// inside an objective-C class implementation and thus can be delay parsed. +bool Parser::isStartOfDelayParsedFunctionDefinition( + const ParsingDeclarator &Declarator) { + if (!CurParsedObjCImpl || + !Declarator.isFunctionDeclarator()) + return false; + if (Tok.is(tok::l_brace)) // int X() {} + return true; + + // Handle K&R C argument lists: int X(f) int f; {} + if (!getLangOpts().CPlusPlus && + Declarator.getFunctionTypeInfo().isKNRPrototype()) + return isDeclarationSpecifier(); + + return getLangOpts().CPlusPlus && + (Tok.is(tok::colon) || // X() : Base() {} (used for ctors) + Tok.is(tok::kw_try)); // X() try { ... } +} + /// ParseDeclarationOrFunctionDefinition - Parse either a function-definition or /// a declaration. We can't tell which we have until we read up to the /// compound-statement in function-definition. TemplateParams, if |