[clang] [clang-tools-extra] [llvm] [clang] Introduce diagnostics suppression mappings (PR #112517)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 17 08:48:47 PDT 2024
================
@@ -332,19 +334,22 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
void CompilerInstance::createDiagnostics(DiagnosticConsumer *Client,
bool ShouldOwnClient) {
- Diagnostics = createDiagnostics(&getDiagnosticOpts(), Client,
- ShouldOwnClient, &getCodeGenOpts());
+ Diagnostics = createDiagnostics(
+ &getDiagnosticOpts(), Client, ShouldOwnClient, &getCodeGenOpts(),
+ FileMgr ? FileMgr->getVirtualFileSystemPtr() : nullptr);
}
-IntrusiveRefCntPtr<DiagnosticsEngine>
-CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
- DiagnosticConsumer *Client,
- bool ShouldOwnClient,
- const CodeGenOptions *CodeGenOpts) {
+IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
+ DiagnosticOptions *Opts, DiagnosticConsumer *Client, bool ShouldOwnClient,
+ const CodeGenOptions *CodeGenOpts,
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
IntrusiveRefCntPtr<DiagnosticsEngine>
Diags(new DiagnosticsEngine(DiagID, Opts));
+ if (!VFS)
----------------
ilya-biryukov wrote:
Are we worried that we might forget to pass the VFS here and accidentally get `RealFS` when the clients intend to use their own?
These things have definitely happened in the past, and they are really expensive to debug.
I know it's tedious to change all the call sites, but I suggest considering to add this as a required parameter and move the choice of a VFS to call sites.
It's a trade-off that will pay back with the fact that we won't need to be chasing those bugs where the file wasn't found in the future.
https://github.com/llvm/llvm-project/pull/112517
More information about the cfe-commits
mailing list