diff options
author | Manuel Klimek <klimek@google.com> | 2013-02-13 10:54:19 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-02-13 10:54:19 +0000 |
commit | 62a48fbb891267873a71e1147d39200363a49276 (patch) | |
tree | 188c2bfe8d2b3c8192e45253dcffae1e4bc73d9b /lib/Format/Format.cpp | |
parent | 32a2fd7631026f2fe248381546c5e6149f4f95ee (diff) |
Pull search state out as class members.
Fix some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 35389d140d..d66271ce61 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -233,7 +233,7 @@ public: WhitespaceManager &Whitespaces, bool StructuralError) : Style(Style), SourceMgr(SourceMgr), Line(Line), FirstIndent(FirstIndent), RootToken(RootToken), - Whitespaces(Whitespaces) { + Whitespaces(Whitespaces), Count(0) { } /// \brief Formats an \c UnwrappedLine. @@ -668,13 +668,6 @@ private: /// find the shortest path (the one with lowest penalty) from \p InitialState /// to a state where all tokens are placed. unsigned analyzeSolutionSpace(LineState &InitialState) { - llvm::SpecificBumpPtrAllocator<StateNode> Allocator; - - // Increasing count of \c StateNode items we have created. This is used - // to create a deterministic order independent of the container. - unsigned Count = 0; - QueueType Queue; - std::set<LineState> Seen; // Insert start element into queue. @@ -697,10 +690,8 @@ private: // State already examined with lower penalty. continue; - addNextStateToQueue(Allocator, Queue, Count, Penalty, Node, - /*NewLine=*/ false); - addNextStateToQueue(Allocator, Queue, Count, Penalty, Node, - /*NewLine=*/ true); + addNextStateToQueue(Penalty, Node, /*NewLine=*/ false); + addNextStateToQueue(Penalty, Node, /*NewLine=*/ true); } if (Queue.empty()) @@ -734,13 +725,12 @@ private: addTokenToState(Current->NewLine, false, State); } - /// \brief Add the following state to the analysis queue \p Queue. + /// \brief Add the following state to the analysis queue \c Queue. /// - /// Assume the current state is \p OldState and has been reached with a + /// Assume the current state is \p PreviousNode and has been reached with a /// penalty of \p Penalty. Insert a line break if \p NewLine is \c true. - void addNextStateToQueue(llvm::SpecificBumpPtrAllocator<StateNode> &Allocator, - QueueType &Queue, unsigned &Count, unsigned Penalty, - StateNode *PreviousNode, bool NewLine) { + void addNextStateToQueue(unsigned Penalty, StateNode *PreviousNode, + bool NewLine) { if (NewLine && !canBreak(PreviousNode->State)) return; if (!NewLine && mustBreak(PreviousNode->State)) @@ -807,6 +797,12 @@ private: const unsigned FirstIndent; const AnnotatedToken &RootToken; WhitespaceManager &Whitespaces; + + llvm::SpecificBumpPtrAllocator<StateNode> Allocator; + QueueType Queue; + // Increasing count of \c StateNode items we have created. This is used + // to create a deterministic order independent of the container. + unsigned Count; }; class LexerBasedFormatTokenSource : public FormatTokenSource { |