]> granicus.if.org Git - clang/commit
[Support] Teach YAMLIO about polymorphic types
authorScott Linder <scott@scottlinder.com>
Wed, 14 Nov 2018 19:39:59 +0000 (19:39 +0000)
committerScott Linder <scott@scottlinder.com>
Wed, 14 Nov 2018 19:39:59 +0000 (19:39 +0000)
commit52daf3b92d0db0617bdc8d4125aaed5e4abe02db
tree92ae0a0db53e4dae37021bdb2c7e544b56fb8140
parent10d91a7d0c6078c3fedf1f7e6ca536d52f00ee69
[Support] Teach YAMLIO about polymorphic types

Add support for "polymorphic" types to YAMLIO.

PolymorphicTraits can dynamically switch between other traits (Scalar, Map, or
Sequence). When inputting, the PolymorphicTraits type is told which type to
become, and when outputting the PolymorphicTraits type is asked which type it
currently is.

Also add support for TaggedScalarTraits to allow dynamically differentiating
between multiple scalar types using YAML tags.

Serialize empty maps as "{}" and empty sequences as "[]", so that types
are preserved when round-tripping PolymorphicTraits. This change has
equivalent semantics, but may break e.g. tests which compare output
verbatim.

Differential Revision: https://reviews.llvm.org/D48144

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346884 91177308-0d34-0410-b5e6-96231b3b80d8
unittests/Tooling/DiagnosticsYamlTest.cpp
unittests/Tooling/RefactoringActionRulesTest.cpp