summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-04 22:32:19 +0000
committerChris Lattner <sabre@nondot.org>2009-01-04 22:32:19 +0000
commitdfa1a45abd566ed681cc876af626d06c8c04366c (patch)
treefc0bb1a06063c7c9eefc550c604fc34d8fbe22b3
parent8a38aa83daa7d81adb9aa09e4c590edf5f66cb56 (diff)
downloadbcm5719-llvm-dfa1a45abd566ed681cc876af626d06c8c04366c.tar.gz
bcm5719-llvm-dfa1a45abd566ed681cc876af626d06c8c04366c.zip
use early exits to reduce nesting.
llvm-svn: 61642
-rw-r--r--clang/lib/Parse/Parser.cpp65
1 files changed, 33 insertions, 32 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 3c79d6405cb..381c84e3178 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -784,48 +784,49 @@ void Parser::TryAnnotateTypeOrScopeToken() {
// FIXME: check for a template-id token here, and look it up if it
// names a type.
- if (SS.isNotEmpty()) {
- // A C++ scope specifier that isn't followed by a typename.
- // 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.
- if (PP.isBacktrackEnabled())
- PP.RevertCachedTokens(1);
- else
- PP.EnterToken(Tok);
- Tok.setKind(tok::annot_cxxscope);
- Tok.setAnnotationValue(SS.getScopeRep());
- Tok.setAnnotationRange(SS.getRange());
-
- // In case the tokens were cached, have Preprocessor replace them with the
- // annotation token.
- PP.AnnotateCachedTokens(Tok);
- }
+ if (SS.isEmpty())
+ return;
+
+ // A C++ scope specifier that isn't followed by a typename.
+ // 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.
+ if (PP.isBacktrackEnabled())
+ PP.RevertCachedTokens(1);
+ else
+ PP.EnterToken(Tok);
+ Tok.setKind(tok::annot_cxxscope);
+ Tok.setAnnotationValue(SS.getScopeRep());
+ Tok.setAnnotationRange(SS.getRange());
+
+ // In case the tokens were cached, have Preprocessor replace them with the
+ // annotation token.
+ PP.AnnotateCachedTokens(Tok);
}
/// TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only
/// annotates C++ scope specifiers.
void Parser::TryAnnotateCXXScopeToken() {
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))
return;
CXXScopeSpec SS;
- if (MaybeParseCXXScopeSpecifier(SS)) {
+ if (!MaybeParseCXXScopeSpecifier(SS))
+ return;
- // 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.
- if (PP.isBacktrackEnabled())
- PP.RevertCachedTokens(1);
- else
- PP.EnterToken(Tok);
- Tok.setKind(tok::annot_cxxscope);
- Tok.setAnnotationValue(SS.getScopeRep());
- Tok.setAnnotationRange(SS.getRange());
-
- // In case the tokens were cached, have Preprocessor replace them with the
- // annotation token.
- PP.AnnotateCachedTokens(Tok);
- }
+ // 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.
+ if (PP.isBacktrackEnabled())
+ PP.RevertCachedTokens(1);
+ else
+ PP.EnterToken(Tok);
+ Tok.setKind(tok::annot_cxxscope);
+ Tok.setAnnotationValue(SS.getScopeRep());
+ Tok.setAnnotationRange(SS.getRange());
+
+ // In case the tokens were cached, have Preprocessor replace them with the
+ // annotation token.
+ PP.AnnotateCachedTokens(Tok);
}
OpenPOWER on IntegriCloud