summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-20 14:31:47 +0000
committerDaniel Jasper <djasper@google.com>2013-03-20 14:31:47 +0000
commit66dc2ec30b11a111ec9b95b3e0739b7b7b84857a (patch)
tree19ef4206d7f0960946c1b47c7ee482fe24a867de /clang/lib/Format/Format.cpp
parent9f94dff7a687432dafcb0fda94fbea018caa6cec (diff)
downloadbcm5719-llvm-66dc2ec30b11a111ec9b95b3e0739b7b7b84857a.tar.gz
bcm5719-llvm-66dc2ec30b11a111ec9b95b3e0739b7b7b84857a.zip
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. llvm-svn: 177524
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1a7dbe09365..b1005b5de6c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/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))
OpenPOWER on IntegriCloud