/// provided via a header map. This bit indicates when this is one of
/// those framework headers.
unsigned IndexHeaderMapHeader : 1;
+
+ /// \brief Whether this file had been looked up as a header.
+ unsigned IsValid : 1;
/// \brief The number of times the file has been included already.
unsigned short NumIncludes;
: isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
External(false), isModuleHeader(false), isCompilingModuleHeader(false),
HeaderRole(ModuleMap::NormalHeader),
- Resolved(false), IndexHeaderMapHeader(false),
+ Resolved(false), IndexHeaderMapHeader(false), IsValid(0),
NumIncludes(0), ControllingMacroID(0), ControllingMacro(0) {}
/// \brief Retrieve the controlling macro for this header file, if
/// of the given search directory.
void loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir);
+ /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
+ const HeaderFileInfo &getFileInfo(const FileEntry *FE) const {
+ return const_cast<HeaderSearch*>(this)->getFileInfo(FE);
+ }
+
public:
/// \brief Retrieve the module map.
ModuleMap &getModuleMap() { return ModMap; }
unsigned header_file_size() const { return FileInfo.size(); }
- /// \brief Return the HeaderFileInfo structure for the specified FileEntry.
- const HeaderFileInfo &getFileInfo(const FileEntry *FE) const {
- return const_cast<HeaderSearch*>(this)->getFileInfo(FE);
- }
+ /// \brief Get a \c HeaderFileInfo structure for the specified \c FileEntry,
+ /// if one exists.
+ bool tryGetFileInfo(const FileEntry *FE, HeaderFileInfo &Result) const;
// Used by external tools
typedef std::vector<DirectoryLookup>::const_iterator search_dir_iterator;
HeaderFileInfo &HFI = FileInfo[FE->getUID()];
if (ExternalSource && !HFI.Resolved)
mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(FE));
+ HFI.IsValid = 1;
return HFI;
}
+bool HeaderSearch::tryGetFileInfo(const FileEntry *FE, HeaderFileInfo &Result) const {
+ if (FE->getUID() >= FileInfo.size())
+ return false;
+ const HeaderFileInfo &HFI = FileInfo[FE->getUID()];
+ if (HFI.IsValid) {
+ Result = HFI;
+ return true;
+ }
+ return false;
+}
+
bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) {
// Check if we've ever seen this file as a header.
if (File->getUID() >= FileInfo.size())
// Use HeaderSearch's getFileInfo to make sure we get the HeaderFileInfo
// from the external source if it was not provided already.
- const HeaderFileInfo &HFI = HS.getFileInfo(File);
- if (HFI.External && Chain)
- continue;
- if (HFI.isModuleHeader && !HFI.isCompilingModuleHeader)
+ HeaderFileInfo HFI;
+ if (!HS.tryGetFileInfo(File, HFI) ||
+ (HFI.External && Chain) ||
+ (HFI.isModuleHeader && !HFI.isCompilingModuleHeader))
continue;
// Turn the file name into an absolute path, if it isn't already.