diff options
| author | Daniel Jasper <djasper@google.com> | 2013-05-08 10:00:18 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-05-08 10:00:18 +0000 |
| commit | 0f0234e16ece8610248ce0a7113f7bb75853ed58 (patch) | |
| tree | d51488a4e7b1a08c618711d00c1ab31488d6e0b8 /clang | |
| parent | 1fb61c6eed3f375896c66ea5554a917ae6cb73fe (diff) | |
| download | bcm5719-llvm-0f0234e16ece8610248ce0a7113f7bb75853ed58.tar.gz bcm5719-llvm-0f0234e16ece8610248ce0a7113f7bb75853ed58.zip | |
Change indentation of multi-line nested name specifiers.
Before:
aaaaaaaa::
aaaaaaaa::
aaaaaaaa();
After:
aaaaaaaa::
aaaaaaaa::
aaaaaaaa();
The reason for the change is that:
a) we are not sure which is better
b) it is a really rare edge case
c) it simplifies the code
d) it currently causes problems with memoization
llvm-svn: 181421
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 15 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 5 insertions, 14 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 4c7c405e81e..814017a5127 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -338,10 +338,6 @@ private: return ColonPos < Other.ColonPos; if (StartOfFunctionCall != Other.StartOfFunctionCall) return StartOfFunctionCall < Other.StartOfFunctionCall; - if (NestedNameSpecifierContinuation != - Other.NestedNameSpecifierContinuation) - return NestedNameSpecifierContinuation < - Other.NestedNameSpecifierContinuation; if (CallContinuation != Other.CallContinuation) return CallContinuation < Other.CallContinuation; if (VariablePos != Other.VariablePos) @@ -432,13 +428,6 @@ private: } else if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess != 0) { State.Column = State.Stack.back().FirstLessLess; - } else if (Previous.is(tok::coloncolon)) { - if (State.Stack.back().NestedNameSpecifierContinuation == 0) { - State.Column = ContinuationIndent; - State.Stack.back().NestedNameSpecifierContinuation = State.Column; - } else { - State.Column = State.Stack.back().NestedNameSpecifierContinuation; - } } else if (Current.isOneOf(tok::period, tok::arrow)) { if (State.Stack.back().CallContinuation == 0) { State.Column = ContinuationIndent; @@ -464,7 +453,8 @@ private: State.Stack.back().ColonPos = State.Column + Current.FormatTok.TokenLength; } - } else if (Current.Type == TT_StartOfName || Previous.is(tok::equal) || + } else if (Current.Type == TT_StartOfName || + Previous.isOneOf(tok::coloncolon, tok::equal) || Previous.Type == TT_ObjCMethodExpr) { State.Column = ContinuationIndent; } else { @@ -854,6 +844,7 @@ private: // Reconstruct the solution. reconstructPath(InitialState, Queue.top().second); + DEBUG(llvm::errs() << "Total number of analyzed states: " << Count << "\n"); DEBUG(llvm::errs() << "---\n"); // Return the column after the last token of the solution. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 92435fe0fe4..2a11f80eaa5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2338,11 +2338,11 @@ TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa());"); - // FIXME: Should we have an extra indent after the second break? + // FIXME: Should we have the extra indent after the second break? verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa::\n" - " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); // FIXME: Look into whether we should indent 4 from the start or 4 from // "bbbbb..." here instead of what we are doing now. |

