Fix clang-tidy warnings (#1231)

* Fix clang-tidy warnings

Signed-off-by: Marcel Opprecht <marcel.opprecht@scandit.com>

* Fixup/clang-format

Co-authored-by: Marcel Opprecht <marcel.opprecht@scandit.com>
Co-authored-by: Jordan Bayles <jophba@chromium.org>
This commit is contained in:
Marcel Opprecht 2020-11-06 22:22:26 +01:00 committed by GitHub
parent 30170d651c
commit ceae0e3867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 15 deletions

View File

@ -143,7 +143,9 @@ bool Reader::decodeNumber(Token& token) {
``` ```
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command: Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
``` ```
ninja -v -C build-${LIB_TYPE}/ clang-format ninja -v -C build-${LIB_TYPE}/ clang-format
``` ```
For convenience, you can also run the `reformat.sh` script located in the root directory.

View File

@ -263,10 +263,10 @@ private:
CZString(ArrayIndex index); CZString(ArrayIndex index);
CZString(char const* str, unsigned length, DuplicationPolicy allocate); CZString(char const* str, unsigned length, DuplicationPolicy allocate);
CZString(CZString const& other); CZString(CZString const& other);
CZString(CZString&& other); CZString(CZString&& other) noexcept;
~CZString(); ~CZString();
CZString& operator=(const CZString& other); CZString& operator=(const CZString& other);
CZString& operator=(CZString&& other); CZString& operator=(CZString&& other) noexcept;
bool operator<(CZString const& other) const; bool operator<(CZString const& other) const;
bool operator==(CZString const& other) const; bool operator==(CZString const& other) const;
@ -344,13 +344,13 @@ public:
Value(bool value); Value(bool value);
Value(std::nullptr_t ptr) = delete; Value(std::nullptr_t ptr) = delete;
Value(const Value& other); Value(const Value& other);
Value(Value&& other); Value(Value&& other) noexcept;
~Value(); ~Value();
/// \note Overwrite existing comments. To preserve comments, use /// \note Overwrite existing comments. To preserve comments, use
/// #swapPayload(). /// #swapPayload().
Value& operator=(const Value& other); Value& operator=(const Value& other);
Value& operator=(Value&& other); Value& operator=(Value&& other) noexcept;
/// Swap everything. /// Swap everything.
void swap(Value& other); void swap(Value& other);
@ -635,9 +635,9 @@ private:
public: public:
Comments() = default; Comments() = default;
Comments(const Comments& that); Comments(const Comments& that);
Comments(Comments&& that); Comments(Comments&& that) noexcept;
Comments& operator=(const Comments& that); Comments& operator=(const Comments& that);
Comments& operator=(Comments&& that); Comments& operator=(Comments&& that) noexcept;
bool has(CommentPlacement slot) const; bool has(CommentPlacement slot) const;
String get(CommentPlacement slot) const; String get(CommentPlacement slot) const;
void set(CommentPlacement slot, String comment); void set(CommentPlacement slot, String comment);

0
reformat.sh Normal file → Executable file
View File

View File

@ -1921,7 +1921,7 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const {
if (valid_keys.count(key)) if (valid_keys.count(key))
continue; continue;
if (invalid) if (invalid)
(*invalid)[std::move(key)] = *si; (*invalid)[key] = *si;
else else
return false; return false;
} }

View File

@ -259,7 +259,7 @@ Value::CZString::CZString(const CZString& other) {
storage_.length_ = other.storage_.length_; storage_.length_ = other.storage_.length_;
} }
Value::CZString::CZString(CZString&& other) Value::CZString::CZString(CZString&& other) noexcept
: cstr_(other.cstr_), index_(other.index_) { : cstr_(other.cstr_), index_(other.index_) {
other.cstr_ = nullptr; other.cstr_ = nullptr;
} }
@ -285,7 +285,7 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
return *this; return *this;
} }
Value::CZString& Value::CZString::operator=(CZString&& other) { Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
cstr_ = other.cstr_; cstr_ = other.cstr_;
index_ = other.index_; index_ = other.index_;
other.cstr_ = nullptr; other.cstr_ = nullptr;
@ -433,7 +433,7 @@ Value::Value(const Value& other) {
dupMeta(other); dupMeta(other);
} }
Value::Value(Value&& other) { Value::Value(Value&& other) noexcept {
initBasic(nullValue); initBasic(nullValue);
swap(other); swap(other);
} }
@ -448,7 +448,7 @@ Value& Value::operator=(const Value& other) {
return *this; return *this;
} }
Value& Value::operator=(Value&& other) { Value& Value::operator=(Value&& other) noexcept {
other.swap(*this); other.swap(*this);
return *this; return *this;
} }
@ -1373,14 +1373,15 @@ bool Value::isObject() const { return type() == objectValue; }
Value::Comments::Comments(const Comments& that) Value::Comments::Comments(const Comments& that)
: ptr_{cloneUnique(that.ptr_)} {} : ptr_{cloneUnique(that.ptr_)} {}
Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {} Value::Comments::Comments(Comments&& that) noexcept
: ptr_{std::move(that.ptr_)} {}
Value::Comments& Value::Comments::operator=(const Comments& that) { Value::Comments& Value::Comments::operator=(const Comments& that) {
ptr_ = cloneUnique(that.ptr_); ptr_ = cloneUnique(that.ptr_);
return *this; return *this;
} }
Value::Comments& Value::Comments::operator=(Comments&& that) { Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
ptr_ = std::move(that.ptr_); ptr_ = std::move(that.ptr_);
return *this; return *this;
} }

View File

@ -1217,7 +1217,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
if (valid_keys.count(key)) if (valid_keys.count(key))
continue; continue;
if (invalid) if (invalid)
(*invalid)[std::move(key)] = *si; (*invalid)[key] = *si;
else else
return false; return false;
} }