forked from OSchip/llvm-project
[clang-format] Indent tokens after hash only if it starts a line
Fixes #56602. Differential Revision: https://reviews.llvm.org/D130136
This commit is contained in:
parent
7dda6c71b1
commit
892a9968ec
|
@ -656,6 +656,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
|
|||
int PPColumnCorrection = 0;
|
||||
if (Style.IndentPPDirectives == FormatStyle::PPDIS_AfterHash &&
|
||||
Previous.is(tok::hash) && State.FirstIndent > 0 &&
|
||||
&Previous == State.Line->First &&
|
||||
(State.Line->Type == LT_PreprocessorDirective ||
|
||||
State.Line->Type == LT_ImportStatement)) {
|
||||
Spaces += State.FirstIndent;
|
||||
|
|
|
@ -5385,6 +5385,10 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
|
|||
"#endif",
|
||||
Style);
|
||||
Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
|
||||
verifyFormat("#if 1\n"
|
||||
"# define __STR(x) #x\n"
|
||||
"#endif",
|
||||
Style);
|
||||
verifyFormat("#ifdef _WIN32\n"
|
||||
"# define A 0\n"
|
||||
"# ifdef VAR2\n"
|
||||
|
|
Loading…
Reference in New Issue