HeaderSearchOptions.h revision 59fd63581d6d572f23e82e81a50e0b940c8d1089
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 Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework, 56 bool ignoreSysRoot) 57 : Path(path), Group(group), IsFramework(isFramework), 58 IgnoreSysRoot(ignoreSysRoot) {} 59 }; 60 61 struct SystemHeaderPrefix { 62 /// A prefix to be matched against paths in \#include directives. 63 std::string Prefix; 64 65 /// True if paths beginning with this prefix should be treated as system 66 /// headers. 67 bool IsSystemHeader; 68 69 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) 70 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {} 71 }; 72 73 /// If non-empty, the directory to use as a "virtual system root" for include 74 /// paths. 75 std::string Sysroot; 76 77 /// User specified include entries. 78 std::vector<Entry> UserEntries; 79 80 /// User-specified system header prefixes. 81 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes; 82 83 /// The directory which holds the compiler resource files (builtin includes, 84 /// etc.). 85 std::string ResourceDir; 86 87 /// \brief The directory used for the module cache. 88 std::string ModuleCachePath; 89 90 /// \brief Whether we should disable the use of the hash string within the 91 /// module cache. 92 /// 93 /// Note: Only used for testing! 94 unsigned DisableModuleHash : 1; 95 96 /// Include the compiler builtin includes. 97 unsigned UseBuiltinIncludes : 1; 98 99 /// Include the system standard include search directories. 100 unsigned UseStandardSystemIncludes : 1; 101 102 /// Include the system standard C++ library include search directories. 103 unsigned UseStandardCXXIncludes : 1; 104 105 /// Use libc++ instead of the default libstdc++. 106 unsigned UseLibcxx : 1; 107 108 /// Whether header search information should be output as for -v. 109 unsigned Verbose : 1; 110 111public: 112 HeaderSearchOptions(StringRef _Sysroot = "/") 113 : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), 114 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 115 UseLibcxx(false), Verbose(false) {} 116 117 /// AddPath - Add the \p Path path to the specified \p Group list. 118 void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 119 bool IsFramework, bool IgnoreSysRoot) { 120 UserEntries.push_back(Entry(Path, Group, IsFramework, IgnoreSysRoot)); 121 } 122 123 /// AddSystemHeaderPrefix - Override whether \#include directives naming a 124 /// path starting with \p Prefix should be considered as naming a system 125 /// header. 126 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { 127 SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); 128 } 129}; 130 131} // end namespace clang 132 133#endif 134