This revision was automatically updated to reflect the committed changes. Closed by commit rGeee536dd3185: [clang-format] Don't format qualifiers in PPDirective (authored by owenpan).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122548/new/ https://reviews.llvm.org/D122548 Files: clang/lib/Format/QualifierAlignmentFixer.cpp clang/unittests/Format/QualifierFixerTest.cpp Index: clang/unittests/Format/QualifierFixerTest.cpp =================================================================== --- clang/unittests/Format/QualifierFixerTest.cpp +++ clang/unittests/Format/QualifierFixerTest.cpp @@ -815,6 +815,7 @@ ReplacementCount = 0; EXPECT_EQ(ReplacementCount, 0); verifyFormat("static const uint32 foo[] = {0, 31};", Style); + verifyFormat("#define MACRO static const", Style); EXPECT_EQ(ReplacementCount, 0); } Index: clang/lib/Format/QualifierAlignmentFixer.cpp =================================================================== --- clang/lib/Format/QualifierAlignmentFixer.cpp +++ clang/lib/Format/QualifierAlignmentFixer.cpp @@ -407,6 +407,8 @@ assert(QualifierToken != tok::identifier && "Unrecognised Qualifier"); for (AnnotatedLine *Line : AnnotatedLines) { + if (Line->InPPDirective) + continue; FormatToken *First = Line->First; assert(First); if (First->Finalized)
Index: clang/unittests/Format/QualifierFixerTest.cpp =================================================================== --- clang/unittests/Format/QualifierFixerTest.cpp +++ clang/unittests/Format/QualifierFixerTest.cpp @@ -815,6 +815,7 @@ ReplacementCount = 0; EXPECT_EQ(ReplacementCount, 0); verifyFormat("static const uint32 foo[] = {0, 31};", Style); + verifyFormat("#define MACRO static const", Style); EXPECT_EQ(ReplacementCount, 0); } Index: clang/lib/Format/QualifierAlignmentFixer.cpp =================================================================== --- clang/lib/Format/QualifierAlignmentFixer.cpp +++ clang/lib/Format/QualifierAlignmentFixer.cpp @@ -407,6 +407,8 @@ assert(QualifierToken != tok::identifier && "Unrecognised Qualifier"); for (AnnotatedLine *Line : AnnotatedLines) { + if (Line->InPPDirective) + continue; FormatToken *First = Line->First; assert(First); if (First->Finalized)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits