llvm/clang-tools-extra/clang-doc/BitcodeReader.cpp

//===--  BitcodeReader.cpp - ClangDoc Bitcode Reader ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "BitcodeReader.h"
#include "llvm/ADT/IndexedMap.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

namespace clang {
namespace doc {

Record;

// This implements decode for SmallString.
llvm::Error decodeRecord(const Record &R, llvm::SmallVectorImpl<char> &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, SymbolID &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, bool &Field, llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, int &Field, llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, std::optional<Location> &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, InfoType &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R, FieldId &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R,
                         llvm::SmallVectorImpl<llvm::SmallString<16>> &Field,
                         llvm::StringRef Blob) {}

llvm::Error decodeRecord(const Record &R,
                         llvm::SmallVectorImpl<Location> &Field,
                         llvm::StringRef Blob) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        const unsigned VersionNo) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        NamespaceInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        RecordInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        BaseRecordInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        EnumInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        TypedefInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        EnumValueInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        FunctionInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        TypeInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        FieldTypeInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        MemberTypeInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        CommentInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        Reference *I, FieldId &F) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        TemplateInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        TemplateSpecializationInfo *I) {}

llvm::Error parseRecord(const Record &R, unsigned ID, llvm::StringRef Blob,
                        TemplateParamInfo *I) {}

template <typename T> llvm::Expected<CommentInfo *> getCommentInfo(T I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(FunctionInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(NamespaceInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(RecordInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(MemberTypeInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(EnumInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(TypedefInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(EnumValueInfo *I) {}

template <> llvm::Expected<CommentInfo *> getCommentInfo(CommentInfo *I) {}

template <>
llvm::Expected<CommentInfo *> getCommentInfo(std::unique_ptr<CommentInfo> &I) {}

// When readSubBlock encounters a TypeInfo sub-block, it calls addTypeInfo on
// the parent block to set it. The template specializations define what to do
// for each supported parent block.
template <typename T, typename TTypeInfo>
llvm::Error addTypeInfo(T I, TTypeInfo &&TI) {}

template <> llvm::Error addTypeInfo(RecordInfo *I, MemberTypeInfo &&T) {}

template <> llvm::Error addTypeInfo(BaseRecordInfo *I, MemberTypeInfo &&T) {}

template <> llvm::Error addTypeInfo(FunctionInfo *I, TypeInfo &&T) {}

template <> llvm::Error addTypeInfo(FunctionInfo *I, FieldTypeInfo &&T) {}

template <> llvm::Error addTypeInfo(EnumInfo *I, TypeInfo &&T) {}

template <> llvm::Error addTypeInfo(TypedefInfo *I, TypeInfo &&T) {}

template <typename T> llvm::Error addReference(T I, Reference &&R, FieldId F) {}

template <> llvm::Error addReference(TypeInfo *I, Reference &&R, FieldId F) {}

template <>
llvm::Error addReference(FieldTypeInfo *I, Reference &&R, FieldId F) {}

template <>
llvm::Error addReference(MemberTypeInfo *I, Reference &&R, FieldId F) {}

template <> llvm::Error addReference(EnumInfo *I, Reference &&R, FieldId F) {}

template <> llvm::Error addReference(TypedefInfo *I, Reference &&R, FieldId F) {}

template <>
llvm::Error addReference(NamespaceInfo *I, Reference &&R, FieldId F) {}

template <>
llvm::Error addReference(FunctionInfo *I, Reference &&R, FieldId F) {}

template <> llvm::Error addReference(RecordInfo *I, Reference &&R, FieldId F) {}

template <typename T, typename ChildInfoType>
void addChild(T I, ChildInfoType &&R) {}

// Namespace children:
template <> void addChild(NamespaceInfo *I, FunctionInfo &&R) {}
template <> void addChild(NamespaceInfo *I, EnumInfo &&R) {}
template <> void addChild(NamespaceInfo *I, TypedefInfo &&R) {}

// Record children:
template <> void addChild(RecordInfo *I, FunctionInfo &&R) {}
template <> void addChild(RecordInfo *I, EnumInfo &&R) {}
template <> void addChild(RecordInfo *I, TypedefInfo &&R) {}

// Other types of children:
template <> void addChild(EnumInfo *I, EnumValueInfo &&R) {}
template <> void addChild(RecordInfo *I, BaseRecordInfo &&R) {}
template <> void addChild(BaseRecordInfo *I, FunctionInfo &&R) {}

// TemplateParam children. These go into either a TemplateInfo (for template
// parameters) or TemplateSpecializationInfo (for the specialization's
// parameters).
template <typename T> void addTemplateParam(T I, TemplateParamInfo &&P) {}
template <> void addTemplateParam(TemplateInfo *I, TemplateParamInfo &&P) {}
template <>
void addTemplateParam(TemplateSpecializationInfo *I, TemplateParamInfo &&P) {}

// Template info. These apply to either records or functions.
template <typename T> void addTemplate(T I, TemplateInfo &&P) {}
template <> void addTemplate(RecordInfo *I, TemplateInfo &&P) {}
template <> void addTemplate(FunctionInfo *I, TemplateInfo &&P) {}

// Template specializations go only into template records.
template <typename T>
void addTemplateSpecialization(T I, TemplateSpecializationInfo &&TSI) {}
template <>
void addTemplateSpecialization(TemplateInfo *I,
                               TemplateSpecializationInfo &&TSI) {}

// Read records from bitcode into a given info.
template <typename T>
llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) {}

template <>
llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) {}

// Read a block of records into a single info.
template <typename T>
llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {}

template <typename T>
llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {}

ClangDocBitcodeReader::Cursor
ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) {}

llvm::Error ClangDocBitcodeReader::validateStream() {}

llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() {}

template <typename T>
llvm::Expected<std::unique_ptr<Info>>
ClangDocBitcodeReader::createInfo(unsigned ID) {}

llvm::Expected<std::unique_ptr<Info>>
ClangDocBitcodeReader::readBlockToInfo(unsigned ID) {}

// Entry point
llvm::Expected<std::vector<std::unique_ptr<Info>>>
ClangDocBitcodeReader::readBitcode() {}

} // namespace doc
} // namespace clang