aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/AST/Interp/Context.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/Interp/Context.h')
-rw-r--r--contrib/llvm-project/clang/lib/AST/Interp/Context.h44
1 files changed, 36 insertions, 8 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/Interp/Context.h b/contrib/llvm-project/clang/lib/AST/Interp/Context.h
index e8238eea716a..ab83a8d13224 100644
--- a/contrib/llvm-project/clang/lib/AST/Interp/Context.h
+++ b/contrib/llvm-project/clang/lib/AST/Interp/Context.h
@@ -17,15 +17,13 @@
#define LLVM_CLANG_AST_INTERP_CONTEXT_H
#include "InterpStack.h"
-#include "clang/AST/APValue.h"
-#include "llvm/ADT/PointerIntPair.h"
namespace clang {
class ASTContext;
class LangOptions;
-class Stmt;
class FunctionDecl;
class VarDecl;
+class APValue;
namespace interp {
class Function;
@@ -33,8 +31,13 @@ class Program;
class State;
enum PrimType : unsigned;
+struct ParamOffset {
+ unsigned Offset;
+ bool IsPtr;
+};
+
/// Holds all information required to evaluate constexpr code in a module.
-class Context {
+class Context final {
public:
/// Initialises the constexpr VM.
Context(ASTContext &Ctx);
@@ -48,6 +51,9 @@ public:
/// Evaluates a toplevel expression as an rvalue.
bool evaluateAsRValue(State &Parent, const Expr *E, APValue &Result);
+ /// Like evaluateAsRvalue(), but does no implicit lvalue-to-rvalue conversion.
+ bool evaluate(State &Parent, const Expr *E, APValue &Result);
+
/// Evaluates a toplevel initializer.
bool evaluateAsInitializer(State &Parent, const VarDecl *VD, APValue &Result);
@@ -59,18 +65,40 @@ public:
InterpStack &getStack() { return Stk; }
/// Returns CHAR_BIT.
unsigned getCharBit() const;
+ /// Return the floating-point semantics for T.
+ const llvm::fltSemantics &getFloatSemantics(QualType T) const;
+ /// Return the size of T in bits.
+ uint32_t getBitWidth(QualType T) const { return Ctx.getIntWidth(T); }
/// Classifies an expression.
- llvm::Optional<PrimType> classify(QualType T);
+ std::optional<PrimType> classify(QualType T) const;
+
+ const CXXMethodDecl *
+ getOverridingFunction(const CXXRecordDecl *DynamicDecl,
+ const CXXRecordDecl *StaticDecl,
+ const CXXMethodDecl *InitialFunction) const;
+
+ const Function *getOrCreateFunction(const FunctionDecl *FD);
+
+ /// Returns whether we should create a global variable for the
+ /// given ValueDecl.
+ static bool shouldBeGloballyIndexed(const ValueDecl *VD) {
+ if (const auto *V = dyn_cast<VarDecl>(VD))
+ return V->hasGlobalStorage() || V->isConstexpr();
+
+ return false;
+ }
+
+ /// Returns the program. This is only needed for unittests.
+ Program &getProgram() const { return *P.get(); }
private:
/// Runs a function.
- bool Run(State &Parent, Function *Func, APValue &Result);
+ bool Run(State &Parent, const Function *Func, APValue &Result);
- /// Checks a result fromt the interpreter.
+ /// Checks a result from the interpreter.
bool Check(State &Parent, llvm::Expected<bool> &&R);
-private:
/// Current compilation context.
ASTContext &Ctx;
/// Interpreter stack, shared across invocations.