Skip to content

Commit 9718949

Browse files
authored
The real option name and not the alias used is displayed in msgs when using a config file (#107613)
An example of this is the -mpure-code option. Without a config file being used, an error message will print `-mpure-code`. But if a config file is used, the error message will print `-mexecute-only`.
1 parent 4cb61c2 commit 9718949

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt,
10051005
Copy->setOwnsValues(Opt->getOwnsValues());
10061006
Opt->setOwnsValues(false);
10071007
Args.append(Copy);
1008+
if (Opt->getAlias()) {
1009+
const Arg *Alias = Opt->getAlias();
1010+
unsigned Index = Args.MakeIndex(Alias->getSpelling());
1011+
auto AliasCopy = std::make_unique<Arg>(Alias->getOption(),
1012+
Args.getArgString(Index), Index);
1013+
AliasCopy->getValues() = Alias->getValues();
1014+
AliasCopy->setOwnsValues(false);
1015+
if (Alias->isClaimed())
1016+
AliasCopy->claim();
1017+
Copy->setAlias(std::move(AliasCopy));
1018+
}
10081019
}
10091020

10101021
bool Driver::readConfigFile(StringRef FileName,

clang/test/Driver/arm-execute-only.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \
2121
// RUN: | FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT
22+
// RUN: echo "-DABC" > %t.cfg
23+
// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \
24+
// RUN: | FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT
2225
// CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt'
2326

2427
// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \

0 commit comments

Comments
 (0)