HeaderSearchOptions.h revision 9946fc735d7285f2195f89635370f534afd9877e
1//===--- HeaderSearchOptions.h ----------------------------------*- 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_LEX_HEADERSEARCHOPTIONS_H 11#define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H 12 13#include "clang/Basic/LLVM.h" 14#include "llvm/ADT/IntrusiveRefCntPtr.h" 15#include "llvm/ADT/StringRef.h" 16#include <vector> 17 18namespace clang { 19 20namespace frontend { 21 /// IncludeDirGroup - Identifiers the group a include entry belongs to, which 22 /// represents its relative positive in the search list. A \#include of a "" 23 /// path starts at the -iquote group, then searches the Angled group, then 24 /// searches the system group, etc. 25 enum IncludeDirGroup { 26 Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'. 27 Angled, ///< Paths for '\#include <>' added by '-I'. 28 IndexHeaderMap, ///< Like Angled, but marks header maps used when 29 /// building frameworks. 30 System, ///< Like Angled, but marks system directories. 31 CSystem, ///< Like System, but only used for C. 32 CXXSystem, ///< Like System, but only used for C++. 33 ObjCSystem, ///< Like System, but only used for ObjC. 34 ObjCXXSystem, ///< Like System, but only used for ObjC++. 35 After ///< Like System, but searched after the system directories. 36 }; 37} 38 39/// HeaderSearchOptions - Helper class for storing options related to the 40/// initialization of the HeaderSearch object. 41class HeaderSearchOptions : public llvm::RefCountedBase<HeaderSearchOptions> { 42public: 43 struct Entry { 44 std::string Path; 45 frontend::IncludeDirGroup Group; 46 unsigned IsUserSupplied : 1; 47 unsigned IsFramework : 1; 48 49 /// IgnoreSysRoot - This is false if an absolute path should be treated 50 /// relative to the sysroot, or true if it should always be the absolute 51 /// path. 52 unsigned IgnoreSysRoot : 1; 53 54 /// \brief True if this entry is an internal search path. 55 /// 56 /// This typically indicates that users didn't directly provide it, but 57 /// instead it was provided by a compatibility layer for a particular 58 /// system. This isn't redundant with IsUserSupplied (even though perhaps 59 /// it should be) because that is false for user provided '-iwithprefix' 60 /// header search entries. 61 unsigned IsInternal : 1; 62 63 /// \brief True if this entry's headers should be wrapped in extern "C". 64 unsigned ImplicitExternC : 1; 65 66 Entry(StringRef path, frontend::IncludeDirGroup group, 67 bool isUserSupplied, bool isFramework, bool ignoreSysRoot, 68 bool isInternal, bool implicitExternC) 69 : Path(path), Group(group), IsUserSupplied(isUserSupplied), 70 IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot), 71 IsInternal(isInternal), ImplicitExternC(implicitExternC) {} 72 }; 73 74 struct SystemHeaderPrefix { 75 /// A prefix to be matched against paths in \#include directives. 76 std::string Prefix; 77 78 /// True if paths beginning with this prefix should be treated as system 79 /// headers. 80 bool IsSystemHeader; 81 82 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) 83 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {} 84 }; 85 86 /// If non-empty, the directory to use as a "virtual system root" for include 87 /// paths. 88 std::string Sysroot; 89 90 /// User specified include entries. 91 std::vector<Entry> UserEntries; 92 93 /// User-specified system header prefixes. 94 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes; 95 96 /// The directory which holds the compiler resource files (builtin includes, 97 /// etc.). 98 std::string ResourceDir; 99 100 /// \brief The directory used for the module cache. 101 std::string ModuleCachePath; 102 103 /// \brief Whether we should disable the use of the hash string within the 104 /// module cache. 105 /// 106 /// Note: Only used for testing! 107 unsigned DisableModuleHash : 1; 108 109 /// Include the compiler builtin includes. 110 unsigned UseBuiltinIncludes : 1; 111 112 /// Include the system standard include search directories. 113 unsigned UseStandardSystemIncludes : 1; 114 115 /// Include the system standard C++ library include search directories. 116 unsigned UseStandardCXXIncludes : 1; 117 118 /// Use libc++ instead of the default libstdc++. 119 unsigned UseLibcxx : 1; 120 121 /// Whether header search information should be output as for -v. 122 unsigned Verbose : 1; 123 124public: 125 HeaderSearchOptions(StringRef _Sysroot = "/") 126 : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), 127 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 128 UseLibcxx(false), Verbose(false) {} 129 130 /// AddPath - Add the \p Path path to the specified \p Group list. 131 void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 132 bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot, 133 bool IsInternal = false, bool ImplicitExternC = false) { 134 UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework, 135 IgnoreSysRoot, IsInternal, ImplicitExternC)); 136 } 137 138 /// AddSystemHeaderPrefix - Override whether \#include directives naming a 139 /// path starting with \p Prefix should be considered as naming a system 140 /// header. 141 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { 142 SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); 143 } 144}; 145 146} // end namespace clang 147 148#endif 149