#include "clang/APINotes/APINotesWriter.h"
#include "APINotesFormat.h"
#include "clang/APINotes/Types.h"
#include "clang/Basic/FileManager.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Bitstream/BitstreamWriter.h"
#include "llvm/Support/DJB.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/VersionTuple.h"
namespace clang {
namespace api_notes {
class APINotesWriter::Implementation { … };
void APINotesWriter::Implementation::writeToStream(llvm::raw_ostream &OS) { … }
namespace {
void emitBlockID(llvm::BitstreamWriter &Stream, unsigned ID,
llvm::StringRef Name) { … }
void emitRecordID(llvm::BitstreamWriter &Stream, unsigned ID,
llvm::StringRef Name) { … }
}
void APINotesWriter::Implementation::writeBlockInfoBlock(
llvm::BitstreamWriter &Stream) { … }
void APINotesWriter::Implementation::writeControlBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class IdentifierTableInfo { … };
}
void APINotesWriter::Implementation::writeIdentifierBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class ContextIDTableInfo { … };
template <typename T> struct MakeDependent { … };
unsigned getVersionTupleSize(const VersionTuple &VT) { … }
template <typename T>
unsigned getVersionedInfoSize(
const llvm::SmallVectorImpl<std::pair<llvm::VersionTuple, T>> &VI,
llvm::function_ref<unsigned(const typename MakeDependent<T>::Type &)>
getInfoSize) { … }
void emitVersionTuple(raw_ostream &OS, const VersionTuple &VT) { … }
template <typename T>
void emitVersionedInfo(
raw_ostream &OS, llvm::SmallVectorImpl<std::pair<VersionTuple, T>> &VI,
llvm::function_ref<void(raw_ostream &,
const typename MakeDependent<T>::Type &)>
emitInfo) { … }
template <typename Derived, typename KeyType, typename UnversionedDataType>
class VersionedTableInfo { … };
void emitCommonEntityInfo(raw_ostream &OS, const CommonEntityInfo &CEI) { … }
unsigned getCommonEntityInfoSize(const CommonEntityInfo &CEI) { … }
unsigned getCommonTypeInfoSize(const CommonTypeInfo &CTI) { … }
void emitCommonTypeInfo(raw_ostream &OS, const CommonTypeInfo &CTI) { … }
class ContextInfoTableInfo
: public VersionedTableInfo<ContextInfoTableInfo, unsigned, ContextInfo> { … };
}
void APINotesWriter::Implementation::writeContextBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
unsigned getVariableInfoSize(const VariableInfo &VI) { … }
void emitVariableInfo(raw_ostream &OS, const VariableInfo &VI) { … }
class ObjCPropertyTableInfo
: public VersionedTableInfo<ObjCPropertyTableInfo,
std::tuple<unsigned, unsigned, char>,
ObjCPropertyInfo> { … };
}
void APINotesWriter::Implementation::writeObjCPropertyBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
unsigned getFunctionInfoSize(const FunctionInfo &);
void emitFunctionInfo(llvm::raw_ostream &, const FunctionInfo &);
class ObjCMethodTableInfo
: public VersionedTableInfo<ObjCMethodTableInfo,
std::tuple<unsigned, unsigned, char>,
ObjCMethodInfo> { … };
class CXXMethodTableInfo
: public VersionedTableInfo<CXXMethodTableInfo, SingleDeclTableKey,
CXXMethodInfo> { … };
}
void APINotesWriter::Implementation::writeObjCMethodBlock(
llvm::BitstreamWriter &Stream) { … }
void APINotesWriter::Implementation::writeCXXMethodBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class FieldTableInfo
: public VersionedTableInfo<FieldTableInfo, SingleDeclTableKey, FieldInfo> { … };
}
void APINotesWriter::Implementation::writeFieldBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class ObjCSelectorTableInfo { … };
}
void APINotesWriter::Implementation::writeObjCSelectorBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class GlobalVariableTableInfo
: public VersionedTableInfo<GlobalVariableTableInfo, SingleDeclTableKey,
GlobalVariableInfo> { … };
}
void APINotesWriter::Implementation::writeGlobalVariableBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
unsigned getParamInfoSize(const ParamInfo &PI) { … }
void emitParamInfo(raw_ostream &OS, const ParamInfo &PI) { … }
unsigned getFunctionInfoSize(const FunctionInfo &FI) { … }
void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) { … }
class GlobalFunctionTableInfo
: public VersionedTableInfo<GlobalFunctionTableInfo, SingleDeclTableKey,
GlobalFunctionInfo> { … };
}
void APINotesWriter::Implementation::writeGlobalFunctionBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class EnumConstantTableInfo
: public VersionedTableInfo<EnumConstantTableInfo, unsigned,
EnumConstantInfo> { … };
}
void APINotesWriter::Implementation::writeEnumConstantBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
template <typename Derived, typename UnversionedDataType>
class CommonTypeTableInfo
: public VersionedTableInfo<Derived, SingleDeclTableKey,
UnversionedDataType> { … };
class TagTableInfo : public CommonTypeTableInfo<TagTableInfo, TagInfo> { … };
}
void APINotesWriter::Implementation::writeTagBlock(
llvm::BitstreamWriter &Stream) { … }
namespace {
class TypedefTableInfo
: public CommonTypeTableInfo<TypedefTableInfo, TypedefInfo> { … };
}
void APINotesWriter::Implementation::writeTypedefBlock(
llvm::BitstreamWriter &Stream) { … }
APINotesWriter::APINotesWriter(llvm::StringRef ModuleName, const FileEntry *SF)
: … { … }
APINotesWriter::~APINotesWriter() = default;
void APINotesWriter::writeToStream(llvm::raw_ostream &OS) { … }
ContextID APINotesWriter::addContext(std::optional<ContextID> ParentCtxID,
llvm::StringRef Name, ContextKind Kind,
const ContextInfo &Info,
llvm::VersionTuple SwiftVersion) { … }
void APINotesWriter::addObjCProperty(ContextID CtxID, StringRef Name,
bool IsInstanceProperty,
const ObjCPropertyInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addObjCMethod(ContextID CtxID, ObjCSelectorRef Selector,
bool IsInstanceMethod,
const ObjCMethodInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addCXXMethod(ContextID CtxID, llvm::StringRef Name,
const CXXMethodInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addField(ContextID CtxID, llvm::StringRef Name,
const FieldInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addGlobalVariable(std::optional<Context> Ctx,
llvm::StringRef Name,
const GlobalVariableInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addGlobalFunction(std::optional<Context> Ctx,
llvm::StringRef Name,
const GlobalFunctionInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addEnumConstant(llvm::StringRef Name,
const EnumConstantInfo &Info,
VersionTuple SwiftVersion) { … }
void APINotesWriter::addTag(std::optional<Context> Ctx, llvm::StringRef Name,
const TagInfo &Info, VersionTuple SwiftVersion) { … }
void APINotesWriter::addTypedef(std::optional<Context> Ctx,
llvm::StringRef Name, const TypedefInfo &Info,
VersionTuple SwiftVersion) { … }
}
}