Replace deprecated LLVM functions.

Several functions regarding file handling are deprecated. This commit replaces these functions with the new one from llvm::sys::fs and llvm::sys::path. It also removes some warnings about signed/unsigned mismatches.
This commit is contained in:
kai 2011-11-16 19:05:23 +01:00
parent 7431d58702
commit 1ecd536f45
2 changed files with 28 additions and 23 deletions

View file

@ -1,6 +1,7 @@
#include "gen/linker.h"
#include "gen/llvm.h"
#include "llvm/Linker.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#if _WIN32
#include "llvm/Support/SystemUtils.h"
@ -96,9 +97,8 @@ int linkExecutable(const char* argv0)
assert(gExePath.isValid());
// create path to exe
llvm::sys::Path exedir(gExePath);
exedir.set(gExePath.getDirname());
if (!exedir.exists())
llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str()));
if (!llvm::sys::fs::exists(exedir.str()))
{
exedir.createDirectoryOnDisk(true, &errstr);
if (!errstr.empty())
@ -145,7 +145,7 @@ int linkExecutable(const char* argv0)
}
// additional linker switches
for (int i = 0; i < global.params.linkswitches->dim; i++)
for (unsigned i = 0; i < global.params.linkswitches->dim; i++)
{
char *p = (char *)global.params.linkswitches->data[i];
args.push_back(p);
@ -156,7 +156,7 @@ int linkExecutable(const char* argv0)
// user libs
for (int i = 0; i < global.params.libfiles->dim; i++)
for (unsigned i = 0; i < global.params.libfiles->dim; i++)
{
char *p = (char *)global.params.libfiles->data[i];
args.push_back(p);
@ -180,7 +180,7 @@ int linkExecutable(const char* argv0)
}
// object files
for (int i = 0; i < global.params.objfiles->dim; i++)
for (unsigned i = 0; i < global.params.objfiles->dim; i++)
{
char *p = (char *)global.params.objfiles->data[i];
args.push_back(p);
@ -232,7 +232,7 @@ int linkObjToExecutable(const char* argv0)
args.push_back(gccStr);
// object files
for (int i = 0; i < global.params.objfiles->dim; i++)
for (unsigned i = 0; i < global.params.objfiles->dim; i++)
{
char *p = (char *)global.params.objfiles->data[i];
args.push_back(p);
@ -265,9 +265,8 @@ int linkObjToExecutable(const char* argv0)
assert(gExePath.isValid());
// create path to exe
llvm::sys::Path exedir(gExePath);
exedir.set(gExePath.getDirname());
if (!exedir.exists())
llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str()));
if (!llvm::sys::fs::exists(exedir.str()))
{
exedir.createDirectoryOnDisk(true, &errstr);
if (!errstr.empty())
@ -278,14 +277,14 @@ int linkObjToExecutable(const char* argv0)
}
// additional linker switches
for (int i = 0; i < global.params.linkswitches->dim; i++)
for (unsigned i = 0; i < global.params.linkswitches->dim; i++)
{
char *p = (char *)global.params.linkswitches->data[i];
args.push_back(p);
}
// user libs
for (int i = 0; i < global.params.libfiles->dim; i++)
for (unsigned i = 0; i < global.params.libfiles->dim; i++)
{
char *p = (char *)global.params.libfiles->data[i];
args.push_back(p);
@ -363,7 +362,8 @@ void deleteExecutable()
if (!gExePath.isEmpty())
{
assert(gExePath.isValid());
assert(!gExePath.isDirectory());
bool is_directory;
assert(!(!llvm::sys::fs::is_directory(gExePath.str(), is_directory) && is_directory));
gExePath.eraseFromDisk(false);
}
}
@ -392,7 +392,11 @@ int runExecutable()
int status = llvm::sys::Program::ExecuteAndWait(gExePath, &args[0], NULL, NULL, 0,0, &errstr);
if (status < 0)
{
#if defined(_MSC_VER)
error("program received signal %d", -status);
#else
error("program received signal %d (%s)", -status, strsignal(-status));
#endif
return -status;
}