24 #include "llvm/Support/Error.h" 34 llvm::Expected<std::unique_ptr<Info>>
35 reduce(std::vector<std::unique_ptr<Info>> &Values) {
37 return llvm::make_error<llvm::StringError>(
" No values to reduce.\n",
38 llvm::inconvertibleErrorCode());
39 std::unique_ptr<Info> Merged = llvm::make_unique<T>(Values[0]->USR);
40 T *Tmp =
static_cast<T *
>(Merged.get());
41 for (
auto &I : Values)
42 Tmp->merge(std::move(*static_cast<T *>(I.get())));
43 return std::move(Merged);
49 int getChildIndexIfExists(std::vector<T> &Children, T &ChildToMerge) {
50 for (
unsigned long I = 0; I < Children.size(); I++) {
51 if (ChildToMerge.USR == Children[I].USR)
59 void reduceChildren(std::vector<Reference> &Children,
60 std::vector<Reference> &&ChildrenToMerge) {
61 for (
auto &ChildToMerge : ChildrenToMerge) {
62 if (getChildIndexIfExists(Children, ChildToMerge) == -1)
63 Children.push_back(std::move(ChildToMerge));
67 void reduceChildren(std::vector<FunctionInfo> &Children,
68 std::vector<FunctionInfo> &&ChildrenToMerge) {
69 for (
auto &ChildToMerge : ChildrenToMerge) {
70 int mergeIdx = getChildIndexIfExists(Children, ChildToMerge);
72 Children.push_back(std::move(ChildToMerge));
75 Children[mergeIdx].merge(std::move(ChildToMerge));
79 void reduceChildren(std::vector<EnumInfo> &Children,
80 std::vector<EnumInfo> &&ChildrenToMerge) {
81 for (
auto &ChildToMerge : ChildrenToMerge) {
82 int mergeIdx = getChildIndexIfExists(Children, ChildToMerge);
84 Children.push_back(std::move(ChildToMerge));
87 Children[mergeIdx].merge(std::move(ChildToMerge));
94 llvm::Expected<std::unique_ptr<Info>>
97 return llvm::make_error<llvm::StringError>(
"No info values to merge.\n",
98 llvm::inconvertibleErrorCode());
100 switch (Values[0]->IT) {
102 return reduce<NamespaceInfo>(Values);
104 return reduce<RecordInfo>(Values);
106 return reduce<EnumInfo>(Values);
108 return reduce<FunctionInfo>(Values);
110 return llvm::make_error<llvm::StringError>(
"Unexpected info type.\n",
111 llvm::inconvertibleErrorCode());
124 std::move(Other.Description.begin(), Other.Description.end(),
135 DefLoc = std::move(Other.DefLoc);
137 std::move(Other.Loc.begin(), Other.Loc.end(), std::back_inserter(
Loc));
144 reduceChildren(ChildNamespaces, std::move(Other.ChildNamespaces));
145 reduceChildren(ChildRecords, std::move(Other.ChildRecords));
146 reduceChildren(ChildFunctions, std::move(Other.ChildFunctions));
147 reduceChildren(ChildEnums, std::move(Other.ChildEnums));
154 TagType = Other.TagType;
156 Members = std::move(Other.Members);
158 Parents = std::move(Other.Parents);
159 if (VirtualParents.empty())
160 VirtualParents = std::move(Other.VirtualParents);
162 reduceChildren(ChildRecords, std::move(Other.ChildRecords));
163 reduceChildren(ChildFunctions, std::move(Other.ChildFunctions));
164 reduceChildren(ChildEnums, std::move(Other.ChildEnums));
171 Scoped = Other.Scoped;
173 Members = std::move(Other.Members);
180 IsMethod = Other.IsMethod;
182 Access = Other.Access;
185 if (Parent.USR == EmptySID && Parent.Name ==
"")
186 Parent = std::move(Other.Parent);
188 Params = std::move(Other.Params);
SourceLocation Loc
'#' location in the include directive
llvm::SmallVector< Reference, 4 > Namespace
static const SymbolID EmptySID
void merge(NamespaceInfo &&I)
bool mergeable(const Info &Other)
std::vector< CommentInfo > Description
llvm::Expected< std::unique_ptr< Info > > mergeInfos(std::vector< std::unique_ptr< Info >> &Values)
void merge(SymbolInfo &&I)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void merge(FunctionInfo &&I)
std::array< uint8_t, 20 > SymbolID
void merge(RecordInfo &&I)