[cfe-commits] r130668 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Serialization/ASTReaderStmt.cpp

Chandler Carruth chandlerc at gmail.com
Sun May 1 15:14:37 PDT 2011


Author: chandlerc
Date: Sun May  1 17:14:37 2011
New Revision: 130668

URL: http://llvm.org/viewvc/llvm-project?rev=130668&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=130668&r1=130667&r2=130668&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun May  1 17:14:37 2011
@@ -630,14 +630,6 @@
   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 "<int>" in "sort<int>".
 struct ExplicitTemplateArgumentList {
@@ -697,15 +689,15 @@
   /// 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<NameQualifier *>(this + 1);
+    return *reinterpret_cast<NestedNameSpecifierLoc *>(this + 1);
   }
 
-  /// \brief Helper to retrieve the optional NameQualifier.
-  const NameQualifier &getNameQualifier() const {
-    return const_cast<DeclRefExpr *>(this)->getNameQualifier();
+  /// \brief Helper to retrieve the optional NestedNameSpecifierLoc.
+  const NestedNameSpecifierLoc &getInternalQualifierLoc() const {
+    return const_cast<DeclRefExpr *>(this)->getInternalQualifierLoc();
   }
 
   DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
@@ -777,7 +769,7 @@
     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 @@
     if (!hasQualifier())
       return NestedNameSpecifierLoc();
 
-    return getNameQualifier().QualifierLoc;
+    return getInternalQualifierLoc();
   }
 
   /// \brief Determines whether this declaration reference was followed by an
@@ -803,7 +795,7 @@
       return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
 
     return *reinterpret_cast<ExplicitTemplateArgumentList *>(
-      &getNameQualifier() + 1);
+      &getInternalQualifierLoc() + 1);
   }
 
   /// \brief Retrieve the explicit template argument list that followed the
@@ -1879,7 +1871,13 @@
 ///
 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;
   };
 

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=130668&r1=130667&r2=130668&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun May  1 17:14:37 2011
@@ -282,7 +282,7 @@
     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 @@
     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 @@
                                  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 @@
                                       unsigned NumTemplateArgs) {
   std::size_t Size = sizeof(DeclRefExpr);
   if (HasQualifier)
-    Size += sizeof(NameQualifier);
+    Size += sizeof(NestedNameSpecifierLoc);
   
   if (HasExplicitTemplateArgs)
     Size += ExplicitTemplateArgumentList::sizeFor(NumTemplateArgs);

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=130668&r1=130667&r2=130668&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Sun May  1 17:14:37 2011
@@ -432,7 +432,7 @@
     NumTemplateArgs = Record[Idx++];
 
   if (E->hasQualifier())
-    E->getNameQualifier().QualifierLoc
+    E->getInternalQualifierLoc()
       = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
 
   if (E->hasExplicitTemplateArgs())





More information about the cfe-commits mailing list