]> granicus.if.org Git - clang/commitdiff
Sink SpecifierInfo into the only class that uses it.
authorKaelyn Takata <rikka@google.com>
Wed, 11 Jun 2014 18:07:08 +0000 (18:07 +0000)
committerKaelyn Takata <rikka@google.com>
Wed, 11 Jun 2014 18:07:08 +0000 (18:07 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210672 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLookup.cpp

index 47e5f6f66cd09c071f23675702e3c3f78ade3849..d0bd01e6da8a4c5bf132eac6e0cf060f2a2aa416 100644 (file)
@@ -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::performQualifiedLookups() {
   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::NamespaceSpecifierSet::addNameSpecifier(
 
   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.