Skip to content

Commit 75ae623

Browse files
committed
renamed the setting to SkipMacroDefinitionBody
1 parent edc929b commit 75ae623

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4900,10 +4900,10 @@ the configuration (without a prefix: ``Auto``).
49004900
int bar; int bar;
49014901
} // namespace b } // namespace b
49024902

4903-
.. _SkipMacroDefinition:
4903+
.. _SkipMacroDefinitionBody:
49044904

4905-
**SkipMacroDefinition** (``Boolean``) :versionbadge:`clang-format 18` :ref:`<SkipMacroDefinition>`
4906-
Do not format macro definitions.
4905+
**SkipMacroDefinitionBody** (``Boolean``) :versionbadge:`clang-format 18` :ref:`<SkipMacroDefinitionBody>`
4906+
Do not format macro definition body.
49074907

49084908
.. _SortIncludes:
49094909

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ clang-format
961961
- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
962962
- Add ``AllowShortCompoundRequirementOnASingleLine`` option.
963963
- Add ``BreakAdjacentStringLiterals`` option.
964+
- Add ``SkipMacroDefinitionBody`` option.
964965
- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style.
965966

966967
libclang

clang/include/clang/Format/Format.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,9 +3884,9 @@ struct FormatStyle {
38843884
/// \version 13
38853885
unsigned ShortNamespaceLines;
38863886

3887-
/// Do not format macro definitions.
3887+
/// Do not format macro definition body.
38883888
/// \version 18
3889-
bool SkipMacroDefinition;
3889+
bool SkipMacroDefinitionBody;
38903890

38913891
/// Include sorting options.
38923892
enum SortIncludesOptions : int8_t {
@@ -4849,7 +4849,7 @@ struct FormatStyle {
48494849
RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
48504850
SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
48514851
ShortNamespaceLines == R.ShortNamespaceLines &&
4852-
SkipMacroDefinition == R.SkipMacroDefinition &&
4852+
SkipMacroDefinitionBody == R.SkipMacroDefinitionBody &&
48534853
SortIncludes == R.SortIncludes &&
48544854
SortJavaStaticImport == R.SortJavaStaticImport &&
48554855
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
739739
}
740740

741741
if (!DryRun) {
742-
if (Style.SkipMacroDefinition && CurrentState.IsPPDefineBody &&
742+
if (Style.SkipMacroDefinitionBody && CurrentState.IsPPDefineBody &&
743743
!Current.is(tok::comment)) {
744744
Whitespaces.addUntouchableToken(Current, State.Line->InPPDirective);
745745
} else {
@@ -748,7 +748,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
748748
}
749749
}
750750

751-
if (Style.SkipMacroDefinition && Previous.is(tok::pp_define)) {
751+
if (Style.SkipMacroDefinitionBody && Previous.is(tok::pp_define)) {
752752
CurrentState.NoLineBreak = true;
753753
CurrentState.IsPPDefineBody = true;
754754
}

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ template <> struct MappingTraits<FormatStyle> {
10811081
Style.RequiresExpressionIndentation);
10821082
IO.mapOptional("SeparateDefinitionBlocks", Style.SeparateDefinitionBlocks);
10831083
IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
1084-
IO.mapOptional("SkipMacroDefinition", Style.SkipMacroDefinition);
1084+
IO.mapOptional("SkipMacroDefinitionBody", Style.SkipMacroDefinitionBody);
10851085
IO.mapOptional("SortIncludes", Style.SortIncludes);
10861086
IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
10871087
IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
@@ -1556,7 +1556,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15561556
LLVMStyle.RequiresExpressionIndentation = FormatStyle::REI_OuterScope;
15571557
LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
15581558
LLVMStyle.ShortNamespaceLines = 1;
1559-
LLVMStyle.SkipMacroDefinition = false;
1559+
LLVMStyle.SkipMacroDefinitionBody = false;
15601560
LLVMStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
15611561
LLVMStyle.SortJavaStaticImport = FormatStyle::SJSIO_Before;
15621562
LLVMStyle.SortUsingDeclarations = FormatStyle::SUD_LexicographicNumeric;

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,6 @@ unsigned UnwrappedLineFormatter::format(
13551355
bool FixIndentation = (FixBadIndentation || ContinueFormatting) &&
13561356
Indent != TheLine.First->OriginalColumn;
13571357
bool ShouldFormat = TheLine.Affected || FixIndentation;
1358-
13591358
// We cannot format this line; if the reason is that the line had a
13601359
// parsing error, remember that.
13611360
if (ShouldFormat && TheLine.Type == LT_Invalid && Status) {

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ void UnwrappedLineParser::parsePPDefine() {
11581158
FormatTok->Tok.setKind(tok::identifier);
11591159
FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
11601160

1161-
if (Style.SkipMacroDefinition) {
1161+
if (Style.SkipMacroDefinitionBody) {
11621162
do {
11631163
nextToken();
11641164
} while (!eof());

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
184184
CHECK_PARSE_BOOL(ReflowComments);
185185
CHECK_PARSE_BOOL(RemoveBracesLLVM);
186186
CHECK_PARSE_BOOL(RemoveSemicolon);
187-
CHECK_PARSE_BOOL(SkipMacroDefinition);
187+
CHECK_PARSE_BOOL(SkipMacroDefinitionBody);
188188
CHECK_PARSE_BOOL(SpacesInSquareBrackets);
189189
CHECK_PARSE_BOOL(SpaceInEmptyBlock);
190190
CHECK_PARSE_BOOL(SpacesInContainerLiterals);

clang/unittests/Format/FormatTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24219,9 +24219,9 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) {
2421924219
verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style);
2422024220
}
2422124221

24222-
TEST_F(FormatTest, SkipMacroDefinition) {
24222+
TEST_F(FormatTest, SkipMacroDefinitionBody) {
2422324223
auto Style = getLLVMStyle();
24224-
Style.SkipMacroDefinition = true;
24224+
Style.SkipMacroDefinitionBody = true;
2422524225

2422624226
verifyFormat("#define A", "#define A", Style);
2422724227
verifyFormat("#define A a aa", "#define A a aa", Style);
@@ -24322,7 +24322,7 @@ TEST_F(FormatTest, SkipMacroDefinition) {
2432224322
Style);
2432324323

2432424324
Style.IndentPPDirectives = FormatStyle::PPDIS_None;
24325-
// SkipMacroDefinition should not affect other PP directives
24325+
// SkipMacroDefinitionBody should not affect other PP directives
2432624326
verifyFormat("#if !defined(A)\n"
2432724327
"#define A a\n"
2432824328
"#endif",

0 commit comments

Comments
 (0)