From 66dc2ec30b11a111ec9b95b3e0739b7b7b84857a Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 20 Mar 2013 14:31:47 +0000 Subject: 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 --- clang/lib/Format/Format.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/Format.cpp') 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(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)) -- cgit v1.2.3