diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2018-04-12 00:47:17 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2018-04-12 00:47:17 -0700 |
| commit | a2aeb2f1949c42622ccc7f9572a441e2a4475132 (patch) | |
| tree | b9f06050b6a1fc09950783508686be4143b1da28 /toolsrc/include | |
| parent | 8da8f3e5b3cca98e9151d421a91f5c1590a47086 (diff) | |
| download | vcpkg-a2aeb2f1949c42622ccc7f9572a441e2a4475132.tar.gz vcpkg-a2aeb2f1949c42622ccc7f9572a441e2a4475132.zip | |
[vcpkg] Mark many types noexcept. Make certain code patterns more transparent to /analyze. #ifdef-out unused code on non-windows.
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/chrono.h | 10 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/cstringview.h | 15 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/lineinfo.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/optional.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/span.h | 7 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/strings.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/binaryparagraph.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/build.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/dependencies.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/packagespecparseresult.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/statusparagraph.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/triplet.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/versiont.h | 4 |
14 files changed, 30 insertions, 42 deletions
diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h index 7b393e377..aa764a597 100644 --- a/toolsrc/include/vcpkg/base/chrono.h +++ b/toolsrc/include/vcpkg/base/chrono.h @@ -11,8 +11,8 @@ namespace vcpkg::Chrono using duration = std::chrono::high_resolution_clock::time_point::duration; public: - constexpr ElapsedTime() : m_duration() {} - constexpr ElapsedTime(duration d) : m_duration(d) {} + constexpr ElapsedTime() noexcept : m_duration() {} + constexpr ElapsedTime(duration d) noexcept : m_duration(d) {} template<class TimeUnit> TimeUnit as() const @@ -31,7 +31,7 @@ namespace vcpkg::Chrono public: static ElapsedTimer create_started(); - constexpr ElapsedTimer() : m_start_tick() {} + constexpr ElapsedTimer() noexcept : m_start_tick() {} ElapsedTime elapsed() const { @@ -52,8 +52,8 @@ namespace vcpkg::Chrono static Optional<CTime> get_current_date_time(); static Optional<CTime> parse(CStringView str); - constexpr CTime() : m_tm{0} {} - explicit constexpr CTime(tm t) : m_tm{t} {} + constexpr CTime() noexcept : m_tm{0} {} + explicit constexpr CTime(tm t) noexcept : m_tm{t} {} std::string to_string() const; diff --git a/toolsrc/include/vcpkg/base/cstringview.h b/toolsrc/include/vcpkg/base/cstringview.h index 0441bc573..f285aa36c 100644 --- a/toolsrc/include/vcpkg/base/cstringview.h +++ b/toolsrc/include/vcpkg/base/cstringview.h @@ -7,7 +7,7 @@ namespace vcpkg { struct CStringView { - constexpr CStringView() : cstr(nullptr) {} + constexpr CStringView() noexcept : cstr(nullptr) {} constexpr CStringView(const char* cstr) : cstr(cstr) {} constexpr CStringView(const CStringView&) = default; CStringView(const std::string& str) : cstr(str.c_str()) {} @@ -18,19 +18,6 @@ namespace vcpkg const char* cstr; }; - struct CWStringView - { - constexpr CWStringView() : cstr(nullptr) {} - constexpr CWStringView(const wchar_t* cstr) : cstr(cstr) {} - constexpr CWStringView(const CWStringView&) = default; - CWStringView(const std::wstring& str) : cstr(str.c_str()) {} - - constexpr const wchar_t* c_str() const { return cstr; } - - private: - const wchar_t* cstr; - }; - namespace details { inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; } diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index ac1f192ae..f16805d0a 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -64,7 +64,7 @@ namespace vcpkg::Files Filesystem& get_real_filesystem(); - static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; + static constexpr const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; bool has_invalid_chars_for_filesystem(const std::string& s); diff --git a/toolsrc/include/vcpkg/base/lineinfo.h b/toolsrc/include/vcpkg/base/lineinfo.h index e7e8c3031..e0eb8bec9 100644 --- a/toolsrc/include/vcpkg/base/lineinfo.h +++ b/toolsrc/include/vcpkg/base/lineinfo.h @@ -9,7 +9,7 @@ namespace vcpkg int line_number; const char* file_name; - constexpr LineInfo() : line_number(0), file_name("") {} + constexpr LineInfo() noexcept : line_number(0), file_name("") {} constexpr LineInfo(const int lineno, const char* filename) : line_number(lineno), file_name(filename) {} std::string to_string() const; diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index b629de9b3..6b84b10aa 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -16,7 +16,7 @@ namespace vcpkg template<class T> struct OptionalStorage { - constexpr OptionalStorage() : m_is_present(false), m_t() {} + constexpr OptionalStorage() noexcept : m_is_present(false), m_t() {} constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {} constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} @@ -33,7 +33,7 @@ namespace vcpkg template<class T> struct OptionalStorage<T&> { - constexpr OptionalStorage() : m_t(nullptr) {} + constexpr OptionalStorage() noexcept : m_t(nullptr) {} constexpr OptionalStorage(T& t) : m_t(&t) {} constexpr bool has_value() const { return m_t != nullptr; } @@ -48,7 +48,7 @@ namespace vcpkg template<class T> struct Optional { - constexpr Optional() {} + constexpr Optional() noexcept {} // Constructors are intentionally implicit constexpr Optional(NullOpt) {} diff --git a/toolsrc/include/vcpkg/base/span.h b/toolsrc/include/vcpkg/base/span.h index c9ac18afe..2b067d0ac 100644 --- a/toolsrc/include/vcpkg/base/span.h +++ b/toolsrc/include/vcpkg/base/span.h @@ -19,18 +19,19 @@ namespace vcpkg using iterator = pointer;
constexpr Span() noexcept : m_ptr(nullptr), m_count(0) {}
- constexpr Span(std::nullptr_t) noexcept : Span() {}
+ constexpr Span(std::nullptr_t) noexcept : m_ptr(nullptr), m_count(0) {}
constexpr Span(pointer ptr, size_t count) noexcept : m_ptr(ptr), m_count(count) {}
constexpr Span(pointer ptr_begin, pointer ptr_end) noexcept : m_ptr(ptr_begin), m_count(ptr_end - ptr_begin) {}
constexpr Span(std::initializer_list<T> l) noexcept : m_ptr(l.begin()), m_count(l.size()) {}
template<size_t N>
- constexpr Span(T (&arr)[N]) noexcept : Span(arr, N)
+ constexpr Span(T (&arr)[N]) noexcept : m_ptr(arr), m_count(N)
{
}
template<size_t N>
- constexpr Span(const std::array<std::remove_const_t<T>, N>& arr) noexcept : Span(arr.data(), arr.size())
+ constexpr Span(const std::array<std::remove_const_t<T>, N>& arr) noexcept
+ : m_ptr(arr.data()), m_count(arr.size())
{
}
diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index c32e81ac2..4cc17bcf4 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -36,7 +36,7 @@ namespace vcpkg::Strings std::wstring to_utf16(const CStringView& s); - std::string to_utf8(const CWStringView& w); + std::string to_utf8(const wchar_t* w); std::string escape_string(const CStringView& s, char char_to_escape, char escape_char); diff --git a/toolsrc/include/vcpkg/binaryparagraph.h b/toolsrc/include/vcpkg/binaryparagraph.h index 3315151c6..5ba2fbde3 100644 --- a/toolsrc/include/vcpkg/binaryparagraph.h +++ b/toolsrc/include/vcpkg/binaryparagraph.h @@ -12,7 +12,7 @@ namespace vcpkg /// </summary> struct BinaryParagraph { - BinaryParagraph(); + BinaryParagraph() noexcept; explicit BinaryParagraph(std::unordered_map<std::string, std::string> fields); BinaryParagraph(const SourceParagraph& spgh, const Triplet& triplet, const std::string& abi_tag); BinaryParagraph(const SourceParagraph& spgh, const FeatureParagraph& fpgh, const Triplet& triplet); diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index a86245ccf..c5e7e8d88 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -62,7 +62,7 @@ namespace vcpkg::Build BUILT_IN, ARIA2, }; - const std::string& to_string(DownloadTool tool); + const std::string& to_string(DownloadTool tool); struct BuildPackageOptions { @@ -203,8 +203,8 @@ namespace vcpkg::Build struct BuildInfo { - LinkageType crt_linkage; - LinkageType library_linkage; + LinkageType crt_linkage = LinkageType::DYNAMIC; + LinkageType library_linkage = LinkageType::DYNAMIC; Optional<std::string> version; diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 704e76b07..3c3b8f267 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -35,7 +35,7 @@ namespace vcpkg::Dependencies { static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right); - InstallPlanAction(); + InstallPlanAction() noexcept; InstallPlanAction(InstalledPackageView&& spghs, const std::set<std::string>& features, @@ -73,7 +73,7 @@ namespace vcpkg::Dependencies { static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right); - RemovePlanAction(); + RemovePlanAction() noexcept; RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type); PackageSpec spec; @@ -103,7 +103,7 @@ namespace vcpkg::Dependencies { static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right); - ExportPlanAction(); + ExportPlanAction() noexcept; ExportPlanAction(const PackageSpec& spec, InstalledPackageView&& installed_package, const RequestType& request_type); diff --git a/toolsrc/include/vcpkg/packagespecparseresult.h b/toolsrc/include/vcpkg/packagespecparseresult.h index dd91c9a67..be3497152 100644 --- a/toolsrc/include/vcpkg/packagespecparseresult.h +++ b/toolsrc/include/vcpkg/packagespecparseresult.h @@ -17,7 +17,7 @@ namespace vcpkg template<> struct ErrorHolder<PackageSpecParseResult> { - ErrorHolder() : m_err(PackageSpecParseResult::SUCCESS) {} + ErrorHolder() noexcept : m_err(PackageSpecParseResult::SUCCESS) {} ErrorHolder(PackageSpecParseResult err) : m_err(err) {} bool has_error() const { return m_err != PackageSpecParseResult::SUCCESS; } diff --git a/toolsrc/include/vcpkg/statusparagraph.h b/toolsrc/include/vcpkg/statusparagraph.h index 16144e467..e79c946cc 100644 --- a/toolsrc/include/vcpkg/statusparagraph.h +++ b/toolsrc/include/vcpkg/statusparagraph.h @@ -29,7 +29,7 @@ namespace vcpkg /// </summary> struct StatusParagraph { - StatusParagraph(); + StatusParagraph() noexcept; explicit StatusParagraph(std::unordered_map<std::string, std::string>&& fields); bool is_installed() const { return want == Want::INSTALL && state == InstallState::INSTALLED; } @@ -47,7 +47,7 @@ namespace vcpkg struct InstalledPackageView { - InstalledPackageView() : core(nullptr) {} + InstalledPackageView() noexcept : core(nullptr) {} InstalledPackageView(const StatusParagraph* c, std::vector<const StatusParagraph*>&& fs) : core(c), features(std::move(fs)) diff --git a/toolsrc/include/vcpkg/triplet.h b/toolsrc/include/vcpkg/triplet.h index 10464dc2c..334960e49 100644 --- a/toolsrc/include/vcpkg/triplet.h +++ b/toolsrc/include/vcpkg/triplet.h @@ -9,7 +9,7 @@ namespace vcpkg struct Triplet { public: - constexpr Triplet() : m_instance(&DEFAULT_INSTANCE) {} + constexpr Triplet() noexcept : m_instance(&DEFAULT_INSTANCE) {} static Triplet from_canonical_name(const std::string& triplet_as_string); @@ -47,4 +47,4 @@ namespace std { size_t operator()(const vcpkg::Triplet& t) const { return t.hash_code(); } }; -}
\ No newline at end of file +} diff --git a/toolsrc/include/vcpkg/versiont.h b/toolsrc/include/vcpkg/versiont.h index 8427dfe3b..e893f1abc 100644 --- a/toolsrc/include/vcpkg/versiont.h +++ b/toolsrc/include/vcpkg/versiont.h @@ -5,7 +5,7 @@ namespace vcpkg { struct VersionT { - VersionT(); + VersionT() noexcept; VersionT(std::string&& value); VersionT(const std::string& value); @@ -23,7 +23,7 @@ namespace vcpkg VersionT left; VersionT right; - VersionDiff(); + VersionDiff() noexcept; VersionDiff(const VersionT& left, const VersionT& right); std::string to_string() const; |
