Files
TheRock/compiler/amd-llvm/clang-tools-extra/clang-doc/BitcodeReader.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

110 lines
4.1 KiB
C++

//===-- BitcodeReader.h - 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
//
//===----------------------------------------------------------------------===//
//
// This file implements a reader for parsing the clang-doc internal
// representation from LLVM bitcode. The reader takes in a stream of bits and
// generates the set of infos that it represents.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_BITCODEREADER_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_BITCODEREADER_H
#include "BitcodeWriter.h"
#include "Representation.h"
#include "llvm/Bitstream/BitstreamReader.h"
#include "llvm/Support/Error.h"
#include <optional>
namespace clang {
namespace doc {
// Class to read bitstream into an InfoSet collection
class ClangDocBitcodeReader {
public:
ClangDocBitcodeReader(llvm::BitstreamCursor &Stream, DiagnosticsEngine &Diags)
: Stream(Stream), Diags(Diags) {}
// Main entry point, calls readBlock to read each block in the given stream.
llvm::Expected<std::vector<Info *>> readBitcode();
private:
enum class Cursor { BadBlock = 1, Record, BlockEnd, BlockBegin };
// Top level parsing
llvm::Error validateStream();
llvm::Error readVersion();
llvm::Error readBlockInfoBlock();
// Read a block of records into a single Info struct, calls readRecord on each
// record found.
template <typename T> llvm::Error readBlock(unsigned ID, T I);
template <typename T> llvm::Error readBlockWithNamespace(unsigned ID, T I);
template <typename T, typename BlockBeginHandler, typename BlockEndHandler,
typename RecordHandler>
llvm::Error parseBlock(unsigned ID, T I, BlockBeginHandler &&BBH,
BlockEndHandler &&BEH, RecordHandler &&RH);
template <typename T, typename BlockBeginHandler, typename BlockEndHandler>
llvm::Error parseBlock(unsigned ID, T I, BlockBeginHandler &&BBH,
BlockEndHandler &&BEH);
template <typename ChildType>
llvm::Expected<bool> readSubBlockIfMatch(unsigned ID, unsigned TargetID,
llvm::SmallVectorImpl<ChildType> &V);
struct ReferenceMap {
FieldId Field;
llvm::SmallVectorImpl<Reference> *Vec;
};
template <typename InfoT>
llvm::Expected<bool>
routeReferenceBlock(unsigned ID, llvm::SmallVectorImpl<Reference> &Namespaces,
InfoT *I,
std::initializer_list<ReferenceMap> Mappings = {});
// Step through a block of records to find the next data field.
template <typename T> llvm::Error readSubBlock(unsigned ID, T I);
// Read record data into the given Info data field, calling the appropriate
// parseRecord functions to parse and store the data.
template <typename T> llvm::Error readRecord(unsigned ID, T I);
// Allocate the relevant type of info and add read data to the object.
template <typename T> llvm::Expected<Info *> createInfo(unsigned ID);
// Helper function to step through blocks to find and dispatch the next record
// or block to be read.
llvm::Expected<Cursor> skipUntilRecordOrBlock(unsigned &BlockOrRecordID);
// Helper function to set up the appropriate type of Info.
llvm::Expected<Info *> readBlockToInfo(unsigned ID);
template <typename InfoType, typename T, typename CallbackFunction>
llvm::Error handleSubBlock(unsigned ID, T Parent, CallbackFunction Function);
template <typename InfoType, typename T>
llvm::Error handleSubBlock(unsigned ID, T Parent);
template <typename InfoType, typename T, typename CallbackFunction>
llvm::Error handleTypeSubBlock(unsigned ID, T Parent,
CallbackFunction Function);
llvm::BitstreamCursor &Stream;
std::optional<llvm::BitstreamBlockInfo> BlockInfo;
FieldId CurrentReferenceField = FieldId::F_default;
DiagnosticsEngine &Diags;
};
} // namespace doc
} // namespace clang
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_BITCODEREADER_H