llvm-project/clang/unittests
Ben Hamilton 1462e8440f [clang-format] Support lightweight Objective-C generics
Summary:
Previously, `clang-format` didn't understand lightweight
Objective-C generics, which have the form:

```
@interface Foo <KeyType,
                ValueTypeWithConstraint : Foo,
		AnotherValueTypeWithGenericConstraint: Bar<Baz>, ... > ...
```

The lightweight generic specifier list appears before the base
class, if present, but because it starts with < like the protocol
specifier list, `UnwrappedLineParser` was getting confused and
failed to parse interfaces with both generics and protocol lists:

```
@interface Foo <KeyType> : NSObject <NSCopying>
```

Since the parsed line would be incomplete, the format result
would be very confused (e.g., https://bugs.llvm.org/show_bug.cgi?id=24381).

This fixes the issue by explicitly parsing the ObjC lightweight
generic conformance list, so the line is fully parsed.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=24381

Test Plan: New tests added. Ran tests with:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper, jolesiak

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D45185

llvm-svn: 329298
2018-04-05 15:26:25 +00:00
..
AST [ASTImporter] Add test helper Fixture 2018-03-30 22:03:29 +00:00
ASTMatchers [ASTMatchers] Introduce a matcher for matching any given Objective-C selector 2018-03-29 00:51:12 +00:00
Analysis [CMake] Use PRIVATE in target_link_libraries for executables 2017-12-05 21:49:56 +00:00
Basic Fixes errors with FS iterators caused by https://reviews.llvm.org/D44960 2018-04-04 19:47:25 +00:00
CodeGen Unit tests for TBAA metadata generation. 2017-12-22 15:22:45 +00:00
CrossTU Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>" 2018-02-27 15:54:55 +00:00
Driver Add a unit test for Driver::getDefaultModuleCachePath(). 2018-02-12 17:59:54 +00:00
Format [clang-format] Support lightweight Objective-C generics 2018-04-05 15:26:25 +00:00
Frontend Add possibility to specify output stream for CompilerInstance 2018-03-02 12:11:40 +00:00
Lex [Lexer] Support adding working directory to relative search dir for #include shortening in HeaderSearch. 2018-01-29 13:21:23 +00:00
Rename Unittests misc. typos 2018-02-06 13:12:29 +00:00
Rewrite [CMake] Use PRIVATE in target_link_libraries for executables 2017-12-05 21:49:56 +00:00
Sema Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>" 2018-02-27 15:54:55 +00:00
StaticAnalyzer Unittests misc. typos 2018-02-06 13:12:29 +00:00
Tooling Updated a usage of createTemporaryFile that does not expect file to be created. 2018-03-19 14:20:25 +00:00
libclang [libclang] Add PrintingPolicy for pretty printing declarations 2018-01-16 10:19:56 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00