[clang] [clang][deps] Make dependency directives getter thread-safe (PR #136178)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 18 14:05:16 PDT 2025


================
@@ -92,16 +92,10 @@ bool Preprocessor::EnterSourceFile(FileID FID, ConstSearchDirIterator CurDir,
   }
 
   Lexer *TheLexer = new Lexer(FID, *InputFile, *this, IsFirstIncludeOfFile);
-  if (getPreprocessorOpts().DependencyDirectivesForFile &&
-      FID != PredefinesFileID) {
-    if (OptionalFileEntryRef File = SourceMgr.getFileEntryRefForID(FID)) {
-      if (std::optional<ArrayRef<dependency_directives_scan::Directive>>
-              DepDirectives =
-                  getPreprocessorOpts().DependencyDirectivesForFile(*File)) {
-        TheLexer->DepDirectives = *DepDirectives;
-      }
-    }
-  }
+  if (GetDependencyDirectives && FID != PredefinesFileID)
+    if (OptionalFileEntryRef File = SourceMgr.getFileEntryRefForID(FID))
+      if (auto MaybeDepDirectives = GetDependencyDirectives(FileMgr, *File))
----------------
cyndyishida wrote:

I'd find that a bit easier for reasoning about the state through the ScanInstance, but I also don't feel that strongly. Thanks for explaining though

https://github.com/llvm/llvm-project/pull/136178


More information about the cfe-commits mailing list