diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-08-23 07:18:36 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-08-23 07:18:36 +0000 |
commit | 4a9c260751815ea03026a066f8c3296049b6c544 (patch) | |
tree | 9981ee4f61a376a439ad1a561249989e9f46084e /clang/lib/Format | |
parent | d5d559421f41684b69ddba76938136426f7f29a2 (diff) | |
download | bcm5719-llvm-4a9c260751815ea03026a066f8c3296049b6c544.tar.gz bcm5719-llvm-4a9c260751815ea03026a066f8c3296049b6c544.zip |
[clang-format] Align trailing comments if ColumnLimit is 0
Summary:
ColumnLimit = 0 means no limit, so comment should always be aligned if requested. This was broken with
https://llvm.org/svn/llvm-project/cfe/trunk@304687
introduced via
https://reviews.llvm.org/D33830
and is included in 5.0.0-rc2. This commit fixes it and adds a unittest for this property.
Should go into clang-5.0 IMHO.
Contributed by @pboettch!
Reviewers: djasper, krasimir
Reviewed By: djasper, krasimir
Subscribers: hans, klimek
Differential Revision: https://reviews.llvm.org/D36967
llvm-svn: 311532
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/WhitespaceManager.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index e41a0767f59..f7d08f871b6 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -472,9 +472,14 @@ void WhitespaceManager::alignTrailingComments() { continue; unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn; - unsigned ChangeMaxColumn = Style.ColumnLimit >= Changes[i].TokenLength - ? Style.ColumnLimit - Changes[i].TokenLength - : ChangeMinColumn; + unsigned ChangeMaxColumn; + + if (Style.ColumnLimit == 0) + ChangeMaxColumn = UINT_MAX; + else if (Style.ColumnLimit >= Changes[i].TokenLength) + ChangeMaxColumn = Style.ColumnLimit - Changes[i].TokenLength; + else + ChangeMaxColumn = ChangeMinColumn; // If we don't create a replacement for this change, we have to consider // it to be immovable. |