about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-25 05:17:51 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-25 05:17:51 +0000
commitf8f6c637b24f11703a9991361df8c4260242dbd9 (patch)
tree717be1833e7890a7221396695562ba75d36defbe /lib/Core
parent6fdbb198e201ae935e19fb824a88f168f07c928a (diff)
downloadklee-f8f6c637b24f11703a9991361df8c4260242dbd9.tar.gz
(llvm up) Update for llvm::Value getName() change.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@77049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/CallPathManager.cpp12
-rw-r--r--lib/Core/Executor.cpp89
-rw-r--r--lib/Core/Executor.h13
-rw-r--r--lib/Core/ExecutorTimers.cpp2
-rw-r--r--lib/Core/Memory.cpp4
-rw-r--r--lib/Core/SpecialFunctionHandler.cpp7
-rw-r--r--lib/Core/StatsTracker.cpp4
7 files changed, 70 insertions, 61 deletions
diff --git a/lib/Core/CallPathManager.cpp b/lib/Core/CallPathManager.cpp
index d0a61b31..ca127f25 100644
--- a/lib/Core/CallPathManager.cpp
+++ b/lib/Core/CallPathManager.cpp
@@ -14,7 +14,7 @@
 #include <map>
 #include <vector>
 #include "llvm/Function.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 using namespace klee;
@@ -31,14 +31,14 @@ CallPathNode::CallPathNode(CallPathNode *_parent,
 }
 
 void CallPathNode::print() {
-  llvm::cerr << "  (Function: " << this->function->getName() << ", "
-	     << "Callsite: " << callSite << ", "
-	     << "Count: " << this->count << ")";
+  llvm::errs() << "  (Function: " << this->function->getName() << ", "
+               << "Callsite: " << callSite << ", "
+               << "Count: " << this->count << ")";
   if (parent && parent->callSite) {
-    llvm::cerr << ";\n";
+    llvm::errs() << ";\n";
     parent->print();
   }
-  else llvm::cerr << "\n";
+  else llvm::errs() << "\n";
 }
 
 ///
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index df9c5b49..f007293a 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Process.h"
 #include "llvm/Target/TargetData.h"
 
