r210672 - Sink SpecifierInfo into the only class that uses it.

Kaelyn Takata rikka at google.com
Wed Jun 11 11:07:08 PDT 2014


Author: rikka
Date: Wed Jun 11 13:07:08 2014
New Revision: 210672

URL: http://llvm.org/viewvc/llvm-project?rev=210672&view=rev
Log:
Sink SpecifierInfo into the only class that uses it.

SpecifierInfo is not used outside of NamespaceSpecifierSet except
indirectly through NamespaceSpecifierSet's iterator, so clean up the
code a bit by moving SpecifierInfo into NamespaceSpecifierSet. Also drop
SpecifierInfo's trivial yet verbose constructor since brace
initiialization is sufficient in the only two places the constructor was
being explicitly called.

No functionality changed.

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=210672&r1=210671&r2=210672&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jun 11 13:07:08 2014
@@ -3374,20 +3374,16 @@ public:
   TypoCorrection getNextCorrection();
 
 private:
-  class SpecifierInfo {
-   public:
-    DeclContext* DeclCtx;
-    NestedNameSpecifier* NameSpecifier;
-    unsigned EditDistance;
-
-    SpecifierInfo(DeclContext *Ctx, NestedNameSpecifier *NNS, unsigned ED)
-        : DeclCtx(Ctx), NameSpecifier(NNS), EditDistance(ED) {}
-  };
+  class NamespaceSpecifierSet {
+    struct SpecifierInfo {
+      DeclContext* DeclCtx;
+      NestedNameSpecifier* NameSpecifier;
+      unsigned EditDistance;
+    };
 
-  typedef SmallVector<DeclContext*, 4> DeclContextList;
-  typedef SmallVector<SpecifierInfo, 16> SpecifierInfoList;
+    typedef SmallVector<DeclContext*, 4> DeclContextList;
+    typedef SmallVector<SpecifierInfo, 16> SpecifierInfoList;
 
-  class NamespaceSpecifierSet {
     ASTContext &Context;
     DeclContextList CurContextChain;
     std::string CurNameSpecifier;
@@ -3433,8 +3429,8 @@ private:
       // Add the global context as a NestedNameSpecifier
       Distances.insert(1);
       DistanceMap[1].push_back(
-          SpecifierInfo(cast<DeclContext>(Context.getTranslationUnitDecl()),
-                        NestedNameSpecifier::GlobalSpecifier(Context), 1));
+          {cast<DeclContext>(Context.getTranslationUnitDecl()),
+           NestedNameSpecifier::GlobalSpecifier(Context), 1});
     }
 
     /// \brief Add the DeclContext (a namespace or record) to the set, computing
@@ -3747,9 +3743,8 @@ void TypoCorrectionConsumer::performQual
   QualifiedResults.clear();
 }
 
-TypoCorrectionConsumer::DeclContextList
-TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
-    DeclContext *Start) {
+auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
+    DeclContext *Start) -> DeclContextList {
   assert(Start && "Building a context chain from a null context");
   DeclContextList Chain;
   for (DeclContext *DC = Start->getPrimaryContext(); DC != nullptr;
@@ -3862,7 +3857,7 @@ void TypoCorrectionConsumer::NamespaceSp
 
   isSorted = false;
   Distances.insert(NumSpecifiers);
-  DistanceMap[NumSpecifiers].push_back(SpecifierInfo(Ctx, NNS, NumSpecifiers));
+  DistanceMap[NumSpecifiers].push_back({Ctx, NNS, NumSpecifiers});
 }
 
 /// \brief Perform name lookup for a possible result for typo correction.





More information about the cfe-commits mailing list