brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 2488626 Raw
37 lines · cpp
1//===----------------------- FunctionPointer.cpp ----------------*- 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-exception6//7//===----------------------------------------------------------------------===//8 9#include "FunctionPointer.h"10 11namespace clang {12namespace interp {13 14APValue FunctionPointer::toAPValue(const ASTContext &) const {15  if (!Func)16    return APValue(static_cast<Expr *>(nullptr), CharUnits::Zero(), {},17                   /*OnePastTheEnd=*/false, /*IsNull=*/true);18 19  if (Func->getDecl())20    return APValue(Func->getDecl(), CharUnits::fromQuantity(0), {},21                   /*OnePastTheEnd=*/false, /*IsNull=*/false);22  return APValue(Func->getExpr(), CharUnits::fromQuantity(0), {},23                 /*OnePastTheEnd=*/false, /*IsNull=*/false);24}25 26void FunctionPointer::print(llvm::raw_ostream &OS) const {27  OS << "FnPtr(";28  if (Func)29    OS << Func->getName();30  else31    OS << "nullptr";32  OS << ")";33}34 35} // namespace interp36} // namespace clang37