clang API Documentation
00001 //===--- Utils.h - Misc utilities for the front-end -------------*- C++ -*-===// 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 header contains miscellaneous utilities for various front-end actions. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_FRONTEND_UTILS_H 00015 #define LLVM_CLANG_FRONTEND_UTILS_H 00016 00017 #include "clang/Basic/Diagnostic.h" 00018 #include "llvm/ADT/IntrusiveRefCntPtr.h" 00019 #include "llvm/ADT/StringRef.h" 00020 00021 namespace llvm { 00022 class raw_fd_ostream; 00023 class Triple; 00024 } 00025 00026 namespace clang { 00027 class ASTConsumer; 00028 class CompilerInstance; 00029 class CompilerInvocation; 00030 class Decl; 00031 class DependencyOutputOptions; 00032 class DiagnosticsEngine; 00033 class DiagnosticOptions; 00034 class FileManager; 00035 class HeaderSearch; 00036 class HeaderSearchOptions; 00037 class IdentifierTable; 00038 class LangOptions; 00039 class Preprocessor; 00040 class PreprocessorOptions; 00041 class PreprocessorOutputOptions; 00042 class SourceManager; 00043 class Stmt; 00044 class TargetInfo; 00045 class FrontendOptions; 00046 00047 /// Apply the header search options to get given HeaderSearch object. 00048 void ApplyHeaderSearchOptions(HeaderSearch &HS, 00049 const HeaderSearchOptions &HSOpts, 00050 const LangOptions &Lang, 00051 const llvm::Triple &triple); 00052 00053 /// InitializePreprocessor - Initialize the preprocessor getting it and the 00054 /// environment ready to process a single file. 00055 void InitializePreprocessor(Preprocessor &PP, 00056 const PreprocessorOptions &PPOpts, 00057 const HeaderSearchOptions &HSOpts, 00058 const FrontendOptions &FEOpts); 00059 00060 /// ProcessWarningOptions - Initialize the diagnostic client and process the 00061 /// warning options specified on the command line. 00062 void ProcessWarningOptions(DiagnosticsEngine &Diags, 00063 const DiagnosticOptions &Opts); 00064 00065 /// DoPrintPreprocessedInput - Implement -E mode. 00066 void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, 00067 const PreprocessorOutputOptions &Opts); 00068 00069 /// AttachDependencyFileGen - Create a dependency file generator, and attach 00070 /// it to the given preprocessor. This takes ownership of the output stream. 00071 void AttachDependencyFileGen(Preprocessor &PP, 00072 const DependencyOutputOptions &Opts); 00073 00074 /// AttachDependencyGraphGen - Create a dependency graph generator, and attach 00075 /// it to the given preprocessor. 00076 void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, 00077 StringRef SysRoot); 00078 00079 /// AttachHeaderIncludeGen - Create a header include list generator, and attach 00080 /// it to the given preprocessor. 00081 /// 00082 /// \param ShowAllHeaders - If true, show all header information instead of just 00083 /// headers following the predefines buffer. This is useful for making sure 00084 /// includes mentioned on the command line are also reported, but differs from 00085 /// the default behavior used by -H. 00086 /// \param OutputPath - If non-empty, a path to write the header include 00087 /// information to, instead of writing to stderr. 00088 void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders = false, 00089 StringRef OutputPath = "", 00090 bool ShowDepth = true); 00091 00092 /// CacheTokens - Cache tokens for use with PCH. Note that this requires 00093 /// a seekable stream. 00094 void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS); 00095 00096 /// createInvocationFromCommandLine - Construct a compiler invocation object for 00097 /// a command line argument vector. 00098 /// 00099 /// \return A CompilerInvocation, or 0 if none was built for the given 00100 /// argument vector. 00101 CompilerInvocation * 00102 createInvocationFromCommandLine(ArrayRef<const char *> Args, 00103 IntrusiveRefCntPtr<DiagnosticsEngine> Diags = 00104 IntrusiveRefCntPtr<DiagnosticsEngine>()); 00105 00106 } // end namespace clang 00107 00108 #endif