clang API Documentation
00001 //===--- HeaderSearchOptions.h ----------------------------------*- 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 #ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H 00011 #define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H 00012 00013 #include "clang/Basic/LLVM.h" 00014 #include "llvm/ADT/IntrusiveRefCntPtr.h" 00015 #include "llvm/ADT/SetVector.h" 00016 #include "llvm/ADT/StringRef.h" 00017 #include <string> 00018 #include <vector> 00019 00020 namespace clang { 00021 00022 namespace frontend { 00023 /// IncludeDirGroup - Identifiers the group a include entry belongs to, which 00024 /// represents its relative positive in the search list. A \#include of a "" 00025 /// path starts at the -iquote group, then searches the Angled group, then 00026 /// searches the system group, etc. 00027 enum IncludeDirGroup { 00028 Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'. 00029 Angled, ///< Paths for '\#include <>' added by '-I'. 00030 IndexHeaderMap, ///< Like Angled, but marks header maps used when 00031 /// building frameworks. 00032 System, ///< Like Angled, but marks system directories. 00033 ExternCSystem, ///< Like System, but headers are implicitly wrapped in 00034 /// extern "C". 00035 CSystem, ///< Like System, but only used for C. 00036 CXXSystem, ///< Like System, but only used for C++. 00037 ObjCSystem, ///< Like System, but only used for ObjC. 00038 ObjCXXSystem, ///< Like System, but only used for ObjC++. 00039 After ///< Like System, but searched after the system directories. 00040 }; 00041 } 00042 00043 /// HeaderSearchOptions - Helper class for storing options related to the 00044 /// initialization of the HeaderSearch object. 00045 class HeaderSearchOptions : public RefCountedBase<HeaderSearchOptions> { 00046 public: 00047 struct Entry { 00048 std::string Path; 00049 frontend::IncludeDirGroup Group; 00050 unsigned IsFramework : 1; 00051 00052 /// IgnoreSysRoot - This is false if an absolute path should be treated 00053 /// relative to the sysroot, or true if it should always be the absolute 00054 /// path. 00055 unsigned IgnoreSysRoot : 1; 00056 00057 Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework, 00058 bool ignoreSysRoot) 00059 : Path(path), Group(group), IsFramework(isFramework), 00060 IgnoreSysRoot(ignoreSysRoot) {} 00061 }; 00062 00063 struct SystemHeaderPrefix { 00064 /// A prefix to be matched against paths in \#include directives. 00065 std::string Prefix; 00066 00067 /// True if paths beginning with this prefix should be treated as system 00068 /// headers. 00069 bool IsSystemHeader; 00070 00071 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) 00072 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {} 00073 }; 00074 00075 /// If non-empty, the directory to use as a "virtual system root" for include 00076 /// paths. 00077 std::string Sysroot; 00078 00079 /// User specified include entries. 00080 std::vector<Entry> UserEntries; 00081 00082 /// User-specified system header prefixes. 00083 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes; 00084 00085 /// The directory which holds the compiler resource files (builtin includes, 00086 /// etc.). 00087 std::string ResourceDir; 00088 00089 /// \brief The directory used for the module cache. 00090 std::string ModuleCachePath; 00091 00092 /// \brief The directory used for a user build. 00093 std::string ModuleUserBuildPath; 00094 00095 /// \brief Whether we should disable the use of the hash string within the 00096 /// module cache. 00097 /// 00098 /// Note: Only used for testing! 00099 unsigned DisableModuleHash : 1; 00100 00101 /// \brief Interpret module maps. This option is implied by full modules. 00102 unsigned ModuleMaps : 1; 00103 00104 /// \brief The interval (in seconds) between pruning operations. 00105 /// 00106 /// This operation is expensive, because it requires Clang to walk through 00107 /// the directory structure of the module cache, stat()'ing and removing 00108 /// files. 00109 /// 00110 /// The default value is large, e.g., the operation runs once a week. 00111 unsigned ModuleCachePruneInterval; 00112 00113 /// \brief The time (in seconds) after which an unused module file will be 00114 /// considered unused and will, therefore, be pruned. 00115 /// 00116 /// When the module cache is pruned, any module file that has not been 00117 /// accessed in this many seconds will be removed. The default value is 00118 /// large, e.g., a month, to avoid forcing infrequently-used modules to be 00119 /// regenerated often. 00120 unsigned ModuleCachePruneAfter; 00121 00122 /// \brief The time in seconds when the build session started. 00123 /// 00124 /// This time is used by other optimizations in header search and module 00125 /// loading. 00126 uint64_t BuildSessionTimestamp; 00127 00128 /// \brief The set of macro names that should be ignored for the purposes 00129 /// of computing the module hash. 00130 llvm::SetVector<std::string> ModulesIgnoreMacros; 00131 00132 /// \brief The set of user-provided module-map-files. 00133 llvm::SetVector<std::string> ModuleMapFiles; 00134 00135 /// \brief The set of user-provided virtual filesystem overlay files. 00136 std::vector<std::string> VFSOverlayFiles; 00137 00138 /// Include the compiler builtin includes. 00139 unsigned UseBuiltinIncludes : 1; 00140 00141 /// Include the system standard include search directories. 00142 unsigned UseStandardSystemIncludes : 1; 00143 00144 /// Include the system standard C++ library include search directories. 00145 unsigned UseStandardCXXIncludes : 1; 00146 00147 /// Use libc++ instead of the default libstdc++. 00148 unsigned UseLibcxx : 1; 00149 00150 /// Whether header search information should be output as for -v. 00151 unsigned Verbose : 1; 00152 00153 /// \brief If true, skip verifying input files used by modules if the 00154 /// module was already verified during this build session (see 00155 /// \c BuildSessionTimestamp). 00156 unsigned ModulesValidateOncePerBuildSession : 1; 00157 00158 /// \brief Whether to validate system input files when a module is loaded. 00159 unsigned ModulesValidateSystemHeaders : 1; 00160 00161 public: 00162 HeaderSearchOptions(StringRef _Sysroot = "/") 00163 : Sysroot(_Sysroot), DisableModuleHash(0), ModuleMaps(0), 00164 ModuleCachePruneInterval(7*24*60*60), 00165 ModuleCachePruneAfter(31*24*60*60), 00166 BuildSessionTimestamp(0), 00167 UseBuiltinIncludes(true), 00168 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 00169 UseLibcxx(false), Verbose(false), 00170 ModulesValidateOncePerBuildSession(false), 00171 ModulesValidateSystemHeaders(false) {} 00172 00173 /// AddPath - Add the \p Path path to the specified \p Group list. 00174 void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 00175 bool IsFramework, bool IgnoreSysRoot) { 00176 UserEntries.push_back(Entry(Path, Group, IsFramework, IgnoreSysRoot)); 00177 } 00178 00179 /// AddSystemHeaderPrefix - Override whether \#include directives naming a 00180 /// path starting with \p Prefix should be considered as naming a system 00181 /// header. 00182 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { 00183 SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); 00184 } 00185 00186 void AddVFSOverlayFile(StringRef Name) { 00187 VFSOverlayFiles.push_back(Name); 00188 } 00189 }; 00190 00191 } // end namespace clang 00192 00193 #endif