HeaderSearchOptions.h revision eab6652b7e417c8e46b21c7d340f3a7d41492d6e
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 RefCountedBase<HeaderSearchOptions> { 42public: 43 struct Entry { 44 std::string Path; 45 frontend::IncludeDirGroup Group; 46 unsigned IsFramework : 1; 47 48 /// IgnoreSysRoot - This is false if an absolute path should be treated 49 /// relative to the sysroot, or true if it should always be the absolute 50 /// path. 51 unsigned IgnoreSysRoot : 1; 52 53 /// \brief True if this entry is an internal search path. 54 /// 55 /// This typically indicates that users didn't directly provide it, but 56 /// instead it was provided by a compatibility layer for a particular 57 /// system. 58 unsigned IsInternal : 1; 59 60 /// \brief True if this entry's headers should be wrapped in extern "C". 61 unsigned ImplicitExternC : 1; 62 63 Entry(StringRef path, frontend::IncludeDirGroup group, 64 bool isFramework, bool ignoreSysRoot, bool isInternal, 65 bool implicitExternC) 66 : Path(path), Group(group), IsFramework(isFramework), 67 IgnoreSysRoot(ignoreSysRoot), IsInternal(isInternal), 68 ImplicitExternC(implicitExternC) {} 69 }; 70 71 struct SystemHeaderPrefix { 72 /// A prefix to be matched against paths in \#include directives. 73 std::string Prefix; 74 75 /// True if paths beginning with this prefix should be treated as system 76 /// headers. 77 bool IsSystemHeader; 78 79 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) 80 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {} 81 }; 82 83 /// If non-empty, the directory to use as a "virtual system root" for include 84 /// paths. 85 std::string Sysroot; 86 87 /// User specified include entries. 88 std::vector<Entry> UserEntries; 89 90 /// User-specified system header prefixes. 91 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes; 92 93 /// The directory which holds the compiler resource files (builtin includes, 94 /// etc.). 95 std::string ResourceDir; 96 97 /// \brief The directory used for the module cache. 98 std::string ModuleCachePath; 99 100 /// \brief Whether we should disable the use of the hash string within the 101 /// module cache. 102 /// 103 /// Note: Only used for testing! 104 unsigned DisableModuleHash : 1; 105 106 /// Include the compiler builtin includes. 107 unsigned UseBuiltinIncludes : 1; 108 109 /// Include the system standard include search directories. 110 unsigned UseStandardSystemIncludes : 1; 111 112 /// Include the system standard C++ library include search directories. 113 unsigned UseStandardCXXIncludes : 1; 114 115 /// Use libc++ instead of the default libstdc++. 116 unsigned UseLibcxx : 1; 117 118 /// Whether header search information should be output as for -v. 119 unsigned Verbose : 1; 120 121public: 122 HeaderSearchOptions(StringRef _Sysroot = "/") 123 : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), 124 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 125 UseLibcxx(false), Verbose(false) {} 126 127 /// AddPath - Add the \p Path path to the specified \p Group list. 128 void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 129 bool IsFramework, bool IgnoreSysRoot, 130 bool IsInternal = false, bool ImplicitExternC = false) { 131 UserEntries.push_back(Entry(Path, Group, IsFramework, 132 IgnoreSysRoot, IsInternal, ImplicitExternC)); 133 } 134 135 /// AddSystemHeaderPrefix - Override whether \#include directives naming a 136 /// path starting with \p Prefix should be considered as naming a system 137 /// header. 138 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { 139 SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); 140 } 141}; 142 143} // end namespace clang 144 145#endif 146