1//===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This header contains miscellaneous utilities for various front-end actions. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_FRONTEND_UTILS_H 15#define LLVM_CLANG_FRONTEND_UTILS_H 16 17#include "clang/Basic/Diagnostic.h" 18#include "llvm/ADT/IntrusiveRefCntPtr.h" 19#include "llvm/ADT/StringRef.h" 20 21namespace llvm { 22class raw_fd_ostream; 23class Triple; 24} 25 26namespace clang { 27class ASTConsumer; 28class CompilerInstance; 29class CompilerInvocation; 30class Decl; 31class DependencyOutputOptions; 32class DiagnosticsEngine; 33class DiagnosticOptions; 34class FileManager; 35class HeaderSearch; 36class HeaderSearchOptions; 37class IdentifierTable; 38class LangOptions; 39class Preprocessor; 40class PreprocessorOptions; 41class PreprocessorOutputOptions; 42class SourceManager; 43class Stmt; 44class TargetInfo; 45class FrontendOptions; 46 47/// Apply the header search options to get given HeaderSearch object. 48void ApplyHeaderSearchOptions(HeaderSearch &HS, 49 const HeaderSearchOptions &HSOpts, 50 const LangOptions &Lang, 51 const llvm::Triple &triple); 52 53/// InitializePreprocessor - Initialize the preprocessor getting it and the 54/// environment ready to process a single file. 55void InitializePreprocessor(Preprocessor &PP, 56 const PreprocessorOptions &PPOpts, 57 const HeaderSearchOptions &HSOpts, 58 const FrontendOptions &FEOpts); 59 60/// ProcessWarningOptions - Initialize the diagnostic client and process the 61/// warning options specified on the command line. 62void ProcessWarningOptions(DiagnosticsEngine &Diags, 63 const DiagnosticOptions &Opts); 64 65/// DoPrintPreprocessedInput - Implement -E mode. 66void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, 67 const PreprocessorOutputOptions &Opts); 68 69/// AttachDependencyFileGen - Create a dependency file generator, and attach 70/// it to the given preprocessor. This takes ownership of the output stream. 71void AttachDependencyFileGen(Preprocessor &PP, 72 const DependencyOutputOptions &Opts); 73 74/// AttachDependencyGraphGen - Create a dependency graph generator, and attach 75/// it to the given preprocessor. 76 void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, 77 StringRef SysRoot); 78 79/// AttachHeaderIncludeGen - Create a header include list generator, and attach 80/// it to the given preprocessor. 81/// 82/// \param ShowAllHeaders - If true, show all header information instead of just 83/// headers following the predefines buffer. This is useful for making sure 84/// includes mentioned on the command line are also reported, but differs from 85/// the default behavior used by -H. 86/// \param OutputPath - If non-empty, a path to write the header include 87/// information to, instead of writing to stderr. 88void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false, 89 StringRef OutputPath = "", 90 bool ShowDepth = true); 91 92/// CacheTokens - Cache tokens for use with PCH. Note that this requires 93/// a seekable stream. 94void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); 95 96/// createInvocationFromCommandLine - Construct a compiler invocation object for 97/// a command line argument vector. 98/// 99/// \return A CompilerInvocation, or 0 if none was built for the given 100/// argument vector. 101CompilerInvocation * 102createInvocationFromCommandLine(ArrayRef<const char *> Args, 103 IntrusiveRefCntPtr<DiagnosticsEngine> Diags = 104 IntrusiveRefCntPtr<DiagnosticsEngine>()); 105 106} // end namespace clang 107 108#endif 109