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++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60117 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index f00eaeb..ec07b42 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -705,8 +705,8 @@
return;
CXXScopeSpec SS;
- if (isTokenCXXScopeSpecifier())
- ParseCXXScopeSpecifier(SS);
+ if (getLang().CPlusPlus)
+ MaybeParseCXXScopeSpecifier(SS);
if (Tok.is(tok::identifier)) {
TypeTy *Ty = Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope, &SS);
@@ -746,13 +746,15 @@
/// TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only
/// annotates C++ scope specifiers.
-void Parser::TryAnnotateScopeToken() {
+void Parser::TryAnnotateCXXScopeToken() {
+ assert(getLang().CPlusPlus &&
+ "Call sites of this function should be guarded by checking for C++.");
+
if (Tok.is(tok::annot_cxxscope))
return;
- if (isTokenCXXScopeSpecifier()) {
- CXXScopeSpec SS;
- ParseCXXScopeSpecifier(SS);
+ CXXScopeSpec SS;
+ if (MaybeParseCXXScopeSpecifier(SS)) {
// Push the current token back into the token stream (or revert it if it is
// cached) and use an annotation scope token for current token.