Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
// build directories, make them absolute immediately.
SmallString<128> Path = R.getFilePath();
if (BuildDir)
llvm::sys::path::make_absolute(*BuildDir, Path);
llvm::sys::fs::make_absolute(*BuildDir, Path);
else
SM.getFileManager().makeAbsolutePath(Path);

Expand Down
5 changes: 3 additions & 2 deletions clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ bool IncludeFixerActionFactory::runInvocation(

// Create the compiler's actual diagnostics engine. We want to drop all
// diagnostics here.
Compiler.createDiagnostics(new clang::IgnoringDiagConsumer,
Compiler.createDiagnostics(Files->getVirtualFileSystem(),
new clang::IgnoringDiagConsumer,
/*ShouldOwnClient=*/true);
Compiler.createSourceManager();
Compiler.createSourceManager(*Files);

// We abort on fatal errors so don't let a large number of errors become
// fatal. A missing #include can cause thousands of errors.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-move/Move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
return "";
llvm::SmallString<128> InitialDirectory(CurrentDir);
llvm::SmallString<128> AbsolutePath(Path);
llvm::sys::path::make_absolute(InitialDirectory, AbsolutePath);
llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath);
return CleanPath(std::move(AbsolutePath));
}

Expand Down
10 changes: 7 additions & 3 deletions clang-tools-extra/clangd/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI,
}

auto Clang = std::make_unique<CompilerInstance>(std::move(CI));
Clang->createVirtualFileSystem(VFS, &DiagsClient);
Clang->createDiagnostics(&DiagsClient, false);
Clang->createFileManager();
Clang->createDiagnostics(*VFS, &DiagsClient, false);

if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
Clang->getInvocation(), Clang->getDiagnostics(), VFS))
VFS = VFSWithRemapping;
Clang->createFileManager(VFS);

if (!Clang->createTarget())
return nullptr;

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct FragmentCompiler {
return std::nullopt;
}
llvm::SmallString<256> AbsPath = llvm::StringRef(*Path);
llvm::sys::path::make_absolute(FragmentDirectory, AbsPath);
llvm::sys::fs::make_absolute(FragmentDirectory, AbsPath);
llvm::sys::path::native(AbsPath, Style);
return AbsPath.str().str();
}
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/SystemIncludeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct DriverArgs {
// relative or absolute).
if (llvm::any_of(Driver,
[](char C) { return llvm::sys::path::is_separator(C); })) {
llvm::sys::path::make_absolute(Cmd.Directory, Driver);
llvm::sys::fs::make_absolute(Cmd.Directory, Driver);
}
this->Driver = Driver.str().str();
for (size_t I = 0, E = Cmd.CommandLine.size(); I < E; ++I) {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/SymbolCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class SymbolCollector::HeaderFileURICache {
if (R.second) {
llvm::SmallString<256> AbsPath = Path;
if (!llvm::sys::path::is_absolute(AbsPath) && !FallbackDir.empty())
llvm::sys::path::make_absolute(FallbackDir, AbsPath);
llvm::sys::fs::make_absolute(FallbackDir, AbsPath);
assert(llvm::sys::path::is_absolute(AbsPath) &&
"If the VFS can't make paths absolute, a FallbackDir must be "
"provided");
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/tool/ClangdMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ class TestScheme : public URIScheme {
Body = Body.ltrim('/');
llvm::SmallString<16> Path(Body);
path::native(Path);
path::make_absolute(TestScheme::TestDir, Path);
fs::make_absolute(TestScheme::TestDir, Path);
return std::string(Path);
}

Expand Down Expand Up @@ -775,8 +775,8 @@ It should be used via an editor plugin rather than invoked directly. For more in
clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.
)";
llvm::cl::HideUnrelatedOptions(ClangdCategories);
llvm::cl::ParseCommandLineOptions(argc, argv, Overview, /*Errs=*/nullptr,
/*VFS=*/nullptr, FlagsEnvVar);
llvm::cl::ParseCommandLineOptions(argc, argv, Overview,
/*Errs=*/nullptr, FlagsEnvVar);
if (Test) {
if (!Sync.getNumOccurrences())
Sync = true;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mapInputsToAbsPaths(clang::tooling::CompilationDatabase &CDB,
}
for (const auto &Cmd : Cmds) {
llvm::SmallString<256> CDBPath(Cmd.Filename);
llvm::sys::path::make_absolute(Cmd.Directory, CDBPath);
llvm::sys::fs::make_absolute(Cmd.Directory, CDBPath);
CDBToAbsPaths[std::string(CDBPath)] = std::string(AbsPath);
}
}
Expand Down
10 changes: 4 additions & 6 deletions clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,15 +625,13 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
*Diags, "clang"));

auto Clang = std::make_unique<CompilerInstance>(std::move(Invocation));
Clang->createVirtualFileSystem(VFS);
Clang->createDiagnostics();
Clang->createDiagnostics(*VFS);

Clang->createFileManager();
FileManager &FM = Clang->getFileManager();
auto *FM = Clang->createFileManager(VFS);
ASSERT_TRUE(Clang->ExecuteAction(*Inputs.MakeAction()));
EXPECT_THAT(
PI.getExporters(llvm::cantFail(FM.getFileRef("foo.h")), FM),
testing::ElementsAre(llvm::cantFail(FM.getFileRef("exporter.h"))));
PI.getExporters(llvm::cantFail(FM->getFileRef("foo.h")), *FM),
testing::ElementsAre(llvm::cantFail(FM->getFileRef("exporter.h"))));
}

