Skip to content

Commit 7f8415b

Browse files
committed
ClangImporter: Refactor Clang invocation path remapping after change to...
...`clang::tooling::dependencies::DepscanPrefixMapping::configurePrefixMapper` See swiftlang/llvm-project#10723
1 parent 50ee3f4 commit 7f8415b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "swift/AST/ConcreteDeclRef.h"
2727
#include "swift/AST/DiagnosticEngine.h"
2828
#include "swift/AST/DiagnosticsClangImporter.h"
29+
#include "swift/AST/DiagnosticsFrontend.h"
2930
#include "swift/AST/DiagnosticsSema.h"
3031
#include "swift/AST/Evaluator.h"
3132
#include "swift/AST/IRGenOptions.h"
@@ -4207,8 +4208,19 @@ ClangImporter::getSwiftExplicitModuleDirectCC1Args() const {
42074208
if (!Impl.SwiftContext.SearchPathOpts.ScannerPrefixMapper.empty()) {
42084209
// Remap all the paths if requested.
42094210
llvm::PrefixMapper Mapper;
4210-
clang::tooling::dependencies::DepscanPrefixMapping::configurePrefixMapper(
4211-
Impl.SwiftContext.SearchPathOpts.ScannerPrefixMapper, Mapper);
4211+
SmallVector<llvm::MappedPrefix> Prefixes;
4212+
if (auto E = llvm::MappedPrefix::transformJoined(
4213+
Impl.SwiftContext.SearchPathOpts.ScannerPrefixMapper, Prefixes)) {
4214+
// Take permanent ownership of this string. In general the diagnostic
4215+
// might outlive this function.
4216+
auto errorMessage =
4217+
Impl.SwiftContext.AllocateCopy(llvm::toString(std::move(E)));
4218+
Impl.SwiftContext.Diags.diagnose(SourceLoc(), diag::error_prefix_mapping,
4219+
errorMessage);
4220+
}
4221+
Mapper.addRange(Prefixes);
4222+
Mapper.sort();
4223+
42124224
clang::tooling::dependencies::DepscanPrefixMapping::remapInvocationPaths(
42134225
instance, Mapper);
42144226
instance.getFrontendOpts().PathPrefixMappings.clear();

0 commit comments

Comments
 (0)