From bcfcc38538af8bb896551c9e5730767807ad7a67 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Feb 2017 10:05:47 +0200 Subject: Tighten code that operates during both search/match and execute --- build2/cc/msvc.cxx | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'build2/cc/msvc.cxx') diff --git a/build2/cc/msvc.cxx b/build2/cc/msvc.cxx index fc2979c..86a7d38 100644 --- a/build2/cc/msvc.cxx +++ b/build2/cc/msvc.cxx @@ -225,7 +225,8 @@ namespace build2 const prerequisite_key& p, otype lt, const char* pfx, - const char* sfx) + const char* sfx, + bool exist) { // Pretty similar logic to search_library(). // @@ -267,7 +268,15 @@ namespace build2 { // Enter the target. // - T& t (targets.insert (d, dir_path (), name, e, trace)); + auto p (targets.insert (T::static_type, + d, + dir_path (), + name, + e, + true, // Implied. + trace)); + assert (!exist || !p.second); + T& t (static_cast (p.first)); if (t.path ().empty ()) t.path (move (f)); @@ -282,14 +291,15 @@ namespace build2 liba* common:: msvc_search_static (const process_path& ld, const dir_path& d, - const prerequisite_key& p) const + const prerequisite_key& p, + bool exist) const { liba* r (nullptr); - auto search = [&r, &ld, &d, &p, this] (const char* pf, const char* sf) - -> bool + auto search = [&r, &ld, &d, &p, exist, this] ( + const char* pf, const char* sf) -> bool { - r = msvc_search_library (x, ld, d, p, otype::a, pf, sf); + r = msvc_search_library (x, ld, d, p, otype::a, pf, sf, exist); return r != nullptr; }; @@ -309,20 +319,28 @@ namespace build2 libs* common:: msvc_search_shared (const process_path& ld, const dir_path& d, - const prerequisite_key& p) const + const prerequisite_key& pk, + bool exist) const { tracer trace (x, "msvc_search_shared"); libs* r (nullptr); - auto search = [&r, &ld, &d, &p, &trace, this] ( + auto search = [&r, &ld, &d, &pk, &trace, exist, this] ( const char* pf, const char* sf) -> bool { if (libi* i = - msvc_search_library (x, ld, d, p, otype::s, pf, sf)) + msvc_search_library (x, ld, d, pk, otype::s, pf, sf, exist)) { - r = &targets.insert ( - d, dir_path (), *p.tk.name, nullopt, trace); + auto p (targets.insert (libs::static_type, + d, + dir_path (), + *pk.tk.name, + nullopt, + true, // Implied. + trace)); + assert (!exist || !p.second); + r = static_cast (&p.first); if (r->member == nullptr) { -- cgit v1.1