================
@@ -556,6 +565,11 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, 
SourceManager &SM,
           OptionalFileEntryRef File =
               PP->LookupFile(Pos, Filename, false, nullptr, nullptr, nullptr,
                              nullptr, nullptr, nullptr, nullptr, nullptr);
+
+          // Check if the file was virtual
+          if (!File)
+            File = SM.getFileManager().getOptionalFileRef(Filename);
----------------
devajithvs wrote:

We could also have something like this in `HeaderSearch`, but I don't know if 
that is ideal:

```diff
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 5f52d62bd36e..795e91673de3 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1021,9 +1021,20 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
         assert(HFI && "includer without file info");
         return HFI->DirInfo != SrcMgr::C_User;
       }();
-      if (OptionalFileEntryRef FE = getFileAndSuggestModule(
-              TmpDir, IncludeLoc, IncluderAndDir.second, 
IncluderIsSystemHeader,
-              RequestingModule, SuggestedModule)) {
+
+      OptionalFileEntryRef FE = getFileAndSuggestModule(
+          TmpDir, IncludeLoc, IncluderAndDir.second, IncluderIsSystemHeader,
+          RequestingModule, SuggestedModule);
+
+      // Check if it is a virtual file from incremental buffer
+      if (!FE && IncluderAndDir.second.getName() == "." &&
+          Filename.starts_with("input_line_")) {
+        FE = getFileAndSuggestModule(
+            Filename, IncludeLoc, IncluderAndDir.second, 
IncluderIsSystemHeader,
+            RequestingModule, SuggestedModule);
+      }
+
+      if (FE) {
         diagnoseHeaderShadowing(Filename, FE, DiagnosedShadowing, IncludeLoc,
                                 FromDir, Includers, isAngled,
                                 &IncluderAndDir - Includers.begin(), nullptr);
```

https://github.com/llvm/llvm-project/pull/182044
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to