diff options
| author | Thomas Fussell <thomas.fussell@gmail.com> | 2017-03-17 00:33:06 -0400 |
|---|---|---|
| committer | Thomas Fussell <thomas.fussell@gmail.com> | 2017-03-17 00:33:06 -0400 |
| commit | d821b0a28a7223d0b49745c53a3ff032fcb001c8 (patch) | |
| tree | 12e13d5ff298a4e4b4f946ceb90b49cbfbe2d2c9 /toolsrc/include | |
| parent | 4921636f6bc92e041a410870ce564615c85a6cfb (diff) | |
| parent | 01b1e39c6a006adba7b9cf2af758be679d0b7eb9 (diff) | |
| download | vcpkg-d821b0a28a7223d0b49745c53a3ff032fcb001c8.tar.gz vcpkg-d821b0a28a7223d0b49745c53a3ff032fcb001c8.zip | |
Merge branch 'master' of https://github.com/Microsoft/vcpkg
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/LineInfo.h | 17 | ||||
| -rw-r--r-- | toolsrc/include/expected.h | 12 | ||||
| -rw-r--r-- | toolsrc/include/lazy.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Checks.h | 29 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Enums.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Files.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkglib.h | 2 |
7 files changed, 44 insertions, 25 deletions
diff --git a/toolsrc/include/LineInfo.h b/toolsrc/include/LineInfo.h new file mode 100644 index 000000000..a3de4fc29 --- /dev/null +++ b/toolsrc/include/LineInfo.h @@ -0,0 +1,17 @@ +#pragma once + +namespace vcpkg +{ + struct LineInfo + { + int line_number; + const char* file_name; + + constexpr LineInfo() : line_number(0), file_name(nullptr) {} + constexpr LineInfo(const int line_number, const char* file_name) : line_number(line_number), file_name(file_name) {} + + std::string toString() const; + }; +} + +#define VCPKG_LINE_INFO vcpkg::LineInfo(__LINE__, __FILE__) diff --git a/toolsrc/include/expected.h b/toolsrc/include/expected.h index cbb513b22..377168645 100644 --- a/toolsrc/include/expected.h +++ b/toolsrc/include/expected.h @@ -40,15 +40,15 @@ namespace vcpkg return this->m_error_code; } - T&& get_or_throw() && + T&& get_or_throw(const LineInfo& line_info) && { - throw_if_error(); + throw_if_error(line_info); return std::move(this->m_t); } - const T& get_or_throw() const & + const T& get_or_throw(const LineInfo& line_info) const & { - throw_if_error(); + throw_if_error(line_info); return this->m_t; } @@ -71,9 +71,9 @@ namespace vcpkg } private: - void throw_if_error() const + void throw_if_error(const LineInfo& line_info) const { - Checks::check_throw(!this->m_error_code, this->m_error_code.message().c_str()); + Checks::check_throw(line_info, !this->m_error_code, this->m_error_code.message().c_str()); } std::error_code m_error_code; diff --git a/toolsrc/include/lazy.h b/toolsrc/include/lazy.h index f9dbd8dc7..0fa50dc4d 100644 --- a/toolsrc/include/lazy.h +++ b/toolsrc/include/lazy.h @@ -9,7 +9,7 @@ namespace vcpkg lazy() : value(T()), initialized(false) {} template <class F> - T const& get_lazy(F& f) const + T const& get_lazy(const F& f) const { if (!initialized) { diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 23869f35f..47662637f 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -1,51 +1,52 @@ #pragma once #include "vcpkg_Strings.h" +#include "LineInfo.h" 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); + _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage); template <class...Args> - _declspec(noreturn) void exit_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs) { - exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } - _declspec(noreturn) void throw_with_message(const char* errorMessage); + _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage); template <class...Args> - _declspec(noreturn) void throw_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs) { - throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } - void check_throw(bool expression, const char* errorMessage); + void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage); template <class...Args> - void check_throw(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) { if (!expression) { // Only create the string if the expression is false - throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } } - void check_exit(bool expression); + void check_exit(const LineInfo& line_info, bool expression); - void check_exit(bool expression, const char* errorMessage); + void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage); template <class...Args> - void check_exit(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) { if (!expression) { // Only create the string if the expression is false - exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); } } } diff --git a/toolsrc/include/vcpkg_Enums.h b/toolsrc/include/vcpkg_Enums.h index 5c4dc8b06..ef41155d9 100644 --- a/toolsrc/include/vcpkg_Enums.h +++ b/toolsrc/include/vcpkg_Enums.h @@ -1,11 +1,10 @@ #pragma once #include <string> +#include "LineInfo.h" namespace vcpkg::Enums { std::string nullvalue_toString(const std::string& enum_name); - __declspec(noreturn) void nullvalue_used(const std::string& enum_name); - - __declspec(noreturn) void unreachable(const std::string& enum_name); + __declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name); } diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 3f9570946..0b0373231 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -8,7 +8,7 @@ namespace vcpkg::Files { static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; - void check_is_directory(const fs::path& dirpath); + void check_is_directory(const LineInfo& line_info, const fs::path& dirpath); bool has_invalid_chars_for_filesystem(const std::string& s); diff --git a/toolsrc/include/vcpkglib.h b/toolsrc/include/vcpkglib.h index 353bfb0a0..710b21cd5 100644 --- a/toolsrc/include/vcpkglib.h +++ b/toolsrc/include/vcpkglib.h @@ -6,6 +6,8 @@ namespace vcpkg { + extern bool g_debugging; + StatusParagraphs database_load_check(const vcpkg_paths& paths); void write_update(const vcpkg_paths& paths, const StatusParagraph& p); |