TEST_F(PragmaIncludeTest, OutlivesFMAndSM) {
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ def err_drv_optimization_remark_format : Error<
def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, please use [no]simd instead">;
def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
def err_drv_incompatible_omp_arch : Error<"OpenMP target architecture '%0' pointer size is incompatible with host '%1'">;
def err_drv_omp_host_ir_file_not_found : Error<
"provided host compiler IR file '%0' is required to generate code for OpenMP "
"target regions but cannot be found">;
def err_drv_omp_host_target_not_supported : Error<
"target '%0' is not a supported OpenMP host target">;
def err_drv_ptrauth_not_supported : Error<
Expand Down Expand Up @@ -683,9 +686,6 @@ def warn_drv_fine_grained_bitfield_accesses_ignored : Warning<
"option '-ffine-grained-bitfield-accesses' cannot be enabled together with a sanitizer; flag ignored">,
InGroup<OptionIgnored>;

def err_drv_profile_instrument_use_path_with_no_kind : Error<
"option '-fprofile-instrument-use-path=' requires -fprofile-instrument-use=<kind>">;

def note_drv_verify_prefix_spelling : Note<
"-verify prefixes must start with a letter and contain only alphanumeric"
" characters, hyphens, and underscores">;
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/DiagnosticFrontendKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ def err_target_unsupported_type_for_abi
: Error<"%0 requires %1 type support, but ABI '%2' does not support it">;
}

def err_omp_host_ir_file_not_found : Error<
"provided host compiler IR file '%0' is required to generate code for OpenMP "
"target regions but cannot be found">;
def err_alias_to_undefined : Error<
"%select{alias|ifunc}0 must point to a defined "
"%select{variable or |}1function">;
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/CodeGen/BackendUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
llvm::MemoryBufferRef Buf);

void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
llvm::vfs::FileSystem &VFS, DiagnosticsEngine &Diags);
DiagnosticsEngine &Diags);
} // namespace clang

#endif
11 changes: 2 additions & 9 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3399,8 +3399,7 @@ defm declspec : BoolOption<"f", "declspec",
def fmodules_cache_path : Joined<["-"], "fmodules-cache-path=">, Group<i_Group>,
Flags<[]>, Visibility<[ClangOption, CC1Option]>,
MetaVarName<"<directory>">,
HelpText<"Specify the module cache path">,
MarshallingInfoString<HeaderSearchOpts<"ModuleCachePath">>;
HelpText<"Specify the module cache path">;
def fmodules_user_build_path : Separate<["-"], "fmodules-user-build-path">, Group<i_Group>,
Flags<[]>, Visibility<[ClangOption, CC1Option]>,
MetaVarName<"<directory>">,
Expand Down Expand Up @@ -8084,11 +8083,6 @@ def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">,
HelpText<"Generate instrumented code to collect execution counts into "
"<file> (overridden by LLVM_PROFILE_FILE env var)">,
MarshallingInfoString<CodeGenOpts<"InstrProfileOutput">>;
def fprofile_instrument_use_EQ : Joined<["-"], "fprofile-instrument-use=">,
HelpText<"Enable PGO use instrumentation">, Values<"none,clang,llvm,csllvm,sample-coldcov">,
NormalizedValuesScope<"llvm::driver::ProfileInstrKind">,
NormalizedValues<["ProfileNone", "ProfileClangInstr", "ProfileIRInstr", "ProfileCSIRInstr", "ProfileIRSampleColdCov"]>,
MarshallingInfoEnum<CodeGenOpts<"ProfileUse">, "ProfileNone">;
def fprofile_instrument_use_path_EQ :
Joined<["-"], "fprofile-instrument-use-path=">,
HelpText<"Specify the profile path in PGO use compilation">,
Expand Down Expand Up @@ -8892,8 +8886,7 @@ def fopenmp_is_target_device : Flag<["-"], "fopenmp-is-target-device">,
HelpText<"Generate code only for an OpenMP target device.">;
def : Flag<["-"], "fopenmp-is-device">, Alias<fopenmp_is_target_device>;
def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
HelpText<"Path to the IR file produced by the frontend for the host.">,
MarshallingInfoString<LangOpts<"OMPHostIRFile">>;
HelpText<"Path to the IR file produced by the frontend for the host.">;

} // let Visibility = [CC1Option, FC1Option]

