rename MaybeParseCXXScopeSpecifier -> ParseOptionalCXXScopeSpecifier and

MaybeParseTypeSpecifier -> ParseOptionalTypeSpecifier.

llvm-svn: 61796
This commit is contained in:
Chris Lattner 2009-01-06 06:59:53 +00:00
parent 9b01ca1f5a
commit a448d75b2a
5 changed files with 31 additions and 29 deletions

View File

@ -608,11 +608,12 @@ private:
// C++ Expressions
OwningExprResult ParseCXXIdExpression();
/// MaybeParseCXXScopeSpecifier - Parse global scope or nested-name-specifier.
/// Returns true if a nested-name-specifier was parsed from the token stream.
/// Note that this routine will not parse ::new or ::delete.
/// ParseOptionalCXXScopeSpecifier - Parse global scope or
/// nested-name-specifier if present. Returns true if a nested-name-specifier
/// was parsed from the token stream. Note that this routine will not parse
/// ::new or ::delete, it will just leave them in the token stream.
///
bool MaybeParseCXXScopeSpecifier(CXXScopeSpec &SS);
bool ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS);
//===--------------------------------------------------------------------===//
// C++ 5.2p1: C++ Casts
@ -763,9 +764,9 @@ private:
SourceLocation L, SourceLocation R);
void ParseDeclarationSpecifiers(DeclSpec &DS,
TemplateParameterLists *TemplateParams = 0);
bool MaybeParseTypeSpecifier(DeclSpec &DS, int &isInvalid,
const char *&PrevSpec,
TemplateParameterLists *TemplateParams = 0);
bool ParseOptionalTypeSpecifier(DeclSpec &DS, int &isInvalid,
const char *&PrevSpec,
TemplateParameterLists *TemplateParams = 0);
void ParseSpecifierQualifierList(DeclSpec &DS);
void ParseObjCTypeQualifierList(ObjCDeclSpec &DS);

View File

