[clang] [clang-format] Remove YAML hack to emit a BasedOnStyle comment (PR #89228)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 12:10:47 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);
----------------
HazardyKnusperkeks wrote:

If we go that way, why read it back? This does not have any effect.

https://github.com/llvm/llvm-project/pull/89228


More information about the cfe-commits mailing list