diff options
author | Tom Stellard <tstellar@redhat.com> | 2018-05-17 18:55:19 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2018-05-17 18:55:19 +0000 |
commit | fb18c2f200d4a364a071e7eec822ec4249a0a11b (patch) | |
tree | 7af7614d810dfde7ea10c5fe523fbd083705e9db | |
parent | f0ac6bbc7e2082f14cbec7fd1241c130f938201a (diff) |
Merging r330926:
------------------------------------------------------------------------
r330926 | sepavloff | 2018-04-25 23:28:47 -0700 (Wed, 25 Apr 2018) | 9 lines
[ConfigFiles] Update argument strings when merging argrument lists
Implementation of `InputArgList` assumes its field `ArgStrings` contains
strings for each argument exactly in the same order. This condition was
broken when arguments from config file and from invocation were merged.
This change fixes https://bugs.llvm.org/show_bug.cgi?id=37196 (Clang
config files can crash argument handling).
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@332649 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Driver/Driver.cpp | 5 | ||||
-rw-r--r-- | test/Driver/Inputs/empty.cfg | 0 | ||||
-rw-r--r-- | test/Driver/config-file4.c | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 325b233ac5..c890f77415 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -858,11 +858,14 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) { : std::move(*CLOptions)); if (HasConfigFile) for (auto *Opt : *CLOptions) { + if (Opt->getOption().matches(options::OPT_config)) + continue; + unsigned Index = Args.MakeIndex(Opt->getSpelling()); const Arg *BaseArg = &Opt->getBaseArg(); if (BaseArg == Opt) BaseArg = nullptr; Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(), - Args.size(), BaseArg); + Index, BaseArg); Copy->getValues() = Opt->getValues(); if (Opt->isClaimed()) Copy->claim(); diff --git a/test/Driver/Inputs/empty.cfg b/test/Driver/Inputs/empty.cfg new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/Driver/Inputs/empty.cfg diff --git a/test/Driver/config-file4.c b/test/Driver/config-file4.c new file mode 100644 index 0000000000..f61e317343 --- /dev/null +++ b/test/Driver/config-file4.c @@ -0,0 +1,2 @@ +// RUN: %clang --config %S/Inputs/empty.cfg -Wall -Wextra -Wformat -Wstrict-aliasing -Wshadow -Wpacked -Winline -Wimplicit-function-declaration -c %s -O2 -o /dev/null -v 2>&1 | FileCheck %s -check-prefix PR37196 +// PR37196: Configuration file: {{.*}}/empty.cfg |