<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101953>101953</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format misaligns comments when indenting preprocessor directives with BeforeHash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Melirius
</td>
</tr>
</table>
<pre>
Issue similar to https://github.com/llvm/llvm-project/issues/56326. Comment before preprocessor directives with BeforeHash gets aligned one surplus tab more.
Example:
``` cxx
#ifndef PREDICTORS_HPP_
#define PREDICTORS_HPP_
int compute_prior(int column) {
#if defined(SPECIAL_PATH)
return top[column];
#else
// division-by-multiplication
#ifdef PEDANTIC
return prior(top[column]);
#else
return fast_prior(top[column]);
#endif
#endif
}
#endif // PREDICTORS_HPP_
```
Intended formatting is `// division-by-multiplication` aligned with `return` or at lest with `#ifdef`. However, with very simple `.clang-format` file
```
---
Language: Cpp
IndentPPDirectives: BeforeHash
---
```
it becomes
``` cxx
#ifndef PREDICTORS_HPP_
#define PREDICTORS_HPP_
int compute_prior(int column) {
#if defined(SPECIAL_PATH)
return top[column];
#else
// division-by-multiplication
#ifdef PEDANTIC
return prior(top[column]);
#else
return fast_prior(top[column]);
#endif
#endif
}
#endif // PREDICTORS_HPP_
```
Note additional tab before this comment.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVd9vozgQ_mvMyyjImELCAw9p0qiR9vai3b5HBg_gk7GRbdL2vz8Z8murnq66x9NKEQHPzDf-PP5muHOy1YglyR5Jto346Dtjyz9QSStHF1VGvJd750YEJ3upuAVvoPN-cCRdE7YjbNdK341VXJuesJ1Sp8vfYrDmL6w9YTsZEBxhuyxPWR7DxvQ9ag8VNsYiDBYHa2p0zlgQ0mLt5QkdvErfwePk88xdBy16B1yFHQswGsGNdlCjA88r6I3FmNAtoev5-fTG-0Fh2Oe8mtP5B_Xb23mJpbLRAhs4_Hja7jcvf_74eXw-HI5Xs8BGavwH8_SU2kNt-mH0eBysNJaw1bymxl4TVgBZPt6lgxlSELb6eXja7Nffjof1yzNhxewEYNGPVoM3A8kezzDZlqQ3FFQOLx-hBCDkSTpp9KJ6X_Sj8nJQsuZeGn0BnXJPTJ-26-8v-82HbJetf8zKimviCeSW-hracOePX4kP4VrI5sbj7mu5vT_VixHOBD8vwKWi95F77VELFNAY23PvpW5BOghe_3pWOb1er-nukZzOHIPFWOAeFDp_NV4OleQ0hmfziie0hG1m-wnte1DNoDD4xrXiul3Muwp4jQyGz4gsFov55RvX7cjbcIdhMwy_0hSo_eGwvcolON3E8gHp06OSQYG16dH9jxUCvyVyq_t34xG4EDLw5mpqnOcm7DvpQplCY44jUaaiSAseYZksGVtlaUKLqCt5KpDWSbqs62XNU1EUeZ7RPEmq1arJ6ySSJaPsga5oltBkxYq4qfJlg3nS0IRXDJfkgWLPpYrDjIiNbaNpOpQJTYosjRSvULlpHjH2i2QYCxPKltNsqcbWkQeqpPPuhuSlV1jeR0Ev3STpKzcHrx1qkJN-QnP44vSJRqvK_z75zvROJfs7AAD__x-cQ2w">