[clang] [clang-format] Remove YAML hack to emit a BasedOnStyle comment (PR #89228)
Jannik Silvanus via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 03:35:37 PDT 2024
================
@@ -807,12 +807,18 @@ template <> struct MappingTraits<FormatStyle> {
FormatStyle PredefinedStyle;
if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
Style == PredefinedStyle) {
- IO.mapOptional("# BasedOnStyle", StyleName);
+ // For convenience, emit the info which style this matches. However,
+ // setting BasedOnStyle will override all other keys when importing,
+ // so we set a helper key that is ignored when importing.
+ // Ideally, we'd want a YAML comment here, but that's not supported.
+ IO.mapOptional("OrigBasedOnStyle", StyleName);
BasedOnStyle = StyleName;
break;
}
}
} else {
+ StringRef OrigBasedOnStyle; // ignored
+ IO.mapOptional("OrigBasedOnStyle", OrigBasedOnStyle);
----------------
jasilvanus wrote:
This allows the key being present in the input, avoiding an unknown key error. But now with all of it removed, this is no longer relevant.
https://github.com/llvm/llvm-project/pull/89228
More information about the cfe-commits
mailing list