Go to file
Ben Hamilton 707e68fb21 [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name
Summary:
Please take a close look at this CL. I haven't touched much of
`UnwrappedLineParser` before, so I may have gotten things wrong.

Previously, clang-format would incorrectly format the following:

```
@implementation Foo

- (Class)class {
}

- (void)foo {
}

@end
```

as:

```
@implementation Foo

- (Class)class {
}

    - (void)foo {
}

@end
```

The problem is whenever `UnwrappedLineParser::parseStructuralElement()`
sees any of the keywords `class`, `struct`, or `enum`, it calls
`parseRecord()` to parse them as a C/C++ record.

This causes subsequent lines to be parsed incorrectly, which
causes them to be indented incorrectly.

In Objective-C/Objective-C++, these keywords are valid selector
components.

This diff fixes the issue by explicitly handling `+` and `-` lines
inside `@implementation` / `@interface` / `@protocol` blocks
and parsing them as Objective-C methods.

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

Reviewers: jolesiak, klimek

Reviewed By: jolesiak, klimek

Subscribers: klimek, cfe-commits, Wizard

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

llvm-svn: 333553
2018-05-30 15:21:38 +00:00
clang [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name 2018-05-30 15:21:38 +00:00
clang-tools-extra [clangd] Add forgotten include guard to TestFS.h. NFC 2018-05-30 14:21:31 +00:00
compiler-rt [asan, myriad] Simplify main thread handling 2018-05-30 04:57:29 +00:00
debuginfo-tests [Darwin] Specify DWARF 2/4 when running apple accelerator tests. 2018-02-26 20:56:45 +00:00
libclc Add initial support for half precision builtins 2018-05-17 22:55:30 +00:00
libcxx Update ABI lists after change in r333467. 2018-05-29 23:52:14 +00:00
libcxxabi private_typeinfo: limit is_dst_type_derived_from_static_type optimization 2018-05-18 20:51:38 +00:00
libunwind [OR1K] Add the EPCR special-purpose register to register state. 2018-05-16 19:09:48 +00:00
lld [ELF][MIPS] Update comments in test cases. NFC 2018-05-30 08:48:53 +00:00
lldb [LLDB] Re-apply r303907 that's reverted by mistake 2018-05-30 14:54:22 +00:00
llgo irgen: Create functions instead of global variables for builtin hash and equal algorithms. 2017-06-04 22:11:28 +00:00
llvm [AliasSet] Teach the alias set how to handle atomic memcpy/memmove/memset 2018-05-30 14:43:39 +00:00
openmp [OMPT] Rename ompt_wait_id to omp_wait_id 2018-05-28 08:16:08 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly [ForwardOpTree] Use less computationally expensive method to compute def-to-target map. NFCI. 2018-05-29 15:19:17 +00:00
README.md Add an svn project to contain the files that appear at the root of the 2017-10-19 21:09:49 +00:00

README.md

Low Level Virtual Machine (LLVM)

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.