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