[lld] r196715 - Move static member functions out of a class.

Rui Ueyama ruiu at google.com
Sat Dec 7 19:24:09 PST 2013


Author: ruiu
Date: Sat Dec  7 21:24:09 2013
New Revision: 196715

URL: http://llvm.org/viewvc/llvm-project?rev=196715&view=rev
Log:
Move static member functions out of a class.

Because compare() and its heper functions no longer have to be members of
LayoutPass class, we can remove it from the class. No functionality change.

Modified:
    lld/trunk/include/lld/Passes/LayoutPass.h
    lld/trunk/lib/Passes/LayoutPass.cpp

Modified: lld/trunk/include/lld/Passes/LayoutPass.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Passes/LayoutPass.h?rev=196715&r1=196714&r2=196715&view=diff
==============================================================================
--- lld/trunk/include/lld/Passes/LayoutPass.h (original)
+++ lld/trunk/include/lld/Passes/LayoutPass.h Sat Dec  7 21:24:09 2013
@@ -79,11 +79,6 @@ private:
 
   AtomToOrdinalT _ordinalOverrideMap;
 
-  // Compare and Sort Atoms by their ordinals
-  static bool compareAtoms(const SortKey &left, const SortKey &right);
-  static bool compareAtomsSub(const SortKey &left, const SortKey &right,
-                              std::string &reason);
-
   // Helper methods for buildFollowOnTable().
   const DefinedAtom *findAtomFollowedBy(const DefinedAtom *targetAtom);
   bool checkAllPrevAtomsZeroSize(const DefinedAtom *targetAtom);
@@ -97,9 +92,6 @@ private:
 #ifndef NDEBUG
   // Check if the follow-on graph is a correct structure. For debugging only.
   void checkFollowonChain(MutableFile::DefinedAtomRange &range);
-
-  typedef std::vector<const DefinedAtom *>::iterator DefinedAtomIter;
-  void checkTransitivity(std::vector<SortKey> &vec) const;
 #endif
 };
 

Modified: lld/trunk/lib/Passes/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/LayoutPass.cpp?rev=196715&r1=196714&r2=196715&view=diff
==============================================================================
--- lld/trunk/lib/Passes/LayoutPass.cpp (original)
+++ lld/trunk/lib/Passes/LayoutPass.cpp Sat Dec  7 21:24:09 2013
@@ -20,20 +20,20 @@
 
 using namespace lld;
 
-#ifndef NDEBUG
-namespace {
+static bool compareAtoms(const LayoutPass::SortKey &,
+                         const LayoutPass::SortKey &);
+
 // Return "reason (leftval, rightval)"
-std::string formatReason(StringRef reason, int leftVal, int rightVal) {
+static std::string formatReason(StringRef reason, int leftVal, int rightVal) {
   Twine msg =
       Twine(reason) + " (" + Twine(leftVal) + ", " + Twine(rightVal) + ")";
   return msg.str();
 }
-} // end anonymous namespace
 
 // Less-than relationship of two atoms must be transitive, which is, if a < b
 // and b < c, a < c must be true. This function checks the transitivity by
 // checking the sort results.
-void LayoutPass::checkTransitivity(std::vector<SortKey> &vec) const {
+static void checkTransitivity(std::vector<LayoutPass::SortKey> &vec) {
   for (auto i = vec.begin(), e = vec.end(); (i + 1) != e; ++i) {
     for (auto j = i + 1; j != e; ++j) {
       assert(compareAtoms(*i, *j));
@@ -42,8 +42,6 @@ void LayoutPass::checkTransitivity(std::
   }
 }
 
-#endif // NDEBUG
-
 /// The function compares atoms by sorting atoms in the following order
 /// a) Sorts atoms by Section position preference
 /// b) Sorts atoms by their ordinal overrides
@@ -52,8 +50,9 @@ void LayoutPass::checkTransitivity(std::
 /// d) Sorts atoms by their content
 /// e) Sorts atoms on how they appear using File Ordinality
 /// f) Sorts atoms on how they appear within the File
-bool LayoutPass::compareAtomsSub(const SortKey &lc, const SortKey &rc,
-                                 std::string &reason) {
+static bool compareAtomsSub(const LayoutPass::SortKey &lc,
+                            const LayoutPass::SortKey &rc,
+                            std::string &reason) {
   const DefinedAtom *left = lc._atom;
   const DefinedAtom *right = rc._atom;
   if (left == right) {
@@ -129,7 +128,8 @@ bool LayoutPass::compareAtomsSub(const S
   llvm_unreachable("Atoms with Same Ordinal!");
 }
 
-bool LayoutPass::compareAtoms(const SortKey &lc, const SortKey &rc) {
+static bool compareAtoms(const LayoutPass::SortKey &lc,
+                         const LayoutPass::SortKey &rc) {
   std::string reason;
   bool result = compareAtomsSub(lc, rc, reason);
   DEBUG({





More information about the llvm-commits mailing list