mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
aad252295b
This adds a Remark class that allows us to share code when working with remarks. The C API has been updated to reflect this. Instead of the parser generating C structs, it's now using a C++ object that is used through opaque pointers in C. This gives us much more flexibility on what changes we can make to the internal state of the object and interacts much better with scenarios where the library is used through dlopen. * C API updates: * move from C structs to opaque pointers and functions * the remark type is now an enum instead of a string * unit tests updates: * use mostly the C++ API * keep one test for the C API * rename to YAMLRemarksParsingTest * a typo was fixed: AnalysisFPCompute -> AnalysisFPCommute. * a new error message was added: "expected a remark tag." * llvm-opt-report has been updated to use the C++ parser instead of the C API Differential Revision: https://reviews.llvm.org/D59049 Original llvm-svn: 356491 llvm-svn: 356519
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
//===-- 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_REMARK_PARSER_H
|
|
#define LLVM_REMARKS_REMARK_PARSER_H
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Remarks/Remark.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include <memory>
|
|
|
|
namespace llvm {
|
|
namespace remarks {
|
|
|
|
struct ParserImpl;
|
|
|
|
/// Parser used to parse a raw buffer to remarks::Remark objects.
|
|
struct Parser {
|
|
/// The hidden implementation of the parser.
|
|
std::unique_ptr<ParserImpl> Impl;
|
|
|
|
/// Create a parser parsing \p Buffer to Remark objects.
|
|
/// This constructor should be only used for parsing YAML remarks.
|
|
Parser(StringRef Buffer);
|
|
|
|
// Needed because ParserImpl is an incomplete type.
|
|
~Parser();
|
|
|
|
/// Returns an empty Optional if it reached the end.
|
|
/// Returns a valid remark otherwise.
|
|
Expected<const Remark *> getNext() const;
|
|
};
|
|
|
|
} // end namespace remarks
|
|
} // end namespace llvm
|
|
|
|
#endif /* LLVM_REMARKS_REMARK_PARSER_H */
|