llvm/llvm/include/llvm/Remarks/RemarkParser.h

//===-- llvm/Remarks/Remark.h - The remark type -----------------*- 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 provides an interface for parsing remarks in LLVM.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_REMARKS_REMARKPARSER_H
#define LLVM_REMARKS_REMARKPARSER_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/Support/Error.h"
#include <memory>
#include <optional>

namespace llvm {
namespace remarks {

struct Remark;

class EndOfFileError : public ErrorInfo<EndOfFileError> {};

/// Parser used to parse a raw buffer to remarks::Remark objects.
struct RemarkParser {};

/// In-memory representation of the string table parsed from a buffer (e.g. the
/// remarks section).
struct ParsedStringTable {};

Expected<std::unique_ptr<RemarkParser>> createRemarkParser(Format ParserFormat,
                                                           StringRef Buf);

Expected<std::unique_ptr<RemarkParser>>
createRemarkParser(Format ParserFormat, StringRef Buf,
                   ParsedStringTable StrTab);

Expected<std::unique_ptr<RemarkParser>> createRemarkParserFromMeta(
    Format ParserFormat, StringRef Buf,
    std::optional<ParsedStringTable> StrTab = std::nullopt,
    std::optional<StringRef> ExternalFilePrependPath = std::nullopt);

} // end namespace remarks
} // end namespace llvm

#endif // LLVM_REMARKS_REMARKPARSER_H