From 06e962f263a86c4b66e1c6195b3d2615695fea1e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 21 Feb 2018 11:52:59 +0100 Subject: init variables where they are declared when possible (clang-tidy) clang-tidy -p compile_commands.json $file -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' -header-filter='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing --- src/qml/parser/qqmljsast_p.h | 11 +++++------ src/qml/parser/qqmljsengine_p.h | 5 ++--- src/qml/parser/qqmljsmemorypool_p.h | 18 ++++++------------ 3 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src/qml/parser') diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index acbd88d466..ed3c83badf 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -224,8 +224,7 @@ public: Kind_UiEnumMemberList }; - inline Node() - : kind(Kind_Undefined) {} + inline Node() {} // NOTE: node destructors are never called, // instead we block free the memory @@ -248,7 +247,7 @@ public: virtual SourceLocation lastSourceLocation() const = 0; // attributes - int kind; + int kind = Kind_Undefined; }; class QML_PARSER_EXPORT ExpressionNode: public Node @@ -489,8 +488,8 @@ class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode public: QQMLJS_DECLARE_AST_NODE(ObjectLiteral) - ObjectLiteral(): - properties (nullptr) { kind = K; } + ObjectLiteral() + { kind = K; } ObjectLiteral(PropertyAssignmentList *plist): properties (plist) { kind = K; } @@ -504,7 +503,7 @@ public: { return rbraceToken; } // attributes - PropertyAssignmentList *properties; + PropertyAssignmentList *properties = nullptr; SourceLocation lbraceToken; SourceLocation rbraceToken; }; diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h index 8cbe69a0ba..af26bac0ff 100644 --- a/src/qml/parser/qqmljsengine_p.h +++ b/src/qml/parser/qqmljsengine_p.h @@ -71,8 +71,7 @@ class QML_PARSER_EXPORT DiagnosticMessage public: enum Kind { Warning, Error }; - DiagnosticMessage() - : kind(Error) {} + DiagnosticMessage() {} DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) : kind(kind), loc(loc), message(message) {} @@ -83,7 +82,7 @@ public: bool isError() const { return kind == Error; } - Kind kind; + Kind kind = Error; AST::SourceLocation loc; QString message; }; diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h index 5682d66f45..ef443d96bc 100644 --- a/src/qml/parser/qqmljsmemorypool_p.h +++ b/src/qml/parser/qqmljsmemorypool_p.h @@ -71,13 +71,7 @@ class QML_PARSER_EXPORT MemoryPool : public QSharedData void operator =(const MemoryPool &other); public: - MemoryPool() - : _blocks(nullptr), - _allocatedBlocks(0), - _blockCount(-1), - _ptr(nullptr), - _end(nullptr) - { } + MemoryPool() {} ~MemoryPool() { @@ -144,11 +138,11 @@ private: } private: - char **_blocks; - int _allocatedBlocks; - int _blockCount; - char *_ptr; - char *_end; + char **_blocks = nullptr; + int _allocatedBlocks = 0; + int _blockCount = -1; + char *_ptr = nullptr; + char *_end = nullptr; enum { -- cgit v1.2.3