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 | af491072eeda33328d95614c6efab5e3ff50086f (patch) | |
tree | 69cb0f00af6667dd2942abcf717695f523ae8763 /clang/lib/Format/Format.cpp | |
parent | 2ef908e4e28ae865e4049c6a325b9e19f29b7227 (diff) | |
download | bcm5719-llvm-af491072eeda33328d95614c6efab5e3ff50086f.tar.gz bcm5719-llvm-af491072eeda33328d95614c6efab5e3ff50086f.zip |
Pull search state out as class members.
Fix some comments.
llvm-svn: 175052
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 35389d140d1..d66271ce61d 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/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 { |