/// \param II the identifier that represents the scope that this
/// nested-name-specifier refers to, e.g., the "bar" in "foo::bar::".
///
- /// \param MayBePseudoDestructor Whether this nested-name-specifier
- /// may be part of a pseudo-destructor, meaning that we are in a
- /// member access expression (such as p->T::~T()) and a '~' follows
- /// the '::'.
- ///
/// \param ObjectType if this nested-name-specifier occurs as part of a
/// C++ member access expression such as "x->Base::f", the type of the base
/// object (e.g., *x in the example, if "x" were a pointer).
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
TypeTy *ObjectType,
bool EnteringContext) {
return 0;
virtual bool IsInvalidUnlessNestedName(Scope *S,
const CXXScopeSpec &SS,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
TypeTy *ObjectType,
bool EnteringContext) {
return false;
const CXXScopeSpec &SS,
TypeTy *Type,
SourceRange TypeRange,
- SourceLocation CCLoc,
- bool MayBePseudoDestructor) {
+ SourceLocation CCLoc) {
return 0;
}
if (LHS.isInvalid())
break;
- ParseOptionalCXXScopeSpecifier(SS, ObjectType, false,
+ ParseOptionalCXXScopeSpecifier(SS, ObjectType, false,
&MayBePseudoDestructor);
}
Actions.ActOnCXXNestedNameSpecifier(CurScope, SS,
TypeToken.getAnnotationValue(),
TypeToken.getAnnotationRange(),
- CCLoc,
- false));
+ CCLoc));
else
SS.setScopeRep(0);
SS.setEndLoc(CCLoc);
// 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 (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde) &&
- !Actions.isNonTypeNestedNameSpecifier(CurScope, SS, Tok.getLocation(),
- II, ObjectType)) {
- *MayBePseudoDestructor = true;
- return HasScopeSpecifier;
- }
-
- if (Actions.IsInvalidUnlessNestedName(CurScope, SS, II,
- false, ObjectType,
+ if (Actions.IsInvalidUnlessNestedName(CurScope, 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
SS.setScopeRep(
Actions.ActOnCXXNestedNameSpecifier(CurScope, SS, IdLoc, CCLoc, II,
- false, ObjectType,
- EnteringContext));
+ ObjectType, EnteringContext));
SS.setEndLoc(CCLoc);
continue;
}
virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S,
SourceLocation CCLoc);
- bool isAcceptableNestedNameSpecifier(NamedDecl *SD,
- bool MayBePseudoDestructor = false);
+ bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
virtual bool isNonTypeNestedNameSpecifier(Scope *S, const CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
QualType ObjectType,
NamedDecl *ScopeLookupResult,
bool EnteringContext,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
TypeTy *ObjectType,
bool EnteringContext);
virtual bool IsInvalidUnlessNestedName(Scope *S,
const CXXScopeSpec &SS,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
TypeTy *ObjectType,
bool EnteringContext);
const CXXScopeSpec &SS,
TypeTy *Type,
SourceRange TypeRange,
- SourceLocation CCLoc,
- bool MayBePseudoDestructor);
+ SourceLocation CCLoc);
virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
- if (const TagType *Tag = NNS->getAsType()->getAs<TagType>())
- return Tag->getDecl();
- break;
- }
+ const TagType *Tag = NNS->getAsType()->getAs<TagType>();
+ assert(Tag && "Non-tag type in nested-name-specifier");
+ return Tag->getDecl();
+ } break;
case NestedNameSpecifier::Global:
return Context.getTranslationUnitDecl();
}
+ // Required to silence a GCC warning.
return 0;
}
/// \brief Determines whether the given declaration is an valid acceptable
/// result for name lookup of a nested-name-specifier.
-bool Sema::isAcceptableNestedNameSpecifier(NamedDecl *SD,
- bool MayBePseudoDestructor) {
+bool Sema::isAcceptableNestedNameSpecifier(NamedDecl *SD) {
if (!SD)
return false;
if (!isa<TypeDecl>(SD))
return false;
- // If this may be part of a pseudo-destructor expression, we'll
- // accept any type.
- if (MayBePseudoDestructor)
- return true;
-
// Determine whether we have a class (or, in C++0x, an enum) or
// a typedef thereof. If so, build the nested-name-specifier.
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
return 0;
NamedDecl *Result = Found.getFoundDecl();
- if (isAcceptableNestedNameSpecifier(Result, true))
+ if (isAcceptableNestedNameSpecifier(Result))
return Result;
return 0;
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
QualType ObjectType,
NamedDecl *ScopeLookupResult,
bool EnteringContext,
DeclarationName Name = Found.getLookupName();
if (CorrectTypo(Found, S, &SS, LookupCtx, EnteringContext) &&
Found.isSingleResult() &&
- isAcceptableNestedNameSpecifier(Found.getAsSingle<NamedDecl>(),
- MayBePseudoDestructor)) {
+ isAcceptableNestedNameSpecifier(Found.getAsSingle<NamedDecl>())) {
if (LookupCtx)
Diag(Found.getNameLoc(), diag::err_no_member_suggest)
<< Name << LookupCtx << Found.getLookupName() << SS.getRange()
}
NamedDecl *SD = Found.getAsSingle<NamedDecl>();
- if (isAcceptableNestedNameSpecifier(SD, MayBePseudoDestructor)) {
+ if (isAcceptableNestedNameSpecifier(SD)) {
if (!ObjectType.isNull() && !ObjectTypeSearchedInScope) {
// C++ [basic.lookup.classref]p4:
// [...] If the name is found in both contexts, the
// scope, reconstruct the result from the template instantiation itself.
NamedDecl *OuterDecl;
if (S) {
- LookupResult FoundOuter(*this, &II, IdLoc,
- LookupNestedNameSpecifierName);
+ LookupResult FoundOuter(*this, &II, IdLoc, LookupNestedNameSpecifierName);
LookupName(FoundOuter, S);
OuterDecl = FoundOuter.getAsSingle<NamedDecl>();
} else
OuterDecl = ScopeLookupResult;
- if (isAcceptableNestedNameSpecifier(OuterDecl, MayBePseudoDestructor) &&
+ if (isAcceptableNestedNameSpecifier(OuterDecl) &&
OuterDecl->getCanonicalDecl() != SD->getCanonicalDecl() &&
(!isa<TypeDecl>(OuterDecl) || !isa<TypeDecl>(SD) ||
!Context.hasSameType(
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
TypeTy *ObjectTypePtr,
bool EnteringContext) {
return BuildCXXNestedNameSpecifier(S, SS, IdLoc, CCLoc, II,
- MayBePseudoDestructor,
QualType::getFromOpaquePtr(ObjectTypePtr),
/*ScopeLookupResult=*/0, EnteringContext,
false);
///
/// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
bool Sema::IsInvalidUnlessNestedName(Scope *S, const CXXScopeSpec &SS,
- IdentifierInfo &II,
- bool MayBePseudoDestructor,
- TypeTy *ObjectType,
+ IdentifierInfo &II, TypeTy *ObjectType,
bool EnteringContext) {
return BuildCXXNestedNameSpecifier(S, SS, SourceLocation(), SourceLocation(),
- II, MayBePseudoDestructor,
- QualType::getFromOpaquePtr(ObjectType),
+ II, QualType::getFromOpaquePtr(ObjectType),
/*ScopeLookupResult=*/0, EnteringContext,
true);
}
const CXXScopeSpec &SS,
TypeTy *Ty,
SourceRange TypeRange,
- SourceLocation CCLoc,
- bool MayBePseudoDestructor) {
+ SourceLocation CCLoc) {
NestedNameSpecifier *Prefix
= static_cast<NestedNameSpecifier *>(SS.getScopeRep());
QualType T = GetTypeFromParser(Ty);
isDependent = LookupCtx && LookupCtx->isDependentContext();
}
- LookInScope = (LookupCtx == 0) && !isDependent;
+ LookInScope = false;
} else if (ObjectTypePtr) {
// C++ [basic.lookup.classref]p3:
// If the unqualified-id is ~type-name, the type-name is looked up
NestedNameSpecifier *NNS
= TransformNestedNameSpecifier(T->getQualifier(),
/*FIXME:*/SourceRange(getBaseLocation()),
- false,
ObjectType);
if (!NNS)
return QualType();
const MultiLevelTemplateArgumentList &TemplateArgs) {
TemplateInstantiator Instantiator(*this, TemplateArgs, Range.getBegin(),
DeclarationName());
- return Instantiator.TransformNestedNameSpecifier(NNS, Range, false);
+ return Instantiator.TransformNestedNameSpecifier(NNS, Range);
}
TemplateName
/// alternate behavior.
NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
- bool MayBePseudoDestructor,
QualType ObjectType = QualType(),
NamedDecl *FirstQualifierInScope = 0);
NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
SourceRange Range,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
QualType ObjectType,
NamedDecl *FirstQualifierInScope);
NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
SourceRange Range,
bool TemplateKW,
- QualType T,
- bool MayBePseudoDestructor);
+ QualType T);
/// \brief Build a new template name given a nested name specifier, a flag
/// indicating whether the "template" keyword was provided, and the template
NestedNameSpecifier *
TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
SourceRange Range,
- bool MayBePseudoDestructor,
QualType ObjectType,
NamedDecl *FirstQualifierInScope) {
if (!NNS)
NestedNameSpecifier *Prefix = NNS->getPrefix();
if (Prefix) {
Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range,
- false,
ObjectType,
FirstQualifierInScope);
if (!Prefix)
return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
*NNS->getAsIdentifier(),
- MayBePseudoDestructor,
ObjectType,
FirstQualifierInScope);
return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
- T,
- MayBePseudoDestructor);
+ T);
}
}
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(QTN->getQualifier(),
/*FIXME:*/SourceRange(getDerived().getBaseLocation()),
- false,
ObjectType);
if (!NNS)
return TemplateName();
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(DTN->getQualifier(),
/*FIXME:*/SourceRange(getDerived().getBaseLocation()),
- false,
ObjectType);
if (!NNS && DTN->getQualifier())
return TemplateName();
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
SourceRange(),
- false,
ObjectType);
if (!NNS)
return QualType();
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(T->getQualifier(), SR,
- false, ObjectType);
+ ObjectType);
if (!NNS)
return QualType();
NestedNameSpecifier *Qualifier = 0;
if (E->getQualifier()) {
Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
- E->getQualifierRange(),
- false);
+ E->getQualifierRange());
if (!Qualifier)
return SemaRef.ExprError();
}
if (E->hasQualifier()) {
Qualifier
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
- E->getQualifierRange(),
- false);
+ E->getQualifierRange());
if (Qualifier == 0)
return SemaRef.ExprError();
}
NestedNameSpecifier *Qualifier
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange(),
- true,
ObjectType);
if (E->getQualifier() && !Qualifier)
return SemaRef.ExprError();
NestedNameSpecifier *Qualifier = 0;
if (Old->getQualifier()) {
Qualifier = getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
- Old->getQualifierRange(),
- false);
+ Old->getQualifierRange());
if (!Qualifier)
return SemaRef.ExprError();
DependentScopeDeclRefExpr *E) {
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
- E->getQualifierRange(),
- false);
+ E->getQualifierRange());
if (!NNS)
return SemaRef.ExprError();
NestedNameSpecifier *Qualifier = 0;
if (E->getQualifier()) {
- bool MayBePseudoDestructor
- = E->getMember().getNameKind() == DeclarationName::CXXDestructorName;
Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
E->getQualifierRange(),
- MayBePseudoDestructor,
ObjectType,
FirstQualifierInScope);
if (!Qualifier)
if (Old->getQualifier()) {
Qualifier
= getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
- Old->getQualifierRange(),
- false);
+ Old->getQualifierRange());
if (Qualifier == 0)
return SemaRef.ExprError();
}
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
SourceRange Range,
IdentifierInfo &II,
- bool MayBePseudoDestructor,
QualType ObjectType,
NamedDecl *FirstQualifierInScope) {
CXXScopeSpec SS;
return static_cast<NestedNameSpecifier *>(
SemaRef.BuildCXXNestedNameSpecifier(0, SS, Range.getEnd(),
Range.getEnd(), II,
- MayBePseudoDestructor,
ObjectType,
FirstQualifierInScope,
false, false));
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
SourceRange Range,
bool TemplateKW,
- QualType T,
- bool MayBePseudoDestructor) {
- if (MayBePseudoDestructor || T->isDependentType() || T->isRecordType() ||
+ QualType T) {
+ if (T->isDependentType() || T->isRecordType() ||
(SemaRef.getLangOptions().CPlusPlus0x && T->isEnumeralType())) {
assert(!T.hasLocalQualifiers() && "Can't get cv-qualifiers here");
return NestedNameSpecifier::Create(SemaRef.Context, Prefix, TemplateKW,