@@ -442,7 +443,7 @@ void Executor::initializeGlobals(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->getNameStr())) {
       addr = Expr::createPointer(0);
     } else {
       addr = Expr::createPointer((unsigned long) (void*) f);
@@ -496,23 +497,23 @@ void Executor::initializeGlobals(ExecutionState &state) {
       // hack where we check the object file information.
 
       const Type *ty = i->getType()->getElementType();
-      const std::string &name = i->getName();
       uint64_t size = kmodule->targetData->getTypeStoreSize(ty);
 
       // XXX - DWD - hardcode some things until we decide how to fix.
 #ifndef WINDOWS
-      if (name == "_ZTVN10__cxxabiv117__class_type_infoE") {
+      if (i->getName() == "_ZTVN10__cxxabiv117__class_type_infoE") {
         size = 0x2C;
-      } else if (name == "_ZTVN10__cxxabiv120__si_class_type_infoE") {
+      } else if (i->getName() == "_ZTVN10__cxxabiv120__si_class_type_infoE") {
         size = 0x2C;
-      } else if (name == "_ZTVN10__cxxabiv121__vmi_class_type_infoE") {
+      } else if (i->getName() == "_ZTVN10__cxxabiv121__vmi_class_type_infoE") {
         size = 0x2C;
       }
 #endif
 
       if (size == 0) {
-        llvm::cerr << "Unable to find size for global variable: " << i->getName() 
-                   << " (use will result in out of bounds access)\n";
+        llvm::errs() << "Unable to find size for global variable: " 
+                     << i->getName() 
+                     << " (use will result in out of bounds access)\n";
       }
 
       MemoryObject *mo = memory->allocate(size, false, true, i);
@@ -524,28 +525,27 @@ void Executor::initializeGlobals(ExecutionState &state) {
       // concrete value and write it to our copy.
       if (size) {
         void *addr;
-        if (name=="__dso_handle") {
+        if (i->getName() == "__dso_handle") {
           extern void *__dso_handle __attribute__ ((__weak__));
           addr = &__dso_handle; // wtf ?
         } else {
-          addr = externalDispatcher->resolveSymbol(name);
+          addr = externalDispatcher->resolveSymbol(i->getNameStr());
         }
         if (!addr)
           klee_error("unable to load symbol(%s) while initializing globals.", 
-                     name.c_str());
+                     i->getName().data());
 
         for (unsigned offset=0; offset<mo->size; offset++)
           os->write8(offset, ((unsigned char*)addr)[offset]);
       }
     } else {
-      const std::string &name = i->getName();
       const Type *ty = i->getType()->getElementType();
       uint64_t size = kmodule->targetData->getTypeStoreSize(ty);
       MemoryObject *mo = 0;
 
-      if (UseAsmAddresses && name[0]=='\01') {
+      if (UseAsmAddresses && i->getName()[0]=='\01') {
         char *end;
-        uint64_t address = ::strtoll(name.c_str()+1, &end, 0);
+        uint64_t address = ::strtoll(i->getNameStr().c_str()+1, &end, 0);
 
         if (end && *end == '\0') {
           klee_message("NOTE: allocated global at asm specified address: %#08llx"
@@ -1089,10 +1089,9 @@ void Executor::executeCall(ExecutionState &state,
                            std::vector< ref<Expr> > &arguments) {
   if (WriteTraces) {
     // don't print out special debug stop point 'function' calls
-    if (f->getIntrinsicID() != Intrinsic::dbg_stoppoint) {
-      const std::string& calleeFuncName = f->getName();
-      state.exeTraceMgr.addEvent(new FunctionCallTraceEvent(state, ki, calleeFuncName));
-    }
+    if (f->getIntrinsicID() != Intrinsic::dbg_stoppoint)
+      state.exeTraceMgr.addEvent(new FunctionCallTraceEvent(state, ki, 
+                                                            f->getName()));
   }
 
   Instruction *i = ki->inst;
@@ -1124,7 +1123,7 @@ void Executor::executeCall(ExecutionState &state,
           
       case Intrinsic::vacopy: // should be lowered
       default:
-        klee_error("unknown intrinsic: %s", f->getName().c_str());
+        klee_error("unknown intrinsic: %s", f->getName().data());
       }
     }
 
@@ -1148,7 +1147,7 @@ void Executor::executeCall(ExecutionState &state,
     if (!f->isVarArg()) {
       if (callingArgs > funcArgs) {
         klee_warning_once(f, "calling %s with extra arguments.", 
-                          f->getName().c_str());
+                          f->getName().data());
       } else if (callingArgs < funcArgs) {
         terminateStateOnError(state, "calling function with too few arguments", 
                               "user.err");
@@ -1226,12 +1225,12 @@ Function* Executor::getCalledFunction(CallSite &cs, ExecutionState &state) {
   if (f) {
     std::string alias = state.getFnAlias(f->getName());
     if (alias != "") {
-      //llvm::cerr << f->getName() << "() is aliased with " << alias << "()\n";
       llvm::Module* currModule = kmodule->module;
       Function* old_f = f;
       f = currModule->getFunction(alias);
       if (!f) {
-	llvm::cerr << "Function " << alias << "(), alias for " << old_f->getName() << " not found!\n";
+	llvm::errs() << "Function " << alias << "(), alias for " 
+                     << old_f->getName() << " not found!\n";
 	assert(f && "function alias not found");
       }
     }
@@ -1529,7 +1528,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
             if (res.second || !first)
               klee_warning_once((void*) (unsigned long) addr, 
                                 "resolved symbolic function pointer to: %s",
-                                f->getName().c_str());
+                                f->getName().data());
 
             executeCall(*res.first, ki, f, arguments);
           } else {
@@ -2392,10 +2391,12 @@ void Executor::terminateState(ExecutionState &state) {
   }
 }
 
-void Executor::terminateStateEarly(ExecutionState &state, std::string message) {
+void Executor::terminateStateEarly(ExecutionState &state, 
+                                   const Twine &message) {
   if (!OnlyOutputStatesCoveringNew || state.coveredNew ||
       (AlwaysOutputSeeds && seedMap.count(&state)))
-    interpreterHandler->processTestCase(state, (message + "\n").c_str(), "early");
+    interpreterHandler->processTestCase(state, (message + "\n").str().c_str(),
+                                        "early");
   terminateState(state);
 }
 
@@ -2407,14 +2408,15 @@ void Executor::terminateStateOnExit(ExecutionState &state) {
 }
 
 void Executor::terminateStateOnError(ExecutionState &state,
-                                     const std::string &message,
-                                     const std::string &suffix,
-                                     const std::string &info) {
+                                     const llvm::Twine &messaget,
+                                     const char *suffix,
+                                     const llvm::Twine &info) {
+  std::string message = messaget.str();
   static std::set< std::pair<Instruction*, std::string> > emittedErrors;
   const InstructionInfo &ii = *state.prevPC->info;
   
   if (EmitAllErrors ||
-      emittedErrors.insert(std::make_pair(state.prevPC->inst,message)).second) {
+      emittedErrors.insert(std::make_pair(state.prevPC->inst, message)).second) {
     if (ii.file != "") {
       klee_message("ERROR: %s:%d: %s", ii.file.c_str(), ii.line, message.c_str());
     } else {
@@ -2440,14 +2442,14 @@ void Executor::terminateStateOnError(ExecutionState &state,
       const InstructionInfo &ii = *target->info;
       msg << "\t#" << idx++ 
           << " " << std::setw(8) << std::setfill('0') << ii.assemblyLine
-          << " in " << f->getName() << " (";
+          << " in " << f->getNameStr() << " (";
       // Yawn, we could go up and print varargs if we wanted to.
       unsigned index = 0;
       for (Function::arg_iterator ai = f->arg_begin(), ae = f->arg_end();
            ai != ae; ++ai) {
         if (ai!=f->arg_begin()) msg << ", ";
 
-        msg << ai->getName();
+        msg << ai->getNameStr();
         // XXX should go through function
         ref<Expr> value = sf.locals[sf.kf->getArgRegister(index++)].value; 
         if (isa<ConstantExpr>(value))
@@ -2460,9 +2462,10 @@ void Executor::terminateStateOnError(ExecutionState &state,
       target = sf.caller;
     }
 
-    if (info != "")
-      msg << "Info: \n" << info;
-    interpreterHandler->processTestCase(state, msg.str().c_str(), suffix.c_str());
+    std::string info_str = info.str();
+    if (info_str != "")
+      msg << "Info: \n" << info_str;
+    interpreterHandler->processTestCase(state, msg.str().c_str(), suffix);
   }
     
   terminateState(state);
@@ -2486,7 +2489,8 @@ void Executor::callExternalFunction(ExecutionState &state,
     return;
   
   if (NoExternals && !okExternals.count(function->getName())) {
-    llvm::cerr << "KLEE:ERROR: Calling not-OK external function : " << function->getName() << "\n";
+    llvm::cerr << "KLEE:ERROR: Calling not-OK external function : " 
+               << function->getNameStr() << "\n";
     terminateStateOnError(state, "externals disallowed", "user.err");
     return;
   }
@@ -2496,8 +2500,8 @@ void Executor::callExternalFunction(ExecutionState &state,
   memset(args, 0, sizeof(*args) * (arguments.size() + 1));
 
   unsigned i = 1;
-  for (std::vector<ref<Expr> >::iterator ai = arguments.begin(), ae = arguments.end();
-       ai!=ae; ++ai, ++i) {
+  for (std::vector<ref<Expr> >::iterator ai = arguments.begin(), 
+         ae = arguments.end(); ai!=ae; ++ai, ++i) {
     if (AllowExternalSymCalls) { // don't bother checking uniqueness
       ref<ConstantExpr> ce;
       bool success = solver->getValue(state, *ai, ce);
@@ -2510,8 +2514,9 @@ void Executor::callExternalFunction(ExecutionState &state,
         // XXX kick toMemory functions from here
         CE->toMemory((void*) &args[i]);
       } else {
-        std::string msg = "external call with symbolic argument: " + function->getName();
-        terminateStateOnExecError(state, msg);
+        terminateStateOnExecError(state, 
+                                  "external call with symbolic argument: " + 
+                                  function->getName());
         return;
       }
     }
@@ -2521,7 +2526,7 @@ void Executor::callExternalFunction(ExecutionState &state,
 
   if (!SuppressExternalWarnings) {
     std::ostringstream os;
-    os << "calling external: " << function->getName().c_str() << "(";
+    os << "calling external: " << function->getNameStr() << "(";
     for (unsigned i=0; i<arguments.size(); i++) {
       os << arguments[i];
       if (i != arguments.size()-1)
@@ -2537,12 +2542,14 @@ void Executor::callExternalFunction(ExecutionState &state,
   
   bool success = externalDispatcher->executeCall(function, target->inst, args);
   if (!success) {
-    terminateStateOnError(state, "failed external call: " + function->getName(), "external.err");
+    terminateStateOnError(state, "failed external call: " + function->getName(),
+                          "external.err");
     return;
   }
 
   if (!state.addressSpace.copyInConcretes()) {
-    terminateStateOnError(state, "external modified read-only object", "external.err");
+    terminateStateOnError(state, "external modified read-only object",
+                          "external.err");
     return;
   }
 
diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h
index 88a3db4e..c8211854 100644
--- a/lib/Core/Executor.h
+++ b/lib/Core/Executor.h
@@ -38,6 +38,7 @@ namespace llvm {
   class GlobalValue;
   class Instruction;
   class TargetData;
+  class Twine;
   class Value;
 }
 
@@ -333,21 +334,21 @@ private:
   // remove state from queue and delete
   void terminateState(ExecutionState &state);
   // call exit handler and terminate state
-  void terminateStateEarly(ExecutionState &state, std::string message);
+  void terminateStateEarly(ExecutionState &state, const llvm::Twine &message);
   // call exit handler and terminate state
   void terminateStateOnExit(ExecutionState &state);
   // call error handler and terminate state
   void terminateStateOnError(ExecutionState &state, 
-                             const std::string &message,
-                             const std::string &suffix,
-                             const std::string &longMessage="");
+                             const llvm::Twine &message,
+                             const char *suffix,
+                             const llvm::Twine &longMessage="");
 
   // call error handler and terminate state, for execution errors
   // (things that should not be possible, like illegal instruction or
   // unlowered instrinsic, or are unsupported, like inline assembly)
   void terminateStateOnExecError(ExecutionState &state, 
-                                 const std::string &message,
-                                 const std::string &info="") {
+                                 const llvm::Twine &message,
+                                 const llvm::Twine &info="") {
     terminateStateOnError(state, message, "exec.err", info);
   }
 
diff --git a/lib/Core/ExecutorTimers.cpp b/lib/Core/ExecutorTimers.cpp
index 51792e0d..0c274d5c 100644
--- a/lib/Core/ExecutorTimers.cpp
+++ b/lib/Core/ExecutorTimers.cpp
@@ -155,7 +155,7 @@ void Executor::processTimers(ExecutionState *current,
           ++next;
           for (ExecutionState::stack_ty::iterator sfIt = es->stack.begin(),
                  sf_ie = es->stack.end(); sfIt != sf_ie; ++sfIt) {
-            *os << "('" << sfIt->kf->function->getName() << "',";
+            *os << "('" << sfIt->kf->function->getNameStr() << "',";
             if (next == es->stack.end()) {
               *os << es->prevPC->info->line << "), ";
             } else {
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index 1a929a12..2032fd53 100644
--- a/lib/Core/Memory.cpp
+++ b/lib/Core/Memory.cpp
@@ -72,10 +72,10 @@ void MemoryObject::getAllocInfo(std::string &result) const {
   if (allocSite) {
     info << " allocated at ";
     if (const Instruction *i = dyn_cast<Instruction>(allocSite)) {
-      info << i->getParent()->getParent()->getName() << "():";
+      info << i->getParent()->getParent()->getNameStr() << "():";
       info << *i;
     } else if (const GlobalValue *gv = dyn_cast<GlobalValue>(allocSite)) {
-      info << "global:" << gv->getName();
+      info << "global:" << gv->getNameStr();
     } else {
       info << "value:" << *allocSite;
     }
diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp
index db673f15..9904f052 100644
--- a/lib/Core/SpecialFunctionHandler.cpp
+++ b/lib/Core/SpecialFunctionHandler.cpp
@@ -22,6 +22,7 @@
 #include "MemoryManager.h"
 
 #include "llvm/Module.h"
+#include "llvm/ADT/Twine.h"
 
 #include <errno.h>
 
@@ -297,7 +298,7 @@ void SpecialFunctionHandler::handleReportError(ExecutionState &state,
   } else
     executor.terminateStateOnError(state, 
                                    readStringAtAddress(state, arguments[2]),
-                                   readStringAtAddress(state, arguments[3]));
+                                   readStringAtAddress(state, arguments[3]).c_str());
 }
 
 void SpecialFunctionHandler::handleMerge(ExecutionState &state,
@@ -430,7 +431,7 @@ void SpecialFunctionHandler::handleWarning(ExecutionState &state,
   assert(arguments.size()==1 && "invalid number of arguments to klee_warning");
 
   std::string msg_str = readStringAtAddress(state, arguments[0]);
-  klee_warning("%s: %s", state.stack.back().kf->function->getName().c_str(), 
+  klee_warning("%s: %s", state.stack.back().kf->function->getName().data(), 
                msg_str.c_str());
 }
 
@@ -441,7 +442,7 @@ void SpecialFunctionHandler::handleWarningOnce(ExecutionState &state,
          "invalid number of arguments to klee_warning_once");
 
   std::string msg_str = readStringAtAddress(state, arguments[0]);
-  klee_warning_once(0, "%s: %s", state.stack.back().kf->function->getName().c_str(), 
+  klee_warning_once(0, "%s: %s", state.stack.back().kf->function->getName().data(),
                     msg_str.c_str());
 }
 
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index 7a87024d..3437e10c 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -464,7 +464,7 @@ void StatsTracker::writeIStats() {
   for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); 
        fnIt != fn_ie; ++fnIt) {
     if (!fnIt->isDeclaration()) {
-      of << "fn=" << fnIt->getName() << "\n";
+      of << "fn=" << fnIt->getNameStr() << "\n";
       for (Function::iterator bbIt = fnIt->begin(), bb_ie = fnIt->end(); 
            bbIt != bb_ie; ++bbIt) {
         for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); 
@@ -497,7 +497,7 @@ void StatsTracker::writeIStats() {
   
                 if (fii.file!="" && fii.file!=sourceFile)
                   of << "cfl=" << fii.file << "\n";
-                of << "cfn=" << f->getName() << "\n";
+                of << "cfn=" << f->getNameStr() << "\n";
                 of << "calls=" << csi.count << " ";
                 of << fii.assemblyLine << " ";
                 of << fii.line << "\n";