Skip to content

Commit 1f55f19

Browse files
committed
[APINotes] Support C++ namespaces as top-level items
Namespaces are not read or written just yet. rdar://113403829
1 parent 6f488fe commit 1f55f19

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

clang/lib/APINotes/APINotesYAMLCompiler.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ template <> struct MappingTraits<Typedef> {
608608
} // namespace llvm
609609

610610
namespace {
611+
struct Namespace;
612+
typedef std::vector<Namespace> NamespacesSeq;
613+
611614
struct TopLevelItems {
612615
ClassesSeq Classes;
613616
ClassesSeq Protocols;
@@ -616,6 +619,7 @@ struct TopLevelItems {
616619
EnumConstantsSeq EnumConstants;
617620
TagsSeq Tags;
618621
TypedefsSeq Typedefs;
622+
NamespacesSeq Namespaces;
619623
};
620624
} // namespace
621625

@@ -629,10 +633,39 @@ static void mapTopLevelItems(IO &IO, TopLevelItems &TLI) {
629633
IO.mapOptional("Enumerators", TLI.EnumConstants);
630634
IO.mapOptional("Tags", TLI.Tags);
631635
IO.mapOptional("Typedefs", TLI.Typedefs);
636+
IO.mapOptional("Namespaces", TLI.Namespaces);
632637
}
633638
} // namespace yaml
634639
} // namespace llvm
635640

641+
namespace {
642+
struct Namespace {
643+
StringRef Name;
644+
AvailabilityItem Availability;
645+
StringRef SwiftName;
646+
llvm::Optional<bool> SwiftPrivate;
647+
TopLevelItems Items;
648+
};
649+
} // namespace
650+
651+
LLVM_YAML_IS_SEQUENCE_VECTOR(Namespace)
652+
653+
namespace llvm {
654+
namespace yaml {
655+
template <> struct MappingTraits<Namespace> {
656+
static void mapping(IO &IO, Namespace &T) {
657+
IO.mapRequired("Name", T.Name);
658+
IO.mapOptional("Availability", T.Availability.Mode,
659+
APIAvailability::Available);
660+
IO.mapOptional("AvailabilityMsg", T.Availability.Msg, StringRef(""));
661+
IO.mapOptional("SwiftPrivate", T.SwiftPrivate);
662+
IO.mapOptional("SwiftName", T.SwiftName, StringRef(""));
663+
mapTopLevelItems(IO, T.Items);
664+
}
665+
};
666+
} // namespace yaml
667+
} // namespace llvm
668+
636669
namespace {
637670
struct Versioned {
638671
VersionTuple Version;

0 commit comments

Comments
 (0)