diff options
author | Cristian Cadar <cristic@cs.stanford.edu> | 2012-10-24 16:03:30 +0000 |
---|---|---|
committer | Cristian Cadar <cristic@cs.stanford.edu> | 2012-10-24 16:03:30 +0000 |
commit | 5f9b8f9424b5bf8737cb36894c3da9b9d79aeb3c (patch) | |
tree | c427157ced461f955f8a460bd55b798b5108e7ba /tools | |
parent | 4316936f20713742b1fdf9070505efbc9596ccb6 (diff) | |
download | klee-5f9b8f9424b5bf8737cb36894c3da9b9d79aeb3c.tar.gz |
Code refactorings by Jonathan Neuschäfer: "move increment into for-loop
head (Just a cosmetic change to make things a bit more readable)" and "move duplicate code to a function and also remove an old comment that seems to be obsolete by now. (Another cosmetic change)" git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@166581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/klee/main.cpp | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index d28356bd..9d445ac7 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -950,6 +950,23 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { return 0; } #else +static void replaceOrRenameFunction(llvm::Module *module, + const char *old_name, const char *new_name) +{ + Function *f, *f2; + f = module->getFunction(new_name); + f2 = module->getFunction(old_name); + if (f2) { + if (f) { + f2->replaceAllUsesWith(f); + f2->eraseFromParent(); + } else { + f2->setName(new_name); + assert(f2->getName() == new_name); + } + } +} + static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { Function *f; // force import of __uClibc_main @@ -989,9 +1006,8 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { // versions are present in the module, make sure we don't create a // naming conflict. for (Module::iterator fi = mainModule->begin(), fe = mainModule->end(); - fi != fe;) { + fi != fe; ++fi) { Function *f = fi; - ++fi; const std::string &name = f->getName(); if (name[0]=='\01') { unsigned size = name.size(); @@ -1013,36 +1029,10 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule) { KLEE_UCLIBC "/lib/libc.a"); assert(mainModule && "unable to link with uclibc"); - // more sighs, this is horrible but just a temp hack - // f = mainModule->getFunction("__fputc_unlocked"); - // if (f) f->setName("fputc_unlocked"); - // f = mainModule->getFunction("__fgetc_unlocked"); - // if (f) f->setName("fgetc_unlocked"); - - Function *f2; - f = mainModule->getFunction("open"); - f2 = mainModule->getFunction("__libc_open"); - if (f2) { - if (f) { - f2->replaceAllUsesWith(f); - f2->eraseFromParent(); - } else { - f2->setName("open"); - assert(f2->getName() == "open"); - } - } - f = mainModule->getFunction("fcntl"); - f2 = mainModule->getFunction("__libc_fcntl"); - if (f2) { - if (f) { - f2->replaceAllUsesWith(f); - f2->eraseFromParent(); - } else { - f2->setName("fcntl"); - assert(f2->getName() == "fcntl"); - } - } + replaceOrRenameFunction(mainModule, "__libc_open", "open"); + replaceOrRenameFunction(mainModule, "__libc_fcntl", "fcntl"); + // XXX we need to rearchitect so this can also be used with // programs externally linked with uclibc. |