diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-05 01:24:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-05 01:24:05 +0000 |
commit | 7452c6fc567ea1799f617395d0fa4c7ed075e5d9 (patch) | |
tree | cf8673af65634475376dc897ff1e3b5352368993 | |
parent | 835c909696ecd1e1f128297089d1def8d1a6f7cd (diff) |
TryAnnotateTypeOrScopeToken and TryAnnotateCXXScopeToken can
only be called when they might be needed now, so make them assert
that their current token is :: or identifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61662 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 3 | ||||
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 12 | ||||
-rw-r--r-- | lib/Parse/ParseTemplate.cpp | 4 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 13 |
4 files changed, 16 insertions, 16 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 8770bc2864..80e25ee6cb 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -637,7 +637,8 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) { return ParseCXXDeleteExpression(true, ColonColonTok.getLocation()); // Turn the qualified name into a annot_qualtypename or annot_cxxscope if // it would be valid. - if (TryAnnotateTypeOrScopeToken(&ColonColonTok)) { + if ((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) && + TryAnnotateTypeOrScopeToken(&ColonColonTok)) { // If so, retry (tail recurse). return ParseCastExpression(isUnaryExpression); } diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index f9514352ee..a4b97e173b 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -35,7 +35,7 @@ using namespace clang; bool Parser::MaybeParseCXXScopeSpecifier(CXXScopeSpec &SS, const Token *GlobalQualifier) { assert(getLang().CPlusPlus && - "Call sites of this function should be guarded by checking for C++."); + "Call sites of this function should be guarded by checking for C++"); if (Tok.is(tok::annot_cxxscope)) { assert(GlobalQualifier == 0 && @@ -183,13 +183,13 @@ Parser::OwningExprResult Parser::ParseCXXIdExpression() { case tok::kw_operator: { SourceLocation OperatorLoc = Tok.getLocation(); - if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) { + if (OverloadedOperatorKind Op = TryParseOperatorFunctionId()) return Owned(Actions.ActOnCXXOperatorFunctionIdExpr( CurScope, OperatorLoc, Op, Tok.is(tok::l_paren), SS)); - } else if (TypeTy *Type = ParseConversionFunctionId()) { - return Owned(Actions.ActOnCXXConversionFunctionExpr( - CurScope, OperatorLoc, Type, Tok.is(tok::l_paren),SS)); - } + if (TypeTy *Type = ParseConversionFunctionId()) + return Owned(Actions.ActOnCXXConversionFunctionExpr(CurScope, OperatorLoc, + Type, + Tok.is(tok::l_paren), SS)); // We already complained about a bad conversion-function-id, // above. diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 076aae38cc..f21854dc1e 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -318,7 +318,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { // Parse this as a typename. Declarator ParamDecl(DS, Declarator::TemplateParamContext); ParseDeclarator(ParamDecl); - if(DS.getTypeSpecType() == DeclSpec::TST_unspecified && !DS.getTypeRep()) { + if (DS.getTypeSpecType() == DeclSpec::TST_unspecified && !DS.getTypeRep()) { // This probably shouldn't happen - and it's more of a Sema thing, but // basically we didn't parse the type name because we couldn't associate // it with an AST node. we should just skip to the comma or greater. @@ -335,7 +335,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) { // Is there a default value? Parsing this can be fairly annoying because // we have to stop on the first non-nested (paren'd) '>' as the closure // for the template parameter list. Or a ','. - if(Tok.is(tok::equal)) { + if (Tok.is(tok::equal)) { // TODO: Implement default non-type values. SkipUntil(tok::comma, tok::greater, true, true); } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 02ddb6823f..16f0837240 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -747,10 +747,10 @@ Parser::OwningExprResult Parser::ParseSimpleAsm() { /// Note that this routine emits an error if you call it with ::new or ::delete /// as the current tokens, so only call it in contexts where these are invalid. bool Parser::TryAnnotateTypeOrScopeToken(const Token *GlobalQualifier) { - // FIXME: what about template-ids? - if (Tok.is(tok::annot_qualtypename) || Tok.is(tok::annot_cxxscope)) - return false; - + assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) && + "Cannot be a type or scope token!"); + + // FIXME: Implement template-ids CXXScopeSpec SS; if (getLang().CPlusPlus) MaybeParseCXXScopeSpecifier(SS, GlobalQualifier); @@ -818,9 +818,8 @@ bool Parser::TryAnnotateTypeOrScopeToken(const Token *GlobalQualifier) { bool Parser::TryAnnotateCXXScopeToken() { assert(getLang().CPlusPlus && "Call sites of this function should be guarded by checking for C++"); - - if (Tok.is(tok::annot_cxxscope)) - return false; + assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) && + "Cannot be a type or scope token!"); CXXScopeSpec SS; if (!MaybeParseCXXScopeSpecifier(SS)) |