[clang] [llvm] [mlir] [polly] [llvm] Forward declare VirtualFileSystem (PR #211761)
Fabrice de Gans via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 24 02:48:23 PDT 2026
https://github.com/Steelskin created https://github.com/llvm/llvm-project/pull/211761
This adds a new header that adds an explicit forward declaration for VirtualFileSystem, as well as a specialization of IntrusiveRefCntPtrInfo for this class. This allows for code that uses
`IntrusiveRefCntPtr<vfs::FileSystem>` to compile when building LLVM as a dylib on Windows, without having to include the full VirtualFileSystem.h header.
The effort to build LLVM as a dylib is tracked in #109483.
>From 2bb7a410bc5a11de3c0c24bb31d2da3129131678 Mon Sep 17 00:00:00 2001
From: Fabrice de Gans <steelskin at gmail.com>
Date: Fri, 24 Jul 2026 11:35:20 +0200
Subject: [PATCH] [llvm] Forward declare VirtualFileSystem
This adds a new header that adds an explicit forward declaration for
VirtualFileSystem, as well as a specialization of IntrusiveRefCntPtrInfo
for this class. This allows for code that uses
`IntrusiveRefCntPtr<vfs::FileSystem>` to compile when building LLVM as a
dylib on Windows, without having to include the full VirtualFileSystem.h
header.
The effort to build LLVM as a dylib is tracked in #109483.
---
clang/include/clang/Basic/Diagnostic.h | 4 +--
.../clang/Basic/SanitizerSpecialCaseList.h | 8 +----
clang/include/clang/CIR/LowerToLLVM.h | 4 +--
clang/include/clang/CodeGen/BackendUtil.h | 4 +--
clang/include/clang/CodeGen/ModuleBuilder.h | 5 +--
clang/include/clang/Driver/Driver.h | 4 +--
clang/include/clang/Driver/ModulesDriver.h | 5 +--
clang/include/clang/Driver/ToolChain.h | 6 +---
clang/include/clang/Format/Format.h | 7 +---
clang/include/clang/Frontend/ASTUnit.h | 6 +---
.../clang/Frontend/CompilerInvocation.h | 7 +---
.../clang/Frontend/PrecompiledPreamble.h | 4 +--
clang/lib/CodeGen/CodeGenModule.h | 5 +--
llvm/include/llvm/CodeGen/MIRSampleProfile.h | 5 +--
llvm/include/llvm/CodeGen/Passes.h | 4 +--
.../llvm/Frontend/OpenMP/OMPIRBuilder.h | 5 +--
.../ProfileData/Coverage/CoverageMapping.h | 5 +--
.../llvm/ProfileData/InstrProfReader.h | 6 +---
.../llvm/ProfileData/SampleProfReader.h | 5 +--
llvm/include/llvm/Support/CommandLine.h | 5 +--
llvm/include/llvm/Support/SourceMgr.h | 5 +--
llvm/include/llvm/Support/SpecialCaseList.h | 5 +--
llvm/include/llvm/Support/VirtualFileSystem.h | 3 +-
.../llvm/Support/VirtualFileSystemFwd.h | 36 +++++++++++++++++++
.../llvm/Transforms/IPO/SampleProfile.h | 5 +--
.../Transforms/Instrumentation/MemProfUse.h | 5 +--
.../Instrumentation/SanitizerBinaryMetadata.h | 4 +--
.../Instrumentation/SanitizerCoverage.h | 4 +--
.../Utils/SampleProfileLoaderBaseImpl.h | 5 +--
llvm/include/llvm/WindowsDriver/MSVCPaths.h | 5 +--
llvm/lib/Support/VirtualFileSystem.cpp | 13 +++++++
mlir/include/mlir/Target/LLVMIR/Export.h | 4 +--
.../mlir/Target/LLVMIR/ModuleTranslation.h | 4 +--
polly/include/polly/ScopInliner.h | 7 +---
34 files changed, 81 insertions(+), 128 deletions(-)
create mode 100644 llvm/include/llvm/Support/VirtualFileSystemFwd.h
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 66e79e3b4300b..ee4a16d241f19 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -29,6 +29,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <cassert>
#include <cstdint>
#include <limits>
@@ -46,9 +47,6 @@ namespace llvm {
class Error;
class raw_ostream;
class MemoryBuffer;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Basic/SanitizerSpecialCaseList.h b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
index a05da4c1561d9..2469cf074fc0c 100644
--- a/clang/include/clang/Basic/SanitizerSpecialCaseList.h
+++ b/clang/include/clang/Basic/SanitizerSpecialCaseList.h
@@ -18,16 +18,10 @@
#include "clang/Basic/Sanitizers.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SpecialCaseList.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
#include <utility>
#include <vector>
-
-namespace llvm {
-namespace vfs {
-class FileSystem;
-}
-} // namespace llvm
-
namespace clang {
class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
diff --git a/clang/include/clang/CIR/LowerToLLVM.h b/clang/include/clang/CIR/LowerToLLVM.h
index 305f54017ebe0..d97ac5265c282 100644
--- a/clang/include/clang/CIR/LowerToLLVM.h
+++ b/clang/include/clang/CIR/LowerToLLVM.h
@@ -13,14 +13,12 @@
#define CLANG_CIR_LOWERTOLLVM_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
namespace llvm {
class LLVMContext;
class Module;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
namespace mlir {
diff --git a/clang/include/clang/CodeGen/BackendUtil.h b/clang/include/clang/CodeGen/BackendUtil.h
index 8b0d975a876e6..630dbab00700e 100644
--- a/clang/include/clang/CodeGen/BackendUtil.h
+++ b/clang/include/clang/CodeGen/BackendUtil.h
@@ -11,6 +11,7 @@
#include "clang/Basic/LLVM.h"
#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
namespace llvm {
@@ -19,9 +20,6 @@ template <typename T> class Expected;
template <typename T> class IntrusiveRefCntPtr;
class Module;
class MemoryBufferRef;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/CodeGen/ModuleBuilder.h b/clang/include/clang/CodeGen/ModuleBuilder.h
index cd93ef7cc654a..99e3bdf013a8e 100644
--- a/clang/include/clang/CodeGen/ModuleBuilder.h
+++ b/clang/include/clang/CodeGen/ModuleBuilder.h
@@ -16,16 +16,13 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
namespace llvm {
class Constant;
class LLVMContext;
class Module;
class StringRef;
-
- namespace vfs {
- class FileSystem;
- }
}
// Prefix of the name of the artificial inline frame.
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h
index eece9ac5293f0..15b6fdcb8a574 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -28,6 +28,7 @@
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <map>
#include <set>
@@ -36,9 +37,6 @@
namespace llvm {
class Triple;
-namespace vfs {
-class FileSystem;
-}
namespace cl {
class ExpansionContext;
}
diff --git a/clang/include/clang/Driver/ModulesDriver.h b/clang/include/clang/Driver/ModulesDriver.h
index 7146d2f6b143f..e67a862f3beff 100644
--- a/clang/include/clang/Driver/ModulesDriver.h
+++ b/clang/include/clang/Driver/ModulesDriver.h
@@ -18,10 +18,7 @@
#include "clang/Basic/LLVM.h"
#include "clang/Driver/Types.h"
#include "llvm/Support/Error.h"
-
-namespace llvm::vfs {
-class FileSystem;
-} // namespace llvm::vfs
+#include "llvm/Support/VirtualFileSystemFwd.h"
namespace clang {
class DiagnosticsEngine;
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h
index c5633e10933e8..55856a6e4e1c3 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -26,6 +26,7 @@
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/Triple.h"
#include <cassert>
@@ -43,11 +44,6 @@ class ArgList;
class DerivedArgList;
} // namespace opt
-namespace vfs {
-
-class FileSystem;
-
-} // namespace vfs
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 27b2d8f4a405b..9363222205414 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -21,15 +21,10 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <optional>
#include <system_error>
-namespace llvm {
-namespace vfs {
-class FileSystem;
-}
-} // namespace llvm
-
namespace clang {
namespace format {
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index b187494e449f2..92d0bd9d03b4d 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -39,6 +39,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Bitstream/BitstreamWriter.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
@@ -52,11 +53,6 @@ namespace llvm {
class MemoryBuffer;
-namespace vfs {
-
-class FileSystem;
-
-} // namespace vfs
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index f71969d515be0..926d77a312c66 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -24,6 +24,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
#include <string>
@@ -38,12 +39,6 @@ class ArgList;
} // namespace opt
-namespace vfs {
-
-class FileSystem;
-
-} // namespace vfs
-
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Frontend/PrecompiledPreamble.h b/clang/include/clang/Frontend/PrecompiledPreamble.h
index 565395b4f3986..34839f50d3e86 100644
--- a/clang/include/clang/Frontend/PrecompiledPreamble.h
+++ b/clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MD5.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <cstddef>
#include <memory>
#include <system_error>
@@ -26,9 +27,6 @@
namespace llvm {
class MemoryBuffer;
class MemoryBufferRef;
-namespace vfs {
-class FileSystem;
-}
} // namespace llvm
namespace clang {
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 54b08b588dfde..4b924e12d7adf 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -39,6 +39,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Allocator.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Transforms/Utils/SanitizerStats.h"
#include <optional>
@@ -53,10 +54,6 @@ class FunctionType;
class LLVMContext;
class IndexedInstrProfReader;
-namespace vfs {
-class FileSystem;
-}
-
namespace abi {
class ArgInfo;
class IRTypeMapper;
diff --git a/llvm/include/llvm/CodeGen/MIRSampleProfile.h b/llvm/include/llvm/CodeGen/MIRSampleProfile.h
index 9ae5472fd83bf..43639c7bb8039 100644
--- a/llvm/include/llvm/CodeGen/MIRSampleProfile.h
+++ b/llvm/include/llvm/CodeGen/MIRSampleProfile.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/Discriminator.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
#include <string>
@@ -27,10 +28,6 @@ class MachineBlockFrequencyInfo;
class MachineFunction;
class Module;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
using namespace sampleprof;
class MIRProfileLoader;
diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h
index 86bf5aea7b23a..d48e1770a4d89 100644
--- a/llvm/include/llvm/CodeGen/Passes.h
+++ b/llvm/include/llvm/CodeGen/Passes.h
@@ -18,6 +18,7 @@
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Discriminator.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <functional>
#include <string>
@@ -34,9 +35,6 @@ class raw_ostream;
enum class RunOutliner;
template <typename T> class IntrusiveRefCntPtr;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index fee8c712998b5..86252ad20d867 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -27,6 +27,7 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/TargetParser/Triple.h"
#include <forward_list>
#include <map>
@@ -43,10 +44,6 @@ class Loop;
class LoopAnalysis;
class LoopInfo;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
/// Move the instruction after an InsertPoint to the beginning of another
/// BasicBlock.
///
diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
index a664b6b5fa560..a74b334c35f06 100644
--- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -30,6 +30,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@@ -52,10 +53,6 @@ namespace object {
class BuildIDFetcher;
} // namespace object
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
namespace coverage {
class CoverageMappingReader;
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 51b97e9f88ee3..2607a2566e39d 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -13,7 +13,6 @@
#ifndef LLVM_PROFILEDATA_INSTRPROFREADER_H
#define LLVM_PROFILEDATA_INSTRPROFREADER_H
-
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/ProfileSummary.h"
@@ -32,6 +31,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/SwapByteOrder.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
@@ -45,10 +45,6 @@ namespace llvm {
class InstrProfReader;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
/// A file format agnostic iterator over profiling data.
template <class record_type = NamedInstrProfRecord,
class reader_type = InstrProfReader>
diff --git a/llvm/include/llvm/ProfileData/SampleProfReader.h b/llvm/include/llvm/ProfileData/SampleProfReader.h
index fd7bf8c49374e..830d4086f95e2 100644
--- a/llvm/include/llvm/ProfileData/SampleProfReader.h
+++ b/llvm/include/llvm/ProfileData/SampleProfReader.h
@@ -241,6 +241,7 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <array>
#include <cstdint>
#include <list>
@@ -255,10 +256,6 @@ namespace llvm {
class raw_ostream;
class Twine;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
namespace sampleprof {
class SampleProfileReader;
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index 662eb44d6d2a8..dd42c4bfb7f49 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -29,6 +29,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <climits>
@@ -41,10 +42,6 @@
namespace llvm {
-namespace vfs {
-class FileSystem;
-}
-
class StringSaver;
class ElementCount;
diff --git a/llvm/include/llvm/Support/SourceMgr.h b/llvm/include/llvm/Support/SourceMgr.h
index 884f15ac482fe..452a9ab28af94 100644
--- a/llvm/include/llvm/Support/SourceMgr.h
+++ b/llvm/include/llvm/Support/SourceMgr.h
@@ -20,14 +20,11 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SMLoc.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <vector>
namespace llvm {
-namespace vfs {
-class FileSystem;
-} // end namespace vfs
-
class raw_ostream;
class SMDiagnostic;
class SMFixIt;
diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h
index 28e264f078d89..3366ee078ebc7 100644
--- a/llvm/include/llvm/Support/SpecialCaseList.h
+++ b/llvm/include/llvm/Support/SpecialCaseList.h
@@ -14,6 +14,7 @@
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
#include <string>
#include <utility>
@@ -23,10 +24,6 @@ namespace llvm {
class MemoryBuffer;
class StringRef;
-namespace vfs {
-class FileSystem;
-}
-
/// This is a utility class used to parse user-provided text files with
/// "special case lists" for code sanitizers. Such files are used to
/// define an "ABI list" for DataFlowSanitizer and allow/exclusion lists for
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h
index d22c534228331..288f9817976e6 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -27,6 +27,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <atomic>
#include <cassert>
#include <cstdint>
@@ -215,8 +216,6 @@ class directory_iterator {
}
};
-class FileSystem;
-
namespace detail {
/// Keeps state for the recursive_directory_iterator.
diff --git a/llvm/include/llvm/Support/VirtualFileSystemFwd.h b/llvm/include/llvm/Support/VirtualFileSystemFwd.h
new file mode 100644
index 0000000000000..fc971f7aa9b40
--- /dev/null
+++ b/llvm/include/llvm/Support/VirtualFileSystemFwd.h
@@ -0,0 +1,36 @@
+//===- VirtualFileSystemFwd.h - Virtual File System Forward -----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// Contains the forward declaration for vfs::FileSystem, as well as the
+/// IntrusiveRefCntPtrInfo specialization for it. This allows the
+/// vfs::FileSystem class to be used with IntrusiveRefCntPtr without including
+/// its full definition.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_VIRTUALFILESYSTEMFWD_H
+#define LLVM_SUPPORT_VIRTUALFILESYSTEMFWD_H
+
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/Compiler.h"
+
+namespace llvm {
+namespace vfs {
+class FileSystem;
+} // namespace vfs
+
+template <> struct LLVM_ABI IntrusiveRefCntPtrInfo<::llvm::vfs::FileSystem> {
+ static unsigned useCount(const ::llvm::vfs::FileSystem *FS);
+ static void retain(::llvm::vfs::FileSystem *FS);
+ static void release(::llvm::vfs::FileSystem *FS);
+};
+
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_VIRTUALFILESYSTEMFWD_H
diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfile.h b/llvm/include/llvm/Transforms/IPO/SampleProfile.h
index ab8c754c16fbe..a3496b596dff6 100644
--- a/llvm/include/llvm/Transforms/IPO/SampleProfile.h
+++ b/llvm/include/llvm/Transforms/IPO/SampleProfile.h
@@ -19,6 +19,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <string>
namespace llvm {
@@ -32,10 +33,6 @@ LLVM_ABI extern cl::opt<int> ProfileInlineLimitMin;
LLVM_ABI extern cl::opt<int> ProfileInlineLimitMax;
LLVM_ABI extern cl::opt<bool> SortProfiledSCC;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
/// The sample profiler data loader pass.
class SampleProfileLoaderPass
: public OptionalPassInfoMixin<SampleProfileLoaderPass> {
diff --git a/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h b/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
index 01104097180e4..3afd88f144859 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/MemProfUse.h
@@ -17,16 +17,13 @@
#include "llvm/ProfileData/DataAccessProf.h"
#include "llvm/ProfileData/MemProf.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
namespace llvm {
class IndexedInstrProfReader;
class Module;
class TargetLibraryInfo;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
class MemProfUsePass : public OptionalPassInfoMixin<MemProfUsePass> {
public:
LLVM_ABI explicit MemProfUsePass(
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
index 4cc0253ba0baf..1246c29ca3d46 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h
@@ -18,12 +18,10 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Transforms/Utils/Instrumentation.h"
namespace llvm {
-namespace vfs {
-class FileSystem;
-} // namespace vfs
struct SanitizerBinaryMetadataOptions {
bool Covered = false;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
index 269bcbcd32265..1d8b6fc2441c6 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
@@ -19,13 +19,11 @@
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/SpecialCaseList.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Transforms/Utils/Instrumentation.h"
namespace llvm {
class Module;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
/// This is the ModuleSanitizerCoverage pass used in the new pass manager. The
/// pass instruments functions for coverage, adds initialization calls to the
diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
index 5346871249cf5..c7262fb35ab95 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
@@ -40,6 +40,7 @@
#include "llvm/ProfileData/SampleProfReader.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/GenericDomTree.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/SampleProfileInference.h"
#include "llvm/Transforms/Utils/SampleProfileLoaderBaseUtil.h"
@@ -48,10 +49,6 @@ namespace llvm {
using namespace sampleprof;
using namespace sampleprofutil;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
-
#define DEBUG_TYPE "sample-profile-impl"
namespace afdo_detail {
diff --git a/llvm/include/llvm/WindowsDriver/MSVCPaths.h b/llvm/include/llvm/WindowsDriver/MSVCPaths.h
index 076c2eaf9c3f0..0a5f007d48006 100644
--- a/llvm/include/llvm/WindowsDriver/MSVCPaths.h
+++ b/llvm/include/llvm/WindowsDriver/MSVCPaths.h
@@ -12,16 +12,13 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include "llvm/TargetParser/Triple.h"
#include <optional>
#include <string>
namespace llvm {
-namespace vfs {
-class FileSystem;
-}
-
enum class SubDirectoryType {
Bin,
Include,
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 42e8bb4f9958e..7b970bee1adc8 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -2996,3 +2996,16 @@ const char OverlayFileSystem::ID = 0;
const char ProxyFileSystem::ID = 0;
const char InMemoryFileSystem::ID = 0;
const char RedirectingFileSystem::ID = 0;
+
+unsigned ::llvm::IntrusiveRefCntPtrInfo<FileSystem>::useCount(
+ const FileSystem *FS) {
+ return FS->UseCount();
+}
+
+void ::llvm::IntrusiveRefCntPtrInfo<FileSystem>::retain(FileSystem *FS) {
+ FS->Retain();
+}
+
+void ::llvm::IntrusiveRefCntPtrInfo<FileSystem>::release(FileSystem *FS) {
+ FS->Release();
+}
diff --git a/mlir/include/mlir/Target/LLVMIR/Export.h b/mlir/include/mlir/Target/LLVMIR/Export.h
index 49cac420c26bf..08f5f92980b20 100644
--- a/mlir/include/mlir/Target/LLVMIR/Export.h
+++ b/mlir/include/mlir/Target/LLVMIR/Export.h
@@ -10,14 +10,12 @@
#define MLIR_TARGET_LLVMIR_EXPORT_H
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
#include <memory>
namespace llvm {
class LLVMContext;
class Module;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
namespace mlir {
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index c5c4b105ee152..39d2570982ead 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -27,6 +27,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/IR/FPEnv.h"
#include "llvm/IR/Module.h"
+#include "llvm/Support/VirtualFileSystemFwd.h"
namespace llvm {
class BasicBlock;
@@ -36,9 +37,6 @@ class Function;
class IRBuilderBase;
class OpenMPIRBuilder;
class Value;
-namespace vfs {
-class FileSystem;
-} // namespace vfs
} // namespace llvm
namespace mlir {
diff --git a/polly/include/polly/ScopInliner.h b/polly/include/polly/ScopInliner.h
index f5cf97833e6a5..940dbf49aebde 100644
--- a/polly/include/polly/ScopInliner.h
+++ b/polly/include/polly/ScopInliner.h
@@ -13,12 +13,7 @@
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/IR/PassManager.h"
-
-namespace llvm {
-namespace vfs {
-class FileSystem;
-}
-} // namespace llvm
+#include "llvm/Support/VirtualFileSystemFwd.h"
namespace polly {
class ScopInlinerPass : public llvm::OptionalPassInfoMixin<ScopInlinerPass> {
More information about the cfe-commits
mailing list