1 //===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
11 #define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
13 #include "llvm/ADT/IntrusiveRefCntPtr.h"
14 #include "llvm/ADT/StringRef.h"
20 /// IncludeDirGroup - Identifiers the group a include entry belongs to, which
21 /// represents its relative positive in the search list. A \#include of a ""
22 /// path starts at the -iquote group, then searches the Angled group, then
23 /// searches the system group, etc.
24 enum IncludeDirGroup {
25 Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'.
26 Angled, ///< Paths for '\#include <>' added by '-I'.
27 IndexHeaderMap, ///< Like Angled, but marks header maps used when
28 /// building frameworks.
29 System, ///< Like Angled, but marks system directories.
30 CSystem, ///< Like System, but only used for C.
31 CXXSystem, ///< Like System, but only used for C++.
32 ObjCSystem, ///< Like System, but only used for ObjC.
33 ObjCXXSystem, ///< Like System, but only used for ObjC++.
34 After ///< Like System, but searched after the system directories.
38 /// HeaderSearchOptions - Helper class for storing options related to the
39 /// initialization of the HeaderSearch object.
40 class HeaderSearchOptions : public llvm::RefCountedBase<HeaderSearchOptions> {
44 frontend::IncludeDirGroup Group;
45 unsigned IsUserSupplied : 1;
46 unsigned IsFramework : 1;
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
51 unsigned IgnoreSysRoot : 1;
53 /// \brief True if this entry is an internal search path.
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. This isn't redundant with IsUserSupplied (even though perhaps
58 /// it should be) because that is false for user provided '-iwithprefix'
59 /// header search entries.
60 unsigned IsInternal : 1;
62 /// \brief True if this entry's headers should be wrapped in extern "C".
63 unsigned ImplicitExternC : 1;
65 Entry(StringRef path, frontend::IncludeDirGroup group,
66 bool isUserSupplied, bool isFramework, bool ignoreSysRoot,
67 bool isInternal, bool implicitExternC)
68 : Path(path), Group(group), IsUserSupplied(isUserSupplied),
69 IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot),
70 IsInternal(isInternal), ImplicitExternC(implicitExternC) {}
73 struct SystemHeaderPrefix {
74 /// A prefix to be matched against paths in \#include directives.
77 /// True if paths beginning with this prefix should be treated as system
81 SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
82 : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
85 /// If non-empty, the directory to use as a "virtual system root" for include
89 /// User specified include entries.
90 std::vector<Entry> UserEntries;
92 /// User-specified system header prefixes.
93 std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
95 /// The directory which holds the compiler resource files (builtin includes,
97 std::string ResourceDir;
99 /// \brief The directory used for the module cache.
100 std::string ModuleCachePath;
102 /// \brief Whether we should disable the use of the hash string within the
105 /// Note: Only used for testing!
106 unsigned DisableModuleHash : 1;
108 /// Include the compiler builtin includes.
109 unsigned UseBuiltinIncludes : 1;
111 /// Include the system standard include search directories.
112 unsigned UseStandardSystemIncludes : 1;
114 /// Include the system standard C++ library include search directories.
115 unsigned UseStandardCXXIncludes : 1;
117 /// Use libc++ instead of the default libstdc++.
118 unsigned UseLibcxx : 1;
120 /// Whether header search information should be output as for -v.
121 unsigned Verbose : 1;
124 HeaderSearchOptions(StringRef _Sysroot = "/")
125 : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
126 UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
127 UseLibcxx(false), Verbose(false) {}
129 /// AddPath - Add the \p Path path to the specified \p Group list.
130 void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
131 bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot,
132 bool IsInternal = false, bool ImplicitExternC = false) {
133 UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
134 IgnoreSysRoot, IsInternal, ImplicitExternC));
137 /// AddSystemHeaderPrefix - Override whether \#include directives naming a
138 /// path starting with \p Prefix should be considered as naming a system
140 void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
141 SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader));
145 } // end namespace clang