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