diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-07-02 17:43:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-07-02 17:43:08 +0000 |
commit | 23c94dbb6631fecdb55ba401aa93722803d980c6 (patch) | |
tree | 19240dbaae509d69e403e4962fd5a14b9c8d5c53 /lib/Parse/ParseExprCXX.cpp | |
parent | fe2dd6ceeeb31a7c681b2873a8459c5de5d1a3e9 (diff) |
Move the "current scope" state from the Parser into Action. This
allows Sema some limited access to the current scope, which we only
use in one way: when Sema is performing some kind of declaration that
is not directly driven by the parser (e.g., due to template
instantiatio or lazy declaration of a member), we can find the Scope
associated with a DeclContext, if that DeclContext is still in the
process of being parsed.
Use this to make the implicit declaration of special member functions
in a C++ class more "scope-less", rather than using the NULL Scope hack.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107491 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExprCXX.cpp')
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 08357e63f6..9d4389b1ff 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -81,7 +81,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, // '::' - Global scope qualifier. SourceLocation CCLoc = ConsumeToken(); SS.setBeginLoc(CCLoc); - SS.setScopeRep(Actions.ActOnCXXGlobalScopeSpecifier(CurScope, CCLoc)); + SS.setScopeRep(Actions.ActOnCXXGlobalScopeSpecifier(getCurScope(), CCLoc)); SS.setEndLoc(CCLoc); HasScopeSpecifier = true; } @@ -109,7 +109,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, if (Tok.is(tok::code_completion)) { // Code completion for a nested-name-specifier, where the code // code completion token follows the '::'. - Actions.CodeCompleteQualifiedId(CurScope, SS, EnteringContext); + Actions.CodeCompleteQualifiedId(getCurScope(), SS, EnteringContext); ConsumeCodeCompletionToken(); } } @@ -165,7 +165,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, // Commit to parsing the template-id. TPA.Commit(); TemplateTy Template; - if (TemplateNameKind TNK = Actions.ActOnDependentTemplateName(CurScope, + if (TemplateNameKind TNK = Actions.ActOnDependentTemplateName(getCurScope(), TemplateKWLoc, SS, TemplateName, @@ -214,7 +214,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, if (TypeToken.getAnnotationValue()) SS.setScopeRep( - Actions.ActOnCXXNestedNameSpecifier(CurScope, SS, + Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, TypeToken.getAnnotationValue(), TypeToken.getAnnotationRange(), CCLoc)); @@ -244,7 +244,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, // If we get foo:bar, this is almost certainly a typo for foo::bar. Recover // and emit a fixit hint for it. if (Next.is(tok::colon) && !ColonIsSacred) { - if (Actions.IsInvalidUnlessNestedName(CurScope, SS, II, ObjectType, + if (Actions.IsInvalidUnlessNestedName(getCurScope(), SS, II, ObjectType, EnteringContext) && // If the token after the colon isn't an identifier, it's still an // error, but they probably meant something else strange so don't @@ -260,7 +260,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, if (Next.is(tok::coloncolon)) { if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde) && - !Actions.isNonTypeNestedNameSpecifier(CurScope, SS, Tok.getLocation(), + !Actions.isNonTypeNestedNameSpecifier(getCurScope(), SS, Tok.getLocation(), II, ObjectType)) { *MayBePseudoDestructor = true; return false; @@ -280,7 +280,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, if (!SS.isInvalid()) SS.setScopeRep( - Actions.ActOnCXXNestedNameSpecifier(CurScope, SS, IdLoc, CCLoc, II, + Actions.ActOnCXXNestedNameSpecifier(getCurScope(), SS, IdLoc, CCLoc, II, ObjectType, EnteringContext)); SS.setEndLoc(CCLoc); continue; @@ -293,7 +293,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, UnqualifiedId TemplateName; TemplateName.setIdentifier(&II, Tok.getLocation()); bool MemberOfUnknownSpecialization; - if (TemplateNameKind TNK = Actions.isTemplateName(CurScope, SS, + if (TemplateNameKind TNK = Actions.isTemplateName(getCurScope(), SS, TemplateName, ObjectType, EnteringContext, @@ -323,7 +323,7 @@ bool Parser::ParseOptionalCXXScopeSpecifier(CXXScopeSpec &SS, << FixItHint::CreateInsertion(Tok.getLocation(), "template "); if (TemplateNameKind TNK - = Actions.ActOnDependentTemplateName(CurScope, + = Actions.ActOnDependentTemplateName(getCurScope(), Tok.getLocation(), SS, TemplateName, ObjectType, EnteringContext, Template)) { @@ -431,7 +431,7 @@ Parser::OwningExprResult Parser::ParseCXXIdExpression(bool isAddressOfOperand) { } } - return Actions.ActOnIdExpression(CurScope, SS, Name, Tok.is(tok::l_paren), + return Actions.ActOnIdExpression(getCurScope(), SS, Name, Tok.is(tok::l_paren), isAddressOfOperand); } @@ -612,7 +612,7 @@ Parser::ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc, /*TemplateKWLoc*/SourceLocation())) return ExprError(); - return Actions.ActOnPseudoDestructorExpr(CurScope, move(Base), OpLoc, OpKind, + return Actions.ActOnPseudoDestructorExpr(getCurScope(), move(Base), OpLoc, OpKind, SS, FirstTypeName, CCLoc, TildeLoc, SecondTypeName, Tok.is(tok::l_paren)); @@ -678,7 +678,7 @@ Parser::OwningExprResult Parser::ParseCXXThis() { Parser::OwningExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); - TypeTy *TypeRep = Actions.ActOnTypeName(CurScope, DeclaratorInfo).get(); + TypeTy *TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get(); assert(Tok.is(tok::l_paren) && "Expected '('!"); SourceLocation LParenLoc = ConsumeParen(); @@ -733,7 +733,7 @@ bool Parser::ParseCXXCondition(OwningExprResult &ExprResult, SourceLocation Loc, bool ConvertToBoolean) { if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Condition); + Actions.CodeCompleteOrdinaryName(getCurScope(), Action::CCC_Condition); ConsumeCodeCompletionToken(); } @@ -747,7 +747,7 @@ bool Parser::ParseCXXCondition(OwningExprResult &ExprResult, // If required, convert to a boolean value. if (ConvertToBoolean) ExprResult - = Actions.ActOnBooleanCondition(CurScope, Loc, move(ExprResult)); + = Actions.ActOnBooleanCondition(getCurScope(), Loc, move(ExprResult)); return ExprResult.isInvalid(); } @@ -779,7 +779,7 @@ bool Parser::ParseCXXCondition(OwningExprResult &ExprResult, } // Type-check the declaration itself. - Action::DeclResult Dcl = Actions.ActOnCXXConditionDeclaration(CurScope, + Action::DeclResult Dcl = Actions.ActOnCXXConditionDeclaration(getCurScope(), DeclaratorInfo); DeclResult = Dcl.get(); ExprResult = ExprError(); @@ -1016,14 +1016,14 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, case UnqualifiedId::IK_OperatorFunctionId: case UnqualifiedId::IK_LiteralOperatorId: if (AssumeTemplateId) { - TNK = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, SS, + TNK = Actions.ActOnDependentTemplateName(getCurScope(), TemplateKWLoc, SS, Id, ObjectType, EnteringContext, Template); if (TNK == TNK_Non_template) return true; } else { bool MemberOfUnknownSpecialization; - TNK = Actions.isTemplateName(CurScope, SS, Id, ObjectType, + TNK = Actions.isTemplateName(getCurScope(), SS, Id, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); @@ -1046,7 +1046,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, Diag(Id.StartLocation, diag::err_missing_dependent_template_keyword) << Name << FixItHint::CreateInsertion(Id.StartLocation, "template "); - TNK = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, + TNK = Actions.ActOnDependentTemplateName(getCurScope(), TemplateKWLoc, SS, Id, ObjectType, EnteringContext, Template); if (TNK == TNK_Non_template) @@ -1059,7 +1059,7 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, UnqualifiedId TemplateName; bool MemberOfUnknownSpecialization; TemplateName.setIdentifier(Name, NameLoc); - TNK = Actions.isTemplateName(CurScope, SS, TemplateName, ObjectType, + TNK = Actions.isTemplateName(getCurScope(), SS, TemplateName, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); break; @@ -1070,13 +1070,13 @@ bool Parser::ParseUnqualifiedIdTemplateId(CXXScopeSpec &SS, bool MemberOfUnknownSpecialization; TemplateName.setIdentifier(Name, NameLoc); if (ObjectType) { - TNK = Actions.ActOnDependentTemplateName(CurScope, TemplateKWLoc, SS, + TNK = Actions.ActOnDependentTemplateName(getCurScope(), TemplateKWLoc, SS, TemplateName, ObjectType, EnteringContext, Template); if (TNK == TNK_Non_template) return true; } else { - TNK = Actions.isTemplateName(CurScope, SS, TemplateName, ObjectType, + TNK = Actions.isTemplateName(getCurScope(), SS, TemplateName, ObjectType, EnteringContext, Template, MemberOfUnknownSpecialization); @@ -1273,7 +1273,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, case tok::code_completion: { // Code completion for the operator name. - Actions.CodeCompleteOperatorName(CurScope); + Actions.CodeCompleteOperatorName(getCurScope()); // Consume the operator token. ConsumeCodeCompletionToken(); @@ -1334,7 +1334,7 @@ bool Parser::ParseUnqualifiedIdOperator(CXXScopeSpec &SS, bool EnteringContext, ParseDeclaratorInternal(D, /*DirectDeclParser=*/0); // Finish up the type. - Action::TypeResult Ty = Actions.ActOnTypeName(CurScope, D); + Action::TypeResult Ty = Actions.ActOnTypeName(getCurScope(), D); if (Ty.isInvalid()) return true; @@ -1406,9 +1406,9 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, } if (AllowConstructorName && - Actions.isCurrentClassName(*Id, CurScope, &SS)) { + Actions.isCurrentClassName(*Id, getCurScope(), &SS)) { // We have parsed a constructor name. - Result.setConstructorName(Actions.getTypeName(*Id, IdLoc, CurScope, + Result.setConstructorName(Actions.getTypeName(*Id, IdLoc, getCurScope(), &SS, false), IdLoc, IdLoc); } else { @@ -1433,7 +1433,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, // If the template-name names the current class, then this is a constructor if (AllowConstructorName && TemplateId->Name && - Actions.isCurrentClassName(*TemplateId->Name, CurScope, &SS)) { + Actions.isCurrentClassName(*TemplateId->Name, getCurScope(), &SS)) { if (SS.isSet()) { // C++ [class.qual]p2 specifies that a qualified template-name // is taken as the constructor name where a constructor can be @@ -1446,7 +1446,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc)); Result.setConstructorName(Actions.getTypeName(*TemplateId->Name, TemplateId->TemplateNameLoc, - CurScope, + getCurScope(), &SS, false), TemplateId->TemplateNameLoc, TemplateId->RAngleLoc); @@ -1519,7 +1519,7 @@ bool Parser::ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, // Note that this is a destructor name. Action::TypeTy *Ty = Actions.getDestructorName(TildeLoc, *ClassName, - ClassNameLoc, CurScope, + ClassNameLoc, getCurScope(), SS, ObjectType, EnteringContext); if (!Ty) @@ -1895,7 +1895,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, // Result is what ParseCastExpression returned earlier. if (!Result.isInvalid()) - Result = Actions.ActOnCastExpr(CurScope, LParenLoc, CastTy, RParenLoc, + Result = Actions.ActOnCastExpr(getCurScope(), LParenLoc, CastTy, RParenLoc, move(Result)); return move(Result); } |