[clang] 8b87cb4 - [clang][Interp] Remove unused getGlobalIdx()

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 07:36:21 PDT 2022


Author: Timm Bäder
Date: 2022-10-28T16:34:29+02:00
New Revision: 8b87cb4853409ea8066e451ee87f550a9ecd3c34

URL: https://github.com/llvm/llvm-project/commit/8b87cb4853409ea8066e451ee87f550a9ecd3c34
DIFF: https://github.com/llvm/llvm-project/commit/8b87cb4853409ea8066e451ee87f550a9ecd3c34.diff

LOG: [clang][Interp] Remove unused getGlobalIdx()

Remove the only use with the version we already use in
VisitDeclRefExpr().

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 7e00fc4f707e..2ec14afdf9ac 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -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))
@@ -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))

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index d1cda8939d58..489e8bdb79ca 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -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");


        


More information about the cfe-commits mailing list