Checks::unreachable() now needs LineInfo as an argument
MODIFY
include/vcpkg_Checks.h
include/vcpkg_Checks.h
@@ -20,7 +20,7 @@ namespace vcpkg
namespace vcpkg::Checks
{
- __declspec(noreturn) void unreachable();
+ __declspec(noreturn) void unreachable(const LineInfo& line_info);
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
_declspec(noreturn) void exit_with_message(const char* errorMessage);

MODIFY
src/PostBuildLint.cpp
src/PostBuildLint.cpp
@@ -693,7 +693,7 @@ namespace vcpkg::PostBuildLint
}
case LinkageType::backing_enum_t::NULLVALUE:
default:
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
error_count += check_no_empty_folders(package_dir);

MODIFY
src/commands_build.cpp
src/commands_build.cpp
@@ -101,7 +101,7 @@ namespace vcpkg::Commands::Build
case BuildResult::BUILD_FAILED: return BUILD_FAILED_STRING;
case BuildResult::POST_BUILD_CHECKS_FAILED: return POST_BUILD_CHECKS_FAILED_STRING;
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: return CASCADED_DUE_TO_MISSING_DEPENDENCIES_STRING;
- default: Checks::unreachable();
+ default: Checks::unreachable(VCPKG_LINE_INFO);
}
}

MODIFY
src/commands_ci.cpp
src/commands_ci.cpp
@@ -81,7 +81,7 @@ namespace vcpkg::Commands::CI
System::println(System::color::success, "Package %s is installed from cache", action.spec);
}
else
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
catch (const std::exception& e)
{

MODIFY
src/commands_install.cpp
src/commands_install.cpp
@@ -170,7 +170,7 @@ namespace vcpkg::Commands::Install
{
if (status_db->find_installed(dep, spgh.package.spec.target_triplet()) == status_db->end())
{
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
}
write_update(paths, spgh);
@@ -233,7 +233,7 @@ namespace vcpkg::Commands::Install
System::println(System::color::success, "Package %s is installed", action.spec);
}
else
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
catch (const std::exception& e)
{

MODIFY
src/commands_integrate.cpp
src/commands_integrate.cpp
@@ -156,7 +156,7 @@ namespace vcpkg::Commands::Integrate
System::println(System::color::warning, "Warning: Previous integration file was not removed");
exit(EXIT_FAILURE);
default:
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
}
}
@@ -195,7 +195,7 @@ namespace vcpkg::Commands::Integrate
System::println(System::color::warning, "Warning: integration was not applied");
exit(EXIT_FAILURE);
default:
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
Checks::check_exit(fs::exists(system_wide_targets_file), "Error: failed to copy targets file to %s", system_wide_targets_file.string());

MODIFY
src/commands_remove.cpp
src/commands_remove.cpp
@@ -129,7 +129,7 @@ namespace vcpkg::Commands::Remove
continue;
}
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
if (!not_installed.empty())
@@ -158,7 +158,7 @@ namespace vcpkg::Commands::Remove
return " " + p->spec.toString();
}
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}));
}
}
@@ -208,7 +208,7 @@ namespace vcpkg::Commands::Remove
break;
case remove_plan_type::UNKNOWN:
default:
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
if (alsoRemoveFolderFromPackages)

MODIFY
src/package_spec_parse_result.cpp
src/package_spec_parse_result.cpp
@@ -20,7 +20,7 @@ namespace vcpkg
case package_spec_parse_result::INVALID_CHARACTERS:
return "Contains invalid characters. Only alphanumeric lowercase ASCII characters and dashes are allowed";
default:
- Checks::unreachable();
+ Checks::unreachable(VCPKG_LINE_INFO);
}
}

MODIFY
src/vcpkg_Checks.cpp
src/vcpkg_Checks.cpp
#include "pch.h"
#include "vcpkg_Checks.h"
#include "vcpkg_System.h"
+#include "vcpkglib.h"
namespace vcpkg
{
@@ -12,9 +13,10 @@ namespace vcpkg
namespace vcpkg::Checks
{
- __declspec(noreturn) void unreachable()
+ __declspec(noreturn) void unreachable(const LineInfo& line_info)
{
System::println(System::color::error, "Error: Unreachable code was reached");
+ System::println(System::color::error, line_info.toString()); // Always print line_info here
#ifndef NDEBUG
std::abort();
#else

Checks::unreachable() now needs LineInfo as an argument