<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-format incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon"
   href="https://bugs.llvm.org/show_bug.cgi?id=45614">45614</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format incorrectly indents [[nodiscard]] attribute funtions after a macro without semicolon
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cpeterson@mozilla.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang-format incorrectly indents [[nodiscard]] functions (or any functions with
a [[attribute]]) that follow a macro without a trailing semicolon. This problem
does not affect __attribute__((warn_unused_result)) functions.


```
#define MACRO

MACRO;

__attribute__((warn_unused_result)) int f1(); // ok

MACRO;

[[nodiscard]] int f2(); // ok

MACRO

__attribute__((warn_unused_result)) int f3(); // ok

MACRO

[[nodiscard]] int f4(); // bad: unexpectedly indented!

MACRO

[[bogus_attribute_name]] int f5(); // bad: unexpectedly indented!
```

produces this output:

```
#define MACRO

MACRO;

__attribute__((warn_unused_result)) int f1(); // ok

MACRO;

[[nodiscard]] int f2(); // ok

MACRO

__attribute__((warn_unused_result)) int f3(); // ok

MACRO

    [[nodiscard]] int
    f4(); // bad: unexpectedly indented!

MACRO

    [[bogus_attribute_name]] int
    f5(); // bad: unexpectedly indented!
```

I found this bug when trying to replace __attribute__((warn_unused_result))
with [[nodiscard]] in Firefox source code:
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1629756">https://bugzilla.mozilla.org/show_bug.cgi?id=1629756</a>. I am testing clang-format
version 9.0.1.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>