https://github.com/vhscampos created 
https://github.com/llvm/llvm-project/pull/122722

Reverts llvm/llvm-project#110657

It seems that this patch is causing the sanitizer bot to fail. Reverting while 
I investigate

>From ad6c95a7c6e5e8d376225b42a3a71d5663aa7942 Mon Sep 17 00:00:00 2001
From: Victor Campos <git...@victorcampos.me>
Date: Mon, 13 Jan 2025 15:07:18 +0000
Subject: [PATCH] Revert "[Multilib] Custom flags YAML parsing (#110657)"

This reverts commit d98ced1a9d641539d5bbb287bd16378ba3f5dba9.
---
 clang/include/clang/Driver/Multilib.h         |  28 +---
 clang/lib/Driver/Multilib.cpp                 |  73 ++--------
 ...remetal-multilib-custom-flags-parsing.yaml | 133 ------------------
 3 files changed, 11 insertions(+), 223 deletions(-)
 delete mode 100644 
clang/test/Driver/baremetal-multilib-custom-flags-parsing.yaml

diff --git a/clang/include/clang/Driver/Multilib.h 
b/clang/include/clang/Driver/Multilib.h
index 1dab45c062aeec..dbed70f4f9008f 100644
--- a/clang/include/clang/Driver/Multilib.h
+++ b/clang/include/clang/Driver/Multilib.h
@@ -101,25 +101,6 @@ class Multilib {
 
 raw_ostream &operator<<(raw_ostream &OS, const Multilib &M);
 
-namespace custom_flag {
-struct Declaration;
-using DeclarationPtr = std::shared_ptr<Declaration>;
-
-struct ValueDetail {
-  std::string Name;
-  std::optional<SmallVector<std::string>> MacroDefines;
-  DeclarationPtr Decl;
-};
-
-struct Declaration {
-  std::string Name;
-  SmallVector<ValueDetail> ValueList;
-  std::optional<size_t> DefaultValueIdx;
-};
-
-static constexpr StringRef Prefix = "-fmultilib-flag=";
-} // namespace custom_flag
-
 /// See also MultilibSetBuilder for combining multilibs into a set.
 class MultilibSet {
 public:
@@ -139,18 +120,15 @@ class MultilibSet {
 
 private:
   multilib_list Multilibs;
-  SmallVector<FlagMatcher> FlagMatchers;
-  SmallVector<custom_flag::DeclarationPtr> CustomFlagDecls;
+  std::vector<FlagMatcher> FlagMatchers;
   IncludeDirsFunc IncludeCallback;
   IncludeDirsFunc FilePathsCallback;
 
 public:
   MultilibSet() = default;
   MultilibSet(multilib_list &&Multilibs,
-              SmallVector<FlagMatcher> &&FlagMatchers = {},
-              SmallVector<custom_flag::DeclarationPtr> &&CustomFlagDecls = {})
-      : Multilibs(std::move(Multilibs)), FlagMatchers(std::move(FlagMatchers)),
-        CustomFlagDecls(std::move(CustomFlagDecls)) {}
+              std::vector<FlagMatcher> &&FlagMatchers = {})
+      : Multilibs(Multilibs), FlagMatchers(FlagMatchers) {}
 
   const multilib_list &getMultilibs() { return Multilibs; }
 
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index b4b5dbd1bdb5e3..0207e0f2eb2ded 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -10,7 +10,6 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Driver.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -202,20 +201,13 @@ struct MultilibGroupSerialization {
 
 struct MultilibSetSerialization {
   llvm::VersionTuple MultilibVersion;
-  SmallVector<MultilibGroupSerialization> Groups;
-  SmallVector<MultilibSerialization> Multilibs;
-  SmallVector<MultilibSet::FlagMatcher> FlagMatchers;
-  SmallVector<custom_flag::DeclarationPtr> CustomFlagDeclarations;
+  std::vector<MultilibGroupSerialization> Groups;
+  std::vector<MultilibSerialization> Multilibs;
+  std::vector<MultilibSet::FlagMatcher> FlagMatchers;
 };
 
 } // end anonymous namespace
 
-LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSerialization)
-LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibGroupSerialization)
-LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::FlagMatcher)
-LLVM_YAML_IS_SEQUENCE_VECTOR(custom_flag::ValueDetail)
-LLVM_YAML_IS_SEQUENCE_VECTOR(custom_flag::DeclarationPtr)
-
 template <> struct llvm::yaml::MappingTraits<MultilibSerialization> {
   static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) {
     io.mapOptional("Dir", V.Dir);
@@ -263,63 +255,11 @@ template <> struct 
llvm::yaml::MappingTraits<MultilibSet::FlagMatcher> {
   }
 };
 
