From 6c1ea91ca421a1b899af091043abdb58c2ed57e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Feb 2022 07:10:09 +0200 Subject: Use target::as instead of static_cast everywhere --- libbuild2/cc/compile-rule.cxx | 10 +++++----- libbuild2/in/rule.cxx | 4 ++-- libbuild2/version/rule.cxx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 77d01c6..aaaa43c 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -2582,7 +2582,7 @@ namespace build2 if (ht != pts.back ()) { - ht = static_cast (pts.back ().target); + ht = &pts.back ().target->as (); rs = "ERROR expected header '" + ht->path ().string () + "' to be found instead"; bad_error = true; // We expect an error from the compiler. @@ -5672,7 +5672,7 @@ namespace build2 // Hash (we know it's a file). // - cs.append (static_cast (*bt).path ().string ()); + cs.append (bt->as ().path ().string ()); // Copy over bmi{}s from our prerequisites weeding out duplicates. // @@ -5698,7 +5698,7 @@ namespace build2 }) == imports.end ()) { pts.push_back (et); - cs.append (static_cast (*et).path ().string ()); + cs.append (et->as ().path ().string ()); // Add to the list of imports for further duplicate suppression. // We could have stored reference to the name (e.g., in score) @@ -5907,7 +5907,7 @@ namespace build2 nullopt, // Use default extension. target_decl::implied, trace)); - file& bt (static_cast (p.first)); + file& bt (p.first.as ()); // Note that this is racy and someone might have created this target // while we were preparing the prerequisite list. @@ -6142,7 +6142,7 @@ namespace build2 nullopt, // Use default extension. target_decl::implied, trace)); - file& bt (static_cast (p.first)); + file& bt (p.first.as ()); // Note that this is racy and someone might have created this target // while we were preparing the prerequisite list. diff --git a/libbuild2/in/rule.cxx b/libbuild2/in/rule.cxx index 2117b0e..dd39485 100644 --- a/libbuild2/in/rule.cxx +++ b/libbuild2/in/rule.cxx @@ -30,7 +30,7 @@ namespace build2 if (!xt.is_a ()) // See module init() for details. return false; - file& t (static_cast (xt)); + file& t (xt.as ()); bool fi (false); // Found in. for (prerequisite_member p: group_prerequisite_members (a, t)) @@ -53,7 +53,7 @@ namespace build2 recipe rule:: apply (action a, target& xt) const { - file& t (static_cast (xt)); + file& t (xt.as ()); // Derive the file name. // diff --git a/libbuild2/version/rule.cxx b/libbuild2/version/rule.cxx index 4da4e3f..3da69cc 100644 --- a/libbuild2/version/rule.cxx +++ b/libbuild2/version/rule.cxx @@ -51,7 +51,7 @@ namespace build2 { tracer trace ("version::in_rule::match"); - file& t (static_cast (xt)); + file& t (xt.as ()); const scope& rs (t.root_scope ()); bool fm (false); // Found manifest. -- cgit v1.1