@ -449,7 +449,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
default:
// Try to parse a type-specifier; if we found one, continue. If it's not
// a type, this falls through.
if (MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams))
if (ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams))
continue;
DoneWithDeclSpec:
@ -660,7 +660,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
}
}
/// MaybeParseTypeSpecifier - Try to parse a single type-specifier. We
/// ParseOptionalTypeSpecifier - Try to parse a single type-specifier. We
/// primarily follow the C++ grammar with additions for C99 and GNU,
/// which together subsume the C grammar. Note that the C++
/// type-specifier also includes the C type-qualifier (for const,
@ -702,9 +702,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
/// [GNU] typeof-specifier
/// [OBJC] class-name objc-protocol-refs[opt] [TODO]
/// [OBJC] typedef-name objc-protocol-refs[opt] [TODO]
bool Parser::MaybeParseTypeSpecifier(DeclSpec &DS, int& isInvalid,
const char *&PrevSpec,
TemplateParameterLists *TemplateParams) {
bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, int& isInvalid,
const char *&PrevSpec,
TemplateParameterLists *TemplateParams){
SourceLocation Loc = Tok.getLocation();
switch (Tok.getKind()) {
@ -712,7 +712,7 @@ bool Parser::MaybeParseTypeSpecifier(DeclSpec &DS, int& isInvalid,
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams);
return ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec,TemplateParams);
// Otherwise, not a type specifier.
return false;
case tok::coloncolon: // ::foo::bar
@ -723,7 +723,7 @@ bool Parser::MaybeParseTypeSpecifier(DeclSpec &DS, int& isInvalid,
// Annotate typenames and C++ scope specifiers. If we get one, just
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec, TemplateParams);
return ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec,TemplateParams);
// Otherwise, not a type specifier.
return false;
@ -1055,7 +1055,7 @@ void Parser::ParseEnumSpecifier(DeclSpec &DS) {
Attr = ParseAttributes();
CXXScopeSpec SS;
if (getLang().CPlusPlus && MaybeParseCXXScopeSpecifier(SS)) {
if (getLang().CPlusPlus && ParseOptionalCXXScopeSpecifier(SS)) {
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
if (Tok.isNot(tok::l_brace)) {
@ -1565,7 +1565,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
if (getLang().CPlusPlus) {
if (D.mayHaveIdentifier()) {
bool afterCXXScope = MaybeParseCXXScopeSpecifier(D.getCXXScopeSpec());
bool afterCXXScope = ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec());
if (afterCXXScope) {
// Change the declaration context for name lookup, until this function
// is exited (and the declarator has been parsed).

View File

@ -167,7 +167,7 @@ Parser::DeclTy *Parser::ParseUsingDirective(unsigned Context,
CXXScopeSpec SS;
// Parse (optional) nested-name-specifier.
MaybeParseCXXScopeSpecifier(SS);
ParseOptionalCXXScopeSpecifier(SS);
AttributeList *AttrList = 0;
IdentifierInfo *NamespcName = 0;
@ -310,7 +310,7 @@ void Parser::ParseClassSpecifier(DeclSpec &DS,
// Parse the (optional) nested-name-specifier.
CXXScopeSpec SS;
if (getLang().CPlusPlus && MaybeParseCXXScopeSpecifier(SS)) {
if (getLang().CPlusPlus && ParseOptionalCXXScopeSpecifier(SS)) {
if (Tok.isNot(tok::identifier))
Diag(Tok, diag::err_expected_ident);
}
@ -458,7 +458,7 @@ Parser::BaseResult Parser::ParseBaseSpecifier(DeclTy *ClassDecl)
// Parse optional '::' and optional nested-name-specifier.
CXXScopeSpec SS;
MaybeParseCXXScopeSpecifier(SS);
ParseOptionalCXXScopeSpecifier(SS);
// The location of the base class itself.
SourceLocation BaseLoc = Tok.getLocation();

View File

@ -17,10 +17,10 @@
#include "AstGuard.h"
using namespace clang;
/// MaybeParseCXXScopeSpecifier - Parse global scope or nested-name-specifier.
/// Returns true if a nested-name-specifier was parsed from the token stream.
///
/// Note that this routine will not parse ::new or ::delete.
/// ParseOptionalCXXScopeSpecifier - Parse global scope or
/// nested-name-specifier if present. Returns true if a nested-name-specifier
/// was parsed from the token stream. Note that this routine will not parse
/// ::new or ::delete, it will just leave them in the token stream.
///
/// '::'[opt] nested-name-specifier
/// '::'
@ -31,7 +31,7 @@ using namespace clang;
/// nested-name-specifier identifier '::'
/// nested-name-specifier 'template'[opt] simple-template-id '::' [TODO]
///
bool Parser::MaybeParseCXXScopeSpecifier(CXXScopeSpec &SS) {
bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS) {
assert(getLang().CPlusPlus &&
"Call sites of this function should be guarded by checking for C++");
@ -137,7 +137,7 @@ Parser::OwningExprResult Parser::ParseCXXIdExpression() {
// '::' unqualified-id
//
CXXScopeSpec SS;
MaybeParseCXXScopeSpecifier(SS);
ParseOptionalCXXScopeSpecifier(SS);
// unqualified-id:
// identifier
@ -521,11 +521,12 @@ bool Parser::ParseCXXTypeSpecifierSeq(DeclSpec &DS) {
int isInvalid = 0;
// Parse one or more of the type specifiers.
if (!MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec)) {
if (!ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec)) {
Diag(Tok, diag::err_operator_missing_type_specifier);
return true;
}
while (MaybeParseTypeSpecifier(DS, isInvalid, PrevSpec)) ;
while (ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec));
return false;
}

View File

@ -753,7 +753,7 @@ bool Parser::TryAnnotateTypeOrScopeToken() {
// FIXME: Implement template-ids
CXXScopeSpec SS;
if (getLang().CPlusPlus)
MaybeParseCXXScopeSpecifier(SS);
ParseOptionalCXXScopeSpecifier(SS);
if (Tok.is(tok::identifier)) {
// Determine whether the identifier is a type name.
@ -825,7 +825,7 @@ bool Parser::TryAnnotateCXXScopeToken() {
"Cannot be a type or scope token!");
CXXScopeSpec SS;
if (!MaybeParseCXXScopeSpecifier(SS))
if (!ParseOptionalCXXScopeSpecifier(SS))
return false;
// Push the current token back into the token stream (or revert it if it is