Skip to content

Commit

Permalink
[clang][Interp] Remove unused getGlobalIdx()
Browse files Browse the repository at this point in the history
Remove the only use with the version we already use in
VisitDeclRefExpr().
  • Loading branch information
tbaederr committed Oct 28, 2022
1 parent dce7864 commit 8b87cb4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
17 changes: 1 addition & 16 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Expand Up @@ -553,7 +553,7 @@ bool ByteCodeExprGen<Emitter>::dereferenceVar(
return false;
return DiscardResult ? true : this->emitGetPtrLocal(L.Offset, LV);
}
} else if (auto Idx = getGlobalIdx(VD)) {
} else if (auto Idx = P.getGlobal(VD)) {
switch (AK) {
case DerefKind::Read:
if (!this->emitGetGlobal(T, *Idx, LV))
Expand Down Expand Up @@ -867,21 +867,6 @@ bool ByteCodeExprGen<Emitter>::visitInitializer(const Expr *Initializer) {
return this->Visit(Initializer);
}

template <class Emitter>
llvm::Optional<unsigned>
ByteCodeExprGen<Emitter>::getGlobalIdx(const VarDecl *VD) {
if (VD->isConstexpr()) {
// Constexpr decl - it must have already been defined.
return P.getGlobal(VD);
}
if (!VD->hasLocalStorage()) {
// Not constexpr, but a global var - can have pointer taken.
Program::DeclScope Scope(P, VD);
return P.getOrCreateGlobal(VD);
}
return {};
}

template <class Emitter>
const RecordType *ByteCodeExprGen<Emitter>::getRecordTy(QualType Ty) {
if (const PointerType *PT = dyn_cast<PointerType>(Ty))
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/AST/Interp/ByteCodeExprGen.h
Expand Up @@ -238,9 +238,6 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
return emitConst(*Ctx.classify(Ty), WrappedValue, E);
}

/// Returns the index of a global.
llvm::Optional<unsigned> getGlobalIdx(const VarDecl *VD);

/// Emits the initialized pointer.
bool emitInitFn() {
assert(InitFn && "missing initializer");
Expand Down

0 comments on commit 8b87cb4

Please sign in to comment.