llvm-project/clang/lib
Francois Ferrand 5f07f443be clang-format: Fix C99 designated initializers corner cases
Summary:
This fixes the missing space before the designated initializer when `Cpp11BracedListStyle=false` :

  const struct A a = { .a = 1, .b = 2 };
                      ^

Also, wrapping between opening brace and designated array initializers used to have an excessive penalty (like breaking between an expression and the subscript operator), leading to unexpected wrapping:

  const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa =
      {[1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
       [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

instead of:

  const struct Aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa = {
      [1] = aaaaaaaaaaaaaaaaaaaaaaaaaaa,
      [2] = bbbbbbbbbbbbbbbbbbbbbbbbbbb};

Finally, designated array initializers are not binpacked, just like designated member initializers.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, krasimir, klimek

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

llvm-svn: 305696
2017-06-19 14:41:21 +00:00
..
ARCMigrate Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:19 +00:00
AST Call setMustBuildLookupTable on TagDecls in ExternalASTMerger 2017-06-17 00:12:38 +00:00
ASTMatchers [ASTMatchers] Fix use after free. 2017-06-09 17:55:42 +00:00
Analysis [analyzer] Teach CloneDetection about Qt Meta-Object Compiler 2017-06-19 01:55:50 +00:00
Basic Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc" 2017-06-19 12:41:22 +00:00
CodeGen CodeGen: make the type match the comment for a libcall 2017-06-17 17:30:31 +00:00
Driver Add missing OS check to r305678 2017-06-19 11:25:37 +00:00
Edit [clang] Fix format specifiers fixits 2017-06-08 21:44:45 +00:00
Format clang-format: Fix C99 designated initializers corner cases 2017-06-19 14:41:21 +00:00
Frontend Revert "[NFC] Refactor DiagnosticRenderer to use FullSourceLoc" 2017-06-19 12:41:22 +00:00
FrontendTool Add -frewrite-imports flag. 2017-06-09 21:24:02 +00:00
Headers [DOXYGEN] Corrected several typos and incorrect parameters description that Sony's techinical writer found during review. 2017-06-06 22:58:01 +00:00
Index [index] Record C++17 global binding declarations 2017-06-15 21:19:01 +00:00
Lex [PR33394] Avoid lexing editor placeholders when Clang is used only 2017-06-16 20:13:39 +00:00
Parse PR33318: Add missing full-expression checking to static_assert expression. 2017-06-06 01:34:24 +00:00
Rewrite Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:29:40 +00:00
Sema [XRay][clang] Support capturing the implicit `this` argument to C++ class member functions 2017-06-16 03:22:09 +00:00
Serialization [ODRHash] Hash VarDecl members. 2017-06-16 02:44:29 +00:00
StaticAnalyzer [analyzer] Fix logical not for pointers with different bit width 2017-06-19 08:55:51 +00:00
Tooling Method loadFromCommandLine should be able to report errors 2017-05-24 11:57:37 +00:00
CMakeLists.txt