clang
22.0.0git
lib
AST
ByteCode
FunctionPointer.h
Go to the documentation of this file.
1
//===--- FunctionPointer.h - Types 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_FUNCTION_POINTER_H
10
#define LLVM_CLANG_AST_INTERP_FUNCTION_POINTER_H
11
12
#include "
Function.h
"
13
#include "
Primitives.h
"
14
15
namespace
clang
{
16
class
ASTContext
;
17
class
APValue
;
18
namespace
interp
{
19
20
class
FunctionPointer
final {
21
private
:
22
const
Function
*Func;
23
24
public
:
25
FunctionPointer
() =
default
;
26
FunctionPointer
(
const
Function
*Func) : Func(Func) {}
27
28
const
Function
*
getFunction
()
const
{
return
Func; }
29
bool
isZero
()
const
{
return
!Func; }
30
bool
isWeak
()
const
{
31
if
(!Func || !Func->getDecl())
32
return
false
;
33
34
return
Func->getDecl()->isWeak();
35
}
36
37
APValue
toAPValue
(
const
ASTContext
&)
const
;
38
void
print
(llvm::raw_ostream &OS)
const
;
39
40
std::string
toDiagnosticString
(
const
ASTContext
&Ctx)
const
{
41
if
(!Func)
42
return
"nullptr"
;
43
44
return
toAPValue
(Ctx).
getAsString
(Ctx, Func->getDecl()->getType());
45
}
46
47
uint64_t
getIntegerRepresentation
()
const
{
48
return
static_cast<
uint64_t
>
(
reinterpret_cast<
uintptr_t
>
(Func));
49
}
50
};
51
52
}
// namespace interp
53
}
// namespace clang
54
55
#endif
Function.h
Primitives.h
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition
APValue.h:122
clang::APValue::getAsString
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Definition
APValue.cpp:956
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition
ASTContext.h:188
clang::interp::FunctionPointer::isWeak
bool isWeak() const
Definition
FunctionPointer.h:30
clang::interp::FunctionPointer::print
void print(llvm::raw_ostream &OS) const
Definition
FunctionPointer.cpp:26
clang::interp::FunctionPointer::getFunction
const Function * getFunction() const
Definition
FunctionPointer.h:28
clang::interp::FunctionPointer::FunctionPointer
FunctionPointer()=default
clang::interp::FunctionPointer::FunctionPointer
FunctionPointer(const Function *Func)
Definition
FunctionPointer.h:26
clang::interp::FunctionPointer::toAPValue
APValue toAPValue(const ASTContext &) const
Definition
FunctionPointer.cpp:14
clang::interp::FunctionPointer::getIntegerRepresentation
uint64_t getIntegerRepresentation() const
Definition
FunctionPointer.h:47
clang::interp::FunctionPointer::toDiagnosticString
std::string toDiagnosticString(const ASTContext &Ctx) const
Definition
FunctionPointer.h:40
clang::interp::FunctionPointer::isZero
bool isZero() const
Definition
FunctionPointer.h:29
clang::interp::Function
Bytecode function.
Definition
Function.h:86
clang::interp
Definition
ASTContext.h:134
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
uintptr_t
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Definition
opencl-c-base.h:166
Generated on
for clang by
1.14.0