summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExprCXX.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-26 21:41:52 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-26 21:41:52 +0000
commitace521a1e1bc8c3c00dd5c1d655a606753b6653e (patch)
tree3aaa373255c12d6cca0f85b0fa2d9415466900ad /clang/lib/Parse/ParseExprCXX.cpp
parent041f958303ef302479bbd372ba8a044824851353 (diff)
downloadbcm5719-llvm-ace521a1e1bc8c3c00dd5c1d655a606753b6653e.tar.gz
bcm5719-llvm-ace521a1e1bc8c3c00dd5c1d655a606753b6653e.zip
Implement some suggestions by Daniel:
-Change Parser::ParseCXXScopeSpecifier to MaybeParseCXXScopeSpecifier -Remove Parser::isTokenCXXScopeSpecifier and fold it into MaybeParseCXXScopeSpecifier -Rename Parser::TryAnnotateScopeToken to TryAnnotateCXXScopeToken and only allow it to be called when in C++ llvm-svn: 60117
Diffstat (limited to 'clang/lib/Parse/ParseExprCXX.cpp')
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index b4b6fb53302..09aea033827 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -17,7 +17,8 @@
#include "AstGuard.h"
using namespace clang;
-/// ParseCXXScopeSpecifier - Parse global scope or nested-name-specifier.
+/// MaybeParseCXXScopeSpecifier - Parse global scope or nested-name-specifier.
+/// Returns true if a nested-name-specifier was parsed from the token stream.
///
/// '::'[opt] nested-name-specifier
/// '::'
@@ -28,14 +29,20 @@ using namespace clang;
/// nested-name-specifier identifier '::'
/// nested-name-specifier 'template'[opt] simple-template-id '::' [TODO]
///
-void Parser::ParseCXXScopeSpecifier(CXXScopeSpec &SS) {
- assert(isTokenCXXScopeSpecifier() && "Not scope specifier!");
+bool Parser::MaybeParseCXXScopeSpecifier(CXXScopeSpec &SS) {
+ assert(getLang().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++.");
+
+ if (Tok.isNot(tok::coloncolon) &&
+ Tok.isNot(tok::annot_cxxscope) &&
+ (Tok.isNot(tok::identifier) || NextToken().isNot(tok::coloncolon)))
+ return false;
if (Tok.is(tok::annot_cxxscope)) {
SS.setScopeRep(Tok.getAnnotationValue());
SS.setRange(Tok.getAnnotationRange());
ConsumeToken();
- return;
+ return true;
}
SS.setBeginLoc(Tok.getLocation());
@@ -68,6 +75,8 @@ void Parser::ParseCXXScopeSpecifier(CXXScopeSpec &SS) {
Actions.ActOnCXXNestedNameSpecifier(CurScope, SS, IdLoc, CCLoc, *II) );
SS.setEndLoc(CCLoc);
}
+
+ return true;
}
/// ParseCXXIdExpression - Handle id-expression.
@@ -126,8 +135,7 @@ Parser::ExprResult Parser::ParseCXXIdExpression() {
// '::' unqualified-id
//
CXXScopeSpec SS;
- if (isTokenCXXScopeSpecifier())
- ParseCXXScopeSpecifier(SS);
+ MaybeParseCXXScopeSpecifier(SS);
// unqualified-id:
// identifier
OpenPOWER on IntegriCloud