[PATCH] D66886: [yaml2obj][obj2yaml] - Use a single "Other" field instead of "Other", "Visibility" and "StOther".

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 22:11:34 PDT 2019


MaskRay added inline comments.


================
Comment at: test/tools/obj2yaml/elf-symbol-visibility.yaml:14
+# CHECK-NEXT:   - Name: internal
+# CHECK-NEXT:     Other:
+# CHECK-NEXT:      - STV_INTERNAL
----------------
MaskRay wrote:
> jhenderson wrote:
> > Is there any way straightforward way of forcing obj2yaml to produce output in the form `Other: [ STV_HIDDEN ]` etc?
> Not straightforward but I managed to find an approach..
> 
> ```
>  struct NormalizedOther {
> +  struct Piece {
> +    std::string Str;
> +  };
>  ...
> -  Optional<std::vector<StringRef>> Other;
> +  Optional<std::vector<Piece>> Other;
>    std::string UnknownFlagsHolder;
>  };
>  } // namespace
>  
> +template<>
> +struct ScalarTraits<NormalizedOther::Piece> {
> +  static void output(const NormalizedOther::Piece &Val, void *, raw_ostream &Out) {
> +    Out << Val.Str;
> +  }
> +  static StringRef input(StringRef Scalar, void *, NormalizedOther::Piece &Val) {
> +    Val.Str = Scalar.str();
> +    return {};
> +  }
> +  static QuotingType mustQuote(StringRef) { return QuotingType::None; }
> +};
> +template<> struct SequenceElementTraits<NormalizedOther::Piece> {
> +  static const bool flow = true;
> +};
> ```
> 
> This way obj2yaml will dump: `Other: [ STV_HIDDEN ]`
Oh, I think StringRef should be fine.

```
+  struct Piece {
+    StringRef Str;
+  };
```


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

https://reviews.llvm.org/D66886





More information about the llvm-commits mailing list