Constify.

This commit is contained in:
Vassil Vassilev 2019-03-16 11:36:13 +02:00 committed by SFT
parent 9dd448d998
commit 2a88ca8943
2 changed files with 26 additions and 25 deletions

View File

@ -148,8 +148,8 @@ void unresolvedSymbol()
// throw exception instead?
}
void* IncrementalExecutor::HandleMissingFunction(const std::string& mangled_name)
{
void*
IncrementalExecutor::HandleMissingFunction(const std::string& mangled_name) const {
// Not found in the map, add the symbol in the list of unresolved symbols
if (m_unresolvedSymbols.insert(mangled_name).second) {
//cling::errs() << "IncrementalExecutor: use of undefined symbol '"
@ -159,10 +159,9 @@ void* IncrementalExecutor::HandleMissingFunction(const std::string& mangled_name
return utils::FunctionToVoidPtr(&unresolvedSymbol);
}
void* IncrementalExecutor::NotifyLazyFunctionCreators(const std::string& mangled_name)
{
for (std::vector<LazyFunctionCreatorFunc_t>::iterator it
= m_lazyFuncCreator.begin(), et = m_lazyFuncCreator.end();
void*
IncrementalExecutor::NotifyLazyFunctionCreators(const std::string& mangled_name) const {
for (auto it = m_lazyFuncCreator.begin(), et = m_lazyFuncCreator.end();
it != et; ++it) {
void* ret = (void*)((LazyFunctionCreatorFunc_t)*it)(mangled_name);
if (ret)
@ -208,7 +207,7 @@ freeCallersOfUnresolvedSymbols(llvm::SmallVectorImpl<llvm::Function*>&
#endif
IncrementalExecutor::ExecutionResult
IncrementalExecutor::runStaticInitializersOnce(const Transaction& T) {
IncrementalExecutor::runStaticInitializersOnce(const Transaction& T) const {
auto m = T.getModule();
assert(m.get() && "Module must not be null");
@ -326,7 +325,7 @@ static void flushOutBuffers() {
IncrementalExecutor::ExecutionResult
IncrementalExecutor::executeWrapper(llvm::StringRef function,
Value* returnValue/* =0*/) {
Value* returnValue/* =0*/) const {
// Set the value to cling::invalid.
if (returnValue)
*returnValue = Value();
@ -351,12 +350,12 @@ IncrementalExecutor::installLazyFunctionCreator(LazyFunctionCreatorFunc_t fp)
bool
IncrementalExecutor::addSymbol(const char* Name, void* Addr,
bool Jit) {
bool Jit) const {
return m_JIT->lookupSymbol(Name, Addr, Jit).second;
}
void* IncrementalExecutor::getAddressOfGlobal(llvm::StringRef symbolName,
bool* fromJIT /*=0*/) {
bool* fromJIT /*=0*/) const {
// Return a symbol's address, and whether it was jitted.
void* address = m_JIT->lookupSymbol(symbolName).first;
@ -371,7 +370,7 @@ void* IncrementalExecutor::getAddressOfGlobal(llvm::StringRef symbolName,
}
void*
IncrementalExecutor::getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) {
IncrementalExecutor::getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) const {
// Get the function / variable pointer referenced by GV.
// We don't care whether something was unresolved before.
@ -386,7 +385,7 @@ IncrementalExecutor::getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) {
}
bool IncrementalExecutor::diagnoseUnresolvedSymbols(llvm::StringRef trigger,
llvm::StringRef title) {
llvm::StringRef title) const {
if (m_unresolvedSymbols.empty())
return false;

View File

@ -133,7 +133,7 @@ namespace cling {
///\brief Set of the symbols that the JIT couldn't resolve.
///
std::unordered_set<std::string> m_unresolvedSymbols;
mutable std::unordered_set<std::string> m_unresolvedSymbols;
#if 0 // See FIXME in IncrementalExecutor.cpp
///\brief The diagnostics engine, printing out issues coming from the
@ -164,7 +164,7 @@ namespace cling {
void installLazyFunctionCreator(LazyFunctionCreatorFunc_t fp);
///\brief Unload a set of JIT symbols.
bool unloadModule(const std::shared_ptr<llvm::Module>& M) {
bool unloadModule(const std::shared_ptr<llvm::Module>& M) const {
// FIXME: Propagate the error in a more verbose way.
if (auto Err = m_JIT->removeModule(M))
return false;
@ -172,7 +172,7 @@ namespace cling {
}
///\brief Run the static initializers of all modules collected to far.
ExecutionResult runStaticInitializersOnce(const Transaction& T);
ExecutionResult runStaticInitializersOnce(const Transaction& T) const;
///\brief Runs all destructors bound to the given transaction and removes
/// them from the list.
@ -182,7 +182,7 @@ namespace cling {
///\brief Runs a wrapper function.
ExecutionResult executeWrapper(llvm::StringRef function,
Value* returnValue = 0);
Value* returnValue = 0) const;
///\brief Adds a symbol (function) to the execution engine.
///
/// Allows runtime declaration of a function passing its pointer for being
@ -194,13 +194,14 @@ namespace cling {
/// @param[in] JIT - Add to the JIT injected symbol table
/// @returns true if the symbol is successfully registered, false otherwise.
///
bool addSymbol(const char* Name, void* Address, bool JIT = false);
bool addSymbol(const char* Name, void* Address, bool JIT = false) const;
///\brief Emit a llvm::Module to the JIT.
///
/// @param[in] module - The module to pass to the execution engine.
/// @param[in] optLevel - The optimization level to be used.
void emitModule(const std::shared_ptr<llvm::Module>& module, int optLevel) {
void
emitModule(const std::shared_ptr<llvm::Module>& module, int optLevel) const {
if (m_BackendPasses)
m_BackendPasses->runOnModule(*module, optLevel);
@ -223,14 +224,15 @@ namespace cling {
///\param[in] mangledName - the globa's name
///\param[out] fromJIT - whether the symbol was JITted.
///
void* getAddressOfGlobal(llvm::StringRef mangledName, bool* fromJIT = 0);
void*
getAddressOfGlobal(llvm::StringRef mangledName, bool* fromJIT = 0) const;
///\brief Return the address of a global from the JIT (as
/// opposed to dynamic libraries). Forces the emission of the symbol if
/// it has not happened yet.
///
///param[in] GV - global value for which the address will be returned.
void* getPointerToGlobalFromJIT(const llvm::GlobalValue& GV);
void* getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) const;
///\brief Keep track of the entities whose dtor we need to call.
///
@ -239,19 +241,19 @@ namespace cling {
///\brief Try to resolve a symbol through our LazyFunctionCreators;
/// print an error message if that fails.
void* NotifyLazyFunctionCreators(const std::string&);
void* NotifyLazyFunctionCreators(const std::string&) const;
private:
///\brief Report and empty m_unresolvedSymbols.
///\return true if m_unresolvedSymbols was non-empty.
bool diagnoseUnresolvedSymbols(llvm::StringRef trigger,
llvm::StringRef title = llvm::StringRef());
llvm::StringRef title = llvm::StringRef()) const;
///\brief Remember that the symbol could not be resolved by the JIT.
void* HandleMissingFunction(const std::string& symbol);
void* HandleMissingFunction(const std::string& symbol) const;
///\brief Runs an initializer function.
ExecutionResult executeInit(llvm::StringRef function) {
ExecutionResult executeInit(llvm::StringRef function) const {
typedef void (*InitFun_t)();
InitFun_t fun;
ExecutionResult res = jitInitOrWrapper(function, fun);
@ -263,7 +265,7 @@ namespace cling {
}
template <class T>
ExecutionResult jitInitOrWrapper(llvm::StringRef funcname, T& fun) {
ExecutionResult jitInitOrWrapper(llvm::StringRef funcname, T& fun) const {
fun = utils::UIntToFunctionPtr<T>(m_JIT->getSymbolAddress(funcname,
false /*dlsym*/));