From 557269660c1d9796a7cf9e911efb9262f645e359 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Nov 2016 12:10:03 +0200 Subject: Use diagnostics facility from libbutl --- build2/function.cxx | 71 ++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) (limited to 'build2/function.cxx') diff --git a/build2/function.cxx b/build2/function.cxx index 720a5c2..46dc403 100644 --- a/build2/function.cxx +++ b/build2/function.cxx @@ -177,54 +177,49 @@ namespace build2 { // No match. // - { - diag_record dr (error (loc)); + diag_record dr; + + dr << fail (loc) << "unmatched call to "; print_call (dr.os); - dr << "unmatched call to "; print_call (dr.os); + for (auto i (ip.first); i != ip.second; ++i) + dr << info << "candidate: " << i->second; - for (auto i (ip.first); i != ip.second; ++i) - dr << info << "candidate: " << i->second; + // If this is an unqualified name, then also print qualified + // functions that end with this name. But skip functions that we + // have already printed in the previous loop. + // + if (name.find ('.') == string::npos) + { + size_t n (name.size ()); - // If this is an unqualified name, then also print qualified - // functions that end with this name. But skip functions that we - // have already printed in the previous loop. - // - if (name.find ('.') == string::npos) + for (auto i (functions.begin ()); i != functions.end (); ++i) { - size_t n (name.size ()); + const string& q (i->first); + const function_overload& f (i->second); - for (auto i (functions.begin ()); i != functions.end (); ++i) + if ((f.alt_name == nullptr || f.alt_name != name) && + q.size () > n) { - const string& q (i->first); - const function_overload& f (i->second); - - if ((f.alt_name == nullptr || f.alt_name != name) && - q.size () > n) - { - size_t p (q.size () - n); - if (q[p - 1] == '.' && q.compare (p, n, name) == 0) - dr << info << "candidate: " << i->second; - } + size_t p (q.size () - n); + if (q[p - 1] == '.' && q.compare (p, n, name) == 0) + dr << info << "candidate: " << i->second; } } } - throw failed (); + dr << endf; } default: { // Ambigous match. // - { - diag_record dr (error (loc)); - - dr << "ambiguous call to "; print_call (dr.os); + diag_record dr; + dr << fail (loc) << "ambiguous call to "; print_call (dr.os); - for (auto f: r) - dr << info << "candidate: " << *f; - } + for (auto f: r) + dr << info << "candidate: " << *f; - throw failed (); + dr << endf; } } } @@ -245,16 +240,14 @@ namespace build2 } catch (const invalid_argument& e) { - { - diag_record dr (error); - dr << "invalid argument"; + diag_record dr (fail); + dr << "invalid argument"; - const char* w (e.what ()); - if (*w != '\0') - dr << ": " << w; - } + const char* w (e.what ()); + if (*w != '\0') + dr << ": " << w; - throw failed (); + dr << endf; } #if !defined(_MSC_VER) || _MSC_VER > 1900 -- cgit v1.1