diff options
author | Eric Liu <ioeric@google.com> | 2016-10-05 15:49:01 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2016-10-05 15:49:01 +0000 |
commit | 7956c4004db510e20d23a4e87d1cc1d00c14902c (patch) | |
tree | 8d4ee3b2abf7b3405c26c371d5d3fce1e54b50cb /clang/lib/Format | |
parent | 67be6ff8392a20dad2a02df12151e62d13b34a24 (diff) | |
download | bcm5719-llvm-7956c4004db510e20d23a4e87d1cc1d00c14902c.tar.gz bcm5719-llvm-7956c4004db510e20d23a4e87d1cc1d00c14902c.zip |
Make DeletedLines local variables in checkEmptyNamespace.
Summary: Patch by Sam McCall!
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D25162
llvm-svn: 283332
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/Format.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index d58e6adb99f..2a47c2f5cfb 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1041,11 +1041,12 @@ private: // Iterate through all lines and remove any empty (nested) namespaces. void checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines) { + std::set<unsigned> DeletedLines; for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { auto &Line = *AnnotatedLines[i]; if (Line.startsWith(tok::kw_namespace) || Line.startsWith(tok::kw_inline, tok::kw_namespace)) { - checkEmptyNamespace(AnnotatedLines, i, i); + checkEmptyNamespace(AnnotatedLines, i, i, DeletedLines); } } @@ -1063,7 +1064,8 @@ private: // sets \p NewLine to the last line checked. // Returns true if the current namespace is empty. bool checkEmptyNamespace(SmallVectorImpl<AnnotatedLine *> &AnnotatedLines, - unsigned CurrentLine, unsigned &NewLine) { + unsigned CurrentLine, unsigned &NewLine, + std::set<unsigned> &DeletedLines) { unsigned InitLine = CurrentLine, End = AnnotatedLines.size(); if (Style.BraceWrapping.AfterNamespace) { // If the left brace is in a new line, we should consume it first so that @@ -1083,7 +1085,8 @@ private: if (AnnotatedLines[CurrentLine]->startsWith(tok::kw_namespace) || AnnotatedLines[CurrentLine]->startsWith(tok::kw_inline, tok::kw_namespace)) { - if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine)) + if (!checkEmptyNamespace(AnnotatedLines, CurrentLine, NewLine, + DeletedLines)) return false; CurrentLine = NewLine; continue; @@ -1208,8 +1211,6 @@ private: // Tokens to be deleted. std::set<FormatToken *, FormatTokenLess> DeletedTokens; - // The line numbers of lines to be deleted. - std::set<unsigned> DeletedLines; }; struct IncludeDirective { |