SourceLocation getEndLoc() const { return Range.getEnd(); }
NestedNameSpecifier *getScopeRep() const { return ScopeRep; }
- void setScopeRep(NestedNameSpecifier *S) { ScopeRep = S; }
/// \brief Extend the current nested-name-specifier by another
/// nested-name-specifier component of the form 'type::'.
/// nested-name-specifier '::'.
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc);
+ /// \brief Adopt an existing nested-name-specifier and its source range
+ /// as our own.
+ void Adopt(NestedNameSpecifier *Qualifier, SourceRange R) {
+ ScopeRep = Qualifier;
+ Range = R;
+ }
+
/// No scope specifier.
bool isEmpty() const { return !Range.isValid(); }
/// A scope specifier is present, but may be valid or invalid.
goto DoneWithDeclSpec;
CXXScopeSpec SS;
- SS.setScopeRep((NestedNameSpecifier*) Tok.getAnnotationValue());
- SS.setRange(Tok.getAnnotationRange());
+ SS.Adopt(static_cast<NestedNameSpecifier *>(Tok.getAnnotationValue()),
+ Tok.getAnnotationRange());
// We are looking for a qualified typename.
Token Next = NextToken();
"Call sites of this function should be guarded by checking for C++");
if (Tok.is(tok::annot_cxxscope)) {
- SS.setScopeRep(static_cast<NestedNameSpecifier*>(Tok.getAnnotationValue()));
- SS.setRange(Tok.getAnnotationRange());
+ SS.Adopt(static_cast<NestedNameSpecifier*>(Tok.getAnnotationValue()),
+ Tok.getAnnotationRange());
ConsumeToken();
return false;
}
// reference to operator=; this is required to suppress the virtual
// call mechanism.
CXXScopeSpec SS;
- SS.setRange(Loc);
- SS.setScopeRep(NestedNameSpecifier::Create(S.Context, 0, false,
- T.getTypePtr()));
+ SS.Adopt(NestedNameSpecifier::Create(S.Context, 0, false, T.getTypePtr()),
+ Loc);
// Create the reference to operator=.
ExprResult OpEqualRef
// Nothing left to do.
} else if (LookAtPrefix && (Prefix = NNS->getPrefix())) {
CXXScopeSpec PrefixSS;
- PrefixSS.setScopeRep(Prefix);
+ PrefixSS.Adopt(Prefix, SS.getRange());
LookupCtx = computeDeclContext(PrefixSS, EnteringContext);
isDependent = isDependentScopeSpecifier(PrefixSS);
} else if (ObjectTypePtr) {
SourceLocation RParenLoc) {
CXXScopeSpec SS;
- if (ULE->getQualifier()) {
- SS.setScopeRep(ULE->getQualifier());
- SS.setRange(ULE->getQualifierRange());
- }
+ if (ULE->getQualifier())
+ SS.Adopt(ULE->getQualifier(), ULE->getQualifierRange());
TemplateArgumentListInfo TABuffer;
const TemplateArgumentListInfo *ExplicitTemplateArgs = 0;
= NestedNameSpecifier::Create(Context, 0, false,
ClassType.getTypePtr());
CXXScopeSpec SS;
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, Loc);
// The actual value-ness of this is unimportant, but for
// internal consistency's sake, references to instance methods
SourceLocation KeywordLoc, SourceRange NNSRange,
SourceLocation IILoc) {
CXXScopeSpec SS;
- SS.setScopeRep(NNS);
- SS.setRange(NNSRange);
+ SS.Adopt(NNS, NNSRange);
DeclContext *Ctx = computeDeclContext(SS);
if (!Ctx) {
Rebuilder.TransformNestedNameSpecifier(NNS, SS.getRange());
if (!Rebuilt) return true;
- SS.setScopeRep(Rebuilt);
+ SS.Adopt(Rebuilt, SS.getRange());
return false;
}
if (isFriend) {
if (Qualifier) {
CXXScopeSpec SS;
- SS.setScopeRep(Qualifier);
- SS.setRange(Pattern->getQualifierRange());
+ SS.Adopt(Qualifier, Pattern->getQualifierRange());
DC = SemaRef.computeDeclContext(SS);
if (!DC) return 0;
} else {
DC = Owner;
else if (isFriend && Qualifier) {
CXXScopeSpec SS;
- SS.setScopeRep(Qualifier);
- SS.setRange(D->getQualifierRange());
+ SS.Adopt(Qualifier, D->getQualifierRange());
DC = SemaRef.computeDeclContext(SS);
if (!DC) return 0;
} else {
if (isFriend) {
if (Qualifier) {
CXXScopeSpec SS;
- SS.setScopeRep(Qualifier);
- SS.setRange(D->getQualifierRange());
+ SS.Adopt(Qualifier, D->getQualifierRange());
DC = SemaRef.computeDeclContext(SS);
if (DC && SemaRef.RequireCompleteDeclContext(SS, DC))
D->isTypeName());
CXXScopeSpec SS;
- SS.setScopeRep(NNS);
- SS.setRange(D->getNestedNameRange());
+ SS.Adopt(NNS, D->getNestedNameRange());
if (CheckRedeclaration) {
Prev.setHideTags(false);
return 0;
CXXScopeSpec SS;
- SS.setRange(D->getTargetNestedNameRange());
- SS.setScopeRep(NNS);
+ SS.Adopt(NNS, D->getTargetNestedNameRange());
// Since NameInfo refers to a typename, it cannot be a C++ special name.
// Hence, no tranformation is required for it.
return 0;
CXXScopeSpec SS;
- SS.setRange(D->getTargetNestedNameRange());
- SS.setScopeRep(NNS);
+ SS.Adopt(NNS, D->getTargetNestedNameRange());
DeclarationNameInfo NameInfo
= SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
SourceRange NNSRange,
SourceLocation IdLoc) {
CXXScopeSpec SS;
- SS.setScopeRep(NNS);
- SS.setRange(NNSRange);
+ SS.Adopt(NNS, NNSRange);
if (NNS->isDependent()) {
// If the name is still dependent, just build a new dependent name type.
const DeclarationNameInfo &NameInfo,
TemplateArgumentListInfo *TemplateArgs) {
CXXScopeSpec SS;
- SS.setScopeRep(Qualifier);
- SS.setRange(QualifierRange);
+ SS.Adopt(Qualifier, QualifierRange);
// FIXME: loses template args.
CXXScopeSpec SS;
if (Qualifier) {
- SS.setRange(QualifierRange);
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, QualifierRange);
}
getSema().DefaultFunctionArrayConversion(Base);
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
CXXScopeSpec SS;
- SS.setRange(QualifierRange);
- SS.setScopeRep(NNS);
+ SS.Adopt(NNS, QualifierRange);
if (TemplateArgs)
return getSema().BuildQualifiedTemplateIdExpr(SS, NameInfo,
const DeclarationNameInfo &MemberNameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
CXXScopeSpec SS;
- SS.setRange(QualifierRange);
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, QualifierRange);
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
OperatorLoc, IsArrow,
LookupResult &R,
const TemplateArgumentListInfo *TemplateArgs) {
CXXScopeSpec SS;
- SS.setRange(QualifierRange);
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, QualifierRange);
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
OperatorLoc, IsArrow,
} else {
// Look for a destructor known with the given name.
CXXScopeSpec SS;
- if (Qualifier) {
- SS.setScopeRep(Qualifier);
- SS.setRange(E->getQualifierRange());
- }
+ if (Qualifier)
+ SS.Adopt(Qualifier, E->getQualifierRange());
ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
*E->getDestroyedTypeIdentifier(),
if (!Qualifier)
return ExprError();
- SS.setScopeRep(Qualifier);
- SS.setRange(Old->getQualifierRange());
+ SS.Adopt(Qualifier, Old->getQualifierRange());
}
if (Old->getNamingClass()) {
NamedDecl *FirstQualifierInScope) {
CXXScopeSpec SS;
// FIXME: The source location information is all wrong.
- SS.setRange(Range);
- SS.setScopeRep(Prefix);
+ SS.Adopt(Prefix, Range);
if (SemaRef.BuildCXXNestedNameSpecifier(0, II, /*FIXME:*/Range.getBegin(),
/*FIXME:*/Range.getEnd(),
ObjectType, false,
QualType ObjectType,
NamedDecl *FirstQualifierInScope) {
CXXScopeSpec SS;
- SS.setRange(QualifierRange);
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, QualifierRange);
UnqualifiedId Name;
Name.setIdentifier(&II, /*FIXME:*/getDerived().getBaseLocation());
Sema::TemplateTy Template;
OverloadedOperatorKind Operator,
QualType ObjectType) {
CXXScopeSpec SS;
- SS.setRange(SourceRange(getDerived().getBaseLocation()));
- SS.setScopeRep(Qualifier);
+ SS.Adopt(Qualifier, SourceRange(getDerived().getBaseLocation()));
UnqualifiedId Name;
SourceLocation SymbolLocations[3]; // FIXME: Bogus location information.
Name.setOperatorFunctionId(/*FIXME:*/getDerived().getBaseLocation(),
SourceLocation TildeLoc,
PseudoDestructorTypeStorage Destroyed) {
CXXScopeSpec SS;
- if (Qualifier) {
- SS.setRange(QualifierRange);
- SS.setScopeRep(Qualifier);
- }
+ if (Qualifier)
+ SS.Adopt(Qualifier, QualifierRange);
QualType BaseType = Base->getType();
if (Base->isTypeDependent() || Destroyed.getIdentifier() ||