[clang-format] Support indentation of preprocessor directives to level of surrounding code
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Please support indentation of preprocessor directives to level of surrounding code.
I want
```cpp
int main()
{
#warning This is a test!
while (true)
{
DoThingOne();
#ifdef MACRO_A
DoThingThree();
#endif
}
return 0;
}
```
to to be formatted as
```cpp
int main()
{
#warning This is a test!
while (true)
{
DoThingOne();
#ifdef MACRO_A
DoThingThree();
#endif
}
return 0;
}
```
Related: https://www.reddit.com/r/cpp_questions/comments/102vlmu/indent_macros_with_clang_format/
Contributor guide
Research direction
No source file or test is named. Start by locating clang-format's handling of preprocessor directives, then use the issue's C++ examples as the acceptance cases: directives should align with their surrounding code level while nested body statements retain their indentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100