From 6857c3e12c86fd0271eb46baab5b18756a94f4cb Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 1 May 2011 22:14:37 +0000 Subject: [PATCH] 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 --- include/clang/AST/Expr.h | 34 ++++++++++++++--------------- lib/AST/Expr.cpp | 8 +++---- lib/Serialization/ASTReaderStmt.cpp | 2 +- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index a1a685a2b8..980ad376fb 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -630,14 +630,6 @@ public: 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., /// the "" in "sort". struct ExplicitTemplateArgumentList { @@ -697,15 +689,15 @@ class DeclRefExpr : public Expr { /// embedded in D. DeclarationNameLoc DNLoc; - /// \brief Helper to retrieve the optional NameQualifier. - NameQualifier &getNameQualifier() { + /// \brief Helper to retrieve the optional NestedNameSpecifierLoc. + NestedNameSpecifierLoc &getInternalQualifierLoc() { assert(hasQualifier()); - return *reinterpret_cast(this + 1); + return *reinterpret_cast(this + 1); } - /// \brief Helper to retrieve the optional NameQualifier. - const NameQualifier &getNameQualifier() const { - return const_cast(this)->getNameQualifier(); + /// \brief Helper to retrieve the optional NestedNameSpecifierLoc. + const NestedNameSpecifierLoc &getInternalQualifierLoc() const { + return const_cast(this)->getInternalQualifierLoc(); } DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, @@ -777,7 +769,7 @@ public: if (!hasQualifier()) return 0; - return getNameQualifier().QualifierLoc.getNestedNameSpecifier(); + return getInternalQualifierLoc().getNestedNameSpecifier(); } /// \brief If the name was qualified, retrieves the nested-name-specifier @@ -786,7 +778,7 @@ public: if (!hasQualifier()) return NestedNameSpecifierLoc(); - return getNameQualifier().QualifierLoc; + return getInternalQualifierLoc(); } /// \brief Determines whether this declaration reference was followed by an @@ -803,7 +795,7 @@ public: return *reinterpret_cast(this + 1); return *reinterpret_cast( - &getNameQualifier() + 1); + &getInternalQualifierLoc() + 1); } /// \brief Retrieve the explicit template argument list that followed the @@ -1879,7 +1871,13 @@ public: /// class MemberExpr : public Expr { /// 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; }; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index a4365f1c44..92e66722ef 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -282,7 +282,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, D(D), Loc(NameLoc) { DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0; if (QualifierLoc) - getNameQualifier().QualifierLoc = QualifierLoc; + getInternalQualifierLoc() = QualifierLoc; DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0; if (TemplateArgs) { @@ -300,7 +300,7 @@ DeclRefExpr::DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) { DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0; if (QualifierLoc) - getNameQualifier().QualifierLoc = QualifierLoc; + getInternalQualifierLoc() = QualifierLoc; DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0; if (TemplateArgs) @@ -330,7 +330,7 @@ DeclRefExpr *DeclRefExpr::Create(ASTContext &Context, const TemplateArgumentListInfo *TemplateArgs) { std::size_t Size = sizeof(DeclRefExpr); if (QualifierLoc != 0) - Size += sizeof(NameQualifier); + Size += sizeof(NestedNameSpecifierLoc); if (TemplateArgs) Size += ExplicitTemplateArgumentList::sizeFor(*TemplateArgs); @@ -345,7 +345,7 @@ DeclRefExpr *DeclRefExpr::CreateEmpty(ASTContext &Context, unsigned NumTemplateArgs) { std::size_t Size = sizeof(DeclRefExpr); if (HasQualifier) - Size += sizeof(NameQualifier); + Size += sizeof(NestedNameSpecifierLoc); if (HasExplicitTemplateArgs) Size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs); diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp index 38b41bb55f..6b49b7ba6c 100644 --- a/lib/Serialization/ASTReaderStmt.cpp +++ b/lib/Serialization/ASTReaderStmt.cpp @@ -432,7 +432,7 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { NumTemplateArgs = Record[Idx++]; if (E->hasQualifier()) - E->getNameQualifier().QualifierLoc + E->getInternalQualifierLoc() = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); if (E->hasExplicitTemplateArgs())