-template <>
-struct llvm::yaml::MappingContextTraits<custom_flag::ValueDetail,
-                                        llvm::SmallSet<std::string, 32>> {
-  static void mapping(llvm::yaml::IO &io, custom_flag::ValueDetail &V,
-                      llvm::SmallSet<std::string, 32> &) {
-    io.mapRequired("Name", V.Name);
-    io.mapOptional("MacroDefines", V.MacroDefines);
-  }
-  static std::string validate(IO &io, custom_flag::ValueDetail &V,
-                              llvm::SmallSet<std::string, 32> &NameSet) {
-    if (V.Name.empty())
-      return "custom flag value requires a name";
-    if (!NameSet.insert(V.Name).second)
-      return "duplicate custom flag value name: \"" + V.Name + "\"";
-    return {};
-  }
-};
-
-template <>
-struct llvm::yaml::MappingContextTraits<custom_flag::DeclarationPtr,
-                                        llvm::SmallSet<std::string, 32>> {
-  static void mapping(llvm::yaml::IO &io, custom_flag::DeclarationPtr &V,
-                      llvm::SmallSet<std::string, 32> &NameSet) {
-    assert(!V);
-    V = std::make_shared<custom_flag::Declaration>();
-    io.mapRequired("Name", V->Name);
-    io.mapRequired("Values", V->ValueList, NameSet);
-    std::string DefaultValueName;
-    io.mapRequired("Default", DefaultValueName);
-
-    for (auto [Idx, Value] : llvm::enumerate(V->ValueList)) {
-      Value.Decl = V;
-      if (Value.Name == DefaultValueName) {
-        assert(!V->DefaultValueIdx);
-        V->DefaultValueIdx = Idx;
-      }
-    }
-  }
-  static std::string validate(IO &io, custom_flag::DeclarationPtr &V,
-                              llvm::SmallSet<std::string, 32> &) {
-    if (V->Name.empty())
-      return "custom flag requires a name";
-    if (V->ValueList.empty())
-      return "custom flag must have at least one value";
-    if (!V->DefaultValueIdx)
-      return "custom flag must have a default value";
-    return {};
-  }
-};
-
 template <> struct llvm::yaml::MappingTraits<MultilibSetSerialization> {
   static void mapping(llvm::yaml::IO &io, MultilibSetSerialization &M) {
     io.mapRequired("MultilibVersion", M.MultilibVersion);
     io.mapRequired("Variants", M.Multilibs);
     io.mapOptional("Groups", M.Groups);
-    llvm::SmallSet<std::string, 32> NameSet;
-    io.mapOptionalWithContext("Flags", M.CustomFlagDeclarations, NameSet);
     io.mapOptional("Mappings", M.FlagMatchers);
   }
   static std::string validate(IO &io, MultilibSetSerialization &M) {
@@ -348,6 +288,10 @@ template <> struct 
llvm::yaml::MappingTraits<MultilibSetSerialization> {
   }
 };
 
+LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSerialization)
+LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibGroupSerialization)
+LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::FlagMatcher)
+
 llvm::ErrorOr<MultilibSet>
 MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
                        llvm::SourceMgr::DiagHandlerTy DiagHandler,
@@ -375,8 +319,7 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input,
     }
   }
 
