mini-llvm 0.1.0
Loading...
Searching...
No Matches
Attribute.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5#include <format>
6#include <memory>
7#include <string>
8
10
11namespace mini_llvm::ir {
12
14public:
15 virtual ~Attribute() = default;
16
17 Attribute(const Attribute &) = delete;
18 Attribute &operator=(const Attribute &) = delete;
19
20 Attribute(Attribute &&) = delete;
22
23 virtual std::string format() const = 0;
24 virtual std::unique_ptr<Attribute> clone() const = 0;
25
26protected:
27 Attribute() = default;
28};
29
30} // namespace mini_llvm::ir
31
32template <>
33struct std::formatter<mini_llvm::ir::Attribute> {
34public:
35 constexpr auto parse(std::format_parse_context &ctx) {
36 return ctx.begin();
37 }
38
39 template <typename FormatContext>
40 auto format(const mini_llvm::ir::Attribute &attr, FormatContext &ctx) const {
41 return format_to(ctx.out(), "{}", attr.format());
42 }
43};
#define MINI_LLVM_EXPORT
Definition Compiler.h:17
Definition Attribute.h:13
Attribute & operator=(const Attribute &)=delete
Attribute & operator=(Attribute &&)=delete
virtual ~Attribute()=default
Attribute(const Attribute &)=delete
Attribute(Attribute &&)=delete
virtual std::unique_ptr< Attribute > clone() const =0
virtual std::string format() const =0
Definition Argument.h:13
Definition GraphColoringAllocator.h:13
auto format(const mini_llvm::ir::Attribute &attr, FormatContext &ctx) const
Definition Attribute.h:40
constexpr auto parse(std::format_parse_context &ctx)
Definition Attribute.h:35