From 65fadc6003259719161be650d2ede16c30e0bb3b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 15 Apr 2022 10:03:36 +0200 Subject: Get rid of target::dynamic_type() virtual function Instead of overriding this function, derived targets must now set the dynamic_type variable to their static_type in their constructor body. --- libbuild2/bash/target.hxx | 7 +- libbuild2/bin/rule.cxx | 2 +- libbuild2/bin/target.hxx | 182 +++++++++++++++++++++++++++++++++------------- libbuild2/cc/target.hxx | 42 ++++++++--- libbuild2/cxx/target.hxx | 35 ++++++--- libbuild2/in/target.hxx | 7 +- libbuild2/target.hxx | 120 +++++++++++++++++++++--------- libbuild2/target.ixx | 15 ++-- libbuild2/test/target.hxx | 7 +- 9 files changed, 291 insertions(+), 126 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/bash/target.hxx b/libbuild2/bash/target.hxx index f0af967..ad926bd 100644 --- a/libbuild2/bash/target.hxx +++ b/libbuild2/bash/target.hxx @@ -21,11 +21,14 @@ namespace build2 class LIBBUILD2_BASH_SYMEXPORT bash: public file { public: - using file::file; + bash (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } diff --git a/libbuild2/bin/rule.cxx b/libbuild2/bin/rule.cxx index 85cc9de..38a3d98 100644 --- a/libbuild2/bin/rule.cxx +++ b/libbuild2/bin/rule.cxx @@ -22,7 +22,7 @@ namespace build2 bool obj_rule:: match (action a, target& t) const { - const char* n (t.dynamic_type ().name); // Ignore derived type. + const char* n (t.dynamic_type->name); // Ignore derived type. fail << diag_doing (a, t) << " target group" << info << "explicitly select " << n << "e{}, " << n << "a{}, or " diff --git a/libbuild2/bin/target.hxx b/libbuild2/bin/target.hxx index f8d2dd0..89e0f17 100644 --- a/libbuild2/bin/target.hxx +++ b/libbuild2/bin/target.hxx @@ -22,7 +22,11 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT objx: public file { public: - using file::file; + objx (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; @@ -31,41 +35,53 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT obje: public objx { public: - using objx::objx; + obje (context& c, dir_path d, dir_path o, string n) + : objx (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT obja: public objx { public: - using objx::objx; + obja (context& c, dir_path d, dir_path o, string n) + : objx (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT objs: public objx { public: - using objx::objx; + objs (context& c, dir_path d, dir_path o, string n) + : objx (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT obj: public target { public: - using target::target; + obj (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Binary module interface (BMI). @@ -100,7 +116,11 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT bmix: public file { public: - using file::file; + bmix (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; @@ -111,7 +131,11 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT hbmix: public bmix { public: - using bmix::bmix; + hbmix (context& c, dir_path d, dir_path o, string n) + : bmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; @@ -120,84 +144,107 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT bmie: public bmix { public: - using bmix::bmix; + bmie (context& c, dir_path d, dir_path o, string n) + : bmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT hbmie: public hbmix { public: - using hbmix::hbmix; + hbmie (context& c, dir_path d, dir_path o, string n) + : hbmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT bmia: public bmix { public: - using bmix::bmix; + bmia (context& c, dir_path d, dir_path o, string n) + : bmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT hbmia: public hbmix { public: - using hbmix::hbmix; + hbmia (context& c, dir_path d, dir_path o, string n) + : hbmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT bmis: public bmix { public: - using bmix::bmix; + bmis (context& c, dir_path d, dir_path o, string n) + : bmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT hbmis: public hbmix { public: - using hbmix::hbmix; + hbmis (context& c, dir_path d, dir_path o, string n) + : hbmix (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT bmi: public target { public: - using target::target; + bmi (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT hbmi: public target { public: - using target::target; + hbmi (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; - // Common base for lib{} and libul{} groups. // // Use mtime_target as a base for the "trust me it exists" functionality @@ -207,7 +254,11 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT libx: public mtime_target { public: - using mtime_target::mtime_target; + libx (context& c, dir_path d, dir_path o, string n) + : mtime_target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; @@ -240,7 +291,11 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT libux: public file { public: - using file::file; + libux (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; @@ -249,41 +304,53 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT libue: public libux { public: - using libux::libux; + libue (context& c, dir_path d, dir_path o, string n) + : libux (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT libua: public libux { public: - using libux::libux; + libua (context& c, dir_path d, dir_path o, string n) + : libux (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT libus: public libux { public: - using libux::libux; + libus (context& c, dir_path d, dir_path o, string n) + : libux (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT libul: public libx { public: - using libx::libx; + libul (context& c, dir_path d, dir_path o, string n) + : libx (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // The lib{} target group. @@ -291,23 +358,27 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT liba: public file { public: - using file::file; + liba (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_BIN_SYMEXPORT libs: public file { public: - using file::file; + libs (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - - virtual const target_type& - dynamic_type () const override {return static_type;} }; // Standard layout type compatible with group_view's const target*[2]. @@ -321,16 +392,17 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT lib: public libx, public lib_members { public: - using libx::libx; + lib (context& c, dir_path d, dir_path o, string n) + : libx (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } virtual group_view group_members (action) const override; public: static const target_type static_type; - - virtual const target_type& - dynamic_type () const override {return static_type;} }; // Windows import library. @@ -338,11 +410,14 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT libi: public file { public: - using file::file; + libi (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Windows module definition (.def). @@ -350,11 +425,14 @@ namespace build2 class LIBBUILD2_BIN_SYMEXPORT def: public file { public: - using file::file; + def (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } diff --git a/libbuild2/cc/target.hxx b/libbuild2/cc/target.hxx index 7067421..fbac790 100644 --- a/libbuild2/cc/target.hxx +++ b/libbuild2/cc/target.hxx @@ -23,11 +23,14 @@ namespace build2 class LIBBUILD2_CC_SYMEXPORT cc: public file { public: - using file::file; + cc (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const = 0; }; // There is hardly a c-family compilation without a C header inclusion. @@ -36,11 +39,14 @@ namespace build2 class LIBBUILD2_CC_SYMEXPORT h: public cc { public: - using cc::cc; + h (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // This one we define in cc but the target type is only registered by the @@ -52,11 +58,14 @@ namespace build2 class LIBBUILD2_CC_SYMEXPORT c: public cc { public: - using cc::cc; + c (context& ctx, dir_path d, dir_path o, string n) + : cc (ctx, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // pkg-config file targets. @@ -64,31 +73,40 @@ namespace build2 class LIBBUILD2_CC_SYMEXPORT pc: public file // .pc (common) { public: - using file::file; + pc (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_CC_SYMEXPORT pca: public pc // .static.pc { public: - using pc::pc; + pca (context& c, dir_path d, dir_path o, string n) + : pc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_CC_SYMEXPORT pcs: public pc // .shared.pc { public: - using pc::pc; + pcs (context& c, dir_path d, dir_path o, string n) + : pc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } diff --git a/libbuild2/cxx/target.hxx b/libbuild2/cxx/target.hxx index cddab68..b20bf00 100644 --- a/libbuild2/cxx/target.hxx +++ b/libbuild2/cxx/target.hxx @@ -22,41 +22,53 @@ namespace build2 class LIBBUILD2_CXX_SYMEXPORT hxx: public cc::cc { public: - using cc::cc; + hxx (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_CXX_SYMEXPORT ixx: public cc::cc { public: - using cc::cc; + ixx (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_CXX_SYMEXPORT txx: public cc::cc { public: - using cc::cc; + txx (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_CXX_SYMEXPORT cxx: public cc::cc { public: - using cc::cc; + cxx (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // The module interface unit is both like a header (e.g., we need to @@ -67,11 +79,14 @@ namespace build2 class LIBBUILD2_CXX_SYMEXPORT mxx: public cc::cc { public: - using cc::cc; + mxx (context& c, dir_path d, dir_path o, string n) + : cc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } diff --git a/libbuild2/in/target.hxx b/libbuild2/in/target.hxx index 20a0c44..619c06e 100644 --- a/libbuild2/in/target.hxx +++ b/libbuild2/in/target.hxx @@ -35,11 +35,14 @@ namespace build2 class LIBBUILD2_IN_SYMEXPORT in: public file { public: - using file::file; + in (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index d3e88dd..e6622f4 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -870,7 +870,7 @@ namespace build2 #else // We can skip dynamically-derived type here (derived_type). // - return dynamic_type ().is_a () ? static_cast (this) : nullptr; + return dynamic_type->is_a () ? static_cast (this) : nullptr; #endif } @@ -881,7 +881,7 @@ namespace build2 #if 0 return dynamic_cast (this); #else - return dynamic_type ().is_a () ? static_cast (this) : nullptr; + return dynamic_type->is_a () ? static_cast (this) : nullptr; #endif } @@ -901,18 +901,23 @@ namespace build2 const T& as () const {return static_cast (*this);} - // Dynamic derivation to support define. + // Target type information. + // + // A derived target is expected to set dynamic_type to its static_type in + // its constructor body. + // + // We also have dynamic "derivation" support (e.g., via define in + // buildfile). // - const target_type* derived_type = nullptr; - const target_type& type () const { - return derived_type != nullptr ? *derived_type : dynamic_type (); + return derived_type != nullptr ? *derived_type : *dynamic_type; } static const target_type static_type; - virtual const target_type& dynamic_type () const = 0; + const target_type* dynamic_type; + const target_type* derived_type = nullptr; // RW access. // @@ -941,13 +946,19 @@ namespace build2 // Targets should be created via the targets set below. // - public: + protected: + friend class target_set; + target (context& c, dir_path d, dir_path o, string n) : ctx (c), dir (move (d)), out (move (o)), name (move (n)), vars (c, false /* global */), - state (c) {} + state (c) + { + dynamic_type = &static_type; + } + public: target (target&&) = delete; target& operator= (target&&) = delete; @@ -956,8 +967,6 @@ namespace build2 virtual ~target (); - - friend class target_set; }; // All targets are from the targets set below. @@ -1635,7 +1644,11 @@ namespace build2 class LIBBUILD2_SYMEXPORT mtime_target: public target { public: - using target::target; + mtime_target (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } // Modification time is an "atomic cash". That is, it can be set at any // time (including on a const instance) and we assume everything will be @@ -1722,7 +1735,11 @@ namespace build2 class LIBBUILD2_SYMEXPORT path_target: public mtime_target { public: - using mtime_target::mtime_target; + path_target (context& c, dir_path d, dir_path o, string n) + : mtime_target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } using path_type = build2::path; @@ -1871,11 +1888,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT file: public path_target { public: - using path_target::path_target; + file (context& c, dir_path d, dir_path o, string n) + : path_target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Alias target. It represents a list of targets (its prerequisites) @@ -1884,11 +1904,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT alias: public target { public: - using target::target; + alias (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Directory target. Note that this is not a filesystem directory @@ -1898,11 +1921,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT dir: public alias { public: - using alias::alias; + dir (context& c, dir_path d, dir_path o, string n) + : alias (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} public: template @@ -1931,11 +1957,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT fsdir: public target { public: - using target::target; + fsdir (context& c, dir_path d, dir_path o, string n) + : target (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Executable file (not necessarily binary, though we do fallback to the @@ -1945,7 +1974,11 @@ namespace build2 class LIBBUILD2_SYMEXPORT exe: public file { public: - using file::file; + exe (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } using process_path_type = build2::process_path; @@ -1973,7 +2006,6 @@ namespace build2 public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} private: process_path_type process_path_; @@ -1982,11 +2014,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT buildfile: public file { public: - using file::file; + buildfile (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Common documentation file target. @@ -1994,11 +2029,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT doc: public file { public: - using file::file; + doc (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Legal files (LICENSE, AUTHORS, COPYRIGHT, etc). @@ -2006,11 +2044,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT legal: public doc { public: - using doc::doc; + legal (context& c, dir_path d, dir_path o, string n) + : doc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // The problem with man pages is this: different platforms have @@ -2050,21 +2091,27 @@ namespace build2 class LIBBUILD2_SYMEXPORT man: public doc { public: - using doc::doc; + man (context& c, dir_path d, dir_path o, string n) + : doc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; class LIBBUILD2_SYMEXPORT man1: public man { public: - using man::man; + man1 (context& c, dir_path d, dir_path o, string n) + : man (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // We derive manifest from doc rather than file so that it get automatically @@ -2075,11 +2122,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT manifest: public doc { public: - using doc::doc; + manifest (context& c, dir_path d, dir_path o, string n) + : doc (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; // Common implementation of the target factory, extension, and search diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx index ecc16c4..79cc07c 100644 --- a/libbuild2/target.ixx +++ b/libbuild2/target.ixx @@ -99,7 +99,7 @@ namespace build2 { using flag = target_type::flag; - const target_type* tt (nullptr); // Resolve lazily. + const target_type& tt (type ()); // First check the target itself. // @@ -108,10 +108,9 @@ namespace build2 // If this is a group that "gave" its untyped hints to the members, then // ignore untyped entries. // - tt = &type (); - bool ut ((tt->flags & flag::member_hint) != flag::member_hint); + bool ut ((tt.flags & flag::member_hint) != flag::member_hint); - const string& r (rule_hints.find (*tt, o, ut)); + const string& r (rule_hints.find (tt, o, ut)); if (!r.empty ()) return r; } @@ -125,13 +124,9 @@ namespace build2 // If the group "gave" its untyped hints to the members, then don't // ignore untyped entries. // - const target_type& gt (g->type ()); - bool ut ((gt.flags & flag::member_hint) == flag::member_hint); + bool ut ((g->type ().flags & flag::member_hint) == flag::member_hint); - if (tt == nullptr) - tt = &type (); - - return g->rule_hints.find (*tt, o, ut); + return g->rule_hints.find (tt, o, ut); } } diff --git a/libbuild2/test/target.hxx b/libbuild2/test/target.hxx index 1dd7307..e6c549f 100644 --- a/libbuild2/test/target.hxx +++ b/libbuild2/test/target.hxx @@ -18,11 +18,14 @@ namespace build2 class LIBBUILD2_SYMEXPORT testscript: public file { public: - using file::file; + testscript (context& c, dir_path d, dir_path o, string n) + : file (c, move (d), move (o), move (n)) + { + dynamic_type = &static_type; + } public: static const target_type static_type; - virtual const target_type& dynamic_type () const {return static_type;} }; } } -- cgit v1.1