about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorLukas Zaoral <lzaoral@redhat.com>2020-09-10 17:12:28 +0200
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-12-04 20:35:47 +0000
commitb398c94c821edd3e8699026dc00501062eafd5b2 (patch)
tree862f321cb7e784e28a861f23701e443deeb5ebfe
parent4ca5a80836de48036e47f611a6ea610a6fb2b54b (diff)
downloadklee-b398c94c821edd3e8699026dc00501062eafd5b2.tar.gz
llvm11: Make conversions from StringRef to std::string explicit
The same applies to SmallString.

See: llvm/llvm-project@777180a#diff-497ba4c0c527a125d382b51a34f32542
-rw-r--r--lib/Core/Executor.cpp12
-rw-r--r--lib/Core/ExternalDispatcher.cpp4
-rw-r--r--lib/Module/InstructionInfoTable.cpp4
-rw-r--r--lib/Module/ModuleUtil.cpp11
-rw-r--r--tools/klee/main.cpp6
5 files changed, 18 insertions, 19 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index a0df89f0..333eb563 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -524,7 +524,7 @@ Executor::setModule(std::vector<std::unique_ptr<llvm::Module>> &modules,
   llvm::sys::path::append(LibPath,
                           "libkleeRuntimeIntrinsic" + opts.OptSuffix + ".bca");
   std::string error;
-  if (!klee::loadFile(LibPath.str(), modules[0]->getContext(), modules,
+  if (!klee::loadFile(LibPath.c_str(), modules[0]->getContext(), modules,
                       error)) {
     klee_error("Could not load KLEE intrinsic file %s", LibPath.c_str());
   }
@@ -675,7 +675,7 @@ void Executor::allocateGlobalObjects(ExecutionState &state) {
     // not defined in this module; if it isn't resolvable then it
     // should be null.
     if (f.hasExternalWeakLinkage() &&
-        !externalDispatcher->resolveSymbol(f.getName())) {
+        !externalDispatcher->resolveSymbol(f.getName().str())) {
       addr = Expr::createPointer(0);
     } else {
       addr = Expr::createPointer(reinterpret_cast<std::uint64_t>(&f));
@@ -825,7 +825,7 @@ void Executor::initializeGlobalObjects(ExecutionState &state) {
       if (v.getName() == "__dso_handle") {
         addr = &__dso_handle; // wtf ?
       } else {
-        addr = externalDispatcher->resolveSymbol(v.getName());
+        addr = externalDispatcher->resolveSymbol(v.getName().str());
       }
       if (!addr) {
         klee_error("Unable to load symbol(%.*s) while initializing globals",
@@ -3716,9 +3716,9 @@ void Executor::callExternalFunction(ExecutionState &state,
   // check if specialFunctionHandler wants it
   if (specialFunctionHandler->handle(state, function, target, arguments))
     return;
-  
-  if (ExternalCalls == ExternalCallPolicy::None
-      && !okExternals.count(function->getName())) {
+
+  if (ExternalCalls == ExternalCallPolicy::None &&
+      !okExternals.count(function->getName().str())) {
     klee_warning("Disallowed call to external function: %s\n",
                function->getName().str().c_str());
     terminateStateOnError(state, "external calls disallowed", User);
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index 7ba8df53..baa5327a 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -198,7 +198,7 @@ bool ExternalDispatcherImpl::executeCall(Function *f, Instruction *i,
         std::move(dispatchModuleUniq)); // MCJIT takes ownership
     // Force code generation
     uint64_t fnAddr =
-        executionEngine->getFunctionAddress(dispatcher->getName());
+        executionEngine->getFunctionAddress(dispatcher->getName().str());
     executionEngine->finalizeObject();
     assert(fnAddr && "failed to get function address");
     (void)fnAddr;
@@ -255,7 +255,7 @@ bool ExternalDispatcherImpl::runProtectedCall(Function *f, uint64_t *args) {
 Function *ExternalDispatcherImpl::createDispatcher(Function *target,
                                                    Instruction *inst,
                                                    Module *module) {
-  if (!resolveSymbol(target->getName()))
+  if (!resolveSymbol(target->getName().str()))
     return 0;
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index fde5ff19..05a1f7b9 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -120,7 +120,7 @@ public:
     if (dsub != nullptr) {
       auto path = dsub->getFilename();
       return std::make_unique<FunctionInfo>(FunctionInfo(
-          0, getInternedString(path), dsub->getLine(), asmLine));
+          0, getInternedString(path.str()), dsub->getLine(), asmLine));
     }
 
     // Fallback: Mark as unknown
@@ -151,7 +151,7 @@ public:
         }
       }
       return std::make_unique<InstructionInfo>(InstructionInfo(
-          0, getInternedString(full_path), line, column, asmLine));
+          0, getInternedString(full_path.str()), line, column, asmLine));
     }
 
     if (f != nullptr)
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 2316ef45..7cd66415 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -82,11 +82,11 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
   for (auto const &Function : *M) {
     if (Function.hasName()) {
       if (Function.isDeclaration())
-        UndefinedSymbols.insert(Function.getName());
+        UndefinedSymbols.insert(Function.getName().str());
       else if (!Function.hasLocalLinkage()) {
         assert(!Function.hasDLLImportStorageClass() &&
                "Found dllimported non-external symbol!");
-        DefinedSymbols.insert(Function.getName());
+        DefinedSymbols.insert(Function.getName().str());
       }
     }
   }
@@ -95,18 +95,17 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
        I != E; ++I)
     if (I->hasName()) {
       if (I->isDeclaration())
-        UndefinedSymbols.insert(I->getName());
+        UndefinedSymbols.insert(I->getName().str());
       else if (!I->hasLocalLinkage()) {
         assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
-        DefinedSymbols.insert(I->getName());
+        DefinedSymbols.insert(I->getName().str());
       }
     }
 
   for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
        I != E; ++I)
     if (I->hasName())
-      DefinedSymbols.insert(I->getName());
-
+      DefinedSymbols.insert(I->getName().str());
 
   // Prune out any defined symbols from the undefined symbols set
   // and other symbols we don't want to treat as an undefined symbol
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 7184bd44..874660d7 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -441,7 +441,7 @@ void KleeHandler::setInterpreter(Interpreter *i) {
 std::string KleeHandler::getOutputFilename(const std::string &filename) {
   SmallString<128> path = m_outputDirectory;
   sys::path::append(path,filename);
-  return path.str();
+  return path.c_str();
 }
 
 std::unique_ptr<llvm::raw_fd_ostream>
@@ -673,7 +673,7 @@ std::string KleeHandler::getRunTimeLibraryPath(const char *argv0) {
 
   KLEE_DEBUG_WITH_TYPE("klee_runtime", llvm::dbgs() <<
                        libDir.c_str() << "\n");
-  return libDir.str();
+  return libDir.c_str();
 }
 
 //===----------------------------------------------------------------------===//
@@ -938,7 +938,7 @@ void externalsAndGlobalsCheck(const llvm::Module *m) {
          it = m->alias_begin(), ie = m->alias_end();
        it != ie; ++it) {
     std::map<std::string, bool>::iterator it2 =
-      externals.find(it->getName());
+        externals.find(it->getName().str());
     if (it2!=externals.end())
       externals.erase(it2);
   }