Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EvalIDScope;
class Context final {
public:
/// Initialises the constexpr VM.
Context(ASTContext &Ctx);
explicit Context(ASTContext &Ctx);

/// Cleans up the constexpr VM.
~Context();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/EvalEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ bool EvalEmitter::emitRetValue(SourceInfo Info) {
return false;

if (std::optional<APValue> APV =
Ptr.toRValue(S.getASTContext(), EvalResult.getSourceType())) {
Ptr.toRValue(Ctx, EvalResult.getSourceType())) {
EvalResult.takeValue(std::move(*APV));
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Function final {
}

/// Returns a parameter descriptor.
ParamDescriptor getParamDescriptor(unsigned Index) const {
const ParamDescriptor &getParamDescriptor(unsigned Index) const {
return ParamDescriptors[Index];
}

Expand Down
42 changes: 21 additions & 21 deletions clang/lib/AST/ByteCode/InterpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@ void InterpFrame::destroy(unsigned Idx) {
}

template <typename T>
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx,
static void print(llvm::raw_ostream &OS, const T &V, const Context &Ctx,
QualType Ty) {
if constexpr (std::is_same_v<Pointer, T>) {
if (Ty->isPointerOrReferenceType())
V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
V.toAPValue(Ctx.getASTContext()).printPretty(OS, Ctx.getASTContext(), Ty);
else {
if (std::optional<APValue> RValue = V.toRValue(ASTCtx, Ty))
RValue->printPretty(OS, ASTCtx, Ty);
if (std::optional<APValue> RValue = V.toRValue(Ctx, Ty))
RValue->printPretty(OS, Ctx.getASTContext(), Ty);
else
OS << "...";
}
} else {
V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
V.toAPValue(Ctx.getASTContext()).printPretty(OS, Ctx.getASTContext(), Ty);
}
}

Expand All @@ -159,9 +159,10 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
if (shouldSkipInBacktrace(Func))
return;

const ASTContext &ASTCtx = S.getASTContext();
const Expr *CallExpr = Caller->getExpr(getRetPC());
const FunctionDecl *F = getCallee();
auto PrintingPolicy = S.getASTContext().getPrintingPolicy();
auto PrintingPolicy = ASTCtx.getPrintingPolicy();
PrintingPolicy.SuppressLambdaBody = true;

bool IsMemberCall = false;
Expand All @@ -180,39 +181,38 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
if (Object->getType()->isPointerType())
OS << "->";
else
OS << ".";
OS << '.';
} else if (const auto *OCE =
dyn_cast_if_present<CXXOperatorCallExpr>(CallExpr)) {
OCE->getArg(0)->printPretty(OS, /*Helper=*/nullptr,
PrintingPolicy,
/*Indentation=*/0);
OS << ".";
OS << '.';
} else if (const auto *M = dyn_cast<CXXMethodDecl>(F)) {
print(OS, getThis(), S.getASTContext(),
S.getASTContext().getLValueReferenceType(
S.getASTContext().getCanonicalTagType(M->getParent())));
OS << ".";
print(OS, getThis(), S.getContext(),
ASTCtx.getLValueReferenceType(
ASTCtx.getCanonicalTagType(M->getParent())));
OS << '.';
}
}

F->getNameForDiagnostic(OS, PrintingPolicy,
/*Qualified=*/false);
F->getNameForDiagnostic(OS, PrintingPolicy, /*Qualified=*/false);
OS << '(';
unsigned Off = 0;

unsigned ParamIndex = ExplicitInstanceParam;
Off += Func->hasRVO() ? primSize(PT_Ptr) : 0;
Off += Func->hasThisPointer() ? primSize(PT_Ptr) : 0;
llvm::ListSeparator Comma;
for (const ParmVarDecl *Param :
F->parameters().slice(ExplicitInstanceParam)) {
OS << Comma;
QualType Ty = Param->getType();
PrimType PrimTy = S.Ctx.classify(Ty).value_or(PT_Ptr);

TYPE_SWITCH(PrimTy, print(OS, stackRef<T>(Off), S.getASTContext(), Ty));
Off += align(primSize(PrimTy));
PrimType PrimT = Func->getParamDescriptor(ParamIndex).T;
TYPE_SWITCH(PrimT,
print(OS, stackRef<T>(Off), S.getContext(), Param->getType()));
Off += align(primSize(PrimT));
++ParamIndex;
}
OS << ")";
OS << ')';
}

SourceRange InterpFrame::getCallRange() const {
Expand Down
Loading