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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] BUG: IndentPPDirectives will format incositent
        </td>
    </tr>

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

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

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

<pre>
    Input:
```cpp
#ifdef __has_include
#if __has_include(<LoggerFactory.h>)
#include <LoggerFactory.h>
#else
#include <iostream>
#endif
#else
#include <iostream>
#endif
```

Will result into that:
```cpp
#ifdef __has_include
  #if __has_include( <LoggerFactory.h>)
    #include <LoggerFactory.h>
  #else
    #include <iostream>
  #endif
#else
  #include <iostream>
#endif
```

As you can see, there is a space after the opening brace in line 2. This is ok for my configuration, but there is no space before the closing brace. And this is inconsistent. The space will be forced. So removing this space will insert one, but adding one before the closing brace will keep the space. So this is the workaround to keep the code consistent but looks like some kind of issue.

Tested with clang-format-14 and clang-format-15

My configuration:
[clang-format.txt](https://github.com/llvm/llvm-project/files/9709170/clang-format.txt)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylU9tunDAU_Bp4OQoCA3t54GGTNFWkVorUVH2MDD6Au14b2Sbp_n2P2ZDd3JReJAvw8cyc8WDXRuyraz2MPso3UXoZpZtokR5GMwyPFZbLVmALd3c9d3dSN2oUeLL2YoGtovzii-k6tFe88cbukz7KP0VsfeQcoPA2cEahcvgWRRrnLfLdM6wWsv1v5rz3x-n0_CGVAotuVB6k9gZ8z_81LoC3A3sniDkxgAPx49Qm3HH3r4mvEjgw3knvQ_Yf5LdxsDcjNFyDQ9rsBQWIFkE64OAG3iDw1qMNZTADaqk7qG2oSw1KagSWwG1PeBpmC62xsNtDY3Qru9FyL40OsvXoj9LaPGrXSHicxBtl3JN4AhstqHyQpT0a7aTzqH1oho_sh_Dzaww9GxQJfDN0FHbmPshM3BOY1A6tB6NxdsOFCECqvGvjQN0iDtPaJDe1mZ2F6oOxW27NGAybI7gxIjxm31NLZczWUWpb0jI7hK0kkmlJyY2YnP6XWySWoP6-J0tcd2fkcMf9WVYAJ9LzWnlK_foy_afbUJ6f0hL_y0flJR3w3vvBBRi7otFRz7FOGrOjiVL38-tssOYnNp6mrVTo6L1eputsmdLXK-H5dsRYZYtFsU7zMs9jUeVina957KVXWL1wRG7g_PtncgLXWlBoNzeX0lJLeY_u8C8OwOlEOBlyjUerqr_ewBR42EG5yopl3FeLgq0WjNVpzVdlywq2YGWRtaJG1hSsFbHiNd284JhcxrJiKWNZmhbZMmNZnohVlq6yhRDELIs6i4oUd1yqJDROjO1iW00e6rFztKjoVLjjIndOdhpx1uej742tWmWs5LrGZos2nkxXk-PfVHrtOA">