summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-14 12:31:14 +0000
committerDaniel Jasper <djasper@google.com>2014-11-14 12:31:14 +0000
commit119ff533e4c37a85782c6ffe121e391d063218bd (patch)
treef80bfd1bc36b2bdf5b9b09e28ecbfd16678ec48b /clang/lib/Format/TokenAnnotator.cpp
parentcee13a2712c3ac3134791f951157011411e798d8 (diff)
downloadbcm5719-llvm-119ff533e4c37a85782c6ffe121e391d063218bd.tar.gz
bcm5719-llvm-119ff533e4c37a85782c6ffe121e391d063218bd.zip
clang-format: Improve indentation of comments in expressions.
Before: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; After: int i = (a) // comment + b; return aaaa == bbbb // comment ? aaaa : bbbb; llvm-svn: 221985
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 48ce19e1323..cb945c6161b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1186,9 +1186,12 @@ private:
if (Precedence > prec::Unknown)
Start->StartsBinaryExpression = true;
if (Current) {
- ++Current->Previous->FakeRParens;
+ FormatToken *Previous = Current->Previous;
+ if (Previous->is(tok::comment) && Previous->Previous)
+ Previous = Previous->Previous;
+ ++Previous->FakeRParens;
if (Precedence > prec::Unknown)
- Current->Previous->EndsBinaryExpression = true;
+ Previous->EndsBinaryExpression = true;
}
}
OpenPOWER on IntegriCloud