diff options
author | Sirraide <aeternalmail@gmail.com> | 2025-01-19 00:26:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-19 00:26:40 +0100 |
commit | 106c483a102e1328f11e2b1d9398f4ad2826b59f (patch) | |
tree | a3fe8a3949bbc0c7d6a71be33a9b6b24df004d3e /clang/lib/Format/Format.cpp | |
parent | eae5ca9b45bf1232f30d92ce50c19c1ea82c0f0b (diff) | |
download | llvm-106c483a102e1328f11e2b1d9398f4ad2826b59f.zip llvm-106c483a102e1328f11e2b1d9398f4ad2826b59f.tar.gz llvm-106c483a102e1328f11e2b1d9398f4ad2826b59f.tar.bz2 |
[clang-format] Improve brace wrapping and add an option to control indentation of `export { ... }` (#110381)
`export { ... }` blocks can get a bit long, so I thought it would make
sense to have an option that makes it so their contents are not indented
(basically the same argument as for namespaces).
This is based on the `NamespaceIndentation` option, except that there is
no option to control the behaviour of `export` blocks when nested because
nesting them doesn’t really make sense.
Additionally, brace wrapping of short `export { ... }` blocks is now controlled by the
`AllowShortBlocksOnASingleLine` option. There is no separate option just for `export`
blocks because you can just write e.g. `export int x;` instead of `export { int x; }`.
This closes #121723.
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index fc60c5e..6826fa7 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1040,6 +1040,7 @@ template <> struct MappingTraits<FormatStyle> { Style.EmptyLineBeforeAccessModifier); IO.mapOptional("ExperimentalAutoDetectBinPacking", Style.ExperimentalAutoDetectBinPacking); + IO.mapOptional("ExportBlockIndentation", Style.ExportBlockIndentation); IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments); IO.mapOptional("ForEachMacros", Style.ForEachMacros); IO.mapOptional("IfMacros", Style.IfMacros); @@ -1550,6 +1551,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never; LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock; LLVMStyle.ExperimentalAutoDetectBinPacking = false; + LLVMStyle.ExportBlockIndentation = true; LLVMStyle.FixNamespaceComments = true; LLVMStyle.ForEachMacros.push_back("foreach"); LLVMStyle.ForEachMacros.push_back("Q_FOREACH"); |