Path: blob/main/contrib/llvm-project/clang/lib/AST/ByteCode/FunctionPointer.h
213799 views
//===--- FunctionPointer.h - Types for the constexpr VM ---------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_CLANG_AST_INTERP_FUNCTION_POINTER_H9#define LLVM_CLANG_AST_INTERP_FUNCTION_POINTER_H1011#include "Function.h"12#include "Primitives.h"1314namespace clang {15class ASTContext;16class APValue;17namespace interp {1819class FunctionPointer final {20private:21const Function *Func;2223public:24FunctionPointer() = default;25FunctionPointer(const Function *Func) : Func(Func) {}2627const Function *getFunction() const { return Func; }28bool isZero() const { return !Func; }29bool isWeak() const {30if (!Func || !Func->getDecl())31return false;3233return Func->getDecl()->isWeak();34}3536APValue toAPValue(const ASTContext &) const;37void print(llvm::raw_ostream &OS) const;3839std::string toDiagnosticString(const ASTContext &Ctx) const {40if (!Func)41return "nullptr";4243return toAPValue(Ctx).getAsString(Ctx, Func->getDecl()->getType());44}4546uint64_t getIntegerRepresentation() const {47return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Func));48}49};5051} // namespace interp52} // namespace clang5354#endif555657