Skip to content

Message handler: add quote_begin, quote_end commands #5696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test
--classpath ./NotHere.jar
^EXIT=6$
^SIGNAL=0$
Warning: failed to access JAR file `./NotHere.jar'
Warning: failed to access JAR file './NotHere.jar'
Error: Could not find or load main class Test
--
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test
--classpath `../../../../scripts/format_classpath.sh ./NotHere .`
^EXIT=0$
^SIGNAL=0$
Warning: failed to access directory `./NotHere'
Warning: failed to access directory './NotHere'
--
--
Note: 'java' does not emit such a warning.
Expand Down
18 changes: 9 additions & 9 deletions jbmc/regression/jbmc/lambda1/test_goto_functions.desc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
CORE
Lambdatest
--verbosity 10 --show-goto-functions --function Lambdatest.main --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar ../../../lib/java-models-library/target/cprover-api.jar`
lambda function reference lambda\$new\$0 in class \"Lambdatest\"
lambda function reference lambda\$new\$1 in class \"Lambdatest\"
lambda function reference lambda\$captureReference\$2 in class \"Lambdatest\"
lambda function reference lambda\$captureInt\$3 in class \"Lambdatest\"
lambda function reference lambda\$captureThisPrimitive\$4 in class \"Lambdatest\"
lambda function reference lambda\$captureThisReference\$5 in class \"Lambdatest\"
lambda function reference lambda\$captureAndCall\$6 in class \"Lambdatest\"
lambda function reference lambda\$captureAndAssign\$7 in class \"Lambdatest\"
lambda function reference lambda\$static\$0 in class \"B\"
lambda function reference lambda\$new\$0 in class 'Lambdatest'
lambda function reference lambda\$new\$1 in class 'Lambdatest'
lambda function reference lambda\$captureReference\$2 in class 'Lambdatest'
lambda function reference lambda\$captureInt\$3 in class 'Lambdatest'
lambda function reference lambda\$captureThisPrimitive\$4 in class 'Lambdatest'
lambda function reference lambda\$captureThisReference\$5 in class 'Lambdatest'
lambda function reference lambda\$captureAndCall\$6 in class 'Lambdatest'
lambda function reference lambda\$captureAndAssign\$7 in class 'Lambdatest'
lambda function reference lambda\$static\$0 in class 'B'
^EXIT=0$
^SIGNAL=0$
2 changes: 1 addition & 1 deletion jbmc/regression/jbmc/lambda2/test.desc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CORE symex-driven-lazy-loading-expected-failure
org.symphonyoss.symphony.clients.model.SymStream
--show-goto-functions --verbosity 10
lambda function reference toSymUser in class "org\.symphonyoss\.symphony\.clients\.model\.SymStream"
lambda function reference toSymUser in class 'org\.symphonyoss\.symphony\.clients\.model\.SymStream'
^EXIT=0$
^SIGNAL=0$
--
Expand Down
12 changes: 5 additions & 7 deletions jbmc/src/java_bytecode/java_bytecode_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2101,13 +2101,11 @@ void java_bytecode_parsert::read_bootstrapmethods_entry()

log.debug()
<< "lambda function reference "
<< id2string(
lambda_method_handle->get_method_descriptor().base_method_name())
<< " in class \"" << parse_tree.parsed_class.name << "\""
<< "\n interface type is "
<< id2string(pool_entry(interface_type_argument.ref1).s)
<< "\n method type is "
<< id2string(pool_entry(method_type_argument.ref1).s) << messaget::eom;
<< lambda_method_handle->get_method_descriptor().base_method_name()
<< " in class " << messaget::quote_begin << parse_tree.parsed_class.name
<< messaget::quote_end << "\n interface type is "
<< pool_entry(interface_type_argument.ref1).s << "\n method type is "
<< pool_entry(method_type_argument.ref1).s << messaget::eom;
parse_tree.parsed_class.add_method_handle(
bootstrap_method_index, *lambda_method_handle);
}
Expand Down
6 changes: 4 additions & 2 deletions jbmc/src/java_bytecode/java_class_loader_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ void java_class_loader_baset::add_classpath_entry(
}
else
{
log.warning() << "Warning: failed to access JAR file `" << path << "'"
log.warning() << "Warning: failed to access JAR file "
<< messaget::quote_begin << path << messaget::quote_end
<< messaget::eom;
}
}
Expand All @@ -47,7 +48,8 @@ void java_class_loader_baset::add_classpath_entry(
}
else
{
log.warning() << "Warning: failed to access directory `" << path << "'"
log.warning() << "Warning: failed to access directory "
<< messaget::quote_begin << path << messaget::quote_end
<< messaget::eom;
}
}
Expand Down
2 changes: 1 addition & 1 deletion regression/goto-cc-file-local/old-flag-name/test.desc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ final-link assertion-check old-flag
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
^The `--export-function-local-symbols` flag is deprecated. Please use `--export-file-local-symbols` instead.$
^The '--export-function-local-symbols' flag is deprecated. Please use '--export-file-local-symbols' instead.$
--
^warning: ignoring
^\*\*\*\* WARNING: no body for function
Expand Down
5 changes: 3 additions & 2 deletions src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol)
// versions of Visual Studio insist to use this in their C library, and
// GCC just warns as well.
warning().source_location = symbol.value.find_source_location();
warning() << "'extern' symbol '" << new_name
<< "' should not have an initializer" << eom;
warning() << quote_begin << "extern" << quote_end << " symbol "
<< quote_begin << new_name << quote_end
<< " should not have an initializer " << eom;
}
}
else if(!is_function && symbol.value.id()==ID_code)
Expand Down
6 changes: 4 additions & 2 deletions src/ansi-c/c_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code)
if(!case_is_allowed)
{
error().source_location = code.source_location();
error() << "did not expect `case' here" << eom;
error() << "did not expect " << quote_begin << "case" << quote_end
<< " here" << eom;
throw 0;
}

