[yaml2obj] - Implement BBAddrMapSection::getEntries(). NFC.
authorGeorgii Rymar <grimar@accesssoftek.com>
Mon, 9 Nov 2020 08:11:57 +0000 (11:11 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Mon, 9 Nov 2020 08:11:57 +0000 (11:11 +0300)
This allows to use the generic fields validation
mechanism that we have.

The behavior (i.e. an error reported) remains the same.

llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/lib/ObjectYAML/ELFYAML.cpp

index 16d8cf6..206d767 100644 (file)
@@ -256,6 +256,10 @@ struct BBAddrMapSection : Section {
 
   BBAddrMapSection() : Section(ChunkKind::BBAddrMap) {}
 
+  std::vector<std::pair<StringRef, bool>> getEntries() const override {
+    return {{"Entries", Entries.hasValue()}};
+  };
+
   static bool classof(const Chunk *S) {
     return S->Kind == ChunkKind::BBAddrMap;
   }
index 0df8482..b2016dc 100644 (file)
@@ -1497,12 +1497,6 @@ std::string MappingTraits<std::unique_ptr<ELFYAML::Chunk>>::validate(
     return "";
   }
 
-  if (const auto *BBAM = dyn_cast<ELFYAML::BBAddrMapSection>(C.get())) {
-    if ((BBAM->Content || BBAM->Size) && BBAM->Entries)
-      return "\"Entries\" cannot be used with \"Content\" or \"Size\"";
-    return "";
-  }
-
   return "";
 }