clang 24.0.0git
Reflect.h
Go to the documentation of this file.
1//===--- Reflect.h - Reflection type for the constexpr VM -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_AST_INTERP_REFLECT_H
10#define LLVM_CLANG_AST_INTERP_REFLECT_H
11
12#include "clang/AST/APValue.h"
15#include "llvm/Support/raw_ostream.h"
16
17namespace clang {
18namespace interp {
19
20class Reflect final {
21private:
22 ReflectionKind Kind;
23 const void *Operand;
24
25public:
26 Reflect() : Kind(ReflectionKind::Null), Operand(nullptr) {}
27 Reflect(ReflectionKind Kind, const void *Operand)
28 : Kind(Kind), Operand(Operand) {}
29
30 ReflectionKind getKind() const { return Kind; }
31
33 llvm::FoldingSetNodeID LID, RID;
34 APValue(Kind, Operand).Profile(LID);
35 APValue(RHS.Kind, RHS.Operand).Profile(RID);
36
37 if (LID == RID)
40 }
41
42 void print(llvm::raw_ostream &OS) const {
43 OS << "Reflect(" << Kind << ", " << Operand << ")";
44 }
45 APValue toAPValue(const ASTContext &Ctx) const {
46 return APValue(Kind, Operand);
47 }
48};
49
50inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Reflect &R) {
51 R.print(OS);
52 return OS;
53}
54
55} // namespace interp
56} // namespace clang
57
58#endif
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:158
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:246
APValue toAPValue(const ASTContext &Ctx) const
Definition Reflect.h:45
ComparisonCategoryResult compare(const Reflect &RHS) const
Definition Reflect.h:32
void print(llvm::raw_ostream &OS) const
Definition Reflect.h:42
ReflectionKind getKind() const
Definition Reflect.h:30
Reflect(ReflectionKind Kind, const void *Operand)
Definition Reflect.h:27
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
Definition Boolean.h:148
bool Null(InterpState &S, uint64_t Value, const Type *Ty)
Definition Interp.h:3153
Top level wrappers for InstallAPI frontend operations.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
ReflectionKind
Definition Reflection.h:22