[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-02 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:383 + Current.Previous->is(tok::hash) && State.FirstIndent > 0) { +// subtract 1 so indent lines up with non-preprocessor code +Spaces += State.FirstIndent; djasper wrote

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-03 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:701 + PPMaybeIncludeGuard->TokenText == FormatTok->TokenText && + PPIndentLevel > 0) { +--PPIndentLevel; djasper wrote: > I think you'll need substantially more tests her

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-03 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 109613. euhlmann added a comment. This uses `FormatToken::getPreviousNonComment` and adds a test. This also fixes a bug in token annotation that was breaking the test (by also using `getPreviousNonComment` instead of `Previous`) https://reviews.llvm.org/D

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-04 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 109785. euhlmann added a comment. Pulled out `getPreviousNonComment()` into local variable to avoid calling twice. https://reviews.llvm.org/D35847 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-04 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 109805. euhlmann added a comment. Fix bad formatting https://reviews.llvm.org/D35847 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110032. euhlmann added a comment. Ran clang-format over changes and corrected formatting https://reviews.llvm.org/D35847 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann marked 2 inline comments as done. euhlmann added a comment. I resolved the formatting issues. I apologize for not paying closer attention to formatting earlier. I don't have commit access, so if this change looks good now, could someone with access please commit? https://reviews.llvm

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: lib/Format/UnwrappedLineParser.h:238 + unsigned PPIndentLevel; + FormatToken *PPMaybeIncludeGuard; djasper wrote: > I think this should almost always be PPBranchLevel. Probably the different > case is the #else its

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-08 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added a comment. In https://reviews.llvm.org/D35955#835439, @klimek wrote: > I think if we need this info, we can just make it count down to -1 again (or, > but that's isomorphic, let it run from 0 and make sure we never index into > the data structures at 0 :) Should I do one of the

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-09 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110429. euhlmann edited the summary of this revision. euhlmann added a comment. This addresses Daniel's previous concerns. The option is now an enum, the heuristic for detecting include guards is expanded and has corresponding unit tests, and style issues a

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-10 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110602. euhlmann edited the summary of this revision. euhlmann added a comment. The patch now uses `PPBranchLevel` to track indent level. It allows `PPBranchLevel` to go back down to -1. The existing `PPBranchLevel >= 0` checks appear to prevent indexing in

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-15 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: unittests/Format/FormatTest.cpp:2405-2408 + // Defect: We currently do not deal with cases where legitimate lines may be + // outside an include guard. Examples are #pragma once and + // #pragma GCC diagnostic, or anything else that

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-16 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 111433. euhlmann marked 13 inline comments as done. euhlmann edited the summary of this revision. euhlmann added a comment. Allows comments before the include guard opens. However, if there's a single non-comment line before an include-guard-like structure t

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-17 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 111606. euhlmann marked an inline comment as done. euhlmann edited the summary of this revision. euhlmann added a comment. Eliminated redundancy in tests by fixing test::messUp which was incorrectly merging lines. Fixing the issue Mark brought up regarding

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-22 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: lib/Format/ContinuationIndenter.cpp:387 +// hash. This causes second-level indents onward to have an extra space +// after the tabs. We set the state to column 0 to avoid this misalignment. +if (Style.UseTab != FormatStyle::

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-23 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 112432. euhlmann marked 7 inline comments as done. euhlmann added a comment. - Swapped checks in ContinuationIndenter - Renamed `PPMaybeIncludeGuard` to `IfNdefCondition` and added comment - Added another bool member that tracks if include guard detection was

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-23 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:737 +for (auto& Line : Lines) { + if (Line.InPPDirective && Line.Level > 0) +--Line.Level; krasimir wrote: > Wouldn't this also indent lines continuing macro definitio

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-24 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added a comment. I'm glad this is finally in a state to land. Thanks for the helpful reviews! https://reviews.llvm.org/D35955 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-07-25 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann created this revision. euhlmann added a project: clang. Change 272124* introduced a regression in spaceRequiredBetween for left aligned pointers to decltype and typeof expressions. This fix adds logic to fix this. The test added is based on a related test in determineStarAmpUsage. Also

[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-07-27 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann created this revision. euhlmann added a project: clang. This is an implementation for bug 17362 which adds support for indenting preprocessor statements inside if/ifdef/endif. This takes previous work from fmauch and makes it into a fu