-  return MultilibSet(std::move(Multilibs), std::move(MS.FlagMatchers),
-                     std::move(MS.CustomFlagDeclarations));
+  return MultilibSet(std::move(Multilibs), std::move(MS.FlagMatchers));
 }
 
 LLVM_DUMP_METHOD void MultilibSet::dump() const {
diff --git a/clang/test/Driver/baremetal-multilib-custom-flags-parsing.yaml 
b/clang/test/Driver/baremetal-multilib-custom-flags-parsing.yaml
deleted file mode 100644
index fe6a9a8d7f1ee7..00000000000000
--- a/clang/test/Driver/baremetal-multilib-custom-flags-parsing.yaml
+++ /dev/null
@@ -1,133 +0,0 @@
-# RUN: split-file %s %t
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/multilib-without-macro-defines.yaml %s -### -o /dev/null 
2>&1 \
-# RUN: | FileCheck %s
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/multilib-with-macro-defines.yaml %s -### -o /dev/null 
2>&1 \
-# RUN: | FileCheck %s
-# CHECK-NOT: error:
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/missing-flag-name.yaml %s -### -o /dev/null 2>&1 \
-# RUN: | FileCheck %s --check-prefix=CHECK-MISSING-FLAG-NAME
-# CHECK-MISSING-FLAG-NAME: error: custom flag requires a name
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/missing-flag-values.yaml %s -### -o /dev/null 2>&1 \
-# RUN: | FileCheck %s --check-prefix=CHECK-MISSING-FLAG-VALUES
-# CHECK-MISSING-FLAG-VALUES: error: custom flag must have at least one value
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/missing-flag-value-default.yaml %s -### -o /dev/null 2>&1 
\
-# RUN: | FileCheck %s --check-prefix=CHECK-MISSING-FLAG-VALUE-DEFAULT
-# CHECK-MISSING-FLAG-VALUE-DEFAULT: error: custom flag must have a default 
value
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/missing-flag-value-name.yaml %s -### -o /dev/null 2>&1 \
-# RUN: | FileCheck %s --check-prefix=CHECK-MISSING-FLAG-VALUE-NAME
-# CHECK-MISSING-FLAG-VALUE-NAME: error: custom flag value requires a name
-
-# RUN: %clang --target=arm-none-eabi 
--multi-lib-config=%t/duplicate-flag-value-name.yaml %s -### -o /dev/null 2>&1 \
-# RUN: | FileCheck %s --check-prefix=CHECK-DUPLICATE-FLAG-VALUE-NAME
-# CHECK-DUPLICATE-FLAG-VALUE-NAME:      error: duplicate custom flag value 
name: "value-name"
-# CHECK-DUPLICATE-FLAG-VALUE-NAME-NEXT: - Name: value-name
-
-#--- multilib-without-macro-defines.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Name: flag
-    Values:
-    - Name: a
-    - Name: b
-    Default: a
-
-#--- multilib-with-macro-defines.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Name: flag
-    Values:
-    - Name: a
-      MacroDefines: [FEATURE_A]
-    - Name: b
-      MacroDefines: [FEATURE_B]
-    Default: a
-
-#--- missing-flag-name.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Values:
-    - Name: a
-    Default: a
-
-#--- missing-flag-values.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Name: flag
-    Values:
-    Default: a
-
-#--- missing-flag-value-default.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Name: flag
-    Values:
-    - Name: a
-    Default:
-
-#--- missing-flag-value-name.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=a]
-
-Flags:
-  - Name: flag
-    Values:
-    - Name:
-    Default: a
-
-#--- duplicate-flag-value-name.yaml
----
-MultilibVersion: 1.0
-
-Variants:
-- Dir: libc
-  Flags: [-fmultilib-flag=value-name]
-
-Flags:
-  - Name: a
-    Values:
-    - Name: value-name
-    - Name: value-a
-    Default: value-name
-  - Name: b
-    Values:
-    - Name: value-name
-    Default: value-name

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to