From 9f2781b5271b725f003c204d48d008b043a004d5 Mon Sep 17 00:00:00 2001 From: Ian Taylor Date: Wed, 29 Apr 2020 10:40:33 -0400 Subject: [PATCH] Fix clang format (#854) Fix invocation of clang-format in CMakeLists and apply clang-format. --- CMakeLists.txt | 1 + src/binary.cpp | 2 +- src/contrib/graphbuilder.cpp | 2 +- src/contrib/graphbuilderadapter.cpp | 2 +- src/depthguard.cpp | 9 ++++----- src/emit.cpp | 2 +- src/exceptions.cpp | 2 +- src/memory.cpp | 4 ++-- src/node.cpp | 2 +- src/null.cpp | 2 +- src/parse.cpp | 6 +++--- src/parser.cpp | 4 +--- src/scanscalar.cpp | 2 +- src/scantag.cpp | 2 +- src/simplekey.cpp | 8 ++++++-- src/stream.cpp | 5 +++-- 16 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f477c05..d1d2ce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,6 +156,7 @@ endif() if (YAML_CPP_CLANG_FORMAT_EXE) add_custom_target(format COMMAND clang-format --style=file -i $ + COMMAND_EXPAND_LISTS COMMENT "Running clang-format" VERBATIM) endif() diff --git a/src/binary.cpp b/src/binary.cpp index 306ed0e..4311a2d 100644 --- a/src/binary.cpp +++ b/src/binary.cpp @@ -97,4 +97,4 @@ std::vector DecodeBase64(const std::string &input) { ret.resize(out - &ret[0]); return ret; } -} +} // namespace YAML diff --git a/src/contrib/graphbuilder.cpp b/src/contrib/graphbuilder.cpp index bf25162..7032dc4 100644 --- a/src/contrib/graphbuilder.cpp +++ b/src/contrib/graphbuilder.cpp @@ -14,4 +14,4 @@ void* BuildGraphOfNextDocument(Parser& parser, return nullptr; } } -} +} // namespace YAML diff --git a/src/contrib/graphbuilderadapter.cpp b/src/contrib/graphbuilderadapter.cpp index b9e0b65..c386a92 100644 --- a/src/contrib/graphbuilderadapter.cpp +++ b/src/contrib/graphbuilderadapter.cpp @@ -91,4 +91,4 @@ void GraphBuilderAdapter::DispositionNode(void *pNode) { m_builder.AppendToSequence(pContainer, pNode); } } -} +} // namespace YAML diff --git a/src/depthguard.cpp b/src/depthguard.cpp index b88cd34..5bf6cdf 100644 --- a/src/depthguard.cpp +++ b/src/depthguard.cpp @@ -2,9 +2,8 @@ namespace YAML { -DeepRecursion::DeepRecursion(int depth, const Mark& mark_, const std::string& msg_) - : ParserException(mark_, msg_), - m_depth(depth) { -} +DeepRecursion::DeepRecursion(int depth, const Mark& mark_, + const std::string& msg_) + : ParserException(mark_, msg_), m_depth(depth) {} -} // namespace YAML +} // namespace YAML diff --git a/src/emit.cpp b/src/emit.cpp index 51bc791..b0efb84 100644 --- a/src/emit.cpp +++ b/src/emit.cpp @@ -1,7 +1,7 @@ #include "yaml-cpp/node/emit.h" +#include "nodeevents.h" #include "yaml-cpp/emitfromevents.h" #include "yaml-cpp/emitter.h" -#include "nodeevents.h" namespace YAML { Emitter& operator<<(Emitter& out, const Node& node) { diff --git a/src/exceptions.cpp b/src/exceptions.cpp index a6cc202..43a7976 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -17,4 +17,4 @@ BadPushback::~BadPushback() YAML_CPP_NOEXCEPT = default; BadInsert::~BadInsert() YAML_CPP_NOEXCEPT = default; EmitterException::~EmitterException() YAML_CPP_NOEXCEPT = default; BadFile::~BadFile() YAML_CPP_NOEXCEPT = default; -} +} // namespace YAML diff --git a/src/memory.cpp b/src/memory.cpp index e5f8a9d..676e4c7 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -22,5 +22,5 @@ node& memory::create_node() { void memory::merge(const memory& rhs) { m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end()); } -} -} +} // namespace detail +} // namespace YAML diff --git a/src/node.cpp b/src/node.cpp index 2088e13..badc311 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -9,4 +9,4 @@ Node Clone(const Node& node) { events.Emit(builder); return builder.Root(); } -} +} // namespace YAML diff --git a/src/null.cpp b/src/null.cpp index d12dd08..db7daeb 100644 --- a/src/null.cpp +++ b/src/null.cpp @@ -7,4 +7,4 @@ bool IsNullString(const std::string& str) { return str.empty() || str == "~" || str == "null" || str == "Null" || str == "NULL"; } -} +} // namespace YAML diff --git a/src/parse.cpp b/src/parse.cpp index 0b2ae4a..597404d 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -3,10 +3,10 @@ #include #include -#include "yaml-cpp/node/node.h" -#include "yaml-cpp/node/impl.h" -#include "yaml-cpp/parser.h" #include "nodebuilder.h" +#include "yaml-cpp/node/impl.h" +#include "yaml-cpp/node/node.h" +#include "yaml-cpp/parser.h" namespace YAML { Node Load(const std::string& input) { diff --git a/src/parser.cpp b/src/parser.cpp index 9d315e0..b8b78eb 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -17,9 +17,7 @@ Parser::Parser(std::istream& in) : Parser() { Load(in); } Parser::~Parser() = default; -Parser::operator bool() const { - return m_pScanner && !m_pScanner->empty(); -} +Parser::operator bool() const { return m_pScanner && !m_pScanner->empty(); } void Parser::Load(std::istream& in) { m_pScanner.reset(new Scanner(in)); diff --git a/src/scanscalar.cpp b/src/scanscalar.cpp index e5b0973..c97d136 100644 --- a/src/scanscalar.cpp +++ b/src/scanscalar.cpp @@ -247,4 +247,4 @@ std::string ScanScalar(Stream& INPUT, ScanScalarParams& params) { return scalar; } -} +} // namespace YAML diff --git a/src/scantag.cpp b/src/scantag.cpp index c5b3965..176cc5c 100644 --- a/src/scantag.cpp +++ b/src/scantag.cpp @@ -78,4 +78,4 @@ const std::string ScanTagSuffix(Stream& INPUT) { return tag; } -} +} // namespace YAML diff --git a/src/simplekey.cpp b/src/simplekey.cpp index c7a2135..67c2d71 100644 --- a/src/simplekey.cpp +++ b/src/simplekey.cpp @@ -5,7 +5,11 @@ namespace YAML { struct Mark; Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_) - : mark(mark_), flowLevel(flowLevel_), pIndent(nullptr), pMapStart(nullptr), pKey(nullptr) {} + : mark(mark_), + flowLevel(flowLevel_), + pIndent(nullptr), + pMapStart(nullptr), + pKey(nullptr) {} void Scanner::SimpleKey::Validate() { // Note: pIndent will *not* be garbage here; @@ -125,4 +129,4 @@ void Scanner::PopAllSimpleKeys() { while (!m_simpleKeys.empty()) m_simpleKeys.pop(); } -} +} // namespace YAML diff --git a/src/stream.cpp b/src/stream.cpp index e1ff265..8fa6ab7 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -151,7 +151,8 @@ inline UtfIntroCharType IntroCharTypeOf(std::istream::int_type ch) { inline char Utf8Adjust(unsigned long ch, unsigned char lead_bits, unsigned char rshift) { - const unsigned char header = static_cast(((1 << lead_bits) - 1) << (8 - lead_bits)); + const unsigned char header = + static_cast(((1 << lead_bits) - 1) << (8 - lead_bits)); const unsigned char mask = (0xFF >> (lead_bits + 1)); return static_cast( static_cast(header | ((ch >> rshift) & mask))); @@ -273,7 +274,7 @@ char Stream::get() { // . Extracts 'n' characters from the stream and updates our position std::string Stream::get(int n) { std::string ret; - if(n > 0) { + if (n > 0) { ret.reserve(static_cast(n)); for (int i = 0; i < n; i++) ret += get();