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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] AlignTrailingComments on PP dependent on newline?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    **clang-format Version:** 13.0.
**Description:** AlignTrailingComments (?) behaves different for the following two input cases

**Reproduction Steps:** Format the following two blocks of input code (no whitespace at all before comments) with default settings (no .clang-format specified). _Notice the different aligned trailing comment on #else with #endif when there is a newline at the end of the class definition._

Input _without newline_ at end of class definition:
```c++
#define HAS_CPP_11 0

class SomeClass
{
 protected:
#if HAS_CPP_11// C++11 support
  SomeClass(const NonCopyableClass&) = delete;
  SomeClass& operator=(const NonCopyableClass&) = delete;
#else// HAS_CPP_11
 private:
  SomeClass(const SomeClass&);
  SomeClass& operator=(const SomeClass&);
#endif// HAS_CPP_11
};
```

Output _without newline_ (_comment on else **is** aligned_ with endif)
```c++
#define HAS_CPP_11 0

class SomeClass
{
 protected:
#if HAS_CPP_11 // C++11 support
  SomeClass(const NonCopyableClass&) = delete;
  SomeClass& operator=(const NonCopyableClass&) = delete;
#else  // HAS_CPP_11
 private:
  SomeClass(const SomeClass&);
  SomeClass& operator=(const SomeClass&);
#endif // HAS_CPP_11
};
```

Input _with newline_ at end of class definition:
```c++
#define HAS_CPP_11 0

class SomeClass
{
 protected:
#if HAS_CPP_11// C++11 support
  SomeClass(const NonCopyableClass&) = delete;
  SomeClass& operator=(const NonCopyableClass&) = delete;
#else// HAS_CPP_11
 private:
  SomeClass(const SomeClass&);
  SomeClass& operator=(const SomeClass&);

#endif// HAS_CPP_11
};
```

Output _with newline_ (_comment on else is **not** aligned_ with endif)
```c++
#define HAS_CPP_11 0

class SomeClass
{
 protected:
#if HAS_CPP_11 // C++11 support
  SomeClass(const NonCopyableClass&) = delete;
  SomeClass& operator=(const NonCopyableClass&) = delete;
#else // HAS_CPP_11
 private:
  SomeClass(const SomeClass&);
  SomeClass& operator=(const SomeClass&);

#endif // HAS_CPP_11
};
```

I am curious why this is the case and also why it is not aligned with the initial if-PP. Also I would like to know how to set clang-format to not differentiate and either always align or not, regardless of a newline at the end of the definition (in this case).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV1Fv2jAQ_jXm5dQoOISUhzxQULW9bGid9oqc-AJeTRzFTlH__c6JKek2Nm2atE6rFISD77777nw-fRRGPuaML-kptah3V5VpD8LBJ2ytMjVLlsMmTJMojli8ZnH4ZY22bFXjnlkttdrVH1uhtKp3K3M4YO0sMH7NklvGF1DgXjygBamqClvaBIoHbo_0rbU5khe4owFVN52DUli0IeYo8gdsWiO70oeGO4eNPRO4Heh_i1hoU95bMNUJ20j0xGoDx71yaBtRIpCr0JpoEi0kmyEBz_yo3B4kVqLTDiw6R8A2AETPSmcbLFWlUJJbBNt3xilC9ozOWQtfJ5TgQqlOoYAyYjxBbXGI6F9q8iOSWHsQoqUsCKjxSI49Yw9NRj43vyQy1nqqqla-RNF2XMK3ffZbD25oEWC2HidgfO3vizsAzOPhKRm_8U84k6S3RXizvNuuNpvtdArxOOQAeGcOuPKrsJUFf6DDdFg6qtdTIJ5Qxmc4xql5bmE1hCV42zWNaV0AGEHz69LU1sE7U69M8ygKfdqY-0NkyZoS0-iQJTff8Z6DabAVzrRk-Rtg4egC31ECp0zVg_Dmy8vMx2woyq_wvOR66qELtFi2Ppuejnh8fu879_2eocjbUeP2XTvcQ2XDfQyNvh26OdBY_OV-gn-toQBeaEtd4vXTnhqNodcZ9D_MoD8-iX48hpQNk6g27nUU_clR9KIb6_fnEYgDlF2rTGdJaz2SkqIWoqdXVKRDQdBkEtqaflc5v0e99aTk-qbyxv3EEhpUdbXZRKSIyeUtHE2nJWh1T0rQwH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