mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 07:09:50 +03:00
Simplify code for LLVM 3.4.
Introduces a compability function instead of a #if/#endif cascade.
This commit is contained in:
parent
683294cec9
commit
e556882be4
1 changed files with 10 additions and 13 deletions
|
@ -39,33 +39,30 @@ static cl::opt<std::string> mslib("ms-lib",
|
|||
typedef std::string RetType;
|
||||
#else
|
||||
typedef sys::Path RetType;
|
||||
|
||||
namespace llvm {
|
||||
namespace sys {
|
||||
inline sys::Path FindProgramByName(const std::string& name)
|
||||
{
|
||||
return llvm::sys::Program::FindProgramByName(name);
|
||||
}
|
||||
} // namespace sys
|
||||
} // namespace llvm
|
||||
#endif
|
||||
|
||||
RetType getProgram(const char *name, const cl::opt<std::string> &opt, const char *envVar = 0)
|
||||
static RetType getProgram(const char *name, const cl::opt<std::string> &opt, const char *envVar = 0)
|
||||
{
|
||||
RetType path;
|
||||
const char *prog = NULL;
|
||||
|
||||
if (opt.getNumOccurrences() > 0 && opt.length() > 0 && (prog = opt.c_str()))
|
||||
#if LDC_LLVM_VER >= 304
|
||||
path = sys::FindProgramByName(prog);
|
||||
#else
|
||||
path = sys::Program::FindProgramByName(prog);
|
||||
#endif
|
||||
|
||||
if (path.empty() && envVar && (prog = getenv(envVar)))
|
||||
#if LDC_LLVM_VER >= 304
|
||||
path = sys::FindProgramByName(prog);
|
||||
#else
|
||||
path = sys::Program::FindProgramByName(prog);
|
||||
#endif
|
||||
|
||||
if (path.empty())
|
||||
#if LDC_LLVM_VER >= 304
|
||||
path = sys::FindProgramByName(name);
|
||||
#else
|
||||
path = sys::Program::FindProgramByName(name);
|
||||
#endif
|
||||
|
||||
if (path.empty()) {
|
||||
error("failed to locate %s", name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue