clang-tools  17.0.0git
BitcodeReader.cpp
Go to the documentation of this file.
1 //===-- BitcodeReader.cpp - ClangDoc Bitcode Reader ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "BitcodeReader.h"
10 #include "llvm/ADT/IndexedMap.h"
11 #include "llvm/Support/Error.h"
12 #include "llvm/Support/raw_ostream.h"
13 #include <optional>
14 
15 namespace clang {
16 namespace doc {
17 
18 using Record = llvm::SmallVector<uint64_t, 1024>;
19 
20 // This implements decode for SmallString.
21 llvm::Error decodeRecord(const Record &R, llvm::SmallVectorImpl<char> &Field,
22  llvm::StringRef Blob) {
23  Field.assign(Blob.begin(), Blob.end());
24  return llvm::Error::success();
25 }
26 
27 llvm::Error decodeRecord(const Record &R, SymbolID &Field,
28  llvm::StringRef Blob) {
30  return llvm::createStringError(llvm::inconvertibleErrorCode(),
31  "incorrect USR size");
32 
33  // First position in the record is the length of the following array, so we
34  // copy the following elements to the field.
35  for (int I = 0, E = R[0]; I < E; ++I)
36  Field[I] = R[I + 1];
37  return llvm::Error::success();
38 }
39 
40 llvm::Error decodeRecord(const Record &R, bool &Field, llvm::StringRef Blob) {
41  Field = R[0] != 0;
42  return llvm::Error::success();
43 }
44 
45 llvm::Error decodeRecord(const Record &R, int &Field, llvm::StringRef Blob) {
46  if (R[0] > INT_MAX)
47  return llvm::createStringError(llvm::inconvertibleErrorCode(),
48  "integer too large to parse");
49  Field = (int)R[0];
50  return llvm::Error::success();
51 }
52 
53 llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
54  llvm::StringRef Blob) {
55  switch (R[0]) {
56  case AS_public:
57  case AS_private:
58  case AS_protected:
59  case AS_none:
60  Field = (AccessSpecifier)R[0];
61  return llvm::Error::success();
62  default:
63  return llvm::createStringError(llvm::inconvertibleErrorCode(),
64  "invalid value for AccessSpecifier");
65  }
66 }
67 
68 llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,
69  llvm::StringRef Blob) {
70  switch (R[0]) {
71  case TTK_Struct:
72  case TTK_Interface:
73  case TTK_Union:
74  case TTK_Class:
75  case TTK_Enum:
76  Field = (TagTypeKind)R[0];
77  return llvm::Error::success();
78  default:
79  return llvm::createStringError(llvm::inconvertibleErrorCode(),
80  "invalid value for TagTypeKind");
81  }
82 }
83 
84 llvm::Error decodeRecord(const Record &R, std::optional<Location> &Field,
85  llvm::StringRef Blob) {
86  if (R[0] > INT_MAX)
87  return llvm::createStringError(llvm::inconvertibleErrorCode(),
88  "integer too large to parse");
89  Field.emplace((int)R[0], Blob, (bool)R[1]);
90  return llvm::Error::success();
91 }
92 
93 llvm::Error decodeRecord(const Record &R, InfoType &Field,
94  llvm::StringRef Blob) {
95  switch (auto IT = static_cast<InfoType>(R[0])) {
100  case InfoType::IT_enum:
102  Field = IT;
103  return llvm::Error::success();
104  }
105  return llvm::createStringError(llvm::inconvertibleErrorCode(),
106  "invalid value for InfoType");
107 }
108 
109 llvm::Error decodeRecord(const Record &R, FieldId &Field,
110  llvm::StringRef Blob) {
111  switch (auto F = static_cast<FieldId>(R[0])) {
113  case FieldId::F_parent:
114  case FieldId::F_vparent:
115  case FieldId::F_type:
118  case FieldId::F_default:
119  Field = F;
120  return llvm::Error::success();
121  }
122  return llvm::createStringError(llvm::inconvertibleErrorCode(),
123  "invalid value for FieldId");
124 }
125 
126 llvm::Error decodeRecord(const Record &R,
127  llvm::SmallVectorImpl<llvm::SmallString<16>> &Field,
128  llvm::StringRef Blob) {
129  Field.push_back(Blob);
130  return llvm::Error::success();
131 }
132 
133 llvm::Error decodeRecord(const Record &R,
135  llvm::StringRef Blob) {
136  if (R[0] > INT_MAX)
137  return llvm::createStringError(llvm::inconvertibleErrorCode(),
138  "integer too large to parse");
139  Field.emplace_back((int)R[0], Blob, (bool)R[1]);
140  return llvm::Error::success();
141 }
142 
143 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
144  const unsigned VersionNo) {
145  if (ID == VERSION && R[0] == VersionNo)
146  return llvm::Error::success();
147  return llvm::createStringError(llvm::inconvertibleErrorCode(),
148  "mismatched bitcode version number");
149 }
150 
151 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
152  NamespaceInfo *I) {
153  switch (ID) {
154  case NAMESPACE_USR:
155  return decodeRecord(R, I->USR, Blob);
156  case NAMESPACE_NAME:
157  return decodeRecord(R, I->Name, Blob);
158  case NAMESPACE_PATH:
159  return decodeRecord(R, I->Path, Blob);
160  default:
161  return llvm::createStringError(llvm::inconvertibleErrorCode(),
162  "invalid field for NamespaceInfo");
163  }
164 }
165 
166 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
167  RecordInfo *I) {
168  switch (ID) {
169  case RECORD_USR:
170  return decodeRecord(R, I->USR, Blob);
171  case RECORD_NAME:
172  return decodeRecord(R, I->Name, Blob);
173  case RECORD_PATH:
174  return decodeRecord(R, I->Path, Blob);
175  case RECORD_DEFLOCATION:
176  return decodeRecord(R, I->DefLoc, Blob);
177  case RECORD_LOCATION:
178  return decodeRecord(R, I->Loc, Blob);
179  case RECORD_TAG_TYPE:
180  return decodeRecord(R, I->TagType, Blob);
181  case RECORD_IS_TYPE_DEF:
182  return decodeRecord(R, I->IsTypeDef, Blob);
183  default:
184  return llvm::createStringError(llvm::inconvertibleErrorCode(),
185  "invalid field for RecordInfo");
186  }
187 }
188 
189 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
190  BaseRecordInfo *I) {
191  switch (ID) {
192  case BASE_RECORD_USR:
193  return decodeRecord(R, I->USR, Blob);
194  case BASE_RECORD_NAME:
195  return decodeRecord(R, I->Name, Blob);
196  case BASE_RECORD_PATH:
197  return decodeRecord(R, I->Path, Blob);
199  return decodeRecord(R, I->TagType, Blob);
201  return decodeRecord(R, I->IsVirtual, Blob);
202  case BASE_RECORD_ACCESS:
203  return decodeRecord(R, I->Access, Blob);
205  return decodeRecord(R, I->IsParent, Blob);
206  default:
207  return llvm::createStringError(llvm::inconvertibleErrorCode(),
208  "invalid field for BaseRecordInfo");
209  }
210 }
211 
212 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
213  EnumInfo *I) {
214  switch (ID) {
215  case ENUM_USR:
216  return decodeRecord(R, I->USR, Blob);
217  case ENUM_NAME:
218  return decodeRecord(R, I->Name, Blob);
219  case ENUM_DEFLOCATION:
220  return decodeRecord(R, I->DefLoc, Blob);
221  case ENUM_LOCATION:
222  return decodeRecord(R, I->Loc, Blob);
223  case ENUM_SCOPED:
224  return decodeRecord(R, I->Scoped, Blob);
225  default:
226  return llvm::createStringError(llvm::inconvertibleErrorCode(),
227  "invalid field for EnumInfo");
228  }
229 }
230 
231 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
232  TypedefInfo *I) {
233  switch (ID) {
234  case TYPEDEF_USR:
235  return decodeRecord(R, I->USR, Blob);
236  case TYPEDEF_NAME:
237  return decodeRecord(R, I->Name, Blob);
238  case TYPEDEF_DEFLOCATION:
239  return decodeRecord(R, I->DefLoc, Blob);
240  case TYPEDEF_IS_USING:
241  return decodeRecord(R, I->IsUsing, Blob);
242  default:
243  return llvm::createStringError(llvm::inconvertibleErrorCode(),
244  "invalid field for TypedefInfo");
245  }
246 }
247 
248 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
249  EnumValueInfo *I) {
250  switch (ID) {
251  case ENUM_VALUE_NAME:
252  return decodeRecord(R, I->Name, Blob);
253  case ENUM_VALUE_VALUE:
254  return decodeRecord(R, I->Value, Blob);
255  case ENUM_VALUE_EXPR:
256  return decodeRecord(R, I->ValueExpr, Blob);
257  default:
258  return llvm::createStringError(llvm::inconvertibleErrorCode(),
259  "invalid field for EnumValueInfo");
260  }
261 }
262 
263 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
264  FunctionInfo *I) {
265  switch (ID) {
266  case FUNCTION_USR:
267  return decodeRecord(R, I->USR, Blob);
268  case FUNCTION_NAME:
269  return decodeRecord(R, I->Name, Blob);
271  return decodeRecord(R, I->DefLoc, Blob);
272  case FUNCTION_LOCATION:
273  return decodeRecord(R, I->Loc, Blob);
274  case FUNCTION_ACCESS:
275  return decodeRecord(R, I->Access, Blob);
276  case FUNCTION_IS_METHOD:
277  return decodeRecord(R, I->IsMethod, Blob);
278  default:
279  return llvm::createStringError(llvm::inconvertibleErrorCode(),
280  "invalid field for FunctionInfo");
281  }
282 }
283 
284 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
285  TypeInfo *I) {
286  return llvm::Error::success();
287 }
288 
289 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
290  FieldTypeInfo *I) {
291  switch (ID) {
292  case FIELD_TYPE_NAME:
293  return decodeRecord(R, I->Name, Blob);
294  case FIELD_DEFAULT_VALUE:
295  return decodeRecord(R, I->DefaultValue, Blob);
296  default:
297  return llvm::createStringError(llvm::inconvertibleErrorCode(),
298  "invalid field for TypeInfo");
299  }
300 }
301 
302 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
303  MemberTypeInfo *I) {
304  switch (ID) {
305  case MEMBER_TYPE_NAME:
306  return decodeRecord(R, I->Name, Blob);
307  case MEMBER_TYPE_ACCESS:
308  return decodeRecord(R, I->Access, Blob);
309  default:
310  return llvm::createStringError(llvm::inconvertibleErrorCode(),
311  "invalid field for MemberTypeInfo");
312  }
313 }
314 
315 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
316  CommentInfo *I) {
317  switch (ID) {
318  case COMMENT_KIND:
319  return decodeRecord(R, I->Kind, Blob);
320  case COMMENT_TEXT:
321  return decodeRecord(R, I->Text, Blob);
322  case COMMENT_NAME:
323  return decodeRecord(R, I->Name, Blob);
324  case COMMENT_DIRECTION:
325  return decodeRecord(R, I->Direction, Blob);
326  case COMMENT_PARAMNAME:
327  return decodeRecord(R, I->ParamName, Blob);
328  case COMMENT_CLOSENAME:
329  return decodeRecord(R, I->CloseName, Blob);
330  case COMMENT_ATTRKEY:
331  return decodeRecord(R, I->AttrKeys, Blob);
332  case COMMENT_ATTRVAL:
333  return decodeRecord(R, I->AttrValues, Blob);
334  case COMMENT_ARG:
335  return decodeRecord(R, I->Args, Blob);
336  case COMMENT_SELFCLOSING:
337  return decodeRecord(R, I->SelfClosing, Blob);
338  case COMMENT_EXPLICIT:
339  return decodeRecord(R, I->Explicit, Blob);
340  default:
341  return llvm::createStringError(llvm::inconvertibleErrorCode(),
342  "invalid field for CommentInfo");
343  }
344 }
345 
346 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
347  Reference *I, FieldId &F) {
348  switch (ID) {
349  case REFERENCE_USR:
350  return decodeRecord(R, I->USR, Blob);
351  case REFERENCE_NAME:
352  return decodeRecord(R, I->Name, Blob);
353  case REFERENCE_QUAL_NAME:
354  return decodeRecord(R, I->QualName, Blob);
355  case REFERENCE_TYPE:
356  return decodeRecord(R, I->RefType, Blob);
357  case REFERENCE_PATH:
358  return decodeRecord(R, I->Path, Blob);
359  case REFERENCE_FIELD:
360  return decodeRecord(R, F, Blob);
361  default:
362  return llvm::createStringError(llvm::inconvertibleErrorCode(),
363  "invalid field for Reference");
364  }
365 }
366 
367 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
368  TemplateInfo *I) {
369  // Currently there are no child records of TemplateInfo (only child blocks).
370  return llvm::createStringError(llvm::inconvertibleErrorCode(),
371  "invalid field for TemplateParamInfo");
372 }
373 
374 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
377  return decodeRecord(R, I->SpecializationOf, Blob);
378  return llvm::createStringError(llvm::inconvertibleErrorCode(),
379  "invalid field for TemplateParamInfo");
380 }
381 
382 llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
383  TemplateParamInfo *I) {
385  return decodeRecord(R, I->Contents, Blob);
386  return llvm::createStringError(llvm::inconvertibleErrorCode(),
387  "invalid field for TemplateParamInfo");
388 }
389 
390 template <typename T> llvm::Expected<CommentInfo *> getCommentInfo(T I) {
391  return llvm::createStringError(llvm::inconvertibleErrorCode(),
392  "invalid type cannot contain CommentInfo");
393 }
394 
395 template <> llvm::Expected<CommentInfo *> getCommentInfo(FunctionInfo *I) {
396  return &I->Description.emplace_back();
397 }
398 
399 template <> llvm::Expected<CommentInfo *> getCommentInfo(NamespaceInfo *I) {
400  return &I->Description.emplace_back();
401 }
402 
403 template <> llvm::Expected<CommentInfo *> getCommentInfo(RecordInfo *I) {
404  return &I->Description.emplace_back();
405 }
406 
407 template <> llvm::Expected<CommentInfo *> getCommentInfo(MemberTypeInfo *I) {
408  return &I->Description.emplace_back();
409 }
410 
411 template <> llvm::Expected<CommentInfo *> getCommentInfo(EnumInfo *I) {
412  return &I->Description.emplace_back();
413 }
414 
415 template <> llvm::Expected<CommentInfo *> getCommentInfo(TypedefInfo *I) {
416  return &I->Description.emplace_back();
417 }
418 
419 template <> llvm::Expected<CommentInfo *> getCommentInfo(CommentInfo *I) {
420  I->Children.emplace_back(std::make_unique<CommentInfo>());
421  return I->Children.back().get();
422 }
423 
424 template <>
425 llvm::Expected<CommentInfo *> getCommentInfo(std::unique_ptr<CommentInfo> &I) {
426  return getCommentInfo(I.get());
427 }
428 
429 // When readSubBlock encounters a TypeInfo sub-block, it calls addTypeInfo on
430 // the parent block to set it. The template specializations define what to do
431 // for each supported parent block.
432 template <typename T, typename TTypeInfo>
433 llvm::Error addTypeInfo(T I, TTypeInfo &&TI) {
434  return llvm::createStringError(llvm::inconvertibleErrorCode(),
435  "invalid type cannot contain TypeInfo");
436 }
437 
438 template <> llvm::Error addTypeInfo(RecordInfo *I, MemberTypeInfo &&T) {
439  I->Members.emplace_back(std::move(T));
440  return llvm::Error::success();
441 }
442 
443 template <> llvm::Error addTypeInfo(BaseRecordInfo *I, MemberTypeInfo &&T) {
444  I->Members.emplace_back(std::move(T));
445  return llvm::Error::success();
446 }
447 
448 template <> llvm::Error addTypeInfo(FunctionInfo *I, TypeInfo &&T) {
449  I->ReturnType = std::move(T);
450  return llvm::Error::success();
451 }
452 
453 template <> llvm::Error addTypeInfo(FunctionInfo *I, FieldTypeInfo &&T) {
454  I->Params.emplace_back(std::move(T));
455  return llvm::Error::success();
456 }
457 
458 template <> llvm::Error addTypeInfo(EnumInfo *I, TypeInfo &&T) {
459  I->BaseType = std::move(T);
460  return llvm::Error::success();
461 }
462 
463 template <> llvm::Error addTypeInfo(TypedefInfo *I, TypeInfo &&T) {
464  I->Underlying = std::move(T);
465  return llvm::Error::success();
466 }
467 
468 template <typename T> llvm::Error addReference(T I, Reference &&R, FieldId F) {
469  return llvm::createStringError(llvm::inconvertibleErrorCode(),
470  "invalid type cannot contain Reference");
471 }
472 
473 template <> llvm::Error addReference(TypeInfo *I, Reference &&R, FieldId F) {
474  switch (F) {
475  case FieldId::F_type:
476  I->Type = std::move(R);
477  return llvm::Error::success();
478  default:
479  return llvm::createStringError(llvm::inconvertibleErrorCode(),
480  "invalid type cannot contain Reference");
481  }
482 }
483 
484 template <>
485 llvm::Error addReference(FieldTypeInfo *I, Reference &&R, FieldId F) {
486  switch (F) {
487  case FieldId::F_type:
488  I->Type = std::move(R);
489  return llvm::Error::success();
490  default:
491  return llvm::createStringError(llvm::inconvertibleErrorCode(),
492  "invalid type cannot contain Reference");
493  }
494 }
495 
496 template <>
497 llvm::Error addReference(MemberTypeInfo *I, Reference &&R, FieldId F) {
498  switch (F) {
499  case FieldId::F_type:
500  I->Type = std::move(R);
501  return llvm::Error::success();
502  default:
503  return llvm::createStringError(llvm::inconvertibleErrorCode(),
504  "invalid type cannot contain Reference");
505  }
506 }
507 
508 template <> llvm::Error addReference(EnumInfo *I, Reference &&R, FieldId F) {
509  switch (F) {
511  I->Namespace.emplace_back(std::move(R));
512  return llvm::Error::success();
513  default:
514  return llvm::createStringError(llvm::inconvertibleErrorCode(),
515  "invalid type cannot contain Reference");
516  }
517 }
518 
519 template <> llvm::Error addReference(TypedefInfo *I, Reference &&R, FieldId F) {
520  switch (F) {
522  I->Namespace.emplace_back(std::move(R));
523  return llvm::Error::success();
524  default:
525  return llvm::createStringError(llvm::inconvertibleErrorCode(),
526  "invalid type cannot contain Reference");
527  }
528 }
529 
530 template <>
531 llvm::Error addReference(NamespaceInfo *I, Reference &&R, FieldId F) {
532  switch (F) {
534  I->Namespace.emplace_back(std::move(R));
535  return llvm::Error::success();
537  I->Children.Namespaces.emplace_back(std::move(R));
538  return llvm::Error::success();
540  I->Children.Records.emplace_back(std::move(R));
541  return llvm::Error::success();
542  default:
543  return llvm::createStringError(llvm::inconvertibleErrorCode(),
544  "invalid type cannot contain Reference");
545  }
546 }
547 
548 template <>
549 llvm::Error addReference(FunctionInfo *I, Reference &&R, FieldId F) {
550  switch (F) {
552  I->Namespace.emplace_back(std::move(R));
553  return llvm::Error::success();
554  case FieldId::F_parent:
555  I->Parent = std::move(R);
556  return llvm::Error::success();
557  default:
558  return llvm::createStringError(llvm::inconvertibleErrorCode(),
559  "invalid type cannot contain Reference");
560  }
561 }
562 
563 template <> llvm::Error addReference(RecordInfo *I, Reference &&R, FieldId F) {
564  switch (F) {
566  I->Namespace.emplace_back(std::move(R));
567  return llvm::Error::success();
568  case FieldId::F_parent:
569  I->Parents.emplace_back(std::move(R));
570  return llvm::Error::success();
571  case FieldId::F_vparent:
572  I->VirtualParents.emplace_back(std::move(R));
573  return llvm::Error::success();
575  I->Children.Records.emplace_back(std::move(R));
576  return llvm::Error::success();
577  default:
578  return llvm::createStringError(llvm::inconvertibleErrorCode(),
579  "invalid type cannot contain Reference");
580  }
581 }
582 
583 template <typename T, typename ChildInfoType>
584 void addChild(T I, ChildInfoType &&R) {
585  llvm::errs() << "invalid child type for info";
586  exit(1);
587 }
588 
589 // Namespace children:
590 template <> void addChild(NamespaceInfo *I, FunctionInfo &&R) {
591  I->Children.Functions.emplace_back(std::move(R));
592 }
593 template <> void addChild(NamespaceInfo *I, EnumInfo &&R) {
594  I->Children.Enums.emplace_back(std::move(R));
595 }
596 template <> void addChild(NamespaceInfo *I, TypedefInfo &&R) {
597  I->Children.Typedefs.emplace_back(std::move(R));
598 }
599 
600 // Record children:
601 template <> void addChild(RecordInfo *I, FunctionInfo &&R) {
602  I->Children.Functions.emplace_back(std::move(R));
603 }
604 template <> void addChild(RecordInfo *I, EnumInfo &&R) {
605  I->Children.Enums.emplace_back(std::move(R));
606 }
607 template <> void addChild(RecordInfo *I, TypedefInfo &&R) {
608  I->Children.Typedefs.emplace_back(std::move(R));
609 }
610 
611 // Other types of children:
612 template <> void addChild(EnumInfo *I, EnumValueInfo &&R) {
613  I->Members.emplace_back(std::move(R));
614 }
615 template <> void addChild(RecordInfo *I, BaseRecordInfo &&R) {
616  I->Bases.emplace_back(std::move(R));
617 }
618 template <> void addChild(BaseRecordInfo *I, FunctionInfo &&R) {
619  I->Children.Functions.emplace_back(std::move(R));
620 }
621 
622 // TemplateParam children. These go into either a TemplateInfo (for template
623 // parameters) or TemplateSpecializationInfo (for the specialization's
624 // parameters).
625 template <typename T> void addTemplateParam(T I, TemplateParamInfo &&P) {
626  llvm::errs() << "invalid container for template parameter";
627  exit(1);
628 }
630  I->Params.emplace_back(std::move(P));
631 }
632 template <>
634  I->Params.emplace_back(std::move(P));
635 }
636 
637 // Template info. These apply to either records or functions.
638 template <typename T> void addTemplate(T I, TemplateInfo &&P) {
639  llvm::errs() << "invalid container for template info";
640  exit(1);
641 }
642 template <> void addTemplate(RecordInfo *I, TemplateInfo &&P) {
643  I->Template.emplace(std::move(P));
644 }
645 template <> void addTemplate(FunctionInfo *I, TemplateInfo &&P) {
646  I->Template.emplace(std::move(P));
647 }
648 
649 // Template specializations go only into template records.
650 template <typename T>
652  llvm::errs() << "invalid container for template specialization info";
653  exit(1);
654 }
655 template <>
658  I->Specialization.emplace(std::move(TSI));
659 }
660 
661 // Read records from bitcode into a given info.
662 template <typename T>
663 llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) {
664  Record R;
665  llvm::StringRef Blob;
666  llvm::Expected<unsigned> MaybeRecID = Stream.readRecord(ID, R, &Blob);
667  if (!MaybeRecID)
668  return MaybeRecID.takeError();
669  return parseRecord(R, MaybeRecID.get(), Blob, I);
670 }
671 
672 template <>
673 llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {
674  Record R;
675  llvm::StringRef Blob;
676  llvm::Expected<unsigned> MaybeRecID = Stream.readRecord(ID, R, &Blob);
677  if (!MaybeRecID)
678  return MaybeRecID.takeError();
679  return parseRecord(R, MaybeRecID.get(), Blob, I, CurrentReferenceField);
680 }
681 
682 // Read a block of records into a single info.
683 template <typename T>
684 llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
685  if (llvm::Error Err = Stream.EnterSubBlock(ID))
686  return Err;
687 
688  while (true) {
689  unsigned BlockOrCode = 0;
690  Cursor Res = skipUntilRecordOrBlock(BlockOrCode);
691 
692  switch (Res) {
693  case Cursor::BadBlock:
694  return llvm::createStringError(llvm::inconvertibleErrorCode(),
695  "bad block found");
696  case Cursor::BlockEnd:
697  return llvm::Error::success();
698  case Cursor::BlockBegin:
699  if (llvm::Error Err = readSubBlock(BlockOrCode, I)) {
700  if (llvm::Error Skipped = Stream.SkipBlock())
701  return joinErrors(std::move(Err), std::move(Skipped));
702  return Err;
703  }
704  continue;
705  case Cursor::Record:
706  break;
707  }
708  if (auto Err = readRecord(BlockOrCode, I))
709  return Err;
710  }
711 }
712 
713 template <typename T>
714 llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
715  switch (ID) {
716  // Blocks can only have certain types of sub blocks.
717  case BI_COMMENT_BLOCK_ID: {
718  auto Comment = getCommentInfo(I);
719  if (!Comment)
720  return Comment.takeError();
721  if (auto Err = readBlock(ID, Comment.get()))
722  return Err;
723  return llvm::Error::success();
724  }
725  case BI_TYPE_BLOCK_ID: {
726  TypeInfo TI;
727  if (auto Err = readBlock(ID, &TI))
728  return Err;
729  if (auto Err = addTypeInfo(I, std::move(TI)))
730  return Err;
731  return llvm::Error::success();
732  }
733  case BI_FIELD_TYPE_BLOCK_ID: {
734  FieldTypeInfo TI;
735  if (auto Err = readBlock(ID, &TI))
736  return Err;
737  if (auto Err = addTypeInfo(I, std::move(TI)))
738  return Err;
739  return llvm::Error::success();
740  }
742  MemberTypeInfo TI;
743  if (auto Err = readBlock(ID, &TI))
744  return Err;
745  if (auto Err = addTypeInfo(I, std::move(TI)))
746  return Err;
747  return llvm::Error::success();
748  }
749  case BI_REFERENCE_BLOCK_ID: {
750  Reference R;
751  if (auto Err = readBlock(ID, &R))
752  return Err;
753  if (auto Err = addReference(I, std::move(R), CurrentReferenceField))
754  return Err;
755  return llvm::Error::success();
756  }
757  case BI_FUNCTION_BLOCK_ID: {
758  FunctionInfo F;
759  if (auto Err = readBlock(ID, &F))
760  return Err;
761  addChild(I, std::move(F));
762  return llvm::Error::success();
763  }
765  BaseRecordInfo BR;
766  if (auto Err = readBlock(ID, &BR))
767  return Err;
768  addChild(I, std::move(BR));
769  return llvm::Error::success();
770  }
771  case BI_ENUM_BLOCK_ID: {
772  EnumInfo E;
773  if (auto Err = readBlock(ID, &E))
774  return Err;
775  addChild(I, std::move(E));
776  return llvm::Error::success();
777  }
778  case BI_ENUM_VALUE_BLOCK_ID: {
779  EnumValueInfo EV;
780  if (auto Err = readBlock(ID, &EV))
781  return Err;
782  addChild(I, std::move(EV));
783  return llvm::Error::success();
784  }
785  case BI_TEMPLATE_BLOCK_ID: {
786  TemplateInfo TI;
787  if (auto Err = readBlock(ID, &TI))
788  return Err;
789  addTemplate(I, std::move(TI));
790  return llvm::Error::success();
791  }
793  TemplateSpecializationInfo TSI;
794  if (auto Err = readBlock(ID, &TSI))
795  return Err;
796  addTemplateSpecialization(I, std::move(TSI));
797  return llvm::Error::success();
798  }
800  TemplateParamInfo TPI;
801  if (auto Err = readBlock(ID, &TPI))
802  return Err;
803  addTemplateParam(I, std::move(TPI));
804  return llvm::Error::success();
805  }
806  case BI_TYPEDEF_BLOCK_ID: {
807  TypedefInfo TI;
808  if (auto Err = readBlock(ID, &TI))
809  return Err;
810  addChild(I, std::move(TI));
811  return llvm::Error::success();
812  }
813  default:
814  return llvm::createStringError(llvm::inconvertibleErrorCode(),
815  "invalid subblock type");
816  }
817 }
818 
819 ClangDocBitcodeReader::Cursor
820 ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) {
821  BlockOrRecordID = 0;
822 
823  while (!Stream.AtEndOfStream()) {
824  Expected<unsigned> MaybeCode = Stream.ReadCode();
825  if (!MaybeCode) {
826  // FIXME this drops the error on the floor.
827  consumeError(MaybeCode.takeError());
828  return Cursor::BadBlock;
829  }
830 
831  unsigned Code = MaybeCode.get();
832  if (Code >= static_cast<unsigned>(llvm::bitc::FIRST_APPLICATION_ABBREV)) {
833  BlockOrRecordID = Code;
834  return Cursor::Record;
835  }
836  switch (static_cast<llvm::bitc::FixedAbbrevIDs>(Code)) {
837  case llvm::bitc::ENTER_SUBBLOCK:
838  if (Expected<unsigned> MaybeID = Stream.ReadSubBlockID())
839  BlockOrRecordID = MaybeID.get();
840  else {
841  // FIXME this drops the error on the floor.
842  consumeError(MaybeID.takeError());
843  }
844  return Cursor::BlockBegin;
845  case llvm::bitc::END_BLOCK:
846  if (Stream.ReadBlockEnd())
847  return Cursor::BadBlock;
848  return Cursor::BlockEnd;
849  case llvm::bitc::DEFINE_ABBREV:
850  if (llvm::Error Err = Stream.ReadAbbrevRecord()) {
851  // FIXME this drops the error on the floor.
852  consumeError(std::move(Err));
853  }
854  continue;
855  case llvm::bitc::UNABBREV_RECORD:
856  return Cursor::BadBlock;
857  case llvm::bitc::FIRST_APPLICATION_ABBREV:
858  llvm_unreachable("Unexpected abbrev id.");
859  }
860  }
861  llvm_unreachable("Premature stream end.");
862 }
863 
864 llvm::Error ClangDocBitcodeReader::validateStream() {
865  if (Stream.AtEndOfStream())
866  return llvm::createStringError(llvm::inconvertibleErrorCode(),
867  "premature end of stream");
868 
869  // Sniff for the signature.
870  for (int Idx = 0; Idx != 4; ++Idx) {
871  Expected<llvm::SimpleBitstreamCursor::word_t> MaybeRead = Stream.Read(8);
872  if (!MaybeRead)
873  return MaybeRead.takeError();
874  else if (MaybeRead.get() != BitCodeConstants::Signature[Idx])
875  return llvm::createStringError(llvm::inconvertibleErrorCode(),
876  "invalid bitcode signature");
877  }
878  return llvm::Error::success();
879 }
880 
881 llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {
882  Expected<std::optional<llvm::BitstreamBlockInfo>> MaybeBlockInfo =
883  Stream.ReadBlockInfoBlock();
884  if (!MaybeBlockInfo)
885  return MaybeBlockInfo.takeError();
886  else
887  BlockInfo = MaybeBlockInfo.get();
888  if (!BlockInfo)
889  return llvm::createStringError(llvm::inconvertibleErrorCode(),
890  "unable to parse BlockInfoBlock");
891  Stream.setBlockInfo(&*BlockInfo);
892  return llvm::Error::success();
893 }
894 
895 template <typename T>
896 llvm::Expected<std::unique_ptr<Info>>
897 ClangDocBitcodeReader::createInfo(unsigned ID) {
898  std::unique_ptr<Info> I = std::make_unique<T>();
899  if (auto Err = readBlock(ID, static_cast<T *>(I.get())))
900  return std::move(Err);
901  return std::unique_ptr<Info>{std::move(I)};
902 }
903 
904 llvm::Expected<std::unique_ptr<Info>>
905 ClangDocBitcodeReader::readBlockToInfo(unsigned ID) {
906  switch (ID) {
908  return createInfo<NamespaceInfo>(ID);
909  case BI_RECORD_BLOCK_ID:
910  return createInfo<RecordInfo>(ID);
911  case BI_ENUM_BLOCK_ID:
912  return createInfo<EnumInfo>(ID);
913  case BI_TYPEDEF_BLOCK_ID:
914  return createInfo<TypedefInfo>(ID);
916  return createInfo<FunctionInfo>(ID);
917  default:
918  return llvm::createStringError(llvm::inconvertibleErrorCode(),
919  "cannot create info");
920  }
921 }
922 
923 // Entry point
924 llvm::Expected<std::vector<std::unique_ptr<Info>>>
926  std::vector<std::unique_ptr<Info>> Infos;
927  if (auto Err = validateStream())
928  return std::move(Err);
929 
930  // Read the top level blocks.
931  while (!Stream.AtEndOfStream()) {
932  Expected<unsigned> MaybeCode = Stream.ReadCode();
933  if (!MaybeCode)
934  return MaybeCode.takeError();
935  if (MaybeCode.get() != llvm::bitc::ENTER_SUBBLOCK)
936  return llvm::createStringError(llvm::inconvertibleErrorCode(),
937  "no blocks in input");
938  Expected<unsigned> MaybeID = Stream.ReadSubBlockID();
939  if (!MaybeID)
940  return MaybeID.takeError();
941  unsigned ID = MaybeID.get();
942  switch (ID) {
943  // NamedType and Comment blocks should not appear at the top level
944  case BI_TYPE_BLOCK_ID:
947  case BI_COMMENT_BLOCK_ID:
949  return llvm::createStringError(llvm::inconvertibleErrorCode(),
950  "invalid top level block");
952  case BI_RECORD_BLOCK_ID:
953  case BI_ENUM_BLOCK_ID:
954  case BI_TYPEDEF_BLOCK_ID:
955  case BI_FUNCTION_BLOCK_ID: {
956  auto InfoOrErr = readBlockToInfo(ID);
957  if (!InfoOrErr)
958  return InfoOrErr.takeError();
959  Infos.emplace_back(std::move(InfoOrErr.get()));
960  continue;
961  }
962  case BI_VERSION_BLOCK_ID:
963  if (auto Err = readBlock(ID, VersionNumber))
964  return std::move(Err);
965  continue;
966  case llvm::bitc::BLOCKINFO_BLOCK_ID:
967  if (auto Err = readBlockInfoBlock())
968  return std::move(Err);
969  continue;
970  default:
971  if (llvm::Error Err = Stream.SkipBlock()) {
972  // FIXME this drops the error on the floor.
973  consumeError(std::move(Err));
974  }
975  continue;
976  }
977  }
978  return std::move(Infos);
979 }
980 
981 } // namespace doc
982 } // namespace clang
clang::doc::EnumValueInfo
Definition: Representation.h:413
clang::doc::FieldId::F_type
@ F_type
clang::doc::BI_VERSION_BLOCK_ID
@ BI_VERSION_BLOCK_ID
Definition: BitcodeWriter.h:54
clang::doc::FieldId::F_child_record
@ F_child_record
clang::doc::BaseRecordInfo::Access
AccessSpecifier Access
Definition: Representation.h:408
clang::doc::MemberTypeInfo::Description
std::vector< CommentInfo > Description
Definition: Representation.h:234
clang::doc::FieldId::F_default
@ F_default
clang::doc::TypedefInfo
Definition: Representation.h:384
clang::doc::EnumInfo::Members
llvm::SmallVector< EnumValueInfo, 4 > Members
Definition: Representation.h:452
clang::doc::addTemplateParam
void addTemplateParam(T I, TemplateParamInfo &&P)
Definition: BitcodeReader.cpp:625
clang::doc::RecordInfo::IsTypeDef
bool IsTypeDef
Definition: Representation.h:366
clang::doc::Info::Description
std::vector< CommentInfo > Description
Definition: Representation.h:279
clang::doc::BI_FUNCTION_BLOCK_ID
@ BI_FUNCTION_BLOCK_ID
Definition: BitcodeWriter.h:63
clang::doc::TemplateInfo::Specialization
std::optional< TemplateSpecializationInfo > Specialization
Definition: Representation.h:195
E
const Expr * E
Definition: AvoidBindCheck.cpp:86
clang::doc::FIELD_DEFAULT_VALUE
@ FIELD_DEFAULT_VALUE
Definition: BitcodeWriter.h:96
clang::doc::InfoType::IT_enum
@ IT_enum
clang::doc::FUNCTION_DEFLOCATION
@ FUNCTION_DEFLOCATION
Definition: BitcodeWriter.h:80
clang::doc::Info::Name
SmallString< 16 > Name
Definition: Representation.h:276
clang::doc::parseRecord
llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob, const unsigned VersionNo)
Definition: BitcodeReader.cpp:143
clang::doc::RECORD_IS_TYPE_DEF
@ RECORD_IS_TYPE_DEF
Definition: BitcodeWriter.h:116
clang::doc::InfoType::IT_namespace
@ IT_namespace
clang::doc::COMMENT_CLOSENAME
@ COMMENT_CLOSENAME
Definition: BitcodeWriter.h:89
clang::doc::ENUM_VALUE_NAME
@ ENUM_VALUE_NAME
Definition: BitcodeWriter.h:107
clang::doc::FunctionInfo
Definition: Representation.h:319
clang::doc::COMMENT_NAME
@ COMMENT_NAME
Definition: BitcodeWriter.h:86
clang::doc::Reference::Path
llvm::SmallString< 128 > Path
Definition: Representation.h:131
clang::doc::FieldTypeInfo::Name
SmallString< 16 > Name
Definition: Representation.h:210
clang::doc::InfoType
InfoType
Definition: Representation.h:39
clang::doc::RECORD_LOCATION
@ RECORD_LOCATION
Definition: BitcodeWriter.h:114
clang::doc::TypedefInfo::IsUsing
bool IsUsing
Definition: Representation.h:396
clang::doc::COMMENT_PARAMNAME
@ COMMENT_PARAMNAME
Definition: BitcodeWriter.h:88
clang::doc::CommentInfo
Definition: Representation.h:49
clang::doc::FieldId::F_child_namespace
@ F_child_namespace
clang::doc::BI_BASE_RECORD_BLOCK_ID
@ BI_BASE_RECORD_BLOCK_ID
Definition: BitcodeWriter.h:62
clang::doc::Reference::Name
SmallString< 16 > Name
Definition: Representation.h:119
clang::doc::ENUM_NAME
@ ENUM_NAME
Definition: BitcodeWriter.h:103
clang::doc::COMMENT_EXPLICIT
@ COMMENT_EXPLICIT
Definition: BitcodeWriter.h:91
clang::doc::BI_MEMBER_TYPE_BLOCK_ID
@ BI_MEMBER_TYPE_BLOCK_ID
Definition: BitcodeWriter.h:60
clang::doc::InfoType::IT_function
@ IT_function
clang::doc::InfoType::IT_typedef
@ IT_typedef
clang::doc::EnumInfo
Definition: Representation.h:438
clang::doc::CommentInfo::CloseName
SmallString< 16 > CloseName
Definition: Representation.h:73
clang::doc::decodeRecord
llvm::Error decodeRecord(const Record &R, llvm::SmallVectorImpl< char > &Field, llvm::StringRef Blob)
Definition: BitcodeReader.cpp:21
clang::doc::ScopeChildren::Typedefs
std::vector< TypedefInfo > Typedefs
Definition: Representation.h:147
clang::doc::addChild
void addChild(T I, ChildInfoType &&R)
Definition: BitcodeReader.cpp:584
clang::doc::CommentInfo::Kind
SmallString< 16 > Kind
Definition: Representation.h:64
clang::doc::ScopeChildren::Functions
std::vector< FunctionInfo > Functions
Definition: Representation.h:145
clang::doc::ENUM_USR
@ ENUM_USR
Definition: BitcodeWriter.h:102
clang::doc::BASE_RECORD_PATH
@ BASE_RECORD_PATH
Definition: BitcodeWriter.h:119
clang::doc::CommentInfo::Direction
SmallString< 8 > Direction
Definition: Representation.h:71
clang::doc::CommentInfo::Explicit
bool Explicit
Definition: Representation.h:75
clang::doc::TemplateInfo::Params
std::vector< TemplateParamInfo > Params
Definition: Representation.h:192
clang::doc::RecordInfo::VirtualParents
llvm::SmallVector< Reference, 4 > VirtualParents
Definition: Representation.h:374
clang::doc::BI_ENUM_VALUE_BLOCK_ID
@ BI_ENUM_VALUE_BLOCK_ID
Definition: BitcodeWriter.h:57
clang::doc::RECORD_PATH
@ RECORD_PATH
Definition: BitcodeWriter.h:112
clang::doc::CommentInfo::Name
SmallString< 16 > Name
Definition: Representation.h:70
clang::doc::NAMESPACE_USR
@ NAMESPACE_USR
Definition: BitcodeWriter.h:99
clang::doc::BitCodeConstants::USRHashSize
static constexpr int USRHashSize
Definition: BitcodeWriter.h:48
clang::doc::BaseRecordInfo
Definition: Representation.h:399
clang::tidy::misc::VariableCategory::Reference
@ Reference
clang::doc::RecordInfo::Members
llvm::SmallVector< MemberTypeInfo, 4 > Members
Definition: Representation.h:369
clang::doc::ENUM_SCOPED
@ ENUM_SCOPED
Definition: BitcodeWriter.h:106
clang::doc::Reference::QualName
SmallString< 16 > QualName
Definition: Representation.h:124
clang::doc::REFERENCE_PATH
@ REFERENCE_PATH
Definition: BitcodeWriter.h:128
clang::doc::FieldId::F_namespace
@ F_namespace
clang::doc::SymbolInfo::DefLoc
std::optional< Location > DefLoc
Definition: Representation.h:313
clang::doc::RecordInfo::Bases
std::vector< BaseRecordInfo > Bases
Definition: Representation.h:377
clang::doc::CommentInfo::ParamName
SmallString< 16 > ParamName
Definition: Representation.h:72
clang::doc::TYPEDEF_NAME
@ TYPEDEF_NAME
Definition: BitcodeWriter.h:133
clang::doc::TEMPLATE_SPECIALIZATION_OF
@ TEMPLATE_SPECIALIZATION_OF
Definition: BitcodeWriter.h:131
clang::doc::TemplateParamInfo::Contents
SmallString< 16 > Contents
Definition: Representation.h:177
clang::doc::MEMBER_TYPE_ACCESS
@ MEMBER_TYPE_ACCESS
Definition: BitcodeWriter.h:98
clang::doc::Info::Path
llvm::SmallString< 128 > Path
Definition: Representation.h:280
clang::doc::TEMPLATE_PARAM_CONTENTS
@ TEMPLATE_PARAM_CONTENTS
Definition: BitcodeWriter.h:130
clang::doc::CommentInfo::Children
std::vector< std::unique_ptr< CommentInfo > > Children
Definition: Representation.h:84
clang::doc::ScopeChildren::Namespaces
std::vector< Reference > Namespaces
Definition: Representation.h:143
clang::doc::InfoType::IT_record
@ IT_record
clang::doc::CommentInfo::AttrKeys
llvm::SmallVector< SmallString< 16 >, 4 > AttrKeys
Definition: Representation.h:78
clang::doc::FunctionInfo::Parent
Reference Parent
Definition: Representation.h:326
clang::doc::TYPEDEF_IS_USING
@ TYPEDEF_IS_USING
Definition: BitcodeWriter.h:135
clang::doc::getCommentInfo
llvm::Expected< CommentInfo * > getCommentInfo(T I)
Definition: BitcodeReader.cpp:390
clang::doc::EnumValueInfo::ValueExpr
SmallString< 16 > ValueExpr
Definition: Representation.h:433
clang::doc::EnumValueInfo::Value
SmallString< 16 > Value
Definition: Representation.h:429
TypeInfo
QualType TypeInfo
Definition: ExtractFunction.cpp:347
Code
std::string Code
Definition: FindTargetTests.cpp:67
clang::doc::BASE_RECORD_IS_PARENT
@ BASE_RECORD_IS_PARENT
Definition: BitcodeWriter.h:123
clang::doc::addReference
llvm::Error addReference(T I, Reference &&R, FieldId F)
Definition: BitcodeReader.cpp:468
clang::doc::FUNCTION_USR
@ FUNCTION_USR
Definition: BitcodeWriter.h:78
clang::doc::NAMESPACE_PATH
@ NAMESPACE_PATH
Definition: BitcodeWriter.h:101
clang::doc::TYPEDEF_DEFLOCATION
@ TYPEDEF_DEFLOCATION
Definition: BitcodeWriter.h:134
clang::doc::FieldId::F_vparent
@ F_vparent
clang::doc::CommentInfo::Text
SmallString< 64 > Text
Definition: Representation.h:69
clang::doc::RecordInfo::Children
ScopeChildren Children
Definition: Representation.h:380
clang::doc::BASE_RECORD_USR
@ BASE_RECORD_USR
Definition: BitcodeWriter.h:117
clang::doc::RecordInfo::Template
std::optional< TemplateInfo > Template
Definition: Representation.h:360
clang::doc::SymbolInfo::Loc
llvm::SmallVector< Location, 2 > Loc
Definition: Representation.h:314
clang::doc::TYPEDEF_USR
@ TYPEDEF_USR
Definition: BitcodeWriter.h:132
clang::doc::COMMENT_DIRECTION
@ COMMENT_DIRECTION
Definition: BitcodeWriter.h:87
clang::doc::RecordInfo::Parents
llvm::SmallVector< Reference, 4 > Parents
Definition: Representation.h:370
clang::doc::MemberTypeInfo::Access
AccessSpecifier Access
Definition: Representation.h:232
clang::doc::RECORD_USR
@ RECORD_USR
Definition: BitcodeWriter.h:110
clang::doc::BaseRecordInfo::IsVirtual
bool IsVirtual
Definition: Representation.h:405
clang::doc::REFERENCE_FIELD
@ REFERENCE_FIELD
Definition: BitcodeWriter.h:129
clang::doc::REFERENCE_NAME
@ REFERENCE_NAME
Definition: BitcodeWriter.h:125
clang::doc::TypedefInfo::Underlying
TypeInfo Underlying
Definition: Representation.h:390
clang::doc::Info::USR
SymbolID USR
Definition: Representation.h:273
clang::doc::FunctionInfo::Access
AccessSpecifier Access
Definition: Representation.h:333
clang::doc::FunctionInfo::Params
llvm::SmallVector< FieldTypeInfo, 4 > Params
Definition: Representation.h:328
clang::doc::RECORD_NAME
@ RECORD_NAME
Definition: BitcodeWriter.h:111
clang::doc::InfoType::IT_default
@ IT_default
clang::doc::SymbolID
std::array< uint8_t, 20 > SymbolID
Definition: Representation.h:31
clang::doc::ScopeChildren::Enums
std::vector< EnumInfo > Enums
Definition: Representation.h:146
clang::doc::REFERENCE_USR
@ REFERENCE_USR
Definition: BitcodeWriter.h:124
clang::doc::TemplateParamInfo
Definition: Representation.h:170
clang::doc::RecordInfo
Definition: Representation.h:346
clang::doc::BitCodeConstants::Signature
static constexpr unsigned char Signature[4]
Definition: BitcodeWriter.h:47
clang::doc::ENUM_VALUE_VALUE
@ ENUM_VALUE_VALUE
Definition: BitcodeWriter.h:108
clang::doc::ENUM_LOCATION
@ ENUM_LOCATION
Definition: BitcodeWriter.h:105
clang::doc::TemplateInfo
Definition: Representation.h:190
clang::doc::BASE_RECORD_IS_VIRTUAL
@ BASE_RECORD_IS_VIRTUAL
Definition: BitcodeWriter.h:121
clang::doc::BaseRecordInfo::IsParent
bool IsParent
Definition: Representation.h:409
clang::doc::BASE_RECORD_TAG_TYPE
@ BASE_RECORD_TAG_TYPE
Definition: BitcodeWriter.h:120
clang::doc::TemplateSpecializationInfo
Definition: Representation.h:180
clang::doc::TypeInfo::Type
Reference Type
Definition: Representation.h:162
clang::doc::BI_COMMENT_BLOCK_ID
@ BI_COMMENT_BLOCK_ID
Definition: BitcodeWriter.h:64
clang::doc::addTypeInfo
llvm::Error addTypeInfo(T I, TTypeInfo &&TI)
Definition: BitcodeReader.cpp:433
clang::doc::BASE_RECORD_ACCESS
@ BASE_RECORD_ACCESS
Definition: BitcodeWriter.h:122
clang::doc::COMMENT_SELFCLOSING
@ COMMENT_SELFCLOSING
Definition: BitcodeWriter.h:90
clang::doc::Reference::USR
SymbolID USR
Definition: Representation.h:114
clang::doc::Reference
Definition: Representation.h:87
clang::doc::BI_RECORD_BLOCK_ID
@ BI_RECORD_BLOCK_ID
Definition: BitcodeWriter.h:61
clang::doc::FieldTypeInfo::DefaultValue
SmallString< 16 > DefaultValue
Definition: Representation.h:214
clang::doc::BI_REFERENCE_BLOCK_ID
@ BI_REFERENCE_BLOCK_ID
Definition: BitcodeWriter.h:65
clang::doc::TemplateSpecializationInfo::Params
std::vector< TemplateParamInfo > Params
Definition: Representation.h:185
clang::doc::REFERENCE_TYPE
@ REFERENCE_TYPE
Definition: BitcodeWriter.h:127
clang::doc::FIELD_TYPE_NAME
@ FIELD_TYPE_NAME
Definition: BitcodeWriter.h:95
clang::doc::ENUM_DEFLOCATION
@ ENUM_DEFLOCATION
Definition: BitcodeWriter.h:104
clang::doc::ScopeChildren::Records
std::vector< Reference > Records
Definition: Representation.h:144
clang::doc::VERSION
@ VERSION
Definition: BitcodeWriter.h:77
clang::doc::BI_TEMPLATE_PARAM_BLOCK_ID
@ BI_TEMPLATE_PARAM_BLOCK_ID
Definition: BitcodeWriter.h:68
ID
static char ID
Definition: Logger.cpp:74
clang::doc::NamespaceInfo::Children
ScopeChildren Children
Definition: Representation.h:302
clang::doc::Reference::RefType
InfoType RefType
Definition: Representation.h:126
clang::doc::VersionNumber
static const unsigned VersionNumber
Definition: BitcodeWriter.h:33
clang::doc::FUNCTION_LOCATION
@ FUNCTION_LOCATION
Definition: BitcodeWriter.h:81
clang::doc::addTemplateSpecialization
void addTemplateSpecialization(T I, TemplateSpecializationInfo &&TSI)
Definition: BitcodeReader.cpp:651
clang::doc::BI_FIELD_TYPE_BLOCK_ID
@ BI_FIELD_TYPE_BLOCK_ID
Definition: BitcodeWriter.h:59
clang::doc::COMMENT_ATTRVAL
@ COMMENT_ATTRVAL
Definition: BitcodeWriter.h:93
clang::doc::CommentInfo::SelfClosing
bool SelfClosing
Definition: Representation.h:74
clang::doc::MEMBER_TYPE_NAME
@ MEMBER_TYPE_NAME
Definition: BitcodeWriter.h:97
clang::doc::FunctionInfo::ReturnType
TypeInfo ReturnType
Definition: Representation.h:327
clang::doc::BASE_RECORD_NAME
@ BASE_RECORD_NAME
Definition: BitcodeWriter.h:118
clang::doc::EnumInfo::BaseType
std::optional< TypeInfo > BaseType
Definition: Representation.h:450
clang::doc::COMMENT_TEXT
@ COMMENT_TEXT
Definition: BitcodeWriter.h:85
clang::doc::BI_TEMPLATE_BLOCK_ID
@ BI_TEMPLATE_BLOCK_ID
Definition: BitcodeWriter.h:66
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::doc::NamespaceInfo
Definition: Representation.h:296
clang::doc::FieldId::F_parent
@ F_parent
clang::doc::RECORD_TAG_TYPE
@ RECORD_TAG_TYPE
Definition: BitcodeWriter.h:115
clang::doc::FUNCTION_NAME
@ FUNCTION_NAME
Definition: BitcodeWriter.h:79
clang::doc::COMMENT_ATTRKEY
@ COMMENT_ATTRKEY
Definition: BitcodeWriter.h:92
clang::doc::EnumValueInfo::Name
SmallString< 16 > Name
Definition: Representation.h:424
clang::doc::BI_TEMPLATE_SPECIALIZATION_BLOCK_ID
@ BI_TEMPLATE_SPECIALIZATION_BLOCK_ID
Definition: BitcodeWriter.h:67
clang::doc::Record
llvm::SmallVector< uint64_t, 1024 > Record
Definition: BitcodeReader.cpp:18
clang::doc::RecordInfo::TagType
TagTypeKind TagType
Definition: Representation.h:353
clang::doc::TypeInfo
Definition: Representation.h:151
clang::doc::CommentInfo::AttrValues
llvm::SmallVector< SmallString< 16 >, 4 > AttrValues
Definition: Representation.h:80
clang::doc::FunctionInfo::Template
std::optional< TemplateInfo > Template
Definition: Representation.h:340
clang::doc::BI_NAMESPACE_BLOCK_ID
@ BI_NAMESPACE_BLOCK_ID
Definition: BitcodeWriter.h:55
clang::doc::RECORD_DEFLOCATION
@ RECORD_DEFLOCATION
Definition: BitcodeWriter.h:113
Field
const FieldDecl * Field
Definition: MemberwiseConstructor.cpp:260
clang::doc::CommentInfo::Args
llvm::SmallVector< SmallString< 16 >, 4 > Args
Definition: Representation.h:82
clang::doc::ClangDocBitcodeReader::readBitcode
llvm::Expected< std::vector< std::unique_ptr< Info > > > readBitcode()
Definition: BitcodeReader.cpp:925
llvm::SmallVectorImpl
Definition: NoLintDirectiveHandler.h:21
clang::doc::COMMENT_KIND
@ COMMENT_KIND
Definition: BitcodeWriter.h:84
clang::doc::COMMENT_ARG
@ COMMENT_ARG
Definition: BitcodeWriter.h:94
clang::doc::ENUM_VALUE_EXPR
@ ENUM_VALUE_EXPR
Definition: BitcodeWriter.h:109
BitcodeReader.h
clang::doc::FieldTypeInfo
Definition: Representation.h:199
clang::doc::FUNCTION_IS_METHOD
@ FUNCTION_IS_METHOD
Definition: BitcodeWriter.h:83
clang::doc::BI_TYPEDEF_BLOCK_ID
@ BI_TYPEDEF_BLOCK_ID
Definition: BitcodeWriter.h:69
clang::doc::MemberTypeInfo
Definition: Representation.h:218
clang::doc::REFERENCE_QUAL_NAME
@ REFERENCE_QUAL_NAME
Definition: BitcodeWriter.h:126
clang::doc::BI_TYPE_BLOCK_ID
@ BI_TYPE_BLOCK_ID
Definition: BitcodeWriter.h:58
clang::doc::Info::Namespace
llvm::SmallVector< Reference, 4 > Namespace
Definition: Representation.h:278
clang::doc::addTemplate
void addTemplate(T I, TemplateInfo &&P)
Definition: BitcodeReader.cpp:638
clang::doc::BI_ENUM_BLOCK_ID
@ BI_ENUM_BLOCK_ID
Definition: BitcodeWriter.h:56
clang::doc::FieldId
FieldId
Definition: BitcodeWriter.h:144
clang::doc::EnumInfo::Scoped
bool Scoped
Definition: Representation.h:445
clang::doc::FUNCTION_ACCESS
@ FUNCTION_ACCESS
Definition: BitcodeWriter.h:82
clang::doc::TemplateSpecializationInfo::SpecializationOf
SymbolID SpecializationOf
Definition: Representation.h:182
clang::doc::FunctionInfo::IsMethod
bool IsMethod
Definition: Representation.h:325
clang::doc::NAMESPACE_NAME
@ NAMESPACE_NAME
Definition: BitcodeWriter.h:100