[clang] d9e7286 - [NFC][clang][bytecode] Rename `clang::interp::State::getCtx` to `clang::interp::State::getASTContext` (#106071)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 07:23:10 PDT 2024
Author: yronglin
Date: 2024-08-26T22:23:07+08:00
New Revision: d9e728601938f7d587ac580d32f042fa74041864
URL: https://github.com/llvm/llvm-project/commit/d9e728601938f7d587ac580d32f042fa74041864
DIFF: https://github.com/llvm/llvm-project/commit/d9e728601938f7d587ac580d32f042fa74041864.diff
LOG: [NFC][clang][bytecode] Rename `clang::interp::State::getCtx` to `clang::interp::State::getASTContext` (#106071)
The new constant interpreter's `clang::interp::InterpState` contains
both `clang::interp::Context` and `clang::ASTContext`. So using `S.Ctx`
and `S.getCtx()` was a bit confusing. This PR rename `getCtx()` to
`getASTContext` to make things more clearer.
Signed-off-by: yronglin <yronglin777 at gmail.com>
Added:
Modified:
clang/lib/AST/ByteCode/EvalEmitter.cpp
clang/lib/AST/ByteCode/Interp.cpp
clang/lib/AST/ByteCode/Interp.h
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/lib/AST/ByteCode/InterpFrame.cpp
clang/lib/AST/ByteCode/InterpState.h
clang/lib/AST/ByteCode/State.cpp
clang/lib/AST/ByteCode/State.h
clang/lib/AST/ExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp
index 53ec8f52d4921f..3b9e5f9f9f69cd 100644
--- a/clang/lib/AST/ByteCode/EvalEmitter.cpp
+++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp
@@ -219,7 +219,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
return false;
if (std::optional<APValue> APV =
- Ptr.toRValue(S.getCtx(), EvalResult.getSourceType())) {
+ Ptr.toRValue(S.getASTContext(), EvalResult.getSourceType())) {
EvalResult.setValue(*APV);
return true;
}
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index aea303f0e630c9..09d3f4525138ed 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -326,7 +326,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
auto IsConstType = [&S](const VarDecl *VD) -> bool {
QualType T = VD->getType();
- if (T.isConstant(S.getCtx()))
+ if (T.isConstant(S.getASTContext()))
return true;
if (S.getLangOpts().CPlusPlus && !S.getLangOpts().CPlusPlus11)
@@ -523,9 +523,9 @@ bool CheckGlobalInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
assert(S.getLangOpts().CPlusPlus);
const auto *VD = cast<VarDecl>(Ptr.getDeclDesc()->asValueDecl());
if ((!VD->hasConstantInitialization() &&
- VD->mightBeUsableInConstantExpressions(S.getCtx())) ||
+ VD->mightBeUsableInConstantExpressions(S.getASTContext())) ||
(S.getLangOpts().OpenCL && !S.getLangOpts().CPlusPlus11 &&
- !VD->hasICEInitializer(S.getCtx()))) {
+ !VD->hasICEInitializer(S.getASTContext()))) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;
S.Note(VD->getLocation(), diag::note_declared_at);
@@ -797,7 +797,7 @@ bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC, bool NewWasArray,
// but we want to get the array size right.
if (D->isArray()) {
QualType ElemQT = D->getType()->getPointeeType();
- TypeToDiagnose = S.getCtx().getConstantArrayType(
+ TypeToDiagnose = S.getASTContext().getConstantArrayType(
ElemQT, APInt(64, static_cast<uint64_t>(D->getNumElems()), false),
nullptr, ArraySizeModifier::Normal, 0);
} else
@@ -819,7 +819,7 @@ bool CheckDeleteSource(InterpState &S, CodePtr OpPC, const Expr *Source,
// Whatever this is, we didn't heap allocate it.
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_delete_not_heap_alloc)
- << Ptr.toDiagnosticString(S.getCtx());
+ << Ptr.toDiagnosticString(S.getASTContext());
if (Ptr.isTemporary())
S.Note(Ptr.getDeclLoc(), diag::note_constexpr_temporary_here);
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 81c547991c3d7d..242532a3f0544e 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -41,7 +41,7 @@ using APSInt = llvm::APSInt;
/// Convert a value to an APValue.
template <typename T>
bool ReturnValue(const InterpState &S, const T &V, APValue &R) {
- R = V.toAPValue(S.getCtx());
+ R = V.toAPValue(S.getASTContext());
return true;
}
@@ -231,12 +231,12 @@ bool CheckArraySize(InterpState &S, CodePtr OpPC, SizeT *NumElements,
// constructing the array, we catch this here.
SizeT MaxElements = SizeT::from(Descriptor::MaxArrayElemBytes / ElemSize);
if (NumElements->toAPSInt().getActiveBits() >
- ConstantArrayType::getMaxSizeBits(S.getCtx()) ||
+ ConstantArrayType::getMaxSizeBits(S.getASTContext()) ||
*NumElements > MaxElements) {
if (!IsNoThrow) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_new_too_large)
- << NumElements->toDiagnosticString(S.getCtx());
+ << NumElements->toDiagnosticString(S.getASTContext());
}
return false;
}
@@ -911,8 +911,8 @@ inline bool CmpHelper<FunctionPointer>(InterpState &S, CodePtr OpPC,
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
- << LHS.toDiagnosticString(S.getCtx())
- << RHS.toDiagnosticString(S.getCtx());
+ << LHS.toDiagnosticString(S.getASTContext())
+ << RHS.toDiagnosticString(S.getASTContext());
return false;
}
@@ -927,7 +927,7 @@ inline bool CmpHelperEQ<FunctionPointer>(InterpState &S, CodePtr OpPC,
if (FP.isWeak()) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_weak_comparison)
- << FP.toDiagnosticString(S.getCtx());
+ << FP.toDiagnosticString(S.getASTContext());
return false;
}
}
@@ -945,8 +945,8 @@ inline bool CmpHelper<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
if (!Pointer::hasSameBase(LHS, RHS)) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
- << LHS.toDiagnosticString(S.getCtx())
- << RHS.toDiagnosticString(S.getCtx());
+ << LHS.toDiagnosticString(S.getASTContext())
+ << RHS.toDiagnosticString(S.getASTContext());
return false;
} else {
unsigned VL = LHS.getByteOffset();
@@ -974,7 +974,7 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
if (P.isWeak()) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_weak_comparison)
- << P.toDiagnosticString(S.getCtx());
+ << P.toDiagnosticString(S.getASTContext());
return false;
}
}
@@ -984,13 +984,13 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
RHS.getOffset() == 0) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
- << LHS.toDiagnosticString(S.getCtx());
+ << LHS.toDiagnosticString(S.getASTContext());
return false;
} else if (RHS.isOnePastEnd() && !LHS.isOnePastEnd() && !LHS.isZero() &&
LHS.getOffset() == 0) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_past_end)
- << RHS.toDiagnosticString(S.getCtx());
+ << RHS.toDiagnosticString(S.getASTContext());
return false;
}
@@ -1073,8 +1073,8 @@ bool CMP3(InterpState &S, CodePtr OpPC, const ComparisonCategoryInfo *CmpInfo) {
// This should only happen with pointers.
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_pointer_comparison_unspecified)
- << LHS.toDiagnosticString(S.getCtx())
- << RHS.toDiagnosticString(S.getCtx());
+ << LHS.toDiagnosticString(S.getASTContext())
+ << RHS.toDiagnosticString(S.getASTContext());
return false;
}
@@ -1342,7 +1342,7 @@ bool InitGlobalTemp(InterpState &S, CodePtr OpPC, uint32_t I,
const Pointer &Ptr = S.P.getGlobal(I);
const T Value = S.Stk.peek<T>();
- APValue APV = Value.toAPValue(S.getCtx());
+ APValue APV = Value.toAPValue(S.getASTContext());
APValue *Cached = Temp->getOrCreateValue(true);
*Cached = APV;
@@ -1369,7 +1369,7 @@ inline bool InitGlobalTempComp(InterpState &S, CodePtr OpPC,
std::make_pair(P.getDeclDesc()->asExpr(), Temp));
if (std::optional<APValue> APV =
- P.toRValue(S.getCtx(), Temp->getTemporaryExpr()->getType())) {
+ P.toRValue(S.getASTContext(), Temp->getTemporaryExpr()->getType())) {
*Cached = *APV;
return true;
}
@@ -1404,7 +1404,8 @@ bool InitThisBitField(InterpState &S, CodePtr OpPC, const Record::Field *F,
return false;
const Pointer &Field = This.atField(FieldOffset);
const auto &Value = S.Stk.pop<T>();
- Field.deref<T>() = Value.truncate(F->Decl->getBitWidthValue(S.getCtx()));
+ Field.deref<T>() =
+ Value.truncate(F->Decl->getBitWidthValue(S.getASTContext()));
Field.initialize();
return true;
}
@@ -1427,7 +1428,8 @@ bool InitBitField(InterpState &S, CodePtr OpPC, const Record::Field *F) {
assert(F->isBitField());
const T &Value = S.Stk.pop<T>();
const Pointer &Field = S.Stk.peek<Pointer>().atField(F->Offset);
- Field.deref<T>() = Value.truncate(F->Decl->getBitWidthValue(S.getCtx()));
+ Field.deref<T>() =
+ Value.truncate(F->Decl->getBitWidthValue(S.getASTContext()));
Field.activate();
Field.initialize();
return true;
@@ -1477,7 +1479,7 @@ inline bool GetPtrField(InterpState &S, CodePtr OpPC, uint32_t Off) {
return false;
if (Ptr.isIntegralPointer()) {
- S.Stk.push<Pointer>(Ptr.asIntPointer().atOffset(S.getCtx(), Off));
+ S.Stk.push<Pointer>(Ptr.asIntPointer().atOffset(S.getASTContext(), Off));
return true;
}
@@ -1505,7 +1507,7 @@ inline bool GetPtrFieldPop(InterpState &S, CodePtr OpPC, uint32_t Off) {
return false;
if (Ptr.isIntegralPointer()) {
- S.Stk.push<Pointer>(Ptr.asIntPointer().atOffset(S.getCtx(), Off));
+ S.Stk.push<Pointer>(Ptr.asIntPointer().atOffset(S.getASTContext(), Off));
return true;
}
@@ -1721,7 +1723,7 @@ bool StoreBitField(InterpState &S, CodePtr OpPC) {
if (Ptr.canBeInitialized())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
- Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getCtx()));
+ Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getASTContext()));
else
Ptr.deref<T>() = Value;
return true;
@@ -1736,7 +1738,7 @@ bool StoreBitFieldPop(InterpState &S, CodePtr OpPC) {
if (Ptr.canBeInitialized())
Ptr.initialize();
if (const auto *FD = Ptr.getField())
- Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getCtx()));
+ Ptr.deref<T>() = Value.truncate(FD->getBitWidthValue(S.getASTContext()));
else
Ptr.deref<T>() = Value;
return true;
@@ -2014,7 +2016,7 @@ inline bool SubPtr(InterpState &S, CodePtr OpPC) {
while (auto *AT = dyn_cast<ArrayType>(PtrT))
PtrT = AT->getElementType();
- QualType ArrayTy = S.getCtx().getConstantArrayType(
+ QualType ArrayTy = S.getASTContext().getConstantArrayType(
PtrT, APInt::getZero(1), nullptr, ArraySizeModifier::Normal, 0);
S.FFDiag(S.Current->getSource(OpPC),
diag::note_constexpr_pointer_subtraction_zero_size)
@@ -2953,7 +2955,7 @@ inline bool CheckDecl(InterpState &S, CodePtr OpPC, const VarDecl *VD) {
if (VD == S.EvaluatingDecl)
return true;
- if (!VD->isUsableInConstantExpressions(S.getCtx())) {
+ if (!VD->isUsableInConstantExpressions(S.getASTContext())) {
S.CCEDiag(VD->getLocation(), diag::note_constexpr_static_local)
<< (VD->getTSCSpec() == TSCS_unspecified ? 0 : 1) << VD;
return false;
@@ -3047,7 +3049,7 @@ static inline bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm) {
if (!Ptr.isRoot() || Ptr.isOnePastEnd() || Ptr.isArrayElement()) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_delete_subobject)
- << Ptr.toDiagnosticString(S.getCtx()) << Ptr.isOnePastEnd();
+ << Ptr.toDiagnosticString(S.getASTContext()) << Ptr.isOnePastEnd();
return false;
}
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 26abf582051067..1a71bff25d2540 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -38,7 +38,7 @@ static T getParam(const InterpFrame *Frame, unsigned Index) {
}
PrimType getIntPrimType(const InterpState &S) {
- const TargetInfo &TI = S.getCtx().getTargetInfo();
+ const TargetInfo &TI = S.getASTContext().getTargetInfo();
unsigned IntWidth = TI.getIntWidth();
if (IntWidth == 32)
@@ -49,7 +49,7 @@ PrimType getIntPrimType(const InterpState &S) {
}
PrimType getLongPrimType(const InterpState &S) {
- const TargetInfo &TI = S.getCtx().getTargetInfo();
+ const TargetInfo &TI = S.getASTContext().getTargetInfo();
unsigned LongWidth = TI.getLongWidth();
if (LongWidth == 64)
@@ -272,10 +272,10 @@ static bool interp__builtin_nan(InterpState &S, CodePtr OpPC,
return false;
const llvm::fltSemantics &TargetSemantics =
- S.getCtx().getFloatTypeSemantics(F->getDecl()->getReturnType());
+ S.getASTContext().getFloatTypeSemantics(F->getDecl()->getReturnType());
Floating Result;
- if (S.getCtx().getTargetInfo().isNan2008()) {
+ if (S.getASTContext().getTargetInfo().isNan2008()) {
if (Signaling)
Result = Floating(
llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, &Fill));
@@ -303,7 +303,7 @@ static bool interp__builtin_nan(InterpState &S, CodePtr OpPC,
static bool interp__builtin_inf(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame, const Function *F) {
const llvm::fltSemantics &TargetSemantics =
- S.getCtx().getFloatTypeSemantics(F->getDecl()->getReturnType());
+ S.getASTContext().getFloatTypeSemantics(F->getDecl()->getReturnType());
S.Stk.push<Floating>(Floating::getInf(TargetSemantics));
return true;
@@ -689,8 +689,8 @@ static bool interp__builtin_eh_return_data_regno(InterpState &S, CodePtr OpPC,
PrimType ArgT = *S.getContext().classify(Call->getArg(0)->getType());
APSInt Arg = peekToAPSInt(S.Stk, ArgT);
- int Result =
- S.getCtx().getTargetInfo().getEHDataRegisterNumber(Arg.getZExtValue());
+ int Result = S.getASTContext().getTargetInfo().getEHDataRegisterNumber(
+ Arg.getZExtValue());
pushInteger(S, Result, Call->getType());
return true;
}
@@ -734,7 +734,7 @@ static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC,
ResultType->isSignedIntegerOrEnumerationType();
uint64_t LHSSize = LHS.getBitWidth();
uint64_t RHSSize = RHS.getBitWidth();
- uint64_t ResultSize = S.getCtx().getTypeSize(ResultType);
+ uint64_t ResultSize = S.getASTContext().getTypeSize(ResultType);
uint64_t MaxBits = std::max(std::max(LHSSize, RHSSize), ResultSize);
// Add an additional bit if the signedness isn't uniformly agreed to. We
@@ -794,7 +794,7 @@ static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC,
// since it will give us the behavior of a TruncOrSelf in the case where
// its parameter <= its size. We previously set Result to be at least the
// type-size of the result, so getTypeSize(ResultType) <= Resu
- APSInt Temp = Result.extOrTrunc(S.getCtx().getTypeSize(ResultType));
+ APSInt Temp = Result.extOrTrunc(S.getASTContext().getTypeSize(ResultType));
Temp.setIsSigned(ResultType->isSignedIntegerOrEnumerationType());
if (!APSInt::isSameValue(Temp, Result))
@@ -974,8 +974,8 @@ static bool interp__builtin_atomic_lock_free(InterpState &S, CodePtr OpPC,
if (Size.isPowerOfTwo()) {
// Check against inlining width.
unsigned InlineWidthBits =
- S.getCtx().getTargetInfo().getMaxAtomicInlineWidth();
- if (Size <= S.getCtx().toCharUnitsFromBits(InlineWidthBits)) {
+ S.getASTContext().getTargetInfo().getMaxAtomicInlineWidth();
+ if (Size <= S.getASTContext().toCharUnitsFromBits(InlineWidthBits)) {
// OK, we will inline appropriately-aligned operations of this size,
// and _Atomic(T) is appropriately-aligned.
@@ -1007,7 +1007,7 @@ static bool interp__builtin_atomic_lock_free(InterpState &S, CodePtr OpPC,
if (auto PtrTy = PtrArg->getType()->getAs<PointerType>()) {
QualType PointeeType = PtrTy->getPointeeType();
if (!PointeeType->isIncompleteType() &&
- S.getCtx().getTypeAlignInChars(PointeeType) >= Size) {
+ S.getASTContext().getTypeAlignInChars(PointeeType) >= Size) {
// OK, we will inline operations on this object.
return returnBool(true);
}
@@ -1059,7 +1059,7 @@ static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
S.FFDiag(Call, diag::note_constexpr_invalid_alignment) << Alignment;
return false;
}
- unsigned SrcWidth = S.getCtx().getIntWidth(Call->getArg(0)->getType());
+ unsigned SrcWidth = S.getASTContext().getIntWidth(Call->getArg(0)->getType());
APSInt MaxValue(APInt::getOneBitSet(SrcWidth, SrcWidth - 1));
if (APSInt::compareValues(Alignment, MaxValue) > 0) {
S.FFDiag(Call, diag::note_constexpr_alignment_too_big)
@@ -1094,7 +1094,7 @@ static bool interp__builtin_is_aligned_up_down(InterpState &S, CodePtr OpPC,
unsigned PtrOffset = Ptr.getByteOffset();
PtrOffset = Ptr.getIndex();
CharUnits BaseAlignment =
- S.getCtx().getDeclAlign(Ptr.getDeclDesc()->asValueDecl());
+ S.getASTContext().getDeclAlign(Ptr.getDeclDesc()->asValueDecl());
CharUnits PtrAlign =
BaseAlignment.alignmentAtOffset(CharUnits::fromQuantity(PtrOffset));
@@ -1157,7 +1157,7 @@ static bool interp__builtin_os_log_format_buffer_size(InterpState &S,
const Function *Func,
const CallExpr *Call) {
analyze_os_log::OSLogBufferLayout Layout;
- analyze_os_log::computeOSLogBufferLayout(S.getCtx(), Call, Layout);
+ analyze_os_log::computeOSLogBufferLayout(S.getASTContext(), Call, Layout);
pushInteger(S, Layout.size().getQuantity(), Call->getType());
return true;
}
@@ -1624,10 +1624,11 @@ bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
const RecordDecl *RD = RT->getDecl();
if (RD->isInvalidDecl())
return false;
- const ASTRecordLayout &RL = S.getCtx().getASTRecordLayout(RD);
+ const ASTRecordLayout &RL = S.getASTContext().getASTRecordLayout(RD);
unsigned FieldIndex = MemberDecl->getFieldIndex();
assert(FieldIndex < RL.getFieldCount() && "offsetof field in wrong type");
- Result += S.getCtx().toCharUnitsFromBits(RL.getFieldOffset(FieldIndex));
+ Result +=
+ S.getASTContext().toCharUnitsFromBits(RL.getFieldOffset(FieldIndex));
CurrentType = MemberDecl->getType().getNonReferenceType();
break;
}
@@ -1635,11 +1636,11 @@ bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
// When generating bytecode, we put all the index expressions as Sint64 on
// the stack.
int64_t Index = ArrayIndices[ArrayIndex];
- const ArrayType *AT = S.getCtx().getAsArrayType(CurrentType);
+ const ArrayType *AT = S.getASTContext().getAsArrayType(CurrentType);
if (!AT)
return false;
CurrentType = AT->getElementType();
- CharUnits ElementSize = S.getCtx().getTypeSizeInChars(CurrentType);
+ CharUnits ElementSize = S.getASTContext().getTypeSizeInChars(CurrentType);
Result += Index * ElementSize;
++ArrayIndex;
break;
@@ -1656,7 +1657,7 @@ bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E,
const RecordDecl *RD = RT->getDecl();
if (RD->isInvalidDecl())
return false;
- const ASTRecordLayout &RL = S.getCtx().getASTRecordLayout(RD);
+ const ASTRecordLayout &RL = S.getASTContext().getASTRecordLayout(RD);
// Find the base class itself.
CurrentType = BaseSpec->getType();
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 8b55b61cbbfa7e..5e98444ef05a59 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -179,7 +179,7 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
if (const auto *MCE = dyn_cast_if_present<CXXMemberCallExpr>(CallExpr)) {
const Expr *Object = MCE->getImplicitObjectArgument();
Object->printPretty(OS, /*Helper=*/nullptr,
- S.getCtx().getPrintingPolicy(),
+ S.getASTContext().getPrintingPolicy(),
/*Indentation=*/0);
if (Object->getType()->isPointerType())
OS << "->";
@@ -188,18 +188,18 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
} else if (const auto *OCE =
dyn_cast_if_present<CXXOperatorCallExpr>(CallExpr)) {
OCE->getArg(0)->printPretty(OS, /*Helper=*/nullptr,
- S.getCtx().getPrintingPolicy(),
+ S.getASTContext().getPrintingPolicy(),
/*Indentation=*/0);
OS << ".";
} else if (const auto *M = dyn_cast<CXXMethodDecl>(F)) {
- print(OS, This, S.getCtx(),
- S.getCtx().getLValueReferenceType(
- S.getCtx().getRecordType(M->getParent())));
+ print(OS, This, S.getASTContext(),
+ S.getASTContext().getLValueReferenceType(
+ S.getASTContext().getRecordType(M->getParent())));
OS << ".";
}
}
- F->getNameForDiagnostic(OS, S.getCtx().getPrintingPolicy(),
+ F->getNameForDiagnostic(OS, S.getASTContext().getPrintingPolicy(),
/*Qualified=*/false);
OS << '(';
unsigned Off = 0;
@@ -212,7 +212,7 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
PrimType PrimTy = S.Ctx.classify(Ty).value_or(PT_Ptr);
- TYPE_SWITCH(PrimTy, print(OS, stackRef<T>(Off), S.getCtx(), Ty));
+ TYPE_SWITCH(PrimTy, print(OS, stackRef<T>(Off), S.getASTContext(), Ty));
Off += align(primSize(PrimTy));
if (I + 1 != N)
OS << ", ";
diff --git a/clang/lib/AST/ByteCode/InterpState.h b/clang/lib/AST/ByteCode/InterpState.h
index 61ee54331c65d6..961ba5f5c28a09 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -59,7 +59,7 @@ class InterpState final : public State, public SourceMapper {
Expr::EvalStatus &getEvalStatus() const override {
return Parent.getEvalStatus();
}
- ASTContext &getCtx() const override { return Parent.getCtx(); }
+ ASTContext &getASTContext() const override { return Parent.getASTContext(); }
// Forward status checks and updates to the walker.
bool checkingForUndefinedBehavior() const override {
diff --git a/clang/lib/AST/ByteCode/State.cpp b/clang/lib/AST/ByteCode/State.cpp
index 0d9dadec4b9581..b4db86e8d22c71 100644
--- a/clang/lib/AST/ByteCode/State.cpp
+++ b/clang/lib/AST/ByteCode/State.cpp
@@ -74,12 +74,12 @@ void State::addNotes(ArrayRef<PartialDiagnosticAt> Diags) {
}
DiagnosticBuilder State::report(SourceLocation Loc, diag::kind DiagId) {
- return getCtx().getDiagnostics().Report(Loc, DiagId);
+ return getASTContext().getDiagnostics().Report(Loc, DiagId);
}
/// Add a diagnostic to the diagnostics list.
PartialDiagnostic &State::addDiag(SourceLocation Loc, diag::kind DiagId) {
- PartialDiagnostic PD(DiagId, getCtx().getDiagAllocator());
+ PartialDiagnostic PD(DiagId, getASTContext().getDiagAllocator());
getEvalStatus().Diag->push_back(std::make_pair(Loc, PD));
return getEvalStatus().Diag->back().second;
}
@@ -93,7 +93,8 @@ OptionalDiagnostic State::diag(SourceLocation Loc, diag::kind DiagId,
}
unsigned CallStackNotes = getCallStackDepth() - 1;
- unsigned Limit = getCtx().getDiagnostics().getConstexprBacktraceLimit();
+ unsigned Limit =
+ getASTContext().getDiagnostics().getConstexprBacktraceLimit();
if (Limit)
CallStackNotes = std::min(CallStackNotes, Limit + 1);
if (checkingPotentialConstantExpression())
@@ -113,7 +114,9 @@ OptionalDiagnostic State::diag(SourceLocation Loc, diag::kind DiagId,
return OptionalDiagnostic();
}
-const LangOptions &State::getLangOpts() const { return getCtx().getLangOpts(); }
+const LangOptions &State::getLangOpts() const {
+ return getASTContext().getLangOpts();
+}
void State::addCallStack(unsigned Limit) {
// Determine which calls to skip, if any.
diff --git a/clang/lib/AST/ByteCode/State.h b/clang/lib/AST/ByteCode/State.h
index 44d6c037c5ad95..2cffce4bc2ae40 100644
--- a/clang/lib/AST/ByteCode/State.h
+++ b/clang/lib/AST/ByteCode/State.h
@@ -67,7 +67,7 @@ class State {
virtual void setActiveDiagnostic(bool Flag) = 0;
virtual void setFoldFailureDiagnostic(bool Flag) = 0;
virtual Expr::EvalStatus &getEvalStatus() const = 0;
- virtual ASTContext &getCtx() const = 0;
+ virtual ASTContext &getASTContext() const = 0;
virtual bool hasPriorDiagnostic() = 0;
virtual unsigned getCallStackDepth() = 0;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 826cc5f58bdf51..d46f57521a97d3 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1030,7 +1030,7 @@ namespace {
discardCleanups();
}
- ASTContext &getCtx() const override { return Ctx; }
+ ASTContext &getASTContext() const override { return Ctx; }
void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
@@ -2327,9 +2327,9 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
// In CUDA/HIP device compilation, only device side variables have
// constant addresses.
- if (Info.getCtx().getLangOpts().CUDA &&
- Info.getCtx().getLangOpts().CUDAIsDevice &&
- Info.getCtx().CUDAConstantEvalCtx.NoWrongSidedVars) {
+ if (Info.getASTContext().getLangOpts().CUDA &&
+ Info.getASTContext().getLangOpts().CUDAIsDevice &&
+ Info.getASTContext().CUDAConstantEvalCtx.NoWrongSidedVars) {
if ((!Var->hasAttr<CUDADeviceAttr>() &&
!Var->hasAttr<CUDAConstantAttr>() &&
!Var->getType()->isCUDADeviceBuiltinSurfaceType() &&
@@ -5662,7 +5662,7 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
*Info.CurrentCall, hasSpecificAttr<MSConstexprAttr>(AS->getAttrs()) &&
isa<ReturnStmt>(SS));
- auto LO = Info.getCtx().getLangOpts();
+ auto LO = Info.getASTContext().getLangOpts();
if (LO.CXXAssumptions && !LO.MSVCCompat) {
for (auto *Attr : AS->getAttrs()) {
auto *AA = dyn_cast<CXXAssumeAttr>(Attr);
@@ -5673,7 +5673,7 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
if (Assumption->isValueDependent())
return ESR_Failed;
- if (Assumption->HasSideEffects(Info.getCtx()))
+ if (Assumption->HasSideEffects(Info.getASTContext()))
continue;
bool Value;
More information about the cfe-commits
mailing list