Skip to content

Commit 1c3d467

Browse files
committed
[ParseableInterfaces] Use namespace path = llvm::sys::path
Makes this code easier to read. No functionality change.
1 parent 4bfe4ef commit 1c3d467

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/Frontend/ParseableInterfaceSupport.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
444444
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
445445
llvm::SmallVectorImpl<char> &Scratch) {
446446

447+
namespace path = llvm::sys::path;
448+
447449
// If running in OnlySerialized mode, ParseableInterfaceModuleLoader
448450
// should not have been constructed at all.
449451
assert(LoadMode != ModuleLoadingMode::OnlySerialized);
@@ -454,11 +456,11 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
454456

455457
// First check to see if the .swiftinterface exists at all. Bail if not.
456458
ModPath = DirName;
457-
llvm::sys::path::append(ModPath, ModuleFilename);
459+
path::append(ModPath, ModuleFilename);
458460

459461
auto Ext = file_types::getExtension(file_types::TY_SwiftParseableInterfaceFile);
460462
InPath = ModPath;
461-
llvm::sys::path::replace_extension(InPath, Ext);
463+
path::replace_extension(InPath, Ext);
462464
if (!FS.exists(InPath))
463465
return std::make_error_code(std::errc::no_such_file_or_directory);
464466

@@ -477,24 +479,23 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
477479
// from the SDK.
478480
if (!PrebuiltCacheDir.empty()) {
479481
StringRef SDKPath = Ctx.SearchPathOpts.SDKPath;
480-
if (!SDKPath.empty() && hasPrefix(llvm::sys::path::begin(InPath),
481-
llvm::sys::path::end(InPath),
482-
llvm::sys::path::begin(SDKPath),
483-
llvm::sys::path::end(SDKPath))) {
482+
if (!SDKPath.empty() && hasPrefix(path::begin(InPath),
483+
path::end(InPath),
484+
path::begin(SDKPath),
485+
path::end(SDKPath))) {
484486
// Assemble the expected path: $PREBUILT_CACHE/Foo.swiftmodule or
485487
// $PREBUILT_CACHE/Foo.swiftmodule/arch.swiftmodule. Note that there's no
486488
// cache key here.
487489
OutPath = PrebuiltCacheDir;
488490

489491
// FIXME: Would it be possible to only have architecture-specific names
490492
// here? Then we could skip this check.
491-
StringRef InParentDirName =
492-
llvm::sys::path::filename(llvm::sys::path::parent_path(InPath));
493-
if (llvm::sys::path::extension(InParentDirName) == ".swiftmodule") {
494-
assert(llvm::sys::path::stem(InParentDirName) == ModuleID.first.str());
495-
llvm::sys::path::append(OutPath, InParentDirName);
493+
StringRef InParentDirName = path::filename(path::parent_path(InPath));
494+
if (path::extension(InParentDirName) == ".swiftmodule") {
495+
assert(path::stem(InParentDirName) == ModuleID.first.str());
496+
path::append(OutPath, InParentDirName);
496497
}
497-
llvm::sys::path::append(OutPath, ModuleFilename);
498+
path::append(OutPath, ModuleFilename);
498499

499500
if (!swiftModuleIsUpToDate(FS, ModuleID, OutPath, Diags,
500501
dependencyTracker)) {
@@ -534,9 +535,8 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
534535
// original directory. We should probably just not try to match the signature
535536
// of the overridable entry point.
536537
auto ErrorCode = SerializedModuleLoaderBase::openModuleFiles(
537-
ModuleID, llvm::sys::path::parent_path(OutPath),
538-
llvm::sys::path::filename(OutPath), ModuleDocFilename, ModuleBuffer,
539-
ModuleDocBuffer, Scratch);
538+
ModuleID, path::parent_path(OutPath), path::filename(OutPath),
539+
ModuleDocFilename, ModuleBuffer, ModuleDocBuffer, Scratch);
540540
LLVM_DEBUG(llvm::dbgs() << "Loaded " << OutPath
541541
<< " via normal module loader");
542542
if (ErrorCode) {

0 commit comments

Comments
 (0)