diff options
author | Stan Cox <scox@redhat.com> | 2008-06-16 12:49:42 -0400 |
---|---|---|
committer | Stan Cox <scox@redhat.com> | 2008-06-16 12:49:42 -0400 |
commit | 6643650db25f9ea5b32fe767b4f09e2b6d91a7c4 (patch) | |
tree | da089e0cf1a937aee3452ca322802439036daa06 /elaborate.cxx | |
parent | e8402528a3e3f77fa804904e875453039ed4abee (diff) | |
download | systemtap-steved-6643650db25f9ea5b32fe767b4f09e2b6d91a7c4.tar.gz systemtap-steved-6643650db25f9ea5b32fe767b4f09e2b6d91a7c4.tar.xz systemtap-steved-6643650db25f9ea5b32fe767b4f09e2b6d91a7c4.zip |
Bug 6611: read-only variable typo warnings should list alternatives.
Diffstat (limited to 'elaborate.cxx')
-rw-r--r-- | elaborate.cxx | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/elaborate.cxx b/elaborate.cxx index e9746cdd..efdf2e96 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1229,13 +1229,13 @@ systemtap_session::print_error (const semantic_error& e) } void -systemtap_session::print_warning (const string& message_str) +systemtap_session::print_warning (const string& message_str, string optional_str = "") { // Duplicate elimination if (seen_warnings.find (message_str) == seen_warnings.end()) { seen_warnings.insert (message_str); - clog << "WARNING: " << message_str << endl; + clog << "WARNING: " << message_str << optional_str << endl; } } @@ -1612,7 +1612,7 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) // Now in vut.read/written, we have a mixture of all locals, globals - for (unsigned i=0; i<s.probes.size(); i++) + for (unsigned i=0; i<s.probes.size(); i++) for (unsigned j=0; j<s.probes[i]->locals.size(); /* see below */) { vardecl* l = s.probes[i]->locals[j]; @@ -1638,11 +1638,27 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) { if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - s.print_warning ("read-only local variable " + stringify(*l->tok)); - + { + stringstream o; + vector<vardecl*>::iterator it; + for ( it = s.probes[i]->locals.begin() ; + it != s.probes[i]->locals.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.globals.begin() ; + it != s.globals.end() ; it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + + s.print_warning ("read-only local variable " + + stringify(*l->tok), + " (alternatives: " + o.str () + ")"); + } + j++; } } + for (unsigned i=0; i<s.functions.size(); i++) for (unsigned j=0; j<s.functions[i]->locals.size(); /* see below */) { @@ -1667,9 +1683,27 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) } else { + stringstream o; + vector<vardecl*>::iterator it; + for ( it = s.functions[i]->formal_args.begin() ; + it != s.functions[i]->formal_args.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.functions[i]->locals.begin() ; + it != s.functions[i]->locals.end(); it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + for ( it = s.globals.begin() ; + it != s.globals.end() ; it++ ) + if (l->name.compare(((vardecl*)*it)->name) != 0) + o << " " << ((vardecl*)*it)->name; + if (vut.written.find (l) == vut.written.end()) if (! s.suppress_warnings) - s.print_warning ("read-only local variable " + stringify(*l->tok)); + s.print_warning ("read-only local variable " + + stringify(*l->tok), + " (alternatives:" + o.str () + ")"); + j++; } } |