@@ -80,6 +80,9 @@ struct HeaderFileInfo {
8080 LLVM_PREFERRED_TYPE (SrcMgr::CharacteristicKind)
8181 unsigned DirInfo : 3 ;
8282
83+ LLVM_PREFERRED_TYPE (bool )
84+ unsigned IsDeprecated : 1 ;
85+
8386 // / Whether this header file info was supplied by an external source,
8487 // / and has not changed since.
8588 LLVM_PREFERRED_TYPE (bool )
@@ -124,9 +127,9 @@ struct HeaderFileInfo {
124127
125128 HeaderFileInfo ()
126129 : IsLocallyIncluded(false ), isImport(false ), isPragmaOnce(false ),
127- DirInfo (SrcMgr::C_User), External (false ), isModuleHeader (false ),
128- isTextualModuleHeader (false ), isCompilingModuleHeader (false ),
129- Resolved(false ), IsValid(false ) {}
130+ DirInfo (SrcMgr::C_User), IsDeprecated (false ), External (false ),
131+ isModuleHeader (false ), isTextualModuleHeader (false ),
132+ isCompilingModuleHeader( false ), Resolved(false ), IsValid(false ) {}
130133
131134 // / Retrieve the controlling macro for this header file, if
132135 // / any.
@@ -356,6 +359,9 @@ class HeaderSearch {
356359 // A map of discovered headers with their associated include file name.
357360 llvm::DenseMap<const FileEntry *, llvm::SmallString<64 >> IncludeNames;
358361
362+ // A map from a file to its deprecation message
363+ llvm::DenseMap<const FileEntry *, std::string> DeprecationMessages;
364+
359365 // / Uniqued set of framework names, which is used to track which
360366 // / headers were included as framework headers.
361367 llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames;
@@ -563,6 +569,12 @@ class HeaderSearch {
563569 getFileInfo (File).DirInfo = SrcMgr::C_System;
564570 }
565571
572+ void MarkFileDeprecated (FileEntryRef File, std::string DeprecationMessage) {
573+ getFileInfo (File).IsDeprecated = true ;
574+ DeprecationMessages.emplace_or_assign (&File.getFileEntry (),
575+ std::move (DeprecationMessage));
576+ }
577+
566578 // / Mark the specified file as part of a module.
567579 void MarkFileModuleHeader (FileEntryRef FE, ModuleMap::ModuleHeaderRole Role,
568580 bool isCompilingModuleHeader);
@@ -652,6 +664,13 @@ class HeaderSearch {
652664 std::string getCachedModuleFileName (StringRef ModuleName,
653665 StringRef ModuleMapPath);
654666
667+ std::optional<std::string_view>
668+ getHeaderDeprecationMessage (FileEntryRef File) {
669+ if (!getFileInfo (File).IsDeprecated )
670+ return std::nullopt ;
671+ return DeprecationMessages.at (File);
672+ }
673+
655674 // / Lookup a module Search for a module with the given name.
656675 // /
657676 // / \param ModuleName The name of the module we're looking for.
0 commit comments