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/Streams.h"
16 #include "llvm/Support/SystemUtils.h"
17 #include "llvm/System/Process.h"
18 #include "llvm/System/Program.h"
22 bool llvm::CheckBitcodeOutputToConsole(raw_ostream
* stream_to_check
,
24 if (stream_to_check
== &outs() &&
25 sys::Process::StandardOutIsDisplayed()) {
27 cerr
<< "WARNING: You're attempting to print out a bitcode file.\n"
28 << "This is inadvisable as it may cause display problems. If\n"
29 << "you REALLY want to taste LLVM bitcode first-hand, you\n"
30 << "can force output with the `-f' option.\n\n";
37 bool llvm::CheckBitcodeOutputToConsole(std::ostream
* stream_to_check
,
39 if (stream_to_check
== cout
.stream() &&
40 sys::Process::StandardOutIsDisplayed()) {
42 cerr
<< "WARNING: You're attempting to print out a bitcode file.\n"
43 << "This is inadvisable as it may cause display problems. If\n"
44 << "you REALLY want to taste LLVM bitcode first-hand, you\n"
45 << "can force output with the `-f' option.\n\n";
52 /// FindExecutable - Find a named executable, giving the argv[0] of program
53 /// being executed. This allows us to find another LLVM tool if it is built in
54 /// the same directory. If the executable cannot be found, return an
56 /// @brief Find a named executable.
57 #undef FindExecutable // needed on windows :(
58 sys::Path
llvm::FindExecutable(const std::string
&ExeName
,
59 const char *Argv0
, void *MainAddr
) {
60 // Check the directory that the calling program is in. We can do
61 // this if ProgramPath contains at least one / character, indicating that it
62 // is a relative path to the executable itself.
63 sys::Path Result
= sys::Path::GetMainExecutable(Argv0
, MainAddr
);
64 Result
.eraseComponent();
65 if (!Result
.isEmpty()) {
66 Result
.appendComponent(ExeName
);
67 if (Result
.canExecute())