Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

111 lines
2.9 KiB
C++

//===------ EvaluationResult.h - Result class for the VM -------*- 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
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_INTERP_EVALUATION_RESULT_H
#define LLVM_CLANG_AST_INTERP_EVALUATION_RESULT_H
#include "clang/AST/APValue.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
namespace clang {
namespace interp {
class EvalEmitter;
class Context;
class Pointer;
class SourceInfo;
class InterpState;
/// Defines the result of an evaluation.
///
/// The Kind defined if the evaluation was invalid, valid (but empty, e.g. for
/// void expressions) or if we have a valid evaluation result.
///
/// We use this class to inspect and diagnose the result, as well as
/// convert it to the requested form.
class EvaluationResult final {
public:
enum ResultKind {
Empty, // Initial state.
Invalid, // Result is invalid.
Valid, // Result is valid and empty.
};
using DeclTy = llvm::PointerUnion<const Decl *, const Expr *>;
private:
#ifndef NDEBUG
const Context *Ctx = nullptr;
#endif
APValue Value;
ResultKind Kind = Empty;
DeclTy Source = nullptr;
void setSource(DeclTy D) { Source = D; }
void takeValue(APValue &&V) {
assert(empty());
Value = std::move(V);
}
void setInvalid() {
// We are NOT asserting empty() here, since setting it to invalid
// is allowed even if there is already a result.
Kind = Invalid;
}
void setValid() {
assert(empty());
Kind = Valid;
}
public:
#ifndef NDEBUG
EvaluationResult(const Context *Ctx) : Ctx(Ctx) {}
#else
EvaluationResult(const Context *Ctx) {}
#endif
bool empty() const { return Kind == Empty; }
bool isInvalid() const { return Kind == Invalid; }
/// Returns an APValue for the evaluation result.
APValue toAPValue() const {
assert(!empty());
assert(!isInvalid());
return Value;
}
APValue stealAPValue() { return std::move(Value); }
/// Check that all subobjects of the given pointer have been initialized.
bool checkFullyInitialized(InterpState &S, const Pointer &Ptr) const;
/// Check that none of the blocks the given pointer (transitively) points
/// to are dynamically allocated.
bool checkReturnValue(InterpState &S, const Context &Ctx, const Pointer &Ptr,
const SourceInfo &Info);
QualType getSourceType() const {
if (const auto *D =
dyn_cast_if_present<ValueDecl>(Source.dyn_cast<const Decl *>()))
return D->getType();
if (const auto *E = Source.dyn_cast<const Expr *>())
return E->getType();
return QualType();
}
/// Dump to stderr.
void dump() const;
friend class EvalEmitter;
friend class InterpState;
};
} // namespace interp
} // namespace clang
#endif