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.is_displayed()) {
25 errs() << "WARNING: You're attempting to print out a bitcode file.\n"
26 "This is inadvisable as it may cause display problems. If\n"
27 "you REALLY want to taste LLVM bitcode first-hand, you\n"
28 "can force output with the `-f' option.\n\n";
35 /// FindExecutable - Find a named executable, given the value of argv[0] of the
36 /// program being executed and the address of main itself. This allows us to
37 /// find another LLVM tool if it is built in the same directory. An empty string
38 /// is returned on error.
39 #undef FindExecutable // needed on windows :(
40 sys::Path llvm::FindExecutable(const std::string &ExeName,
41 const char *Argv0, void *MainAddr) {
42 // Check the directory that the calling program is in. We can do
43 // this if ProgramPath contains at least one / character, indicating that it
44 // is a relative path to the executable itself.
45 sys::Path Result = sys::Path::GetMainExecutable(Argv0, MainAddr);
46 Result.eraseComponent();
48 if (!Result.isEmpty()) {
49 Result.appendComponent(ExeName);
50 Result.appendSuffix(sys::Path::GetEXESuffix());