[clang-tools-extra] r346884 - [Support] Teach YAMLIO about polymorphic types

Scott Linder via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 14 11:40:00 PST 2018


Author: scott.linder
Date: Wed Nov 14 11:39:59 2018
New Revision: 346884

URL: http://llvm.org/viewvc/llvm-project?rev=346884&view=rev
Log:
[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

Modified:
    clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp?rev=346884&r1=346883&r2=346884&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-doc/YAMLGeneratorTest.cpp Wed Nov 14 11:39:59 2018
@@ -58,7 +58,7 @@ ChildRecords:
 ChildFunctions:  
   - USR:             '0000000000000000000000000000000000000000'
     Name:            'OneFunction'
-    ReturnType:      
+    ReturnType:      {}
 ChildEnums:      
   - USR:             '0000000000000000000000000000000000000000'
     Name:            'OneEnum'
@@ -123,7 +123,7 @@ ChildRecords:
 ChildFunctions:  
   - USR:             '0000000000000000000000000000000000000000'
     Name:            'OneFunction'
-    ReturnType:      
+    ReturnType:      {}
 ChildEnums:      
   - USR:             '0000000000000000000000000000000000000000'
     Name:            'OneEnum'




More information about the cfe-commits mailing list