[llvm] c9d036a - [yaml2obj] - Implement BBAddrMapSection::getEntries(). NFC.

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 00:19:12 PST 2020


Author: Georgii Rymar
Date: 2020-11-09T11:11:57+03:00
New Revision: c9d036ad4a2962059c595c77abb51154e2f5ec27

URL: https://github.com/llvm/llvm-project/commit/c9d036ad4a2962059c595c77abb51154e2f5ec27
DIFF: https://github.com/llvm/llvm-project/commit/c9d036ad4a2962059c595c77abb51154e2f5ec27.diff

LOG: [yaml2obj] - Implement BBAddrMapSection::getEntries(). NFC.

This allows to use the generic fields validation
mechanism that we have.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h b/llvm/include/llvm/ObjectYAML/ELFYAML.h
index 16d8cf68042b..206d767de758 100644
--- a/llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -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;
   }

diff  --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp
index 0df84826cc14..b2016dc9f13e 100644
--- a/llvm/lib/ObjectYAML/ELFYAML.cpp
+++ b/llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -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 "";
 }
 


        


More information about the llvm-commits mailing list