[clang][Interp] Remove unused getGlobalIdx()
authorTimm Bäder <tbaeder@redhat.com>
Fri, 28 Oct 2022 13:06:24 +0000 (15:06 +0200)
committerTimm Bäder <tbaeder@redhat.com>
Fri, 28 Oct 2022 14:34:29 +0000 (16:34 +0200)
Remove the only use with the version we already use in
VisitDeclRefExpr().

clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h

index 7e00fc4..2ec14af 100644 (file)
@@ -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))
@@ -868,21 +868,6 @@ bool ByteCodeExprGen<Emitter>::visitInitializer(const Expr *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))
     return PT->getPointeeType()->getAs<RecordType>();
index d1cda89..489e8bd 100644 (file)
@@ -238,9 +238,6 @@ private:
     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");