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())