Expand Down
7 changes: 4 additions & 3 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,16 @@ class ASTUnit {
/// \returns - The initialized ASTUnit or null if the AST failed to load.
static std::unique_ptr<ASTUnit> LoadFromASTFile(
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
std::shared_ptr<DiagnosticOptions> DiagOpts,
WhatToLoad ToLoad, std::shared_ptr<DiagnosticOptions> DiagOpts,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
const HeaderSearchOptions &HSOpts, const LangOptions *LangOpts = nullptr,
bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
bool AllowASTWithCompilerErrors = false,
bool UserFilesAreVolatile = false);
bool UserFilesAreVolatile = false,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem());

private:
/// Helper function for \c LoadFromCompilerInvocation() and
Expand Down
51 changes: 14 additions & 37 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ class CompilerInstance : public ModuleLoader {
/// The options used in this compiler instance.
std::shared_ptr<CompilerInvocation> Invocation;

/// The virtual file system instance.
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS;

/// The diagnostics engine instance.
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;

Expand Down Expand Up @@ -456,31 +453,7 @@ class CompilerInstance : public ModuleLoader {
/// @name Virtual File System
/// @{

bool hasVirtualFileSystem() const { return VFS != nullptr; }

/// Create a virtual file system instance based on the invocation.
///
/// @param BaseFS The file system that may be used when configuring the final
/// file system, and act as the underlying file system. Must not
/// be NULL.
/// @param DC If non-NULL, the diagnostic consumer to be used in case
/// configuring the file system emits diagnostics. Note that the
/// DiagnosticsEngine using the consumer won't obey the
/// --warning-suppression-mappings= flag.
void createVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem>
BaseFS = llvm::vfs::getRealFileSystem(),
DiagnosticConsumer *DC = nullptr);

/// Use the given file system.
void setVirtualFileSystem(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
VFS = std::move(FS);
}

llvm::vfs::FileSystem &getVirtualFileSystem() const { return *VFS; }

IntrusiveRefCntPtr<llvm::vfs::FileSystem> getVirtualFileSystemPtr() const {
return VFS;
}
llvm::vfs::FileSystem &getVirtualFileSystem() const;

/// @}
/// @name File Manager
Expand Down Expand Up @@ -718,31 +691,32 @@ class CompilerInstance : public ModuleLoader {
/// Note that this routine also replaces the diagnostic client,
/// allocating one if one is not provided.
///
/// \param VFS is used for any IO needed when creating DiagnosticsEngine. It
/// doesn't replace VFS in the CompilerInstance (if any).
///
/// \param Client If non-NULL, a diagnostic client that will be
/// attached to (and, then, owned by) the DiagnosticsEngine inside this AST
/// unit.
///
/// \param ShouldOwnClient If Client is non-NULL, specifies whether
/// the diagnostic object should take ownership of the client.
void createDiagnostics(DiagnosticConsumer *Client = nullptr,
void createDiagnostics(llvm::vfs::FileSystem &VFS,
DiagnosticConsumer *Client = nullptr,
bool ShouldOwnClient = true);

/// Create a DiagnosticsEngine object.
/// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
///
/// If no diagnostic client is provided, this creates a
/// DiagnosticConsumer that is owned by the returned diagnostic
/// object, if using directly the caller is responsible for
/// releasing the returned DiagnosticsEngine's client eventually.
///
/// \param VFS The file system used to load the suppression mappings file.
///
/// \param Opts - The diagnostic options; note that the created text
/// diagnostic object contains a reference to these options.
///
/// \param Client If non-NULL, a diagnostic client that will be
/// attached to (and, then, owned by) the returned DiagnosticsEngine
/// object. If NULL, the returned DiagnosticsEngine will own a newly-created
/// client.
/// object.
///
/// \param CodeGenOpts If non-NULL, the code gen options in use, which may be
/// used by some diagnostics printers (for logging purposes only).
Expand All @@ -755,10 +729,13 @@ class CompilerInstance : public ModuleLoader {
const CodeGenOptions *CodeGenOpts = nullptr);

/// Create the file manager and replace any existing one with it.
void createFileManager();
///
/// \return The new file manager on success, or null on failure.
FileManager *
createFileManager(IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);

/// Create the source manager and replace any existing one with it.
void createSourceManager();
void createSourceManager(FileManager &FileMgr);

/// Create the preprocessor, using the invocation, file, and source managers,
/// and replace any existing one with it.
Expand Down Expand Up @@ -1028,7 +1005,7 @@ class CompilerInstance : public ModuleLoader {

std::pair<std::shared_ptr<llvm::cas::ObjectStore>,
std::shared_ptr<llvm::cas::ActionCache>>
getOrCreateCASDatabases();
createCASDatabases();
};

} // end namespace clang
Expand Down
3 changes: 1 addition & 2 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation(

IntrusiveRefCntPtr<llvm::vfs::FileSystem> createVFSFromCompilerInvocation(
const CompilerInvocation &CI, DiagnosticsEngine &Diags,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
std::shared_ptr<llvm::cas::ObjectStore> OverrideCAS = nullptr);
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);

IntrusiveRefCntPtr<llvm::vfs::FileSystem>
createVFSFromOverlayFiles(ArrayRef<std::string> VFSOverlayFiles,
Expand Down
5 changes: 2 additions & 3 deletions clang/include/clang/Frontend/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ class ModuleDependencyCollector : public DependencyCollector {
std::error_code copyToRoot(StringRef Src, StringRef Dst = {});

public:
ModuleDependencyCollector(std::string DestDir,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
: DestDir(std::move(DestDir)), Canonicalizer(std::move(VFS)) {}
ModuleDependencyCollector(std::string DestDir)
: DestDir(std::move(DestDir)) {}
~ModuleDependencyCollector() override { writeFileMap(); }

StringRef getDest() { return DestDir; }
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,6 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS,
const LangOptions &Lang,
const llvm::Triple &triple);

void normalizeModuleCachePath(FileManager &FileMgr, StringRef Path,
SmallVectorImpl<char> &NormalizedPath);

} // namespace clang

#endif // LLVM_CLANG_LEX_HEADERSEARCH_H
9 changes: 1 addition & 8 deletions clang/include/clang/Serialization/ModuleCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,11 @@ class ModuleCache : public RefCountedBase<ModuleCache> {
/// were validated.
virtual void updateModuleTimestamp(StringRef ModuleFilename) = 0;

/// Prune module files that haven't been accessed in a long time.
virtual void maybePrune(StringRef Path, time_t PruneInterval,
time_t PruneAfter) = 0;

/// Returns this process's view of the module cache.
virtual InMemoryModuleCache &getInMemoryModuleCache() = 0;
virtual const InMemoryModuleCache &getInMemoryModuleCache() const = 0;

// TODO: Virtualize writing/reading PCM files, etc.
// TODO: Virtualize writing/reading PCM files, pruning, etc.

virtual ~ModuleCache() = default;
};
Expand All @@ -63,9 +59,6 @@ class ModuleCache : public RefCountedBase<ModuleCache> {
/// \c CompilerInstance instances participating in building modules for single
/// translation unit in order to share the same \c InMemoryModuleCache.
IntrusiveRefCntPtr<ModuleCache> createCrossProcessModuleCache();

/// Shared implementation of `ModuleCache::maybePrune()`.
void maybePruneImpl(StringRef Path, time_t PruneInterval, time_t PruneAfter);
} // namespace clang

#endif
Loading