diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-29 14:02:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-29 14:02:43 +0000 |
commit | 5144832ae62cf97543b274d4bb88d5f74d0f7a20 (patch) | |
tree | 5d5aeda7700c85b0a4d8f291317545f438b91b41 /lib/Parse/ParseDeclCXX.cpp | |
parent | b2e57f6b6540644b53c59589b91a12ee1c561e28 (diff) |
reduce indentation with an early exit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 4201e1cb1e..c50a033e56 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -64,36 +64,34 @@ Parser::DeclPtrTy Parser::ParseNamespace(unsigned Context) { // FIXME: Verify no attributes were present. return ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident); - if (Tok.is(tok::l_brace)) { - SourceLocation LBrace = ConsumeBrace(); + if (Tok.isNot(tok::l_brace)) { + Diag(Tok, Ident ? diag::err_expected_lbrace : + diag::err_expected_ident_lbrace); + return DeclPtrTy(); + } + + SourceLocation LBrace = ConsumeBrace(); - // Enter a scope for the namespace. - ParseScope NamespaceScope(this, Scope::DeclScope); + // Enter a scope for the namespace. + ParseScope NamespaceScope(this, Scope::DeclScope); - DeclPtrTy NamespcDecl = - Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace); + DeclPtrTy NamespcDecl = + Actions.ActOnStartNamespaceDef(CurScope, IdentLoc, Ident, LBrace); - PrettyStackTraceActionsDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions, - PP.getSourceManager(), - "parsing namespace"); - - while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) - ParseExternalDeclaration(); - - // Leave the namespace scope. - NamespaceScope.Exit(); + PrettyStackTraceActionsDecl CrashInfo(NamespcDecl, NamespaceLoc, Actions, + PP.getSourceManager(), + "parsing namespace"); + + while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) + ParseExternalDeclaration(); + + // Leave the namespace scope. + NamespaceScope.Exit(); - SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace); - Actions.ActOnFinishNamespaceDef(NamespcDecl, RBrace); + SourceLocation RBrace = MatchRHSPunctuation(tok::r_brace, LBrace); + Actions.ActOnFinishNamespaceDef(NamespcDecl, RBrace); - return NamespcDecl; - - } else { - Diag(Tok, Ident ? diag::err_expected_lbrace : - diag::err_expected_ident_lbrace); - } - - return DeclPtrTy(); + return NamespcDecl; } /// ParseNamespaceAlias - Parse the part after the '=' in a namespace |