| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H |
| 10 | #define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H |
| 11 | |
| 12 | #include "clang/Basic/CodeGenOptions.h" |
| 13 | #include "clang/Basic/DiagnosticOptions.h" |
| 14 | #include "clang/Basic/FileSystemOptions.h" |
| 15 | #include "clang/Basic/LLVM.h" |
| 16 | #include "clang/Basic/LangOptions.h" |
| 17 | #include "clang/Frontend/DependencyOutputOptions.h" |
| 18 | #include "clang/Frontend/FrontendOptions.h" |
| 19 | #include "clang/Frontend/LangStandard.h" |
| 20 | #include "clang/Frontend/MigratorOptions.h" |
| 21 | #include "clang/Frontend/PreprocessorOutputOptions.h" |
| 22 | #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" |
| 23 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
| 24 | #include <memory> |
| 25 | #include <string> |
| 26 | |
| 27 | namespace llvm { |
| 28 | |
| 29 | class Triple; |
| 30 | |
| 31 | namespace opt { |
| 32 | |
| 33 | class ArgList; |
| 34 | |
| 35 | } |
| 36 | |
| 37 | namespace vfs { |
| 38 | |
| 39 | class FileSystem; |
| 40 | |
| 41 | } |
| 42 | |
| 43 | } |
| 44 | |
| 45 | namespace clang { |
| 46 | |
| 47 | class DiagnosticsEngine; |
| 48 | class ; |
| 49 | class PreprocessorOptions; |
| 50 | class TargetOptions; |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args, |
| 60 | DiagnosticsEngine *Diags = nullptr, |
| 61 | bool DefaultDiagColor = true, |
| 62 | bool DefaultShowOpt = true); |
| 63 | |
| 64 | class CompilerInvocationBase { |
| 65 | public: |
| 66 | |
| 67 | std::shared_ptr<LangOptions> LangOpts; |
| 68 | |
| 69 | |
| 70 | std::shared_ptr<TargetOptions> TargetOpts; |
| 71 | |
| 72 | |
| 73 | IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts; |
| 74 | |
| 75 | |
| 76 | std::shared_ptr<HeaderSearchOptions> ; |
| 77 | |
| 78 | |
| 79 | std::shared_ptr<PreprocessorOptions> PreprocessorOpts; |
| 80 | |
| 81 | CompilerInvocationBase(); |
| 82 | CompilerInvocationBase(const CompilerInvocationBase &X); |
| 83 | CompilerInvocationBase &operator=(const CompilerInvocationBase &) = delete; |
| 84 | ~CompilerInvocationBase(); |
| 85 | |
| 86 | LangOptions *getLangOpts() { return LangOpts.get(); } |
| 87 | const LangOptions *getLangOpts() const { return LangOpts.get(); } |
| 88 | |
| 89 | TargetOptions &getTargetOpts() { return *TargetOpts.get(); } |
| 90 | const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); } |
| 91 | |
| 92 | DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; } |
| 93 | |
| 94 | HeaderSearchOptions &() { return *HeaderSearchOpts; } |
| 95 | |
| 96 | const HeaderSearchOptions &() const { |
| 97 | return *HeaderSearchOpts; |
| 98 | } |
| 99 | |
| 100 | std::shared_ptr<HeaderSearchOptions> () const { |
| 101 | return HeaderSearchOpts; |
| 102 | } |
| 103 | |
| 104 | std::shared_ptr<PreprocessorOptions> getPreprocessorOptsPtr() { |
| 105 | return PreprocessorOpts; |
| 106 | } |
| 107 | |
| 108 | PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; } |
| 109 | |
| 110 | const PreprocessorOptions &getPreprocessorOpts() const { |
| 111 | return *PreprocessorOpts; |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | class CompilerInvocation : public CompilerInvocationBase { |
| 121 | |
| 122 | AnalyzerOptionsRef AnalyzerOpts; |
| 123 | |
| 124 | MigratorOptions MigratorOpts; |
| 125 | |
| 126 | |
| 127 | CodeGenOptions CodeGenOpts; |
| 128 | |
| 129 | |
| 130 | DependencyOutputOptions DependencyOutputOpts; |
| 131 | |
| 132 | |
| 133 | FileSystemOptions FileSystemOpts; |
| 134 | |
| 135 | |
| 136 | FrontendOptions FrontendOpts; |
| 137 | |
| 138 | |
| 139 | PreprocessorOutputOptions PreprocessorOutputOpts; |
| 140 | |
| 141 | public: |
| 142 | CompilerInvocation() : AnalyzerOpts(new AnalyzerOptions()) {} |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | static bool CreateFromArgs(CompilerInvocation &Res, |
| 155 | const char* const *ArgBegin, |
| 156 | const char* const *ArgEnd, |
| 157 | DiagnosticsEngine &Diags); |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | static std::string GetResourcesPath(const char *Argv0, void *MainAddr); |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | static void setLangDefaults(LangOptions &Opts, InputKind IK, |
| 178 | const llvm::Triple &T, PreprocessorOptions &PPOpts, |
| 179 | LangStandard::Kind LangStd = LangStandard::lang_unspecified); |
| 180 | |
| 181 | |
| 182 | |
| 183 | std::string getModuleHash() const; |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; } |
| 190 | |
| 191 | MigratorOptions &getMigratorOpts() { return MigratorOpts; } |
| 192 | const MigratorOptions &getMigratorOpts() const { return MigratorOpts; } |
| 193 | |
| 194 | CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; } |
| 195 | const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } |
| 196 | |
| 197 | DependencyOutputOptions &getDependencyOutputOpts() { |
| 198 | return DependencyOutputOpts; |
| 199 | } |
| 200 | |
| 201 | const DependencyOutputOptions &getDependencyOutputOpts() const { |
| 202 | return DependencyOutputOpts; |
| 203 | } |
| 204 | |
| 205 | FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } |
| 206 | |
| 207 | const FileSystemOptions &getFileSystemOpts() const { |
| 208 | return FileSystemOpts; |
| 209 | } |
| 210 | |
| 211 | FrontendOptions &getFrontendOpts() { return FrontendOpts; } |
| 212 | const FrontendOptions &getFrontendOpts() const { return FrontendOpts; } |
| 213 | |
| 214 | PreprocessorOutputOptions &getPreprocessorOutputOpts() { |
| 215 | return PreprocessorOutputOpts; |
| 216 | } |
| 217 | |
| 218 | const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { |
| 219 | return PreprocessorOutputOpts; |
| 220 | } |
| 221 | |
| 222 | |
| 223 | }; |
| 224 | |
| 225 | IntrusiveRefCntPtr<llvm::vfs::FileSystem> |
| 226 | createVFSFromCompilerInvocation(const CompilerInvocation &CI, |
| 227 | DiagnosticsEngine &Diags); |
| 228 | |
| 229 | IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation( |
| 230 | const CompilerInvocation &CI, DiagnosticsEngine &Diags, |
| 231 | IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS); |
| 232 | |
| 233 | } |
| 234 | |
| 235 | #endif |
| 236 | |