Skip to content

Commit

Permalink
[clang][Interp][NFC] Make some variables const
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Aug 17, 2023
1 parent 1334dee commit 235dad3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions clang/lib/AST/Interp/EvalEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
// Method to recursively traverse composites.
std::function<bool(QualType, const Pointer &, APValue &)> Composite;
Composite = [this, &Composite](QualType Ty, const Pointer &Ptr, APValue &R) {
if (auto *AT = Ty->getAs<AtomicType>())
if (const auto *AT = Ty->getAs<AtomicType>())
Ty = AT->getValueType();

if (auto *RT = Ty->getAs<RecordType>()) {
if (const auto *RT = Ty->getAs<RecordType>()) {
const auto *Record = Ptr.getRecord();
assert(Record && "Missing record descriptor");

bool Ok = true;
if (RT->getDecl()->isUnion()) {
const FieldDecl *ActiveField = nullptr;
APValue Value;
for (auto &F : Record->fields()) {
for (const auto &F : Record->fields()) {
const Pointer &FP = Ptr.atField(F.Offset);
QualType FieldTy = F.Decl->getType();
if (FP.isActive()) {
Expand Down Expand Up @@ -179,7 +179,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
}
return Ok;
}
if (auto *AT = Ty->getAsArrayTypeUnsafe()) {
if (const auto *AT = Ty->getAsArrayTypeUnsafe()) {
const size_t NumElems = Ptr.getNumElems();
QualType ElemTy = AT->getElementType();
R = APValue(APValue::UninitArray{}, NumElems, NumElems);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/Interp/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ APValue Pointer::toAPValue() const {
bool IsVirtual = false;

// Create a path entry for the field.
Descriptor *Desc = Ptr.getFieldDesc();
if (auto *BaseOrMember = Desc->asDecl()) {
const Descriptor *Desc = Ptr.getFieldDesc();
if (const auto *BaseOrMember = Desc->asDecl()) {
Path.push_back(APValue::LValuePathEntry({BaseOrMember, IsVirtual}));
Ptr = Ptr.getBase();
continue;
Expand Down

0 comments on commit 235dad3

Please sign in to comment.