From 6c543717a705fa93b4e1f2b971b066ffa39a2ab4 Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 17 Aug 2007 17:29:30 +0000 Subject: [PATCH] 2007-08-17 Frank Ch. Eigler As suggested by "Zhaolei" : * elaborate.cxx (semantic_pass_optimize[12], unresolved, invalid, mismatch): Use stringstream and print_error(semantic_error) instead of ad-hoc cerr. --- ChangeLog | 7 +++++++ elaborate.cxx | 45 ++++++++++++--------------------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index f11f2e10d..292b9bdc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-08-17 Frank Ch. Eigler + + As suggested by "Zhaolei" : + * elaborate.cxx (semantic_pass_optimize[12], + unresolved, invalid, mismatch): Use stringstream and + print_error(semantic_error) instead of ad-hoc cerr. + 2007-08-16 Frank Ch. Eigler PR 1315. diff --git a/elaborate.cxx b/elaborate.cxx index 0bd1c3eb2..eaf88b0be 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1783,10 +1783,7 @@ semantic_pass_optimize1 (systemtap_session& s) } if (s.probes.size() == 0) - { - cerr << "semantic error: no probes found." << endl; - rc = 1; - } + throw semantic_error ("no probes found"); return rc; } @@ -1810,10 +1807,7 @@ semantic_pass_optimize2 (systemtap_session& s) } if (s.probes.size() == 0) - { - cerr << "semantic error: no probes found." << endl; - rc = 1; - } + throw semantic_error ("no probes found"); return rc; } @@ -1838,7 +1832,6 @@ semantic_pass_types (systemtap_session& s) while (1) { iterations ++; - // cerr << "Type resolution, iteration " << iterations << endl; ti.num_newly_resolved = 0; ti.num_still_unresolved = 0; @@ -2729,15 +2722,12 @@ typeresolution_info::unresolved (const token* tok) if (assert_resolvability) { + stringstream msg; string nm = (current_function ? current_function->name : current_probe ? current_probe->name : "?"); - cerr << "semantic error: " + nm + " with unresolved type for "; - if (tok) - cerr << *tok; - else - cerr << "a token"; - cerr << endl; + msg << nm + " with unresolved type"; + session.print_error (semantic_error (msg.str(), tok)); } } @@ -2749,22 +2739,15 @@ typeresolution_info::invalid (const token* tok, exp_type pe) if (assert_resolvability) { + stringstream msg; string nm = (current_function ? current_function->name : current_probe ? current_probe->name : "?"); if (tok && tok->type == tok_operator) - { - cerr << "semantic error: " + nm + " uses invalid " << *tok; - } + msg << nm + " uses invalid operator"; else - { - cerr << "semantic error: " + nm + " with invalid type " << pe << " for "; - if (tok) - cerr << *tok; - else - cerr << "a token"; - } - cerr << endl; + msg << nm + " with invalid type " << pe; + session.print_error (semantic_error (msg.str(), tok)); } } @@ -2776,15 +2759,12 @@ typeresolution_info::mismatch (const token* tok, exp_type t1, exp_type t2) if (assert_resolvability) { + stringstream msg; string nm = (current_function ? current_function->name : current_probe ? current_probe->name : "?"); - cerr << "semantic error: " + nm + " with type mismatch for "; - if (tok) - cerr << *tok; - else - cerr << "a token"; - cerr << ": " << t1 << " vs. " << t2 << endl; + msg << nm + " with type mismatch (" << t1 << " vs. " << t2 << ")"; + session.print_error (semantic_error (msg.str(), tok)); } } @@ -2793,6 +2773,5 @@ void typeresolution_info::resolved (const token*, exp_type) { num_newly_resolved ++; - // cerr << "resolved " << *e->tok << " type " << t << endl; } -- 2.43.5