Revert "clang-tidy fixes"

This reverts commit 2d0a76370e.
This commit is contained in:
Robert Schumacher 2017-12-23 07:29:12 -08:00
parent 2d0a76370e
commit 332414111d
22 changed files with 60 additions and 58 deletions

View File

@ -14,12 +14,11 @@ namespace vcpkg
{
struct Dependency
{
static Dependency parse_dependency(std::string&& name, std::string&& qualifier);
Features depend;
std::string qualifier;
std::string name() const;
static Dependency parse_dependency(std::string name, std::string qualifier);
};
std::vector<std::string> filter_dependencies(const std::vector<Dependency>& deps, const Triplet& t);

View File

@ -6,7 +6,7 @@ namespace vcpkg
struct VersionT
{
VersionT();
VersionT(std::string&& value);
VersionT(const std::string& value);
const std::string& to_string() const;

View File

@ -4,7 +4,7 @@
#pragma warning(push)
#pragma warning(disable : 4768)
#include <ShlObj.h>
#include <Shlobj.h>
#pragma warning(pop)
#else
#include <unistd.h>
@ -21,8 +21,10 @@
#include <vcpkg/metrics.h>
#include <vcpkg/paragraphs.h>
#include <vcpkg/userconfig.h>
#include <vcpkg/vcpkglib.h>
#include <cassert>
#include <fstream>
#include <memory>
#include <random>
@ -47,7 +49,7 @@ static void inner(const VcpkgCmdArguments& args)
Checks::exit_fail(VCPKG_LINE_INFO);
}
static const auto FIND_COMMAND = [&](auto&& commands) {
static const auto find_command = [&](auto&& commands) {
auto it = Util::find_if(commands, [&](auto&& commandc) {
return Strings::case_insensitive_ascii_equals(commandc.name, args.command);
});
@ -60,7 +62,7 @@ static void inner(const VcpkgCmdArguments& args)
return static_cast<decltype(&*it)>(nullptr);
};
if (const auto command_function = FIND_COMMAND(Commands::get_available_commands_type_c()))
if (const auto command_function = find_command(Commands::get_available_commands_type_c()))
{
return command_function->function(args);
}
@ -134,7 +136,7 @@ static void inner(const VcpkgCmdArguments& args)
}
}
if (const auto command_function = FIND_COMMAND(Commands::get_available_commands_type_b()))
if (const auto command_function = find_command(Commands::get_available_commands_type_b()))
{
return command_function->function(args, paths);
}
@ -159,7 +161,7 @@ static void inner(const VcpkgCmdArguments& args)
Input::check_triplet(default_triplet, paths);
if (const auto command_function = FIND_COMMAND(Commands::get_available_commands_type_a()))
if (const auto command_function = find_command(Commands::get_available_commands_type_a()))
{
return command_function->function(args, paths, default_triplet);
}
@ -212,7 +214,7 @@ static void load_config()
static std::string trim_path_from_command_line(const std::string& full_command_line)
{
Checks::check_exit(
VCPKG_LINE_INFO, !full_command_line.empty(), "Internal failure - cannot have empty command line");
VCPKG_LINE_INFO, full_command_line.size() > 0, "Internal failure - cannot have empty command line");
if (full_command_line[0] == '"')
{

View File

@ -15,7 +15,7 @@ namespace vcpkg::Chrono
using std::chrono::nanoseconds;
using std::chrono::seconds;
const auto nanos_as_double = static_cast<double>(nanos.count());
const double nanos_as_double = static_cast<double>(nanos.count());
if (duration_cast<hours>(nanos) > hours())
{

View File

@ -223,7 +223,7 @@ namespace vcpkg::CoffFileReader
static const char* FILE_START = "!<arch>\n";
static const size_t FILE_START_SIZE = 8;
fs.seekg(fstream::beg);
fs.seekg(fs.beg);
char file_start[FILE_START_SIZE];
fs.read(file_start, FILE_START_SIZE);

View File

@ -18,9 +18,9 @@ namespace vcpkg::Files
return std::make_error_code(std::errc::no_such_file_or_directory);
}
file_stream.seekg(0, std::fstream::end);
file_stream.seekg(0, file_stream.end);
auto length = file_stream.tellg();
file_stream.seekg(0, std::fstream::beg);
file_stream.seekg(0, file_stream.beg);
if (length > SIZE_MAX)
{

View File

@ -60,8 +60,7 @@ namespace vcpkg::Build::Command
spec.name());
const StatusParagraphs status_db = database_load_check(paths);
const Build::BuildPackageOptions build_package_options{
Build::UseHeadVersion::NO, Build::AllowDownloads::YES, Build::CleanBuildtrees::NO};
const Build::BuildPackageOptions build_package_options{Build::UseHeadVersion::NO, Build::AllowDownloads::YES};
const std::unordered_set<std::string> features_as_set(full_spec.features.begin(), full_spec.features.end());
@ -193,7 +192,7 @@ namespace vcpkg::Build
for (auto&& host : host_architectures)
{
const auto it = Util::find_if(toolset.supported_architectures, [&](const ToolsetArchOption& opt) {
auto it = Util::find_if(toolset.supported_architectures, [&](const ToolsetArchOption& opt) {
return host == opt.host_arch && target_arch == opt.target_arch;
});
if (it != toolset.supported_architectures.end()) return it->name;
@ -295,7 +294,7 @@ namespace vcpkg::Build
{
features.append(feature + ";");
}
if (!features.empty())
if (features.size() > 0)
{
features.pop_back();
}
@ -365,7 +364,7 @@ namespace vcpkg::Build
if (config.build_package_options.clean_buildtrees == CleanBuildtrees::YES)
{
auto& fs = paths.get_filesystem();
const auto buildtrees_dir = paths.buildtrees / spec.name();
auto buildtrees_dir = paths.buildtrees / spec.name();
auto buildtree_files = fs.get_files_non_recursive(buildtrees_dir);
for (auto&& file : buildtree_files)
{
@ -501,7 +500,7 @@ namespace vcpkg::Build
const std::vector<std::string> lines = Strings::split(ec_data.output, "\n");
PreBuildInfo pre_build_info{};
PreBuildInfo pre_build_info;
const auto e = lines.cend();
auto cur = std::find(lines.cbegin(), e, FLAG_GUID);

View File

@ -47,7 +47,7 @@ namespace vcpkg::Commands::Cache
Checks::exit_success(VCPKG_LINE_INFO);
}
if (args.command_arguments.empty())
if (args.command_arguments.size() == 0)
{
for (const BinaryParagraph& binary_paragraph : binary_paragraphs)
{

View File

@ -34,7 +34,7 @@ namespace vcpkg::Commands::Create
R"(Filename cannot contain invalid chars %s, but was %s)",
Files::FILESYSTEM_INVALID_CHARACTERS,
zip_file_name);
cmake_args.emplace_back("FILENAME", zip_file_name);
cmake_args.push_back({"FILENAME", zip_file_name});
}
const std::string cmd_launch_cmake = make_cmake_cmd(cmake_exe, paths.ports_cmake, cmake_args);

View File

@ -139,14 +139,14 @@ namespace vcpkg::Export::IFW
)###",
create_release_date()));
for (const auto& unique_package : unique_packages)
for (auto package = unique_packages.begin(); package != unique_packages.end(); ++package)
{
const ExportPlanAction& action = *(unique_package.second);
const ExportPlanAction& action = *(package->second);
const BinaryParagraph& binary_paragraph =
action.any_paragraph.binary_control_file.value_or_exit(VCPKG_LINE_INFO).core_paragraph;
package_xml_file_path =
raw_exported_dir_path / Strings::format("packages.%s", unique_package.first) / "meta" / "package.xml";
raw_exported_dir_path / Strings::format("packages.%s", package->first) / "meta" / "package.xml";
package_xml_dir_path = package_xml_file_path.parent_path();
fs.create_directories(package_xml_dir_path, ec);
Checks::check_exit(VCPKG_LINE_INFO,

View File

@ -191,7 +191,7 @@ namespace vcpkg::Commands::Integrate
const auto found = std::regex_search(*contents_data, match, RE);
if (found)
{
const auto ver = strtol(match[1].str().c_str(), nullptr, 10);
const int ver = atoi(match[1].str().c_str());
if (ver >= 1) should_install_system = false;
}
}

View File

@ -57,7 +57,7 @@ namespace vcpkg::Commands::List
return lhs->package.displayname() < rhs->package.displayname();
});
if (args.command_arguments.empty())
if (args.command_arguments.size() == 0)
{
for (const StatusParagraph* status_paragraph : installed_packages)
{

View File

@ -69,8 +69,8 @@ namespace vcpkg::Export
{
static constexpr std::array<ExportPlanType, 2> ORDER = {ExportPlanType::ALREADY_BUILT,
ExportPlanType::PORT_AVAILABLE_BUT_NOT_BUILT};
static constexpr Build::BuildPackageOptions build_options = {
Build::UseHeadVersion::NO, Build::AllowDownloads::YES, Build::CleanBuildtrees::NO};
static constexpr Build::BuildPackageOptions build_options = {Build::UseHeadVersion::NO,
Build::AllowDownloads::YES};
for (const ExportPlanType plan_type : ORDER)
{

View File

@ -159,7 +159,7 @@ namespace vcpkg::Install
auto package_files = Util::fmap(package_file_paths, [package_remove_char_count](const fs::path& path) {
std::string as_string = path.generic_string();
as_string.erase(0, package_remove_char_count);
return as_string;
return std::move(as_string);
});
return SortedVector<std::string>(std::move(package_files));

View File

@ -152,7 +152,7 @@ namespace vcpkg::Metrics
void track_property(const std::string& name, const std::string& value)
{
if (!properties.empty()) properties.push_back(',');
if (properties.size() != 0) properties.push_back(',');
properties.append(to_json_string(name));
properties.push_back(':');
properties.append(to_json_string(value));
@ -160,7 +160,7 @@ namespace vcpkg::Metrics
void track_metric(const std::string& name, double value)
{
if (!measurements.empty()) measurements.push_back(',');
if (measurements.size() != 0) measurements.push_back(',');
measurements.append(to_json_string(name));
measurements.push_back(':');
measurements.append(std::to_string(value));
@ -302,7 +302,7 @@ namespace vcpkg::Metrics
{
if (MAXDWORD <= payload.size()) abort();
std::wstring hdrs = L"Content-Type: application/json\r\n";
auto& p = const_cast<std::string&>(payload);
std::string& p = const_cast<std::string&>(payload);
results = WinHttpSendRequest(request,
hdrs.c_str(),
static_cast<DWORD>(hdrs.size()),
@ -383,27 +383,30 @@ namespace vcpkg::Metrics
auto& fs = Files::get_real_filesystem();
const fs::path exe_path = [&fs]() -> fs::path {
auto vcpkgdir = System::get_exe_path_of_current_process().parent_path();
auto path = vcpkgdir / "vcpkgmetricsuploader.exe";
if (fs.exists(path)) return path;
if (true)
{
const fs::path exe_path = [&fs]() -> fs::path {
auto vcpkgdir = System::get_exe_path_of_current_process().parent_path();
auto path = vcpkgdir / "vcpkgmetricsuploader.exe";
if (fs.exists(path)) return path;
path = vcpkgdir / "scripts" / "vcpkgmetricsuploader.exe";
if (fs.exists(path)) return path;
path = vcpkgdir / "scripts" / "vcpkgmetricsuploader.exe";
if (fs.exists(path)) return path;
return "";
}();
return "";
}();
std::error_code ec;
fs.create_directories(temp_folder_path, ec);
if (ec) return;
fs.copy_file(exe_path, temp_folder_path_exe, fs::copy_options::skip_existing, ec);
if (ec) return;
std::error_code ec;
fs.create_directories(temp_folder_path, ec);
if (ec) return;
fs.copy_file(exe_path, temp_folder_path_exe, fs::copy_options::skip_existing, ec);
if (ec) return;
}
const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + generate_random_UUID() + ".txt");
fs.write_contents(vcpkg_metrics_txt_path, payload);
const std::string cmd_line = Strings::format(R"(start "vcpkgmetricsuploader.exe" "%s" "%s")",
const std::string cmd_line = Strings::format("start \"vcpkgmetricsuploader.exe\" \"%s\" \"%s\"",
temp_folder_path_exe.u8string(),
vcpkg_metrics_txt_path.u8string());
System::cmd_execute_clean(cmd_line);

View File

@ -202,7 +202,7 @@ namespace vcpkg::Remove
std::vector<PackageSpec> specs;
if (Util::Sets::contains(options.switches, OPTION_OUTDATED))
{
if (!args.command_arguments.empty())
if (args.command_arguments.size() != 0)
{
System::println(System::Color::error, "Error: 'remove' accepts either libraries or '--outdated'");
Checks::exit_fail(VCPKG_LINE_INFO);
@ -221,7 +221,7 @@ namespace vcpkg::Remove
}
else
{
if (args.command_arguments.empty())
if (args.command_arguments.size() < 1)
{
System::println(System::Color::error, "Error: 'remove' accepts either libraries or '--outdated'");
Checks::exit_fail(VCPKG_LINE_INFO);

View File

@ -158,7 +158,7 @@ namespace vcpkg
return std::move(control_file);
}
Dependency Dependency::parse_dependency(std::string&& name, std::string&& qualifier)
Dependency Dependency::parse_dependency(std::string name, std::string qualifier)
{
Dependency dep;
dep.qualifier = qualifier;
@ -182,7 +182,7 @@ namespace vcpkg
{
return Util::fmap(depends, [&](const std::string& depend_string) -> Dependency {
auto pos = depend_string.find(' ');
if (pos == std::string::npos) return Dependency::parse_dependency(std::string{depend_string}, "");
if (pos == std::string::npos) return Dependency::parse_dependency(depend_string, "");
// expect of the form "\w+ \[\w+\]"
Dependency dep;
@ -190,7 +190,7 @@ namespace vcpkg
if (depend_string.c_str()[pos + 1] != '(' || depend_string[depend_string.size() - 1] != ')')
{
// Error, but for now just slurp the entire string.
return Dependency::parse_dependency(std::string{depend_string}, "");
return Dependency::parse_dependency(depend_string, "");
}
dep.qualifier = depend_string.substr(pos + 2, depend_string.size() - pos - 3);
return dep;

View File

@ -47,7 +47,7 @@ namespace vcpkg
StatusParagraphs::const_iterator StatusParagraphs::find_installed(const std::string& name,
const Triplet& triplet) const
{
const auto it = find(name, triplet);
const const_iterator it = find(name, triplet);
if (it != end() && (*it)->want == Want::INSTALL && (*it)->state == InstallState::INSTALLED)
{
return it;

View File

@ -35,8 +35,7 @@ namespace vcpkg::Update
auto&& installed_version = pgh->package.version;
if (installed_version != port_version)
{
output.push_back(
{pgh->package.spec, VersionDiff(std::string{installed_version}, std::string{port_version})});
output.push_back({pgh->package.spec, VersionDiff(installed_version, port_version)});
}
}
else

View File

@ -41,7 +41,7 @@ namespace vcpkg
const auto& pghs = *p_pghs;
std::unordered_map<std::string, std::string> keys;
if (!pghs.empty()) keys = pghs[0];
if (pghs.size() > 0) keys = pghs[0];
for (size_t x = 1; x < pghs.size(); ++x)
{

View File

@ -50,14 +50,14 @@ namespace vcpkg
const std::string& version_check_arguments,
const std::array<int, 3>& expected_version)
{
const auto it = Util::find_if(candidate_paths, [&](const fs::path& p) {
auto it = Util::find_if(candidate_paths, [&](const fs::path& p) {
const std::string cmd = Strings::format(R"("%s" %s)", p.u8string(), version_check_arguments);
return exists_and_has_equal_or_greater_version(cmd, expected_version);
});
if (it != candidate_paths.cend())
{
return *it;
return std::move(*it);
}
return nullopt;

View File

@ -6,7 +6,7 @@
namespace vcpkg
{
VersionT::VersionT() : value("0.0.0") {}
VersionT::VersionT(std::string&& value) : value(std::move(value)) {}
VersionT::VersionT(const std::string& value) : value(value) {}
const std::string& VersionT::to_string() const { return value; }
bool operator==(const VersionT& left, const VersionT& right) { return left.to_string() == right.to_string(); }
bool operator!=(const VersionT& left, const VersionT& right) { return left.to_string() != right.to_string(); }