Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- HeaderSearch.h - Resolve Header File Locations ---------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the HeaderSearch interface. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_LEX_HEADERSEARCH_H |
| 15 | #define LLVM_CLANG_LEX_HEADERSEARCH_H |
| 16 | |
| 17 | #include "clang/Lex/DirectoryLookup.h" |
| 18 | #include "llvm/ADT/StringMap.h" |
| 19 | #include <vector> |
| 20 | |
| 21 | namespace clang { |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 22 | |
| 23 | class ExternalIdentifierLookup; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 24 | class FileEntry; |
| 25 | class FileManager; |
| 26 | class IdentifierInfo; |
| 27 | |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 28 | /// HeaderFileInfo - The preprocessor keeps track of this information for each |
| 29 | /// file that is #included. |
| 30 | struct HeaderFileInfo { |
| 31 | /// isImport - True if this is a #import'd or #pragma once file. |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 32 | unsigned isImport : 1; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 33 | |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 34 | /// isPragmaOnce - True if this is #pragma once file. |
| 35 | unsigned isPragmaOnce : 1; |
| 36 | |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 37 | /// DirInfo - Keep track of whether this is a system header, and if so, |
| 38 | /// whether it is C++ clean or not. This can be set by the include paths or |
| 39 | /// by #pragma gcc system_header. This is an instance of |
| 40 | /// SrcMgr::CharacteristicKind. |
| 41 | unsigned DirInfo : 2; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 42 | |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 43 | /// \brief Whether this header file info was supplied by an external source. |
| 44 | unsigned External : 1; |
| 45 | |
| 46 | /// \brief Whether this structure is considered to already have been |
| 47 | /// "resolved", meaning that it was loaded from the external source. |
| 48 | unsigned Resolved : 1; |
| 49 | |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 50 | /// NumIncludes - This is the number of times the file has been included |
| 51 | /// already. |
| 52 | unsigned short NumIncludes; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 53 | |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 54 | /// \brief The ID number of the controlling macro. |
| 55 | /// |
| 56 | /// This ID number will be non-zero when there is a controlling |
| 57 | /// macro whose IdentifierInfo may not yet have been loaded from |
| 58 | /// external storage. |
| 59 | unsigned ControllingMacroID; |
| 60 | |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 61 | /// ControllingMacro - If this file has a #ifndef XXX (or equivalent) guard |
| 62 | /// that protects the entire contents of the file, this is the identifier |
| 63 | /// for the macro that controls whether or not it has any effect. |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 64 | /// |
| 65 | /// Note: Most clients should use getControllingMacro() to access |
| 66 | /// the controlling macro of this header, since |
| 67 | /// getControllingMacro() is able to load a controlling macro from |
| 68 | /// external storage. |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 69 | const IdentifierInfo *ControllingMacro; |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 70 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 71 | HeaderFileInfo() |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 72 | : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User), |
| 73 | External(false), Resolved(false), NumIncludes(0), ControllingMacroID(0), |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 74 | ControllingMacro(0) {} |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 75 | |
| 76 | /// \brief Retrieve the controlling macro for this header file, if |
| 77 | /// any. |
| 78 | const IdentifierInfo *getControllingMacro(ExternalIdentifierLookup *External); |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 79 | |
| 80 | /// \brief Determine whether this is a non-default header file info, e.g., |
| 81 | /// it corresponds to an actual header we've included or tried to include. |
| 82 | bool isNonDefault() const { |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 83 | return isImport || isPragmaOnce || NumIncludes || ControllingMacro || |
| 84 | ControllingMacroID; |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 85 | } |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 88 | /// \brief An external source of header file information, which may supply |
| 89 | /// information about header files already included. |
| 90 | class ExternalHeaderFileInfoSource { |
| 91 | public: |
| 92 | virtual ~ExternalHeaderFileInfoSource(); |
| 93 | |
| 94 | /// \brief Retrieve the header file information for the given file entry. |
| 95 | /// |
| 96 | /// \returns Header file information for the given file entry, with the |
| 97 | /// \c External bit set. If the file entry is not known, return a |
| 98 | /// default-constructed \c HeaderFileInfo. |
| 99 | virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0; |
| 100 | }; |
| 101 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 102 | /// HeaderSearch - This class encapsulates the information needed to find the |
| 103 | /// file referenced by a #include or #include_next, (sub-)framework lookup, etc. |
| 104 | class HeaderSearch { |
| 105 | FileManager &FileMgr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 106 | /// #include search path information. Requests for #include "x" search the |
| 107 | /// directory of the #including file first, then each directory in SearchDirs |
Nico Weber | 74a5fd8 | 2011-05-24 04:31:14 +0000 | [diff] [blame] | 108 | /// consecutively. Requests for <x> search the current dir first, then each |
| 109 | /// directory in SearchDirs, starting at AngledDirIdx, consecutively. If |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 110 | /// NoCurDirSearch is true, then the check for the file in the current |
Chris Lattner | fc8f0e1 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 111 | /// directory is suppressed. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 112 | std::vector<DirectoryLookup> SearchDirs; |
Nico Weber | 74a5fd8 | 2011-05-24 04:31:14 +0000 | [diff] [blame] | 113 | unsigned AngledDirIdx; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 114 | unsigned SystemDirIdx; |
| 115 | bool NoCurDirSearch; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 116 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 117 | /// FileInfo - This contains all of the preprocessor-specific data about files |
| 118 | /// that are included. The vector is indexed by the FileEntry's UID. |
| 119 | /// |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 120 | std::vector<HeaderFileInfo> FileInfo; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 121 | |
Chris Lattner | 9960ae8 | 2007-07-22 07:28:00 +0000 | [diff] [blame] | 122 | /// LookupFileCache - This is keeps track of each lookup performed by |
| 123 | /// LookupFile. The first part of the value is the starting index in |
| 124 | /// SearchDirs that the cached search was performed from. If there is a hit |
| 125 | /// and this value doesn't match the current query, the cache has to be |
| 126 | /// ignored. The second value is the entry in SearchDirs that satisfied the |
| 127 | /// query. |
| 128 | llvm::StringMap<std::pair<unsigned, unsigned> > LookupFileCache; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 129 | |
| 130 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 131 | /// FrameworkMap - This is a collection mapping a framework or subframework |
| 132 | /// name like "Carbon" to the Carbon.framework directory. |
| 133 | llvm::StringMap<const DirectoryEntry *> FrameworkMap; |
| 134 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 135 | /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing |
Chris Lattner | 822da61 | 2007-12-17 06:36:45 +0000 | [diff] [blame] | 136 | /// headermaps. This vector owns the headermap. |
| 137 | std::vector<std::pair<const FileEntry*, const HeaderMap*> > HeaderMaps; |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 138 | |
| 139 | /// \brief Entity used to resolve the identifier IDs of controlling |
| 140 | /// macros into IdentifierInfo pointers, as needed. |
| 141 | ExternalIdentifierLookup *ExternalLookup; |
| 142 | |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 143 | /// \brief Entity used to look up stored header file information. |
| 144 | ExternalHeaderFileInfoSource *ExternalSource; |
| 145 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 146 | // Various statistics we track for performance analysis. |
| 147 | unsigned NumIncluded; |
| 148 | unsigned NumMultiIncludeFileOptzn; |
| 149 | unsigned NumFrameworkLookups, NumSubFrameworkLookups; |
Steve Naroff | 49c1f4a | 2008-02-02 00:10:46 +0000 | [diff] [blame] | 150 | |
| 151 | // HeaderSearch doesn't support default or copy construction. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 152 | explicit HeaderSearch(); |
Steve Naroff | 49c1f4a | 2008-02-02 00:10:46 +0000 | [diff] [blame] | 153 | explicit HeaderSearch(const HeaderSearch&); |
| 154 | void operator=(const HeaderSearch&); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 155 | public: |
Chris Lattner | 39b49bc | 2010-11-23 08:35:12 +0000 | [diff] [blame] | 156 | HeaderSearch(FileManager &FM); |
Chris Lattner | 822da61 | 2007-12-17 06:36:45 +0000 | [diff] [blame] | 157 | ~HeaderSearch(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 158 | |
| 159 | FileManager &getFileMgr() const { return FileMgr; } |
| 160 | |
| 161 | /// SetSearchPaths - Interface for setting the file search paths. |
| 162 | /// |
| 163 | void SetSearchPaths(const std::vector<DirectoryLookup> &dirs, |
Nico Weber | 74a5fd8 | 2011-05-24 04:31:14 +0000 | [diff] [blame] | 164 | unsigned angledDirIdx, unsigned systemDirIdx, |
| 165 | bool noCurDirSearch) { |
| 166 | assert(angledDirIdx <= systemDirIdx && systemDirIdx <= dirs.size() && |
| 167 | "Directory indicies are unordered"); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 168 | SearchDirs = dirs; |
Nico Weber | 74a5fd8 | 2011-05-24 04:31:14 +0000 | [diff] [blame] | 169 | AngledDirIdx = angledDirIdx; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 170 | SystemDirIdx = systemDirIdx; |
| 171 | NoCurDirSearch = noCurDirSearch; |
Chris Lattner | 9960ae8 | 2007-07-22 07:28:00 +0000 | [diff] [blame] | 172 | //LookupFileCache.clear(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 173 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 174 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 175 | /// ClearFileInfo - Forget everything we know about headers so far. |
| 176 | void ClearFileInfo() { |
| 177 | FileInfo.clear(); |
| 178 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 179 | |
Douglas Gregor | 8c5a760 | 2009-04-25 23:30:02 +0000 | [diff] [blame] | 180 | void SetExternalLookup(ExternalIdentifierLookup *EIL) { |
| 181 | ExternalLookup = EIL; |
| 182 | } |
| 183 | |
Douglas Gregor | cfbf1c7 | 2011-02-10 17:09:37 +0000 | [diff] [blame] | 184 | ExternalIdentifierLookup *getExternalLookup() const { |
| 185 | return ExternalLookup; |
| 186 | } |
| 187 | |
| 188 | /// \brief Set the external source of header information. |
| 189 | void SetExternalSource(ExternalHeaderFileInfoSource *ES) { |
| 190 | ExternalSource = ES; |
| 191 | } |
| 192 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 193 | /// LookupFile - Given a "foo" or <foo> reference, look up the indicated file, |
Manuel Klimek | 7412494 | 2011-04-26 21:50:03 +0000 | [diff] [blame] | 194 | /// return null on failure. |
| 195 | /// |
| 196 | /// \returns If successful, this returns 'UsedDir', the DirectoryLookup member |
| 197 | /// the file was found in, or null if not applicable. |
| 198 | /// |
| 199 | /// \param isAngled indicates whether the file reference is a <> reference. |
| 200 | /// |
| 201 | /// \param CurDir If non-null, the file was found in the specified directory |
| 202 | /// search location. This is used to implement #include_next. |
| 203 | /// |
| 204 | /// \param CurFileEnt If non-null, indicates where the #including file is, in |
| 205 | /// case a relative search is needed. |
| 206 | /// |
| 207 | /// \param SearchPath If non-null, will be set to the search path relative |
| 208 | /// to which the file was found. If the include path is absolute, SearchPath |
| 209 | /// will be set to an empty string. |
| 210 | /// |
| 211 | /// \param RelativePath If non-null, will be set to the path relative to |
| 212 | /// SearchPath at which the file was found. This only differs from the |
| 213 | /// Filename for framework includes. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 214 | const FileEntry *LookupFile(StringRef Filename, bool isAngled, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 215 | const DirectoryLookup *FromDir, |
| 216 | const DirectoryLookup *&CurDir, |
Chandler Carruth | b5142bb | 2011-03-16 18:34:36 +0000 | [diff] [blame] | 217 | const FileEntry *CurFileEnt, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 218 | SmallVectorImpl<char> *SearchPath, |
| 219 | SmallVectorImpl<char> *RelativePath); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 220 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 221 | /// LookupSubframeworkHeader - Look up a subframework for the specified |
| 222 | /// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from |
| 223 | /// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox |
| 224 | /// is a subframework within Carbon.framework. If so, return the FileEntry |
| 225 | /// for the designated file, otherwise return null. |
Chandler Carruth | b5142bb | 2011-03-16 18:34:36 +0000 | [diff] [blame] | 226 | const FileEntry *LookupSubframeworkHeader( |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 227 | StringRef Filename, |
Chandler Carruth | b5142bb | 2011-03-16 18:34:36 +0000 | [diff] [blame] | 228 | const FileEntry *RelativeFileEnt, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 229 | SmallVectorImpl<char> *SearchPath, |
| 230 | SmallVectorImpl<char> *RelativePath); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 231 | |
Chris Lattner | afded5b | 2007-12-17 08:13:48 +0000 | [diff] [blame] | 232 | /// LookupFrameworkCache - Look up the specified framework name in our |
| 233 | /// framework cache, returning the DirectoryEntry it is in if we know, |
| 234 | /// otherwise, return null. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 235 | const DirectoryEntry *&LookupFrameworkCache(StringRef FWName) { |
Chris Lattner | a139481 | 2010-01-10 01:35:12 +0000 | [diff] [blame] | 236 | return FrameworkMap.GetOrCreateValue(FWName).getValue(); |
Chris Lattner | afded5b | 2007-12-17 08:13:48 +0000 | [diff] [blame] | 237 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 238 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 239 | /// ShouldEnterIncludeFile - Mark the specified file as a target of of a |
| 240 | /// #include, #include_next, or #import directive. Return false if #including |
| 241 | /// the file will have no effect or true if we should include it. |
| 242 | bool ShouldEnterIncludeFile(const FileEntry *File, bool isImport); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 243 | |
| 244 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 245 | /// getFileDirFlavor - Return whether the specified file is a normal header, |
| 246 | /// a system header, or a C++ friendly system header. |
Chris Lattner | 9d72851 | 2008-10-27 01:19:25 +0000 | [diff] [blame] | 247 | SrcMgr::CharacteristicKind getFileDirFlavor(const FileEntry *File) { |
| 248 | return (SrcMgr::CharacteristicKind)getFileInfo(File).DirInfo; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 249 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 250 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 251 | /// MarkFileIncludeOnce - Mark the specified file as a "once only" file, e.g. |
| 252 | /// due to #pragma once. |
| 253 | void MarkFileIncludeOnce(const FileEntry *File) { |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 254 | HeaderFileInfo &FI = getFileInfo(File); |
| 255 | FI.isImport = true; |
| 256 | FI.isPragmaOnce = true; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 257 | } |
| 258 | |
Daniel Dunbar | e9eb3f8 | 2008-09-26 01:11:51 +0000 | [diff] [blame] | 259 | /// MarkFileSystemHeader - Mark the specified file as a system header, e.g. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 260 | /// due to #pragma GCC system_header. |
| 261 | void MarkFileSystemHeader(const FileEntry *File) { |
Chris Lattner | 0b9e736 | 2008-09-26 21:18:42 +0000 | [diff] [blame] | 262 | getFileInfo(File).DirInfo = SrcMgr::C_System; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 263 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 264 | |
Chris Lattner | 25bfcb9 | 2007-11-15 19:22:18 +0000 | [diff] [blame] | 265 | /// IncrementIncludeCount - Increment the count for the number of times the |
| 266 | /// specified FileEntry has been entered. |
| 267 | void IncrementIncludeCount(const FileEntry *File) { |
| 268 | ++getFileInfo(File).NumIncludes; |
| 269 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 270 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 271 | /// SetFileControllingMacro - Mark the specified file as having a controlling |
| 272 | /// macro. This is used by the multiple-include optimization to eliminate |
| 273 | /// no-op #includes. |
| 274 | void SetFileControllingMacro(const FileEntry *File, |
| 275 | const IdentifierInfo *ControllingMacro) { |
| 276 | getFileInfo(File).ControllingMacro = ControllingMacro; |
| 277 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 278 | |
Douglas Gregor | dd3e554 | 2011-05-04 00:14:37 +0000 | [diff] [blame] | 279 | /// \brief Determine whether this file is intended to be safe from |
| 280 | /// multiple inclusions, e.g., it has #pragma once or a controlling |
| 281 | /// macro. |
| 282 | /// |
| 283 | /// This routine does not consider the effect of #import |
| 284 | bool isFileMultipleIncludeGuarded(const FileEntry *File); |
| 285 | |
Chris Lattner | 822da61 | 2007-12-17 06:36:45 +0000 | [diff] [blame] | 286 | /// CreateHeaderMap - This method returns a HeaderMap for the specified |
| 287 | /// FileEntry, uniquing them through the the 'HeaderMaps' datastructure. |
Chris Lattner | 1bfd4a6 | 2007-12-17 18:34:53 +0000 | [diff] [blame] | 288 | const HeaderMap *CreateHeaderMap(const FileEntry *FE); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 289 | |
Chris Lattner | afded5b | 2007-12-17 08:13:48 +0000 | [diff] [blame] | 290 | void IncrementFrameworkLookupCount() { ++NumFrameworkLookups; } |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 291 | |
Douglas Gregor | 12fab31 | 2010-03-16 16:35:32 +0000 | [diff] [blame] | 292 | typedef std::vector<HeaderFileInfo>::const_iterator header_file_iterator; |
| 293 | header_file_iterator header_file_begin() const { return FileInfo.begin(); } |
| 294 | header_file_iterator header_file_end() const { return FileInfo.end(); } |
| 295 | unsigned header_file_size() const { return FileInfo.size(); } |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 296 | |
Sebastian Redl | c43b54c | 2010-08-18 23:56:43 +0000 | [diff] [blame] | 297 | // Used by ASTReader. |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 298 | void setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 299 | |
Douglas Gregor | ec356c3 | 2011-03-06 17:33:53 +0000 | [diff] [blame] | 300 | // Used by external tools |
| 301 | typedef std::vector<DirectoryLookup>::const_iterator search_dir_iterator; |
| 302 | search_dir_iterator search_dir_begin() const { return SearchDirs.begin(); } |
| 303 | search_dir_iterator search_dir_end() const { return SearchDirs.end(); } |
| 304 | unsigned search_dir_size() const { return SearchDirs.size(); } |
| 305 | |
Nico Weber | 74a5fd8 | 2011-05-24 04:31:14 +0000 | [diff] [blame] | 306 | search_dir_iterator quoted_dir_begin() const { |
| 307 | return SearchDirs.begin(); |
| 308 | } |
| 309 | search_dir_iterator quoted_dir_end() const { |
| 310 | return SearchDirs.begin() + AngledDirIdx; |
| 311 | } |
| 312 | |
| 313 | search_dir_iterator angled_dir_begin() const { |
| 314 | return SearchDirs.begin() + AngledDirIdx; |
| 315 | } |
| 316 | search_dir_iterator angled_dir_end() const { |
| 317 | return SearchDirs.begin() + SystemDirIdx; |
| 318 | } |
| 319 | |
Douglas Gregor | ec356c3 | 2011-03-06 17:33:53 +0000 | [diff] [blame] | 320 | search_dir_iterator system_dir_begin() const { |
| 321 | return SearchDirs.begin() + SystemDirIdx; |
| 322 | } |
| 323 | search_dir_iterator system_dir_end() const { return SearchDirs.end(); } |
| 324 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 325 | void PrintStats(); |
| 326 | private: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 327 | |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 328 | /// getFileInfo - Return the HeaderFileInfo structure for the specified |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 329 | /// FileEntry. |
Steve Naroff | 83d63c7 | 2009-04-24 20:03:17 +0000 | [diff] [blame] | 330 | HeaderFileInfo &getFileInfo(const FileEntry *FE); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 331 | }; |
| 332 | |
| 333 | } // end namespace clang |
| 334 | |
| 335 | #endif |