From fceb246fa59a77dc063f34c46b5a244c07a715ec Mon Sep 17 00:00:00 2001
From: Axel Naumann <Axel.Naumann@cern.ch>
Date: Wed, 4 Dec 2013 11:26:02 +0100
Subject: [PATCH] Adapt to StoredValueRef interface change.

(cherry picked from commit b5d991d9a06b604fc7a9edcf9bff96d2899b8655)
---
 core/meta/src/TClingCallFunc.cxx              | 58 +++++++++----------
 .../lib/Interpreter/ExecutionContext.cpp      |  7 ++-
 .../cling/lib/Interpreter/ExecutionContext.h  |  4 +-
 .../cling/lib/Interpreter/Interpreter.cpp     |  2 +-
 .../cling/lib/MetaProcessor/MetaSema.cpp      |  2 +-
 5 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/core/meta/src/TClingCallFunc.cxx b/core/meta/src/TClingCallFunc.cxx
index 753abb29930..c8e8a830dd3 100644
--- a/core/meta/src/TClingCallFunc.cxx
+++ b/core/meta/src/TClingCallFunc.cxx
@@ -111,7 +111,7 @@ EvaluateExpr(cling::Interpreter* interp, const Expr* E)
    if (E->EvaluateAsInt(res, C, /*AllowSideEffects*/Expr::SE_NoSideEffects)) {
       GenericValue gv;
       gv.IntVal = res;
-      return cling::StoredValueRef::bitwiseCopy(C, cling::Value(gv, C.IntTy));
+      return cling::StoredValueRef::bitwiseCopy(*interp, cling::Value(gv, C.IntTy));
    }
    // TODO: Build a wrapper around the expression to avoid decompilation and
    // compilation and other string operations.
@@ -2119,7 +2119,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
       QualType QT = Context.getLValueReferenceType(ClassTy);
       GenericValue gv;
       exec(address, &gv.PointerVal);
-      *ret = cling::StoredValueRef::bitwiseCopy(Context,
+      *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                 cling::Value(gv, QT));
       return;
    }
@@ -2127,7 +2127,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
    if (QT->isReferenceType()) {
       GenericValue gv;
       exec(address, &gv.PointerVal);
-      *ret = cling::StoredValueRef::bitwiseCopy(Context,
+      *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                 cling::Value(gv, QT));
       return;
    }
@@ -2140,14 +2140,14 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
          // storage to the storage for the designated data member.
          GenericValue gv;
          exec(address, &gv.PointerVal);
-         *ret = cling::StoredValueRef::bitwiseCopy(Context,
+         *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                    cling::Value(gv, QT));
          return;
       }
       // We are a function member pointer.
       GenericValue gv;
       exec(address, &gv.PointerVal);
-      *ret = cling::StoredValueRef::bitwiseCopy(Context,
+      *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                 cling::Value(gv, QT));
       return;
    }
@@ -2155,7 +2155,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
       // Note: ArrayType is an illegal function return value type.
       GenericValue gv;
       exec(address, &gv.PointerVal);
-      *ret = cling::StoredValueRef::bitwiseCopy(Context,
+      *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                 cling::Value(gv, QT));
       return;
    }
@@ -2163,7 +2163,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
       uint64_t size = Context.getTypeSizeInChars(QT).getQuantity();
       void* p = ::operator new(size);
       exec(address, p);
-      *ret = cling::StoredValueRef::bitwiseCopy(Context,
+      *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                 cling::Value(PTOGV(p),
                                                 QT));
       return;
@@ -2179,7 +2179,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
       GenericValue gv;
       gv.IntVal = APInt(numBits, (uint64_t) retVal,
                               true/*isSigned*/);
-      *ret =  cling::StoredValueRef::bitwiseCopy(Context,
+      *ret =  cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                  cling::Value(gv, QT));
       return;
    }
@@ -2205,7 +2205,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2216,7 +2216,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2227,7 +2227,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2238,7 +2238,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2279,7 +2279,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2290,7 +2290,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2301,7 +2301,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2312,7 +2312,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, false/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2344,7 +2344,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2355,7 +2355,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2366,7 +2366,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2377,7 +2377,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2388,7 +2388,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2399,7 +2399,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2410,7 +2410,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                exec(address, &retVal);
                GenericValue gv;
                gv.IntVal = APInt(numBits, (uint64_t) retVal, true/*isSigned*/);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2450,7 +2450,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                // float
                GenericValue gv;
                exec(address, &gv.FloatVal);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2459,7 +2459,7 @@ TClingCallFunc::exec_with_valref_return(void* address, cling::StoredValueRef* re
                // double
                GenericValue gv;
                exec(address, &gv.DoubleVal);
-               *ret = cling::StoredValueRef::bitwiseCopy(Context,
+               *ret = cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT));
                return;
             }
@@ -2920,7 +2920,7 @@ TClingCallFunc::SetArg(long param)
    GenericValue gv;
    QualType QT = C.LongTy;
    gv.IntVal = APInt(C.getTypeSize(QT), param);
-   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(C,
+   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT)));
 }
 
@@ -2931,7 +2931,7 @@ TClingCallFunc::SetArg(double param)
    GenericValue gv;
    QualType QT = C.DoubleTy;
    gv.DoubleVal = param;
-   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(C,
+   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT)));
 }
 
