LLVM API Documentation
00001 //===- SystemUtils.cpp - Utilities for low-level system tasks -------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains functions used to do a variety of low-level, often 00011 // system-specific, tasks. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/Support/Streams.h" 00016 #include "llvm/Support/SystemUtils.h" 00017 #include "llvm/System/Process.h" 00018 #include "llvm/System/Program.h" 00019 #include <ostream> 00020 using namespace llvm; 00021 00022 bool llvm::CheckBitcodeOutputToConsole(std::ostream* stream_to_check, 00023 bool print_warning) { 00024 if (stream_to_check == cout.stream() && 00025 sys::Process::StandardOutIsDisplayed()) { 00026 if (print_warning) { 00027 cerr << "WARNING: You're attempting to print out a bitcode file.\n" 00028 << "This is inadvisable as it may cause display problems. If\n" 00029 << "you REALLY want to taste LLVM bitcode first-hand, you\n" 00030 << "can force output with the `-f' option.\n\n"; 00031 } 00032 return true; 00033 } 00034 return false; 00035 } 00036 00037 /// FindExecutable - Find a named executable, giving the argv[0] of program 00038 /// being executed. This allows us to find another LLVM tool if it is built 00039 /// into the same directory, but that directory is neither the current 00040 /// directory, nor in the PATH. If the executable cannot be found, return an 00041 /// empty string. 00042 /// 00043 #undef FindExecutable // needed on windows :( 00044 sys::Path llvm::FindExecutable(const std::string &ExeName, 00045 const std::string &ProgramPath) { 00046 // First check the directory that the calling program is in. We can do this 00047 // if ProgramPath contains at least one / character, indicating that it is a 00048 // relative path to bugpoint itself. 00049 sys::Path Result ( ProgramPath ); 00050 Result.eraseComponent(); 00051 if (!Result.isEmpty()) { 00052 Result.appendComponent(ExeName); 00053 if (Result.canExecute()) 00054 return Result; 00055 } 00056 00057 return sys::Program::FindProgramByName(ExeName); 00058 }
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.