[clang-format] Don't format qualifiers in PPDirective

Fixes #54513

Differential Revision: https://reviews.llvm.org/D122548
This commit is contained in:
owenca 2022-03-27 13:19:02 -07:00
parent d394f9f897
commit eee536dd31
2 changed files with 3 additions and 0 deletions

View File

@ -407,6 +407,8 @@ LeftRightQualifierAlignmentFixer::analyze(
assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
for (AnnotatedLine *Line : AnnotatedLines) {
if (Line->InPPDirective)
continue;
FormatToken *First = Line->First;
assert(First);
if (First->Finalized)

View File

@ -815,6 +815,7 @@ TEST_F(QualifierFixerTest, NoOpQualifierReplacements) {
ReplacementCount = 0;
EXPECT_EQ(ReplacementCount, 0);
verifyFormat("static const uint32 foo[] = {0, 31};", Style);
verifyFormat("#define MACRO static const", Style);
EXPECT_EQ(ReplacementCount, 0);
}