[PATCH] D79354: [clang-format] [PR34574] Handle [[nodiscard]] attribute in class declaration

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 5 10:14:21 PDT 2020


krasimir added a comment.

I have an example where this goes wrong in ObjC (modulo indentation):

  struct Stuff stuff[] = {                                                                                                                                                                                                                                              
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},                                                                                                                                                                                                                                       
        {key, value},                                                                                                                                                                                                                                   
        {nil, 0}};

gets formatted to (module indentation):

  struct Stuff stuff[] = {                                                                                                                                                                                                                                              
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},  // comment                                                                                                                                                                                                                                       
        {key, value},                                                                                                                                                                                                                                       
        {key, value},                                                                                                                                                                                                                                   
        {
          nil, 0
        }
    };

I think we should try harder to detect the beginning of an attribute specifier. I think there may be a helper for that somewhere in clang-format.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79354/new/

https://reviews.llvm.org/D79354





More information about the cfe-commits mailing list