1 //===- SystemUtils.cpp - Utilities for low-level system tasks -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains functions used to do a variety of low-level, often
11 // system-specific, tasks.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Support/SystemUtils.h"
16 #include "llvm/System/Process.h"
17 #include "llvm/System/Program.h"
18 #include "llvm/Support/raw_ostream.h"
21 bool llvm::CheckBitcodeOutputToConsole(raw_ostream
&stream_to_check
,
23 if (&stream_to_check
== &outs() &&
24 sys::Process::StandardOutIsDisplayed()) {
26 errs() << "WARNING: You're attempting to print out a bitcode file.\n"
27 << "This is inadvisable as it may cause display problems. If\n"
28 << "you REALLY want to taste LLVM bitcode first-hand, you\n"
29 << "can force output with the `-f' option.\n\n";
36 /// FindExecutable - Find a named executable, giving the argv[0] of program
37 /// being executed. This allows us to find another LLVM tool if it is built in
38 /// the same directory. If the executable cannot be found, return an
40 /// @brief Find a named executable.
41 #undef FindExecutable // needed on windows :(
42 sys::Path
llvm::FindExecutable(const std::string
&ExeName
,
43 const char *Argv0
, void *MainAddr
) {
44 // Check the directory that the calling program is in. We can do
45 // this if ProgramPath contains at least one / character, indicating that it
46 // is a relative path to the executable itself.
47 sys::Path Result
= sys::Path::GetMainExecutable(Argv0
, MainAddr
);
48 Result
.eraseComponent();
49 if (!Result
.isEmpty()) {
50 Result
.appendComponent(ExeName
);
51 if (Result
.canExecute())