diff options
author | Daniel Jasper <djasper@google.com> | 2013-03-20 14:31:47 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-03-20 14:31:47 +0000 |
commit | 83a90e5e6525acdb8cc4778ed102cd3952559f15 (patch) | |
tree | 53bf1913a455eb106888dd29c6e996308476ad05 /lib/Format | |
parent | 64f092865c01c72ecb9e380432e241f3af55c249 (diff) |
Do not consider comments when adjusting to local indent style.
Before (when only reformatting "int b"):
int a; // comment
// comment
int b;
After:
int a; // comment
// comment
int b;
This also fixes llvm.org/PR15433.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r-- | lib/Format/Format.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 1a7dbe0936..b1005b5de6 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1324,7 +1324,8 @@ public: unsigned LevelIndent = Indent; if (static_cast<int>(LevelIndent) - Offset >= 0) LevelIndent -= Offset; - IndentForLevel[TheLine.Level] = LevelIndent; + if (TheLine.First.isNot(tok::comment)) + IndentForLevel[TheLine.Level] = LevelIndent; // Remove trailing whitespace of the previous line if it was touched. if (PreviousLineWasTouched || touchesEmptyLineBefore(TheLine)) |