[clang] 2c5d7a8 - [clang-format] Remove YAML hack to emit a BasedOnStyle comment (#89228)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 25 03:47:47 PDT 2024
Author: Jannik Silvanus
Date: 2024-04-25T12:47:43+02:00
New Revision: 2c5d7a888589a608a4cd6adc34f19a65dc4551af
URL: https://github.com/llvm/llvm-project/commit/2c5d7a888589a608a4cd6adc34f19a65dc4551af
DIFF: https://github.com/llvm/llvm-project/commit/2c5d7a888589a608a4cd6adc34f19a65dc4551af.diff
LOG: [clang-format] Remove YAML hack to emit a BasedOnStyle comment (#89228)
When serializing a formatting style to YAML, we were emitting a comment
`# BasedOnStyle: <style>` if the serialized formatting style matches one
of the known styles. This is useful, but mis-uses the YAML API.
An upcoming change to fix keys with special characters by quoting them
breaks this,
and will emit a non-comment **key** `'# BasedOnStyle': <style>` instead.
(https://github.com/llvm/llvm-project/pull/88763)
Thus, remove this hack. There doesn't seem to be a specific use for it,
and it is not tested.
If we want the comment back, we should add comment support to the YAML writer,
and use that instead.
Added:
Modified:
clang/lib/Format/Format.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ccb2c9190e2eff..373dd4e60bf33f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -807,7 +807,6 @@ template <> struct MappingTraits<FormatStyle> {
FormatStyle PredefinedStyle;
if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
Style == PredefinedStyle) {
- IO.mapOptional("# BasedOnStyle", StyleName);
BasedOnStyle = StyleName;
break;
}
More information about the cfe-commits
mailing list