[PATCH] D79990: [clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 03:02:43 PDT 2020


MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, JakeMerdichAMD, mitchell-stellar, owenpan, sylvestre.ledru.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay retitled this revision from "[clang-format] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon" to "[clang-format] [PR45614] Incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon".
MyDeveloperDay added a reviewer: Abpostelnicu.

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

`[[nodiscard]]` after a macro doesn't behave the same as an __attribute__ resulting in incorrect indentation

This revision corrects that behavior

  MACRO
  
  __attribute__((warn_unused_result)) int f3(); // ok
  
  MACRO
  
      [[nodiscard]] int
      f4(); // bad: unexpectedly indented!

See original Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1629756

Before:

  class FooWidget : public nsBaseWidget {
  public:
    FooWidget();
  
    NS_DECL_ISUPPORTS_INHERITED
  
        [[nodiscard]] nsresult
        FunctionOne();
    [[nodiscard]] nsresult FunctionTwo();
  };

After:

  class FooWidget : public nsBaseWidget {
  public:
    FooWidget();
  
    NS_DECL_ISUPPORTS_INHERITED
  
    [[nodiscard]] nsresult FunctionOne();
    [[nodiscard]] nsresult FunctionTwo();
  };




https://reviews.llvm.org/D79990

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79990.264194.patch
Type: text/x-patch
Size: 4637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200515/81bcb98b/attachment-0001.bin>


More information about the cfe-commits mailing list