Merge remote-tracking branch 'origin/main' into rebranch

This commit is contained in:
swift-ci
2025-06-25 13:36:52 -07:00
4 changed files with 12 additions and 10 deletions

View File

@@ -499,7 +499,7 @@ public:
bool SkipSDKImportPaths = false; bool SkipSDKImportPaths = false;
/// Scanner Prefix Mapper. /// Scanner Prefix Mapper.
std::vector<std::string> ScannerPrefixMapper; std::vector<std::pair<std::string, std::string>> ScannerPrefixMapper;
/// Verify resolved plugin is not changed. /// Verify resolved plugin is not changed.
bool ResolvedPluginVerification = false; bool ResolvedPluginVerification = false;

View File

@@ -755,12 +755,8 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService(
if (!ScannerPrefixMapper.empty()) { if (!ScannerPrefixMapper.empty()) {
Mapper = std::make_unique<llvm::PrefixMapper>(); Mapper = std::make_unique<llvm::PrefixMapper>();
SmallVector<llvm::MappedPrefix, 4> Prefixes; SmallVector<llvm::MappedPrefix, 4> Prefixes;
if (auto E = llvm::MappedPrefix::transformJoined(ScannerPrefixMapper, llvm::MappedPrefix::transformPairs(ScannerPrefixMapper,
Prefixes)) { Prefixes);
Instance.getDiags().diagnose(SourceLoc(), diag::error_prefix_mapping,
toString(std::move(E)));
return true;
}
Mapper->addRange(Prefixes); Mapper->addRange(Prefixes);
Mapper->sort(); Mapper->sort();
} }

View File

@@ -40,8 +40,9 @@ using namespace clang::tooling::dependencies;
static void addScannerPrefixMapperInvocationArguments( static void addScannerPrefixMapperInvocationArguments(
std::vector<std::string> &invocationArgStrs, ASTContext &ctx) { std::vector<std::string> &invocationArgStrs, ASTContext &ctx) {
for (const auto &arg : ctx.SearchPathOpts.ScannerPrefixMapper) { for (const auto &arg : ctx.SearchPathOpts.ScannerPrefixMapper) {
std::string prefixMapArg = "-fdepscan-prefix-map=" + arg; invocationArgStrs.push_back("-fdepscan-prefix-map");
invocationArgStrs.push_back(prefixMapArg); invocationArgStrs.push_back(arg.first);
invocationArgStrs.push_back(arg.second);
} }
} }

View File

@@ -35,6 +35,7 @@
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#include "llvm/Support/LineIterator.h" #include "llvm/Support/LineIterator.h"
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#include "llvm/Support/PrefixMapper.h"
#include "llvm/Support/Process.h" #include "llvm/Support/Process.h"
#include "llvm/Support/VersionTuple.h" #include "llvm/Support/VersionTuple.h"
#include "llvm/Support/WithColor.h" #include "llvm/Support/WithColor.h"
@@ -2473,7 +2474,11 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
Opts.DeserializedPathRecoverer.addMapping(SplitMap.first, SplitMap.second); Opts.DeserializedPathRecoverer.addMapping(SplitMap.first, SplitMap.second);
} }
for (StringRef Opt : Args.getAllArgValues(OPT_scanner_prefix_map)) { for (StringRef Opt : Args.getAllArgValues(OPT_scanner_prefix_map)) {
Opts.ScannerPrefixMapper.push_back(Opt.str()); if (auto Mapping = llvm::MappedPrefix::getFromJoined(Opt)) {
Opts.ScannerPrefixMapper.push_back({Mapping->Old, Mapping->New});
} else {
Diags.diagnose(SourceLoc(), diag::error_prefix_mapping, Opt);
}
} }
Opts.ResolvedPluginVerification |= Opts.ResolvedPluginVerification |=