diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-02-24 00:17:56 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-02-24 00:17:56 +0000 |
| commit | 90c9972fb2c388ad319b63ee43d82c81aca07e20 (patch) | |
| tree | 139d7bf33df51ae0d1d2cb3c04e130ea3e6d1b2a /clang/lib/Parse | |
| parent | 60ed89dc549bf6b131c56d979d35e1debd6e3509 (diff) | |
| download | bcm5719-llvm-90c9972fb2c388ad319b63ee43d82c81aca07e20.tar.gz bcm5719-llvm-90c9972fb2c388ad319b63ee43d82c81aca07e20.zip | |
Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.
llvm-svn: 126346
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 2fb9c0e5aea..e12f62fb290 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -80,10 +80,9 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, return false; // '::' - Global scope qualifier. - SourceLocation CCLoc = ConsumeToken(); - SS.setBeginLoc(CCLoc); - SS.setScopeRep(Actions.ActOnCXXGlobalScopeSpecifier(getCurScope(), CCLoc)); - SS.setEndLoc(CCLoc); + if (Actions.ActOnCXXGlobalScopeSpecifier(getCurScope(), ConsumeToken(), SS)) + return true; + HasScopeSpecifier = true; } @@ -214,14 +213,14 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, } if (ParsedType T = getTypeAnnotation(TypeToken)) { - CXXScopeTy *Scope = - Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, T, - TypeToken.getAnnotationRange(), - CCLoc); - SS.setScopeRep(Scope); - } else - SS.setScopeRep(0); - SS.setEndLoc(CCLoc); + if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(), T, CCLoc, SS)) + SS.SetInvalid(SourceRange(SS.getBeginLoc(), CCLoc)); + + continue; + } else { + SS.SetInvalid(SourceRange(SS.getBeginLoc(), CCLoc)); + } + continue; } @@ -245,7 +244,9 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, // If we get foo:bar, this is almost certainly a typo for foo::bar. Recover // and emit a fixit hint for it. if (Next.is(tok::colon) && !ColonIsSacred) { - if (Actions.IsInvalidUnlessNestedName(getCurScope(), SS, II, ObjectType, + if (Actions.IsInvalidUnlessNestedName(getCurScope(), SS, II, + Tok.getLocation(), + Next.getLocation(), ObjectType, EnteringContext) && // If the token after the colon isn't an identifier, it's still an // error, but they probably meant something else strange so don't @@ -274,16 +275,11 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, "NextToken() not working properly!"); SourceLocation CCLoc = ConsumeToken(); - if (!HasScopeSpecifier) { - SS.setBeginLoc(IdLoc); - HasScopeSpecifier = true; - } - - if (!SS.isInvalid()) - SS.setScopeRep( - Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, IdLoc, CCLoc, II, - ObjectType, EnteringContext)); - SS.setEndLoc(CCLoc); + HasScopeSpecifier = true; + if (Actions.ActOnCXXNestedNameSpecifier(getCurScope(), II, IdLoc, CCLoc, + ObjectType, EnteringContext, SS)) + SS.SetInvalid(SourceRange(IdLoc, CCLoc)); + continue; } |

