llvm-project/clang/lib/Format
Ben Hamilton 788a2227b7 [clang-format] Improve detection of Objective-C block types
Summary:
Previously, clang-format would detect the following as an
Objective-C block type:

  FOO(^);

when it actually must be a C or C++ macro dealing with an XOR
statement or an XOR operator overload.

According to the Clang Block Language Spec:

https://clang.llvm.org/docs/BlockLanguageSpec.html

block types are of the form:

  int (^)(char, float)

and block variables of block type are of the form:

  void (^blockReturningVoidWithVoidArgument)(void);
  int (^blockReturningIntWithIntAndCharArguments)(int, char);
  void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int);

This tightens up the detection so we don't unnecessarily detect
C macros which pass in the XOR operator.

Depends On D43904

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

Reviewers: krasimir, jolesiak, djasper

Reviewed By: djasper

Subscribers: djasper, cfe-commits, klimek

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

llvm-svn: 327285
2018-03-12 15:42:40 +00:00
..
AffectedRangeManager.cpp Added Fixer implementation and fix() interface in clang-format for removing redundant code. 2016-04-25 15:09:22 +00:00
AffectedRangeManager.h removed redundant '#' 2016-04-28 07:52:06 +00:00
BreakableToken.cpp [clang-format] Ignore UnbreakableTailLength sometimes during breaking 2018-01-23 11:26:19 +00:00
BreakableToken.h [clang-format] Ignore UnbreakableTailLength sometimes during breaking 2018-01-23 11:26:19 +00:00
CMakeLists.txt [clang-format] Support sorting using declarations 2017-06-21 12:03:12 +00:00
ContinuationIndenter.cpp [clang-format] Don't detect C++11 attribute specifiers as ObjC 2018-03-12 15:42:38 +00:00
ContinuationIndenter.h [clang-format] Do not break Objective-C string literals inside array literals 2018-02-08 16:07:25 +00:00
Encoding.h [Format] Remove dead code. 2016-12-19 21:10:50 +00:00
Format.cpp clang-format: Properly handle implicit string concatenation in text protos 2018-03-12 10:32:18 +00:00
FormatInternal.h FormatInternal.h: Add missing includes. 2017-11-21 01:09:17 +00:00
FormatToken.cpp clang-format clang-format. 2017-09-20 09:51:03 +00:00
FormatToken.h [clang-format] Don't detect C++11 attribute specifiers as ObjC 2018-03-12 15:42:38 +00:00
FormatTokenLexer.cpp clang-format: Properly handle implicit string concatenation in text protos 2018-03-12 10:32:18 +00:00
FormatTokenLexer.h [clang-format] Support python-style comments in text protos 2017-11-10 12:50:09 +00:00
NamespaceEndCommentsFixer.cpp [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
NamespaceEndCommentsFixer.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
SortJavaScriptImports.cpp [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
SortJavaScriptImports.h clang-format: [JS] sort ES6 imports. 2016-05-20 11:24:24 +00:00
TokenAnalyzer.cpp [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
TokenAnalyzer.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
TokenAnnotator.cpp [clang-format] Improve detection of Objective-C block types 2018-03-12 15:42:40 +00:00
TokenAnnotator.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
UnwrappedLineFormatter.cpp clang-format: use AfterControlStatement to format ObjC control blocks 2018-02-27 13:48:27 +00:00
UnwrappedLineFormatter.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
UnwrappedLineParser.cpp clang-format: use AfterControlStatement to format ObjC control blocks 2018-02-27 13:48:27 +00:00
UnwrappedLineParser.h [clang-format] Re-land: Fixup #include guard indents after parseFile() 2018-02-05 15:59:00 +00:00
UsingDeclarationsSorter.cpp [clang-format] Deduplicate using declarations 2017-11-24 18:00:01 +00:00
UsingDeclarationsSorter.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
WhitespaceManager.cpp [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00
WhitespaceManager.h [clang-format] Format raw string literals 2017-10-30 14:01:50 +00:00