================
@@ -378,8 +378,10 @@ struct SourceMgrDiagnosticHandlerImpl {
     }
 
     // Otherwise, try to load the source file.
-    std::string ignored;
-    unsigned id = mgr.AddIncludeFile(std::string(filename), SMLoc(), ignored);
+    auto bufferOrErr = llvm::MemoryBuffer::getFile(filename);
+    if (!bufferOrErr)
+      return 0;
+    unsigned id = mgr.AddNewSourceBuffer(std::move(*bufferOrErr), SMLoc());
     filenameToBufId[filename] = id;
----------------
uenoku wrote:

mlir/lib/IR/Diagnostics.cpp specifically. AddIncludeFile uses 
[OpenIncludeFile](https://github.com/llvm/llvm-project/blob/8dbc1527f7ad4197dfff8ea598634a8063bb6083/llvm/lib/Support/SourceMgr.cpp#L62)
 which 
[searches](https://github.com/llvm/llvm-project/blob/8dbc1527f7ad4197dfff8ea598634a8063bb6083/llvm/lib/Support/SourceMgr.cpp#L79-L85.)
 files under include directories. I understand the intention of the PR but the 
change in mlir/lib/IR/Diagnostics.cpp looks rather unrelated to VFS. I think 
AddIncludeFile also uses VFS now 
(https://github.com/llvm/llvm-project/pull/163862) so I don't think this change 
is necessary. Maybe I'm missing something?  


Note that setting setVirtualFileSystem(llvm::vfs::getRealFileSystem()) didn't 
fix our issue. 

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

Reply via email to