[all-commits] [llvm/llvm-project] 24b526: [Format/ObjC] Correctly handle base class with lig...
Ben Hamilton (Ben Gertzfield) via All-commits
all-commits at lists.llvm.org
Fri Oct 16 14:12:48 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 24b5266892c30e2c9cb6ea28c2631e988a5754b6
https://github.com/llvm/llvm-project/commit/24b5266892c30e2c9cb6ea28c2631e988a5754b6
Author: Ben Hamilton <benhamilton at google.com>
Date: 2020-10-16 (Fri, 16 Oct 2020)
Changed paths:
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/lib/Format/UnwrappedLineParser.h
M clang/unittests/Format/FormatTestObjC.cpp
Log Message:
-----------
[Format/ObjC] Correctly handle base class with lightweight generics and protocol
ClangFormat does not correctly handle an Objective-C interface declaration
with both lightweight generics and a protocol conformance.
This simple example:
```
@interface Foo : Bar <Baz> <Blech>
@end
```
means `Foo` extends `Bar` (a lightweight generic class whose type
parameter is `Baz`) and also conforms to the protocol `Blech`.
ClangFormat should not apply any changes to the above example, but
instead it currently formats it quite poorly:
```
@interface Foo : Bar <Baz>
<Blech>
@end
```
The bug is that `UnwrappedLineParser` assumes an open-angle bracket
after a base class name is a protocol list, but it can also be a
lightweight generic specification.
This diff fixes the bug by factoring out the logic to parse
lightweight generics so it can apply both to the declared class
as well as the base class.
Test Plan: New tests added. Ran tests with:
% ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
Confirmed tests failed before diff and passed after diff.
Reviewed By: sammccall, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D89496
More information about the All-commits
mailing list