@@ -2942,7 +2942,7 @@ TClingCallFunc::SetArg(long long param)
    GenericValue gv;
    QualType QT = C.LongLongTy;
    gv.IntVal = APInt(C.getTypeSize(QT), param);
-   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(C,
+   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT)));
 }
 
@@ -2953,7 +2953,7 @@ TClingCallFunc::SetArg(unsigned long long param)
    GenericValue gv;
    QualType QT = C.UnsignedLongLongTy;
    gv.IntVal = APInt(C.getTypeSize(QT), param);
-   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(C,
+   fArgVals.push_back(cling::StoredValueRef::bitwiseCopy(*fInterp,
                                                          cling::Value(gv, QT)));
 }
 
diff --git a/interpreter/cling/lib/Interpreter/ExecutionContext.cpp b/interpreter/cling/lib/Interpreter/ExecutionContext.cpp
index 7a44299ab8b..0d8b3cf751d 100644
--- a/interpreter/cling/lib/Interpreter/ExecutionContext.cpp
+++ b/interpreter/cling/lib/Interpreter/ExecutionContext.cpp
@@ -198,7 +198,7 @@ freeCallersOfUnresolvedSymbols(llvm::SmallVectorImpl<llvm::Function*>&
 
 ExecutionContext::ExecutionResult
 ExecutionContext::executeFunction(llvm::StringRef funcname,
-                                  const clang::ASTContext& Ctx,
+                                  Interpreter& interp,
                                   clang::QualType retType,
                                   StoredValueRef* returnValue)
 {
@@ -238,7 +238,8 @@ ExecutionContext::executeFunction(llvm::StringRef funcname,
   if (f->hasStructRetAttr()) {
     // Function expects to receive the storage for the returned aggregate as
     // first argument. Allocate returnValue:
-    aggregateRet = StoredValueRef::allocate(Ctx, retType, f->getReturnType());
+    aggregateRet = StoredValueRef::allocate(interp, retType,
+                                            f->getReturnType());
     if (returnValue) {
       *returnValue = aggregateRet;
     } else {
@@ -252,7 +253,7 @@ ExecutionContext::executeFunction(llvm::StringRef funcname,
   if (wantReturn) {
     llvm::GenericValue gvRet = m_engine->runFunction(f, args);
     // rescue the ret value (which might be aggregate) from the stack
-    *returnValue = StoredValueRef::bitwiseCopy(Ctx, Value(gvRet, retType));
+    *returnValue = StoredValueRef::bitwiseCopy(interp, Value(gvRet, retType));
   } else {
     m_engine->runFunction(f, args);
   }
diff --git a/interpreter/cling/lib/Interpreter/ExecutionContext.h b/interpreter/cling/lib/Interpreter/ExecutionContext.h
index 26f323be122..bdab534292a 100644
--- a/interpreter/cling/lib/Interpreter/ExecutionContext.h
+++ b/interpreter/cling/lib/Interpreter/ExecutionContext.h
@@ -1,6 +1,5 @@
 //--------------------------------------------------------------------*- C++ -*-
 // CLING - the C++ LLVM-based InterpreterG :)
-// version: $Id$
 // author:  Axel Naumann <axel@cern.ch>
 //------------------------------------------------------------------------------
 
@@ -34,6 +33,7 @@ namespace cling {
   } // end namespace runtime
 
   class StoredValueRef;
+  class Interpreter;
 
   class ExecutionContext {
   public:
@@ -137,7 +137,7 @@ namespace cling {
     void runStaticDestructorsOnce(llvm::Module* m);
 
     ExecutionResult executeFunction(llvm::StringRef function,
-                                    const clang::ASTContext& Ctx,
+                                    Interpreter& interp,
                                     clang::QualType retType,
                                     StoredValueRef* returnValue = 0);
 
diff --git a/interpreter/cling/lib/Interpreter/Interpreter.cpp b/interpreter/cling/lib/Interpreter/Interpreter.cpp
index 3031de48be2..40e8044d9de 100644
--- a/interpreter/cling/lib/Interpreter/Interpreter.cpp
+++ b/interpreter/cling/lib/Interpreter/Interpreter.cpp
@@ -661,7 +661,7 @@ namespace cling {
     utils::Analyze::maybeMangleDeclName(FD, mangledNameIfNeeded);
     ExecutionContext::ExecutionResult ExeRes =
        m_ExecutionContext->executeFunction(mangledNameIfNeeded.c_str(),
-                                           getCI()->getASTContext(),
+                                           *this,
                                            FD->getResultType(), res);
     if (res && res->isValid())
       res->get().setLLVMType(getLLVMType(res->get().getClangType()));
diff --git a/interpreter/cling/lib/MetaProcessor/MetaSema.cpp b/interpreter/cling/lib/MetaProcessor/MetaSema.cpp
index a48d687564b..3dc63536cfa 100644
--- a/interpreter/cling/lib/MetaProcessor/MetaSema.cpp
+++ b/interpreter/cling/lib/MetaProcessor/MetaSema.cpp
@@ -223,7 +223,7 @@ namespace cling {
       retGV.IntVal = llvm::APInt(sizeof(int) * 8, ret, true /*isSigned*/);
       Value V(retGV, Ctx.IntTy);
       if (result)
-        *result = StoredValueRef::bitwiseCopy(Ctx, V);
+        *result = StoredValueRef::bitwiseCopy(m_Interpreter, V);
 
       return (ret == 0) ? AR_Success : AR_Failure;
     }
-- 
GitLab