[cfe-commits] r159792 - in /cfe/trunk: include/clang/Parse/Parser.h lib/Parse/Parser.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Jul 5 17:42:20 PDT 2012
Author: fjahanian
Date: Thu Jul 5 19:42:20 2012
New Revision: 159792
URL: http://llvm.org/viewvc/llvm-project?rev=159792&view=rev
Log:
Added a new memberfor Parser, to be used soon
for doing delayed parsing of c++ method defined in
objc class implementations.
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/Parser.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=159792&r1=159791&r2=159792&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Jul 5 19:42:20 2012
@@ -1045,6 +1045,7 @@
ParsingDeclSpec *DS = 0);
bool isDeclarationAfterDeclarator();
bool isStartOfFunctionDefinition(const ParsingDeclarator &Declarator);
+ bool isStartOfDelayParsedFunctionDefinition(const ParsingDeclarator &Declarator);
DeclGroupPtrTy ParseDeclarationOrFunctionDefinition(
ParsedAttributesWithRange &attrs,
ParsingDeclSpec *DS = 0,
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=159792&r1=159791&r2=159792&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Thu Jul 5 19:42:20 2012
@@ -797,6 +797,27 @@
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
More information about the cfe-commits
mailing list