From 623d5ceb595e68450f1d8cfce84fad8b5285f437 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 5 Dec 2020 16:18:15 -0500 Subject: [PATCH] Revert "[clang-tidy] using dynamic_cast for derived classes" This reverts commit a02754159cd8d594d431230fa87941931b8f0bbc. --- src/Hooks.cpp | 8 ++++---- src/Task.cpp | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 8db541580..997936abb 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -432,13 +432,13 @@ void Hooks::assertValidJSON ( throw 0; } - if ((dynamic_cast(root))->_data.find ("description") == (dynamic_cast(root))->_data.end ()) + if (((json::object*)root)->_data.find ("description") == ((json::object*)root)->_data.end ()) { Context::getContext ().error (format (STRING_HOOK_ERROR_NODESC, Path (script).name ())); throw 0; } - if ((dynamic_cast(root))->_data.find ("uuid") == (dynamic_cast(root))->_data.end ()) + if (((json::object*)root)->_data.find ("uuid") == ((json::object*)root)->_data.end ()) { Context::getContext ().error (format (STRING_HOOK_ERROR_NOUUID, Path (script).name ())); throw 0; @@ -486,7 +486,7 @@ void Hooks::assertSameTask ( for (auto& i : input) { - auto* root_obj = dynamic_cast(json::parse (i)); + auto* root_obj = (json::object*)json::parse (i); // If there is no UUID at all. auto u = root_obj->_data.find ("uuid"); @@ -497,7 +497,7 @@ void Hooks::assertSameTask ( throw 0; } - auto* up = dynamic_cast( u->second); + auto* up = (json::string*) u->second; auto text = up->dump (); Lexer::dequote (text); std::string json_uuid = json::decode (text); diff --git a/src/Task.cpp b/src/Task.cpp index f213a1d84..eb8a66260 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -637,7 +637,7 @@ void Task::parseJSON (const std::string& line) json::value* root = json::parse (line); if (root && root->type () == json::j_object) - parseJSON (dynamic_cast( root)); + parseJSON ((json::object*) root); delete root; } @@ -681,10 +681,10 @@ void Task::parseJSON (const json::object* root_obj) // Tags are an array of JSON strings. else if (i.first == "tags" && i.second->type() == json::j_array) { - auto* tags = dynamic_cast(i.second); + auto* tags = (json::array*)i.second; for (auto& t : tags->_data) { - auto* tag = dynamic_cast(t); + auto* tag = (json::string*)t; addTag (tag->_data); } } @@ -695,7 +695,7 @@ void Task::parseJSON (const json::object* root_obj) // removed in a later release. else if (i.first == "tags" && i.second->type() == json::j_string) { - auto* tag = dynamic_cast(i.second); + auto* tag = (json::string*)i.second; addTag (tag->_data); } @@ -704,10 +704,10 @@ void Task::parseJSON (const json::object* root_obj) // See other 2016-02-21 comments for details. else if (i.first == "depends" && i.second->type() == json::j_array) { - auto* deps = dynamic_cast(i.second); + auto* deps = (json::array*)i.second; for (auto& t : deps->_data) { - auto* dep = dynamic_cast(t); + auto* dep = (json::string*)t; addDependency (dep->_data); } } @@ -716,7 +716,7 @@ void Task::parseJSON (const json::object* root_obj) // 2016-02-21: Deprecated - see other 2016-02-21 comments for details. else if (i.first == "depends" && i.second->type() == json::j_string) { - auto* deps = dynamic_cast(i.second); + auto* deps = (json::string*)i.second; auto uuids = split (deps->_data, ','); for (const auto& uuid : uuids) @@ -749,12 +749,12 @@ void Task::parseJSON (const json::object* root_obj) { std::map annos; - auto* atts = dynamic_cast(i.second); + auto* atts = (json::array*)i.second; for (auto& annotations : atts->_data) { - auto* annotation = dynamic_cast(annotations); - json::string* when = dynamic_cast(annotation->_data["entry"]); - json::string* what = dynamic_cast(annotation->_data["description"]); + auto* annotation = (json::object*)annotations; + json::string* when = (json::string*)annotation->_data["entry"]; + json::string* what = (json::string*)annotation->_data["description"]; if (! when) throw format ("Annotation is missing an entry date: {1}", root_obj-> dump ());