[PATCH] D55390: [llvm-tapi] Don't override SequenceTraits for std::string

Armando Montanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 6 16:02:45 PST 2018


This revision was automatically updated to reflect the committed changes.
amontanez marked 2 inline comments as done.
Closed by commit rL348551: [llvm-tapi] Don't override SequenceTraits for std::string (authored by amontanez, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55390?vs=177064&id=177078#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55390/new/

https://reviews.llvm.org/D55390

Files:
  llvm/trunk/lib/TextAPI/ELF/TBEHandler.cpp


Index: llvm/trunk/lib/TextAPI/ELF/TBEHandler.cpp
===================================================================
--- llvm/trunk/lib/TextAPI/ELF/TBEHandler.cpp
+++ llvm/trunk/lib/TextAPI/ELF/TBEHandler.cpp
@@ -18,6 +18,8 @@
 using namespace llvm::elfabi;
 
 LLVM_YAML_STRONG_TYPEDEF(ELFArch, ELFArchMapper)
+LLVM_YAML_STRONG_TYPEDEF(std::string, ELFNeededEntry)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(ELFNeededEntry)
 
 namespace llvm {
 namespace yaml {
@@ -126,21 +128,23 @@
   }
 };
 
-/// YAML traits for generic string vectors (i.e. list of needed libraries).
-template <> struct SequenceTraits<std::vector<std::string>> {
-  static size_t size(IO &IO, std::vector<std::string> &List) {
-    return List.size();
+/// YAML traits for ELFNeededEntry. This is required to enable flow mapping on
+/// NeededLibs.
+template <> struct ScalarTraits<ELFNeededEntry> {
+  static void output(const ELFNeededEntry &Value, void *,
+                     llvm::raw_ostream &Out) {
+    Out << Value.value;
   }
 
-  static std::string &element(IO &IO, std::vector<std::string> &List,
-                              size_t Index) {
-    if (Index >= List.size())
-      List.resize(Index + 1);
-    return List[Index];
+  static StringRef input(StringRef Scalar, void *, ELFNeededEntry &Value) {
+    Value = Scalar.str();
+
+    // Returning empty StringRef indicates successful parse.
+    return StringRef();
   }
 
-  // Compacts list of needed libraries into a single line.
-  static const bool flow = true;
+  // Don't place quotation marks around needed entries.
+  static QuotingType mustQuote(StringRef) { return QuotingType::None; }
 };
 
 /// YAML traits for ELFStub objects.
@@ -151,7 +155,8 @@
     IO.mapRequired("TbeVersion", Stub.TbeVersion);
     IO.mapRequired("SoName", Stub.SoName);
     IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
-    IO.mapOptional("NeededLibs", Stub.NeededLibs);
+    IO.mapOptional("NeededLibs",
+                   (std::vector<ELFNeededEntry> &)Stub.NeededLibs);
     IO.mapRequired("Symbols", Stub.Symbols);
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55390.177078.patch
Type: text/x-patch
Size: 2059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/38ca04bf/attachment.bin>


More information about the llvm-commits mailing list