diff options
author | Daniel Jasper <djasper@google.com> | 2013-03-13 15:53:12 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-03-13 15:53:12 +0000 |
commit | 6050a1e53aa3cd3b21d65d440413af5a5ac1d466 (patch) | |
tree | 57c944eeb74198b6b720f9ddc4cb3da7897f1210 /lib/Format/Format.cpp | |
parent | 8d0d19aa33751d89390e6a2bb2c2b19def287abe (diff) |
Fix comment indentation before labels.
Before:
switch (x) {
// if 1, do f()
case 1:
f();
}
After:
switch (x) {
// if 1, do f()
case 1:
f();
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176953 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 67ca928a1a..63edc6e23e 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1135,6 +1135,13 @@ public: deriveLocalStyle(); for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { Annotator.calculateFormattingInformation(AnnotatedLines[i]); + + // Adapt level to the next line if this is a comment. + // FIXME: Can/should this be done in the UnwrappedLineParser? + if (i + 1 != e && AnnotatedLines[i].First.is(tok::comment) && + AnnotatedLines[i].First.Children.empty() && + AnnotatedLines[i + 1].First.isNot(tok::r_brace)) + AnnotatedLines[i].Level = AnnotatedLines[i + 1].Level; } std::vector<int> IndentForLevel; bool PreviousLineWasTouched = false; |