PageRenderTime 28ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/clang/include/clang/Frontend/CompilerInvocation.h

https://github.com/lygstate/safecode-mirror
C Header | 194 lines | 95 code | 38 blank | 61 comment | 0 complexity | 4e4b8e2165e664ad2cf096e94b15c9b9 MD5 | raw file
  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. #ifndef LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
  10. #define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
  11. #include "clang/Basic/LangOptions.h"
  12. #include "clang/Basic/TargetOptions.h"
  13. #include "clang/Basic/FileSystemOptions.h"
  14. #include "clang/Frontend/AnalyzerOptions.h"
  15. #include "clang/Frontend/CodeGenOptions.h"
  16. #include "clang/Frontend/DependencyOutputOptions.h"
  17. #include "clang/Frontend/DiagnosticOptions.h"
  18. #include "clang/Frontend/FrontendOptions.h"
  19. #include "clang/Frontend/HeaderSearchOptions.h"
  20. #include "clang/Frontend/LangStandard.h"
  21. #include "clang/Frontend/PreprocessorOptions.h"
  22. #include "clang/Frontend/PreprocessorOutputOptions.h"
  23. #include "llvm/ADT/IntrusiveRefCntPtr.h"
  24. #include "llvm/ADT/StringRef.h"
  25. #include "llvm/ADT/StringMap.h"
  26. #include <string>
  27. #include <vector>
  28. namespace clang {
  29. class Diagnostic;
  30. /// CompilerInvocation - Helper class for holding the data necessary to invoke
  31. /// the compiler.
  32. ///
  33. /// This class is designed to represent an abstract "invocation" of the
  34. /// compiler, including data such as the include paths, the code generation
  35. /// options, the warning flags, and so on.
  36. class CompilerInvocation : public llvm::RefCountedBase<CompilerInvocation> {
  37. /// Options controlling the static analyzer.
  38. AnalyzerOptions AnalyzerOpts;
  39. /// Options controlling IRgen and the backend.
  40. CodeGenOptions CodeGenOpts;
  41. /// Options controlling dependency output.
  42. DependencyOutputOptions DependencyOutputOpts;
  43. /// Options controlling the diagnostic engine.
  44. DiagnosticOptions DiagnosticOpts;
  45. /// Options controlling file system operations.
  46. FileSystemOptions FileSystemOpts;
  47. /// Options controlling the frontend itself.
  48. FrontendOptions FrontendOpts;
  49. /// Options controlling the #include directive.
  50. HeaderSearchOptions HeaderSearchOpts;
  51. /// Options controlling the language variant.
  52. LangOptions LangOpts;
  53. /// Options controlling the preprocessor (aside from #include handling).
  54. PreprocessorOptions PreprocessorOpts;
  55. /// Options controlling preprocessed output.
  56. PreprocessorOutputOptions PreprocessorOutputOpts;
  57. /// Options controlling the target.
  58. TargetOptions TargetOpts;
  59. public:
  60. CompilerInvocation() {}
  61. /// @name Utility Methods
  62. /// @{
  63. /// CreateFromArgs - Create a compiler invocation from a list of input
  64. /// options.
  65. ///
  66. /// \param Res [out] - The resulting invocation.
  67. /// \param ArgBegin - The first element in the argument vector.
  68. /// \param ArgEnd - The last element in the argument vector.
  69. /// \param Diags - The diagnostic engine to use for errors.
  70. static void CreateFromArgs(CompilerInvocation &Res,
  71. const char* const *ArgBegin,
  72. const char* const *ArgEnd,
  73. Diagnostic &Diags);
  74. /// GetBuiltinIncludePath - Get the directory where the compiler headers
  75. /// reside, relative to the compiler binary (found by the passed in
  76. /// arguments).
  77. ///
  78. /// \param Argv0 - The program path (from argv[0]), for finding the builtin
  79. /// compiler path.
  80. /// \param MainAddr - The address of main (or some other function in the main
  81. /// executable), for finding the builtin compiler path.
  82. static std::string GetResourcesPath(const char *Argv0, void *MainAddr);
  83. /// toArgs - Convert the CompilerInvocation to a list of strings suitable for
  84. /// passing to CreateFromArgs.
  85. void toArgs(std::vector<std::string> &Res);
  86. /// setLangDefaults - Set language defaults for the given input language and
  87. /// language standard in this CompilerInvocation.
  88. ///
  89. /// \param IK - The input language.
  90. /// \param LangStd - The input language standard.
  91. void setLangDefaults(InputKind IK,
  92. LangStandard::Kind LangStd = LangStandard::lang_unspecified) {
  93. setLangDefaults(LangOpts, IK, LangStd);
  94. }
  95. /// setLangDefaults - Set language defaults for the given input language and
  96. /// language standard in the given LangOptions object.
  97. ///
  98. /// \param LangOpts - The LangOptions object to set up.
  99. /// \param IK - The input language.
  100. /// \param LangStd - The input language standard.
  101. static void setLangDefaults(LangOptions &Opts, InputKind IK,
  102. LangStandard::Kind LangStd = LangStandard::lang_unspecified);
  103. /// \brief Retrieve a module hash string that is suitable for uniquely
  104. /// identifying the conditions under which the module was built.
  105. std::string getModuleHash() const;
  106. /// @}
  107. /// @name Option Subgroups
  108. /// @{
  109. AnalyzerOptions &getAnalyzerOpts() { return AnalyzerOpts; }
  110. const AnalyzerOptions &getAnalyzerOpts() const {
  111. return AnalyzerOpts;
  112. }
  113. CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
  114. const CodeGenOptions &getCodeGenOpts() const {
  115. return CodeGenOpts;
  116. }
  117. DependencyOutputOptions &getDependencyOutputOpts() {
  118. return DependencyOutputOpts;
  119. }
  120. const DependencyOutputOptions &getDependencyOutputOpts() const {
  121. return DependencyOutputOpts;
  122. }
  123. DiagnosticOptions &getDiagnosticOpts() { return DiagnosticOpts; }
  124. const DiagnosticOptions &getDiagnosticOpts() const { return DiagnosticOpts; }
  125. FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
  126. const FileSystemOptions &getFileSystemOpts() const {
  127. return FileSystemOpts;
  128. }
  129. HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
  130. const HeaderSearchOptions &getHeaderSearchOpts() const {
  131. return HeaderSearchOpts;
  132. }
  133. FrontendOptions &getFrontendOpts() { return FrontendOpts; }
  134. const FrontendOptions &getFrontendOpts() const {
  135. return FrontendOpts;
  136. }
  137. LangOptions &getLangOpts() { return LangOpts; }
  138. const LangOptions &getLangOpts() const { return LangOpts; }
  139. PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
  140. const PreprocessorOptions &getPreprocessorOpts() const {
  141. return PreprocessorOpts;
  142. }
  143. PreprocessorOutputOptions &getPreprocessorOutputOpts() {
  144. return PreprocessorOutputOpts;
  145. }
  146. const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
  147. return PreprocessorOutputOpts;
  148. }
  149. TargetOptions &getTargetOpts() { return TargetOpts; }
  150. const TargetOptions &getTargetOpts() const {
  151. return TargetOpts;
  152. }
  153. /// @}
  154. };
  155. } // end namespace clang
  156. #endif