abilint: Support --annotate

It turns out abilint doesn't support the "--annotate" option like
abidw does.  Annoying.  Added thus.

	* tools/abilint.cc (options::annotate): Define new data member.
	(options::options): Initialize.
	(display_usage): Add help string.
	(parse_command): Support the --annotate command options.
	(main): Set the annotate option on the context.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2023-10-31 18:11:52 +01:00
parent 89ab39de78
commit ba094de49e
2 changed files with 16 additions and 1 deletions

View File

@ -27,6 +27,13 @@ Invocation
Options Options
======= =======
* ``--annotate``
Annotate the ABIXML output with comments above most elements. The
comments are made of the pretty-printed form of types, declaration
or even ELF symbols. The purpose is to make the ABIXML output
more human-readable for debugging or documenting purposes.
* ``--help`` * ``--help``
Display a short help message and exits. Display a short help message and exits.

View File

@ -81,6 +81,7 @@ struct options
bool read_tu; bool read_tu;
bool diff; bool diff;
bool noout; bool noout;
bool annotate;
#ifdef WITH_CTF #ifdef WITH_CTF
bool use_ctf; bool use_ctf;
#endif #endif
@ -97,7 +98,8 @@ struct options
read_from_stdin(false), read_from_stdin(false),
read_tu(false), read_tu(false),
diff(false), diff(false),
noout(false) noout(false),
annotate(false)
#ifdef WITH_CTF #ifdef WITH_CTF
, ,
use_ctf(false) use_ctf(false)
@ -493,6 +495,7 @@ display_usage(const string& prog_name, ostream& out)
<< " --diff for xml inputs, perform a text diff between " << " --diff for xml inputs, perform a text diff between "
"the input and the memory model saved back to disk\n" "the input and the memory model saved back to disk\n"
<< " --noout do not display anything on stdout\n" << " --noout do not display anything on stdout\n"
<< " --annotate annotate the ABI artifacts emitted in the output\n"
<< " --stdin read abi-file content from stdin\n" << " --stdin read abi-file content from stdin\n"
<< " --tu expect a single translation unit file\n" << " --tu expect a single translation unit file\n"
#ifdef WITH_CTF #ifdef WITH_CTF
@ -583,6 +586,8 @@ parse_command_line(int argc, char* argv[], options& opts)
opts.diff = true; opts.diff = true;
else if (!strcmp(argv[i], "--noout")) else if (!strcmp(argv[i], "--noout"))
opts.noout = true; opts.noout = true;
else if (!strcmp(argv[i], "--annotate"))
opts.annotate = true;
#ifdef WITH_SHOW_TYPE_USE_IN_ABILINT #ifdef WITH_SHOW_TYPE_USE_IN_ABILINT
else if (!strcmp(argv[i], "--show-type-use")) else if (!strcmp(argv[i], "--show-type-use"))
{ {
@ -723,6 +728,7 @@ main(int argc, char* argv[])
{ {
const write_context_sptr& ctxt const write_context_sptr& ctxt
= create_write_context(env, cout); = create_write_context(env, cout);
set_annotate(*ctxt, opts.annotate);
write_translation_unit(*ctxt, *tu, 0); write_translation_unit(*ctxt, *tu, 0);
} }
return 0; return 0;
@ -739,6 +745,7 @@ main(int argc, char* argv[])
{ {
const write_context_sptr& ctxt const write_context_sptr& ctxt
= create_write_context(env, cout); = create_write_context(env, cout);
set_annotate(*ctxt, opts.annotate);
write_corpus(*ctxt, corp, /*indent=*/0); write_corpus(*ctxt, corp, /*indent=*/0);
} }
return 0; return 0;
@ -879,6 +886,7 @@ main(int argc, char* argv[])
{ {
if (!opts.noout) if (!opts.noout)
{ {
set_annotate(*ctxt, opts.annotate);
if (corp) if (corp)
is_ok = write_corpus(*ctxt, corp, 0); is_ok = write_corpus(*ctxt, corp, 0);
else if (group) else if (group)