r330926 - [ConfigFiles] Update argument strings when merging argrument lists
Serge Pavlov via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 25 23:28:47 PDT 2018
Author: sepavloff
Date: Wed Apr 25 23:28:47 2018
New Revision: 330926
URL: http://llvm.org/viewvc/llvm-project?rev=330926&view=rev
Log:
[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).
Added:
cfe/trunk/test/Driver/Inputs/empty.cfg
cfe/trunk/test/Driver/config-file4.c
Modified:
cfe/trunk/lib/Driver/Driver.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=330926&r1=330925&r2=330926&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Apr 25 23:28:47 2018
@@ -876,11 +876,14 @@ Compilation *Driver::BuildCompilation(Ar
: 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();
Added: cfe/trunk/test/Driver/Inputs/empty.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/empty.cfg?rev=330926&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/config-file4.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/config-file4.c?rev=330926&view=auto
==============================================================================
--- cfe/trunk/test/Driver/config-file4.c (added)
+++ cfe/trunk/test/Driver/config-file4.c Wed Apr 25 23:28:47 2018
@@ -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
More information about the cfe-commits
mailing list