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 /// If non-empty, the directory to use as a "virtual system root" for include 73 /// paths. 74 std::string Sysroot; 75 76 /// User specified include entries. 77 std::vector<Entry> UserEntries; 78 79 /// The directory which holds the compiler resource files (builtin includes, 80 /// etc.). 81 std::string ResourceDir; 82 83 /// \brief The directory used for the module cache. 84 std::string ModuleCachePath; 85 86 /// \brief Whether we should disable the use of the hash string within the 87 /// module cache. 88 /// 89 /// Note: Only used for testing! 90 unsigned DisableModuleHash : 1; 91 92 /// Include the compiler builtin includes. 93 unsigned UseBuiltinIncludes : 1; 94 95 /// Include the system standard include search directories. 96 unsigned UseStandardSystemIncludes : 1; 97 98 /// Include the system standard C++ library include search directories. 99 unsigned UseStandardCXXIncludes : 1; 100 101 /// Use libc++ instead of the default libstdc++. 102 unsigned UseLibcxx : 1; 103 104 /// Whether header search information should be output as for -v. 105 unsigned Verbose : 1; 106 107 public: 108 HeaderSearchOptions(StringRef _Sysroot = "/") Sysroot(_Sysroot)109 : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), 110 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 111 UseLibcxx(false), Verbose(false) {} 112 113 /// AddPath - Add the \arg Path path to the specified \arg Group list. 114 void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 115 bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot, 116 bool IsInternal = false, bool ImplicitExternC = false) { 117 UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework, 118 IgnoreSysRoot, IsInternal, ImplicitExternC)); 119 } 120 }; 121 122 } // end namespace clang 123 124 #endif 125