Skip to content

Commit 81e58f3

Browse files
committed
use a single loop to handle both prefix mapping option formats
1 parent 269df33 commit 81e58f3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5082,22 +5082,16 @@ void Clang::AddPrefixMappingOptions(const ArgList &Args, ArgStringList &CmdArgs,
50825082
}
50835083
}
50845084

5085-
for (const Arg *A : Args.filtered(options::OPT_fdepscan_prefix_map_EQ)) {
5085+
for (const Arg *A : Args.filtered(options::OPT_fdepscan_prefix_map, options::OPT_fdepscan_prefix_map_EQ)) {
50865086
A->claim();
5087-
StringRef Map = A->getValue();
5088-
StringRef Prefix = Map.split('=').first;
5089-
if (Prefix.size() == Map.size() || !IsPathApplicableAsPrefix(Prefix)) {
5090-
D.Diag(diag::err_drv_invalid_argument_to_option)
5091-
<< A->getValue() << A->getOption().getName();
5087+
StringRef Prefix, MapTarget;
5088+
if (A->getOption().matches(options::OPT_fdepscan_prefix_map_EQ)) {
5089+
StringRef Map = A->getValue();
5090+
std::tie(Prefix, MapTarget) = Map.split('=');
50925091
} else {
5093-
A->render(Args, CmdArgs);
5092+
Prefix = A->getValue(0);
5093+
MapTarget = A->getValue(1);
50945094
}
5095-
}
5096-
5097-
for (const Arg *A : Args.filtered(options::OPT_fdepscan_prefix_map)) {
5098-
A->claim();
5099-
StringRef Prefix = A->getValue(0);
5100-
StringRef MapTarget = A->getValue(1);
51015095
if (MapTarget.size() == 0 || !IsPathApplicableAsPrefix(Prefix)) {
51025096
D.Diag(diag::err_drv_invalid_argument_to_option)
51035097
<< A->getValue() << A->getOption().getName();

0 commit comments

Comments
 (0)