[vcpkg] Fix gcc-9 warning (#7816)

* drop one usage of span in export. Span is not appropriate for rvalues

* Add back reference

* Fix @ubsan 's comments
This commit is contained in:
Curtis J Bezault 2019-08-21 14:23:15 -07:00 committed by GitHub
parent 34a26540b1
commit 94ef325828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -339,26 +339,27 @@ namespace vcpkg::Export
struct OptionPair
{
const std::string& name;
const StringLiteral& name;
Optional<std::string>& out_opt;
};
const auto options_implies =
[&](const std::string& main_opt_name, bool main_opt, Span<const OptionPair> implying_opts) {
if (main_opt)
{
for (auto&& opt : implying_opts)
opt.out_opt = maybe_lookup(options.settings, opt.name);
}
else
{
for (auto&& opt : implying_opts)
Checks::check_exit(VCPKG_LINE_INFO,
!maybe_lookup(options.settings, opt.name),
"%s is only valid with %s",
opt.name,
main_opt_name);
}
};
const auto options_implies = [&](const StringLiteral& main_opt_name,
bool is_main_opt,
const std::initializer_list<OptionPair>& implying_opts) {
if (is_main_opt)
{
for (auto&& opt : implying_opts)
opt.out_opt = maybe_lookup(options.settings, opt.name);
}
else
{
for (auto&& opt : implying_opts)
Checks::check_exit(VCPKG_LINE_INFO,
!maybe_lookup(options.settings, opt.name),
"%s is only valid with %s",
opt.name,
main_opt_name);
}
};
#if defined(_MSC_VER) && _MSC_VER <= 1900
// there's a bug in VS 2015 that causes a bunch of "unreferenced local variable" warnings