[clang] 5d24514 - [clang][Interp][NFC] InterpFrame::getLocal() can be const

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 13 01:41:59 PDT 2022


Author: Timm Bäder
Date: 2022-09-13T10:41:24+02:00
New Revision: 5d2451468c5f105bd7837f57c5e385fbbbdb65a4

URL: https://github.com/llvm/llvm-project/commit/5d2451468c5f105bd7837f57c5e385fbbbdb65a4
DIFF: https://github.com/llvm/llvm-project/commit/5d2451468c5f105bd7837f57c5e385fbbbdb65a4.diff

LOG: [clang][Interp][NFC] InterpFrame::getLocal() can be const

Make localRef() const and use that.

Added: 
    

Modified: 
    clang/lib/AST/Interp/InterpFrame.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/InterpFrame.h b/clang/lib/AST/Interp/InterpFrame.h
index ca9803d48dd1..88b4a5af8e5a 100644
--- a/clang/lib/AST/Interp/InterpFrame.h
+++ b/clang/lib/AST/Interp/InterpFrame.h
@@ -63,7 +63,7 @@ class InterpFrame final : public Frame {
   size_t getFrameOffset() const { return FrameOffset; }
 
   /// Returns the value of a local variable.
-  template <typename T> const T &getLocal(unsigned Offset) {
+  template <typename T> const T &getLocal(unsigned Offset) const {
     return localRef<T>(Offset);
   }
 
@@ -118,7 +118,7 @@ class InterpFrame final : public Frame {
   }
 
   /// Returns an offset to a local.
-  template <typename T> T &localRef(unsigned Offset) {
+  template <typename T> T &localRef(unsigned Offset) const {
     return *reinterpret_cast<T *>(Locals.get() + Offset);
   }
 


        


More information about the cfe-commits mailing list