From 7194ccff0c0b826c6d77408e65bcd24ff3bcc6b7 Mon Sep 17 00:00:00 2001 From: kai Date: Sat, 29 Jun 2013 13:00:46 +0200 Subject: [PATCH] Simplify file handling code. Removes dependency of a DMD class and is compatible with LLVM 3.x. --- gen/todebug.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 26e29f93..d2f12359 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -28,9 +28,6 @@ #include "llvm/Support/Dwarf.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#if LDC_LLVM_VER >= 304 -#include "llvm/Support/PathV1.h" -#endif using namespace llvm::dwarf; @@ -579,22 +576,13 @@ void DtoDwarfCompileUnit(Module* m) LOG_SCOPE; // prepare srcpath - const char *srcname = m->srcfile->name->toChars(); - std::string srcpath(FileName::path(srcname)); - if (!FileName::absolute(srcpath.c_str())) { - llvm::sys::Path tmp = llvm::sys::Path::GetCurrentDirectory(); - tmp.appendComponent(srcpath); - srcpath = tmp.str(); - if (!srcpath.empty() && *srcpath.rbegin() != '/' && *srcpath.rbegin() != '\\') - srcpath = srcpath + '/'; - } else { - srcname = FileName::name(srcname); - } + llvm::SmallString<128> srcpath(m->srcfile->name->toChars()); + llvm::sys::fs::make_absolute(srcpath); gIR->dibuilder.createCompileUnit( global.params.symdebug == 2 ? DW_LANG_C : DW_LANG_D, - srcname, - srcpath, + llvm::sys::path::filename(srcpath), + llvm::sys::path::parent_path(srcpath), "LDC (http://wiki.dlang.org/LDC)", false, // isOptimized TODO llvm::StringRef(), // Flags TODO