|
10 | 10 | #include "clang/Basic/LLVM.h" |
11 | 11 | #include "clang/Driver/Driver.h" |
12 | 12 | #include "llvm/ADT/DenseSet.h" |
13 | | -#include "llvm/ADT/SmallSet.h" |
14 | 13 | #include "llvm/ADT/StringRef.h" |
15 | 14 | #include "llvm/Support/Compiler.h" |
16 | 15 | #include "llvm/Support/ErrorHandling.h" |
@@ -202,20 +201,13 @@ struct MultilibGroupSerialization { |
202 | 201 |
|
203 | 202 | struct MultilibSetSerialization { |
204 | 203 | llvm::VersionTuple MultilibVersion; |
205 | | - SmallVector<MultilibGroupSerialization> Groups; |
206 | | - SmallVector<MultilibSerialization> Multilibs; |
207 | | - SmallVector<MultilibSet::FlagMatcher> FlagMatchers; |
208 | | - SmallVector<custom_flag::DeclarationPtr> CustomFlagDeclarations; |
| 204 | + std::vector<MultilibGroupSerialization> Groups; |
| 205 | + std::vector<MultilibSerialization> Multilibs; |
| 206 | + std::vector<MultilibSet::FlagMatcher> FlagMatchers; |
209 | 207 | }; |
210 | 208 |
|
211 | 209 | } // end anonymous namespace |
212 | 210 |
|
213 | | -LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSerialization) |
214 | | -LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibGroupSerialization) |
215 | | -LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::FlagMatcher) |
216 | | -LLVM_YAML_IS_SEQUENCE_VECTOR(custom_flag::ValueDetail) |
217 | | -LLVM_YAML_IS_SEQUENCE_VECTOR(custom_flag::DeclarationPtr) |
218 | | - |
219 | 211 | template <> struct llvm::yaml::MappingTraits<MultilibSerialization> { |
220 | 212 | static void mapping(llvm::yaml::IO &io, MultilibSerialization &V) { |
221 | 213 | io.mapOptional("Dir", V.Dir); |
@@ -263,63 +255,11 @@ template <> struct llvm::yaml::MappingTraits<MultilibSet::FlagMatcher> { |
263 | 255 | } |
264 | 256 | }; |
265 | 257 |
|
266 | | -template <> |
267 | | -struct llvm::yaml::MappingContextTraits<custom_flag::ValueDetail, |
268 | | - llvm::SmallSet<std::string, 32>> { |
269 | | - static void mapping(llvm::yaml::IO &io, custom_flag::ValueDetail &V, |
270 | | - llvm::SmallSet<std::string, 32> &) { |
271 | | - io.mapRequired("Name", V.Name); |
272 | | - io.mapOptional("MacroDefines", V.MacroDefines); |
273 | | - } |
274 | | - static std::string validate(IO &io, custom_flag::ValueDetail &V, |
275 | | - llvm::SmallSet<std::string, 32> &NameSet) { |
276 | | - if (V.Name.empty()) |
277 | | - return "custom flag value requires a name"; |
278 | | - if (!NameSet.insert(V.Name).second) |
279 | | - return "duplicate custom flag value name: \"" + V.Name + "\""; |
280 | | - return {}; |
281 | | - } |
282 | | -}; |
283 | | - |
284 | | -template <> |
285 | | -struct llvm::yaml::MappingContextTraits<custom_flag::DeclarationPtr, |
286 | | - llvm::SmallSet<std::string, 32>> { |
287 | | - static void mapping(llvm::yaml::IO &io, custom_flag::DeclarationPtr &V, |
288 | | - llvm::SmallSet<std::string, 32> &NameSet) { |
289 | | - assert(!V); |
290 | | - V = std::make_shared<custom_flag::Declaration>(); |
291 | | - io.mapRequired("Name", V->Name); |
292 | | - io.mapRequired("Values", V->ValueList, NameSet); |
293 | | - std::string DefaultValueName; |
294 | | - io.mapRequired("Default", DefaultValueName); |
295 | | - |
296 | | - for (auto [Idx, Value] : llvm::enumerate(V->ValueList)) { |
297 | | - Value.Decl = V; |
298 | | - if (Value.Name == DefaultValueName) { |
299 | | - assert(!V->DefaultValueIdx); |
300 | | - V->DefaultValueIdx = Idx; |
301 | | - } |
302 | | - } |
303 | | - } |
304 | | - static std::string validate(IO &io, custom_flag::DeclarationPtr &V, |
305 | | - llvm::SmallSet<std::string, 32> &) { |
306 | | - if (V->Name.empty()) |
307 | | - return "custom flag requires a name"; |
308 | | - if (V->ValueList.empty()) |
309 | | - return "custom flag must have at least one value"; |
310 | | - if (!V->DefaultValueIdx) |
311 | | - return "custom flag must have a default value"; |
312 | | - return {}; |
313 | | - } |
314 | | -}; |
315 | | - |
316 | 258 | template <> struct llvm::yaml::MappingTraits<MultilibSetSerialization> { |
317 | 259 | static void mapping(llvm::yaml::IO &io, MultilibSetSerialization &M) { |
318 | 260 | io.mapRequired("MultilibVersion", M.MultilibVersion); |
319 | 261 | io.mapRequired("Variants", M.Multilibs); |
320 | 262 | io.mapOptional("Groups", M.Groups); |
321 | | - llvm::SmallSet<std::string, 32> NameSet; |
322 | | - io.mapOptionalWithContext("Flags", M.CustomFlagDeclarations, NameSet); |
323 | 263 | io.mapOptional("Mappings", M.FlagMatchers); |
324 | 264 | } |
325 | 265 | static std::string validate(IO &io, MultilibSetSerialization &M) { |
@@ -348,6 +288,10 @@ template <> struct llvm::yaml::MappingTraits<MultilibSetSerialization> { |
348 | 288 | } |
349 | 289 | }; |
350 | 290 |
|
| 291 | +LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSerialization) |
| 292 | +LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibGroupSerialization) |
| 293 | +LLVM_YAML_IS_SEQUENCE_VECTOR(MultilibSet::FlagMatcher) |
| 294 | + |
351 | 295 | llvm::ErrorOr<MultilibSet> |
352 | 296 | MultilibSet::parseYaml(llvm::MemoryBufferRef Input, |
353 | 297 | llvm::SourceMgr::DiagHandlerTy DiagHandler, |
@@ -375,8 +319,7 @@ MultilibSet::parseYaml(llvm::MemoryBufferRef Input, |
375 | 319 | } |
376 | 320 | } |
377 | 321 |
|
378 | | - return MultilibSet(std::move(Multilibs), std::move(MS.FlagMatchers), |
379 | | - std::move(MS.CustomFlagDeclarations)); |
| 322 | + return MultilibSet(std::move(Multilibs), std::move(MS.FlagMatchers)); |
380 | 323 | } |
381 | 324 |
|
382 | 325 | LLVM_DUMP_METHOD void MultilibSet::dump() const { |
|
0 commit comments