Remove the NameQualifier struct, which was just a wrapper around

NestedNameSpecifierLoc. It predates when we had such an object.

Reference the NNSLoc directly in DREs, and embed it directly into the
MemberNameQualifier struct.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2011-05-01 22:14:37 +00:00
Родитель 7e740bd367
Коммит 6857c3e12c
3 изменённых файлов: 21 добавлений и 23 удалений

Просмотреть файл

@ -630,14 +630,6 @@ public:
static bool classof(const OpaqueValueExpr *) { return true; } static bool classof(const OpaqueValueExpr *) { return true; }
}; };
/// \brief Represents the qualifier that may precede a C++ name, e.g., the
/// "std::" in "std::sort".
struct NameQualifier {
/// \brief The nested-name-specifier that qualifies the name, including
/// source-location information.
NestedNameSpecifierLoc QualifierLoc;
};
/// \brief Represents an explicit template argument list in C++, e.g., /// \brief Represents an explicit template argument list in C++, e.g.,
/// the "<int>" in "sort<int>". /// the "<int>" in "sort<int>".
struct ExplicitTemplateArgumentList { struct ExplicitTemplateArgumentList {
@ -697,15 +689,15 @@ class DeclRefExpr : public Expr {
/// embedded in D. /// embedded in D.
DeclarationNameLoc DNLoc; DeclarationNameLoc DNLoc;
/// \brief Helper to retrieve the optional NameQualifier. /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
NameQualifier &getNameQualifier() { NestedNameSpecifierLoc &getInternalQualifierLoc() {
assert(hasQualifier()); assert(hasQualifier());
return *reinterpret_cast<NameQualifier *>(this + 1); return *reinterpret_cast<NestedNameSpecifierLoc *>(this + 1);
} }
/// \brief Helper to retrieve the optional NameQualifier. /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
const NameQualifier &getNameQualifier() const { const NestedNameSpecifierLoc &getInternalQualifierLoc() const {
return const_cast<DeclRefExpr *>(this)->getNameQualifier(); return const_cast<DeclRefExpr *>(this)->getInternalQualifierLoc();
} }
DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
@ -777,7 +769,7 @@ public:
if (!hasQualifier()) if (!hasQualifier())
return 0; return 0;
return getNameQualifier().QualifierLoc.getNestedNameSpecifier(); return getInternalQualifierLoc().getNestedNameSpecifier();
} }
/// \brief If the name was qualified, retrieves the nested-name-specifier /// \brief If the name was qualified, retrieves the nested-name-specifier
@ -786,7 +778,7 @@ public:
if (!hasQualifier()) if (!hasQualifier())
return NestedNameSpecifierLoc(); return NestedNameSpecifierLoc();
return getNameQualifier().QualifierLoc; return getInternalQualifierLoc();
} }
/// \brief Determines whether this declaration reference was followed by an /// \brief Determines whether this declaration reference was followed by an
@ -803,7 +795,7 @@ public:
return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
return *reinterpret_cast<ExplicitTemplateArgumentList *>( return *reinterpret_cast<ExplicitTemplateArgumentList *>(
&getNameQualifier() + 1); &getInternalQualifierLoc() + 1);
} }
/// \brief Retrieve the explicit template argument list that followed the /// \brief Retrieve the explicit template argument list that followed the
@ -1879,7 +1871,13 @@ public:
/// ///
class MemberExpr : public Expr { class MemberExpr : public Expr {
/// Extra data stored in some member expressions. /// Extra data stored in some member expressions.
struct MemberNameQualifier : public NameQualifier { struct MemberNameQualifier {
/// \brief The nested-name-specifier that qualifies the name, including
/// source-location information.
NestedNameSpecifierLoc QualifierLoc;
/// \brief The DeclAccessPair through which the MemberDecl was found due to
/// name qualifiers.
DeclAccessPair FoundDecl; DeclAccessPair FoundDecl;
}; };

Просмотреть файл

@ -282,7 +282,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
D(D), Loc(NameLoc) { D(D), Loc(NameLoc) {
DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0; DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
if (QualifierLoc) if (QualifierLoc)
getNameQualifier().QualifierLoc = QualifierLoc; getInternalQualifierLoc() = QualifierLoc;
DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0; DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
if (TemplateArgs) { if (TemplateArgs) {
@ -300,7 +300,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) { D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) {
DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0; DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
if (QualifierLoc) if (QualifierLoc)
getNameQualifier().QualifierLoc = QualifierLoc; getInternalQualifierLoc() = QualifierLoc;
DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0; DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
if (TemplateArgs) if (TemplateArgs)
@ -330,7 +330,7 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context,
const TemplateArgumentListInfo *TemplateArgs) { const TemplateArgumentListInfo *TemplateArgs) {
std::size_t Size = sizeof(DeclRefExpr); std::size_t Size = sizeof(DeclRefExpr);
if (QualifierLoc != 0) if (QualifierLoc != 0)
Size += sizeof(NameQualifier); Size += sizeof(NestedNameSpecifierLoc);
if (TemplateArgs) if (TemplateArgs)
Size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs); Size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs);
@ -345,7 +345,7 @@ DeclRefExpr *DeclRefExpr::CreateEmpty(ASTContext &Context,
unsigned NumTemplateArgs) { unsigned NumTemplateArgs) {
std::size_t Size = sizeof(DeclRefExpr); std::size_t Size = sizeof(DeclRefExpr);
if (HasQualifier) if (HasQualifier)
Size += sizeof(NameQualifier); Size += sizeof(NestedNameSpecifierLoc);
if (HasExplicitTemplateArgs) if (HasExplicitTemplateArgs)
Size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); Size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs);

Просмотреть файл

@ -432,7 +432,7 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
NumTemplateArgs = Record[Idx++]; NumTemplateArgs = Record[Idx++];
if (E->hasQualifier()) if (E->hasQualifier())
E->getNameQualifier().QualifierLoc E->getInternalQualifierLoc()
= Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
if (E->hasExplicitTemplateArgs()) if (E->hasExplicitTemplateArgs())