Expand All @@ -575,7 +576,8 @@ void c_typecheck_baset::typecheck_gcc_switch_case_range(
if(!case_is_allowed)
{
error().source_location = code.source_location();
error() << "did not expect `case' here" << eom;
error() << "did not expect " << quote_begin << "case" << quote_end
<< " here" << eom;
throw 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr)
if(s_it == symbol_table.symbols.end())
{
error().source_location = expr.source_location();
error() << "failed to find bound symbol `" << identifier
<< "' in symbol table" << eom;
error() << "failed to find bound symbol " << quote_begin << identifier
<< quote_end << " in symbol table" << eom;
throw 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_instantiate_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ const symbolt &cpp_typecheckt::instantiate_template(
if(new_decl.member_spec().is_virtual())
{
error().source_location=new_decl.source_location();
error() << "invalid use of `virtual' in template declaration"
<< eom;
error() << "invalid use of " << quote_begin << "virtual" << quote_end
<< " in template declaration" << eom;
throw 0;
}

Expand Down
3 changes: 2 additions & 1 deletion src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,8 @@ void cpp_typecheckt::typecheck_expr_this(exprt &expr)
if(cpp_scopes.current_scope().class_identifier.empty())
{
error().source_location=expr.find_source_location();
error() << "`this' is not allowed here" << eom;
error() << quote_begin << "this" << quote_end << " is not allowed here"
<< eom;
throw 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void cpp_typecheckt::convert_parameter(
if(symbol_table.move(symbol, new_symbol))
{
error().source_location=symbol.location;
error() << "cpp_typecheckt::convert_parameter: symbol_table.move(\""
<< symbol.name << "\") failed" << eom;
error() << "cpp_typecheckt::convert_parameter: symbol_table.move("
<< quote_begin << symbol.name << quote_end << ") failed" << eom;
throw 0;
}

Expand Down
25 changes: 16 additions & 9 deletions src/goto-analyzer/taint_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ bool taint_parser(
else
{
messaget message(message_handler);
message.error() << "taint rule must have \"kind\" which is "
"\"source\" or \"sink\" or \"sanitizer\""
<< messaget::eom;
message.error() << "taint rule must have " << messaget::quote_begin
<< "kind" << messaget::quote_end << " which is "
<< messaget::quote_begin << "source"
<< messaget::quote_end << " or " << messaget::quote_begin
<< "sink" << messaget::quote_end << " or "
<< messaget::quote_begin << "sanitizer"
<< messaget::quote_end << messaget::eom;
return true;
}

Expand All @@ -75,8 +79,8 @@ bool taint_parser(
if(function.empty())
{
messaget message(message_handler);
message.error() << "taint rule must have \"function\""
<< messaget::eom;
message.error() << "taint rule must have " << messaget::quote_begin
<< "function" << messaget::quote_end << messaget::eom;
return true;
}
else
Expand All @@ -101,10 +105,13 @@ bool taint_parser(
else
{
messaget message(message_handler);
message.error() << "taint rule must have \"where\""
<< " which is \"return_value\" or \"this\" "
<< "or \"parameter1\"..."
<< messaget::eom;
message.error() << "taint rule must have " << messaget::quote_begin
<< "where" << messaget::quote_end << " which is "
<< messaget::quote_begin << "return_value"
<< messaget::quote_end << " or " << messaget::quote_begin
<< "this" << messaget::quote_end << " or "
<< messaget::quote_begin << "parameter1"
<< messaget::quote_end << "..." << messaget::eom;
return true;
}

Expand Down
10 changes: 6 additions & 4 deletions src/goto-cc/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,12 @@ compilet::compilet(cmdlinet &_cmdline, message_handlert &mh, bool Werror)

if(cmdline.isset("export-function-local-symbols"))
{
log.warning()
<< "The `--export-function-local-symbols` flag is deprecated. "
"Please use `--export-file-local-symbols` instead."
<< messaget::eom;
log.warning() << "The " << messaget::quote_begin
<< "--export-function-local-symbols" << messaget::quote_end
<< " flag is deprecated. "
"Please use "
<< messaget::quote_begin << "--export-file-local-symbols"
<< messaget::quote_end << " instead." << messaget::eom;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/linking/linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ void linkingt::duplicate_object_symbol(
log.warning().source_location = new_symbol.location;

log.warning() << "conflicting initializers for"
<< " variable '" << old_symbol.name << "'\n";
<< " variable " << messaget::quote_begin
<< old_symbol.name << messaget::quote_end << '\n';
log.warning() << "using old value in module " << old_symbol.module
<< " " << old_symbol.value.find_source_location() << '\n'
<< from_expr(ns, old_symbol.name, tmp_old) << '\n';
Expand Down
18 changes: 12 additions & 6 deletions src/linking/linking_diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,14 @@ void linking_diagnosticst::error(
messaget log{message_handler};
log.error().source_location = new_symbol.location;

log.error() << msg << " '" << old_symbol.display_name() << "'" << '\n';
log.error() << "old definition in module '" << old_symbol.module << "' "
log.error() << msg << ' ' << messaget::quote_begin
<< old_symbol.display_name() << messaget::quote_end << '\n';
log.error() << "old definition in module " << messaget::quote_begin
<< old_symbol.module << messaget::quote_end << ' '
<< old_symbol.location << '\n'
<< type_to_string_verbose(old_symbol) << '\n';
log.error() << "new definition in module '" << new_symbol.module << "' "
log.error() << "new definition in module " << messaget::quote_begin
<< new_symbol.module << messaget::quote_end << ' '
<< new_symbol.location << '\n'
<< type_to_string_verbose(new_symbol) << messaget::eom;
}
Expand All @@ -387,11 +390,14 @@ void linking_diagnosticst::warning(
messaget log{message_handler};
log.warning().source_location = new_symbol.location;

log.warning() << msg << " '" << old_symbol.display_name() << "'\n";
log.warning() << "old definition in module " << old_symbol.module << " "
log.warning() << msg << ' ' << messaget::quote_begin
<< old_symbol.display_name() << messaget::quote_end << '\n';
log.warning() << "old definition in module " << messaget::quote_begin
<< old_symbol.module << messaget::quote_end << ' '
<< old_symbol.location << '\n'
<< type_to_string_verbose(old_symbol) << '\n';
log.warning() << "new definition in module " << new_symbol.module << " "
log.warning() << "new definition in module " << messaget::quote_begin
<< new_symbol.module << messaget::quote_end << ' '
<< new_symbol.location << '\n'
<< type_to_string_verbose(new_symbol) << messaget::eom;
}
3 changes: 2 additions & 1 deletion src/solvers/smt2/smt2_dec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ decision_proceduret::resultt smt2_dect::read_result(std::istream &in)
const auto &message = id2string(parsed.get_sub()[1].id());
messaget log{message_handler};
log.error() << "SMT2 solver returned error message:\n"
<< "\t\"" << message << "\"" << messaget::eom;
<< "\t" << messaget::quote_begin << message
<< messaget::quote_end << messaget::eom;
return decision_proceduret::resultt::D_ERROR;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/solvers/strings/string_refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,9 @@ static exprt get_char_array_and_concretize(
const auto array_expr =
expr_try_dynamic_cast<array_exprt>(*concretized_array))
{
stream << std::string(4, ' ') << "- as_string: \""
<< string_of_array(*array_expr) << "\"\n";
stream << std::string(4, ' ')
<< "- as_string: " << messaget::quote_begin
<< string_of_array(*array_expr) << messaget::quote_end << '\n';
}
else
stream << std::string(2, ' ') << "- warning: not an array"
Expand Down
13 changes: 8 additions & 5 deletions src/statement-list/statement_list_entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ static bool is_main_symbol_invalid(
if(found)
{
messaget message(message_handler);
message.error() << "main symbol `" << main_symbol_name
<< "' is ambiguous" << messaget::eom;
message.error() << "main symbol " << messaget::quote_begin
<< main_symbol_name << messaget::quote_end
<< " is ambiguous" << messaget::eom;
return true;
}
else
Expand All @@ -66,7 +67,8 @@ static bool is_main_symbol_invalid(
else
{
messaget message(message_handler);
message.error() << "main symbol `" << main_symbol_name << "' not found"
message.error() << "main symbol " << messaget::quote_begin
<< main_symbol_name << messaget::quote_end << " not found"
<< messaget::eom;
return true;
}
Expand Down Expand Up @@ -225,8 +227,9 @@ bool statement_list_entry_point(
if(main.value.is_nil())
{
messaget message(message_handler);
message.error() << "main symbol `" << id2string(main_symbol_name)
<< "' has no body" << messaget::eom;
message.error() << "main symbol " << messaget::quote_begin
<< main_symbol_name << messaget::quote_end << " has no body"
<< messaget::eom;
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/util/cout_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ console_message_handlert::console_message_handlert(bool _always_flush)
/// \param c: ECMA-48 command code
std::string console_message_handlert::command(unsigned c) const
{
// quote_begin and quote_end
if(c == '<' || c == '>')
return "'";

if(!use_SGR)
return std::string();

Expand Down
2 changes: 2 additions & 0 deletions src/util/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ const messaget::commandt messaget::bright_yellow(93);
const messaget::commandt messaget::bright_blue(94);
const messaget::commandt messaget::bright_magenta(95);
const messaget::commandt messaget::bright_cyan(96);
const messaget::commandt messaget::quote_begin('<');
const messaget::commandt messaget::quote_end('>');

/// Parse a (user-)provided string as a verbosity level and set it as the
/// verbosity of dest.
Expand Down
6 changes: 6 additions & 0 deletions src/util/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ class messaget
/// render underlined text
static const commandt underline;

/// start quoted text
static const commandt quote_begin;

/// start quoted text
static const commandt quote_end;

mstreamt &get_mstream(unsigned message_level) const
{
mstream.message_level=message_level;
Expand Down
Loading
Loading