diff options
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 7c38857f5a8..f6a79e5967c 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -52,7 +52,10 @@ Decl *Parser::ParseNamespace(unsigned Context, SourceLocation InlineLoc) { assert(Tok.is(tok::kw_namespace) && "Not a namespace!"); SourceLocation NamespaceLoc = ConsumeToken(); // eat the 'namespace'. - + Decl *DC = getObjCDeclContext(); + if (DC) + Actions.ActOnObjCContainerFinishDefinition(DC); + if (Tok.is(tok::code_completion)) { Actions.CodeCompleteNamespaceDecl(getCurScope()); ConsumeCodeCompletionToken(); @@ -89,8 +92,10 @@ Decl *Parser::ParseNamespace(unsigned Context, if (InlineLoc.isValid()) Diag(InlineLoc, diag::err_inline_namespace_alias) << FixItHint::CreateRemoval(InlineLoc); - - return ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd); + Decl *Res = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd); + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); + return Res; } @@ -101,6 +106,8 @@ Decl *Parser::ParseNamespace(unsigned Context, } Diag(Tok, Ident ? diag::err_expected_lbrace : diag::err_expected_ident_lbrace); + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); return 0; } @@ -115,6 +122,8 @@ Decl *Parser::ParseNamespace(unsigned Context, } Diag(LBrace, diag::err_namespace_nonnamespace_scope); SkipUntil(tok::r_brace, false); + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); return 0; } @@ -173,6 +182,8 @@ Decl *Parser::ParseNamespace(unsigned Context, Actions.ActOnFinishNamespaceDef(NamespcDecl, RBraceLoc); DeclEnd = RBraceLoc; + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); return NamespcDecl; } @@ -317,7 +328,9 @@ Decl *Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, ParsedAttributesWithRange &attrs, Decl **OwnedType) { assert(Tok.is(tok::kw_using) && "Not using token"); - + Decl *DC = getObjCDeclContext(); + if (DC) + Actions.ActOnObjCContainerFinishDefinition(DC); // Eat 'using'. SourceLocation UsingLoc = ConsumeToken(); @@ -335,7 +348,10 @@ Decl *Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, << R << FixItHint::CreateRemoval(R); } - return ParseUsingDirective(Context, UsingLoc, DeclEnd, attrs); + Decl *Res = ParseUsingDirective(Context, UsingLoc, DeclEnd, attrs); + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); + return Res; } // Otherwise, it must be a using-declaration or an alias-declaration. @@ -343,8 +359,11 @@ Decl *Parser::ParseUsingDirectiveOrDeclaration(unsigned Context, // Using declarations can't have attributes. ProhibitAttributes(attrs); - return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, - AS_none, OwnedType); + Decl *Res = ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, + AS_none, OwnedType); + if (DC) + Actions.ActOnObjCContainerStartDefinition(DC); + return Res; } /// ParseUsingDirective - Parse C++ using-directive, assumes |