Skip to content

clang-tidy: use = default and default member init #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/dom_update_namespace/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class Tests
{
public:
virtual ~Tests() {}
virtual ~Tests() = default;

protected:
template<typename RefType, typename ValueType>
Expand All @@ -45,7 +45,7 @@ class fail_exception : public std::exception
{
public:
explicit fail_exception(const std::string& msg) : msg_(msg) {}
~fail_exception() noexcept override {}
~fail_exception() noexcept override = default;
const char* what() const noexcept override { return msg_.c_str(); }

private:
Expand All @@ -67,13 +67,11 @@ class TestNamespace : public Tests

xmlpp::Node::PrefixNsMap nsmap_;
xmlpp::DomParser parser_;
xmlpp::Element* root_;
xmlpp::Element *root_{nullptr};
};


TestNamespace::TestNamespace()
:
root_(nullptr)

{
nsmap_["ns0"] = "http://default.namespace/root";
nsmap_["ns1"] = "http://default.namespace/child";
Expand Down
8 changes: 2 additions & 6 deletions examples/sax_exception/myparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ xmlpp::exception* MyException::clone() const
* MySaxParser implementation
*/

MySaxParser::MySaxParser()
{
}
MySaxParser::MySaxParser() = default;

MySaxParser::~MySaxParser()
{
}
MySaxParser::~MySaxParser() = default;

void MySaxParser::on_start_document()
{
Expand Down
4 changes: 1 addition & 3 deletions examples/sax_parser/myparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ MySaxParser::MySaxParser()
{
}

MySaxParser::~MySaxParser()
{
}
MySaxParser::~MySaxParser() = default;

void MySaxParser::on_start_document()
{
Expand Down
3 changes: 1 addition & 2 deletions examples/sax_parser_build_dom/svgelement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Element::Element(xmlNode* node)
: xmlpp::Element(node)
{}

Element::~Element()
{}
Element::~Element() = default;

// example custom methods
void Element::set_style(const xmlpp::ustring& style)
Expand Down
4 changes: 1 addition & 3 deletions examples/sax_parser_build_dom/svgparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ Parser::Parser(xmlpp::Document& document)
set_substitute_entities(true);
}

Parser::~Parser()
{
}
Parser::~Parser() = default;

void Parser::on_start_element(const xmlpp::ustring& name,
const AttributeList& attributes)
Expand Down
4 changes: 1 addition & 3 deletions examples/sax_parser_entities/myparser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ MySaxParser::MySaxParser()
{
}

MySaxParser::~MySaxParser()
{
}
MySaxParser::~MySaxParser() = default;

void MySaxParser::on_start_document()
{
Expand Down
4 changes: 1 addition & 3 deletions libxml++/attribute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Attribute::Attribute(xmlNode* node)
{
}

Attribute::~Attribute()
{
}
Attribute::~Attribute() = default;

} //namespace xmlpp
4 changes: 1 addition & 3 deletions libxml++/attributedeclaration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ AttributeDeclaration::AttributeDeclaration(xmlNode* node)
{
}

AttributeDeclaration::~AttributeDeclaration()
{
}
AttributeDeclaration::~AttributeDeclaration() = default;

ustring AttributeDeclaration::get_value() const
{
Expand Down
4 changes: 1 addition & 3 deletions libxml++/attributenode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ AttributeNode::AttributeNode(xmlNode* node)
{
}

AttributeNode::~AttributeNode()
{
}
AttributeNode::~AttributeNode() = default;

ustring AttributeNode::get_value() const
{
Expand Down
23 changes: 10 additions & 13 deletions libxml++/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,16 @@ Document::Init::Init()
xmlInitParser(); //Not always necessary, but necessary for thread safety.
}

Document::Init::~Init() noexcept
{
//We don't call this because it breaks libxml generally and should only be
//called at the very end of a process, such as at the end of a main().
//libxml might still be used by the application, so we don't want to break
//that.
//This is important even here, which usually happens only when the library
//is unloaded, because that might happen during normal application use,
//if the application does dynamic library loading, for instance to load
//plugins.
//See http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser
//xmlCleanupParser(); //As per xmlInitParser(), or memory leak will happen.
}
//We don't call this because it breaks libxml generally and should only be
//called at the very end of a process, such as at the end of a main().
//libxml might still be used by the application, so we don't want to break
//that.
//This is important even here, which usually happens only when the library
//is unloaded, because that might happen during normal application use,
//if the application does dynamic library loading, for instance to load
//plugins.
//See http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser
//xmlCleanupParser(); //As per xmlInitParser(), or memory leak will happen.

Document::Init Document::init_;

Expand Down
2 changes: 1 addition & 1 deletion libxml++/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Document : public NonCopyable
{
public:
Init();
~Init() noexcept;
~Init() noexcept = default;
};

friend LIBXMLPP_API class SaxParser;
Expand Down
6 changes: 3 additions & 3 deletions libxml++/dtd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ namespace xmlpp

struct Dtd::Impl
{
Impl() noexcept : dtd(nullptr), is_dtd_owner(false) {}
Impl() noexcept = default;

_xmlDtd* dtd;
bool is_dtd_owner;
_xmlDtd *dtd{nullptr};
bool is_dtd_owner{false};
};

Dtd::Dtd()
Expand Down
3 changes: 1 addition & 2 deletions libxml++/exceptions/exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ exception::exception(const ustring& message)
{
}

exception::~exception() noexcept
{}
exception::~exception() noexcept = default;

const char* exception::what() const noexcept
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/exceptions/internal_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ internal_error::internal_error(const ustring& message)
{
}

internal_error::~internal_error() noexcept
{}
internal_error::~internal_error() noexcept = default;

void internal_error::raise() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/exceptions/parse_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ parse_error::parse_error(const ustring& message)
{
}

parse_error::~parse_error() noexcept
{}
parse_error::~parse_error() noexcept = default;

void parse_error::raise() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/exceptions/validity_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ validity_error::validity_error(const ustring& message)
{
}

validity_error::~validity_error() noexcept
{}
validity_error::~validity_error() noexcept = default;

void validity_error::raise() const
{
Expand Down
4 changes: 1 addition & 3 deletions libxml++/exceptions/wrapped_exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ wrapped_exception::wrapped_exception(std::exception_ptr exception_ptr)
{
}

wrapped_exception::~wrapped_exception() noexcept
{
}
wrapped_exception::~wrapped_exception() noexcept = default;

void wrapped_exception::raise() const
{
Expand Down
4 changes: 1 addition & 3 deletions libxml++/io/istreamparserinputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace xmlpp
{
}

IStreamParserInputBuffer::~IStreamParserInputBuffer()
{
}
IStreamParserInputBuffer::~IStreamParserInputBuffer() = default;

int IStreamParserInputBuffer::do_read(
char * buffer,
Expand Down
4 changes: 1 addition & 3 deletions libxml++/io/ostreamoutputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ namespace xmlpp
{
}

OStreamOutputBuffer::~OStreamOutputBuffer()
{
}
OStreamOutputBuffer::~OStreamOutputBuffer() = default;

bool OStreamOutputBuffer::do_write(
const char * buffer,
Expand Down
4 changes: 1 addition & 3 deletions libxml++/io/outputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ namespace xmlpp
}
}

OutputBuffer::~OutputBuffer()
{
}
OutputBuffer::~OutputBuffer() = default;

bool OutputBuffer::on_close()
{
Expand Down
4 changes: 1 addition & 3 deletions libxml++/io/parserinputbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ namespace xmlpp
}
}

ParserInputBuffer::~ParserInputBuffer()
{
}
ParserInputBuffer::~ParserInputBuffer() = default;

bool ParserInputBuffer::on_close()
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/cdatanode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ CdataNode::CdataNode(xmlNode* node)
: ContentNode(node)
{}

CdataNode::~CdataNode()
{}
CdataNode::~CdataNode() = default;

} //namespace xmlpp
3 changes: 1 addition & 2 deletions libxml++/nodes/commentnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ CommentNode::CommentNode(xmlNode* node)
: ContentNode(node)
{}

CommentNode::~CommentNode()
{}
CommentNode::~CommentNode() = default;

} //namespace xmlpp

3 changes: 1 addition & 2 deletions libxml++/nodes/contentnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ ContentNode::ContentNode(xmlNode* node)
: Node(node)
{}

ContentNode::~ContentNode()
{}
ContentNode::~ContentNode() = default;

ustring ContentNode::get_content() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ Element::Element(xmlNode* node)
: Node(node)
{}

Element::~Element()
{}
Element::~Element() = default;

Element::AttributeList Element::get_attributes()
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/entitydeclaration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ EntityDeclaration::EntityDeclaration(xmlNode* node)
: ContentNode(node)
{}

EntityDeclaration::~EntityDeclaration()
{}
EntityDeclaration::~EntityDeclaration() = default;

ustring EntityDeclaration::get_resolved_text() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/entityreference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ EntityReference::EntityReference(xmlNode* node)
: Node(node)
{}

EntityReference::~EntityReference()
{}
EntityReference::~EntityReference() = default;

ustring EntityReference::get_resolved_text() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ Node::Node(xmlNode* node)
impl_->_private = this;
}

Node::~Node()
{}
Node::~Node() = default;

const Element* Node::get_parent() const
{
Expand Down
3 changes: 1 addition & 2 deletions libxml++/nodes/processinginstructionnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ProcessingInstructionNode::ProcessingInstructionNode(xmlNode* node)
: ContentNode(node)
{}

ProcessingInstructionNode::~ProcessingInstructionNode()
{}
ProcessingInstructionNode::~ProcessingInstructionNode() = default;

} //namespace xmlpp
3 changes: 1 addition & 2 deletions libxml++/nodes/textnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ TextNode::TextNode(xmlNode* node)
: ContentNode(node)
{}

TextNode::~TextNode()
{}
TextNode::~TextNode() = default;

} //namespace xmlpp
3 changes: 1 addition & 2 deletions libxml++/nodes/xincludeend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ XIncludeEnd::XIncludeEnd(xmlNode* node)
: Node(node)
{}

XIncludeEnd::~XIncludeEnd()
{}
XIncludeEnd::~XIncludeEnd() = default;

} //namespace xmlpp
3 changes: 1 addition & 2 deletions libxml++/nodes/xincludestart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ XIncludeStart::XIncludeStart(xmlNode* node)
: Node(node)
{}

XIncludeStart::~XIncludeStart()
{}
XIncludeStart::~XIncludeStart() = default;

} //namespace xmlpp
8 changes: 2 additions & 6 deletions libxml++/noncopyable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
namespace xmlpp
{

NonCopyable::NonCopyable() noexcept
{
}
NonCopyable::NonCopyable() noexcept = default;

NonCopyable::~NonCopyable()
{
}
NonCopyable::~NonCopyable() = default;

} //namespace xmlpp
Loading