<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59701>59701</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-format IndentPPDirectives only works if there's code/comments after the final #
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jdiazdelrio
      </td>
    </tr>
</table>

<pre>
    The option `IndentPPDirectives: BeforeHash` on the following code (**Code 1**)
```
#ifndef HAVE_TEST
#define HAVE_TEST
#include "foo.hpp"

namespace space
{}

#endif
```

does no reformat the code. If instead, the code is formatted as expected (**Code 2**)
```
#ifndef HAVE_TEST
   #define HAVE_TEST
   #include "foo.hpp"

namespace space
{}

#endif
```
the code is reformatted to look like in **Code 1**. If either code would have either code or a comment after the `#endif`:
```
#ifndef HAVE_TEST
#define HAVE_TEST
#include "foo.hpp"

namespace space
{}

#endif
//
```
or

```
#ifndef HAVE_TEST
   #define HAVE_TEST
   #include "foo.hpp"

namespace space
{}

#endif
int x;
```
 Code1 will be reformatted to look like in Code2, and Code2 will remain unchanged.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVE1v4yoU_TV4c9UI46944UXSNGp3lV71tk_YXGxaDBbgpn2_foSddlo1M4tZjCohAtx7wzmH48u9V71BbEixJ8Uh4XMYrGseheL_C9RO2aS14rV5GBDsFJQ1QEp6ZwSacH9_UA67oJ7Rk2wHe5TW4S33AykpWANhQJBWa3tSpofOCgTCtoTtCNtdx126rgmrCT0QuiMlPY91yzIljUAJt7t_b_57uPnn4T0gUCqDFwLKdHpebmLS2s0wTYSxc3SZDR_RT7xDWOZzqNqT6vAxjbAMjVDyMrJlFhY9GAsuEh95WAhHmhu4k6CMD8gFYdfv56A8rKkBBXAP-DJhF9efdWF_qAsA_FKaNfZX1PlI902bSDJY0NY-gVZPCMrAVycswqEKA7r1H0521gIG_oyfjq0DDp0dRzQBuAzoFo0jgjdgJSXZ7tvbih3juITSuk9l39wBygR4Idn-IlqIT5zCSWkNLf7WEjGTxU-GG7Fu1jKHI1cGZtMN3PQoNoloMlFnNU-wScuK0TzPiyoZmi3fdmVJS1p3bVqIQtbVVuaY1mWZ1TlrE9UwyljKWEm3eZVVm4ptM14I2TJss6wrSU7jbXqj9fO4sa5PlPczNkVd0TTRvEXt3_qla2LSVTv3nuRUKx_8z7Kggsam09z0V-cO8bVzgjX6FU7WPXlQMtrYIWGVX4xO2PHscv_B5lIZruNbJrPTzRDCFPvv6qVehWFuN50dCTtGJOefq8nZR-wCYceFjSfsuBD6EQAA____B8D1">