]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Lex/HeaderSearchOptions.h
MFC r244628:
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Lex / HeaderSearchOptions.h
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 "llvm/ADT/IntrusiveRefCntPtr.h"
14 #include "llvm/ADT/StringRef.h"
15 #include <vector>
16
17 namespace clang {
18
19 namespace frontend {
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.
35   };
36 }
37
38 /// HeaderSearchOptions - Helper class for storing options related to the
39 /// initialization of the HeaderSearch object.
40 class HeaderSearchOptions : public llvm::RefCountedBase<HeaderSearchOptions> {
41 public:
42   struct Entry {
43     std::string Path;
44     frontend::IncludeDirGroup Group;
45     unsigned IsUserSupplied : 1;
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. 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;
61
62     /// \brief True if this entry's headers should be wrapped in extern "C".
63     unsigned ImplicitExternC : 1;
64
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) {}
71   };
72
73   struct SystemHeaderPrefix {
74     /// A prefix to be matched against paths in \#include directives.
75     std::string Prefix;
76
77     /// True if paths beginning with this prefix should be treated as system
78     /// headers.
79     bool IsSystemHeader;
80
81     SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
82       : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
83   };
84
85   /// If non-empty, the directory to use as a "virtual system root" for include
86   /// paths.
87   std::string Sysroot;
88
89   /// User specified include entries.
90   std::vector<Entry> UserEntries;
91
92   /// User-specified system header prefixes.
93   std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
94
95   /// The directory which holds the compiler resource files (builtin includes,
96   /// etc.).
97   std::string ResourceDir;
98
99   /// \brief The directory used for the module cache.
100   std::string ModuleCachePath;
101   
102   /// \brief Whether we should disable the use of the hash string within the
103   /// module cache.
104   ///
105   /// Note: Only used for testing!
106   unsigned DisableModuleHash : 1;
107   
108   /// Include the compiler builtin includes.
109   unsigned UseBuiltinIncludes : 1;
110
111   /// Include the system standard include search directories.
112   unsigned UseStandardSystemIncludes : 1;
113
114   /// Include the system standard C++ library include search directories.
115   unsigned UseStandardCXXIncludes : 1;
116
117   /// Use libc++ instead of the default libstdc++.
118   unsigned UseLibcxx : 1;
119
120   /// Whether header search information should be output as for -v.
121   unsigned Verbose : 1;
122
123 public:
124   HeaderSearchOptions(StringRef _Sysroot = "/")
125     : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
126       UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
127       UseLibcxx(false), Verbose(false) {}
128
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));
135   }
136
137   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
138   /// path starting with \p Prefix should be considered as naming a system
139   /// header.
140   void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
141     SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader));
142   }
143 };
144
145 } // end namespace clang
146
147 #endif