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/ADT/APSInt.h"
16#include "llvm/Support/MathExtras.h"
17#include "llvm/Support/raw_ostream.h"
18#include <cstddef>
19#include <cstdint>
20
21namespace clang {
22namespace interp {
23
24class Reflect final {
25private:
26 ReflectionKind Kind;
27 const void *Operand;
28
29public:
30 Reflect() : Kind(ReflectionKind::Null), Operand(nullptr) {}
31 Reflect(ReflectionKind Kind, const void *Operand)
32 : Kind(Kind), Operand(Operand) {}
33
35 llvm::FoldingSetNodeID LID, RID;
36 APValue(Kind, Operand).Profile(LID);
37 APValue(RHS.Kind, RHS.Operand).Profile(RID);
38
39 if (LID == RID)
42 }
43
44 void print(llvm::raw_ostream &OS) const {
45 OS << "Reflect(" << Kind << ", " << Operand << ")";
46 }
47 APValue toAPValue(const ASTContext &Ctx) const {
48 return APValue(Kind, Operand);
49 }
50};
51
52inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Reflect &R) {
53 R.print(OS);
54 return OS;
55}
56
57} // namespace interp
58} // namespace clang
59
60#endif
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:124
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:239
APValue toAPValue(const ASTContext &Ctx) const
Definition Reflect.h:47
ComparisonCategoryResult compare(const Reflect &RHS) const
Definition Reflect.h:34
void print(llvm::raw_ostream &OS) const
Definition Reflect.h:44
Reflect(ReflectionKind Kind, const void *Operand)
Definition Reflect.h:31
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
Definition Boolean.h:147
bool Null(InterpState &S, uint64_t Value, const Type *Ty)
Definition Interp.h:3196
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