CompilerInvocation.h revision b3375cba7938e01895bb504e7e48ad94a2e07dd1
1//===-- CompilerInvocation.h - Compiler Invocation Helper Data --*- 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#ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_ 11#define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_ 12 13#include "clang/Basic/LangOptions.h" 14#include "clang/Basic/TargetOptions.h" 15#include "clang/CodeGen/CodeGenOptions.h" 16#include "clang/Frontend/AnalysisConsumer.h" 17#include "clang/Frontend/DependencyOutputOptions.h" 18#include "clang/Frontend/DiagnosticOptions.h" 19#include "clang/Frontend/FrontendOptions.h" 20#include "clang/Frontend/HeaderSearchOptions.h" 21#include "clang/Frontend/PreprocessorOptions.h" 22#include "clang/Frontend/PreprocessorOutputOptions.h" 23#include "llvm/ADT/StringRef.h" 24#include "llvm/ADT/StringMap.h" 25#include <string> 26#include <vector> 27 28namespace llvm { 29 template<typename T> class SmallVectorImpl; 30} 31 32namespace clang { 33 34/// CompilerInvocation - Helper class for holding the data necessary to invoke 35/// the compiler. 36/// 37/// This class is designed to represent an abstract "invocation" of the 38/// compiler, including data such as the include paths, the code generation 39/// options, the warning flags, and so on. 40class CompilerInvocation { 41 /// Options controlling the static analyzer. 42 AnalyzerOptions AnalyzerOpts; 43 44 /// Options controlling IRgen and the backend. 45 CodeGenOptions CodeGenOpts; 46 47 /// Options controlling dependency output. 48 DependencyOutputOptions DependencyOutputOpts; 49 50 /// Options controlling the diagnostic engine. 51 DiagnosticOptions DiagnosticOpts; 52 53 /// Options controlling the frontend itself. 54 FrontendOptions FrontendOpts; 55 56 /// Options controlling the #include directive. 57 HeaderSearchOptions HeaderSearchOpts; 58 59 /// Options controlling the language variant. 60 LangOptions LangOpts; 61 62 /// Options controlling the preprocessor (aside from #include handling). 63 PreprocessorOptions PreprocessorOpts; 64 65 /// Options controlling preprocessed output. 66 PreprocessorOutputOptions PreprocessorOutputOpts; 67 68 /// Options controlling the target. 69 TargetOptions TargetOpts; 70 71public: 72 CompilerInvocation() {} 73 74 /// @name Utility Methods 75 /// @{ 76 77 /// CreateFromArgs - Create a compiler invocation from a list of input 78 /// options. 79 /// 80 /// FIXME: Documenting error behavior. 81 /// 82 /// \param Res [out] - The resulting invocation. 83 /// \param Args - The input argument strings. 84 static void CreateFromArgs(CompilerInvocation &Res, 85 const llvm::SmallVectorImpl<llvm::StringRef> &Args); 86 87 /// toArgs - Convert the CompilerInvocation to a list of strings suitable for 88 /// passing to CreateFromArgs. 89 void toArgs(std::vector<std::string> &Res); 90 91 /// @} 92 /// @name Option Subgroups 93 /// @{ 94 95 AnalyzerOptions &getAnalyzerOpts() { return AnalyzerOpts; } 96 const AnalyzerOptions &getAnalyzerOpts() const { 97 return AnalyzerOpts; 98 } 99 100 CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } 101 const CodeGenOptions &getCodeGenOpts() const { 102 return CodeGenOpts; 103 } 104 105 DependencyOutputOptions &getDependencyOutputOpts() { 106 return DependencyOutputOpts; 107 } 108 const DependencyOutputOptions &getDependencyOutputOpts() const { 109 return DependencyOutputOpts; 110 } 111 112 DiagnosticOptions &getDiagnosticOpts() { return DiagnosticOpts; } 113 const DiagnosticOptions &getDiagnosticOpts() const { return DiagnosticOpts; } 114 115 HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; } 116 const HeaderSearchOptions &getHeaderSearchOpts() const { 117 return HeaderSearchOpts; 118 } 119 120 FrontendOptions &getFrontendOpts() { return FrontendOpts; } 121 const FrontendOptions &getFrontendOpts() const { 122 return FrontendOpts; 123 } 124 125 LangOptions &getLangOpts() { return LangOpts; } 126 const LangOptions &getLangOpts() const { return LangOpts; } 127 128 PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; } 129 const PreprocessorOptions &getPreprocessorOpts() const { 130 return PreprocessorOpts; 131 } 132 133 PreprocessorOutputOptions &getPreprocessorOutputOpts() { 134 return PreprocessorOutputOpts; 135 } 136 const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { 137 return PreprocessorOutputOpts; 138 } 139 140 TargetOptions &getTargetOpts() { return TargetOpts; } 141 const TargetOptions &getTargetOpts() const { 142 return TargetOpts; 143 } 144 145 /// @} 146}; 147 148} // end namespace clang 149 150#endif 151