forked from OSchip/llvm-project
[clang-format] Honour "// clang-format off" when using QualifierOrder.
Fixes https://github.com/llvm/llvm-project/issues/53643. Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan Differential Revision: https://reviews.llvm.org/D119218
This commit is contained in:
parent
e6d9bab558
commit
e329b5866f
|
@ -390,6 +390,10 @@ LeftRightQualifierAlignmentFixer::analyze(
|
||||||
|
|
||||||
for (AnnotatedLine *Line : AnnotatedLines) {
|
for (AnnotatedLine *Line : AnnotatedLines) {
|
||||||
FormatToken *First = Line->First;
|
FormatToken *First = Line->First;
|
||||||
|
assert(First);
|
||||||
|
if (First->Finalized)
|
||||||
|
continue;
|
||||||
|
|
||||||
const auto *Last = Line->Last;
|
const auto *Last = Line->Last;
|
||||||
|
|
||||||
for (const auto *Tok = First; Tok && Tok != Last && Tok->Next;
|
for (const auto *Tok = First; Tok && Tok != Last && Tok->Next;
|
||||||
|
|
|
@ -858,5 +858,27 @@ TEST_F(QualifierFixerTest, QualifierTemplates) {
|
||||||
Style);
|
Style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(QualifierFixerTest, DisableRegions) {
|
||||||
|
FormatStyle Style = getLLVMStyle();
|
||||||
|
Style.QualifierAlignment = FormatStyle::QAS_Custom;
|
||||||
|
Style.QualifierOrder = {"inline", "static", "const", "type"};
|
||||||
|
|
||||||
|
ReplacementCount = 0;
|
||||||
|
verifyFormat("// clang-format off\n"
|
||||||
|
"int const inline static a = 0;\n"
|
||||||
|
"// clang-format on\n",
|
||||||
|
Style);
|
||||||
|
EXPECT_EQ(ReplacementCount, 0);
|
||||||
|
verifyFormat("// clang-format off\n"
|
||||||
|
"int const inline static a = 0;\n"
|
||||||
|
"// clang-format on\n"
|
||||||
|
"inline static const int a = 0;\n",
|
||||||
|
"// clang-format off\n"
|
||||||
|
"int const inline static a = 0;\n"
|
||||||
|
"// clang-format on\n"
|
||||||
|
"int const inline static a = 0;\n",
|
||||||
|
Style);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace format
|
} // namespace format
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
|
|
Loading…
Reference in New Issue