diff --git a/.gitignore b/.gitignore index f48ca020a60..7ba5ba011b4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,6 @@ src/goto-analyzer/taint_driver_scripts/.idea/* /*.files /*.includes -*.pyc - # compilation files *.lo *.od @@ -70,10 +68,6 @@ src/xmllang/xml_lex.yy.cpp src/xmllang/xml_y.output src/xmllang/xml_y.tab.cpp src/xmllang/xml_y.tab.h -src/memory-models/mm_lex.yy.cpp -src/memory-models/mm_y.output -src/memory-models/mm_y.tab.cpp -src/memory-models/mm_y.tab.h # binaries src/cbmc/cbmc diff --git a/scripts/compare_postprocessor_output.py b/scripts/compare_postprocessor_output.py deleted file mode 100644 index 10dcb0f2709..00000000000 --- a/scripts/compare_postprocessor_output.py +++ /dev/null @@ -1,99 +0,0 @@ -import difflib, argparse, subprocess, sys, os, multiprocessing, itertools - - -def preprocess(compiler, file_contents): - """ Get output from the preprocessing pass on a file. """ - output = subprocess.Popen( - [compiler, '-E', '-'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE).communicate(input=file_contents)[0] - - def should_keep(line): - return str.strip(line) and line[0] != '#' - - return filter(should_keep, output.splitlines()) - - -def preprocess_file(compiler, filename): - """ Open a file and get the preprocessor output. """ - with open(filename, 'rb') as f: - return preprocess(compiler, f.read()) - - -def file_contents_from_branch(filename, branch): - """ Get a copy of a file from another branch and return its contents. """ - return subprocess.check_output( - ['git', 'show', '%s:%s' % (branch, filename)]) - - -def equal_to_file_on_branch(filename, branch, compiler): - """ - Open a file on this branch and preprocess it. Preprocess the same file - from another branch, and return a diff. - """ - with open(filename, 'rb') as f: - def p(text): - return preprocess(compiler, text) - return difflib.unified_diff(p(f.read()), - p(file_contents_from_branch(filename, branch)), - fromfile=filename, - tofile=filename, - lineterm='') - - -def is_source(filename): - """ Return whether the file appears to be a C++ source file. """ - _, ext = os.path.splitext(filename) - return ext == '.h' or ext == '.cpp' - - -def process(tup): - """ - Check a single file, and return its name if the check fails, otherwise - return None. - """ - filename, branch, compiler = tup - failed = '\n'.join(equal_to_file_on_branch(filename, branch, compiler)) - return failed if failed else None - - -def main(): - """ - Open a file and compare its preprocessor output to the output from the same - file on a different branch. Return 0 if the outputs match, or 1 otherwise. - """ - parser = argparse.ArgumentParser() - parser.add_argument( - '--branch', type=str, default='upstream/master', - help='The branch to compare') - parser.add_argument( - '--compiler', type=str, default='g++', - help='The compiler to use') - args = parser.parse_args() - - all_files = [os.path.join(root, file) - for root, _, files in os.walk('.') for file in files] - source_files = filter(is_source, all_files) - - zipped = zip( - source_files, - itertools.cycle([args.branch]), - itertools.cycle([args.compiler])) - - pool = multiprocessing.Pool(10) - - results = filter(None, pool.map(process, zipped)) - - pool.close() - pool.join() - - if results: - print('\n\n'.join(results)) - return 1 - - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/scripts/do_doc_convert.py b/scripts/do_doc_convert.py deleted file mode 100644 index bf7f47fa953..00000000000 --- a/scripts/do_doc_convert.py +++ /dev/null @@ -1,40 +0,0 @@ -from reformat_docs import convert_file -from os import walk -from os.path import join -from sys import exit -from re import match - -""" -Run this from CBMC's top-level directory. -""" - -def main(): - IGNORE_LIST = [ - r'src/big-int/.*', - r'src/miniz/.*', - r'src/ansi-c/arm_builtin_headers.h', - r'src/ansi-c/clang_builtin_headers.h', - r'src/ansi-c/cw_builtin_headers.h', - r'src/ansi-c/gcc_builtin_headers_alpha.h', - r'src/ansi-c/gcc_builtin_headers_arm.h', - r'src/ansi-c/gcc_builtin_headers_generic.h', - r'src/ansi-c/gcc_builtin_headers_ia32-2.h', - r'src/ansi-c/gcc_builtin_headers_ia32.h', - r'src/ansi-c/gcc_builtin_headers_mips.h', - r'src/ansi-c/gcc_builtin_headers_power.h', - r'src/ansi-c/library/cprover.h'] - - MATCH_EXPR = r'.*\.(h|cpp)' - - for root, dirs, files in walk('src'): - for file in files: - path = join(root, file) - if any(map(lambda x: match(x, path), IGNORE_LIST)): - print 'ignoring', path - continue - if not match(MATCH_EXPR, path): - continue - convert_file(path, True) - -if __name__ == '__main__': - exit(main()) diff --git a/scripts/reformat_docs.py b/scripts/reformat_docs.py deleted file mode 100644 index eadc5359052..00000000000 --- a/scripts/reformat_docs.py +++ /dev/null @@ -1,267 +0,0 @@ -import re, collections, textwrap, sys, argparse, platform - -Field = collections.namedtuple('Field', ['name', 'contents']) - -Header = collections.namedtuple('Header', ['module']) - -Function = collections.namedtuple('Function', - ['name', 'purpose', 'inputs', 'returns']) - -Class = collections.namedtuple('Class', ['name', 'purpose']) - - -def warn(message): - """ Print a labelled message to stderr. """ - sys.stderr.write('Warning: %s\n' % message) - - -def header_from_block(block): - """ Create a Header structure from a parsed Block. """ - return Header(block.fields['Module']) - - -def function_from_block(block): - """ Create a Function structure from a parsed Block. """ - return Function(block.fields.get('Function', None), - block.fields.get('Purpose', None), block.fields.get('Inputs', None), - block.fields.get('Outputs', None)) - - -def make_field(name, contents): - return Field(name, contents if contents.strip() else None) - - -def class_from_block(block): - """ Create a Class structure from a parsed Block. """ - return Class(block.fields.get('Class', None), - block.fields.get('Purpose', None)) - - -def parse_fields(block_contents): - """ Extract the named fields of an old-style comment block. """ - - field_re = re.compile( - r'(?:\n *(Purpose):(.*))|(?:\n *([a-zA-Z0-9]+?):\n?(.*?)?^$)', - re.MULTILINE | re.DOTALL) - for m in field_re.finditer(block_contents): - # If the field is a Purpose field - if m.lastindex == 2: - yield make_field(m.group(1), textwrap.dedent(m.group(2))) - # If the field is any other field - elif m.lastindex == 3 or m.lastindex == 4: - yield make_field(m.group(3), textwrap.dedent(m.group(4))) - - -Block = collections.namedtuple('Block', ['fields']) - - -def has_field(block, field_name): - """ Return whether the block has a field with the given name. """ - return field_name in block.fields - - -def make_doxy_comment(text): - text = re.sub(r'^(?!$)', r'/// ', text, flags=re.MULTILINE) - return re.sub(r'^(?=$)', r'///' , text, flags=re.MULTILINE) - - -class GenericFormatter(object): - def __init__(self, doc_width): - self.text_wrapper = textwrap.TextWrapper(width=doc_width) - self.indented_wrapper = textwrap.TextWrapper(width=doc_width, - subsequent_indent=r' ') - self.whitespace_re = re.compile(r'\n\s*', re.MULTILINE | re.DOTALL) - - def convert(self, block): - sections = filter(None, self.convert_sections(block)) - if sections: - return make_doxy_comment('\n'.join(sections)) + '\n' - return '' - - -class HeaderFormatter(GenericFormatter): - def format_module(self, header): - if not header.module: - return None - - subbed = self.whitespace_re.sub(' ', header.module) - # The file directive must be followed by a newline in order to refer to - # the current file - return '\\file\n' + self.indented_wrapper.fill(subbed) - - def is_block_valid(self, block): - return has_field(block, 'Module') - - def convert_sections(self, block): - return [self.format_module(block)] - - def needs_new_header(self, file_contents): - return (re.search(r'^\/\/\/ \\file$', file_contents, flags=re.MULTILINE) - is None) - - -class FunctionFormatter(GenericFormatter): - def __init__(self, doc_width): - super(FunctionFormatter, self).__init__(doc_width) - self.paragraph_re = re.compile(r'(.*?)^$(.*)', re.MULTILINE | re.DOTALL) - - def format_purpose(self, function): - if not function.purpose: - return None - - match = self.paragraph_re.match(function.purpose) - first_paragraph = match.group(1) - first_paragraph = self.whitespace_re.sub(' ', - first_paragraph) if first_paragraph else '' - - tail_paragraphs = (('\n' + match.group(2)) if match.group(2) else '') - formatted_purpose = (self.text_wrapper.fill(first_paragraph) + - tail_paragraphs) - - return formatted_purpose.strip() - - def format_inputs(self, function): - if not function.inputs: - return None - - if re.match(r'^\s*\S+\s*$', function.inputs): - return None - - def param_replacement(match): - return r'\param %s:' % match.group(1) - - lines = function.inputs.split('\n') - tail = '\n'.join(lines[1:]) - - dedented = lines[0] + '\n' + textwrap.dedent(tail) - - text = re.sub(r'\n\s+', ' ', dedented, flags=re.MULTILINE) - text, num_replacements = re.subn(r'^([a-zA-Z0-9_]+)\s*[:-]', - param_replacement, text, flags=re.MULTILINE) - - if num_replacements == 0: - text = r'\par parameters: %s' % text - - text = '\n'.join( - self.indented_wrapper.fill(t) for t in text.split('\n')) - return text.strip() - - def format_returns(self, function): - if not function.returns: - return None - - subbed = self.whitespace_re.sub(' ', function.returns) - return self.indented_wrapper.fill(r'\return %s' % subbed) - - def is_block_valid(self, block): - return has_field(block, 'Function') - - def convert_sections(self, block): - return [ - self.format_purpose(block), - self.format_inputs(block), - self.format_returns(block)] - - -class ClassFormatter(GenericFormatter): - def __init__(self, doc_width): - super(ClassFormatter, self).__init__(doc_width) - self.paragraph_re = re.compile(r'(.*?)^$(.*)', re.MULTILINE | re.DOTALL) - - def format_purpose(self, klass): - if not klass.purpose: - return None - - match = self.paragraph_re.match(klass.purpose) - first_paragraph = match.group(1) - first_paragraph = self.whitespace_re.sub(' ', - first_paragraph) if first_paragraph else '' - - tail_paragraphs = (('\n' + match.group(2)) if match.group(2) else '') - formatted_purpose = (self.text_wrapper.fill(first_paragraph) + - tail_paragraphs) - - return formatted_purpose.strip() - - def is_block_valid(self, block): - return has_field(block, 'Class') - - def convert_sections(self, block): - return [self.format_purpose(block)] - - -def replace_block( - block_contents, - file_contents, - file, - header_formatter, - class_formatter, - function_formatter): - """ - Replace an old-style documentation block with the doxygen equivalent - """ - block = Block( - {f.name: f.contents for f in parse_fields(block_contents.group(1))}) - - if header_formatter.is_block_valid(block): - converted = header_formatter.convert(header_from_block(block)) - if header_formatter.needs_new_header(file_contents) and converted: - return block_contents.group(0) + converted + '\n' - return block_contents.group(0) - - if class_formatter.is_block_valid(block): - return class_formatter.convert(class_from_block(block)) - - if function_formatter.is_block_valid(block): - return function_formatter.convert(function_from_block(block)) - - warn('block in "%s" has unrecognised format:\n%s' % - (file, block_contents.group(1))) - - return '' - - -def convert_file(file, inplace): - """ Replace documentation in file with doxygen-styled comments. """ - with open(file) as f: - contents = f.read() - - doc_width = 76 - - header_formatter = HeaderFormatter(doc_width) - class_formatter = ClassFormatter(doc_width) - function_formatter = FunctionFormatter(doc_width) - - block_re = re.compile( - r'^/\*+\\$(.*?)^\\\*+/$\s*', re.MULTILINE | re.DOTALL) - new_contents = block_re.sub( - lambda match: replace_block( - match, - contents, - file, - header_formatter, - class_formatter, - function_formatter), contents) - - if inplace: - with open(file, 'w') as f: - f.write(new_contents) - else: - sys.stdout.write(new_contents) - - -def main(): - """ Run convert_file from the command-line. """ - parser = argparse.ArgumentParser() - parser.add_argument('file', type=str, help='The file to process') - parser.add_argument('-i', '--inplace', action='store_true', - help='Process in place') - args = parser.parse_args() - - convert_file(args.file, args.inplace) - - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index 47d5a060410..45d4b83c92c 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Abstract Interpretation - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" +/*******************************************************************\ + +Function: ai_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::output( const namespacet &ns, const goto_functionst &goto_functions, @@ -38,6 +47,18 @@ void ai_baset::output( } } +/*******************************************************************\ + +Function: ai_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::output( const namespacet &ns, const goto_programt &goto_program, @@ -58,9 +79,18 @@ void ai_baset::output( } } -/// Output the domains for the whole program as JSON -/// \par parameters: The namespace and goto_functions -/// \return The JSON object +/*******************************************************************\ + +Function: ai_baset::output_json + + Inputs: The namespace and goto_functions + + Outputs: The JSON object + + Purpose: Output the domains for the whole program as JSON + +\*******************************************************************/ + jsont ai_baset::output_json( const namespacet &ns, const goto_functionst &goto_functions) const @@ -83,9 +113,18 @@ jsont ai_baset::output_json( return result; } -/// Output the domains for a single function as JSON -/// \par parameters: The namespace, goto_program and it's identifier -/// \return The JSON object +/*******************************************************************\ + +Function: ai_baset::output_json + + Inputs: The namespace, goto_program and it's identifier + + Outputs: The JSON object + + Purpose: Output the domains for a single function as JSON + +\*******************************************************************/ + jsont ai_baset::output_json( const namespacet &ns, const goto_programt &goto_program, @@ -113,9 +152,18 @@ jsont ai_baset::output_json( return contents; } -/// Output the domains for the whole program as XML -/// \par parameters: The namespace and goto_functions -/// \return The XML object +/*******************************************************************\ + +Function: ai_baset::output_xml + + Inputs: The namespace and goto_functions + + Outputs: The XML object + + Purpose: Output the domains for the whole program as XML + +\*******************************************************************/ + xmlt ai_baset::output_xml( const namespacet &ns, const goto_functionst &goto_functions) const @@ -141,9 +189,18 @@ xmlt ai_baset::output_xml( return program; } -/// Output the domains for a single function as XML -/// \par parameters: The namespace, goto_program and it's identifier -/// \return The XML object +/*******************************************************************\ + +Function: ai_baset::output_xml + + Inputs: The namespace, goto_program and it's identifier + + Outputs: The XML object + + Purpose: Output the domains for a single function as XML + +\*******************************************************************/ + xmlt ai_baset::output_xml( const namespacet &ns, const goto_programt &goto_program, @@ -174,6 +231,18 @@ xmlt ai_baset::output_xml( return function_body; } +/*******************************************************************\ + +Function: ai_baset::entry_state + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::entry_state(const goto_functionst &goto_functions) { // find the 'entry function' @@ -185,17 +254,53 @@ void ai_baset::entry_state(const goto_functionst &goto_functions) entry_state(f_it->second.body); } +/*******************************************************************\ + +Function: ai_baset::entry_state + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::entry_state(const goto_programt &goto_program) { // The first instruction of 'goto_program' is the entry point get_state(goto_program.instructions.begin()).make_entry(); } +/*******************************************************************\ + +Function: ai_baset::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::initialize(const goto_functionst::goto_functiont &goto_function) { initialize(goto_function.body); } +/*******************************************************************\ + +Function: ai_baset::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::initialize(const goto_programt &goto_program) { // we mark everything as unreachable as starting point @@ -204,12 +309,36 @@ void ai_baset::initialize(const goto_programt &goto_program) get_state(i_it).make_bottom(); } +/*******************************************************************\ + +Function: ai_baset::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::initialize(const goto_functionst &goto_functions) { forall_goto_functions(it, goto_functions) initialize(it->second); } +/*******************************************************************\ + +Function: ai_baset::get_next + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ai_baset::locationt ai_baset::get_next( working_sett &working_set) { @@ -222,6 +351,18 @@ ai_baset::locationt ai_baset::get_next( return l; } +/*******************************************************************\ + +Function: ai_baset::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ai_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions, @@ -248,6 +389,18 @@ bool ai_baset::fixedpoint( return new_data; } +/*******************************************************************\ + +Function: ai_baset::visit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ai_baset::visit( locationt l, working_sett &working_set, @@ -306,6 +459,18 @@ bool ai_baset::visit( return new_data; } +/*******************************************************************\ + +Function: ai_baset::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ai_baset::do_function_call( locationt l_call, locationt l_return, const goto_functionst &goto_functions, @@ -369,6 +534,18 @@ bool ai_baset::do_function_call( } } +/*******************************************************************\ + +Function: ai_baset::do_function_call_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ai_baset::do_function_call_rec( locationt l_call, locationt l_return, const exprt &function, @@ -453,6 +630,18 @@ bool ai_baset::do_function_call_rec( return new_data; } +/*******************************************************************\ + +Function: ai_baset::sequential_fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::sequential_fixedpoint( const goto_functionst &goto_functions, const namespacet &ns) @@ -464,6 +653,18 @@ void ai_baset::sequential_fixedpoint( fixedpoint(f_it->second.body, goto_functions, ns); } +/*******************************************************************\ + +Function: ai_baset::concurrent_fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ai_baset::concurrent_fixedpoint( const goto_functionst &goto_functions, const namespacet &ns) diff --git a/src/analyses/ai.h b/src/analyses/ai.h index 3a7cf074340..2894cde3b10 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Abstract Interpretation - #ifndef CPROVER_ANALYSES_AI_H #define CPROVER_ANALYSES_AI_H diff --git a/src/analyses/call_graph.cpp b/src/analyses/call_graph.cpp index 2d91e502a3f..c226e2c73ab 100644 --- a/src/analyses/call_graph.cpp +++ b/src/analyses/call_graph.cpp @@ -6,18 +6,39 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Call Graphs - #include #include #include "call_graph.h" +/*******************************************************************\ + +Function: call_grapht::call_grapht + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + call_grapht::call_grapht() { } +/*******************************************************************\ + +Function: call_grapht::call_grapht + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + call_grapht::call_grapht(const goto_functionst &goto_functions) { forall_goto_functions(f_it, goto_functions) @@ -27,6 +48,18 @@ call_grapht::call_grapht(const goto_functionst &goto_functions) } } +/*******************************************************************\ + +Function: call_grapht::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void call_grapht::add( const irep_idt &function, const goto_programt &body) @@ -42,6 +75,18 @@ void call_grapht::add( } } +/*******************************************************************\ + +Function: call_grapht::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void call_grapht::add( const irep_idt &caller, const irep_idt &callee) @@ -49,6 +94,18 @@ void call_grapht::add( graph.insert(std::pair(caller, callee)); } +/*******************************************************************\ + +Function: call_grapht::output_dot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void call_grapht::output_dot(std::ostream &out) const { out << "digraph call_graph {\n"; @@ -64,6 +121,18 @@ void call_grapht::output_dot(std::ostream &out) const out << "}\n"; } +/*******************************************************************\ + +Function: call_grapht::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void call_grapht::output(std::ostream &out) const { for(const auto &edge : graph) @@ -72,6 +141,18 @@ void call_grapht::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: call_grapht::output_xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void call_grapht::output_xml(std::ostream &out) const { for(const auto &edge : graph) diff --git a/src/analyses/call_graph.h b/src/analyses/call_graph.h index a93289f52bd..3410410f3d4 100644 --- a/src/analyses/call_graph.h +++ b/src/analyses/call_graph.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Call Graphs - #ifndef CPROVER_ANALYSES_CALL_GRAPH_H #define CPROVER_ANALYSES_CALL_GRAPH_H diff --git a/src/analyses/cfg_dominators.h b/src/analyses/cfg_dominators.h index fa7d23ccf0a..930d0ae69b9 100644 --- a/src/analyses/cfg_dominators.h +++ b/src/analyses/cfg_dominators.h @@ -6,9 +6,6 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ -/// \file -/// Compute dominators for CFG of goto_function - #ifndef CPROVER_ANALYSES_CFG_DOMINATORS_H #define CPROVER_ANALYSES_CFG_DOMINATORS_H @@ -47,7 +44,18 @@ class cfg_dominators_templatet void fixedpoint(P &program); }; -/// Print the result of the dominator computation +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: Print the result of the dominator computation + +\*******************************************************************/ + template std::ostream &operator << ( std::ostream &out, @@ -57,7 +65,18 @@ std::ostream &operator << ( return out; } -/// Compute dominators +/*******************************************************************\ + +Function: operator () + + Inputs: + + Outputs: + + Purpose: Compute dominators + +\*******************************************************************/ + template void cfg_dominators_templatet::operator()(P &program) { @@ -65,14 +84,36 @@ void cfg_dominators_templatet::operator()(P &program) fixedpoint(program); } -/// Initialises the elements of the fixed point analysis +/*******************************************************************\ + +Function: cfg_dominators_templatet::initialise + + Inputs: + + Outputs: + + Purpose: Initialises the elements of the fixed point analysis + +\*******************************************************************/ + template void cfg_dominators_templatet::initialise(P &program) { cfg(program); } -/// Computes the MOP for the dominator analysis +/*******************************************************************\ + +Function: cfg_dominators_templatet::fixedpoint + + Inputs: + + Outputs: + + Purpose: Computes the MOP for the dominator analysis + +\*******************************************************************/ + template void cfg_dominators_templatet::fixedpoint(P &program) { @@ -164,9 +205,19 @@ void cfg_dominators_templatet::fixedpoint(P &program) } } -/// Pretty-print a single node in the dominator tree. Supply a specialisation if -/// operator<< is not sufficient. -/// \par parameters: `node` to print and stream `out` to pretty-print it to +/*******************************************************************\ + +Function: dominators_pretty_print_node + + Inputs: `node` to print and stream `out` to pretty-print it to + + Outputs: + + Purpose: Pretty-print a single node in the dominator tree. + Supply a specialisation if operator<< is not sufficient. + +\*******************************************************************/ + template void dominators_pretty_print_node(const T &node, std::ostream &out) { @@ -180,7 +231,18 @@ inline void dominators_pretty_print_node( out << target->code.pretty(); } -/// Print the result of the dominator computation +/*******************************************************************\ + +Function: cfg_dominators_templatet::output + + Inputs: + + Outputs: + + Purpose: Print the result of the dominator computation + +\*******************************************************************/ + template void cfg_dominators_templatet::output(std::ostream &out) const { diff --git a/src/analyses/constant_propagator.cpp b/src/analyses/constant_propagator.cpp index 9fa552fc295..6735d558cc3 100644 --- a/src/analyses/constant_propagator.cpp +++ b/src/analyses/constant_propagator.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Constant Propagation - #ifdef DEBUG #include #endif @@ -19,6 +16,18 @@ Author: Peter Schrammel #include "constant_propagator.h" +/*******************************************************************\ + +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt concatenate_array_id( const exprt &array, const exprt &index, const typet &type) @@ -38,6 +47,18 @@ exprt concatenate_array_id( return new_expr; } +/*******************************************************************\ + +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt concatenate_array_id( const exprt &array, const mp_integer &index, const typet &type) @@ -50,6 +71,18 @@ exprt concatenate_array_id( return new_expr; } +/*******************************************************************\ + +Function: constant_propagator_domaint::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_domaint::assign_rec( valuest &values, const exprt &lhs, const exprt &rhs, @@ -121,6 +154,18 @@ void constant_propagator_domaint::assign_rec( #endif } +/*******************************************************************\ + +Function: constant_propagator_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_domaint::transform( locationt from, locationt to, @@ -210,7 +255,18 @@ void constant_propagator_domaint::transform( } -/// handles equalities and conjunctions containing equalities +/*******************************************************************\ + +Function: constant_propagator_domaint::two_way_propagate_rec + + Inputs: + + Outputs: + + Purpose: handles equalities and conjunctions containing equalities + +\*******************************************************************/ + bool constant_propagator_domaint::two_way_propagate_rec( const exprt &expr, const namespacet &ns) @@ -252,6 +308,18 @@ bool constant_propagator_domaint::two_way_propagate_rec( return change; } +/*******************************************************************\ + +Function: constant_propagator_domaint::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_domaint::assign( valuest &dest, const symbol_exprt &lhs, @@ -263,6 +331,18 @@ void constant_propagator_domaint::assign( dest.set_to(lhs, rhs); } +/*******************************************************************\ + +Function: constant_propagator_domaint::is_array_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::is_array_constant(const exprt &expr) const { exprt new_expr = concatenate_array_id(expr.op0(), @@ -275,6 +355,18 @@ bool constant_propagator_domaint::valuest::is_array_constant(const exprt &expr) return true; } +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::is_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const { if(expr.id()==ID_side_effect && @@ -303,6 +395,18 @@ bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const return true; } +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::is_constant_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::is_constant_address_of( const exprt &expr) const { @@ -322,7 +426,18 @@ bool constant_propagator_domaint::valuest::is_constant_address_of( return true; } -/// Do not call this when iterating over replace_const.expr_map! +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::set_to_top + + Inputs: + + Outputs: + + Purpose: Do not call this when iterating over replace_const.expr_map! + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::set_to_top(const irep_idt &id) { bool result = false; @@ -340,6 +455,18 @@ bool constant_propagator_domaint::valuest::set_to_top(const irep_idt &id) return result; } +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_domaint::valuest::output( std::ostream &out, const namespacet &ns) const @@ -354,6 +481,18 @@ void constant_propagator_domaint::valuest::output( << from_expr(ns, "", replace_pair.second) << '\n'; } +/*******************************************************************\ + +Function: constant_propagator_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_domaint::output( std::ostream &out, const ai_baset &ai, @@ -362,8 +501,18 @@ void constant_propagator_domaint::output( values.output(out, ns); } -/// join -/// \return Return true if "this" has changed. +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::merge + + Inputs: + + Outputs: Return true if "this" has changed. + + Purpose: join + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::merge(const valuest &src) { // nothing to do @@ -408,8 +557,18 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) return changed; } -/// meet -/// \return Return true if "this" has changed. +/*******************************************************************\ + +Function: constant_propagator_domaint::valuest::meet + + Inputs: + + Outputs: Return true if "this" has changed. + + Purpose: meet + +\*******************************************************************/ + bool constant_propagator_domaint::valuest::meet(const valuest &src) { if(src.is_bottom || is_bottom) @@ -441,7 +600,18 @@ bool constant_propagator_domaint::valuest::meet(const valuest &src) return changed; } -/// \return Return true if "this" has changed. +/*******************************************************************\ + +Function: constant_propagator_domaint::merge + + Inputs: + + Outputs: Return true if "this" has changed. + + Purpose: + +\*******************************************************************/ + bool constant_propagator_domaint::merge( const constant_propagator_domaint &other, locationt from, @@ -450,6 +620,18 @@ bool constant_propagator_domaint::merge( return values.merge(other.values); } +/*******************************************************************\ + +Function: constant_propagator_ait::replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_ait::replace( goto_functionst &goto_functions, const namespacet &ns) @@ -458,6 +640,18 @@ void constant_propagator_ait::replace( replace(f_it->second, ns); } +/*******************************************************************\ + +Function: constant_propagator_ait::replace_array_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_ait::replace_array_symbol(exprt &expr) { if (expr.id()==ID_index) @@ -474,6 +668,18 @@ void constant_propagator_ait::replace_array_symbol(exprt &expr) } +/*******************************************************************\ + +Function: constant_propagator_ait::replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_ait::replace( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -526,6 +732,18 @@ void constant_propagator_ait::replace( } } +/*******************************************************************\ + +Function: constant_propagator_ait::replace_types_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void constant_propagator_ait::replace_types_rec( const replace_symbolt &replace_const, exprt &expr) diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index f56b265297b..0766b458f7d 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Constant propagation - #ifndef CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H #define CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H diff --git a/src/analyses/custom_bitvector_analysis.cpp b/src/analyses/custom_bitvector_analysis.cpp index face9d8ae67..0a3f0306471 100644 --- a/src/analyses/custom_bitvector_analysis.cpp +++ b/src/analyses/custom_bitvector_analysis.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive bitvector analysis - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include +/*******************************************************************\ + +Function: custom_bitvector_domaint::set_bit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::set_bit( const irep_idt &identifier, unsigned bit_nr, @@ -41,6 +50,18 @@ void custom_bitvector_domaint::set_bit( } } +/*******************************************************************\ + +Function: custom_bitvector_domaint::set_bit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::set_bit( const exprt &lhs, unsigned bit_nr, @@ -51,6 +72,18 @@ void custom_bitvector_domaint::set_bit( set_bit(id, bit_nr, mode); } +/*******************************************************************\ + +Function: custom_bitvector_domaint::object2id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt custom_bitvector_domaint::object2id(const exprt &src) { if(src.id()==ID_symbol) @@ -84,6 +117,18 @@ irep_idt custom_bitvector_domaint::object2id(const exprt &src) return irep_idt(); } +/*******************************************************************\ + +Function: custom_bitvector_domaint::assign_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::assign_lhs( const exprt &lhs, const vectorst &vectors) @@ -93,6 +138,18 @@ void custom_bitvector_domaint::assign_lhs( assign_lhs(id, vectors); } +/*******************************************************************\ + +Function: custom_bitvector_domaint::assign_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::assign_lhs( const irep_idt &identifier, const vectorst &vectors) @@ -110,6 +167,18 @@ void custom_bitvector_domaint::assign_lhs( may_bits[identifier]=vectors.may_bits; } +/*******************************************************************\ + +Function: custom_bitvector_domaint::get_rhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + custom_bitvector_domaint::vectorst custom_bitvector_domaint::get_rhs(const irep_idt &identifier) const { @@ -126,6 +195,18 @@ custom_bitvector_domaint::vectorst return vectors; } +/*******************************************************************\ + +Function: custom_bitvector_domaint::get_rhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + custom_bitvector_domaint::vectorst custom_bitvector_domaint::get_rhs(const exprt &rhs) const { @@ -150,6 +231,18 @@ custom_bitvector_domaint::vectorst return vectorst(); } +/*******************************************************************\ + +Function: custom_bitvector_analysist::get_bit_nr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned custom_bitvector_analysist::get_bit_nr( const exprt &string_expr) { @@ -168,6 +261,18 @@ unsigned custom_bitvector_analysist::get_bit_nr( return bits("(unknown)"); } +/*******************************************************************\ + +Function: custom_bitvector_domaint::aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set custom_bitvector_analysist::aliases( const exprt &src, locationt loc) @@ -204,6 +309,18 @@ std::set custom_bitvector_analysist::aliases( return std::set(); } +/*******************************************************************\ + +Function: custom_bitvector_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::transform( locationt from, locationt to, @@ -432,6 +549,18 @@ void custom_bitvector_domaint::transform( } } +/*******************************************************************\ + +Function: custom_bitvector_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_domaint::output( std::ostream &out, const ai_baset &ai, @@ -479,6 +608,18 @@ void custom_bitvector_domaint::output( } } +/*******************************************************************\ + +Function: custom_bitvector_domaint::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool custom_bitvector_domaint::merge( const custom_bitvector_domaint &b, locationt from, @@ -532,7 +673,18 @@ bool custom_bitvector_domaint::merge( return changed; } -/// erase blank bitvectors +/*******************************************************************\ + +Function: custom_bitvector_domaint::erase_blank_vectors + + Inputs: + + Outputs: + + Purpose: erase blank bitvectors + +\*******************************************************************/ + void custom_bitvector_domaint::erase_blank_vectors(bitst &bits) { for(bitst::iterator a_it=bits.begin(); @@ -546,6 +698,18 @@ void custom_bitvector_domaint::erase_blank_vectors(bitst &bits) } } +/*******************************************************************\ + +Function: custom_bitvector_domaint::has_get_must_or_may + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) { if(src.id()=="get_must" || @@ -559,6 +723,18 @@ bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) return false; } +/*******************************************************************\ + +Function: custom_bitvector_domaint::eval + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt custom_bitvector_domaint::eval( const exprt &src, custom_bitvector_analysist &custom_bitvector_analysis) const @@ -621,10 +797,34 @@ exprt custom_bitvector_domaint::eval( } } +/*******************************************************************\ + +Function: custom_bitvector_analysist::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_analysist::instrument(goto_functionst &) { } +/*******************************************************************\ + +Function: custom_bitvector_analysist::check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void custom_bitvector_analysist::check( const namespacet &ns, const goto_functionst &goto_functions, diff --git a/src/analyses/custom_bitvector_analysis.h b/src/analyses/custom_bitvector_analysis.h index ff2884cc2ec..e77cb6fc58b 100644 --- a/src/analyses/custom_bitvector_analysis.h +++ b/src/analyses/custom_bitvector_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive bitvector analysis - #ifndef CPROVER_ANALYSES_CUSTOM_BITVECTOR_ANALYSIS_H #define CPROVER_ANALYSES_CUSTOM_BITVECTOR_ANALYSIS_H @@ -18,6 +15,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" #include "local_may_alias.h" +/*******************************************************************\ + + Class: custom_bitvector_domaint + + Purpose: + +\*******************************************************************/ + class custom_bitvector_analysist; class custom_bitvector_domaint:public ai_domain_baset diff --git a/src/analyses/dependence_graph.cpp b/src/analyses/dependence_graph.cpp index 470c0911f01..730ec0266e4 100644 --- a/src/analyses/dependence_graph.cpp +++ b/src/analyses/dependence_graph.cpp @@ -9,15 +9,24 @@ Date: August 2013 \*******************************************************************/ -/// \file -/// Field-Sensitive Program Dependence Analysis, Litvak et al., FSE 2010 - #include #include "goto_rw.h" #include "dependence_graph.h" +/*******************************************************************\ + +Function: dep_graph_domaint::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool dep_graph_domaint::merge( const dep_graph_domaint &src, goto_programt::const_targett from, @@ -57,6 +66,18 @@ bool dep_graph_domaint::merge( return changed; } +/*******************************************************************\ + +Function: dep_graph_domaint::control_dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dep_graph_domaint::control_dependencies( goto_programt::const_targett from, goto_programt::const_targett to, @@ -123,6 +144,18 @@ void dep_graph_domaint::control_dependencies( dep_graph.add_dep(dep_edget::kindt::CTRL, c_dep, to); } +/*******************************************************************\ + +Function: may_be_def_use_pair + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool may_be_def_use_pair( const mp_integer &w_start, const mp_integer &w_end, @@ -144,6 +177,18 @@ static bool may_be_def_use_pair( return false; } +/*******************************************************************\ + +Function: dep_graph_domaint::data_depdendencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dep_graph_domaint::data_dependencies( goto_programt::const_targett from, goto_programt::const_targett to, @@ -193,6 +238,18 @@ void dep_graph_domaint::data_dependencies( } } +/*******************************************************************\ + +Function: dep_graph_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dep_graph_domaint::transform( goto_programt::const_targett from, goto_programt::const_targett to, @@ -240,6 +297,18 @@ void dep_graph_domaint::transform( data_dependencies(from, to, *dep_graph, ns); } +/*******************************************************************\ + +Function: dep_graph_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dep_graph_domaint::output( std::ostream &out, const ai_baset &ai, @@ -276,6 +345,18 @@ void dep_graph_domaint::output( } } +/*******************************************************************\ + +Function: dependence_grapht::add_dep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dependence_grapht::add_dep( dep_edget::kindt kind, goto_programt::const_targett from, diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index fc415fe1721..fae7c7adbd4 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -9,9 +9,6 @@ Date: August 2013 \*******************************************************************/ -/// \file -/// Field-Sensitive Program Dependence Analysis, Litvak et al., FSE 2010 - #ifndef CPROVER_ANALYSES_DEPENDENCE_GRAPH_H #define CPROVER_ANALYSES_DEPENDENCE_GRAPH_H diff --git a/src/analyses/dirty.cpp b/src/analyses/dirty.cpp index 8ff99f77aa8..a159f6ddef2 100644 --- a/src/analyses/dirty.cpp +++ b/src/analyses/dirty.cpp @@ -8,13 +8,22 @@ Date: March 2013 \*******************************************************************/ -/// \file -/// Local variables whose address is taken - #include #include "dirty.h" +/*******************************************************************\ + +Function: dirtyt::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dirtyt::build(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) @@ -24,6 +33,18 @@ void dirtyt::build(const goto_functiont &goto_function) } } +/*******************************************************************\ + +Function: dirtyt::find_dirty + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dirtyt::find_dirty(const exprt &expr) { if(expr.id()==ID_address_of) @@ -37,6 +58,18 @@ void dirtyt::find_dirty(const exprt &expr) find_dirty(*it); } +/*******************************************************************\ + +Function: dirtyt::find_dirty_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dirtyt::find_dirty_address_of(const exprt &expr) { if(expr.id()==ID_symbol) @@ -67,6 +100,18 @@ void dirtyt::find_dirty_address_of(const exprt &expr) } } +/*******************************************************************\ + +Function: dirtyt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dirtyt::output(std::ostream &out) const { for(const auto &d : dirty) diff --git a/src/analyses/dirty.h b/src/analyses/dirty.h index 52801d05281..f60b86703c4 100644 --- a/src/analyses/dirty.h +++ b/src/analyses/dirty.h @@ -8,9 +8,6 @@ Date: March 2013 \*******************************************************************/ -/// \file -/// Variables whose address is taken - #ifndef CPROVER_ANALYSES_DIRTY_H #define CPROVER_ANALYSES_DIRTY_H diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp index 90d82f99e19..fcccd8219c9 100644 --- a/src/analyses/does_remove_const.cpp +++ b/src/analyses/does_remove_const.cpp @@ -6,9 +6,6 @@ \*******************************************************************/ -/// \file -/// Analyses - #include #include #include @@ -18,10 +15,21 @@ #include "does_remove_const.h" -/// A naive analysis to look for casts that remove const-ness from pointers. -/// \param goto_program: the goto program to check -/// \param ns: the namespace of the goto program (used for checking type -/// equality) +/*******************************************************************\ + +Function: does_remove_constt::does_remove_constt + + Inputs: + goto_program - the goto program to check + ns - the namespace of the goto program (used for checking type equality) + + Outputs: + + Purpose: A naive analysis to look for casts that remove const-ness from + pointers. + +\*******************************************************************/ + does_remove_constt::does_remove_constt( const goto_programt &goto_program, const namespacet &ns): @@ -29,8 +37,19 @@ does_remove_constt::does_remove_constt( ns(ns) {} -/// A naive analysis to look for casts that remove const-ness from pointers. -/// \return Returns true if the program contains a const-removing cast +/*******************************************************************\ + +Function: does_remove_constt::operator() + + Inputs: + + Outputs: Returns true if the program contains a const-removing cast + + Purpose: A naive analysis to look for casts that remove const-ness from + pointers. + +\*******************************************************************/ + bool does_remove_constt::operator()() const { for(const goto_programt::instructiont &instruction : @@ -61,12 +80,22 @@ bool does_remove_constt::operator()() const return false; } -/// Search the expression tree to look for any children that have the same base -/// type, but a less strict const qualification. If one is found, we return -/// true. -/// \param expr: The expression to check -/// \return Returns true if somewhere in the passed expression tree the const- -/// ness is lost. +/*******************************************************************\ + +Function: does_remove_constt::does_expr_lose_const() + + Inputs: + expr - The expression to check + + Outputs: Returns true if somewhere in the passed expression tree the const-ness + is lost. + + Purpose: Search the expression tree to look for any children that have the + same base type, but a less strict const qualification. + If one is found, we return true. + +\*******************************************************************/ + bool does_remove_constt::does_expr_lose_const(const exprt &expr) const { const typet &root_type=expr.type(); @@ -93,20 +122,29 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const return false; } -/// A recursive check to check the type_more_const is at least as const as type -/// compare. -/// -/// type_more_const | type_compare || result -/// ---------------------------------------- -/// const int * | const int * -> true -/// int * | const int * -> false -/// const int * | int * -> true -/// int * | int * const -> false -/// \param type_more_const: the type we are expecting to be at least as const -/// qualified -/// \param type_compare: the type we are comparing against which may be less -/// const qualified -/// \return Returns true if type_more_const is at least as const as type_compare +/*******************************************************************\ + +Function: does_remove_constt::is_type_at_least_as_const_as + + Inputs: + type_more_const - the type we are expecting to be at least as const qualified + type_compare - the type we are comparing against which may be less const + qualified + + Outputs: Returns true if type_more_const is at least as const as type_compare + + Purpose: A recursive check to check the type_more_const is at least as const + as type compare. + + type_more_const | type_compare || result + ---------------------------------------- + const int * | const int * -> true + int * | const int * -> false + const int * | int * -> true + int * | int * const -> false + +\*******************************************************************/ + bool does_remove_constt::is_type_at_least_as_const_as( const typet *type_more_const, const typet *type_compare) const { diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h index f0cf2a25799..594682c7d50 100644 --- a/src/analyses/does_remove_const.h +++ b/src/analyses/does_remove_const.h @@ -5,9 +5,6 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ -/// \file -/// Analyses - #ifndef CPROVER_ANALYSES_DOES_REMOVE_CONST_H #define CPROVER_ANALYSES_DOES_REMOVE_CONST_H diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index 3b0e7fc3f5c..1382e9d1689 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive escape analysis - #include #include "escape_analysis.h" +/*******************************************************************\ + +Function: escape_domaint::is_tracked + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool escape_domaint::is_tracked(const symbol_exprt &symbol) { const irep_idt &identifier=symbol.get_identifier(); @@ -25,6 +34,18 @@ bool escape_domaint::is_tracked(const symbol_exprt &symbol) return true; } +/*******************************************************************\ + +Function: escape_domaint::get_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt escape_domaint::get_function(const exprt &lhs) { if(lhs.id()==ID_address_of) @@ -40,6 +61,18 @@ irep_idt escape_domaint::get_function(const exprt &lhs) return irep_idt(); } +/*******************************************************************\ + +Function: escape_domaint::assign_lhs_cleanup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::assign_lhs_cleanup( const exprt &lhs, const std::set &cleanup_functions) @@ -59,6 +92,18 @@ void escape_domaint::assign_lhs_cleanup( } } +/*******************************************************************\ + +Function: escape_domaint::assign_lhs_aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::assign_lhs_aliases( const exprt &lhs, const std::set &alias_set) @@ -80,6 +125,18 @@ void escape_domaint::assign_lhs_aliases( } } +/*******************************************************************\ + +Function: escape_domaint::get_rhs_cleanup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::get_rhs_cleanup( const exprt &rhs, std::set &cleanup_functions) @@ -110,6 +167,18 @@ void escape_domaint::get_rhs_cleanup( } } +/*******************************************************************\ + +Function: escape_domaint::get_rhs_aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::get_rhs_aliases( const exprt &rhs, std::set &alias_set) @@ -142,6 +211,18 @@ void escape_domaint::get_rhs_aliases( } } +/*******************************************************************\ + +Function: escape_domaint::get_rhs_aliases_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::get_rhs_aliases_address_of( const exprt &rhs, std::set &alias_set) @@ -161,6 +242,18 @@ void escape_domaint::get_rhs_aliases_address_of( } } +/*******************************************************************\ + +Function: escape_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::transform( locationt from, locationt to, @@ -253,6 +346,18 @@ void escape_domaint::transform( } } +/*******************************************************************\ + +Function: escape_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::output( std::ostream &out, const ai_baset &ai, @@ -299,6 +404,18 @@ void escape_domaint::output( } } +/*******************************************************************\ + +Function: escape_domaint::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool escape_domaint::merge( const escape_domaint &b, locationt from, @@ -363,6 +480,18 @@ bool escape_domaint::merge( return changed; } +/*******************************************************************\ + +Function: escape_domaint::check_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_domaint::check_lhs( const exprt &lhs, std::set &cleanup_functions) @@ -398,6 +527,18 @@ void escape_domaint::check_lhs( } } +/*******************************************************************\ + +Function: escape_analysist::insert_cleanup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_analysist::insert_cleanup( goto_functionst::goto_functiont &goto_function, goto_programt::targett location, @@ -435,6 +576,18 @@ void escape_analysist::insert_cleanup( } } +/*******************************************************************\ + +Function: escape_analysist::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void escape_analysist::instrument( goto_functionst &goto_functions, const namespacet &ns) diff --git a/src/analyses/escape_analysis.h b/src/analyses/escape_analysis.h index 00f865b45e4..948bed3fea8 100644 --- a/src/analyses/escape_analysis.h +++ b/src/analyses/escape_analysis.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive, over-approximative escape analysis - #ifndef CPROVER_ANALYSES_ESCAPE_ANALYSIS_H #define CPROVER_ANALYSES_ESCAPE_ANALYSIS_H @@ -19,6 +16,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" +/*******************************************************************\ + + Class: escape_domaint + + Purpose: + +\*******************************************************************/ + class escape_analysist; class escape_domaint:public ai_domain_baset diff --git a/src/analyses/flow_insensitive_analysis.cpp b/src/analyses/flow_insensitive_analysis.cpp index 0d46d9d38c0..bc4dd11e889 100644 --- a/src/analyses/flow_insensitive_analysis.cpp +++ b/src/analyses/flow_insensitive_analysis.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Flow Insensitive Static Analysis - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "flow_insensitive_analysis.h" +/*******************************************************************\ + +Function: flow_insensitive_abstract_domain_baset::get_guard + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt flow_insensitive_abstract_domain_baset::get_guard( locationt from, locationt to) const @@ -37,6 +46,18 @@ exprt flow_insensitive_abstract_domain_baset::get_guard( return from->guard; } +/*******************************************************************\ + +Function: flow_insensitive_abstract_domain_baset::get_return_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt flow_insensitive_abstract_domain_baset::get_return_lhs(locationt to) const { // get predecessor of "to" @@ -55,6 +76,18 @@ exprt flow_insensitive_abstract_domain_baset::get_return_lhs(locationt to) const return code.lhs(); } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::operator()( const goto_functionst &goto_functions) { @@ -62,6 +95,18 @@ void flow_insensitive_analysis_baset::operator()( fixedpoint(goto_functions); } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::operator()( const goto_programt &goto_program) { @@ -70,6 +115,18 @@ void flow_insensitive_analysis_baset::operator()( fixedpoint(goto_program, goto_functions); } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::output( const goto_functionst &goto_functions, std::ostream &out) @@ -85,6 +142,18 @@ void flow_insensitive_analysis_baset::output( } } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::output( const goto_programt &goto_program, const irep_idt &identifier, @@ -93,6 +162,18 @@ void flow_insensitive_analysis_baset::output( get_state().output(ns, out); } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::get_next + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + flow_insensitive_analysis_baset::locationt flow_insensitive_analysis_baset::get_next( working_sett &working_set) @@ -110,6 +191,18 @@ flow_insensitive_analysis_baset::get_next( return l; } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool flow_insensitive_analysis_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions) @@ -138,6 +231,18 @@ bool flow_insensitive_analysis_baset::fixedpoint( return new_data; } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::visit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool flow_insensitive_analysis_baset::visit( locationt l, working_sett &working_set, @@ -205,6 +310,18 @@ bool flow_insensitive_analysis_baset::visit( return new_data; } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool flow_insensitive_analysis_baset::do_function_call( locationt l_call, const goto_functionst &goto_functions, @@ -285,6 +402,18 @@ bool flow_insensitive_analysis_baset::do_function_call( return new_data; } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::do_function_call_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool flow_insensitive_analysis_baset::do_function_call_rec( locationt l_call, const exprt &function, @@ -394,6 +523,18 @@ bool flow_insensitive_analysis_baset::do_function_call_rec( return new_data; } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::fixedpoint( const goto_functionst &goto_functions) { @@ -407,6 +548,18 @@ void flow_insensitive_analysis_baset::fixedpoint( } } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool flow_insensitive_analysis_baset::fixedpoint( const goto_functionst::function_mapt::const_iterator it, const goto_functionst &goto_functions) @@ -415,12 +568,36 @@ bool flow_insensitive_analysis_baset::fixedpoint( return fixedpoint(it->second.body, goto_functions); } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::update( const goto_functionst &goto_functions) { // no need to copy value sets around } +/*******************************************************************\ + +Function: flow_insensitive_analysis_baset::update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void flow_insensitive_analysis_baset::update( const goto_programt &goto_program) { diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index bf06cf90cdf..07d1f0f77cd 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Flow Insensitive Static Analysis - #ifndef CPROVER_ANALYSES_FLOW_INSENSITIVE_ANALYSIS_H #define CPROVER_ANALYSES_FLOW_INSENSITIVE_ANALYSIS_H diff --git a/src/analyses/global_may_alias.cpp b/src/analyses/global_may_alias.cpp index 28fabae92b4..33ad0f7f186 100644 --- a/src/analyses/global_may_alias.cpp +++ b/src/analyses/global_may_alias.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive gobal may alias analysis - #include "global_may_alias.h" +/*******************************************************************\ + +Function: global_may_alias_domaint::assign_lhs_aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void global_may_alias_domaint::assign_lhs_aliases( const exprt &lhs, const std::set &alias_set) @@ -28,6 +37,18 @@ void global_may_alias_domaint::assign_lhs_aliases( } } +/*******************************************************************\ + +Function: global_may_alias_domaint::get_rhs_aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void global_may_alias_domaint::get_rhs_aliases( const exprt &rhs, std::set &alias_set) @@ -56,6 +77,18 @@ void global_may_alias_domaint::get_rhs_aliases( } } +/*******************************************************************\ + +Function: global_may_alias_domaint::get_rhs_aliases_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void global_may_alias_domaint::get_rhs_aliases_address_of( const exprt &rhs, std::set &alias_set) @@ -75,6 +108,18 @@ void global_may_alias_domaint::get_rhs_aliases_address_of( } } +/*******************************************************************\ + +Function: global_may_alias_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void global_may_alias_domaint::transform( locationt from, locationt to, @@ -118,6 +163,18 @@ void global_may_alias_domaint::transform( } } +/*******************************************************************\ + +Function: global_may_alias_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void global_may_alias_domaint::output( std::ostream &out, const ai_baset &ai, @@ -156,6 +213,18 @@ void global_may_alias_domaint::output( } } +/*******************************************************************\ + +Function: global_may_alias_domaint::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool global_may_alias_domaint::merge( const global_may_alias_domaint &b, locationt from, diff --git a/src/analyses/global_may_alias.h b/src/analyses/global_may_alias.h index d946b371c05..2f4a49b2d0a 100644 --- a/src/analyses/global_may_alias.h +++ b/src/analyses/global_may_alias.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive, over-approximative escape analysis - #ifndef CPROVER_ANALYSES_GLOBAL_MAY_ALIAS_H #define CPROVER_ANALYSES_GLOBAL_MAY_ALIAS_H @@ -19,6 +16,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "ai.h" +/*******************************************************************\ + + Class: global_may_alias_domaint + + Purpose: + +\*******************************************************************/ + class global_may_alias_analysist; class global_may_alias_domaint:public ai_domain_baset diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index 0f668016b21..a6871b94d23 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// GOTO Programs - #include #include @@ -139,6 +136,18 @@ class goto_checkt error_labelst error_labels; }; +/*******************************************************************\ + +Function: goto_checkt::invalidate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::invalidate(const exprt &lhs) { if(lhs.id()==ID_index) @@ -173,6 +182,18 @@ void goto_checkt::invalidate(const exprt &lhs) } } +/*******************************************************************\ + +Function: goto_checkt::div_by_zero_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::div_by_zero_check( const div_exprt &expr, const guardt &guard) @@ -199,6 +220,18 @@ void goto_checkt::div_by_zero_check( guard); } +/*******************************************************************\ + +Function: goto_checkt::undefined_shift_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::undefined_shift_check( const shift_exprt &expr, const guardt &guard) @@ -250,6 +283,18 @@ void goto_checkt::undefined_shift_check( } } +/*******************************************************************\ + +Function: goto_checkt::mod_by_zero_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::mod_by_zero_check( const mod_exprt &expr, const guardt &guard) @@ -276,6 +321,18 @@ void goto_checkt::mod_by_zero_check( guard); } +/*******************************************************************\ + +Function: goto_checkt::conversion_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::conversion_check( const exprt &expr, const guardt &guard) @@ -455,6 +512,18 @@ void goto_checkt::conversion_check( } } +/*******************************************************************\ + +Function: goto_checkt::integer_overflow_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::integer_overflow_check( const exprt &expr, const guardt &guard) @@ -576,6 +645,18 @@ void goto_checkt::integer_overflow_check( } } +/*******************************************************************\ + +Function: goto_checkt::float_overflow_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::float_overflow_check( const exprt &expr, const guardt &guard) @@ -698,6 +779,18 @@ void goto_checkt::float_overflow_check( } } +/*******************************************************************\ + +Function: goto_checkt::nan_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::nan_check( const exprt &expr, const guardt &guard) @@ -807,6 +900,18 @@ void goto_checkt::nan_check( guard); } +/*******************************************************************\ + +Function: goto_checkt::pointer_rel_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::pointer_rel_check( const exprt &expr, const guardt &guard) @@ -837,6 +942,18 @@ void goto_checkt::pointer_rel_check( } } +/*******************************************************************\ + +Function: goto_checkt::pointer_overflow_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::pointer_overflow_check( const exprt &expr, const guardt &guard) @@ -863,6 +980,18 @@ void goto_checkt::pointer_overflow_check( } } +/*******************************************************************\ + +Function: goto_checkt::pointer_validity_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::pointer_validity_check( const dereference_exprt &expr, const guardt &guard, @@ -991,11 +1120,35 @@ void goto_checkt::pointer_validity_check( } } +/*******************************************************************\ + +Function: goto_checkt::array_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string goto_checkt::array_name(const exprt &expr) { return ::array_name(ns, expr); } +/*******************************************************************\ + +Function: goto_checkt::bounds_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::bounds_check( const index_exprt &expr, const guardt &guard) @@ -1150,6 +1303,18 @@ void goto_checkt::bounds_check( } } +/*******************************************************************\ + +Function: goto_checkt::add_guarded_claim + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::add_guarded_claim( const exprt &_expr, const std::string &comment, @@ -1197,6 +1362,18 @@ void goto_checkt::add_guarded_claim( } } +/*******************************************************************\ + +Function: goto_checkt::check_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::check_rec( const exprt &expr, guardt &guard, @@ -1377,12 +1554,36 @@ void goto_checkt::check_rec( mode); } +/*******************************************************************\ + +Function: goto_checkt::check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::check(const exprt &expr, const irep_idt &mode) { guardt guard; check_rec(expr, guard, false, mode); } +/*******************************************************************\ + +Function: goto_checkt::goto_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_checkt::goto_check( goto_functiont &goto_function, const irep_idt &mode) @@ -1640,6 +1841,18 @@ void goto_checkt::goto_check( } } +/*******************************************************************\ + +Function: goto_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_check( const namespacet &ns, const optionst &options, @@ -1649,6 +1862,18 @@ void goto_check( goto_check.goto_check(goto_function, irep_idt()); } +/*******************************************************************\ + +Function: goto_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_check( const namespacet &ns, const optionst &options, @@ -1663,6 +1888,18 @@ void goto_check( } } +/*******************************************************************\ + +Function: goto_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_check( const optionst &options, goto_modelt &goto_model) diff --git a/src/analyses/goto_check.h b/src/analyses/goto_check.h index 44d98069de9..2089d744fd2 100644 --- a/src/analyses/goto_check.h +++ b/src/analyses/goto_check.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #ifndef CPROVER_ANALYSES_GOTO_CHECK_H #define CPROVER_ANALYSES_GOTO_CHECK_H diff --git a/src/analyses/goto_rw.cpp b/src/analyses/goto_rw.cpp index 0b86a19ef63..e5df484cb9c 100644 --- a/src/analyses/goto_rw.cpp +++ b/src/analyses/goto_rw.cpp @@ -25,10 +25,34 @@ Date: April 2010 #include "goto_rw.h" +/*******************************************************************\ + +Function: range_domain_baset::~range_domain_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + range_domain_baset::~range_domain_baset() { } +/*******************************************************************\ + +Function: range_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void range_domaint::output( const namespacet &ns, std::ostream &out) const { @@ -44,6 +68,18 @@ void range_domaint::output( out << "]"; } +/*******************************************************************\ + +Function: rw_range_sett::~rw_range_sett + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rw_range_sett::~rw_range_sett() { for(rw_range_sett::objectst::iterator it=r_range_set.begin(); @@ -57,6 +93,18 @@ rw_range_sett::~rw_range_sett() delete it->second; } +/*******************************************************************\ + +Function: rw_range_sett::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::output(std::ostream &out) const { out << "READ:" << std::endl; @@ -78,6 +126,18 @@ void rw_range_sett::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_complex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_complex( get_modet mode, const exprt &expr, @@ -95,6 +155,18 @@ void rw_range_sett::get_objects_complex( get_objects_rec(mode, op, range_start+offset, size); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_if( get_modet mode, const if_exprt &if_expr, @@ -114,6 +186,18 @@ void rw_range_sett::get_objects_if( } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_dereference( get_modet mode, const dereference_exprt &deref, @@ -126,6 +210,18 @@ void rw_range_sett::get_objects_dereference( get_objects_rec(mode, pointer); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_byte_extract( get_modet mode, const byte_extract_exprt &be, @@ -153,6 +249,18 @@ void rw_range_sett::get_objects_byte_extract( } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_shift + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_shift( get_modet mode, const shift_exprt &shift, @@ -201,6 +309,18 @@ void rw_range_sett::get_objects_shift( } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_member( get_modet mode, const member_exprt &expr, @@ -231,6 +351,18 @@ void rw_range_sett::get_objects_member( get_objects_rec(mode, expr.struct_op(), offset, size); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_index( get_modet mode, const index_exprt &expr, @@ -279,6 +411,18 @@ void rw_range_sett::get_objects_index( size); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_array( get_modet mode, const array_exprt &expr, @@ -319,6 +463,18 @@ void rw_range_sett::get_objects_array( } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_struct( get_modet mode, const struct_exprt &expr, @@ -379,6 +535,18 @@ void rw_range_sett::get_objects_struct( } } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_typecast( get_modet mode, const typecast_exprt &tc, @@ -404,6 +572,18 @@ void rw_range_sett::get_objects_typecast( get_objects_rec(mode, op, range_start, new_size); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_address_of(const exprt &object) { if(object.id()==ID_string_constant || @@ -454,6 +634,18 @@ void rw_range_sett::get_objects_address_of(const exprt &object) throw "rw_range_sett: address_of `"+object.id_string()+"' not handled"; } +/*******************************************************************\ + +Function: rw_range_sett::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::add( get_modet mode, const irep_idt &identifier, @@ -471,6 +663,18 @@ void rw_range_sett::add( std::make_pair(range_start, range_end)); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_rec( get_modet mode, const exprt &expr, @@ -562,6 +766,18 @@ void rw_range_sett::get_objects_rec( throw "rw_range_sett: assignment to `"+expr.id_string()+"' not handled"; } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_rec(get_modet mode, const exprt &expr) { range_spect size= @@ -569,6 +785,18 @@ void rw_range_sett::get_objects_rec(get_modet mode, const exprt &expr) get_objects_rec(mode, expr, 0, size); } +/*******************************************************************\ + +Function: rw_range_sett::get_objects_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_sett::get_objects_rec(const typet &type) { // TODO should recurse into various composite types @@ -579,6 +807,18 @@ void rw_range_sett::get_objects_rec(const typet &type) } } +/*******************************************************************\ + +Function: rw_range_set_value_sett::get_objects_dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_range_set_value_sett::get_objects_dereference( get_modet mode, const dereference_exprt &deref, @@ -612,6 +852,18 @@ void rw_range_set_value_sett::get_objects_dereference( get_objects_rec(mode, object, range_start, new_size); } +/*******************************************************************\ + +Function: guarded_range_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void guarded_range_domaint::output( const namespacet &ns, std::ostream &out) const { @@ -628,6 +880,18 @@ void guarded_range_domaint::output( out << "]"; } +/*******************************************************************\ + +Function: rw_guarded_range_set_value_sett::get_objects_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_guarded_range_set_value_sett::get_objects_if( get_modet mode, const if_exprt &if_expr, @@ -654,6 +918,18 @@ void rw_guarded_range_set_value_sett::get_objects_if( } } +/*******************************************************************\ + +Function: rw_guarded_range_set_value_sett::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_guarded_range_set_value_sett::add( get_modet mode, const irep_idt &identifier, @@ -672,6 +948,18 @@ void rw_guarded_range_set_value_sett::add( std::make_pair(range_end, guard.as_expr()))); } +/*******************************************************************\ + +Function: goto_rw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_rw(goto_programt::const_targett target, const code_assignt &assign, rw_range_sett &rw_set) @@ -680,6 +968,18 @@ void goto_rw(goto_programt::const_targett target, rw_set.get_objects_rec(target, rw_range_sett::get_modet::READ, assign.rhs()); } +/*******************************************************************\ + +Function: goto_rw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_rw(goto_programt::const_targett target, const code_function_callt &function_call, rw_range_sett &rw_set) @@ -699,6 +999,18 @@ void goto_rw(goto_programt::const_targett target, rw_set.get_objects_rec(target, rw_range_sett::get_modet::READ, *it); } +/*******************************************************************\ + +Function: goto_rw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_rw(goto_programt::const_targett target, rw_range_sett &rw_set) { @@ -776,12 +1088,36 @@ void goto_rw(goto_programt::const_targett target, } } +/*******************************************************************\ + +Function: goto_rw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_rw(const goto_programt &goto_program, rw_range_sett &rw_set) { forall_goto_program_instructions(i_it, goto_program) goto_rw(i_it, rw_set); } +/*******************************************************************\ + +Function: goto_rw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_rw(const goto_functionst &goto_functions, const irep_idt &function, rw_range_sett &rw_set) diff --git a/src/analyses/interval_analysis.cpp b/src/analyses/interval_analysis.cpp index d81d857b1f8..17c3dd68562 100644 --- a/src/analyses/interval_analysis.cpp +++ b/src/analyses/interval_analysis.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interval Analysis - #include #include "interval_domain.h" #include "interval_analysis.h" +/*******************************************************************\ + +Function: instrument_intervals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrument_intervals( const ait &interval_analysis, goto_functionst::goto_functiont &goto_function) @@ -75,6 +84,18 @@ void instrument_intervals( } } +/*******************************************************************\ + +Function: interval_analysis + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_analysis( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/analyses/interval_analysis.h b/src/analyses/interval_analysis.h index 1c85fc9a193..be86a6c65f8 100644 --- a/src/analyses/interval_analysis.h +++ b/src/analyses/interval_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interval Analysis - #ifndef CPROVER_ANALYSES_INTERVAL_ANALYSIS_H #define CPROVER_ANALYSES_INTERVAL_ANALYSIS_H diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index 3c0e0c1a893..1faf8c52364 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interval Domain - #ifdef DEBUG #include #endif @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "interval_domain.h" +/*******************************************************************\ + +Function: interval_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::output( std::ostream &out, const ai_baset &ai, @@ -55,6 +64,18 @@ void interval_domaint::output( } } +/*******************************************************************\ + +Function: interval_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::transform( locationt from, locationt to, @@ -106,6 +127,18 @@ void interval_domaint::transform( } } +/*******************************************************************\ + +Function: interval_domaint::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool interval_domaint::merge( const interval_domaint &b, locationt from, @@ -166,12 +199,36 @@ bool interval_domaint::merge( return result; } +/*******************************************************************\ + +Function: interval_domaint::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::assign(const code_assignt &code_assign) { havoc_rec(code_assign.lhs()); assume_rec(code_assign.lhs(), ID_equal, code_assign.rhs()); } +/*******************************************************************\ + +Function: interval_domaint::havoc_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::havoc_rec(const exprt &lhs) { if(lhs.id()==ID_if) @@ -194,6 +251,18 @@ void interval_domaint::havoc_rec(const exprt &lhs) } } +/*******************************************************************\ + +Function: interval_domaint::assume_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::assume_rec( const exprt &lhs, irep_idt id, const exprt &rhs) { @@ -308,6 +377,18 @@ void interval_domaint::assume_rec( } } +/*******************************************************************\ + +Function: interval_domaint::assume_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::assume( const exprt &cond, const namespacet &ns) @@ -315,6 +396,18 @@ void interval_domaint::assume( assume_rec(simplify_expr(cond, ns), false); } +/*******************************************************************\ + +Function: interval_domaint::assume_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interval_domaint::assume_rec( const exprt &cond, bool negation) @@ -361,6 +454,18 @@ void interval_domaint::assume_rec( } } +/*******************************************************************\ + +Function: interval_domaint::make_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt interval_domaint::make_expression(const symbol_exprt &src) const { if(is_int(src.type())) diff --git a/src/analyses/interval_domain.h b/src/analyses/interval_domain.h index 81be5ec7d54..7e95c65e9de 100644 --- a/src/analyses/interval_domain.h +++ b/src/analyses/interval_domain.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interval Domain - #ifndef CPROVER_ANALYSES_INTERVAL_DOMAIN_H #define CPROVER_ANALYSES_INTERVAL_DOMAIN_H diff --git a/src/analyses/invariant_propagation.cpp b/src/analyses/invariant_propagation.cpp index 8e93ce4ee17..2da2d7278f4 100644 --- a/src/analyses/invariant_propagation.cpp +++ b/src/analyses/invariant_propagation.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Invariant Propagation - #include #include #include @@ -16,18 +13,54 @@ Author: Daniel Kroening, kroening@kroening.com #include "invariant_propagation.h" +/*******************************************************************\ + +Function: invariant_propagationt::make_all_true + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::make_all_true() { for(auto &state : state_map) state.second.invariant_set.make_true(); } +/*******************************************************************\ + +Function: invariant_propagationt::make_all_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::make_all_false() { for(auto &state : state_map) state.second.invariant_set.make_false(); } +/*******************************************************************\ + +Function: invariant_propagationt::add_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::add_objects( const goto_programt &goto_program) { @@ -75,6 +108,18 @@ void invariant_propagationt::add_objects( } } +/*******************************************************************\ + +Function: invariant_propagationt::get_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::get_objects( const symbolt &symbol, object_listt &dest) @@ -87,6 +132,18 @@ void invariant_propagationt::get_objects( dest.push_back(object_store.add(expr)); } +/*******************************************************************\ + +Function: invariant_propagationt::get_objects_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::get_objects_rec( const exprt &src, std::list &dest) @@ -122,6 +179,18 @@ void invariant_propagationt::get_objects_rec( } } +/*******************************************************************\ + +Function: invariant_propagationt::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::add_objects( const goto_functionst &goto_functions) { @@ -174,6 +243,18 @@ void invariant_propagationt::add_objects( } } +/*******************************************************************\ + +Function: invariant_propagationt::get_globals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::get_globals( object_listt &dest) { @@ -184,6 +265,18 @@ void invariant_propagationt::get_globals( get_objects(it->second, dest); } +/*******************************************************************\ + +Function: invariant_propagationt::check_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool invariant_propagationt::check_type(const typet &type) const { if(type.id()==ID_pointer) @@ -204,6 +297,18 @@ bool invariant_propagationt::check_type(const typet &type) const return false; } +/*******************************************************************\ + +Function: invariant_propagationt::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::initialize(const goto_programt &goto_program) { baset::initialize(goto_program); @@ -225,6 +330,18 @@ void invariant_propagationt::initialize(const goto_programt &goto_program) add_objects(goto_program); } +/*******************************************************************\ + +Function: invariant_propagationt::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::initialize(const goto_functionst &goto_functions) { baset::initialize(goto_functions); @@ -233,12 +350,36 @@ void invariant_propagationt::initialize(const goto_functionst &goto_functions) initialize(f_it->second.body); } +/*******************************************************************\ + +Function: invariant_propagationt::simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::simplify(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) simplify(it->second.body); } +/*******************************************************************\ + +Function: invariant_propagationt::simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_propagationt::simplify(goto_programt &goto_program) { Forall_goto_program_instructions(i_it, goto_program) diff --git a/src/analyses/invariant_propagation.h b/src/analyses/invariant_propagation.h index d21f6373bcb..0884ba85d07 100644 --- a/src/analyses/invariant_propagation.h +++ b/src/analyses/invariant_propagation.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Invariant Propagation - #ifndef CPROVER_ANALYSES_INVARIANT_PROPAGATION_H #define CPROVER_ANALYSES_INVARIANT_PROPAGATION_H diff --git a/src/analyses/invariant_set.cpp b/src/analyses/invariant_set.cpp index acd7f99459a..15c350f0e0f 100644 --- a/src/analyses/invariant_set.cpp +++ b/src/analyses/invariant_set.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Invariant Set - #include #include @@ -24,12 +21,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "invariant_set.h" +/*******************************************************************\ + +Function: inv_object_storet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inv_object_storet::output(std::ostream &out) const { for(unsigned i=0; iget(expr, n); } +/*******************************************************************\ + +Function: inv_object_storet::is_constant_address + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool inv_object_storet::is_constant_address(const exprt &expr) { if(expr.id()==ID_address_of) @@ -157,6 +250,18 @@ bool inv_object_storet::is_constant_address(const exprt &expr) return false; } +/*******************************************************************\ + +Function: inv_object_storet::is_constant_address_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool inv_object_storet::is_constant_address_rec(const exprt &expr) { if(expr.id()==ID_symbol) @@ -176,6 +281,18 @@ bool inv_object_storet::is_constant_address_rec(const exprt &expr) return false; } +/*******************************************************************\ + +Function: invariant_sett::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::add( const std::pair &p, ineq_sett &dest) @@ -198,6 +315,18 @@ void invariant_sett::add( } } +/*******************************************************************\ + +Function: invariant_sett::add_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::add_eq(const std::pair &p) { eq_set.make_union(p.first, p.second); @@ -235,6 +364,18 @@ void invariant_sett::add_eq(const std::pair &p) add_eq(ne_set, p, ne); } +/*******************************************************************\ + +Function: invariant_sett::add_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::add_eq( ineq_sett &dest, const std::pair &eq, @@ -273,6 +414,18 @@ void invariant_sett::add_eq( } } +/*******************************************************************\ + +Function: invariant_sett::is_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt invariant_sett::is_eq(std::pair p) const { std::pair s=p; @@ -287,6 +440,18 @@ tvt invariant_sett::is_eq(std::pair p) const return tvt::unknown(); } +/*******************************************************************\ + +Function: invariant_sett::is_le + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt invariant_sett::is_le(std::pair p) const { std::pair s=p; @@ -305,6 +470,18 @@ tvt invariant_sett::is_le(std::pair p) const return tvt::unknown(); } +/*******************************************************************\ + +Function: invariant_sett::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::output( const irep_idt &identifier, std::ostream &out) const @@ -358,6 +535,18 @@ void invariant_sett::output( } } +/*******************************************************************\ + +Function: invariant_sett::strengthen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) { if(expr.type()==type) @@ -378,6 +567,18 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) } } +/*******************************************************************\ + +Function: invariant_sett::strengthen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::strengthen(const exprt &expr) { exprt tmp(expr); @@ -385,6 +586,18 @@ void invariant_sett::strengthen(const exprt &expr) strengthen_rec(tmp); } +/*******************************************************************\ + +Function: invariant_sett::strengthen_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::strengthen_rec(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -586,6 +799,18 @@ void invariant_sett::strengthen_rec(const exprt &expr) } } +/*******************************************************************\ + +Function: invariant_sett::implies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt invariant_sett::implies(const exprt &expr) const { exprt tmp(expr); @@ -593,6 +818,18 @@ tvt invariant_sett::implies(const exprt &expr) const return implies_rec(tmp); } +/*******************************************************************\ + +Function: invariant_sett::implies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt invariant_sett::implies_rec(const exprt &expr) const { if(expr.type().id()!=ID_bool) @@ -677,6 +914,18 @@ tvt invariant_sett::implies_rec(const exprt &expr) const return tvt::unknown(); } +/*******************************************************************\ + +Function: invariant_sett::get_bounds + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::get_bounds(unsigned a, boundst &bounds) const { // unbounded @@ -701,6 +950,18 @@ void invariant_sett::get_bounds(unsigned a, boundst &bounds) const bounds=it->second; } +/*******************************************************************\ + +Function: invariant_sett::nnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::nnf(exprt &expr, bool negate) { if(expr.type().id()!=ID_bool) @@ -814,6 +1075,18 @@ void invariant_sett::nnf(exprt &expr, bool negate) } } +/*******************************************************************\ + +Function: invariant_sett::simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::simplify( exprt &expr) const { @@ -832,6 +1105,18 @@ void invariant_sett::simplify( } } +/*******************************************************************\ + +Function: invariant_sett::get_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt invariant_sett::get_constant(const exprt &expr) const { unsigned a; @@ -887,6 +1172,18 @@ exprt invariant_sett::get_constant(const exprt &expr) const return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: inv_object_storet::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string inv_object_storet::to_string( unsigned a, const irep_idt &identifier) const @@ -895,6 +1192,18 @@ std::string inv_object_storet::to_string( return id2string(map[a]); } +/*******************************************************************\ + +Function: invariant_sett::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string invariant_sett::to_string( unsigned a, const irep_idt &identifier) const @@ -903,6 +1212,18 @@ std::string invariant_sett::to_string( return object_store->to_string(a, identifier); } +/*******************************************************************\ + +Function: invariant_sett::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool invariant_sett::make_union(const invariant_sett &other) { if(other.threaded && @@ -954,6 +1275,18 @@ bool invariant_sett::make_union(const invariant_sett &other) return false; // no change } +/*******************************************************************\ + +Function: invariant_sett::make_union_bounds_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) { bool changed=false; @@ -986,6 +1319,18 @@ bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) return changed; } +/*******************************************************************\ + +Function: invariant_sett::modifies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::modifies(unsigned a) { eq_set.isolate(a); @@ -994,6 +1339,18 @@ void invariant_sett::modifies(unsigned a) bounds_map.erase(a); } +/*******************************************************************\ + +Function: invariant_sett::modifies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::modifies(const exprt &lhs) { if(lhs.id()==ID_symbol || @@ -1054,6 +1411,18 @@ void invariant_sett::modifies(const exprt &lhs) throw "modifies: unexpected lhs: "+lhs.id_string(); } +/*******************************************************************\ + +Function: invariant_sett::assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::assignment( const exprt &lhs, const exprt &rhs) @@ -1073,6 +1442,18 @@ void invariant_sett::assignment( strengthen(equality); } +/*******************************************************************\ + +Function: invariant_sett::apply_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_sett::apply_code(const codet &code) { const irep_idt &statement=code.get(ID_statement); diff --git a/src/analyses/invariant_set.h b/src/analyses/invariant_set.h index 6def40f54a8..d5f0a31003c 100644 --- a/src/analyses/invariant_set.h +++ b/src/analyses/invariant_set.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_ANALYSES_INVARIANT_SET_H #define CPROVER_ANALYSES_INVARIANT_SET_H diff --git a/src/analyses/invariant_set_domain.cpp b/src/analyses/invariant_set_domain.cpp index 6dec2f9ff70..5f8512c55b5 100644 --- a/src/analyses/invariant_set_domain.cpp +++ b/src/analyses/invariant_set_domain.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Invariant Set Domain - #include #include "invariant_set_domain.h" +/*******************************************************************\ + +Function: invariant_set_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void invariant_set_domaint::transform( locationt from_l, locationt to_l, diff --git a/src/analyses/invariant_set_domain.h b/src/analyses/invariant_set_domain.h index 4d38b6b2657..2e231524cbb 100644 --- a/src/analyses/invariant_set_domain.h +++ b/src/analyses/invariant_set_domain.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_ANALYSES_INVARIANT_SET_DOMAIN_H #define CPROVER_ANALYSES_INVARIANT_SET_DOMAIN_H diff --git a/src/analyses/is_threaded.cpp b/src/analyses/is_threaded.cpp index 64b1e48f959..905cd6b91ac 100644 --- a/src/analyses/is_threaded.cpp +++ b/src/analyses/is_threaded.cpp @@ -8,9 +8,6 @@ Date: October 2012 \*******************************************************************/ -/// \file -/// Over-approximate Concurrency for Threaded Goto Programs - #include "ai.h" #include "is_threaded.h" @@ -81,6 +78,18 @@ class is_threaded_domaint:public ai_domain_baset } }; +/*******************************************************************\ + +Function: is_threadedt::compute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void is_threadedt::compute(const goto_functionst &goto_functions) { // the analysis doesn't actually use the namespace, fake one diff --git a/src/analyses/is_threaded.h b/src/analyses/is_threaded.h index 5a3823b867e..738857b8b8a 100644 --- a/src/analyses/is_threaded.h +++ b/src/analyses/is_threaded.h @@ -8,9 +8,6 @@ Date: October 2012 \*******************************************************************/ -/// \file -/// Over-approximate Concurrency for Threaded Goto Programs - #ifndef CPROVER_ANALYSES_IS_THREADED_H #define CPROVER_ANALYSES_IS_THREADED_H diff --git a/src/analyses/local_bitvector_analysis.cpp b/src/analyses/local_bitvector_analysis.cpp index c213885efd7..3fc0d10bb09 100644 --- a/src/analyses/local_bitvector_analysis.cpp +++ b/src/analyses/local_bitvector_analysis.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive may-alias analysis - #include #include @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "local_bitvector_analysis.h" +/*******************************************************************\ + +Function: local_bitvector_analysist::flagst::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_bitvector_analysist::flagst::print(std::ostream &out) const { if(is_unknown()) @@ -41,6 +50,18 @@ void local_bitvector_analysist::flagst::print(std::ostream &out) const out << "+integer_address"; } +/*******************************************************************\ + +Function: local_bitvector_analysist::loc_infot::merge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) { bool result=false; @@ -57,7 +78,19 @@ bool local_bitvector_analysist::loc_infot::merge(const loc_infot &src) return result; } -/// \return return 'true' iff we track the object with given identifier +/*******************************************************************\ + +Function: local_bitvector_analysist::is_tracked + + Inputs: + + Outputs: return 'true' iff we track the object with given + identifier + + Purpose: + +\*******************************************************************/ + bool local_bitvector_analysist::is_tracked(const irep_idt &identifier) { localst::locals_mapt::const_iterator it=locals.locals_map.find(identifier); @@ -69,6 +102,18 @@ bool local_bitvector_analysist::is_tracked(const irep_idt &identifier) return true; } +/*******************************************************************\ + +Function: local_bitvector_analysist::assign_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_bitvector_analysist::assign_lhs( const exprt &lhs, const exprt &rhs, @@ -109,6 +154,18 @@ void local_bitvector_analysist::assign_lhs( } } +/*******************************************************************\ + +Function: local_bitvector_analysist::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + local_bitvector_analysist::flagst local_bitvector_analysist::get( const goto_programt::const_targett t, const exprt &rhs) @@ -122,6 +179,18 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get( return get_rec(rhs, loc_info_src); } +/*******************************************************************\ + +Function: local_bitvector_analysist::get_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( const exprt &rhs, const loc_infot &loc_info_src) @@ -243,6 +312,18 @@ local_bitvector_analysist::flagst local_bitvector_analysist::get_rec( return flagst::mk_unknown(); } +/*******************************************************************\ + +Function: local_bitvector_analysist::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_bitvector_analysist::build(const goto_functiont &goto_function) { if(cfg.nodes.empty()) @@ -325,6 +406,18 @@ void local_bitvector_analysist::build(const goto_functiont &goto_function) } } +/*******************************************************************\ + +Function: local_bitvector_analysist::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_bitvector_analysist::output( std::ostream &out, const goto_functiont &goto_function, diff --git a/src/analyses/local_bitvector_analysis.h b/src/analyses/local_bitvector_analysis.h index a88b38fb1c6..4284ec99475 100644 --- a/src/analyses/local_bitvector_analysis.h +++ b/src/analyses/local_bitvector_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive bitvector analysis - #ifndef CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H #define CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H @@ -20,6 +17,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "dirty.h" #include "local_cfg.h" +/*******************************************************************\ + + Class: local_bitvector_analysist + + Purpose: + +\*******************************************************************/ + class local_bitvector_analysist { public: diff --git a/src/analyses/local_cfg.cpp b/src/analyses/local_cfg.cpp index b65dbafd97e..52f5c6831a4 100644 --- a/src/analyses/local_cfg.cpp +++ b/src/analyses/local_cfg.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CFG for One Function - #if 0 #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "local_cfg.h" +/*******************************************************************\ + +Function: local_cfgt::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_cfgt::build(const goto_programt &goto_program) { nodes.resize(goto_program.instructions.size()); diff --git a/src/analyses/local_cfg.h b/src/analyses/local_cfg.h index d2e53cfdab0..a0187be8177 100644 --- a/src/analyses/local_cfg.h +++ b/src/analyses/local_cfg.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CFG for One Function - #ifndef CPROVER_ANALYSES_LOCAL_CFG_H #define CPROVER_ANALYSES_LOCAL_CFG_H @@ -16,6 +13,14 @@ Author: Daniel Kroening, kroening@kroening.com #include +/*******************************************************************\ + + Class: local_cfgt + + Purpose: + +\*******************************************************************/ + class local_cfgt { public: diff --git a/src/analyses/local_may_alias.cpp b/src/analyses/local_may_alias.cpp index aa50af1487d..ffaefe73667 100644 --- a/src/analyses/local_may_alias.cpp +++ b/src/analyses/local_may_alias.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive may-alias analysis - #include #include @@ -21,7 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "local_may_alias.h" -/// \return return 'true' iff changed +/*******************************************************************\ + +Function: local_may_aliast::loc_infot::merge + + Inputs: + + Outputs: return 'true' iff changed + + Purpose: + +\*******************************************************************/ + bool local_may_aliast::loc_infot::merge(const loc_infot &src) { bool changed=false; @@ -41,6 +49,18 @@ bool local_may_aliast::loc_infot::merge(const loc_infot &src) return changed; } +/*******************************************************************\ + +Function: local_may_aliast::assign_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_may_aliast::assign_lhs( const exprt &lhs, const exprt &rhs, @@ -112,6 +132,18 @@ void local_may_aliast::assign_lhs( } } +/*******************************************************************\ + +Function: local_may_aliast::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set local_may_aliast::get( const goto_programt::const_targett t, const exprt &rhs) const @@ -138,6 +170,18 @@ std::set local_may_aliast::get( return result; } +/*******************************************************************\ + +Function: local_may_aliast::aliases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool local_may_aliast::aliases( const goto_programt::const_targett t, const exprt &src1, const exprt &src2) const @@ -166,6 +210,18 @@ bool local_may_aliast::aliases( return !result.empty(); } +/*******************************************************************\ + +Function: local_may_aliast::get_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_may_aliast::get_rec( object_sett &dest, const exprt &rhs, @@ -313,6 +369,18 @@ void local_may_aliast::get_rec( dest.insert(unknown_object); } +/*******************************************************************\ + +Function: local_may_aliast::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_may_aliast::build(const goto_functiont &goto_function) { if(cfg.nodes.empty()) @@ -434,6 +502,18 @@ void local_may_aliast::build(const goto_functiont &goto_function) } } +/*******************************************************************\ + +Function: local_may_aliast::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void local_may_aliast::output( std::ostream &out, const goto_functiont &goto_function, diff --git a/src/analyses/local_may_alias.h b/src/analyses/local_may_alias.h index b54cf4e9e88..109ca2b5e19 100644 --- a/src/analyses/local_may_alias.h +++ b/src/analyses/local_may_alias.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-insensitive, location-sensitive may-alias analysis - #ifndef CPROVER_ANALYSES_LOCAL_MAY_ALIAS_H #define CPROVER_ANALYSES_LOCAL_MAY_ALIAS_H @@ -21,6 +18,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "dirty.h" #include "local_cfg.h" +/*******************************************************************\ + + Class: local_may_aliast + + Purpose: + +\*******************************************************************/ + class local_may_aliast { public: diff --git a/src/analyses/locals.cpp b/src/analyses/locals.cpp index 09d7ebfe7c3..7f30c1c008b 100644 --- a/src/analyses/locals.cpp +++ b/src/analyses/locals.cpp @@ -8,13 +8,22 @@ Date: March 2013 \*******************************************************************/ -/// \file -/// Local variables - #include #include "locals.h" +/*******************************************************************\ + +Function: localst::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void localst::build(const goto_functiont &goto_function) { forall_goto_program_instructions(it, goto_function.body) @@ -30,6 +39,18 @@ void localst::build(const goto_functiont &goto_function) symbol_exprt(param.get_identifier(), param.type()); } +/*******************************************************************\ + +Function: localst::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void localst::output(std::ostream &out) const { for(const auto &local : locals_map) diff --git a/src/analyses/locals.h b/src/analyses/locals.h index c9c59aaf340..3cd52254c41 100644 --- a/src/analyses/locals.h +++ b/src/analyses/locals.h @@ -8,9 +8,6 @@ Date: March 2013 \*******************************************************************/ -/// \file -/// Local variables whose address is taken - #ifndef CPROVER_ANALYSES_LOCALS_H #define CPROVER_ANALYSES_LOCALS_H diff --git a/src/analyses/natural_loops.cpp b/src/analyses/natural_loops.cpp index 3832ae6b1ad..593fc78006d 100644 --- a/src/analyses/natural_loops.cpp +++ b/src/analyses/natural_loops.cpp @@ -6,13 +6,22 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ -/// \file -/// Dominators - #include #include "natural_loops.h" +/*******************************************************************\ + +Function: show_natural_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_natural_loops(const goto_functionst &goto_functions) { forall_goto_functions(it, goto_functions) diff --git a/src/analyses/natural_loops.h b/src/analyses/natural_loops.h index ce27a306882..ff56c687c93 100644 --- a/src/analyses/natural_loops.h +++ b/src/analyses/natural_loops.h @@ -6,9 +6,6 @@ Author: Georg Weissenbacher, georg@weissenbacher.name \*******************************************************************/ -/// \file -/// Compute natural loops in a goto_function - #ifndef CPROVER_ANALYSES_NATURAL_LOOPS_H #define CPROVER_ANALYSES_NATURAL_LOOPS_H @@ -72,7 +69,18 @@ typedef natural_loops_templatet void show_natural_loops(const goto_functionst &goto_functions); -/// Finds all back-edges and computes the natural loops +/*******************************************************************\ + +Function: natural_loops_templatet::compute + + Inputs: + + Outputs: + + Purpose: Finds all back-edges and computes the natural loops + +\*******************************************************************/ + #ifdef DEBUG #include #endif @@ -115,7 +123,19 @@ void natural_loops_templatet::compute(P &program) } } -/// Computes the natural loop for a given back-edge (see Muchnick section 7.4) +/*******************************************************************\ + +Function: natural_loops_templatet::compute_natural_loop + + Inputs: + + Outputs: + + Purpose: Computes the natural loop for a given back-edge + (see Muchnick section 7.4) + +\*******************************************************************/ + template void natural_loops_templatet::compute_natural_loop(T m, T n) { @@ -150,7 +170,18 @@ void natural_loops_templatet::compute_natural_loop(T m, T n) } } -/// Print all natural loops that were found +/*******************************************************************\ + +Function: natural_loops_templatet::output + + Inputs: + + Outputs: + + Purpose: Print all natural loops that were found + +\*******************************************************************/ + template void natural_loops_templatet::output(std::ostream &out) const { diff --git a/src/analyses/reaching_definitions.cpp b/src/analyses/reaching_definitions.cpp index de78ef99981..81c3c1c5069 100644 --- a/src/analyses/reaching_definitions.cpp +++ b/src/analyses/reaching_definitions.cpp @@ -9,10 +9,6 @@ Date: February 2013 \*******************************************************************/ -/// \file -/// Range-based reaching definitions analysis (following Field- Sensitive -/// Program Dependence Analysis, Litvak et al., FSE 2010) - #include #include @@ -23,6 +19,18 @@ Date: February 2013 #include "reaching_definitions.h" +/*******************************************************************\ + +Function: rd_range_domaint::populate_cache + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::populate_cache(const irep_idt &identifier) const { assert(bv_container); @@ -43,6 +51,18 @@ void rd_range_domaint::populate_cache(const irep_idt &identifier) const } } +/*******************************************************************\ + +Function: rd_range_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform( locationt from, locationt to, @@ -109,6 +129,18 @@ void rd_range_domaint::transform( #endif } +/*******************************************************************\ + +Function: rd_range_domaint::transform_dead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform_dead( const namespacet &ns, locationt from) @@ -125,6 +157,18 @@ void rd_range_domaint::transform_dead( } } +/*******************************************************************\ + +Function: rd_range_domaint::transform_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform_start_thread( const namespacet &ns, reaching_definitions_analysist &rd) @@ -150,6 +194,18 @@ void rd_range_domaint::transform_start_thread( } } +/*******************************************************************\ + +Function: rd_range_domaint::transform_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform_function_call( const namespacet &ns, locationt from, @@ -213,6 +269,18 @@ void rd_range_domaint::transform_function_call( } } +/*******************************************************************\ + +Function: rd_range_domaint::transform_end_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform_end_function( const namespacet &ns, locationt from, @@ -281,6 +349,18 @@ void rd_range_domaint::transform_end_function( } } +/*******************************************************************\ + +Function: rd_range_domaint::transform_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::transform_assign( const namespacet &ns, locationt from, @@ -314,6 +394,18 @@ void rd_range_domaint::transform_assign( } } +/*******************************************************************\ + +Function: rd_range_domaint::kill + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::kill( const irep_idt &identifier, const range_spect &range_start, @@ -414,6 +506,18 @@ void rd_range_domaint::kill( } } +/*******************************************************************\ + +Function: rd_range_domaint::kill_inf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::kill_inf( const irep_idt &identifier, const range_spect &range_start) @@ -448,6 +552,18 @@ void rd_range_domaint::kill_inf( #endif } +/*******************************************************************\ + +Function: rd_range_domaint::gen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool rd_range_domaint::gen( locationt from, const irep_idt &identifier, @@ -520,6 +636,18 @@ bool rd_range_domaint::gen( return true; } +/*******************************************************************\ + +Function: rd_range_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rd_range_domaint::output(std::ostream &out) const { out << "Reaching definitions:" << std::endl; @@ -559,7 +687,18 @@ void rd_range_domaint::output(std::ostream &out) const } } -/// \return returns true iff there is s.th. new +/*******************************************************************\ + +Function: rd_range_domaint::merge_inner + + Inputs: + + Outputs: returns true iff there is s.th. new + + Purpose: + +\*******************************************************************/ + bool rd_range_domaint::merge_inner( values_innert &dest, const values_innert &other) @@ -610,7 +749,18 @@ bool rd_range_domaint::merge_inner( return more; } -/// \return returns true iff there is s.th. new +/*******************************************************************\ + +Function: rd_range_domaint::merge + + Inputs: + + Outputs: returns true iff there is s.th. new + + Purpose: + +\*******************************************************************/ + bool rd_range_domaint::merge( const rd_range_domaint &other, locationt from, @@ -646,7 +796,18 @@ bool rd_range_domaint::merge( return changed; } -/// \return returns true iff there is s.th. new +/*******************************************************************\ + +Function: rd_range_domaint::merge_shared + + Inputs: + + Outputs: returns true iff there is s.th. new + + Purpose: + +\*******************************************************************/ + bool rd_range_domaint::merge_shared( const rd_range_domaint &other, goto_programt::const_targett from, @@ -696,6 +857,18 @@ bool rd_range_domaint::merge_shared( return changed; } +/*******************************************************************\ + +Function: rd_range_domaint::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const rd_range_domaint::ranges_at_loct &rd_range_domaint::get( const irep_idt &identifier) const { @@ -711,6 +884,18 @@ const rd_range_domaint::ranges_at_loct &rd_range_domaint::get( return entry->second; } +/*******************************************************************\ + +Function: reaching_definitions_analysist::~reaching_definitions_analysist + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + reaching_definitions_analysist::~reaching_definitions_analysist() { if(is_dirty) @@ -721,6 +906,18 @@ reaching_definitions_analysist::~reaching_definitions_analysist() delete value_sets; } +/*******************************************************************\ + +Function: reaching_definitions_analysist::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reaching_definitions_analysist::initialize( const goto_functionst &goto_functions) { diff --git a/src/analyses/reaching_definitions.h b/src/analyses/reaching_definitions.h index 2cc7d815fa3..a48a271a9a6 100644 --- a/src/analyses/reaching_definitions.h +++ b/src/analyses/reaching_definitions.h @@ -9,10 +9,6 @@ Date: February 2013 \*******************************************************************/ -/// \file -/// Range-based reaching definitions analysis (following Field- Sensitive -/// Program Dependence Analysis, Litvak et al., FSE 2010) - #ifndef CPROVER_ANALYSES_REACHING_DEFINITIONS_H #define CPROVER_ANALYSES_REACHING_DEFINITIONS_H diff --git a/src/analyses/replace_symbol_ext.cpp b/src/analyses/replace_symbol_ext.cpp index 75c697030b7..568ea45e090 100644 --- a/src/analyses/replace_symbol_ext.cpp +++ b/src/analyses/replace_symbol_ext.cpp @@ -6,15 +6,23 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Modified expression replacement for constant propagator - #include #include #include "replace_symbol_ext.h" -/// does not replace object in address_of expressions +/*******************************************************************\ + +Function: replace_symbol_extt::replace + + Inputs: + + Outputs: + + Purpose: does not replace object in address_of expressions + +\*******************************************************************/ + bool replace_symbol_extt::replace(exprt &dest) const { bool result=true; diff --git a/src/analyses/replace_symbol_ext.h b/src/analyses/replace_symbol_ext.h index 05d7226be40..5a2152db17f 100644 --- a/src/analyses/replace_symbol_ext.h +++ b/src/analyses/replace_symbol_ext.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Modified expression replacement for constant propagator - #ifndef CPROVER_ANALYSES_REPLACE_SYMBOL_EXT_H #define CPROVER_ANALYSES_REPLACE_SYMBOL_EXT_H diff --git a/src/analyses/static_analysis.cpp b/src/analyses/static_analysis.cpp index dd6b8ac0f54..8309566f27d 100644 --- a/src/analyses/static_analysis.cpp +++ b/src/analyses/static_analysis.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #define USE_DEPRECATED_STATIC_ANALYSIS_H #include "static_analysis.h" +/*******************************************************************\ + +Function: static_analysis_baset::get_guard + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt static_analysis_baset::get_guard( locationt from, locationt to) @@ -40,6 +49,18 @@ exprt static_analysis_baset::get_guard( return from->guard; } +/*******************************************************************\ + +Function: static_analysis_baset::get_return_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt static_analysis_baset::get_return_lhs(locationt to) { // get predecessor of "to" @@ -58,6 +79,18 @@ exprt static_analysis_baset::get_return_lhs(locationt to) return code.lhs(); } +/*******************************************************************\ + +Function: static_analysis_baset::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::operator()( const goto_functionst &goto_functions) { @@ -65,6 +98,18 @@ void static_analysis_baset::operator()( fixedpoint(goto_functions); } +/*******************************************************************\ + +Function: static_analysis_baset::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::operator()( const goto_programt &goto_program) { @@ -73,6 +118,18 @@ void static_analysis_baset::operator()( fixedpoint(goto_program, goto_functions); } +/*******************************************************************\ + +Function: static_analysis_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::output( const goto_functionst &goto_functions, std::ostream &out) const @@ -91,6 +148,18 @@ void static_analysis_baset::output( } } +/*******************************************************************\ + +Function: static_analysis_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::output( const goto_programt &goto_program, const irep_idt &identifier, @@ -110,6 +179,18 @@ void static_analysis_baset::output( } } +/*******************************************************************\ + +Function: static_analysis_baset::generate_states + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::generate_states( const goto_functionst &goto_functions) { @@ -117,6 +198,18 @@ void static_analysis_baset::generate_states( generate_states(f_it->second.body); } +/*******************************************************************\ + +Function: static_analysis_baset::generate_states + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::generate_states( const goto_programt &goto_program) { @@ -124,6 +217,18 @@ void static_analysis_baset::generate_states( generate_state(i_it); } +/*******************************************************************\ + +Function: static_analysis_baset::update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::update( const goto_functionst &goto_functions) { @@ -131,6 +236,18 @@ void static_analysis_baset::update( update(f_it->second.body); } +/*******************************************************************\ + +Function: static_analysis_baset::generate_states + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::update( const goto_programt &goto_program) { @@ -153,6 +270,18 @@ void static_analysis_baset::update( } } +/*******************************************************************\ + +Function: static_analysis_baset::get_next + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static_analysis_baset::locationt static_analysis_baset::get_next( working_sett &working_set) { @@ -165,6 +294,18 @@ static_analysis_baset::locationt static_analysis_baset::get_next( return l; } +/*******************************************************************\ + +Function: static_analysis_baset::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool static_analysis_baset::fixedpoint( const goto_programt &goto_program, const goto_functionst &goto_functions) @@ -191,6 +332,18 @@ bool static_analysis_baset::fixedpoint( return new_data; } +/*******************************************************************\ + +Function: static_analysis_baset::visit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool static_analysis_baset::visit( locationt l, working_sett &working_set, @@ -244,6 +397,18 @@ bool static_analysis_baset::visit( return new_data; } +/*******************************************************************\ + +Function: static_analysis_baset::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::do_function_call( locationt l_call, locationt l_return, const goto_functionst &goto_functions, @@ -315,6 +480,18 @@ void static_analysis_baset::do_function_call( } } +/*******************************************************************\ + +Function: static_analysis_baset::do_function_call_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::do_function_call_rec( locationt l_call, locationt l_return, const exprt &function, @@ -417,6 +594,18 @@ void static_analysis_baset::do_function_call_rec( } } +/*******************************************************************\ + +Function: static_analysis_baset::sequential_fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::sequential_fixedpoint( const goto_functionst &goto_functions) { @@ -427,6 +616,18 @@ void static_analysis_baset::sequential_fixedpoint( fixedpoint(it->second.body, goto_functions); } +/*******************************************************************\ + +Function: static_analysis_baset::concurrent_fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analysis_baset::concurrent_fixedpoint( const goto_functionst &goto_functions) { diff --git a/src/analyses/static_analysis.h b/src/analyses/static_analysis.h index 17d8dced473..2a390fb7e61 100644 --- a/src/analyses/static_analysis.h +++ b/src/analyses/static_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Static Analysis - #ifndef CPROVER_ANALYSES_STATIC_ANALYSIS_H #define CPROVER_ANALYSES_STATIC_ANALYSIS_H diff --git a/src/analyses/uncaught_exceptions_analysis.cpp b/src/analyses/uncaught_exceptions_analysis.cpp index dfc012238ab..814fcaf3730 100644 --- a/src/analyses/uncaught_exceptions_analysis.cpp +++ b/src/analyses/uncaught_exceptions_analysis.cpp @@ -6,15 +6,23 @@ Author: Cristina David \*******************************************************************/ -/// \file -/// Over-approximating uncaught exceptions analysis - #ifdef DEBUG #include #endif #include "uncaught_exceptions_analysis.h" -/// Returns the compile type of an exception +/*******************************************************************\ + +Function: get_exception_type + + Inputs: + + Outputs: + + Purpose: Returns the compile type of an exception + +\*******************************************************************/ + irep_idt uncaught_exceptions_domaint::get_exception_type(const typet &type) { assert(type.id()==ID_pointer); @@ -26,7 +34,18 @@ irep_idt uncaught_exceptions_domaint::get_exception_type(const typet &type) return ID_empty; } -/// Returns the symbol corresponding to an exception +/*******************************************************************\ + +Function: get_exception_symbol + + Inputs: + + Outputs: + + Purpose: Returns the symbol corresponding to an exception + +\*******************************************************************/ + exprt uncaught_exceptions_domaint::get_exception_symbol(const exprt &expr) { if(expr.id()!=ID_symbol && expr.has_operands()) @@ -35,7 +54,18 @@ exprt uncaught_exceptions_domaint::get_exception_symbol(const exprt &expr) return expr; } -/// The join operator for the uncaught exceptions domain +/*******************************************************************\ + +Function: uncaught_exceptions_domaint::join + + Inputs: + + Outputs: + + Purpose: The join operator for the uncaught exceptions domain + +\*******************************************************************/ + void uncaught_exceptions_domaint::join( const irep_idt &element) { @@ -55,7 +85,18 @@ void uncaught_exceptions_domaint::join( } -/// The transformer for the uncaught exceptions domain +/*******************************************************************\ + +Function: uncaught_exceptions_domaint::transform + + Inputs: + + Outputs: + + Purpose: The transformer for the uncaught exceptions domain + +\*******************************************************************/ + void uncaught_exceptions_domaint::transform( const goto_programt::const_targett from, uncaught_exceptions_analysist &uea, @@ -134,20 +175,54 @@ void uncaught_exceptions_domaint::transform( } } -/// Returns the value of the private member thrown +/*******************************************************************\ + +Function: uncaught_exceptions_domaint::get_elements + + Inputs: + + Outputs: + + Purpose: Returns the value of the private member thrown + +\*******************************************************************/ + const std::set &uncaught_exceptions_domaint::get_elements() const { return thrown; } -/// Constructs the class hierarchy +/*******************************************************************\ + +Function: uncaught_exceptions_domaint::operator() + + Inputs: + + Outputs: + + Purpose: Constructs the class hierarchy + +\*******************************************************************/ + void uncaught_exceptions_domaint::operator()( const namespacet &ns) { class_hierarchy(ns.get_symbol_table()); } -/// Runs the uncaught exceptions analysis, which populates the exceptions map +/*******************************************************************\ + +Function: uncaught_exceptions_analysist::collect_uncaught_exceptions + + Inputs: + + Outputs: + + Purpose: Runs the uncaught exceptions analysis, which + populates the exceptions map + +\*******************************************************************/ + void uncaught_exceptions_analysist::collect_uncaught_exceptions( const goto_functionst &goto_functions, const namespacet &ns) @@ -181,8 +256,19 @@ void uncaught_exceptions_analysist::collect_uncaught_exceptions( } } -/// Prints the exceptions map that maps each method to the set of exceptions -/// that may escape it +/*******************************************************************\ + +Function: uncaught_exceptions_analysist::output + + Inputs: + + Outputs: + + Purpose: Prints the exceptions map that maps each method to the + set of exceptions that may escape it + +\*******************************************************************/ + void uncaught_exceptions_analysist::output( const goto_functionst &goto_functions) { @@ -202,7 +288,19 @@ void uncaught_exceptions_analysist::output( #endif } -/// Applies the uncaught exceptions analysis and outputs the result +/*******************************************************************\ + +Function: uncaught_exceptions_analysist::operator() + + Inputs: + + Outputs: + + Purpose: Applies the uncaught exceptions analysis and + outputs the result + +\*******************************************************************/ + void uncaught_exceptions_analysist::operator()( const goto_functionst &goto_functions, const namespacet &ns, @@ -214,7 +312,19 @@ void uncaught_exceptions_analysist::operator()( output(goto_functions); } -/// Applies the uncaught exceptions analysis and outputs the result +/*******************************************************************\ + +Function: uncaught_exceptions + + Inputs: + + Outputs: + + Purpose: Applies the uncaught exceptions analysis and + outputs the result + +\*******************************************************************/ + void uncaught_exceptions( const goto_functionst &goto_functions, const namespacet &ns, diff --git a/src/analyses/uncaught_exceptions_analysis.h b/src/analyses/uncaught_exceptions_analysis.h index a53998b4bd2..50ed75b202c 100644 --- a/src/analyses/uncaught_exceptions_analysis.h +++ b/src/analyses/uncaught_exceptions_analysis.h @@ -6,9 +6,6 @@ Author: Cristina David \*******************************************************************/ -/// \file -/// Over-approximative uncaught exceptions analysis - #ifndef CPROVER_ANALYSES_UNCAUGHT_EXCEPTIONS_ANALYSIS_H #define CPROVER_ANALYSES_UNCAUGHT_EXCEPTIONS_ANALYSIS_H @@ -18,7 +15,15 @@ Author: Cristina David #include #include -/// defines the domain used by the uncaught exceptions analysis +/*******************************************************************\ + + Class: uncaught_exceptions_domaint + + Purpose: defines the domain used by the uncaught + exceptions analysis + +\*******************************************************************/ + class uncaught_exceptions_analysist; class uncaught_exceptions_domaint @@ -53,8 +58,15 @@ class uncaught_exceptions_domaint class_hierarchyt class_hierarchy; }; -/// computes in exceptions_map an overapproximation of the exceptions thrown by -/// each method +/*******************************************************************\ + + Class: uncaught_exceptions_analysist + + Purpose: computes in exceptions_map an overapproximation of the + exceptions thrown by each method + +\*******************************************************************/ + class uncaught_exceptions_analysist { public: diff --git a/src/analyses/uninitialized_domain.cpp b/src/analyses/uninitialized_domain.cpp index 60f8c45c1bb..8a6e8dd52a5 100644 --- a/src/analyses/uninitialized_domain.cpp +++ b/src/analyses/uninitialized_domain.cpp @@ -8,14 +8,23 @@ Date: January 2010 \*******************************************************************/ -/// \file -/// Detection for Uninitialized Local Variables - #include #include #include "uninitialized_domain.h" +/*******************************************************************\ + +Function: uninitialized_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void uninitialized_domaint::transform( locationt from, locationt to, @@ -51,6 +60,18 @@ void uninitialized_domaint::transform( } } +/*******************************************************************\ + +Function: uninitialized_domaint::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void uninitialized_domaint::assign(const exprt &lhs) { if(lhs.id()==ID_index) @@ -61,6 +82,18 @@ void uninitialized_domaint::assign(const exprt &lhs) uninitialized.erase(to_symbol_expr(lhs).get_identifier()); } +/*******************************************************************\ + +Function: uninitialized_domaint::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void uninitialized_domaint::output( std::ostream &out, const ai_baset &ai, @@ -75,7 +108,18 @@ void uninitialized_domaint::output( } } -/// \return returns true iff there is s.th. new +/*******************************************************************\ + +Function: uninitialized_domaint::merge + + Inputs: + + Outputs: returns true iff there is s.th. new + + Purpose: + +\*******************************************************************/ + bool uninitialized_domaint::merge( const uninitialized_domaint &other, locationt from, diff --git a/src/analyses/uninitialized_domain.h b/src/analyses/uninitialized_domain.h index a48f9954388..6ca27f341b0 100644 --- a/src/analyses/uninitialized_domain.h +++ b/src/analyses/uninitialized_domain.h @@ -8,9 +8,6 @@ Date: January 2010 \*******************************************************************/ -/// \file -/// Detection for Uninitialized Local Variables - #ifndef CPROVER_ANALYSES_UNINITIALIZED_DOMAIN_H #define CPROVER_ANALYSES_UNINITIALIZED_DOMAIN_H diff --git a/src/ansi-c/anonymous_member.cpp b/src/ansi-c/anonymous_member.cpp index 197739f5941..adaff8d4680 100644 --- a/src/ansi-c/anonymous_member.cpp +++ b/src/ansi-c/anonymous_member.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #include #include #include "anonymous_member.h" +/*******************************************************************\ + +Function: make_member_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static exprt make_member_expr( const exprt &struct_union, const struct_union_typet::componentt &component, @@ -37,6 +46,18 @@ static exprt make_member_expr( return result; } +/*******************************************************************\ + +Function: get_component_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt get_component_rec( const exprt &struct_union, const irep_idt &component_name, @@ -69,6 +90,18 @@ exprt get_component_rec( return nil_exprt(); } +/*******************************************************************\ + +Function: has_component_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_component_rec( const typet &type, const irep_idt &component_name, diff --git a/src/ansi-c/anonymous_member.h b/src/ansi-c/anonymous_member.h index 3c58ad70efb..d9b00394b6f 100644 --- a/src/ansi-c/anonymous_member.h +++ b/src/ansi-c/anonymous_member.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C Language Type Checking - #ifndef CPROVER_ANSI_C_ANONYMOUS_MEMBER_H #define CPROVER_ANSI_C_ANONYMOUS_MEMBER_H diff --git a/src/ansi-c/ansi_c_convert_type.cpp b/src/ansi-c/ansi_c_convert_type.cpp index 56c2a42cac8..7dc6f2165cf 100644 --- a/src/ansi-c/ansi_c_convert_type.cpp +++ b/src/ansi-c/ansi_c_convert_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// SpecC Language Conversion - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_convert_type.h" +/*******************************************************************\ + +Function: ansi_c_convert_typet::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_convert_typet::read(const typet &type) { clear(); @@ -26,6 +35,18 @@ void ansi_c_convert_typet::read(const typet &type) read_rec(type); } +/*******************************************************************\ + +Function: ansi_c_convert_typet::read_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_convert_typet::read_rec(const typet &type) { if(type.id()==ID_merged_type) @@ -219,6 +240,18 @@ void ansi_c_convert_typet::read_rec(const typet &type) other.push_back(type); } +/*******************************************************************\ + +Function: ansi_c_convert_typet::write + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_convert_typet::write(typet &type) { type.clear(); diff --git a/src/ansi-c/ansi_c_convert_type.h b/src/ansi-c/ansi_c_convert_type.h index 6b2de66c5ee..0fef20b4928 100644 --- a/src/ansi-c/ansi_c_convert_type.h +++ b/src/ansi-c/ansi_c_convert_type.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Conversion - #ifndef CPROVER_ANSI_C_ANSI_C_CONVERT_TYPE_H #define CPROVER_ANSI_C_ANSI_C_CONVERT_TYPE_H diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 75726b7471e..7f9d0980583 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_declaration.h" +/*******************************************************************\ + +Function: ansi_c_declaratort::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_declaratort::build(irept &src) { typet *p=static_cast(&src); @@ -57,6 +66,18 @@ void ansi_c_declaratort::build(irept &src) value().make_nil(); } +/*******************************************************************\ + +Function: ansi_c_declarationt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_declarationt::output(std::ostream &out) const { out << "Flags:"; @@ -88,6 +109,18 @@ void ansi_c_declarationt::output(std::ostream &out) const out << "Declarator: " << declarator.pretty() << "\n"; } +/*******************************************************************\ + +Function: ansi_c_declarationt::full_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet ansi_c_declarationt::full_type( const ansi_c_declaratort &declarator) const { @@ -120,6 +153,18 @@ typet ansi_c_declarationt::full_type( return result; } +/*******************************************************************\ + +Function: ansi_c_declarationt::to_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_declarationt::to_symbol( const ansi_c_declaratort &declarator, symbolt &symbol) const diff --git a/src/ansi-c/ansi_c_declaration.h b/src/ansi-c/ansi_c_declaration.h index af5db98e32e..3143c2090a5 100644 --- a/src/ansi-c/ansi_c_declaration.h +++ b/src/ansi-c/ansi_c_declaration.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-CC Language Type Checking - #ifndef CPROVER_ANSI_C_ANSI_C_DECLARATION_H #define CPROVER_ANSI_C_ANSI_C_DECLARATION_H diff --git a/src/ansi-c/ansi_c_entry_point.cpp b/src/ansi-c/ansi_c_entry_point.cpp index 59c9674718a..ecb2dcc73cd 100644 --- a/src/ansi-c/ansi_c_entry_point.cpp +++ b/src/ansi-c/ansi_c_entry_point.cpp @@ -26,6 +26,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_entry_point.h" #include "c_nondet_symbol_factory.h" +/*******************************************************************\ + +Function: build_function_environment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt::operandst build_function_environment( const code_typet::parameterst ¶meters, code_blockt &init_code, @@ -56,6 +68,18 @@ exprt::operandst build_function_environment( return main_arguments; } +/*******************************************************************\ + +Function: record_function_outputs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void record_function_outputs( const symbolt &function, code_blockt &init_code, @@ -117,6 +141,18 @@ void record_function_outputs( #endif } +/*******************************************************************\ + +Function: ansi_c_entry_point + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_entry_point( symbol_tablet &symbol_table, const std::string &standard_main, diff --git a/src/ansi-c/ansi_c_internal_additions.cpp b/src/ansi-c/ansi_c_internal_additions.cpp index 152f1ef8a8e..eb564038e2e 100644 --- a/src/ansi-c/ansi_c_internal_additions.cpp +++ b/src/ansi-c/ansi_c_internal_additions.cpp @@ -58,6 +58,18 @@ const char clang_builtin_headers[]= #include "clang_builtin_headers.inc" ; // NOLINT(whitespace/semicolon) +/*******************************************************************\ + +Function: architecture_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string architecture_string(const std::string &value, const char *s) { return std::string("const char *__CPROVER_architecture_")+ @@ -65,6 +77,18 @@ static std::string architecture_string(const std::string &value, const char *s) "=\""+value+"\";\n"; } +/*******************************************************************\ + +Function: architecture_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string architecture_string(int value, const char *s) { return std::string("const int __CPROVER_architecture_")+ @@ -72,6 +96,18 @@ static std::string architecture_string(int value, const char *s) "="+std::to_string(value)+";\n"; } +/*******************************************************************\ + +Function: ansi_c_internal_additions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_internal_additions(std::string &code) { code+= @@ -274,6 +310,18 @@ void ansi_c_internal_additions(std::string &code) ansi_c_architecture_strings(code); } +/*******************************************************************\ + +Function: architecture_strings + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_architecture_strings(std::string &code) { // The following are CPROVER-specific. diff --git a/src/ansi-c/ansi_c_language.cpp b/src/ansi-c/ansi_c_language.cpp index 5a46bbccc1a..159b0d6df40 100644 --- a/src/ansi-c/ansi_c_language.cpp +++ b/src/ansi-c/ansi_c_language.cpp @@ -25,17 +25,52 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_internal_additions.h" #include "type2name.h" +/*******************************************************************\ + +Function: ansi_c_languaget::extensions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set ansi_c_languaget::extensions() const { return { "c", "i" }; } +/*******************************************************************\ + +Function: ansi_c_languaget::modules_provided + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: ansi_c_languaget::preprocess + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool ansi_c_languaget::preprocess( std::istream &instream, const std::string &path, @@ -48,6 +83,18 @@ bool ansi_c_languaget::preprocess( return c_preprocess(path, outstream, get_message_handler()); } +/*******************************************************************\ + +Function: ansi_c_languaget::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::parse( std::istream &instream, const std::string &path) @@ -100,6 +147,18 @@ bool ansi_c_languaget::parse( return result; } +/*******************************************************************\ + +Function: ansi_c_languaget::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -123,6 +182,18 @@ bool ansi_c_languaget::typecheck( return false; } +/*******************************************************************\ + +Function: ansi_c_languaget::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::final(symbol_tablet &symbol_table) { generate_opaque_method_stubs(symbol_table); @@ -133,16 +204,52 @@ bool ansi_c_languaget::final(symbol_tablet &symbol_table) return false; } +/*******************************************************************\ + +Function: ansi_c_languaget::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_languaget::show_parse(std::ostream &out) { parse_tree.output(out); } +/*******************************************************************\ + +Function: new_ansi_c_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *new_ansi_c_language() { return new ansi_c_languaget; } +/*******************************************************************\ + +Function: ansi_c_languaget::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::from_expr( const exprt &expr, std::string &code, @@ -152,6 +259,18 @@ bool ansi_c_languaget::from_expr( return false; } +/*******************************************************************\ + +Function: ansi_c_languaget::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::from_type( const typet &type, std::string &code, @@ -161,6 +280,18 @@ bool ansi_c_languaget::from_type( return false; } +/*******************************************************************\ + +Function: ansi_c_languaget::type_to_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::type_to_name( const typet &type, std::string &name, @@ -170,6 +301,18 @@ bool ansi_c_languaget::type_to_name( return false; } +/*******************************************************************\ + +Function: ansi_c_languaget::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_languaget::to_expr( const std::string &code, const std::string &module, @@ -216,6 +359,18 @@ bool ansi_c_languaget::to_expr( return result; } +/*******************************************************************\ + +Function: ansi_c_languaget::~ansi_c_languaget + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ansi_c_languaget::~ansi_c_languaget() { } diff --git a/src/ansi-c/ansi_c_parse_tree.cpp b/src/ansi-c/ansi_c_parse_tree.cpp index c2efad964c4..4f58d094563 100644 --- a/src/ansi-c/ansi_c_parse_tree.cpp +++ b/src/ansi-c/ansi_c_parse_tree.cpp @@ -10,16 +10,52 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_parse_tree.h" +/*******************************************************************\ + +Function: ansi_c_parse_treet::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_parse_treet::swap(ansi_c_parse_treet &ansi_c_parse_tree) { ansi_c_parse_tree.items.swap(items); } +/*******************************************************************\ + +Function: ansi_c_parse_treet::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_parse_treet::clear() { items.clear(); } +/*******************************************************************\ + +Function: ansi_c_parse_treet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_parse_treet::output(std::ostream &out) const { for(const auto &item : items) diff --git a/src/ansi-c/ansi_c_parser.cpp b/src/ansi-c/ansi_c_parser.cpp index 2464751cdb3..77a71b62dc2 100644 --- a/src/ansi-c/ansi_c_parser.cpp +++ b/src/ansi-c/ansi_c_parser.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com ansi_c_parsert ansi_c_parser; +/*******************************************************************\ + +Function: ansi_c_parsert::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ansi_c_id_classt ansi_c_parsert::lookup( const irep_idt &base_name, irep_idt &identifier, // output @@ -58,6 +70,18 @@ ansi_c_id_classt ansi_c_parsert::lookup( return ansi_c_id_classt::ANSI_C_UNKNOWN; } +/*******************************************************************\ + +Function: ansi_c_parsert::add_tag_with_body + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_parsert::add_tag_with_body(irept &tag) { const std::string scope_name= @@ -76,6 +100,18 @@ void ansi_c_parsert::add_tag_with_body(irept &tag) } } +/*******************************************************************\ + +Function: yyansi_cerror + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + extern char *yyansi_ctext; int yyansi_cerror(const std::string &error) @@ -84,6 +120,18 @@ int yyansi_cerror(const std::string &error) return 0; } +/*******************************************************************\ + +Function: ansi_c_parsert::add_declarator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_parsert::add_declarator( exprt &declaration, irept &declarator) @@ -154,6 +202,18 @@ void ansi_c_parsert::add_declarator( ansi_c_declaration.declarators().push_back(new_declarator); } +/*******************************************************************\ + +Function: ansi_c_parsert::get_class + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ansi_c_id_classt ansi_c_parsert::get_class(const typet &type) { if(type.id()==ID_typedef) diff --git a/src/ansi-c/ansi_c_scope.cpp b/src/ansi-c/ansi_c_scope.cpp index f23995a6b28..ffd3663e1fa 100644 --- a/src/ansi-c/ansi_c_scope.cpp +++ b/src/ansi-c/ansi_c_scope.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ansi_c_scope.h" +/*******************************************************************\ + +Function: ansi_c_scopet::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_scopet::print(std::ostream &out) const { out << "Prefix: " << prefix << "\n"; diff --git a/src/ansi-c/ansi_c_typecheck.cpp b/src/ansi-c/ansi_c_typecheck.cpp index 98971527711..08da6bbae01 100644 --- a/src/ansi-c/ansi_c_typecheck.cpp +++ b/src/ansi-c/ansi_c_typecheck.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #include "ansi_c_typecheck.h" +/*******************************************************************\ + +Function: ansi_c_typecheckt::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ansi_c_typecheckt::typecheck() { start_typecheck_code(); @@ -23,6 +32,18 @@ void ansi_c_typecheckt::typecheck() } } +/*******************************************************************\ + +Function: ansi_c_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_typecheck( ansi_c_parse_treet &ansi_c_parse_tree, symbol_tablet &symbol_table, @@ -34,6 +55,18 @@ bool ansi_c_typecheck( return ansi_c_typecheck.typecheck_main(); } +/*******************************************************************\ + +Function: ansi_c_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ansi_c_typecheck( exprt &expr, message_handlert &message_handler, diff --git a/src/ansi-c/ansi_c_typecheck.h b/src/ansi-c/ansi_c_typecheck.h index fdb9a32f2fe..aa6672d0d01 100644 --- a/src/ansi-c/ansi_c_typecheck.h +++ b/src/ansi-c/ansi_c_typecheck.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #ifndef CPROVER_ANSI_C_ANSI_C_TYPECHECK_H #define CPROVER_ANSI_C_ANSI_C_TYPECHECK_H diff --git a/src/ansi-c/c_misc.cpp b/src/ansi-c/c_misc.cpp index 6af272c86a0..94baea10fa2 100644 --- a/src/ansi-c/c_misc.cpp +++ b/src/ansi-c/c_misc.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Misc Utilities - #include #ifdef _WIN32 @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_misc.h" +/*******************************************************************\ + +Function: MetaChar + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void MetaChar(std::string &out, char c, bool inString) { switch(c) @@ -93,6 +102,18 @@ static void MetaChar(std::string &out, char c, bool inString) } #if 0 +/*******************************************************************\ + +Function: MetaChar + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string MetaChar(char c) { std::string result; @@ -101,6 +122,18 @@ static std::string MetaChar(char c) } #endif +/*******************************************************************\ + +Function: MetaString + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string MetaString(const std::string &in) { std::string result; diff --git a/src/ansi-c/c_misc.h b/src/ansi-c/c_misc.h index 5af7eb4754c..40f9d0db5b8 100644 --- a/src/ansi-c/c_misc.h +++ b/src/ansi-c/c_misc.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Misc Utilities - #ifndef CPROVER_ANSI_C_C_MISC_H #define CPROVER_ANSI_C_C_MISC_H diff --git a/src/ansi-c/c_nondet_symbol_factory.cpp b/src/ansi-c/c_nondet_symbol_factory.cpp index 99e804bf311..9149d6f8786 100644 --- a/src/ansi-c/c_nondet_symbol_factory.cpp +++ b/src/ansi-c/c_nondet_symbol_factory.cpp @@ -6,9 +6,6 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ -/// \file -/// C Nondet Symbol Factory - #include #include @@ -30,13 +27,23 @@ Author: DiffBlue Limited. All rights reserved. #include "c_nondet_symbol_factory.h" -/// Create a new temporary static symbol -/// \param symbol_table: The symbol table to create the symbol in -/// \param loc: The location to assign to the symbol -/// \param type: The type of symbol to create -/// \param static_lifetime: Whether the symbol should have a static lifetime -/// \param prefix: The prefix to use for the symbol's basename -/// \return Returns a reference to the new symbol +/*******************************************************************\ + +Function: declare_new_tmp_symbol + + Inputs: + symbol_table - The symbol table to create the symbol in + loc - The location to assign to the symbol + type - The type of symbol to create + static_lifetime - Whether the symbol should have a static lifetime + prefix - The prefix to use for the symbol's basename + + Outputs: Returns a reference to the new symbol + + Purpose: Create a new temporary static symbol + +\*******************************************************************/ + static const symbolt &c_new_tmp_symbol( symbol_tablet &symbol_table, const source_locationt &loc, @@ -51,8 +58,19 @@ static const symbolt &c_new_tmp_symbol( return tmp_symbol; } -/// \param type: Desired type (C_bool or plain bool) -/// \return nondet expr of that type +/*******************************************************************\ + +Function: c_get_nondet_bool + + Inputs: + type - Desired type (C_bool or plain bool) + + Outputs: nondet expr of that type + + Purpose: + +\*******************************************************************/ + static exprt c_get_nondet_bool(const typet &type) { // We force this to 0 and 1 and won't consider other values @@ -89,14 +107,23 @@ class symbol_factoryt void gen_nondet_init(code_blockt &assignments, const exprt &expr); }; -/// Create a symbol for a pointer to point to -/// \param assignments: The code block to add code to -/// \param target_expr: The expression which we are allocating a symbol for -/// \param allocate_type: The type to use for the symbol. If this doesn't match -/// target_expr then a cast will be used for the assignment -/// \param static_lifetime: Whether the symbol created should have static -/// lifetime -/// \return Returns the address of the allocated symbol +/*******************************************************************\ + +Function: symbol_factoryt::allocate_object + + Inputs: + assignments - The code block to add code to + target_expr - The expression which we are allocating a symbol for + allocate_type - The type to use for the symbol. If this doesn't match + target_expr then a cast will be used for the assignment + static_lifetime - Whether the symbol created should have static lifetime + + Outputs: Returns the address of the allocated symbol + + Purpose: Create a symbol for a pointer to point to + +\*******************************************************************/ + exprt symbol_factoryt::allocate_object( code_blockt &assignments, const exprt &target_expr, @@ -130,11 +157,21 @@ exprt symbol_factoryt::allocate_object( return aoe; } -/// Creates a nondet for expr, including calling itself recursively to make -/// appropriate symbols to point to if expr is a pointer. -/// \param assignments: The code block to add code to -/// \param expr: The expression which we are generating a non-determinate value -/// for +/*******************************************************************\ + +Function: symbol_factoryt::gen_nondet_init + + Inputs: + assignments - The code block to add code to + expr - The expression which we are generating a non-determinate value for + + Outputs: + + Purpose: Creates a nondet for expr, including calling itself recursively to + make appropriate symbols to point to if expr is a pointer. + +\*******************************************************************/ + void symbol_factoryt::gen_nondet_init( code_blockt &assignments, const exprt &expr) @@ -206,16 +243,26 @@ void symbol_factoryt::gen_nondet_init( } } -/// Creates a symbol and generates code so that it can vary over all possible -/// values for its type. For pointers this involves allocating symbols which it -/// can point to. -/// \param init_code: The code block to add generated code to -/// \param symbol_table: The symbol table -/// \param base_name: The name to use for the symbol created -/// \param type: The type for the symbol created -/// \param loc: The location to assign to generated code -/// \param allow_null: Whether to allow a null value when type is a pointer -/// \return Returns the symbol_exprt for the symbol created +/*******************************************************************\ + +Function: c_nondet_symbol_factory + + Inputs: + init_code - The code block to add generated code to + symbol_table - The symbol table + base_name - The name to use for the symbol created + type - The type for the symbol created + loc - The location to assign to generated code + allow_null - Whether to allow a null value when type is a pointer + + Outputs: Returns the symbol_exprt for the symbol created + + Purpose: Creates a symbol and generates code so that it can vary + over all possible values for its type. For pointers this + involves allocating symbols which it can point to. + +\*******************************************************************/ + exprt c_nondet_symbol_factory( code_blockt &init_code, symbol_tablet &symbol_table, diff --git a/src/ansi-c/c_nondet_symbol_factory.h b/src/ansi-c/c_nondet_symbol_factory.h index 8d375663e73..8760de6ac55 100644 --- a/src/ansi-c/c_nondet_symbol_factory.h +++ b/src/ansi-c/c_nondet_symbol_factory.h @@ -6,9 +6,6 @@ Author: DiffBlue Limited. All rights reserved. \*******************************************************************/ -/// \file -/// C Nondet Symbol Factory - #ifndef CPROVER_ANSI_C_C_NONDET_SYMBOL_FACTORY_H #define CPROVER_ANSI_C_C_NONDET_SYMBOL_FACTORY_H diff --git a/src/ansi-c/c_preprocess.cpp b/src/ansi-c/c_preprocess.cpp index 0eae03ea2ff..9582d6f3b00 100644 --- a/src/ansi-c/c_preprocess.cpp +++ b/src/ansi-c/c_preprocess.cpp @@ -96,7 +96,18 @@ Author: Daniel Kroening, kroening@kroening.com " -D__INTPTR_TYPE__=\"long long int\""\ " -D__UINTPTR_TYPE__=\"long long unsigned int\"" -/// produce a string with the maximum value of a given type +/*******************************************************************\ + +Function: type_max + + Inputs: + + Outputs: + + Purpose: produce a string with the maximum value of a given type + +\*******************************************************************/ + static std::string type_max(const typet &src) { if(src.id()==ID_signedbv) @@ -109,7 +120,18 @@ static std::string type_max(const typet &src) assert(false); } -/// quote a string for bash and CMD +/*******************************************************************\ + +Function: shell_quote + + Inputs: + + Outputs: + + Purpose: quote a string for bash and CMD + +\*******************************************************************/ + static std::string shell_quote(const std::string &src) { #ifdef _WIN32 @@ -183,6 +205,18 @@ static std::string shell_quote(const std::string &src) #endif } +/*******************************************************************\ + +Function: error_parse_line + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void error_parse_line( const std::string &line, bool warning_only, @@ -303,6 +337,18 @@ static void error_parse_line( m << error_msg << messaget::eom; } +/*******************************************************************\ + +Function: error_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void error_parse( std::istream &errors, bool warning_only, @@ -314,7 +360,18 @@ static void error_parse( error_parse_line(line, warning_only, message); } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess( std::istream &instream, std::ostream &outstream, @@ -340,7 +397,18 @@ bool c_preprocess( return result; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: is_dot_i_file + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + static bool is_dot_i_file(const std::string &path) { const char *ext=strrchr(path.c_str(), '.'); @@ -352,7 +420,18 @@ static bool is_dot_i_file(const std::string &path) return false; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_codewarrior( const std::string &, std::ostream &, message_handlert &); bool c_preprocess_arm( @@ -401,7 +480,18 @@ bool c_preprocess( return true; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess_visual_studio + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_visual_studio( const std::string &file, std::ostream &outstream, @@ -508,7 +598,18 @@ bool c_preprocess_visual_studio( return false; } -/// post-processing specifically for CodeWarrior +/*******************************************************************\ + +Function: postprocess_codewarrior + + Inputs: + + Outputs: + + Purpose: post-processing specifically for CodeWarrior + +\*******************************************************************/ + void postprocess_codewarrior( std::istream &instream, std::ostream &outstream) @@ -544,7 +645,18 @@ void postprocess_codewarrior( } } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess_codewarrior + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_codewarrior( const std::string &file, std::ostream &outstream, @@ -617,7 +729,18 @@ bool c_preprocess_codewarrior( return false; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess_gcc_clang + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_gcc_clang( const std::string &file, std::ostream &outstream, @@ -921,7 +1044,18 @@ bool c_preprocess_gcc_clang( return false; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess_arm + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_arm( const std::string &file, std::ostream &outstream, @@ -1043,7 +1177,18 @@ bool c_preprocess_arm( return false; } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: c_preprocess_none + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool c_preprocess_none( const std::string &file, std::ostream &outstream, @@ -1078,7 +1223,18 @@ bool c_preprocess_none( return false; } -/// tests ANSI-C preprocessing +/*******************************************************************\ + +Function: test_c_preprocessor + + Inputs: + + Outputs: + + Purpose: tests ANSI-C preprocessing + +\*******************************************************************/ + const char c_test_program[]= "#include \n" "\n" diff --git a/src/ansi-c/c_qualifiers.cpp b/src/ansi-c/c_qualifiers.cpp index 47a99a63f65..75ca8bf9c05 100644 --- a/src/ansi-c/c_qualifiers.cpp +++ b/src/ansi-c/c_qualifiers.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_qualifiers.h" +/*******************************************************************\ + +Function: c_qualifierst::as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string c_qualifierst::as_string() const { std::string qualifiers; @@ -38,6 +50,18 @@ std::string c_qualifierst::as_string() const return qualifiers; } +/*******************************************************************\ + +Function: c_qualifierst::read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_qualifierst::read(const typet &src) { if(src.get_bool(ID_C_constant)) @@ -65,6 +89,18 @@ void c_qualifierst::read(const typet &src) is_noreturn=true; } +/*******************************************************************\ + +Function: c_qualifierst::write + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_qualifierst::write(typet &dest) const { if(is_constant) @@ -108,6 +144,18 @@ void c_qualifierst::write(typet &dest) const dest.remove(ID_C_noreturn); } +/*******************************************************************\ + +Function: c_qualifierst::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_qualifierst::clear(typet &dest) { dest.remove(ID_C_constant); @@ -119,7 +167,18 @@ void c_qualifierst::clear(typet &dest) dest.remove(ID_C_noreturn); } -/// pretty-print the qualifiers +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: pretty-print the qualifiers + +\*******************************************************************/ + std::ostream &operator << ( std::ostream &out, const c_qualifierst &c_qualifiers) diff --git a/src/ansi-c/c_sizeof.cpp b/src/ansi-c/c_sizeof.cpp index 7d4dd390759..85c91870208 100644 --- a/src/ansi-c/c_sizeof.cpp +++ b/src/ansi-c/c_sizeof.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Conversion of sizeof Expressions - #include #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_typecast.h" #include "c_types.h" +/*******************************************************************\ + +Function: c_sizeoft::sizeof_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_sizeoft::sizeof_rec(const typet &type) { // this implementation will eventually be replaced @@ -249,6 +258,18 @@ exprt c_sizeoft::sizeof_rec(const typet &type) return dest; } +/*******************************************************************\ + +Function: c_sizeoft::c_offsetof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_sizeoft::c_offsetof( const struct_typet &type, const irep_idt &component_name) @@ -299,6 +320,18 @@ exprt c_sizeoft::c_offsetof( return nil_exprt(); } +/*******************************************************************\ + +Function: c_sizeof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_sizeof(const typet &src, const namespacet &ns) { c_sizeoft c_sizeof_inst(ns); @@ -307,6 +340,18 @@ exprt c_sizeof(const typet &src, const namespacet &ns) return tmp; } +/*******************************************************************\ + +Function: c_offsetof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_offsetof( const struct_typet &src, const irep_idt &component_name, diff --git a/src/ansi-c/c_storage_spec.cpp b/src/ansi-c/c_storage_spec.cpp index 6a74d092599..df4cdb2381c 100644 --- a/src/ansi-c/c_storage_spec.cpp +++ b/src/ansi-c/c_storage_spec.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_storage_spec.h" +/*******************************************************************\ + +Function: c_storage_spect::read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_storage_spect::read(const typet &type) { if(type.id()==ID_merged_type || diff --git a/src/ansi-c/c_typecast.cpp b/src/ansi-c/c_typecast.cpp index b8be3a66b50..52070e29257 100644 --- a/src/ansi-c/c_typecast.cpp +++ b/src/ansi-c/c_typecast.cpp @@ -22,6 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_types.h" #include "c_qualifiers.h" +/*******************************************************************\ + +Function: c_implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool c_implicit_typecast( exprt &expr, const typet &dest_type, @@ -32,6 +44,18 @@ bool c_implicit_typecast( return !c_typecast.errors.empty(); } +/*******************************************************************\ + +Function: check_c_implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool check_c_implicit_typecast( const typet &src_type, const typet &dest_type, @@ -44,7 +68,18 @@ bool check_c_implicit_typecast( return !c_typecast.errors.empty(); } -/// perform arithmetic prompotions and conversions +/*******************************************************************\ + +Function: c_implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: perform arithmetic prompotions and conversions + +\*******************************************************************/ + bool c_implicit_typecast_arithmetic( exprt &expr1, exprt &expr2, const namespacet &ns) @@ -54,6 +89,18 @@ bool c_implicit_typecast_arithmetic( return !c_typecast.errors.empty(); } +/*******************************************************************\ + +Function: is_void_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_void_pointer(const typet &type) { if(type.id()==ID_pointer) @@ -67,6 +114,18 @@ bool is_void_pointer(const typet &type) return false; } +/*******************************************************************\ + +Function: check_c_implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool check_c_implicit_typecast( const typet &src_type, const typet &dest_type) @@ -249,6 +308,18 @@ bool check_c_implicit_typecast( return true; } +/*******************************************************************\ + +Function: c_typecastt::follow_with_qualifiers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet c_typecastt::follow_with_qualifiers(const typet &src_type) { if(src_type.id()!=ID_symbol) @@ -273,6 +344,18 @@ typet c_typecastt::follow_with_qualifiers(const typet &src_type) return result_type; } +/*******************************************************************\ + +Function: c_typecastt::get_c_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + c_typecastt::c_typet c_typecastt::get_c_type( const typet &type) const { @@ -358,6 +441,18 @@ c_typecastt::c_typet c_typecastt::get_c_type( return OTHER; } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::implicit_typecast_arithmetic( exprt &expr, c_typet c_type) @@ -404,6 +499,18 @@ void c_typecastt::implicit_typecast_arithmetic( do_typecast(expr, new_type); } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + c_typecastt::c_typet c_typecastt::minimum_promotion( const typet &type) const { @@ -437,12 +544,36 @@ c_typecastt::c_typet c_typecastt::minimum_promotion( return max_type; } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::implicit_typecast_arithmetic(exprt &expr) { c_typet c_type=minimum_promotion(expr.type()); implicit_typecast_arithmetic(expr, c_type); } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::implicit_typecast( exprt &expr, const typet &type) @@ -457,6 +588,18 @@ void c_typecastt::implicit_typecast( implicit_typecast_followed(expr, src_type, type_qual, dest_type); } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast_followed + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::implicit_typecast_followed( exprt &expr, const typet &src_type, @@ -578,6 +721,18 @@ void c_typecastt::implicit_typecast_followed( do_typecast(expr, orig_dest_type); } +/*******************************************************************\ + +Function: c_typecastt::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::implicit_typecast_arithmetic( exprt &expr1, exprt &expr2) @@ -692,6 +847,18 @@ void c_typecastt::implicit_typecast_arithmetic( #endif } +/*******************************************************************\ + +Function: c_typecastt::do_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecastt::do_typecast(exprt &expr, const typet &dest_type) { // special case: array -> pointer is actually diff --git a/src/ansi-c/c_typecheck_argc_argv.cpp b/src/ansi-c/c_typecheck_argc_argv.cpp index 5b6b11c8c1f..a528a630042 100644 --- a/src/ansi-c/c_typecheck_argc_argv.cpp +++ b/src/ansi-c/c_typecheck_argc_argv.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Conversion / Type Checking - #include #include "c_typecheck_base.h" +/*******************************************************************\ + +Function: c_typecheck_baset::add_argc_argv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::add_argc_argv(const symbolt &main_symbol) { const code_typet::parameterst ¶meters= diff --git a/src/ansi-c/c_typecheck_base.cpp b/src/ansi-c/c_typecheck_base.cpp index 2b40d71796f..8597eef3852 100644 --- a/src/ansi-c/c_typecheck_base.cpp +++ b/src/ansi-c/c_typecheck_base.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Conversion / Type Checking - #include #include #include @@ -18,16 +15,52 @@ Author: Daniel Kroening, kroening@kroening.com #include "type2name.h" #include "c_storage_spec.h" +/*******************************************************************\ + +Function: c_typecheck_baset::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string c_typecheck_baset::to_string(const exprt &expr) { return expr2c(expr, *this); } +/*******************************************************************\ + +Function: c_typecheck_baset::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string c_typecheck_baset::to_string(const typet &type) { return type2c(type, *this); } +/*******************************************************************\ + +Function: c_typecheck_baset::move_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::move_symbol(symbolt &symbol, symbolt *&new_symbol) { symbol.mode=mode; @@ -42,6 +75,18 @@ void c_typecheck_baset::move_symbol(symbolt &symbol, symbolt *&new_symbol) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_symbol(symbolt &symbol) { current_symbol_id=symbol.name; @@ -128,6 +173,18 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_new_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_new_symbol(symbolt &symbol) { if(symbol.is_parameter) @@ -179,6 +236,18 @@ void c_typecheck_baset::typecheck_new_symbol(symbolt &symbol) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_redefinition_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_redefinition_type( symbolt &old_symbol, symbolt &new_symbol) @@ -262,6 +331,18 @@ void c_typecheck_baset::typecheck_redefinition_type( } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_redefinition_non_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_redefinition_non_type( symbolt &old_symbol, symbolt &new_symbol) @@ -534,6 +615,18 @@ void c_typecheck_baset::typecheck_redefinition_non_type( // mismatch. } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_function_body + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_function_body(symbolt &symbol) { code_typet &code_type=to_code_type(symbol.type); @@ -604,6 +697,18 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol) } } +/*******************************************************************\ + +Function: c_typecheck_baset::apply_asm_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::apply_asm_label( const irep_idt &asm_label, symbolt &symbol) @@ -672,6 +777,18 @@ void c_typecheck_baset::apply_asm_label( } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_declaration + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_declaration( ansi_c_declarationt &declaration) { diff --git a/src/ansi-c/c_typecheck_base.h b/src/ansi-c/c_typecheck_base.h index 684b0b64edc..68191f54fe9 100644 --- a/src/ansi-c/c_typecheck_base.h +++ b/src/ansi-c/c_typecheck_base.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #ifndef CPROVER_ANSI_C_C_TYPECHECK_BASE_H #define CPROVER_ANSI_C_C_TYPECHECK_BASE_H diff --git a/src/ansi-c/c_typecheck_code.cpp b/src/ansi-c/c_typecheck_code.cpp index c13564b9ab2..dfbac98940c 100644 --- a/src/ansi-c/c_typecheck_code.cpp +++ b/src/ansi-c/c_typecheck_code.cpp @@ -6,20 +6,41 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C Language Type Checking - #include #include #include "ansi_c_declaration.h" #include "c_typecheck_base.h" +/*******************************************************************\ + +Function: c_typecheck_baset::start_typecheck_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::start_typecheck_code() { case_is_allowed=break_is_allowed=continue_is_allowed=false; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_code(codet &code) { if(code.id()!=ID_code) @@ -131,6 +152,18 @@ void c_typecheck_baset::typecheck_code(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_asm + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_asm(codet &code) { const irep_idt flavor=to_code_asm(code).get_flavor(); @@ -164,6 +197,18 @@ void c_typecheck_baset::typecheck_asm(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_assign(codet &code) { if(code.operands().size()!=2) @@ -180,6 +225,18 @@ void c_typecheck_baset::typecheck_assign(codet &code) implicit_typecast(code.op1(), code.op0().type()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_block(codet &code) { Forall_operands(it, code) @@ -219,6 +276,18 @@ void c_typecheck_baset::typecheck_block(codet &code) code.operands().swap(new_ops.operands()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_break + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_break(codet &code) { if(!break_is_allowed) @@ -229,6 +298,18 @@ void c_typecheck_baset::typecheck_break(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_continue + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_continue(codet &code) { if(!continue_is_allowed) @@ -239,6 +320,18 @@ void c_typecheck_baset::typecheck_continue(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_decl(codet &code) { // this comes with 1 operand, which is a declaration @@ -359,6 +452,18 @@ void c_typecheck_baset::typecheck_decl(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::is_complete_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool c_typecheck_baset::is_complete_type(const typet &type) const { if(type.id()==ID_incomplete_struct || @@ -389,6 +494,18 @@ bool c_typecheck_baset::is_complete_type(const typet &type) const return true; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expression(codet &code) { if(code.operands().size()!=1) @@ -403,6 +520,18 @@ void c_typecheck_baset::typecheck_expression(codet &code) typecheck_expr(op); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_for + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_for(codet &code) { if(code.operands().size()!=4) @@ -494,6 +623,18 @@ void c_typecheck_baset::typecheck_for(codet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_label(code_labelt &code) { // record the label @@ -502,6 +643,18 @@ void c_typecheck_baset::typecheck_label(code_labelt &code) typecheck_code(code.code()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_switch_case + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code) { if(code.operands().size()!=2) @@ -537,6 +690,18 @@ void c_typecheck_baset::typecheck_switch_case(code_switch_caset &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_gcc_switch_case_range + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_gcc_switch_case_range(codet &code) { if(code.operands().size()!=3) @@ -562,18 +727,54 @@ void c_typecheck_baset::typecheck_gcc_switch_case_range(codet &code) implicit_typecast(code.op1(), switch_op_type); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_gcc_local_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_gcc_local_label(codet &code) { // these are just declarations, e.g., // __label__ here, there; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_goto(code_gotot &code) { // we record the label used labels_used[code.get_destination()]=code.source_location(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_gcc_computed_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) { if(code.operands().size()!=1) @@ -599,6 +800,18 @@ void c_typecheck_baset::typecheck_gcc_computed_goto(codet &code) dest.type()=empty_typet(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code) { if(code.operands().size()!=3) @@ -648,6 +861,18 @@ void c_typecheck_baset::typecheck_ifthenelse(code_ifthenelset &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_start_thread(codet &code) { if(code.operands().size()!=1) @@ -660,6 +885,18 @@ void c_typecheck_baset::typecheck_start_thread(codet &code) typecheck_code(to_code(code.op0())); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_return(codet &code) { if(code.operands().empty()) @@ -704,6 +941,18 @@ void c_typecheck_baset::typecheck_return(codet &code) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_switch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_switch(code_switcht &code) { if(code.operands().size()!=2) @@ -735,6 +984,18 @@ void c_typecheck_baset::typecheck_switch(code_switcht &code) switch_op_type=old_switch_op_type; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_while + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_while(code_whilet &code) { if(code.operands().size()!=2) @@ -770,6 +1031,18 @@ void c_typecheck_baset::typecheck_while(code_whilet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_dowhile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_dowhile(code_dowhilet &code) { if(code.operands().size()!=2) @@ -805,6 +1078,18 @@ void c_typecheck_baset::typecheck_dowhile(code_dowhilet &code) typecheck_spec_expr(code, ID_C_spec_loop_invariant); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_spec_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_spec_expr( codet &code, const irep_idt &spec) diff --git a/src/ansi-c/c_typecheck_expr.cpp b/src/ansi-c/c_typecheck_expr.cpp index 6f845653102..5d4788e5145 100644 --- a/src/ansi-c/c_typecheck_expr.cpp +++ b/src/ansi-c/c_typecheck_expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #include #include @@ -31,6 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "anonymous_member.h" #include "padding.h" +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr(exprt &expr) { if(expr.id()==ID_already_typechecked) @@ -49,6 +58,18 @@ void c_typecheck_baset::typecheck_expr(exprt &expr) typecheck_expr_main(expr); } +/*******************************************************************\ + +Function: c_typecheck_baset::add_rounding_mode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::add_rounding_mode(exprt &expr) { for(auto &op : expr.operands()) @@ -83,6 +104,18 @@ void c_typecheck_baset::add_rounding_mode(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::gcc_types_compatible_p + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool c_typecheck_baset::gcc_types_compatible_p( const typet &type1, const typet &type2) @@ -165,6 +198,18 @@ bool c_typecheck_baset::gcc_types_compatible_p( return false; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_side_effect) @@ -422,6 +467,18 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_comma + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_comma(exprt &expr) { if(expr.operands().size()!=2) @@ -438,6 +495,18 @@ void c_typecheck_baset::typecheck_expr_comma(exprt &expr) expr.set(ID_C_lvalue, true); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_builtin_va_arg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) { // The first parameter is the va_list, and the second @@ -483,6 +552,18 @@ void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr) symbol_table.move(symbol); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_cw_va_arg_typeof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_cw_va_arg_typeof(exprt &expr) { // used in Code Warrior via @@ -500,6 +581,18 @@ void c_typecheck_baset::typecheck_expr_cw_va_arg_typeof(exprt &expr) expr.type()=signed_int_type(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_builtin_offsetof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) { // these need not be constant, due to array indices! @@ -661,6 +754,18 @@ void c_typecheck_baset::typecheck_expr_builtin_offsetof(exprt &expr) expr.swap(result); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_operands(exprt &expr) { if(expr.id()==ID_side_effect && @@ -732,6 +837,18 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) { irep_idt identifier=to_symbol_expr(expr).get_identifier(); @@ -837,6 +954,18 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_side_effect_statement_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_side_effect_statement_expression( side_effect_exprt &expr) { @@ -913,6 +1042,18 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression( expr.type()=typet(ID_empty); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_sizeof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) { typet type; @@ -975,6 +1116,18 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_alignof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_alignof(exprt &expr) { typet argument_type; @@ -997,6 +1150,18 @@ void c_typecheck_baset::typecheck_expr_alignof(exprt &expr) expr.swap(tmp); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) { if(expr.operands().size()!=1) @@ -1189,11 +1354,35 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::make_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::make_index_type(exprt &expr) { implicit_typecast(expr, index_type()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_index(exprt &expr) { if(expr.operands().size()!=2) @@ -1254,6 +1443,18 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr) expr.type()=final_array_type.subtype(); } +/*******************************************************************\ + +Function: c_typecheck_baset::adjust_float_rel + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::adjust_float_rel(exprt &expr) { // equality and disequality on float is not mathematical equality! @@ -1268,6 +1469,18 @@ void c_typecheck_baset::adjust_float_rel(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_rel + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_rel( binary_relation_exprt &expr) { @@ -1374,6 +1587,18 @@ void c_typecheck_baset::typecheck_expr_rel( throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_rel_vector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_rel_vector( binary_relation_exprt &expr) { @@ -1400,6 +1625,18 @@ void c_typecheck_baset::typecheck_expr_rel_vector( expr.type()=vector_typet(signed_int_type(), to_vector_type(o_type0).size()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_ptrmember + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_ptrmember(exprt &expr) { if(expr.operands().size()!=1) @@ -1435,6 +1672,18 @@ void c_typecheck_baset::typecheck_expr_ptrmember(exprt &expr) typecheck_expr_member(expr); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_member(exprt &expr) { if(expr.operands().size()!=1) @@ -1531,6 +1780,18 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_trinary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1624,6 +1885,18 @@ void c_typecheck_baset::typecheck_expr_trinary(if_exprt &expr) throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_side_effect_gcc_conditional_expresssion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_side_effect_gcc_conditional_expression( side_effect_exprt &expr) { @@ -1655,6 +1928,18 @@ void c_typecheck_baset::typecheck_side_effect_gcc_conditional_expression( expr.type()=if_expr.type(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -1725,6 +2010,18 @@ void c_typecheck_baset::typecheck_expr_address_of(exprt &expr) expr.type()=pointer_type(op.type()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_dereference(exprt &expr) { if(expr.operands().size()!=1) @@ -1768,6 +2065,18 @@ void c_typecheck_baset::typecheck_expr_dereference(exprt &expr) typecheck_expr_function_identifier(expr); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_function_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_function_identifier(exprt &expr) { if(expr.type().id()==ID_code) @@ -1780,6 +2089,18 @@ void c_typecheck_baset::typecheck_expr_function_identifier(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_side_effect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr) { const irep_idt &statement=expr.get_statement(); @@ -1871,6 +2192,18 @@ void c_typecheck_baset::typecheck_expr_side_effect(side_effect_exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_side_effect_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_side_effect_function_call( side_effect_expr_function_callt &expr) { @@ -1979,6 +2312,18 @@ void c_typecheck_baset::typecheck_side_effect_function_call( typecheck_function_call_arguments(expr); } +/*******************************************************************\ + +Function: c_typecheck_baset::do_special_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_typecheck_baset::do_special_functions( side_effect_expr_function_callt &expr) { @@ -2583,8 +2928,18 @@ exprt c_typecheck_baset::do_special_functions( return nil_exprt(); } -/// \param type:checked arguments, type-checked function -/// \return type-adjusted function arguments +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_function_call_arguments + + Inputs: type-checked arguments, type-checked function + + Outputs: type-adjusted function arguments + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_function_call_arguments( side_effect_expr_function_callt &expr) { @@ -2667,11 +3022,35 @@ void c_typecheck_baset::typecheck_function_call_arguments( } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_constant(exprt &expr) { // nothing to do } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_unary_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_unary_arithmetic(exprt &expr) { if(expr.operands().size()!=1) @@ -2711,6 +3090,18 @@ void c_typecheck_baset::typecheck_expr_unary_arithmetic(exprt &expr) throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_unary_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_unary_boolean(exprt &expr) { if(expr.operands().size()!=1) @@ -2733,6 +3124,18 @@ void c_typecheck_baset::typecheck_expr_unary_boolean(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: c_typecheck_baset::gcc_vector_types_compatible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool c_typecheck_baset::gcc_vector_types_compatible( const vector_typet &type0, const vector_typet &type1) @@ -2760,6 +3163,18 @@ bool c_typecheck_baset::gcc_vector_types_compatible( return type0.subtype()==type1.subtype(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_binary_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr) { if(expr.operands().size()!=2) @@ -2861,6 +3276,18 @@ void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr) throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_shifts + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_shifts(shift_exprt &expr) { assert(expr.id()==ID_shl || expr.id()==ID_shr); @@ -2930,6 +3357,18 @@ void c_typecheck_baset::typecheck_expr_shifts(shift_exprt &expr) throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_arithmetic_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_arithmetic_pointer(const exprt &expr) { const typet &type=expr.type(); @@ -2948,6 +3387,18 @@ void c_typecheck_baset::typecheck_arithmetic_pointer(const exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_pointer_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_pointer_arithmetic(exprt &expr) { assert(expr.operands().size()==2); @@ -3038,6 +3489,18 @@ void c_typecheck_baset::typecheck_expr_pointer_arithmetic(exprt &expr) throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_expr_binary_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_expr_binary_boolean(exprt &expr) { if(expr.operands().size()!=2) @@ -3059,6 +3522,18 @@ void c_typecheck_baset::typecheck_expr_binary_boolean(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_side_effect_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_side_effect_assignment( side_effect_exprt &expr) { @@ -3253,6 +3728,18 @@ void c_typecheck_baset::typecheck_side_effect_assignment( throw 0; } +/*******************************************************************\ + +Function: c_typecheck_baset::make_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::make_constant(exprt &expr) { make_constant_rec(expr); @@ -3268,6 +3755,18 @@ void c_typecheck_baset::make_constant(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::make_constant_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::make_constant_index(exprt &expr) { make_constant(expr); @@ -3283,6 +3782,18 @@ void c_typecheck_baset::make_constant_index(exprt &expr) } } +/*******************************************************************\ + +Function: c_typecheck_baset::make_constant_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::make_constant_rec(exprt &expr) { } diff --git a/src/ansi-c/c_typecheck_initializer.cpp b/src/ansi-c/c_typecheck_initializer.cpp index 0c9e7c5ccac..79dabc9f0e9 100644 --- a/src/ansi-c/c_typecheck_initializer.cpp +++ b/src/ansi-c/c_typecheck_initializer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Conversion / Type Checking - #include #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "string_constant.h" #include "anonymous_member.h" +/*******************************************************************\ + +Function: c_typecheck_baset::do_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::do_initializer( exprt &initializer, const typet &type, @@ -51,7 +60,19 @@ void c_typecheck_baset::do_initializer( initializer=result; } -/// initialize something of type `type' with given value `value' +/*******************************************************************\ + +Function: c_typecheck_baset::do_initializer_rec + + Inputs: + + Outputs: + + Purpose: initialize something of type `type' with given + value `value' + +\*******************************************************************/ + exprt c_typecheck_baset::do_initializer_rec( const exprt &value, const typet &type, @@ -209,6 +230,18 @@ exprt c_typecheck_baset::do_initializer_rec( return result; } +/*******************************************************************\ + +Function: c_typecheck_baset::do_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::do_initializer(symbolt &symbol) { // this one doesn't need initialization @@ -252,6 +285,18 @@ void c_typecheck_baset::do_initializer(symbolt &symbol) } } +/*******************************************************************\ + +Function: c_typecheck_baset::designator_enter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::designator_enter( const typet &type, designatort &designator) @@ -349,8 +394,18 @@ void c_typecheck_baset::designator_enter( designator.push_entry(entry); } -/// \param pre:initialized result, designator -/// \return sets result +/*******************************************************************\ + +Function: c_typecheck_baset::do_designated_initializer + + Inputs: pre-initialized result, designator + + Outputs: sets result + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::do_designated_initializer( exprt &result, designatort &designator, @@ -591,6 +646,18 @@ void c_typecheck_baset::do_designated_initializer( } } +/*******************************************************************\ + +Function: c_typecheck_baset::increment_designator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::increment_designator(designatort &designator) { assert(!designator.empty()); @@ -639,6 +706,18 @@ void c_typecheck_baset::increment_designator(designatort &designator) } } +/*******************************************************************\ + +Function: c_typecheck_baset::make_designator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + designatort c_typecheck_baset::make_designator( const typet &src_type, const exprt &src) @@ -786,6 +865,18 @@ designatort c_typecheck_baset::make_designator( return designator; } +/*******************************************************************\ + +Function: c_typecheck_baset::do_initializer_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt c_typecheck_baset::do_initializer_list( const exprt &value, const typet &type, diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index df3ea27a605..ac3fe7f2928 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "type2name.h" #include "ansi_c_convert_type.h" +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_type(typet &type) { // we first convert, and then check @@ -246,6 +255,18 @@ void c_typecheck_baset::typecheck_type(typet &type) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_custom_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_custom_type(typet &type) { // they all have a width @@ -346,6 +367,18 @@ void c_typecheck_baset::typecheck_custom_type(typet &type) assert(false); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_code_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_code_type(code_typet &type) { // the return type is still 'subtype()' @@ -445,6 +478,18 @@ void c_typecheck_baset::typecheck_code_type(code_typet &type) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_array_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_array_type(array_typet &type) { exprt &size=type.size(); @@ -571,6 +616,18 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_vector_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_vector_type(vector_typet &type) { exprt &size=type.size(); @@ -652,6 +709,18 @@ void c_typecheck_baset::typecheck_vector_type(vector_typet &type) type.size()=from_integer(s, signed_size_type()); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_compound_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) { // These get replaced by symbol types later. @@ -764,6 +833,18 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type) original_qualifiers.write(type); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_compound_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_compound_body( struct_union_typet &type) { @@ -940,6 +1021,18 @@ void c_typecheck_baset::typecheck_compound_body( } } +/*******************************************************************\ + +Function: c_typecheck_baset::enum_constant_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet c_typecheck_baset::enum_constant_type( const mp_integer &min_value, const mp_integer &max_value) const @@ -972,6 +1065,18 @@ typet c_typecheck_baset::enum_constant_type( } } +/*******************************************************************\ + +Function: c_typecheck_baset::enum_underlying_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet c_typecheck_baset::enum_underlying_type( const mp_integer &min_value, const mp_integer &max_value, @@ -1030,6 +1135,18 @@ typet c_typecheck_baset::enum_underlying_type( } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_c_enum_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_c_enum_type(typet &type) { // These come with the declarations @@ -1213,6 +1330,18 @@ void c_typecheck_baset::typecheck_c_enum_type(typet &type) type.set(ID_identifier, identifier); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_c_enum_tag_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) { // It's just a tag. @@ -1272,6 +1401,18 @@ void c_typecheck_baset::typecheck_c_enum_tag_type(c_enum_tag_typet &type) type.set_identifier(identifier); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_c_bit_field_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) { typecheck_type(type.subtype()); @@ -1352,6 +1493,18 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type) } } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_typeof_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_typeof_type(typet &type) { // save location @@ -1389,6 +1542,18 @@ void c_typecheck_baset::typecheck_typeof_type(typet &type) c_qualifiers.write(type); } +/*******************************************************************\ + +Function: c_typecheck_baset::typecheck_symbol_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::typecheck_symbol_type(typet &type) { const irep_idt &identifier= @@ -1443,6 +1608,18 @@ void c_typecheck_baset::typecheck_symbol_type(typet &type) } } +/*******************************************************************\ + +Function: c_typecheck_baset::adjust_function_parameter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::adjust_function_parameter(typet &type) const { if(type.id()==ID_array) diff --git a/src/ansi-c/c_typecheck_typecast.cpp b/src/ansi-c/c_typecheck_typecast.cpp index e026ac7044d..5d1cfad1332 100644 --- a/src/ansi-c/c_typecheck_typecast.cpp +++ b/src/ansi-c/c_typecheck_typecast.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_typecheck_base.h" #include "c_types.h" +/*******************************************************************\ + +Function: c_typecheck_baset::implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::implicit_typecast( exprt &expr, const typet &dest_type) @@ -50,6 +62,18 @@ void c_typecheck_baset::implicit_typecast( } } +/*******************************************************************\ + +Function: c_typecheck_baset::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::implicit_typecast_arithmetic( exprt &expr1, exprt &expr2) @@ -58,6 +82,18 @@ void c_typecheck_baset::implicit_typecast_arithmetic( c_typecast.implicit_typecast_arithmetic(expr1, expr2); } +/*******************************************************************\ + +Function: c_typecheck_baset::implicit_typecast_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void c_typecheck_baset::implicit_typecast_arithmetic(exprt &expr) { c_typecastt c_typecast(*this); diff --git a/src/ansi-c/c_types.cpp b/src/ansi-c/c_types.cpp index 5a4504c890c..6ba5ddaefb3 100644 --- a/src/ansi-c/c_types.cpp +++ b/src/ansi-c/c_types.cpp @@ -11,13 +11,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_types.h" +/*******************************************************************\ + +Function: index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet index_type() { // same as signed size type return signed_size_type(); } -/// return type of enum constants +/*******************************************************************\ + +Function: enum_constant_type + + Inputs: + + Outputs: + + Purpose: return type of enum constants + +\*******************************************************************/ + typet enum_constant_type() { // usually same as 'int', @@ -25,6 +48,18 @@ typet enum_constant_type() return signed_int_type(); } +/*******************************************************************\ + +Function: signed_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_int_type() { typet result=signedbv_typet(config.ansi_c.int_width); @@ -32,6 +67,18 @@ typet signed_int_type() return result; } +/*******************************************************************\ + +Function: signed_short_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_short_int_type() { typet result=signedbv_typet(config.ansi_c.short_int_width); @@ -39,6 +86,18 @@ typet signed_short_int_type() return result; } +/*******************************************************************\ + +Function: unsigned_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet unsigned_int_type() { typet result=unsignedbv_typet(config.ansi_c.int_width); @@ -46,6 +105,18 @@ typet unsigned_int_type() return result; } +/*******************************************************************\ + +Function: unsigned_short_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet unsigned_short_int_type() { typet result=unsignedbv_typet(config.ansi_c.short_int_width); @@ -53,6 +124,18 @@ typet unsigned_short_int_type() return result; } +/*******************************************************************\ + +Function: size_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet size_type() { // The size type varies. This is unsigned int on some systems, @@ -69,12 +152,36 @@ typet size_type() assert(false); // aaah! } +/*******************************************************************\ + +Function: signed_size_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_size_type() { // we presume this is the same as pointer difference return pointer_diff_type(); } +/*******************************************************************\ + +Function: signed_long_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_long_int_type() { typet result=signedbv_typet(config.ansi_c.long_int_width); @@ -82,6 +189,18 @@ typet signed_long_int_type() return result; } +/*******************************************************************\ + +Function: signed_long_long_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_long_long_int_type() { typet result=signedbv_typet(config.ansi_c.long_long_int_width); @@ -89,6 +208,18 @@ typet signed_long_long_int_type() return result; } +/*******************************************************************\ + +Function: unsigned_long_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet unsigned_long_int_type() { typet result=unsignedbv_typet(config.ansi_c.long_int_width); @@ -96,6 +227,18 @@ typet unsigned_long_int_type() return result; } +/*******************************************************************\ + +Function: unsigned_long_long_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet unsigned_long_long_int_type() { typet result=unsignedbv_typet(config.ansi_c.long_long_int_width); @@ -103,12 +246,36 @@ typet unsigned_long_long_int_type() return result; } +/*******************************************************************\ + +Function: c_bool_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet c_bool_type() { typet result=c_bool_typet(config.ansi_c.bool_width); return result; } +/*******************************************************************\ + +Function: char_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet char_type() { typet result; @@ -128,6 +295,18 @@ typet char_type() return result; } +/*******************************************************************\ + +Function: unsigned_char_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet unsigned_char_type() { typet result=unsignedbv_typet(config.ansi_c.char_width); @@ -137,6 +316,18 @@ typet unsigned_char_type() return result; } +/*******************************************************************\ + +Function: signed_char_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet signed_char_type() { typet result=signedbv_typet(config.ansi_c.char_width); @@ -146,6 +337,18 @@ typet signed_char_type() return result; } +/*******************************************************************\ + +Function: wchar_t_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet wchar_t_type() { typet result; @@ -160,6 +363,18 @@ typet wchar_t_type() return result; } +/*******************************************************************\ + +Function: char16_t_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet char16_t_type() { typet result; @@ -174,6 +389,18 @@ typet char16_t_type() return result; } +/*******************************************************************\ + +Function: char32_t_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet char32_t_type() { typet result; @@ -188,6 +415,18 @@ typet char32_t_type() return result; } +/*******************************************************************\ + +Function: float_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet float_type() { typet result; @@ -207,6 +446,18 @@ typet float_type() return result; } +/*******************************************************************\ + +Function: double_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet double_type() { typet result; @@ -226,6 +477,18 @@ typet double_type() return result; } +/*******************************************************************\ + +Function: long_double_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet long_double_type() { typet result; @@ -264,6 +527,18 @@ typet long_double_type() return result; } +/*******************************************************************\ + +Function: gcc_float128_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet gcc_float128_type() { typet result; @@ -286,6 +561,18 @@ typet gcc_float128_type() return result; } +/*******************************************************************\ + +Function: pointer_diff_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet pointer_diff_type() { // The pointer-diff type varies. This is signed int on some systems, @@ -301,16 +588,52 @@ typet pointer_diff_type() assert(false); // aaah! } +/*******************************************************************\ + +Function: pointer_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet pointer_type(const typet &subtype) { return pointer_typet(subtype); } +/*******************************************************************\ + +Function: void_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet void_type() { return empty_typet(); } +/*******************************************************************\ + +Function: gcc_unsigned_int128_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet gcc_unsigned_int128_type() { typet result=unsignedbv_typet(128); @@ -318,6 +641,18 @@ typet gcc_unsigned_int128_type() return result; } +/*******************************************************************\ + +Function: gcc_signed_int128_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet gcc_signed_int128_type() { typet result=signedbv_typet(128); @@ -325,6 +660,18 @@ typet gcc_signed_int128_type() return result; } +/*******************************************************************\ + +Function: c_type_as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string c_type_as_string(const irep_idt &c_type) { if(c_type==ID_signed_int) diff --git a/src/ansi-c/cprover_library.cpp b/src/ansi-c/cprover_library.cpp index 4cc00ec28a9..382ec324636 100644 --- a/src/ansi-c/cprover_library.cpp +++ b/src/ansi-c/cprover_library.cpp @@ -21,6 +21,18 @@ struct cprover_library_entryt #include "cprover_library.inc" ; // NOLINT(whitespace/semicolon) +/*******************************************************************\ + +Function: get_cprover_library_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string get_cprover_library_text( const std::set &functions, const symbol_tablet &symbol_table) @@ -62,6 +74,18 @@ std::string get_cprover_library_text( return library_text.str(); } +/*******************************************************************\ + +Function: add_cprover_library + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_cprover_library( const std::set &functions, symbol_tablet &symbol_table, @@ -77,6 +101,18 @@ void add_cprover_library( add_library(library_text, symbol_table, message_handler); } +/*******************************************************************\ + +Function: add_library + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_library( const std::string &src, symbol_tablet &symbol_table, diff --git a/src/ansi-c/designator.cpp b/src/ansi-c/designator.cpp index 1d54f11d5f1..88657e71407 100644 --- a/src/ansi-c/designator.cpp +++ b/src/ansi-c/designator.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #include #include "designator.h" +/*******************************************************************\ + +Function: designatort::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void designatort::print(std::ostream &out) const { for(index_listt::const_iterator it=index_list.begin(); diff --git a/src/ansi-c/designator.h b/src/ansi-c/designator.h index d31d3bb3e66..019f622ef63 100644 --- a/src/ansi-c/designator.h +++ b/src/ansi-c/designator.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #ifndef CPROVER_ANSI_C_DESIGNATOR_H #define CPROVER_ANSI_C_DESIGNATOR_H diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index 9d7b654cae5..e8ccb805a76 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -51,6 +51,18 @@ Precedences are as follows. Higher values mean higher precedence. */ +/*******************************************************************\ + +Function: expr2ct::id_shorthand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt expr2ct::id_shorthand(const irep_idt &identifier) const { const symbolt *symbol; @@ -69,6 +81,18 @@ irep_idt expr2ct::id_shorthand(const irep_idt &identifier) const return sh; } +/*******************************************************************\ + +Function: clean_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string clean_identifier(const irep_idt &id) { std::string dest=id2string(id); @@ -91,6 +115,18 @@ static std::string clean_identifier(const irep_idt &id) return dest; } +/*******************************************************************\ + +Function: expr2ct::get_shorthands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void expr2ct::get_shorthands(const exprt &expr) { find_symbols_sett symbols; @@ -154,11 +190,35 @@ void expr2ct::get_shorthands(const exprt &expr) } } +/*******************************************************************\ + +Function: expr2ct::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert(const typet &src) { return convert_rec(src, c_qualifierst(), ""); } +/*******************************************************************\ + +Function: expr2ct::convert_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -646,12 +706,21 @@ std::string expr2ct::convert_rec( } } -/// To generate C-like string for defining the given struct -/// \param src: the struct type being converted -/// \param qualifiers: any qualifiers on the type -/// \param declarator: the declarator on the type -/// \return Returns a type declaration for a struct, containing the body of the -/// struct and in that body the padding parameters. +/*******************************************************************\ + +Function: expr2ct::convert_struct_type + + Inputs: + src - the struct type being converted + qualifiers - any qualifiers on the type + declarator - the declarator on the type + + Outputs: Returns a type declaration for a struct, containing the + body of the struct and in that body the padding parameters. + + Purpose: To generate C-like string for defining the given struct + +\*******************************************************************/ std::string expr2ct::convert_struct_type( const typet &src, const std::string &qualifiers_str, @@ -660,16 +729,26 @@ std::string expr2ct::convert_struct_type( return convert_struct_type(src, qualifiers_str, declarator_str, true, true); } -/// To generate C-like string for declaring (or defining) the given struct -/// \param src: the struct type being converted -/// \param qualifiers: any qualifiers on the type -/// \param declarator: the declarator on the type -/// \param inc_struct_body: when generating the code, should we include a -/// complete definition of the struct -/// \param inc_padding_components: should the padding parameters be included -/// Note this only makes sense if inc_struct_body -/// \return Returns a type declaration for a struct, optionally containing the -/// body of the struct (and in that body, optionally the padding parameters). +/*******************************************************************\ + +Function: expr2ct::convert_struct_type + + Inputs: + src - the struct type being converted + qualifiers - any qualifiers on the type + declarator - the declarator on the type + inc_struct_body - when generating the code, should we include + a complete definition of the struct + inc_padding_components - should the padding parameters be included + Note this only makes sense if inc_struct_body + + Outputs: Returns a type declaration for a struct, optionally containing the + body of the struct (and in that body, optionally the padding + parameters). + + Purpose: To generate C-like string for declaring (or defining) the given struct + +\*******************************************************************/ std::string expr2ct::convert_struct_type( const typet &src, const std::string &qualifiers, @@ -719,12 +798,22 @@ std::string expr2ct::convert_struct_type( return dest; } -/// To generate a C-like type declaration of an array. Includes the size of the -/// array in the [] -/// \param src: The array type to convert -/// qualifier -/// declarator_str -/// \return A C-like type declaration of an array +/*******************************************************************\ + +Function: expr2ct::convert_array_type + + Inputs: + src - The array type to convert + qualifier + declarator_str + + Outputs: A C-like type declaration of an array + + Purpose: To generate a C-like type declaration of an array. Includes + the size of the array in the [] + +\*******************************************************************/ + std::string expr2ct::convert_array_type( const typet &src, const c_qualifierst &qualifiers, @@ -733,14 +822,24 @@ std::string expr2ct::convert_array_type( return convert_array_type(src, qualifiers, declarator_str, true); } -/// To generate a C-like type declaration of an array. Optionally can include or -/// exclude the size of the array in the [] -/// \param src: The array type to convert -/// qualifier -/// declarator_str -/// \param inc_size_if_possible: Should the generated string include the size of -/// the array (if it is known). -/// \return A C-like type declaration of an array +/*******************************************************************\ + +Function: expr2ct::convert_array_type + + Inputs: + src - The array type to convert + qualifier + declarator_str + inc_size_if_possible - Should the generated string include + the size of the array (if it is known). + + Outputs: A C-like type declaration of an array + + Purpose: To generate a C-like type declaration of an array. Optionally + can include or exclude the size of the array in the [] + +\*******************************************************************/ + std::string expr2ct::convert_array_type( const typet &src, const c_qualifierst &qualifiers, @@ -761,6 +860,18 @@ std::string expr2ct::convert_array_type( src.subtype(), qualifiers, declarator_str+array_suffix); } +/*******************************************************************\ + +Function: expr2ct::convert_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_typecast( const typecast_exprt &src, unsigned &precedence) @@ -795,6 +906,18 @@ std::string expr2ct::convert_typecast( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_trinary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_trinary( const exprt &src, const std::string &symbol1, @@ -846,6 +969,18 @@ std::string expr2ct::convert_trinary( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_quantifier( const exprt &src, const std::string &symbol, @@ -868,6 +1003,18 @@ std::string expr2ct::convert_quantifier( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_with( const exprt &src, unsigned precedence) @@ -936,6 +1083,18 @@ std::string expr2ct::convert_with( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_update( const exprt &src, unsigned precedence) @@ -980,6 +1139,18 @@ std::string expr2ct::convert_update( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_cond + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_cond( const exprt &src, unsigned precedence) @@ -1014,6 +1185,18 @@ std::string expr2ct::convert_cond( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_binary( const exprt &src, const std::string &symbol, @@ -1063,6 +1246,18 @@ std::string expr2ct::convert_binary( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_unary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_unary( const exprt &src, const std::string &symbol, @@ -1086,6 +1281,18 @@ std::string expr2ct::convert_unary( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_pointer_object_has_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_pointer_object_has_type( const exprt &src, unsigned precedence) @@ -1106,6 +1313,18 @@ std::string expr2ct::convert_pointer_object_has_type( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_malloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_malloc( const exprt &src, unsigned &precedence) @@ -1132,6 +1351,18 @@ std::string expr2ct::convert_malloc( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_nondet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_nondet( const exprt &src, unsigned &precedence) @@ -1142,6 +1373,18 @@ std::string expr2ct::convert_nondet( return "NONDET("+convert(src.type())+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_statement_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_statement_expression( const exprt &src, unsigned &precedence) @@ -1153,6 +1396,18 @@ std::string expr2ct::convert_statement_expression( return "("+convert_code(to_code_block(to_code(src.op0())), 0)+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_prob_coin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_prob_coin( const exprt &src, unsigned &precedence) @@ -1163,6 +1418,18 @@ std::string expr2ct::convert_prob_coin( return convert_norep(src, precedence); } +/*******************************************************************\ + +Function: expr2ct::convert_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_literal( const exprt &src, unsigned &precedence) @@ -1170,6 +1437,18 @@ std::string expr2ct::convert_literal( return "L("+src.get_string(ID_literal)+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_prob_uniform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_prob_uniform( const exprt &src, unsigned &precedence) @@ -1180,6 +1459,18 @@ std::string expr2ct::convert_prob_uniform( return convert_norep(src, precedence); } +/*******************************************************************\ + +Function: expr2ct::convert_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_function( const exprt &src, const std::string &name, @@ -1204,6 +1495,18 @@ std::string expr2ct::convert_function( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_comma + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_comma( const exprt &src, unsigned precedence) @@ -1228,6 +1531,18 @@ std::string expr2ct::convert_comma( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_complex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_complex( const exprt &src, unsigned precedence) @@ -1279,6 +1594,18 @@ std::string expr2ct::convert_complex( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_array_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_array_of( const exprt &src, unsigned precedence) @@ -1289,6 +1616,18 @@ std::string expr2ct::convert_array_of( return "ARRAY_OF("+convert(src.op0())+')'; } +/*******************************************************************\ + +Function: expr2ct::convert_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_byte_extract( const exprt &src, unsigned precedence) @@ -1314,6 +1653,18 @@ std::string expr2ct::convert_byte_extract( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_byte_update( const exprt &src, unsigned precedence) @@ -1344,6 +1695,18 @@ std::string expr2ct::convert_byte_update( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_unary_post + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_unary_post( const exprt &src, const std::string &symbol, @@ -1366,6 +1729,18 @@ std::string expr2ct::convert_unary_post( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_index( const exprt &src, unsigned precedence) @@ -1390,8 +1765,20 @@ std::string expr2ct::convert_index( return dest; } -std::string expr2ct::convert_pointer_arithmetic( - const exprt &src, unsigned &precedence) +/*******************************************************************\ + +Function: expr2ct::convert_pointer_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +std::string expr2ct::convert_pointer_arithmetic( + const exprt &src, unsigned &precedence) { if(src.operands().size()!=2) return convert_norep(src, precedence); @@ -1427,6 +1814,18 @@ std::string expr2ct::convert_pointer_arithmetic( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_pointer_difference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_pointer_difference( const exprt &src, unsigned &precedence) { @@ -1464,6 +1863,18 @@ std::string expr2ct::convert_pointer_difference( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_member_designator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_member_designator(const exprt &src) { unsigned precedence; @@ -1474,6 +1885,18 @@ std::string expr2ct::convert_member_designator(const exprt &src) return "."+src.get_string(ID_component_name); } +/*******************************************************************\ + +Function: expr2ct::convert_index_designator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_index_designator(const exprt &src) { unsigned precedence; @@ -1484,6 +1907,18 @@ std::string expr2ct::convert_index_designator(const exprt &src) return "["+convert(src.op0())+"]"; } +/*******************************************************************\ + +Function: expr2ct::convert_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_member( const member_exprt &src, unsigned precedence) @@ -1560,6 +1995,18 @@ std::string expr2ct::convert_member( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_array_member_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_array_member_value( const exprt &src, unsigned precedence) @@ -1570,6 +2017,18 @@ std::string expr2ct::convert_array_member_value( return "[]="+convert(src.op0()); } +/*******************************************************************\ + +Function: expr2ct::convert_struct_member_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_struct_member_value( const exprt &src, unsigned precedence) @@ -1580,6 +2039,18 @@ std::string expr2ct::convert_struct_member_value( return "."+src.get_string(ID_name)+"="+convert(src.op0()); } +/*******************************************************************\ + +Function: expr2ct::convert_norep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_norep( const exprt &src, unsigned &precedence) @@ -1591,6 +2062,18 @@ std::string expr2ct::convert_norep( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_symbol( const exprt &src, unsigned &precedence) @@ -1633,6 +2116,18 @@ std::string expr2ct::convert_symbol( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_nondet_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_nondet_symbol( const exprt &src, unsigned &precedence) @@ -1641,6 +2136,18 @@ std::string expr2ct::convert_nondet_symbol( return "nondet_symbol("+id+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_predicate_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_predicate_symbol( const exprt &src, unsigned &precedence) @@ -1649,6 +2156,18 @@ std::string expr2ct::convert_predicate_symbol( return "ps("+id+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_predicate_next_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_predicate_next_symbol( const exprt &src, unsigned &precedence) @@ -1657,6 +2176,18 @@ std::string expr2ct::convert_predicate_next_symbol( return "pns("+id+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_predicate_passive_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_predicate_passive_symbol( const exprt &src, unsigned &precedence) @@ -1665,6 +2196,18 @@ std::string expr2ct::convert_predicate_passive_symbol( return "pps("+id+")"; } +/*******************************************************************\ + +Function: expr2ct::convert_quantified_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_quantified_symbol( const exprt &src, unsigned &precedence) @@ -1673,6 +2216,18 @@ std::string expr2ct::convert_quantified_symbol( return id; } +/*******************************************************************\ + +Function: expr2ct::convert_nondet_bool + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_nondet_bool( const exprt &src, unsigned &precedence) @@ -1680,6 +2235,18 @@ std::string expr2ct::convert_nondet_bool( return "nondet_bool()"; } +/*******************************************************************\ + +Function: expr2ct::convert_object_descriptor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_object_descriptor( const exprt &src, unsigned &precedence) @@ -1704,6 +2271,18 @@ std::string expr2ct::convert_object_descriptor( return result; } +/*******************************************************************\ + +Function: expr2ct::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -1929,10 +2508,19 @@ std::string expr2ct::convert_constant( return dest; } -/// To get the C-like representation of a given boolean value. -/// \param boolean_value: The value of the constant bool expression -/// \return Returns a C-like representation of the boolean value, e.g. TRUE or -/// FALSE. +/*******************************************************************\ + +Function: expr2ct::convert_constant_bool + + Inputs: + boolean_value - The value of the constant bool expression + + Outputs: Returns a C-like representation of the boolean value, + e.g. TRUE or FALSE. + + Purpose: To get the C-like representation of a given boolean value. + +\*******************************************************************/ std::string expr2ct::convert_constant_bool(bool boolean_value) { // C doesn't really have these @@ -1942,6 +2530,18 @@ std::string expr2ct::convert_constant_bool(bool boolean_value) return "FALSE"; } +/*******************************************************************\ + +Function: expr2ct::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_struct( const exprt &src, unsigned &precedence) @@ -1949,13 +2549,23 @@ std::string expr2ct::convert_struct( return convert_struct(src, precedence, true); } -/// To generate a C-like string representing a struct. Can optionally include -/// the padding parameters. -/// \param src: The struct declaration expression -/// precedence -/// \param include_padding_components: Should the generated C code include the -/// padding members added to structs for GOTOs benifit -/// \return A string representation of the struct expression +/*******************************************************************\ + +Function: expr2ct::convert_struct + + Inputs: + src - The struct declaration expression + precedence + include_padding_components - Should the generated C code + include the padding members added + to structs for GOTOs benifit + + Outputs: A string representation of the struct expression + + Purpose: To generate a C-like string representing a struct. Can optionally + include the padding parameters. + +\*******************************************************************/ std::string expr2ct::convert_struct( const exprt &src, unsigned &precedence, @@ -2030,6 +2640,18 @@ std::string expr2ct::convert_struct( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_vector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_vector( const exprt &src, unsigned &precedence) @@ -2077,6 +2699,18 @@ std::string expr2ct::convert_vector( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_union( const exprt &src, unsigned &precedence) @@ -2098,6 +2732,18 @@ std::string expr2ct::convert_union( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_array( const exprt &src, unsigned &precedence) @@ -2204,6 +2850,18 @@ std::string expr2ct::convert_array( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_array_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_array_list( const exprt &src, unsigned &precedence) @@ -2238,6 +2896,18 @@ std::string expr2ct::convert_array_list( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_initializer_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_initializer_list( const exprt &src, unsigned &precedence) @@ -2266,6 +2936,18 @@ std::string expr2ct::convert_initializer_list( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_designated_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_designated_initializer( const exprt &src, unsigned &precedence) @@ -2284,6 +2966,18 @@ std::string expr2ct::convert_designated_initializer( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_function_application + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_function_application( const function_application_exprt &src, unsigned &precedence) @@ -2314,6 +3008,18 @@ std::string expr2ct::convert_function_application( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_side_effect_expr_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_side_effect_expr_function_call( const side_effect_expr_function_callt &src, unsigned &precedence) @@ -2344,6 +3050,18 @@ std::string expr2ct::convert_side_effect_expr_function_call( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_overflow( const exprt &src, unsigned &precedence) @@ -2375,11 +3093,35 @@ std::string expr2ct::convert_overflow( return dest; } +/*******************************************************************\ + +Function: expr2ct::indent_str + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::indent_str(unsigned indent) { return std::string(indent, ' '); } +/*******************************************************************\ + +Function: expr2ct::convert_code_asm + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_asm( const code_asmt &src, unsigned indent) @@ -2458,6 +3200,18 @@ std::string expr2ct::convert_code_asm( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_while + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_while( const code_whilet &src, unsigned indent) @@ -2484,6 +3238,18 @@ std::string expr2ct::convert_code_while( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_dowhile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_dowhile( const code_dowhilet &src, unsigned indent) @@ -2513,6 +3279,18 @@ std::string expr2ct::convert_code_dowhile( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_ifthenelse( const code_ifthenelset &src, unsigned indent) @@ -2550,6 +3328,18 @@ std::string expr2ct::convert_code_ifthenelse( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_return( const codet &src, unsigned indent) @@ -2572,6 +3362,18 @@ std::string expr2ct::convert_code_return( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_goto( const codet &src, unsigned indent) @@ -2584,6 +3386,18 @@ std::string expr2ct::convert_code_goto( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_break + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_break( const codet &src, unsigned indent) @@ -2595,6 +3409,18 @@ std::string expr2ct::convert_code_break( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_switch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_switch( const codet &src, unsigned indent) @@ -2638,6 +3464,18 @@ std::string expr2ct::convert_code_switch( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_continue + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_continue( const codet &src, unsigned indent) @@ -2649,6 +3487,18 @@ std::string expr2ct::convert_code_continue( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_decl( const codet &src, unsigned indent) @@ -2689,6 +3539,18 @@ std::string expr2ct::convert_code_decl( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_dead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_dead( const codet &src, unsigned indent) @@ -2703,6 +3565,18 @@ std::string expr2ct::convert_code_dead( return "dead "+convert(src.op0())+";"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_for + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_for( const code_fort &src, unsigned indent) @@ -2740,6 +3614,18 @@ std::string expr2ct::convert_code_for( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_block( const code_blockt &src, unsigned indent) @@ -2763,6 +3649,18 @@ std::string expr2ct::convert_code_block( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_decl_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_decl_block( const codet &src, unsigned indent) @@ -2778,6 +3676,18 @@ std::string expr2ct::convert_code_decl_block( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_expression( const codet &src, unsigned indent) @@ -2800,6 +3710,18 @@ std::string expr2ct::convert_code_expression( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code( const codet &src, unsigned indent) @@ -2923,6 +3845,18 @@ std::string expr2ct::convert_code( return convert_norep(src, precedence); } +/*******************************************************************\ + +Function: expr2ct::convert_code_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_assign( const code_assignt &src, unsigned indent) @@ -2934,6 +3868,18 @@ std::string expr2ct::convert_code_assign( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_free + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_free( const codet &src, unsigned indent) @@ -2947,6 +3893,18 @@ std::string expr2ct::convert_code_free( return indent_str(indent)+"FREE("+convert(src.op0())+");"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_init( const codet &src, unsigned indent) @@ -2956,6 +3914,18 @@ std::string expr2ct::convert_code_init( return indent_str(indent)+"INIT "+tmp+";"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_lock + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_lock( const codet &src, unsigned indent) @@ -2969,6 +3939,18 @@ std::string expr2ct::convert_code_lock( return indent_str(indent)+"LOCK("+convert(src.op0())+");"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_unlock + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_unlock( const codet &src, unsigned indent) @@ -2982,6 +3964,18 @@ std::string expr2ct::convert_code_unlock( return indent_str(indent)+"UNLOCK("+convert(src.op0())+");"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_function_call( const code_function_callt &src, unsigned indent) @@ -3030,6 +4024,18 @@ std::string expr2ct::convert_code_function_call( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_printf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_printf( const codet &src, unsigned indent) @@ -3052,6 +4058,18 @@ std::string expr2ct::convert_code_printf( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_fence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_fence( const codet &src, unsigned indent) @@ -3082,6 +4100,18 @@ std::string expr2ct::convert_code_fence( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_input + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_input( const codet &src, unsigned indent) @@ -3104,6 +4134,18 @@ std::string expr2ct::convert_code_input( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_output( const codet &src, unsigned indent) @@ -3125,6 +4167,18 @@ std::string expr2ct::convert_code_output( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_array_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_array_set( const codet &src, unsigned indent) @@ -3147,6 +4201,18 @@ std::string expr2ct::convert_code_array_set( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_array_copy + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_array_copy( const codet &src, unsigned indent) @@ -3169,6 +4235,18 @@ std::string expr2ct::convert_code_array_copy( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_code_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_assert( const codet &src, unsigned indent) @@ -3182,6 +4260,18 @@ std::string expr2ct::convert_code_assert( return indent_str(indent)+"assert("+convert(src.op0())+");"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_assume + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_assume( const codet &src, unsigned indent) @@ -3195,6 +4285,18 @@ std::string expr2ct::convert_code_assume( return indent_str(indent)+"__CPROVER_assume("+convert(src.op0())+");"; } +/*******************************************************************\ + +Function: expr2ct::convert_code_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_label( const code_labelt &src, unsigned indent) @@ -3213,6 +4315,18 @@ std::string expr2ct::convert_code_label( return labels_string+tmp; } +/*******************************************************************\ + +Function: expr2ct::convert_code_switch_case + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code_switch_case( const code_switch_caset &src, unsigned indent) @@ -3243,11 +4357,35 @@ std::string expr2ct::convert_code_switch_case( return labels_string+tmp; } +/*******************************************************************\ + +Function: expr2ct::convert_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_code(const codet &src) { return convert_code(src, 0); } +/*******************************************************************\ + +Function: expr2ct::convert_Hoare + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_Hoare(const exprt &src) { unsigned precedence; @@ -3291,6 +4429,18 @@ std::string expr2ct::convert_Hoare(const exprt &src) return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_extractbit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_extractbit( const exprt &src, unsigned precedence) @@ -3306,6 +4456,18 @@ std::string expr2ct::convert_extractbit( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_extractbits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_extractbits( const exprt &src, unsigned precedence) @@ -3323,6 +4485,18 @@ std::string expr2ct::convert_extractbits( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert_sizeof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_sizeof( const exprt &src, unsigned &precedence) @@ -3337,6 +4511,18 @@ std::string expr2ct::convert_sizeof( return dest; } +/*******************************************************************\ + +Function: expr2ct::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -3841,12 +5027,36 @@ std::string expr2ct::convert_with_precedence( return convert_norep(src, precedence); } +/*******************************************************************\ + +Function: expr2ct::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2ct::convert(const exprt &src) { unsigned precedence; return convert_with_precedence(src, precedence); } +/*******************************************************************\ + +Function: expr2c + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2c(const exprt &expr, const namespacet &ns) { std::string code; @@ -3855,6 +5065,18 @@ std::string expr2c(const exprt &expr, const namespacet &ns) return expr2c.convert(expr); } +/*******************************************************************\ + +Function: type2c + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2c(const typet &type, const namespacet &ns) { expr2ct expr2c(ns); diff --git a/src/ansi-c/file_converter.cpp b/src/ansi-c/file_converter.cpp index f45dec56984..1a3aecab1a3 100644 --- a/src/ansi-c/file_converter.cpp +++ b/src/ansi-c/file_converter.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Convert file contents to C strings - #include #include diff --git a/src/ansi-c/library/jsa.h b/src/ansi-c/library/jsa.h index 4859e34a927..20f68ad371d 100644 --- a/src/ansi-c/library/jsa.h +++ b/src/ansi-c/library/jsa.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Counterexample-Guided Inductive Synthesis - /* FUNCTION: __CPROVER_jsa_synthesise */ #ifndef CPROVER_ANSI_C_LIBRARY_JSA_H diff --git a/src/ansi-c/literals/convert_character_literal.cpp b/src/ansi-c/literals/convert_character_literal.cpp index f494634b7a0..f76af2eefa6 100644 --- a/src/ansi-c/literals/convert_character_literal.cpp +++ b/src/ansi-c/literals/convert_character_literal.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C Language Conversion - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "unescape_string.h" #include "convert_character_literal.h" +/*******************************************************************\ + +Function: convert_character_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt convert_character_literal( const std::string &src, bool force_integer_type) diff --git a/src/ansi-c/literals/convert_character_literal.h b/src/ansi-c/literals/convert_character_literal.h index 797457a3970..4c497db73cd 100644 --- a/src/ansi-c/literals/convert_character_literal.h +++ b/src/ansi-c/literals/convert_character_literal.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Conversion - #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_CHARACTER_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_CHARACTER_LITERAL_H diff --git a/src/ansi-c/literals/convert_float_literal.cpp b/src/ansi-c/literals/convert_float_literal.cpp index 87094fb5e0b..7e72f6e6f53 100644 --- a/src/ansi-c/literals/convert_float_literal.cpp +++ b/src/ansi-c/literals/convert_float_literal.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Conversion - #include #include @@ -22,6 +19,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "parse_float.h" #include "convert_float_literal.h" +/*******************************************************************\ + +Function: convert_float_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt convert_float_literal(const std::string &src) { mp_integer significand; diff --git a/src/ansi-c/literals/convert_float_literal.h b/src/ansi-c/literals/convert_float_literal.h index 5aa627ace8c..4c76abbd312 100644 --- a/src/ansi-c/literals/convert_float_literal.h +++ b/src/ansi-c/literals/convert_float_literal.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C Language Conversion - #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_FLOAT_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_FLOAT_LITERAL_H diff --git a/src/ansi-c/literals/convert_integer_literal.cpp b/src/ansi-c/literals/convert_integer_literal.cpp index d14c5c92b24..d7c832dee31 100644 --- a/src/ansi-c/literals/convert_integer_literal.cpp +++ b/src/ansi-c/literals/convert_integer_literal.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Conversion - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "convert_integer_literal.h" +/*******************************************************************\ + +Function: convert_integer_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt convert_integer_literal(const std::string &src) { bool is_unsigned=false, is_imaginary=false; diff --git a/src/ansi-c/literals/convert_integer_literal.h b/src/ansi-c/literals/convert_integer_literal.h index 27c231d3790..5ce3847fdb6 100644 --- a/src/ansi-c/literals/convert_integer_literal.h +++ b/src/ansi-c/literals/convert_integer_literal.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Conversion - #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_INTEGER_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_INTEGER_LITERAL_H diff --git a/src/ansi-c/literals/convert_string_literal.cpp b/src/ansi-c/literals/convert_string_literal.cpp index 2589cdf122a..4176581afe2 100644 --- a/src/ansi-c/literals/convert_string_literal.cpp +++ b/src/ansi-c/literals/convert_string_literal.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C/C++ Language Conversion - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "unescape_string.h" #include "convert_string_literal.h" +/*******************************************************************\ + +Function: convert_one_string_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::basic_string convert_one_string_literal( const std::string &src) { @@ -70,6 +79,18 @@ std::basic_string convert_one_string_literal( } } +/*******************************************************************\ + +Function: convert_string_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt convert_string_literal(const std::string &src) { // note that 'src' could be a concatenation of string literals, diff --git a/src/ansi-c/literals/convert_string_literal.h b/src/ansi-c/literals/convert_string_literal.h index 16b7e5e5929..f634a1dfb1f 100644 --- a/src/ansi-c/literals/convert_string_literal.h +++ b/src/ansi-c/literals/convert_string_literal.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C/C++ Language Conversion - #ifndef CPROVER_ANSI_C_LITERALS_CONVERT_STRING_LITERAL_H #define CPROVER_ANSI_C_LITERALS_CONVERT_STRING_LITERAL_H diff --git a/src/ansi-c/literals/parse_float.cpp b/src/ansi-c/literals/parse_float.cpp index e5c67ea4d70..674e986e35a 100644 --- a/src/ansi-c/literals/parse_float.cpp +++ b/src/ansi-c/literals/parse_float.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Conversion of Expressions - #include #include "parse_float.h" +/*******************************************************************\ + +Function: convert_ct::parse_float + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_float( const std::string &src, mp_integer &significand, diff --git a/src/ansi-c/literals/parse_float.h b/src/ansi-c/literals/parse_float.h index b750c0cd77b..7edb55a08b7 100644 --- a/src/ansi-c/literals/parse_float.h +++ b/src/ansi-c/literals/parse_float.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Conversion / Type Checking - #ifndef CPROVER_ANSI_C_LITERALS_PARSE_FLOAT_H #define CPROVER_ANSI_C_LITERALS_PARSE_FLOAT_H diff --git a/src/ansi-c/literals/unescape_string.cpp b/src/ansi-c/literals/unescape_string.cpp index c5177be1ad5..6ecfadc703d 100644 --- a/src/ansi-c/literals/unescape_string.cpp +++ b/src/ansi-c/literals/unescape_string.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Conversion - #include #include #include #include "unescape_string.h" +/*******************************************************************\ + +Function: unescape_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string unescape_string(const std::string &src) { std::string dest; @@ -125,6 +134,18 @@ std::string unescape_string(const std::string &src) return dest; } +/*******************************************************************\ + +Function: unescape_wide_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::basic_string unescape_wide_string( const std::string &src) { @@ -235,6 +256,18 @@ std::basic_string unescape_wide_string( return dest; } +/*******************************************************************\ + +Function: hex_to_unsigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned hex_to_unsigned(const char *hex, std::size_t digits) { unsigned value=0; @@ -257,6 +290,18 @@ unsigned hex_to_unsigned(const char *hex, std::size_t digits) return value; } +/*******************************************************************\ + +Function: octal_to_unsigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned octal_to_unsigned(const char *octal, std::size_t digits) { unsigned value=0; diff --git a/src/ansi-c/literals/unescape_string.h b/src/ansi-c/literals/unescape_string.h index be6f1a18093..9d672cde19c 100644 --- a/src/ansi-c/literals/unescape_string.h +++ b/src/ansi-c/literals/unescape_string.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Conversion - #ifndef CPROVER_ANSI_C_LITERALS_UNESCAPE_STRING_H #define CPROVER_ANSI_C_LITERALS_UNESCAPE_STRING_H diff --git a/src/ansi-c/padding.cpp b/src/ansi-c/padding.cpp index 24b40649ca2..16391ee33a7 100644 --- a/src/ansi-c/padding.cpp +++ b/src/ansi-c/padding.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "padding.h" +/*******************************************************************\ + +Function: alignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer alignment(const typet &type, const namespacet &ns) { // we need to consider a number of different cases: @@ -105,6 +114,18 @@ mp_integer alignment(const typet &type, const namespacet &ns) return result; } +/*******************************************************************\ + +Function: add_padding + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_padding(struct_typet &type, const namespacet &ns) { struct_typet::componentst &components=type.components(); @@ -301,6 +322,18 @@ void add_padding(struct_typet &type, const namespacet &ns) } } +/*******************************************************************\ + +Function: add_padding + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_padding(union_typet &type, const namespacet &ns) { mp_integer max_alignment=alignment(type, ns)*8; diff --git a/src/ansi-c/padding.h b/src/ansi-c/padding.h index 27fb6fda099..18634a61559 100644 --- a/src/ansi-c/padding.h +++ b/src/ansi-c/padding.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Type Checking - #ifndef CPROVER_ANSI_C_PADDING_H #define CPROVER_ANSI_C_PADDING_H diff --git a/src/ansi-c/preprocessor_line.cpp b/src/ansi-c/preprocessor_line.cpp index b3b2ea1e2c5..a9b651fc3f7 100644 --- a/src/ansi-c/preprocessor_line.cpp +++ b/src/ansi-c/preprocessor_line.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Conversion - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "literals/unescape_string.h" #include "preprocessor_line.h" +/*******************************************************************\ + +Function: preprocessor_line + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void preprocessor_line( const char *text, parsert &parser) diff --git a/src/ansi-c/preprocessor_line.h b/src/ansi-c/preprocessor_line.h index bd18aa636fe..5222fdd83d9 100644 --- a/src/ansi-c/preprocessor_line.h +++ b/src/ansi-c/preprocessor_line.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Language Conversion - #ifndef CPROVER_ANSI_C_PREPROCESSOR_LINE_H #define CPROVER_ANSI_C_PREPROCESSOR_LINE_H diff --git a/src/ansi-c/printf_formatter.cpp b/src/ansi-c/printf_formatter.cpp index e1431798e2a..31ddfa735f2 100644 --- a/src/ansi-c/printf_formatter.cpp +++ b/src/ansi-c/printf_formatter.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// printf Formatting - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_types.h" #include "printf_formatter.h" +/*******************************************************************\ + +Function: printf_formattert::make_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt printf_formattert::make_type( const exprt &src, const typet &dest) { @@ -29,6 +38,18 @@ const exprt printf_formattert::make_type( return tmp; } +/*******************************************************************\ + +Function: printf_formattert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void printf_formattert::operator()( const std::string &_format, const std::list &_operands) @@ -37,6 +58,18 @@ void printf_formattert::operator()( operands=_operands; } +/*******************************************************************\ + +Function: printf_formattert::print() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void printf_formattert::print(std::ostream &out) { format_pos=0; @@ -52,6 +85,18 @@ void printf_formattert::print(std::ostream &out) } } +/*******************************************************************\ + +Function: printf_formattert::as_string() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string printf_formattert::as_string() { std::ostringstream stream; @@ -59,6 +104,18 @@ std::string printf_formattert::as_string() return stream.str(); } +/*******************************************************************\ + +Function: printf_formattert::process_format + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void printf_formattert::process_format(std::ostream &out) { exprt tmp; @@ -179,6 +236,18 @@ void printf_formattert::process_format(std::ostream &out) } } +/*******************************************************************\ + +Function: printf_formattert::process_char + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void printf_formattert::process_char(std::ostream &out) { char ch=next(); diff --git a/src/ansi-c/printf_formatter.h b/src/ansi-c/printf_formatter.h index 2cc36b87d1e..4048af9a6a4 100644 --- a/src/ansi-c/printf_formatter.h +++ b/src/ansi-c/printf_formatter.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// printf Formatting - #ifndef CPROVER_ANSI_C_PRINTF_FORMATTER_H #define CPROVER_ANSI_C_PRINTF_FORMATTER_H diff --git a/src/ansi-c/string_constant.cpp b/src/ansi-c/string_constant.cpp index 9f09a2abed0..6576a99ea5b 100644 --- a/src/ansi-c/string_constant.cpp +++ b/src/ansi-c/string_constant.cpp @@ -12,18 +12,54 @@ Author: Daniel Kroening, kroening@kroening.com #include "string_constant.h" #include "c_types.h" +/*******************************************************************\ + +Function: string_constantt::string_constantt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + string_constantt::string_constantt(): exprt(ID_string_constant) { set_value(irep_idt()); } +/*******************************************************************\ + +Function: string_constantt::string_constantt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + string_constantt::string_constantt(const irep_idt &_value): exprt(ID_string_constant) { set_value(_value); } +/*******************************************************************\ + +Function: string_constantt::set_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_constantt::set_value(const irep_idt &value) { exprt size_expr=from_integer(value.size()+1, index_type()); @@ -31,7 +67,18 @@ void string_constantt::set_value(const irep_idt &value) set(ID_value, value); } -/// convert string into array constant +/*******************************************************************\ + +Function: string_constantt:to_array_expr + + Inputs: + + Outputs: + + Purpose: convert string into array constant + +\*******************************************************************/ + array_exprt string_constantt::to_array_expr() const { const std::string &str=get_string(ID_value); @@ -72,8 +119,18 @@ array_exprt string_constantt::to_array_expr() const return dest; } -/// convert array constant into string -/// \return true on error +/*******************************************************************\ + +Function: string_constantt:from_array_expr + + Inputs: + + Outputs: true on error + + Purpose: convert array constant into string + +\*******************************************************************/ + bool string_constantt::from_array_expr(const array_exprt &src) { id(ID_string_constant); diff --git a/src/ansi-c/type2name.cpp b/src/ansi-c/type2name.cpp index 6e3ce05b757..fdcf6b0a276 100644 --- a/src/ansi-c/type2name.cpp +++ b/src/ansi-c/type2name.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// Type Naming for C - #include #include #include @@ -25,6 +22,18 @@ static std::string type2name( const namespacet &ns, symbol_numbert &symbol_number); +/*******************************************************************\ + +Function: type2name_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string type2name_symbol( const typet &type, const namespacet &ns, @@ -81,6 +90,18 @@ static std::string type2name_symbol( return result; } +/*******************************************************************\ + +Function: type2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool parent_is_sym_check=false; static std::string type2name( const typet &type, @@ -257,6 +278,18 @@ static std::string type2name( return result; } +/*******************************************************************\ + +Function: type2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2name(const typet &type, const namespacet &ns) { parent_is_sym_check=true; @@ -264,6 +297,18 @@ std::string type2name(const typet &type, const namespacet &ns) return type2name(type, ns, symbol_number); } +/*******************************************************************\ + +Function: type2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2name(const typet &type) { symbol_tablet symbol_table; diff --git a/src/ansi-c/type2name.h b/src/ansi-c/type2name.h index b8d2d5c0e05..b7299617e7f 100644 --- a/src/ansi-c/type2name.h +++ b/src/ansi-c/type2name.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// Type Naming for C - #ifndef CPROVER_ANSI_C_TYPE2NAME_H #define CPROVER_ANSI_C_TYPE2NAME_H diff --git a/src/assembler/assembler_parser.cpp b/src/assembler/assembler_parser.cpp index 045572b7d1f..59367857340 100644 --- a/src/assembler/assembler_parser.cpp +++ b/src/assembler/assembler_parser.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com assembler_parsert assembler_parser; +/*******************************************************************\ + +Function: yyassemblererror + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + extern char *yyassemblertext; int yyassemblererror(const std::string &error) diff --git a/src/cbmc/all_properties.cpp b/src/cbmc/all_properties.cpp index bd9c5242dd4..2534ba7827a 100644 --- a/src/cbmc/all_properties.cpp +++ b/src/cbmc/all_properties.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "all_properties_class.h" +/*******************************************************************\ + +Function: bmc_all_propertiest::goal_covered + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &) { for(auto &g : goal_map) @@ -52,6 +61,18 @@ void bmc_all_propertiest::goal_covered(const cover_goalst::goalt &) } } +/*******************************************************************\ + +Function: bmc_all_propertiest::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt bmc_all_propertiest::operator()() { status() << "Passing problem to " << solver.decision_procedure_text() << eom; @@ -157,6 +178,18 @@ safety_checkert::resultt bmc_all_propertiest::operator()() return safe?safety_checkert::resultt::SAFE:safety_checkert::resultt::UNSAFE; } +/*******************************************************************\ + +Function: bmc_all_propertiest::report() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmc_all_propertiest::report(const cover_goalst &cover_goals) { switch(bmc.ui) @@ -230,6 +263,18 @@ void bmc_all_propertiest::report(const cover_goalst &cover_goals) } } +/*******************************************************************\ + +Function: bmct::all_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt bmct::all_properties( const goto_functionst &goto_functions, prop_convt &solver) diff --git a/src/cbmc/all_properties_class.h b/src/cbmc/all_properties_class.h index 89c4614cc12..1f3fc27960a 100644 --- a/src/cbmc/all_properties_class.h +++ b/src/cbmc/all_properties_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #ifndef CPROVER_CBMC_ALL_PROPERTIES_CLASS_H #define CPROVER_CBMC_ALL_PROPERTIES_CLASS_H @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" +/*******************************************************************\ + + Class: bmc_all_propertiest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class bmc_all_propertiest: public cover_goalst::observert, public messaget diff --git a/src/cbmc/bmc.cpp b/src/cbmc/bmc.cpp index f92483d2441..0a8fd5053c8 100644 --- a/src/cbmc/bmc.cpp +++ b/src/cbmc/bmc.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -42,11 +39,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "fault_localization.h" #include "bmc.h" +/*******************************************************************\ + +Function: bmct::do_unwind_module + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::do_unwind_module() { // this is a hook for hw-cbmc } +/*******************************************************************\ + +Function: bmct::error_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::error_trace() { status() << "Building error trace" << eom; @@ -88,7 +109,18 @@ void bmct::error_trace() } } -/// outputs witnesses in graphml format +/*******************************************************************\ + +Function: bmct::output_graphml + + Inputs: + + Outputs: + + Purpose: outputs witnesses in graphml format + +\*******************************************************************/ + void bmct::output_graphml( resultt result, const goto_functionst &goto_functions) @@ -114,6 +146,18 @@ void bmct::output_graphml( } } +/*******************************************************************\ + +Function: bmct::do_conversion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::do_conversion() { // convert HDL (hook for hw-cbmc) @@ -134,6 +178,18 @@ void bmct::do_conversion() } } +/*******************************************************************\ + +Function: bmct::run_decision_procedure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt bmct::run_decision_procedure(prop_convt &prop_conv) { @@ -161,6 +217,18 @@ bmct::run_decision_procedure(prop_convt &prop_conv) return dec_result; } +/*******************************************************************\ + +Function: bmct::report_success + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -189,6 +257,18 @@ void bmct::report_success() } } +/*******************************************************************\ + +Function: bmct::report_failure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -217,6 +297,18 @@ void bmct::report_failure() } } +/*******************************************************************\ + +Function: bmct::show_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::show_program() { unsigned count=1; @@ -306,6 +398,18 @@ void bmct::show_program() } } +/*******************************************************************\ + +Function: bmct::run + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt bmct::run( const goto_functionst &goto_functions) { @@ -491,6 +595,18 @@ safety_checkert::resultt bmct::run( } } +/*******************************************************************\ + +Function: bmct::decide + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt bmct::decide( const goto_functionst &goto_functions, prop_convt &prop_conv) @@ -503,6 +619,18 @@ safety_checkert::resultt bmct::decide( return all_properties(goto_functions, prop_conv); } +/*******************************************************************\ + +Function: bmct::stop_on_fail + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt bmct::stop_on_fail( const goto_functionst &goto_functions, prop_convt &prop_conv) @@ -539,6 +667,18 @@ safety_checkert::resultt bmct::stop_on_fail( } } +/*******************************************************************\ + +Function: bmct::setup_unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::setup_unwind() { const std::string &set=options.get_option("unwindset"); diff --git a/src/cbmc/bmc.h b/src/cbmc/bmc.h index 4c69fab527c..33d73005c1a 100644 --- a/src/cbmc/bmc.h +++ b/src/cbmc/bmc.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Bounded Model Checking for ANSI-C + HDL - #ifndef CPROVER_CBMC_BMC_H #define CPROVER_CBMC_BMC_H diff --git a/src/cbmc/bmc_cover.cpp b/src/cbmc/bmc_cover.cpp index 4c101cc2159..fd900dda14d 100644 --- a/src/cbmc/bmc_cover.cpp +++ b/src/cbmc/bmc_cover.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Test-Suite Generation with BMC - #include #include @@ -27,6 +24,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" #include "bv_cbmc.h" +/*******************************************************************\ + + Class: bmc_covert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class bmc_covert: public cover_goalst::observert, public messaget @@ -140,6 +149,18 @@ class bmc_covert: bmct &bmc; }; +/*******************************************************************\ + +Function: bmc_covert::satisfying_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmc_covert::satisfying_assignment() { tests.push_back(testt()); @@ -189,6 +210,18 @@ void bmc_covert::satisfying_assignment() #endif } +/*******************************************************************\ + +Function: bmc_covert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bmc_covert::operator()() { status() << "Passing problem to " << solver.decision_procedure_text() << eom; @@ -430,7 +463,18 @@ bool bmc_covert::operator()() return false; } -/// Try to cover all goals +/*******************************************************************\ + +Function: bmct::cover + + Inputs: + + Outputs: + + Purpose: Try to cover all goals + +\*******************************************************************/ + bool bmct::cover( const goto_functionst &goto_functions, const optionst::value_listt &criteria) diff --git a/src/cbmc/bv_cbmc.cpp b/src/cbmc/bv_cbmc.cpp index 6445c6e0295..830507c0099 100644 --- a/src/cbmc/bv_cbmc.cpp +++ b/src/cbmc/bv_cbmc.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_cbmc.h" +/*******************************************************************\ + +Function: bv_cbmct::convert_waitfor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_cbmct::convert_waitfor(const exprt &expr) { if(expr.operands().size()!=4) @@ -132,6 +144,18 @@ bvt bv_cbmct::convert_waitfor(const exprt &expr) return convert_bitvector(new_cycle); } +/*******************************************************************\ + +Function: bv_cbmct::convert_waitfor_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_cbmct::convert_waitfor_symbol(const exprt &expr) { if(expr.operands().size()!=1) @@ -155,6 +179,18 @@ bvt bv_cbmct::convert_waitfor_symbol(const exprt &expr) return convert_bitvector(result); } +/*******************************************************************\ + +Function: bv_cbmct::convert_bitvector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_cbmct::convert_bitvector(const exprt &expr) { if(expr.id()=="waitfor") diff --git a/src/cbmc/cbmc_dimacs.cpp b/src/cbmc/cbmc_dimacs.cpp index 8584c8fac4b..4df2dfbbed9 100644 --- a/src/cbmc/cbmc_dimacs.cpp +++ b/src/cbmc/cbmc_dimacs.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Writing DIMACS Files - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_dimacs.h" +/*******************************************************************\ + +Function: cbmc_dimacst::write_dimacs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cbmc_dimacst::write_dimacs(const std::string &filename) { if(filename.empty() || filename=="-") @@ -32,6 +41,18 @@ bool cbmc_dimacst::write_dimacs(const std::string &filename) return write_dimacs(out); } +/*******************************************************************\ + +Function: cbmc_dimacst::write_dimacs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cbmc_dimacst::write_dimacs(std::ostream &out) { dynamic_cast(prop).write_dimacs_cnf(out); diff --git a/src/cbmc/cbmc_dimacs.h b/src/cbmc/cbmc_dimacs.h index 444a99e73f4..e8ccda5155a 100644 --- a/src/cbmc/cbmc_dimacs.h +++ b/src/cbmc/cbmc_dimacs.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Writing DIMACS Files - #ifndef CPROVER_CBMC_CBMC_DIMACS_H #define CPROVER_CBMC_CBMC_DIMACS_H diff --git a/src/cbmc/cbmc_languages.cpp b/src/cbmc/cbmc_languages.cpp index b9ece275261..a18d0344833 100644 --- a/src/cbmc/cbmc_languages.cpp +++ b/src/cbmc/cbmc_languages.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Language Registration - #include #include @@ -28,6 +25,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_parse_options.h" +/*******************************************************************\ + +Function: cbmc_parse_optionst::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_parse_optionst::register_languages() { register_language(new_ansi_c_language); diff --git a/src/cbmc/cbmc_main.cpp b/src/cbmc/cbmc_main.cpp index 81bf25a7b83..d09ecc4772e 100644 --- a/src/cbmc/cbmc_main.cpp +++ b/src/cbmc/cbmc_main.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CBMC Main Module - /* CBMC @@ -25,6 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cbmc_parse_options.h" +/*******************************************************************\ + +Function: main / wmain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef IREP_HASH_STATS extern unsigned long long irep_hash_cnt; extern unsigned long long irep_cmp_cnt; diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp index 1ad81dd1d1e..b9230c6b4e6 100644 --- a/src/cbmc/cbmc_parse_options.cpp +++ b/src/cbmc/cbmc_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CBMC Command Line Option Processing - #include #include // exit() #include @@ -65,6 +62,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "version.h" #include "xml_interface.h" +/*******************************************************************\ + +Function: cbmc_parse_optionst::cbmc_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv): parse_options_baset(CBMC_OPTIONS, argc, argv), xml_interfacet(cmdline), @@ -73,6 +82,18 @@ cbmc_parse_optionst::cbmc_parse_optionst(int argc, const char **argv): { } +/*******************************************************************\ + +Function: cbmc_parse_optionst::cbmc_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ::cbmc_parse_optionst::cbmc_parse_optionst( int argc, const char **argv, @@ -84,6 +105,18 @@ ::cbmc_parse_optionst::cbmc_parse_optionst( { } +/*******************************************************************\ + +Function: cbmc_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -99,6 +132,18 @@ void cbmc_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } +/*******************************************************************\ + +Function: cbmc_parse_optionst::get_command_line_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -411,7 +456,18 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) cmdline.get_value("symex-coverage-report")); } -/// invoke main modules +/*******************************************************************\ + +Function: cbmc_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int cbmc_parse_optionst::doit() { if(cmdline.isset("version")) @@ -510,6 +566,18 @@ int cbmc_parse_optionst::doit() return do_bmc(bmc, goto_functions); } +/*******************************************************************\ + +Function: cbmc_parse_optionst::set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cbmc_parse_optionst::set_properties(goto_functionst &goto_functions) { try @@ -541,6 +609,18 @@ bool cbmc_parse_optionst::set_properties(goto_functionst &goto_functions) return false; } +/*******************************************************************\ + +Function: cbmc_parse_optionst::get_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cbmc_parse_optionst::get_goto_program( const optionst &options, bmct &bmc, // for get_modules @@ -707,6 +787,18 @@ int cbmc_parse_optionst::get_goto_program( return -1; // no error, continue } +/*******************************************************************\ + +Function: cbmc_parse_optionst::preprocessing + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_parse_optionst::preprocessing() { try @@ -763,6 +855,18 @@ void cbmc_parse_optionst::preprocessing() } } +/*******************************************************************\ + +Function: cbmc_parse_optionst::process_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cbmc_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -911,7 +1015,18 @@ bool cbmc_parse_optionst::process_goto_program( return false; } -/// invoke main modules +/*******************************************************************\ + +Function: cbmc_parse_optionst::do_bmc + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int cbmc_parse_optionst::do_bmc( bmct &bmc, const goto_functionst &goto_functions) @@ -942,7 +1057,18 @@ int cbmc_parse_optionst::do_bmc( return result; } -/// display command line help +/*******************************************************************\ + +Function: cbmc_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void cbmc_parse_optionst::help() { std::cout << diff --git a/src/cbmc/cbmc_parse_options.h b/src/cbmc/cbmc_parse_options.h index 8c68eb57f1b..2c54dfc7353 100644 --- a/src/cbmc/cbmc_parse_options.h +++ b/src/cbmc/cbmc_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CBMC Command Line Option Processing - #ifndef CPROVER_CBMC_CBMC_PARSE_OPTIONS_H #define CPROVER_CBMC_CBMC_PARSE_OPTIONS_H diff --git a/src/cbmc/cbmc_solvers.cpp b/src/cbmc/cbmc_solvers.cpp index 1825a1cd3ab..a9395f476bb 100644 --- a/src/cbmc/cbmc_solvers.cpp +++ b/src/cbmc/cbmc_solvers.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Solvers for VCs Generated by Symbolic Execution of ANSI-C - #include #include #include @@ -30,8 +27,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "counterexample_beautification.h" #include "version.h" -/// Uses the options to pick an SMT 1.2 solver -/// \return An smt1_dect::solvert giving the solver to use. +/*******************************************************************\ + +Function: cbmc_solverst::get_smt1_solver_type + + Inputs: None + + Outputs: An smt1_dect::solvert giving the solver to use. + + Purpose: Uses the options to pick an SMT 1.2 solver + +\*******************************************************************/ + smt1_dect::solvert cbmc_solverst::get_smt1_solver_type() const { assert(options.get_bool_option("smt1")); @@ -58,8 +65,18 @@ smt1_dect::solvert cbmc_solverst::get_smt1_solver_type() const return s; } -/// Uses the options to pick an SMT 2.0 solver -/// \return An smt2_dect::solvert giving the solver to use. +/*******************************************************************\ + +Function: cbmc_solverst::get_smt2_solver_type + + Inputs: None + + Outputs: An smt2_dect::solvert giving the solver to use. + + Purpose: Uses the options to pick an SMT 2.0 solver + +\*******************************************************************/ + smt2_dect::solvert cbmc_solverst::get_smt2_solver_type() const { assert(options.get_bool_option("smt2")); @@ -86,7 +103,18 @@ smt2_dect::solvert cbmc_solverst::get_smt2_solver_type() const return s; } -/// Get the default decision procedure +/*******************************************************************\ + +Function: cbmc_solverst::get_default + + Inputs: + + Outputs: + + Purpose: Get the default decision procedure + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_default() { solvert *solver=new solvert; @@ -116,6 +144,18 @@ cbmc_solverst::solvert* cbmc_solverst::get_default() return solver; } +/*******************************************************************\ + +Function: cbmc_solverst::get_dimacs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_dimacs() { no_beautification(); @@ -129,6 +169,18 @@ cbmc_solverst::solvert* cbmc_solverst::get_dimacs() return new solvert(new cbmc_dimacst(ns, *prop, filename), prop); } +/*******************************************************************\ + +Function: cbmc_solverst::get_bv_refinement + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() { propt *prop; @@ -160,9 +212,17 @@ cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement() return new solvert(bv_refinement, prop); } -/// the string refinement adds to the bit vector refinement specifications for -/// functions from the Java string library -/// \return a solver for cbmc +/*******************************************************************\ + +Function: cbmc_solverst::get_string_refinement + + Outputs: a solver for cbmc + + Purpose: the string refinement adds to the bit vector refinement + specifications for functions from the Java string library + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_string_refinement() { propt *prop; @@ -194,6 +254,18 @@ cbmc_solverst::solvert* cbmc_solverst::get_string_refinement() return new solvert(string_refinement, prop); } +/*******************************************************************\ + +Function: cbmc_solverst::get_smt1 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) { no_beautification(); @@ -263,6 +335,18 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt1(smt1_dect::solvert solver) } } +/*******************************************************************\ + +Function: cbmc_solverst::get_smt2 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) { no_beautification(); @@ -340,6 +424,18 @@ cbmc_solverst::solvert* cbmc_solverst::get_smt2(smt2_dect::solvert solver) } } +/*******************************************************************\ + +Function: cbmc_solverst::no_beautification + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_solverst::no_beautification() { if(options.get_bool_option("beautify")) @@ -349,6 +445,18 @@ void cbmc_solverst::no_beautification() } } +/*******************************************************************\ + +Function: cbmc_solverst::no_incremental_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cbmc_solverst::no_incremental_check() { if(options.get_bool_option("all-properties") || diff --git a/src/cbmc/cbmc_solvers.h b/src/cbmc/cbmc_solvers.h index f17f9b663bf..c837bd55806 100644 --- a/src/cbmc/cbmc_solvers.h +++ b/src/cbmc/cbmc_solvers.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Bounded Model Checking for ANSI-C + HDL - #ifndef CPROVER_CBMC_CBMC_SOLVERS_H #define CPROVER_CBMC_CBMC_SOLVERS_H @@ -30,6 +27,12 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_cbmc.h" +/*******************************************************************\ + +Solver factory + +\*******************************************************************/ + class cbmc_solverst:public messaget { public: diff --git a/src/cbmc/counterexample_beautification.cpp b/src/cbmc/counterexample_beautification.cpp index 334366ca8f2..a65069618df 100644 --- a/src/cbmc/counterexample_beautification.cpp +++ b/src/cbmc/counterexample_beautification.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Counterexample Beautification using Incremental SAT - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "counterexample_beautification.h" +/*******************************************************************\ + +Function: counterexample_beautificationt::get_minimization_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void counterexample_beautificationt::get_minimization_list( prop_convt &prop_conv, const symex_target_equationt &equation, @@ -59,6 +68,18 @@ void counterexample_beautificationt::get_minimization_list( } } +/*******************************************************************\ + +Function: counterexample_beautificationt::get_failed_property + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_target_equationt::SSA_stepst::const_iterator counterexample_beautificationt::get_failed_property( const prop_convt &prop_conv, @@ -78,6 +99,18 @@ counterexample_beautificationt::get_failed_property( return equation.SSA_steps.end(); } +/*******************************************************************\ + +Function: counterexample_beautificationt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void counterexample_beautificationt::operator()( bv_cbmct &bv_cbmc, const symex_target_equationt &equation, diff --git a/src/cbmc/counterexample_beautification.h b/src/cbmc/counterexample_beautification.h index 10bb96f4597..d4f9c35bc88 100644 --- a/src/cbmc/counterexample_beautification.h +++ b/src/cbmc/counterexample_beautification.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Counterexample Beautification - #ifndef CPROVER_CBMC_COUNTEREXAMPLE_BEAUTIFICATION_H #define CPROVER_CBMC_COUNTEREXAMPLE_BEAUTIFICATION_H diff --git a/src/cbmc/fault_localization.cpp b/src/cbmc/fault_localization.cpp index 2beae26ff79..f248428c5be 100644 --- a/src/cbmc/fault_localization.cpp +++ b/src/cbmc/fault_localization.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Fault Localization - #include #include #include @@ -24,6 +21,18 @@ Author: Peter Schrammel #include "fault_localization.h" #include "counterexample_beautification.h" +/*******************************************************************\ + +Function: fault_localizationt::freeze_guards + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::freeze_guards() { for(const auto &step : bmc.equation.SSA_steps) @@ -36,6 +45,18 @@ void fault_localizationt::freeze_guards() } } +/*******************************************************************\ + +Function: fault_localizationt::collect_guards + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::collect_guards(lpointst &lpoints) { for(symex_target_equationt::SSA_stepst::const_iterator @@ -59,6 +80,18 @@ void fault_localizationt::collect_guards(lpointst &lpoints) } } +/*******************************************************************\ + +Function: fault_localizationt::get_failed_property + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_target_equationt::SSA_stepst::const_iterator fault_localizationt::get_failed_property() { @@ -74,6 +107,18 @@ fault_localizationt::get_failed_property() return bmc.equation.SSA_steps.end(); } +/*******************************************************************\ + +Function: fault_localizationt::check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool fault_localizationt::check(const lpointst &lpoints, const lpoints_valuet &value) { @@ -100,6 +145,18 @@ bool fault_localizationt::check(const lpointst &lpoints, return true; } +/*******************************************************************\ + +Function: fault_localizationt::update_scores + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::update_scores(lpointst &lpoints, const lpoints_valuet &value) { @@ -117,6 +174,18 @@ void fault_localizationt::update_scores(lpointst &lpoints, } } +/*******************************************************************\ + +Function: fault_localizationt::localize_linear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::localize_linear(lpointst &lpoints) { lpoints_valuet v; @@ -135,6 +204,18 @@ void fault_localizationt::localize_linear(lpointst &lpoints) } } +/*******************************************************************\ + +Function: fault_localizationt::run + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::run(irep_idt goal_id) { // find failed property @@ -162,6 +243,18 @@ void fault_localizationt::run(irep_idt goal_id) bmc.prop_conv.set_assumptions(assumptions); } +/*******************************************************************\ + +Function: fault_localizationt::report() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::report(irep_idt goal_id) { if(goal_id==ID_nil) @@ -191,6 +284,18 @@ void fault_localizationt::report(irep_idt goal_id) << eom; } +/*******************************************************************\ + +Function: fault_localizationt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt fault_localizationt::operator()() { if(options.get_bool_option("stop-on-fail")) @@ -199,6 +304,18 @@ safety_checkert::resultt fault_localizationt::operator()() return bmc_all_propertiest::operator()(); } +/*******************************************************************\ + +Function: fault_localizationt::run_decision_procedure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt fault_localizationt::run_decision_procedure(prop_convt &prop_conv) { @@ -229,6 +346,18 @@ fault_localizationt::run_decision_procedure(prop_convt &prop_conv) return dec_result; } +/*******************************************************************\ + +Function: fault_localizationt::stop_on_fail + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::resultt fault_localizationt::stop_on_fail() { switch(run_decision_procedure(bmc.prop_conv)) @@ -262,6 +391,18 @@ safety_checkert::resultt fault_localizationt::stop_on_fail() } } +/*******************************************************************\ + +Function: fault_localizationt::goal_covered + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::goal_covered( const cover_goalst::goalt &) { @@ -293,6 +434,18 @@ void fault_localizationt::goal_covered( } } +/*******************************************************************\ + +Function: fault_localizationt::report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fault_localizationt::report( const cover_goalst &cover_goals) { diff --git a/src/cbmc/fault_localization.h b/src/cbmc/fault_localization.h index 0c3ec090153..552095b7cd3 100644 --- a/src/cbmc/fault_localization.h +++ b/src/cbmc/fault_localization.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Fault Localization - #ifndef CPROVER_CBMC_FAULT_LOCALIZATION_H #define CPROVER_CBMC_FAULT_LOCALIZATION_H diff --git a/src/cbmc/show_vcc.cpp b/src/cbmc/show_vcc.cpp index f7a777173ce..1ae0de6900a 100644 --- a/src/cbmc/show_vcc.cpp +++ b/src/cbmc/show_vcc.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bmc.h" +/*******************************************************************\ + +Function: bmct::show_vcc_plain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::show_vcc_plain(std::ostream &out) { out << "\n" << "VERIFICATION CONDITIONS:" << "\n" << "\n"; @@ -81,6 +90,18 @@ void bmct::show_vcc_plain(std::ostream &out) } } +/*******************************************************************\ + +Function: bmct::show_vcc_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::show_vcc_json(std::ostream &out) { json_objectt json_result; @@ -139,6 +160,18 @@ void bmct::show_vcc_json(std::ostream &out) out << ",\n" << json_result; } +/*******************************************************************\ + +Function: bmct::show_vcc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bmct::show_vcc() { const std::string &filename=options.get_option("outfile"); diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index beb014d6db5..5ae65275ef6 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Bounded Model Checking for ANSI-C - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "symex_bmc.h" +/*******************************************************************\ + +Function: symex_bmct::symex_bmct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_bmct::symex_bmct( const namespacet &_ns, symbol_tablet &_new_symbol_table, @@ -27,7 +36,18 @@ symex_bmct::symex_bmct( { } -/// show progress +/*******************************************************************\ + +Function: symex_bmct::symex_step + + Inputs: + + Outputs: + + Purpose: show progress + +\*******************************************************************/ + void symex_bmct::symex_step( const goto_functionst &goto_functions, statet &state) @@ -76,6 +96,18 @@ void symex_bmct::symex_step( symex_coverage.covered(cur_pc, state.source.pc); } +/*******************************************************************\ + +Function: symex_bmct::merge_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_bmct::merge_goto( const statet::goto_statet &goto_state, statet &state) @@ -95,6 +127,18 @@ void symex_bmct::merge_goto( symex_coverage.covered(prev_pc, state.source.pc); } +/*******************************************************************\ + +Function: symex_bmct::get_unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_bmct::get_unwind( const symex_targett::sourcet &source, unsigned unwind) @@ -136,6 +180,18 @@ bool symex_bmct::get_unwind( return abort; } +/*******************************************************************\ + +Function: symex_bmct::get_unwind_recursion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_bmct::get_unwind_recursion( const irep_idt &id, const unsigned thread_nr, @@ -181,6 +237,18 @@ bool symex_bmct::get_unwind_recursion( return abort; } +/*******************************************************************\ + +Function: symex_bmct::no_body + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_bmct::no_body(const irep_idt &identifier) { if(body_warnings.insert(identifier).second) diff --git a/src/cbmc/symex_bmc.h b/src/cbmc/symex_bmc.h index b8d23a52719..8b2df348f3b 100644 --- a/src/cbmc/symex_bmc.h +++ b/src/cbmc/symex_bmc.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Bounded Model Checking for ANSI-C - #ifndef CPROVER_CBMC_SYMEX_BMC_H #define CPROVER_CBMC_SYMEX_BMC_H diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index c36490f67f5..812df4de062 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -8,9 +8,6 @@ Date: March 2016 \*******************************************************************/ -/// \file -/// Record and print code coverage of symbolic execution - #include #include #include @@ -94,6 +91,18 @@ class goto_program_coverage_recordt:public coverage_recordt coverage_lines_mapt &dest); }; +/*******************************************************************\ + +Function: rate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string rate( std::size_t covered, std::size_t total, @@ -120,6 +129,18 @@ static std::string rate( return oss.str(); } +/*******************************************************************\ + +Function: goto_program_coverage_recordt::goto_program_coverage_recordt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_program_coverage_recordt::goto_program_coverage_recordt( const namespacet &ns, goto_functionst::function_mapt::const_iterator gf_it, @@ -206,6 +227,18 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( } } +/*******************************************************************\ + +Function: goto_program_coverage_recordt::compute_coverage_lines + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_coverage_recordt::compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, @@ -288,6 +321,18 @@ void goto_program_coverage_recordt::compute_coverage_lines( } } +/*******************************************************************\ + +Function: symex_coveraget::compute_overall_coverage + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_coveraget::compute_overall_coverage( const goto_functionst &goto_functions, coverage_recordt &dest) const @@ -364,6 +409,18 @@ void symex_coveraget::compute_overall_coverage( } } +/*******************************************************************\ + +Function: symex_coveraget::build_cobertura + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_coveraget::build_cobertura( const goto_functionst &goto_functions, xmlt &xml_coverage) const @@ -405,6 +462,18 @@ void symex_coveraget::build_cobertura( package.set_attribute("complexity", "0.0"); } +/*******************************************************************\ + +Function: symex_coveraget::output_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_coveraget::output_report( const goto_functionst &goto_functions, std::ostream &os) const @@ -420,6 +489,18 @@ bool symex_coveraget::output_report( return !os.good(); } +/*******************************************************************\ + +Function: symex_coveraget::output_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_coveraget::generate_report( const goto_functionst &goto_functions, const std::string &path) const diff --git a/src/cbmc/symex_coverage.h b/src/cbmc/symex_coverage.h index b7556b1087b..c173bc65ad7 100644 --- a/src/cbmc/symex_coverage.h +++ b/src/cbmc/symex_coverage.h @@ -8,9 +8,6 @@ Date: March 2016 \*******************************************************************/ -/// \file -/// Record and print code coverage of symbolic execution - #ifndef CPROVER_CBMC_SYMEX_COVERAGE_H #define CPROVER_CBMC_SYMEX_COVERAGE_H diff --git a/src/cbmc/xml_interface.cpp b/src/cbmc/xml_interface.cpp index da58cfe12c5..d94fa7bf034 100644 --- a/src/cbmc/xml_interface.cpp +++ b/src/cbmc/xml_interface.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// XML Interface - #include #include @@ -17,7 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "xml_interface.h" -/// XML User Interface +/*******************************************************************\ + +Function: xml_interfacet::get_xml_options + + Inputs: + + Outputs: + + Purpose: XML User Interface + +\*******************************************************************/ + void xml_interfacet::get_xml_options(cmdlinet &cmdline) { if(cmdline.isset("xml-interface")) @@ -33,7 +41,18 @@ void xml_interfacet::get_xml_options(cmdlinet &cmdline) } } -/// XML User Interface +/*******************************************************************\ + +Function: xml_interfacet::get_xml_options + + Inputs: + + Outputs: + + Purpose: XML User Interface + +\*******************************************************************/ + void xml_interfacet::get_xml_options( const xmlt &xml, cmdlinet &cmdline) diff --git a/src/cbmc/xml_interface.h b/src/cbmc/xml_interface.h index 945be7624bb..0cf038083db 100644 --- a/src/cbmc/xml_interface.h +++ b/src/cbmc/xml_interface.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// XML Interface - #ifndef CPROVER_CBMC_XML_INTERFACE_H #define CPROVER_CBMC_XML_INTERFACE_H diff --git a/src/clobber/clobber_main.cpp b/src/clobber/clobber_main.cpp index 16e2a286900..8255f068c92 100644 --- a/src/clobber/clobber_main.cpp +++ b/src/clobber/clobber_main.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symex Main Module - #include #include "clobber_parse_options.h" +/*******************************************************************\ + +Function: main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/clobber/clobber_parse_options.cpp b/src/clobber/clobber_parse_options.cpp index dfc4a08faf5..a8fd471ecb6 100644 --- a/src/clobber/clobber_parse_options.cpp +++ b/src/clobber/clobber_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symex Command Line Options Processing - #include #include #include @@ -40,6 +37,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "clobber_parse_options.h" // #include "clobber_instrumenter.h" +/*******************************************************************\ + +Function: clobber_parse_optionst::clobber_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + clobber_parse_optionst::clobber_parse_optionst(int argc, const char **argv): parse_options_baset(CLOBBER_OPTIONS, argc, argv), language_uit(cmdline, ui_message_handler), @@ -47,6 +56,18 @@ clobber_parse_optionst::clobber_parse_optionst(int argc, const char **argv): { } +/*******************************************************************\ + +Function: clobber_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void clobber_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -64,6 +85,18 @@ void clobber_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } +/*******************************************************************\ + +Function: clobber_parse_optionst::get_command_line_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void clobber_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -98,7 +131,18 @@ void clobber_parse_optionst::get_command_line_options(optionst &options) options.set_option("error-label", cmdline.get_value("error-label")); } -/// invoke main modules +/*******************************************************************\ + +Function: clobber_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int clobber_parse_optionst::doit() { if(cmdline.isset("version")) @@ -180,6 +224,18 @@ int clobber_parse_optionst::doit() #endif } +/*******************************************************************\ + +Function: clobber_parse_optionst::set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool clobber_parse_optionst::set_properties(goto_functionst &goto_functions) { if(cmdline.isset("property")) @@ -188,6 +244,18 @@ bool clobber_parse_optionst::set_properties(goto_functionst &goto_functions) return false; } +/*******************************************************************\ + +Function: clobber_parse_optionst::get_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool clobber_parse_optionst::get_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -310,6 +378,18 @@ bool clobber_parse_optionst::get_goto_program( return false; } +/*******************************************************************\ + +Function: clobber_parse_optionst::process_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool clobber_parse_optionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) @@ -355,6 +435,18 @@ bool clobber_parse_optionst::process_goto_program( return false; } +/*******************************************************************\ + +Function: clobber_parse_optionst::report_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #if 0 void clobber_parse_optionst::report_properties( const path_searcht::property_mapt &property_map) @@ -414,6 +506,18 @@ void clobber_parse_optionst::report_properties( } #endif +/*******************************************************************\ + +Function: clobber_parse_optionst::report_success + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void clobber_parse_optionst::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -437,6 +541,18 @@ void clobber_parse_optionst::report_success() } } +/*******************************************************************\ + +Function: clobber_parse_optionst::show_counterexample + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void clobber_parse_optionst::show_counterexample( const goto_tracet &error_trace) { @@ -462,6 +578,18 @@ void clobber_parse_optionst::show_counterexample( } } +/*******************************************************************\ + +Function: clobber_parse_optionst::report_failure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void clobber_parse_optionst::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -485,7 +613,18 @@ void clobber_parse_optionst::report_failure() } } -/// display command line help +/*******************************************************************\ + +Function: clobber_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void clobber_parse_optionst::help() { std::cout << diff --git a/src/clobber/clobber_parse_options.h b/src/clobber/clobber_parse_options.h index 89faff353f0..ffd897c9155 100644 --- a/src/clobber/clobber_parse_options.h +++ b/src/clobber/clobber_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Command Line Parsing - #ifndef CPROVER_CLOBBER_CLOBBER_PARSE_OPTIONS_H #define CPROVER_CLOBBER_CLOBBER_PARSE_OPTIONS_H diff --git a/src/cpp/cpp_constructor.cpp b/src/cpp/cpp_constructor.cpp index 53655ea75df..3c5b34762dd 100644 --- a/src/cpp/cpp_constructor.cpp +++ b/src/cpp/cpp_constructor.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -17,8 +14,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck.h" #include "cpp_util.h" -/// \param non:typchecked object, non-typechecked operands -/// \return typechecked code +/*******************************************************************\ + +Function: cpp_typecheckt::cpp_constructor + + Inputs: non-typchecked object, non-typechecked operands + + Outputs: typechecked code + + Purpose: + +\*******************************************************************/ + codet cpp_typecheckt::cpp_constructor( const source_locationt &source_location, const exprt &object, @@ -308,6 +315,18 @@ codet cpp_typecheckt::cpp_constructor( return nil; } +/*******************************************************************\ + +Function: cpp_typecheckt::new_temporary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::new_temporary( const source_locationt &source_location, const typet &type, @@ -340,6 +359,18 @@ void cpp_typecheckt::new_temporary( temporary.swap(tmp_object_expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::new_temporary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::new_temporary( const source_locationt &source_location, const typet &type, diff --git a/src/cpp/cpp_convert_type.cpp b/src/cpp/cpp_convert_type.cpp index d2c5e3989f9..0f106b19575 100644 --- a/src/cpp/cpp_convert_type.cpp +++ b/src/cpp/cpp_convert_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Conversion - #include #include @@ -45,6 +42,18 @@ class cpp_convert_typet void read_template(const typet &type); }; +/*******************************************************************\ + +Function: cpp_convert_typet::read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_typet::read(const typet &type) { unsigned_cnt=signed_cnt=char_cnt=int_cnt=short_cnt= @@ -63,6 +72,18 @@ void cpp_convert_typet::read(const typet &type) read_rec(type); } +/*******************************************************************\ + +Function: cpp_convert_typet::read_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_typet::read_rec(const typet &type) { #if 0 @@ -164,6 +185,18 @@ void cpp_convert_typet::read_rec(const typet &type) } } +/*******************************************************************\ + +Function: cpp_covnert_typet::read_template + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_typet::read_template(const typet &type) { other.push_back(type); @@ -192,6 +225,18 @@ void cpp_convert_typet::read_template(const typet &type) } } +/*******************************************************************\ + +Function: cpp_convert_typet::read_function_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_typet::read_function_type(const typet &type) { other.push_back(type); @@ -293,6 +338,18 @@ void cpp_convert_typet::read_function_type(const typet &type) parameters.get_sub().clear(); } +/*******************************************************************\ + +Function: cpp_convert_typet::write + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_typet::write(typet &type) { type.clear(); @@ -543,6 +600,18 @@ void cpp_convert_typet::write(typet &type) type.set(ID_C_volatile, true); } +/*******************************************************************\ + +Function: cpp_convert_plain_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_convert_plain_type(typet &type) { if(type.id()==ID_cpp_name || diff --git a/src/cpp/cpp_convert_type.h b/src/cpp/cpp_convert_type.h index 590ce6e98a6..9c690287fae 100644 --- a/src/cpp/cpp_convert_type.h +++ b/src/cpp/cpp_convert_type.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Conversion - #ifndef CPROVER_CPP_CPP_CONVERT_TYPE_H #define CPROVER_CPP_CPP_CONVERT_TYPE_H diff --git a/src/cpp/cpp_declaration.cpp b/src/cpp/cpp_declaration.cpp index 432390c79bc..1a06fbaa36d 100644 --- a/src/cpp/cpp_declaration.cpp +++ b/src/cpp/cpp_declaration.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_declaration.h" +/*******************************************************************\ + +Function: cpp_declarationt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarationt::output(std::ostream &out) const { out << "is_template: " << is_template() << "\n"; @@ -29,6 +38,18 @@ void cpp_declarationt::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: cpp_declarationt::name_anon_struct_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarationt::name_anon_struct_union(typet &dest) { // We name any anon struct/unions according to the first diff --git a/src/cpp/cpp_declaration.h b/src/cpp/cpp_declaration.h index 17cf872d226..271f7c5ee44 100644 --- a/src/cpp/cpp_declaration.h +++ b/src/cpp/cpp_declaration.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_DECLARATION_H #define CPROVER_CPP_CPP_DECLARATION_H diff --git a/src/cpp/cpp_declarator.cpp b/src/cpp/cpp_declarator.cpp index aa671c45a5f..063003b696c 100644 --- a/src/cpp/cpp_declarator.cpp +++ b/src/cpp/cpp_declarator.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include #include "cpp_declarator.h" +/*******************************************************************\ + +Function: cpp_declaratort::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declaratort::output(std::ostream &out) const { out << " name: " << name().pretty() << "\n"; @@ -23,6 +32,18 @@ void cpp_declaratort::output(std::ostream &out) const out << " method_qualifier: " << method_qualifier().pretty() << "\n"; } +/*******************************************************************\ + +Function: cpp_declaratort::merge_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet cpp_declaratort::merge_type(const typet &declaration_type) const { typet dest_type=type(); diff --git a/src/cpp/cpp_declarator.h b/src/cpp/cpp_declarator.h index 7f316506f56..3a08f17180a 100644 --- a/src/cpp/cpp_declarator.h +++ b/src/cpp/cpp_declarator.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_DECLARATOR_H #define CPROVER_CPP_CPP_DECLARATOR_H diff --git a/src/cpp/cpp_declarator_converter.cpp b/src/cpp/cpp_declarator_converter.cpp index c3b8739616f..24a295a03f7 100644 --- a/src/cpp/cpp_declarator_converter.cpp +++ b/src/cpp/cpp_declarator_converter.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_declarator_converter.h" #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_declarator_convertert::cpp_declarator_convertert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_declarator_convertert::cpp_declarator_convertert( class cpp_typecheckt &_cpp_typecheck): is_typedef(false), @@ -29,6 +38,18 @@ cpp_declarator_convertert::cpp_declarator_convertert( { } +/*******************************************************************\ + +Function: cpp_declarator_convertert::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbolt &cpp_declarator_convertert::convert( const typet &declaration_type, const cpp_storage_spect &storage_spec, @@ -231,6 +252,18 @@ symbolt &cpp_declarator_convertert::convert( } } +/*******************************************************************\ + +Function: cpp_declarator_convertert::combine_types + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::combine_types( const source_locationt &source_location, const typet &decl_type, @@ -313,6 +346,18 @@ void cpp_declarator_convertert::combine_types( throw 0; } +/*******************************************************************\ + +Function: cpp_declarator_convertert::enforce_rules + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::enforce_rules(const symbolt &symbol) { // enforce rules for operator overloading @@ -322,6 +367,18 @@ void cpp_declarator_convertert::enforce_rules(const symbolt &symbol) main_function_rules(symbol); } +/*******************************************************************\ + +Function: cpp_declarator_convertert::handle_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::handle_initializer( symbolt &symbol, cpp_declaratort &declarator) @@ -374,6 +431,18 @@ void cpp_declarator_convertert::handle_initializer( } } +/*******************************************************************\ + +Function: cpp_declarator_convertert::get_final_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::get_final_identifier() { std::string identifier=id2string(base_name); @@ -420,6 +489,18 @@ void cpp_declarator_convertert::get_final_identifier() identifier; } +/*******************************************************************\ + +Function: cpp_declarator_convertert::convert_new_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbolt &cpp_declarator_convertert::convert_new_symbol( const cpp_storage_spect &storage_spec, const cpp_member_spect &member_spec, @@ -560,6 +641,18 @@ symbolt &cpp_declarator_convertert::convert_new_symbol( return *new_symbol; } +/*******************************************************************\ + +Function: cpp_declarator_convertert::get_pretty_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt cpp_declarator_convertert::get_pretty_name() { if(is_code) @@ -587,11 +680,35 @@ irep_idt cpp_declarator_convertert::get_pretty_name() return scope->prefix+id2string(base_name); } +/*******************************************************************\ + +Function: cpp_declarator_convertert::operator_overloading_rules + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::operator_overloading_rules( const symbolt &symbol) { } +/*******************************************************************\ + +Function: cpp_declarator_convertert::main_function_rules + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_declarator_convertert::main_function_rules( const symbolt &symbol) { diff --git a/src/cpp/cpp_declarator_converter.h b/src/cpp/cpp_declarator_converter.h index 54399c6b62e..850549a69d5 100644 --- a/src/cpp/cpp_declarator_converter.h +++ b/src/cpp/cpp_declarator_converter.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_DECLARATOR_CONVERTER_H #define CPROVER_CPP_CPP_DECLARATOR_CONVERTER_H diff --git a/src/cpp/cpp_destructor.cpp b/src/cpp/cpp_destructor.cpp index bd1f2ffeb2b..75479a0ee85 100644 --- a/src/cpp/cpp_destructor.cpp +++ b/src/cpp/cpp_destructor.cpp @@ -6,16 +6,24 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include #include "cpp_typecheck.h" -/// \return typechecked code +/*******************************************************************\ + +Function: cpp_typecheckt::cpp_destructor + + Inputs: + + Outputs: typechecked code + + Purpose: + +\*******************************************************************/ + codet cpp_typecheckt::cpp_destructor( const source_locationt &source_location, const typet &type, diff --git a/src/cpp/cpp_enum_type.cpp b/src/cpp/cpp_enum_type.cpp index 98125a4fb8d..ba4bc6ecbae 100644 --- a/src/cpp/cpp_enum_type.cpp +++ b/src/cpp/cpp_enum_type.cpp @@ -6,17 +6,38 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_enum_type.h" +/*******************************************************************\ + +Function: cpp_enum_typet::cpp_enum_typet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_enum_typet::cpp_enum_typet():typet(ID_c_enum) { } +/*******************************************************************\ + +Function: cpp_enum_typet::generate_anon_tag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt cpp_enum_typet::generate_anon_tag() const { // This will only clash with anon enums that would have diff --git a/src/cpp/cpp_enum_type.h b/src/cpp/cpp_enum_type.h index 97dc50df769..23edd61900e 100644 --- a/src/cpp/cpp_enum_type.h +++ b/src/cpp/cpp_enum_type.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_ENUM_TYPE_H #define CPROVER_CPP_CPP_ENUM_TYPE_H diff --git a/src/cpp/cpp_exception_id.cpp b/src/cpp/cpp_exception_id.cpp index d3a4b8f7081..e64fa67e0df 100644 --- a/src/cpp/cpp_exception_id.cpp +++ b/src/cpp/cpp_exception_id.cpp @@ -6,12 +6,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_exception_id.h" -/// turns a type into a list of relevant exception IDs +/*******************************************************************\ + +Function: cpp_exception_list_rec + + Inputs: + + Outputs: + + Purpose: turns a type into a list of relevant exception IDs + +\*******************************************************************/ + void cpp_exception_list_rec( const typet &src, const namespacet &ns, @@ -67,7 +75,18 @@ void cpp_exception_list_rec( } } -/// turns a type into a list of relevant exception IDs +/*******************************************************************\ + +Function: cpp_exception_list + + Inputs: + + Outputs: + + Purpose: turns a type into a list of relevant exception IDs + +\*******************************************************************/ + irept cpp_exception_list( const typet &src, const namespacet &ns) @@ -84,7 +103,18 @@ irept cpp_exception_list( return result; } -/// turns a type into an exception ID +/*******************************************************************\ + +Function: cpp_exception_id + + Inputs: + + Outputs: + + Purpose: turns a type into an exception ID + +\*******************************************************************/ + irep_idt cpp_exception_id( const typet &src, const namespacet &ns) diff --git a/src/cpp/cpp_exception_id.h b/src/cpp/cpp_exception_id.h index c652169aa50..38b675c76fb 100644 --- a/src/cpp/cpp_exception_id.h +++ b/src/cpp/cpp_exception_id.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_EXCEPTION_ID_H #define CPROVER_CPP_CPP_EXCEPTION_ID_H diff --git a/src/cpp/cpp_id.cpp b/src/cpp/cpp_id.cpp index dae74bd1f4d..4ccb1a095d1 100644 --- a/src/cpp/cpp_id.cpp +++ b/src/cpp/cpp_id.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_id.h" #include "cpp_scope.h" +/*******************************************************************\ + +Function: cpp_idt::cpp_idt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_idt::cpp_idt(): is_member(false), is_method(false), @@ -27,6 +36,18 @@ cpp_idt::cpp_idt(): { } +/*******************************************************************\ + +Function: cpp_idt::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_idt::print(std::ostream &out, unsigned indent) const { print_fields(out, indent); @@ -42,6 +63,18 @@ void cpp_idt::print(std::ostream &out, unsigned indent) const } } +/*******************************************************************\ + +Function: cpp_idt::print_fields + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_idt::print_fields(std::ostream &out, unsigned indent) const { for(unsigned i=0; i\"" << '\n'; diff --git a/src/cpp/cpp_is_pod.cpp b/src/cpp/cpp_is_pod.cpp index 5cd698fd718..2b5c895611e 100644 --- a/src/cpp/cpp_is_pod.cpp +++ b/src/cpp/cpp_is_pod.cpp @@ -6,11 +6,41 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::cpp_is_pod + + Inputs: + + Outputs: + + Standard: + "Arithmetic types (3.9.1), enumeration types, pointer types, and + pointer to member types (3.9.2), and cvqualified versions of + these types (3.9.3) are collectively called scalar types. Scalar + types, POD-struct types, POD-union types (clause 9), arrays of + such types and cv-qualified versions of these types (3.9.3) are + collectively called POD types." + + "A POD-struct is an aggregate class that has no non-static data + members of type non-POD-struct, non-POD-union (or array of such + types) or reference, and has no user-defined copy assignment + operator and no user-defined destructor. Similarly, a POD-union + is an aggregate union that has no non-static data members of type + non-POD-struct, non-POD-union (or array of such types) or reference, + and has no userdefined copy assignment operator and no user-defined + destructor. A POD class is a class that is either a POD-struct or + a POD-union." + + "An aggregate is an array or a class (clause 9) with no + user-declared constructors (12.1), no private or protected + non-static data members (clause 11), no base classes (clause 10), + and no virtual functions (10.3)." + +\*******************************************************************/ + bool cpp_typecheckt::cpp_is_pod(const typet &type) const { if(type.id()==ID_struct) diff --git a/src/cpp/cpp_item.h b/src/cpp/cpp_item.h index 75b7c3e120c..f3f32674278 100644 --- a/src/cpp/cpp_item.h +++ b/src/cpp/cpp_item.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_ITEM_H #define CPROVER_CPP_CPP_ITEM_H diff --git a/src/cpp/cpp_language.cpp b/src/cpp/cpp_language.cpp index 1f10dc2c4ae..f1b4b97018d 100644 --- a/src/cpp/cpp_language.cpp +++ b/src/cpp/cpp_language.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Module - #include #include #include @@ -29,6 +26,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck.h" #include "cpp_type2name.h" +/*******************************************************************\ + +Function: cpp_languaget::extensions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set cpp_languaget::extensions() const { std::set s; @@ -47,12 +56,35 @@ std::set cpp_languaget::extensions() const return s; } +/*******************************************************************\ + +Function: cpp_languaget::modules_provided + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: cpp_languaget::preprocess + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool cpp_languaget::preprocess( std::istream &instream, const std::string &path, @@ -79,6 +111,18 @@ bool cpp_languaget::preprocess( return c_preprocess(path, outstream, get_message_handler()); } +/*******************************************************************\ + +Function: cpp_languaget::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::parse( std::istream &instream, const std::string &path) @@ -117,6 +161,18 @@ bool cpp_languaget::parse( return result; } +/*******************************************************************\ + +Function: cpp_languaget::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -133,6 +189,18 @@ bool cpp_languaget::typecheck( return linking(symbol_table, new_symbol_table, get_message_handler()); } +/*******************************************************************\ + +Function: cpp_languaget::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::final(symbol_tablet &symbol_table) { if(ansi_c_entry_point(symbol_table, "main", get_message_handler())) @@ -141,6 +209,18 @@ bool cpp_languaget::final(symbol_tablet &symbol_table) return false; } +/*******************************************************************\ + +Function: cpp_languaget::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_languaget::show_parse(std::ostream &out) { for(cpp_parse_treet::itemst::const_iterator it= @@ -150,6 +230,18 @@ void cpp_languaget::show_parse(std::ostream &out) show_parse(out, *it); } +/*******************************************************************\ + +Function: cpp_languaget::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_languaget::show_parse( std::ostream &out, const cpp_itemt &item) @@ -204,11 +296,35 @@ void cpp_languaget::show_parse( out << "UNKNOWN: " << item.pretty() << std::endl; } +/*******************************************************************\ + +Function: new_cpp_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *new_cpp_language() { return new cpp_languaget; } +/*******************************************************************\ + +Function: cpp_languaget::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::from_expr( const exprt &expr, std::string &code, @@ -218,6 +334,18 @@ bool cpp_languaget::from_expr( return false; } +/*******************************************************************\ + +Function: cpp_languaget::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::from_type( const typet &type, std::string &code, @@ -227,6 +355,18 @@ bool cpp_languaget::from_type( return false; } +/*******************************************************************\ + +Function: cpp_languaget::type_to_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::type_to_name( const typet &type, std::string &name, @@ -236,6 +376,18 @@ bool cpp_languaget::type_to_name( return false; } +/*******************************************************************\ + +Function: cpp_languaget::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_languaget::to_expr( const std::string &code, const std::string &module, @@ -274,6 +426,18 @@ bool cpp_languaget::to_expr( return result; } +/*******************************************************************\ + +Function: cpp_languaget::~cpp_languaget + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_languaget::~cpp_languaget() { } diff --git a/src/cpp/cpp_language.h b/src/cpp/cpp_language.h index 982e2e180c1..329adbaa1a5 100644 --- a/src/cpp/cpp_language.h +++ b/src/cpp/cpp_language.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Module - #ifndef CPROVER_CPP_CPP_LANGUAGE_H #define CPROVER_CPP_CPP_LANGUAGE_H diff --git a/src/cpp/cpp_linkage_spec.h b/src/cpp/cpp_linkage_spec.h index d7b6002ea60..67cf2c93b63 100644 --- a/src/cpp/cpp_linkage_spec.h +++ b/src/cpp/cpp_linkage_spec.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_LINKAGE_SPEC_H #define CPROVER_CPP_CPP_LINKAGE_SPEC_H diff --git a/src/cpp/cpp_name.cpp b/src/cpp/cpp_name.cpp index 7fd959d91eb..ae73ba3cbca 100644 --- a/src/cpp/cpp_name.cpp +++ b/src/cpp/cpp_name.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include #include "cpp_name.h" +/*******************************************************************\ + +Function: cpp_namet::get_base_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt cpp_namet::get_base_name() const { const subt &sub=get_sub(); @@ -40,6 +49,18 @@ irep_idt cpp_namet::get_base_name() const return irep_idt(); } +/*******************************************************************\ + +Function: cpp_namet::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #if 0 void cpp_namet::convert( std::string &identifier, @@ -73,6 +94,18 @@ void cpp_namet::convert( } #endif +/*******************************************************************\ + +Function: cpp_namet::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_namet::to_string() const { std::string str; diff --git a/src/cpp/cpp_namespace_spec.cpp b/src/cpp/cpp_namespace_spec.cpp index c4b60e3eb24..d7e8adb5eda 100644 --- a/src/cpp/cpp_namespace_spec.cpp +++ b/src/cpp/cpp_namespace_spec.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_namespace_spec.h" #include "cpp_item.h" +/*******************************************************************\ + +Function: cpp_namespace_spect::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_namespace_spect::output(std::ostream &out) const { out << " namespace: " << get_namespace() << "\n"; diff --git a/src/cpp/cpp_namespace_spec.h b/src/cpp/cpp_namespace_spec.h index ed96d1dd338..84aa6314086 100644 --- a/src/cpp/cpp_namespace_spec.h +++ b/src/cpp/cpp_namespace_spec.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_NAMESPACE_SPEC_H #define CPROVER_CPP_CPP_NAMESPACE_SPEC_H diff --git a/src/cpp/cpp_parse_tree.cpp b/src/cpp/cpp_parse_tree.cpp index 9027c9ed3b0..33614a83f53 100644 --- a/src/cpp/cpp_parse_tree.cpp +++ b/src/cpp/cpp_parse_tree.cpp @@ -6,16 +6,37 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser - #include "cpp_parse_tree.h" +/*******************************************************************\ + +Function: cpp_parse_treet::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_parse_treet::swap(cpp_parse_treet &cpp_parse_tree) { cpp_parse_tree.items.swap(items); } +/*******************************************************************\ + +Function: cpp_parse_treet::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_parse_treet::clear() { items.clear(); diff --git a/src/cpp/cpp_parse_tree.h b/src/cpp/cpp_parse_tree.h index afcd706fcef..9d620864247 100644 --- a/src/cpp/cpp_parse_tree.h +++ b/src/cpp/cpp_parse_tree.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser - #ifndef CPROVER_CPP_CPP_PARSE_TREE_H #define CPROVER_CPP_CPP_PARSE_TREE_H diff --git a/src/cpp/cpp_parser.cpp b/src/cpp/cpp_parser.cpp index fd0135bb259..b72c6be6d5e 100644 --- a/src/cpp/cpp_parser.cpp +++ b/src/cpp/cpp_parser.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser - #include #include "cpp_parser.h" cpp_parsert cpp_parser; +/*******************************************************************\ + +Function: cpp_parsert::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_parse(); bool cpp_parsert::parse() diff --git a/src/cpp/cpp_parser.h b/src/cpp/cpp_parser.h index 1a167f71f24..f2db8e6c2f7 100644 --- a/src/cpp/cpp_parser.h +++ b/src/cpp/cpp_parser.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser - #ifndef CPROVER_CPP_CPP_PARSER_H #define CPROVER_CPP_CPP_PARSER_H diff --git a/src/cpp/cpp_scope.cpp b/src/cpp/cpp_scope.cpp index 84ce1874ee6..6254cc70af3 100644 --- a/src/cpp/cpp_scope.cpp +++ b/src/cpp/cpp_scope.cpp @@ -6,12 +6,21 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" #include "cpp_scope.h" +/*******************************************************************\ + +Function: cpp_scopet::operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind) { switch(kind) @@ -25,6 +34,18 @@ std::ostream &operator << (std::ostream &out, cpp_scopet::lookup_kindt kind) return out; } +/*******************************************************************\ + +Function: cpp_scopet::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_scopet::lookup( const irep_idt &base_name, lookup_kindt kind, @@ -88,6 +109,18 @@ void cpp_scopet::lookup( get_parent().lookup(base_name, kind, id_set); } +/*******************************************************************\ + +Function: cpp_scopet::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_scopet::lookup( const irep_idt &base_name, lookup_kindt kind, @@ -168,6 +201,18 @@ void cpp_scopet::lookup( get_parent().lookup(base_name, kind, id_class, id_set); } +/*******************************************************************\ + +Function: cpp_scopet::lookup_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_scopet::lookup_identifier( const irep_idt &identifier, cpp_idt::id_classt id_class, @@ -196,6 +241,18 @@ void cpp_scopet::lookup_identifier( #endif } +/*******************************************************************\ + +Function: cpp_scopet::new_scope + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_scopet::new_scope(const irep_idt &new_scope_name) { cpp_idt &id=insert(new_scope_name); @@ -208,6 +265,18 @@ cpp_scopet &cpp_scopet::new_scope(const irep_idt &new_scope_name) } +/*******************************************************************\ + +Function: cpp_scopet::contains + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_scopet::contains(const irep_idt &base_name) { id_sett id_set; diff --git a/src/cpp/cpp_scope.h b/src/cpp/cpp_scope.h index 690318edb43..0c806f427b8 100644 --- a/src/cpp/cpp_scope.h +++ b/src/cpp/cpp_scope.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_SCOPE_H #define CPROVER_CPP_CPP_SCOPE_H diff --git a/src/cpp/cpp_scopes.cpp b/src/cpp/cpp_scopes.cpp index 2a9496fe7cd..bdd78980e9b 100644 --- a/src/cpp/cpp_scopes.cpp +++ b/src/cpp/cpp_scopes.cpp @@ -6,20 +6,41 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_scopes.h" +/*******************************************************************\ + +Function: cpp_scopest::new_block_scope + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_scopest::new_block_scope() { unsigned prefix=++current_scope().compound_counter; return new_scope(std::to_string(prefix), cpp_idt::id_classt::BLOCK_SCOPE); } +/*******************************************************************\ + +Function: cpp_scopest::put_into_scope + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_idt &cpp_scopest::put_into_scope( const symbolt &symbol, cpp_scopet &scope, @@ -69,7 +90,17 @@ cpp_idt &cpp_scopest::put_into_scope( } } -/// \return Purpose: +/*******************************************************************\ + +Function: cpp_scopest::print_current + + Inputs: + + Outputs: + Purpose: + +\*******************************************************************/ + void cpp_scopest::print_current(std::ostream &out) const { const cpp_scopet *scope=current_scope_ptr; diff --git a/src/cpp/cpp_scopes.h b/src/cpp/cpp_scopes.h index ca392497c7d..92d9ebdb6e2 100644 --- a/src/cpp/cpp_scopes.h +++ b/src/cpp/cpp_scopes.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_SCOPES_H #define CPROVER_CPP_CPP_SCOPES_H diff --git a/src/cpp/cpp_static_assert.h b/src/cpp/cpp_static_assert.h index be784ca51f1..64b3d5bcf6a 100644 --- a/src/cpp/cpp_static_assert.h +++ b/src/cpp/cpp_static_assert.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_STATIC_ASSERT_H #define CPROVER_CPP_CPP_STATIC_ASSERT_H diff --git a/src/cpp/cpp_template_args.h b/src/cpp/cpp_template_args.h index 47ceca5f003..5fa708879a8 100644 --- a/src/cpp/cpp_template_args.h +++ b/src/cpp/cpp_template_args.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_TEMPLATE_ARGS_H #define CPROVER_CPP_CPP_TEMPLATE_ARGS_H diff --git a/src/cpp/cpp_token.h b/src/cpp/cpp_token.h index 800ac372353..a022cf92df2 100644 --- a/src/cpp/cpp_token.h +++ b/src/cpp/cpp_token.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser: Token - #ifndef CPROVER_CPP_CPP_TOKEN_H #define CPROVER_CPP_CPP_TOKEN_H diff --git a/src/cpp/cpp_token_buffer.cpp b/src/cpp/cpp_token_buffer.cpp index a59b0b199ff..9dcd75526e6 100644 --- a/src/cpp/cpp_token_buffer.cpp +++ b/src/cpp/cpp_token_buffer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser: Token Buffer - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_token_buffer.h" +/*******************************************************************\ + +Function: cpp_token_buffert::LookAhead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cpp_token_buffert::LookAhead(unsigned offset) { assert(current_pos<=token_vector.size()); @@ -28,6 +37,18 @@ int cpp_token_buffert::LookAhead(unsigned offset) return token_vector[offset]->kind; } +/*******************************************************************\ + +Function: cpp_token_buffert::get_token + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cpp_token_buffert::get_token(cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -42,6 +63,18 @@ int cpp_token_buffert::get_token(cpp_tokent &token) return token.kind; } +/*******************************************************************\ + +Function: cpp_token_buffert::get_token + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cpp_token_buffert::get_token() { assert(current_pos<=token_vector.size()); @@ -56,6 +89,18 @@ int cpp_token_buffert::get_token() return kind; } +/*******************************************************************\ + +Function: cpp_token_buffert::LookAhead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cpp_token_buffert::LookAhead(unsigned offset, cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -70,6 +115,18 @@ int cpp_token_buffert::LookAhead(unsigned offset, cpp_tokent &token) return token.kind; } +/*******************************************************************\ + +Function: cpp_token_buffert::read_token + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int yyansi_clex(); extern char *yyansi_ctext; @@ -98,16 +155,52 @@ void cpp_token_buffert::read_token() // std::cout << "I2: " << token_vector.size() << std::endl; } +/*******************************************************************\ + +Function: cpp_token_buffert::Save + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_token_buffert::post cpp_token_buffert::Save() { return current_pos; } +/*******************************************************************\ + +Function: cpp_token_buffert::Restore + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_token_buffert::Restore(post pos) { current_pos=pos; } +/*******************************************************************\ + +Function: cpp_token_buffert::Replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_token_buffert::Replace(const cpp_tokent &token) { assert(current_pos<=token_vector.size()); @@ -118,6 +211,18 @@ void cpp_token_buffert::Replace(const cpp_tokent &token) *token_vector[current_pos]=token; } +/*******************************************************************\ + +Function: cpp_token_buffert::Replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_token_buffert::Insert(const cpp_tokent &token) { assert(current_pos<=token_vector.size()); diff --git a/src/cpp/cpp_token_buffer.h b/src/cpp/cpp_token_buffer.h index 859945787bd..e4e90422853 100644 --- a/src/cpp/cpp_token_buffer.h +++ b/src/cpp/cpp_token_buffer.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Parser: Token Buffer - #ifndef CPROVER_CPP_CPP_TOKEN_BUFFER_H #define CPROVER_CPP_CPP_TOKEN_BUFFER_H diff --git a/src/cpp/cpp_type2name.cpp b/src/cpp/cpp_type2name.cpp index 6a938a9a4f0..98842b8b41a 100644 --- a/src/cpp/cpp_type2name.cpp +++ b/src/cpp/cpp_type2name.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Module - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_type2name.h" +/*******************************************************************\ + +Function: do_prefix + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string do_prefix(const std::string &s) { if(s.find(',')!=std::string::npos || @@ -25,6 +34,18 @@ static std::string do_prefix(const std::string &s) return s; } +/*******************************************************************\ + +Function: irep2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void irep2name(const irept &irep, std::string &result) { result=""; @@ -88,6 +109,18 @@ static void irep2name(const irept &irep, std::string &result) result+=')'; } +/*******************************************************************\ + +Function: cpp_type2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_type2name(const typet &type) { std::string result; @@ -170,6 +203,18 @@ std::string cpp_type2name(const typet &type) return result; } +/*******************************************************************\ + +Function: cpp_expr2name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_expr2name(const exprt &expr) { std::string tmp; diff --git a/src/cpp/cpp_type2name.h b/src/cpp/cpp_type2name.h index 96aa6b58d8c..ffb2a99eef6 100644 --- a/src/cpp/cpp_type2name.h +++ b/src/cpp/cpp_type2name.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Module - #ifndef CPROVER_CPP_CPP_TYPE2NAME_H #define CPROVER_CPP_CPP_TYPE2NAME_H diff --git a/src/cpp/cpp_typecheck.cpp b/src/cpp/cpp_typecheck.cpp index 0b15d9538f9..fe8a9f063d7 100644 --- a/src/cpp/cpp_typecheck.cpp +++ b/src/cpp/cpp_typecheck.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_declarator.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_itemt &item) { if(item.is_declaration()) @@ -43,7 +52,18 @@ void cpp_typecheckt::convert(cpp_itemt &item) } } -/// typechecking main method +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck + + Inputs: + + Outputs: + + Purpose: typechecking main method + +\*******************************************************************/ + void cpp_typecheckt::typecheck() { // default linkage is "automatic" @@ -59,6 +79,18 @@ void cpp_typecheckt::typecheck() clean_up(); } +/*******************************************************************\ + +Function: cpp_typecheckt::this_struct_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const struct_typet &cpp_typecheckt::this_struct_type() { const exprt &this_expr= @@ -72,16 +104,52 @@ const struct_typet &cpp_typecheckt::this_struct_type() return to_struct_type(t); } +/*******************************************************************\ + +Function: cpp_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_typecheckt::to_string(const exprt &expr) { return expr2cpp(expr, *this); } +/*******************************************************************\ + +Function: cpp_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_typecheckt::to_string(const typet &type) { return type2cpp(type, *this); } +/*******************************************************************\ + +Function: cpp_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheck( cpp_parse_treet &cpp_parse_tree, symbol_tablet &symbol_table, @@ -93,6 +161,18 @@ bool cpp_typecheck( return cpp_typecheck.typecheck_main(); } +/*******************************************************************\ + +Function: cpp_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheck( exprt &expr, message_handlert &message_handler, @@ -127,20 +207,31 @@ bool cpp_typecheck( return cpp_typecheck.get_error_found(); } -/// Initialization of static objects: -/// -/// "Objects with static storage duration (3.7.1) shall be zero-initialized -/// (8.5) before any other initialization takes place. Zero-initialization -/// and initialization with a constant expression are collectively called -/// static initialization; all other initialization is dynamic -/// initialization. Objects of POD types (3.9) with static storage duration -/// initialized with constant expressions (5.19) shall be initialized before -/// any dynamic initialization takes place. Objects with static storage -/// duration defined in namespace scope in the same translation unit and -/// dynamically initialized shall be initialized in the order in which their -/// definition appears in the translation unit. [Note: 8.5.1 describes the -/// order in which aggregate members are initialized. The initialization -/// of local static objects is described in 6.7. ]" +/*******************************************************************\ + +Function: cpp_typecheckt::static_and_dynamic_initialization + + Inputs: + + Outputs: + + Purpose: Initialization of static objects: + + "Objects with static storage duration (3.7.1) shall be zero-initialized + (8.5) before any other initialization takes place. Zero-initialization + and initialization with a constant expression are collectively called + static initialization; all other initialization is dynamic + initialization. Objects of POD types (3.9) with static storage duration + initialized with constant expressions (5.19) shall be initialized before + any dynamic initialization takes place. Objects with static storage + duration defined in namespace scope in the same translation unit and + dynamically initialized shall be initialized in the order in which their + definition appears in the translation unit. [Note: 8.5.1 describes the + order in which aggregate members are initialized. The initialization + of local static objects is described in 6.7. ]" + +\*******************************************************************/ + void cpp_typecheckt::static_and_dynamic_initialization() { code_blockt init_block; // Dynamic Initialization Block @@ -211,6 +302,18 @@ void cpp_typecheckt::static_and_dynamic_initialization() disable_access_control=false; } +/*******************************************************************\ + +Function: cpp_typecheckt::do_not_typechecked + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::do_not_typechecked() { bool cont; @@ -260,6 +363,18 @@ void cpp_typecheckt::do_not_typechecked() } } +/*******************************************************************\ + +Function: cpp_typecheckt::clean_up + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::clean_up() { symbol_tablet::symbolst::iterator it=symbol_table.symbols.begin(); diff --git a/src/cpp/cpp_typecheck.h b/src/cpp/cpp_typecheck.h index 5c0a6afe285..55955cd0334 100644 --- a/src/cpp/cpp_typecheck.h +++ b/src/cpp/cpp_typecheck.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_TYPECHECK_H #define CPROVER_CPP_CPP_TYPECHECK_H diff --git a/src/cpp/cpp_typecheck_bases.cpp b/src/cpp/cpp_typecheck_bases.cpp index 7432b7a382b..1c768d63153 100644 --- a/src/cpp/cpp_typecheck_bases.cpp +++ b/src/cpp/cpp_typecheck_bases.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::typcheck_compound_bases + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) { std::set bases; @@ -117,6 +126,18 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type) } } +/*******************************************************************\ + +Function: cpp_typecheckt::add_base_components + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::add_base_components( const struct_typet &from, const irep_idt &access, diff --git a/src/cpp/cpp_typecheck_code.cpp b/src/cpp/cpp_typecheck_code.cpp index a85b1a5c92f..f375cd4dbf6 100644 --- a/src/cpp/cpp_typecheck_code.cpp +++ b/src/cpp/cpp_typecheck_code.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_typecheck.h" @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_util.h" #include "cpp_exception_id.h" +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_code(codet &code) { const irep_idt &statement=code.get_statement(); @@ -40,6 +49,18 @@ void cpp_typecheckt::typecheck_code(codet &code) c_typecheck_baset::typecheck_code(code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_try_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_try_catch(codet &code) { codet::operandst &operands=code.operands(); @@ -106,6 +127,18 @@ void cpp_typecheckt::typecheck_try_catch(codet &code) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) { // In addition to the C syntax, C++ also allows a declaration @@ -120,6 +153,18 @@ void cpp_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) c_typecheck_baset::typecheck_ifthenelse(code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_while + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_while(code_whilet &code) { // In addition to the C syntax, C++ also allows a declaration @@ -134,6 +179,18 @@ void cpp_typecheckt::typecheck_while(code_whilet &code) c_typecheck_baset::typecheck_while(code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_switch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_switch(code_switcht &code) { // In addition to the C syntax, C++ also allows a declaration @@ -165,6 +222,18 @@ void cpp_typecheckt::typecheck_switch(code_switcht &code) c_typecheck_baset::typecheck_switch(code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_member_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_member_initializer(codet &code) { const cpp_namet &member= @@ -344,6 +413,18 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_decl(codet &code) { if(code.operands().size()!=1) @@ -437,6 +518,18 @@ void cpp_typecheckt::typecheck_decl(codet &code) code.swap(new_code); } +/*******************************************************************\ + +Function: cpp_typecheck_codet::typecheck_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_block(codet &code) { cpp_save_scopet saved_scope(cpp_scopes); @@ -445,6 +538,18 @@ void cpp_typecheckt::typecheck_block(codet &code) c_typecheck_baset::typecheck_block(code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_assign(codet &code) { if(code.operands().size()!=2) diff --git a/src/cpp/cpp_typecheck_compound_type.cpp b/src/cpp/cpp_typecheck_compound_type.cpp index 2a9a9368f90..56db1bbba6c 100644 --- a/src/cpp/cpp_typecheck_compound_type.cpp +++ b/src/cpp/cpp_typecheck_compound_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_name.h" +/*******************************************************************\ + +Function: cpp_typecheckt::has_const + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::has_const(const typet &type) { if(type.id()==ID_const) @@ -39,6 +48,18 @@ bool cpp_typecheckt::has_const(const typet &type) return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::has_volatile + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::has_volatile(const typet &type) { if(type.id()==ID_volatile) @@ -55,6 +76,18 @@ bool cpp_typecheckt::has_volatile(const typet &type) return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::tag_scope + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_typecheckt::tag_scope( const irep_idt &base_name, bool has_body, @@ -94,6 +127,18 @@ cpp_scopet &cpp_typecheckt::tag_scope( return cpp_scopes.get_global_scope(); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_compound_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_compound_type( struct_union_typet &type) { @@ -249,6 +294,18 @@ void cpp_typecheckt::typecheck_compound_type( type.swap(symbol_type); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_compound_declarator + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_compound_declarator( const symbolt &symbol, const cpp_declarationt &declaration, @@ -747,7 +804,18 @@ void cpp_typecheckt::typecheck_compound_declarator( components.push_back(component); } -/// check that an array has fixed size +/*******************************************************************\ + +Function: cpp_typecheckt::check_fixed_size_array + +Inputs: + +Outputs: + +Purpose: check that an array has fixed size + +\*******************************************************************/ + void cpp_typecheckt::check_fixed_size_array(typet &type) { if(type.id()==ID_array) @@ -762,6 +830,18 @@ void cpp_typecheckt::check_fixed_size_array(typet &type) } } +/*******************************************************************\ + +Function: cpp_typecheckt::put_compound_into_scope + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::put_compound_into_scope( const struct_union_typet::componentt &compound) { @@ -838,6 +918,18 @@ void cpp_typecheckt::put_compound_into_scope( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_friend_declaration + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_friend_declaration( symbolt &symbol, cpp_declarationt &declaration) @@ -922,6 +1014,18 @@ void cpp_typecheckt::typecheck_friend_declaration( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_compound_body + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) { cpp_save_scopet saved_scope(cpp_scopes); @@ -1204,6 +1308,18 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol) symbol.type.remove(ID_body); } +/*******************************************************************\ + +Function: cpp_typecheckt::move_member_initializers + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::move_member_initializers( irept &initializers, const typet &type, @@ -1246,6 +1362,18 @@ void cpp_typecheckt::move_member_initializers( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_member_function + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_member_function( const irep_idt &compound_identifier, struct_typet::componentt &component, @@ -1328,6 +1456,18 @@ void cpp_typecheckt::typecheck_member_function( add_method_body(new_symbol); } +/*******************************************************************\ + +Function: cpp_typecheckt::add_this_to_method_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::add_this_to_method_type( const irep_idt &compound_symbol, typet &type, @@ -1355,6 +1495,18 @@ void cpp_typecheckt::add_this_to_method_type( parameter.type()=pointer_typet(subtype); } +/*******************************************************************\ + +Function: cpp_typecheckt::add_anonymous_members_to_scope + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::add_anonymous_members_to_scope( const symbolt &struct_union_symbol) { @@ -1405,6 +1557,18 @@ void cpp_typecheckt::add_anonymous_members_to_scope( } } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_anon_struct_union_member + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_anon_struct_union_member( const cpp_declarationt &declaration, const irep_idt &access, @@ -1456,6 +1620,18 @@ void cpp_typecheckt::convert_anon_struct_union_member( struct_union_symbol.type.set("#unnamed_object", base_name); } +/*******************************************************************\ + +Function: cpp_typecheckt::get_component + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::get_component( const source_locationt &source_location, const exprt &object, @@ -1556,6 +1732,18 @@ bool cpp_typecheckt::get_component( return false; // component not found } +/*******************************************************************\ + +Function: cpp_typecheckt::check_component_access + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::check_component_access( const struct_union_typet::componentt &component, const struct_union_typet &struct_union_type) @@ -1622,6 +1810,18 @@ bool cpp_typecheckt::check_component_access( return true; // not ok } +/*******************************************************************\ + +Function: cpp_typecheckt::get_bases + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::get_bases( const struct_typet &type, std::set &set_bases) const @@ -1641,6 +1841,18 @@ void cpp_typecheckt::get_bases( } } +/*******************************************************************\ + +Function: cpp_typecheckt::get_virtual_bases + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::get_virtual_bases( const struct_typet &type, std::list &vbases) const @@ -1665,6 +1877,18 @@ void cpp_typecheckt::get_virtual_bases( } } +/*******************************************************************\ + +Function: cpp_typecheckt::subtype_typecast + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::subtype_typecast( const struct_typet &from, const struct_typet &to) const @@ -1679,6 +1903,18 @@ bool cpp_typecheckt::subtype_typecast( return bases.find(to.get(ID_name))!=bases.end(); } +/*******************************************************************\ + +Function: cpp_typecheckt::make_ptr_subtypecast + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::make_ptr_typecast( exprt &expr, const typet &dest_type) diff --git a/src/cpp/cpp_typecheck_constructor.cpp b/src/cpp/cpp_typecheck_constructor.cpp index 61e52f3e5c9..01cc9ca7123 100644 --- a/src/cpp/cpp_typecheck_constructor.cpp +++ b/src/cpp/cpp_typecheck_constructor.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include #include @@ -18,9 +15,19 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck.h" #include "cpp_util.h" -/// \param parent_base_name: base name of typechecked parent -/// \param block: non-typechecked block -/// \return generate code to copy the parent +/*******************************************************************\ + +Function: copy_parent + + Inputs: parent_base_name: base name of typechecked parent + block: non-typechecked block + + Outputs: generate code to copy the parent + + Purpose: + +\*******************************************************************/ + static void copy_parent( const source_locationt &source_location, const irep_idt &parent_base_name, @@ -59,9 +66,19 @@ static void copy_parent( op1.add_source_location()=source_location; } -/// \param member_base_name: name of a member -/// \param block: non-typechecked block -/// \return generate code to copy the member +/*******************************************************************\ + +Function: copy_member + + Inputs: member_base_name: name of a member + block: non-typechecked block + + Outputs: generate code to copy the member + + Purpose: + +\*******************************************************************/ + static void copy_member( const source_locationt &source_location, const irep_idt &member_base_name, @@ -103,10 +120,20 @@ static void copy_member( op1.add_source_location()=source_location; } -/// \param member_base_name: name of array member -/// \param index: index to copy -/// \param block: non-typechecked block -/// \return generate code to copy the member +/*******************************************************************\ + +Function: copy_array + + Inputs: member_base_name: name of array member + index: index to copy + block: non-typechecked block + + Outputs: generate code to copy the member + + Purpose: + +\*******************************************************************/ + static void copy_array( const source_locationt &source_location, const irep_idt &member_base_name, @@ -155,7 +182,18 @@ static void copy_array( op1.add_source_location()=source_location; } -/// Generate code for implicit default constructors +/*******************************************************************\ + +Function: cpp_typecheckt::default_ctor + + Inputs: + + Outputs: + + Purpose: Generate code for implicit default constructors + +\*******************************************************************/ + void cpp_typecheckt::default_ctor( const source_locationt &source_location, const irep_idt &base_name, @@ -184,7 +222,18 @@ void cpp_typecheckt::default_ctor( ctor.add_source_location()=source_location; } -/// Generate code for implicit default copy constructor +/*******************************************************************\ + +Function: cpp_typecheckt::default_cpctor + + Inputs: + + Outputs: + + Purpose: Generate code for implicit default copy constructor + +\*******************************************************************/ + void cpp_typecheckt::default_cpctor( const symbolt &symbol, cpp_declarationt &cpctor) const @@ -353,7 +402,19 @@ void cpp_typecheckt::default_cpctor( } } -/// Generate declarartion of the implicit default assignment operator +/*******************************************************************\ + +Function: cpp_typecheckt::default_assignop + + Inputs: + + Outputs: + + Purpose: Generate declarartion of the implicit default assignment + operator + +\*******************************************************************/ + void cpp_typecheckt::default_assignop( const symbolt &symbol, cpp_declarationt &cpctor) @@ -427,7 +488,18 @@ void cpp_typecheckt::default_assignop( args_decl_declor.value().make_nil(); } -/// Generate code for the implicit default assignment operator +/*******************************************************************\ + +Function: cpp_typecheckt::default_assignop_value + + Inputs: + + Outputs: + + Purpose: Generate code for the implicit default assignment operator + +\*******************************************************************/ + void cpp_typecheckt::default_assignop_value( const symbolt &symbol, cpp_declaratort &declarator) @@ -508,13 +580,24 @@ void cpp_typecheckt::default_assignop_value( ret_code.type()=code_typet(); } -/// Check a constructor initialization-list. An initalizer has to be a data -/// member declared in this class or a direct-parent constructor. -/// \param bases: the parents of the class -/// \param components: the components of the class -/// \param initializers: the constructor initializers -/// \return If an invalid initializer is found, then the method outputs an error -/// message and throws a 0 exception. +/*******************************************************************\ + +Function: check_member_initializers + + Inputs: bases: the parents of the class + components: the components of the class + initializers: the constructor initializers + + Outputs: If an invalid initializer is found, then + the method outputs an error message and + throws a 0 exception. + + Purpose: Check a constructor initialization-list. + An initalizer has to be a data member declared + in this class or a direct-parent constructor. + +\*******************************************************************/ + void cpp_typecheckt::check_member_initializers( const irept &bases, const struct_typet::componentst &components, @@ -643,14 +726,23 @@ void cpp_typecheckt::check_member_initializers( } } -/// Build the full initialization list of the constructor. First, all the -/// direct-parent constructors are called. Second, all the non-pod data members -/// are initialized. -/// -/// Note: The initialization order follows the decalration order. -/// \param struct_union_type: the class/struct/union -/// \param initializers: the constructor initializers -/// \return initializers is updated. +/*******************************************************************\ + +Function: full_member_initialization + + Inputs: struct_union_type: the class/struct/union + initializers: the constructor initializers + + Outputs: initializers is updated. + + Purpose: Build the full initialization list of the constructor. + First, all the direct-parent constructors are called. + Second, all the non-pod data members are initialized. + + Note: The initialization order follows the decalration order. + +\*******************************************************************/ + void cpp_typecheckt::full_member_initialization( const struct_union_typet &struct_union_type, irept &initializers) @@ -914,8 +1006,23 @@ void cpp_typecheckt::full_member_initialization( initializers.swap(final_initializers); } -/// \par parameters: typechecked compound symbol -/// \return return true if a copy constructor is found +/*******************************************************************\ + +Function: find_cpctor + + Inputs: typechecked compound symbol + + Outputs: return true if a copy constructor is found + + Note: + "A non-template constructor for class X is a copy constructor + if its first parameter is of type X&, const X&, volatile X& + or const volatile X&, and either there are no other parameters + or else all other parameters have default arguments (8.3.6).106) + [Example: X::X(const X&) and X::X(X&, int=1) are copy constructors." + +\*******************************************************************/ + bool cpp_typecheckt::find_cpctor(const symbolt &symbol) const { const struct_typet &struct_type=to_struct_type(symbol.type); @@ -973,6 +1080,18 @@ bool cpp_typecheckt::find_cpctor(const symbolt &symbol) const return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::find_assignop + + Inputs: + + Outputs: + + Note: + +\*******************************************************************/ + bool cpp_typecheckt::find_assignop(const symbolt &symbol) const { const struct_typet &struct_type=to_struct_type(symbol.type); diff --git a/src/cpp/cpp_typecheck_conversions.cpp b/src/cpp/cpp_typecheck_conversions.cpp index 186d7479ac5..16d8e519741 100644 --- a/src/cpp/cpp_typecheck_conversions.cpp +++ b/src/cpp/cpp_typecheck_conversions.cpp @@ -6,9 +6,6 @@ Module: C++ Language Type Checking \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -22,26 +19,35 @@ Module: C++ Language Type Checking #include "cpp_typecheck.h" -/// Lvalue-to-rvalue conversion -/// -/// An lvalue (3.10) of a non-function, non-array type T can be -/// converted to an rvalue. If T is an incomplete type, a program -/// that necessitates this conversion is ill-formed. If the object -/// to which the lvalue refers is not an object of type T and is -/// not an object of a type derived from T, or if the object is -/// uninitialized, a program that necessitates this conversion has -/// undefined behavior. If T is a non-class type, the type of the -/// rvalue is the cv-unqualified version of T. Otherwise, the type of -/// the rvalue is T. -/// -/// The value contained in the object indicated by the lvalue -/// is the rvalue result. When an lvalue-to-rvalue conversion -/// occurs within the operand of sizeof (5.3.3) the value contained -/// in the referenced object is not accessed, since that operator -/// does not evaluate its operand. -/// \par parameters: A typechecked lvalue expression -/// \return True iff the lvalue-to-rvalue conversion is possible. 'new_type' -/// contains the result of the conversion. +/*******************************************************************\ + +Function: standard_conversion_lvalue_to_rvalue + + Inputs: A typechecked lvalue expression + + Outputs: True iff the lvalue-to-rvalue conversion is possible. + 'new_type' contains the result of the conversion. + + Purpose: Lvalue-to-rvalue conversion + + An lvalue (3.10) of a non-function, non-array type T can be + converted to an rvalue. If T is an incomplete type, a program + that necessitates this conversion is ill-formed. If the object + to which the lvalue refers is not an object of type T and is + not an object of a type derived from T, or if the object is + uninitialized, a program that necessitates this conversion has + undefined behavior. If T is a non-class type, the type of the + rvalue is the cv-unqualified version of T. Otherwise, the type of + the rvalue is T. + + The value contained in the object indicated by the lvalue + is the rvalue result. When an lvalue-to-rvalue conversion + occurs within the operand of sizeof (5.3.3) the value contained + in the referenced object is not accessed, since that operator + does not evaluate its operand. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_lvalue_to_rvalue( const exprt &expr, exprt &new_expr) const @@ -59,14 +65,23 @@ bool cpp_typecheckt::standard_conversion_lvalue_to_rvalue( return true; } -/// Array-to-pointer conversion -/// -/// An lvalue or rvalue of type "array of N T" or "array of unknown -/// bound of T" can be converted to an rvalue of type "pointer to T." -/// The result is a pointer to the first element of the array. -/// \par parameters: An array expression -/// \return True iff the array-to-pointer conversion is possible. The result of -/// the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_array_to_pointer + + Inputs: An array expression + + Outputs: True iff the array-to-pointer conversion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Array-to-pointer conversion + + An lvalue or rvalue of type "array of N T" or "array of unknown + bound of T" can be converted to an rvalue of type "pointer to T." + The result is a pointer to the first element of the array. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_array_to_pointer( const exprt &expr, exprt &new_expr) const @@ -86,13 +101,23 @@ bool cpp_typecheckt::standard_conversion_array_to_pointer( return true; } -/// Function-to-pointer conversion -/// -/// An lvalue of function type T can be converted to an rvalue of type -/// "pointer to T." The result is a pointer to the function.50) -/// \par parameters: A function expression -/// \return True iff the array-to-pointer conversion is possible. The result of -/// the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_function_to_pointer + + Inputs: A function expression + + Outputs: True iff the array-to-pointer conversion is possible. + The result of the conversion is stored in 'new_expr'. + + + Purpose: Function-to-pointer conversion + + An lvalue of function type T can be converted to an rvalue of type + "pointer to T." The result is a pointer to the function.50) + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_function_to_pointer( const exprt &expr, exprt &new_expr) const { @@ -111,11 +136,20 @@ bool cpp_typecheckt::standard_conversion_function_to_pointer( return true; } -/// Qualification conversion -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type' -/// \return True iff the qualification conversion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_qualification + + Inputs: A typechecked expression 'expr', a destination + type 'type' + + Outputs: True iff the qualification conversion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Qualification conversion + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_qualification( const exprt &expr, const typet &type, @@ -169,31 +203,40 @@ bool cpp_typecheckt::standard_conversion_qualification( return false; } -/// Integral-promotion conversion -/// -/// An rvalue of type char, signed char, unsigned char, short int, -/// or unsigned short int can be converted to an rvalue of type int -/// if int can represent all the values of the source type; otherwise, -/// the source rvalue can be converted to an rvalue of type unsigned int. -/// -/// An rvalue of type wchar_t (3.9.1) or an enumeration type (7.2) can -/// be converted to an rvalue of the first of the following types that -/// can represent all the values of its underlying type: int, unsigned int, -/// long, or unsigned long. -/// -/// An rvalue for an integral bit-field (9.6) can be converted -/// to an rvalue of type int if int can represent all the values of the -/// bit-field; otherwise, it can be converted to unsigned int if -/// unsigned int can represent all the values of the bit-field. -/// If the bit-field is larger yet, no integral promotion applies to -/// it. If the bit-field has an enumerated type, it is treated as -/// any other value of that type for promotion purposes. -/// -/// An rvalue of type bool can be converted to an rvalue of type int, -/// with false becoming zero and true becoming one. -/// \par parameters: A typechecked expression 'expr' -/// \return True iff the integral pormotion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_integral_promotion + + Inputs: A typechecked expression 'expr' + + Outputs: True iff the integral pormotion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Integral-promotion conversion + + An rvalue of type char, signed char, unsigned char, short int, + or unsigned short int can be converted to an rvalue of type int + if int can represent all the values of the source type; otherwise, + the source rvalue can be converted to an rvalue of type unsigned int. + + An rvalue of type wchar_t (3.9.1) or an enumeration type (7.2) can + be converted to an rvalue of the first of the following types that + can represent all the values of its underlying type: int, unsigned int, + long, or unsigned long. + + An rvalue for an integral bit-field (9.6) can be converted + to an rvalue of type int if int can represent all the values of the + bit-field; otherwise, it can be converted to unsigned int if + unsigned int can represent all the values of the bit-field. + If the bit-field is larger yet, no integral promotion applies to + it. If the bit-field has an enumerated type, it is treated as + any other value of that type for promotion purposes. + + An rvalue of type bool can be converted to an rvalue of type int, + with false becoming zero and true becoming one. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_integral_promotion( const exprt &expr, exprt &new_expr) const @@ -239,13 +282,22 @@ bool cpp_typecheckt::standard_conversion_integral_promotion( return false; } -/// Floating-point-promotion conversion -/// -/// An rvalue of type float can be converted to an rvalue of type -/// double. The value is unchanged. -/// \par parameters: A typechecked expression 'expr' -/// \return True iff the integral promotion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_floating_point_promotion + + Inputs: A typechecked expression 'expr' + + Outputs: True iff the integral promotion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Floating-point-promotion conversion + + An rvalue of type float can be converted to an rvalue of type + double. The value is unchanged. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_floating_point_promotion( const exprt &expr, exprt &new_expr) const @@ -273,34 +325,43 @@ bool cpp_typecheckt::standard_conversion_floating_point_promotion( return true; } -/// Integral conversion -/// -/// An rvalue of type char, signed char, unsigned char, short int, -/// An rvalue of an integer type can be converted to an rvalue of -/// another integer type. An rvalue of an enumeration type can be -/// converted to an rvalue of an integer type. -/// -/// If the destination type is unsigned, the resulting value is the -/// least unsigned integer congruent to the source integer (modulo -/// 2n where n is the number of bits used to represent the unsigned -/// type). [Note: In a two's complement representation, this -/// conversion is conceptual and there is no change in the bit -/// pattern (if there is no truncation). ] -/// -/// If the destination type is signed, the value is unchanged if it -/// can be represented in the destination type (and bit-field width); -/// otherwise, the value is implementation-defined. -/// -/// If the destination type is bool, see 4.12. If the source type is -/// bool, the value false is converted to zero and the value true is -/// converted to one. -/// -/// The conversions allowed as integral promotions are excluded from -/// the set of integral conversions. -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type' -/// \return True iff the integral pormotion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_integral_conversion + + Inputs: A typechecked expression 'expr', a destination + type 'type' + + Outputs: True iff the integral pormotion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Integral conversion + + An rvalue of type char, signed char, unsigned char, short int, + An rvalue of an integer type can be converted to an rvalue of + another integer type. An rvalue of an enumeration type can be + converted to an rvalue of an integer type. + + If the destination type is unsigned, the resulting value is the + least unsigned integer congruent to the source integer (modulo + 2n where n is the number of bits used to represent the unsigned + type). [Note: In a two's complement representation, this + conversion is conceptual and there is no change in the bit + pattern (if there is no truncation). ] + + If the destination type is signed, the value is unchanged if it + can be represented in the destination type (and bit-field width); + otherwise, the value is implementation-defined. + + If the destination type is bool, see 4.12. If the source type is + bool, the value false is converted to zero and the value true is + converted to one. + + The conversions allowed as integral promotions are excluded from + the set of integral conversions. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_integral_conversion( const exprt &expr, const typet &type, @@ -328,25 +389,34 @@ bool cpp_typecheckt::standard_conversion_integral_conversion( return true; } -/// Floating-integral conversion -/// -/// An rvalue of a floating point type can be converted to an rvalue -/// of an integer type. The conversion truncates; that is, the -/// fractional part is discarded. The behavior is undefined if the -/// truncated value cannot be represented in the destination type. -/// [Note: If the destination type is bool, see 4.12. ] -/// -/// An rvalue of an integer type or of an enumeration type can be -/// converted to an rvalue of a floating point type. The result is -/// exact if possible. Otherwise, it is an implementation-defined -/// choice of either the next lower or higher representable value. -/// [Note: loss of precision occurs if the integral value cannot be -/// represented exactly as a value of the floating type. ] If the -/// source type is bool, the value false is converted to zero and the -/// value true is converted to one. -/// \par parameters: A typechecked expression 'expr' -/// \return True iff the conversion is possible. The result of the conversion is -/// stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_floating_integral_conversion + + Inputs: A typechecked expression 'expr' + + Outputs: True iff the conversion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Floating-integral conversion + + An rvalue of a floating point type can be converted to an rvalue + of an integer type. The conversion truncates; that is, the + fractional part is discarded. The behavior is undefined if the + truncated value cannot be represented in the destination type. + [Note: If the destination type is bool, see 4.12. ] + + An rvalue of an integer type or of an enumeration type can be + converted to an rvalue of a floating point type. The result is + exact if possible. Otherwise, it is an implementation-defined + choice of either the next lower or higher representable value. + [Note: loss of precision occurs if the integral value cannot be + represented exactly as a value of the floating type. ] If the + source type is bool, the value false is converted to zero and the + value true is converted to one. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_floating_integral_conversion( const exprt &expr, const typet &type, @@ -383,22 +453,31 @@ bool cpp_typecheckt::standard_conversion_floating_integral_conversion( } -/// Floating-point conversion -/// -/// An rvalue of floating point type can be converted to an rvalue -/// of another floating point type. If the source value can be exactly -/// represented in the destination type, the result of the conversion -/// is that exact representation. If the source value is between two -/// adjacent destination values, the result of the conversion is an -/// implementation-defined choice of either of those values. Otherwise, -/// the behavior is undefined. -/// -/// The conversions allowed as floating point promotions are excluded -/// from the set of floating point conversions. -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type' -/// \return True iff the floating-point conversion is possible. The result of -/// the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_floating_point_conversion + + Inputs: A typechecked expression 'expr', a destination + type 'type' + + Outputs: True iff the floating-point conversion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Floating-point conversion + + An rvalue of floating point type can be converted to an rvalue + of another floating point type. If the source value can be exactly + represented in the destination type, the result of the conversion + is that exact representation. If the source value is between two + adjacent destination values, the result of the conversion is an + implementation-defined choice of either of those values. Otherwise, + the behavior is undefined. + + The conversions allowed as floating point promotions are excluded + from the set of floating point conversions. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_floating_point_conversion( const exprt &expr, const typet &type, @@ -425,38 +504,47 @@ bool cpp_typecheckt::standard_conversion_floating_point_conversion( return true; } -/// Pointer conversion -/// -/// A null pointer constant is an integral constant expression -/// (5.19) rvalue of integer type that evaluates to zero. A null -/// pointer constant can be converted to a pointer type; the result -/// is the null pointer value of that type and is distinguishable -/// from every other value of pointer to object or pointer to -/// function type. Two null pointer values of the same type shall -/// compare equal. The conversion of a null pointer constant to a -/// pointer to cv-qualified type is a single conversion, and not the -/// sequence of a pointer conversion followed by a qualification -/// conversion (4.4). -/// -/// An rvalue of type "pointer to cv T," where T is an object type, -/// can be converted to an rvalue of type "pointer to cv void." The -/// result of converting a "pointer to cv T" to a "pointer to cv -/// void" points to the start of the storage location where the -/// object of type T resides, as if the object is a most derived -/// object (1.8) of type T (that is, not a base class subobject). -/// -/// An rvalue of type "pointer to cv D," where D is a class type, -/// can be converted to an rvalue of type "pointer to cv B," where -/// B is a base class (clause 10) of D. If B is an inaccessible -/// (clause 11) or ambiguous (10.2) base class of D, a program that -/// necessitates this conversion is ill-formed. The result of the -/// conversion is a pointer to the base class sub-object of the -/// derived class object. The null pointer value is converted to -/// the null pointer value of the destination type. -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type' -/// \return True iff the pointer conversion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_pointer + + Inputs: A typechecked expression 'expr', a destination + type 'type' + + Outputs: True iff the pointer conversion is possible. + The result of the conversion is stored in 'new_expr'. + + Purpose: Pointer conversion + + A null pointer constant is an integral constant expression + (5.19) rvalue of integer type that evaluates to zero. A null + pointer constant can be converted to a pointer type; the result + is the null pointer value of that type and is distinguishable + from every other value of pointer to object or pointer to + function type. Two null pointer values of the same type shall + compare equal. The conversion of a null pointer constant to a + pointer to cv-qualified type is a single conversion, and not the + sequence of a pointer conversion followed by a qualification + conversion (4.4). + + An rvalue of type "pointer to cv T," where T is an object type, + can be converted to an rvalue of type "pointer to cv void." The + result of converting a "pointer to cv T" to a "pointer to cv + void" points to the start of the storage location where the + object of type T resides, as if the object is a most derived + object (1.8) of type T (that is, not a base class subobject). + + An rvalue of type "pointer to cv D," where D is a class type, + can be converted to an rvalue of type "pointer to cv B," where + B is a base class (clause 10) of D. If B is an inaccessible + (clause 11) or ambiguous (10.2) base class of D, a program that + necessitates this conversion is ill-formed. The result of the + conversion is a pointer to the base class sub-object of the + derived class object. The null pointer value is converted to + the null pointer value of the destination type. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_pointer( const exprt &expr, const typet &type, @@ -523,36 +611,46 @@ bool cpp_typecheckt::standard_conversion_pointer( return false; } -/// Pointer-to-member conversion -/// -/// A null pointer constant (4.10) can be converted to a pointer to -/// member type; the result is the null member pointer value of that -/// type and is distinguishable from any pointer to member not created -/// from a null pointer constant. Two null member pointer values of -/// the same type shall compare equal. The conversion of a null pointer -/// constant to a pointer to member of cv-qualified type is a single -/// conversion, and not the sequence of a pointer to member conversion -/// followed by a qualification conversion (4.4). -/// -/// An rvalue of type "pointer to member of B of type cv T," where B -/// is a class type, can be converted to an rvalue of type "pointer -/// to member of D of type cv T," where D is a derived class -/// (clause 10) of B. If B is an inaccessible (clause 11), ambiguous -/// (10.2) or virtual (10.1) base class of D, a program that -/// necessitates this conversion is ill-formed. The result of the -/// conversion refers to the same member as the pointer to member -/// before the conversion took place, but it refers to the base class -/// member as if it were a member of the derived class. The result -/// refers to the member in D"s instance of B. Since the result has -/// type "pointer to member of D of type cv T," it can be dereferenced -/// with a D object. The result is the same as if the pointer to -/// member of B were dereferenced with the B sub-object of D. The null -/// member pointer value is converted to the null member pointer value -/// of the destination type.52) -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type' -/// \return True iff the pointer-to-member conversion is possible. The result of -/// the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_pointer_to_member + + Inputs: A typechecked expression 'expr', a destination + type 'type' + + Outputs: True iff the pointer-to-member conversion is possible. + The result of the conversion is stored in 'new_expr'. + + + Purpose: Pointer-to-member conversion + + A null pointer constant (4.10) can be converted to a pointer to + member type; the result is the null member pointer value of that + type and is distinguishable from any pointer to member not created + from a null pointer constant. Two null member pointer values of + the same type shall compare equal. The conversion of a null pointer + constant to a pointer to member of cv-qualified type is a single + conversion, and not the sequence of a pointer to member conversion + followed by a qualification conversion (4.4). + + An rvalue of type "pointer to member of B of type cv T," where B + is a class type, can be converted to an rvalue of type "pointer + to member of D of type cv T," where D is a derived class + (clause 10) of B. If B is an inaccessible (clause 11), ambiguous + (10.2) or virtual (10.1) base class of D, a program that + necessitates this conversion is ill-formed. The result of the + conversion refers to the same member as the pointer to member + before the conversion took place, but it refers to the base class + member as if it were a member of the derived class. The result + refers to the member in D"s instance of B. Since the result has + type "pointer to member of D of type cv T," it can be dereferenced + with a D object. The result is the same as if the pointer to + member of B were dereferenced with the B sub-object of D. The null + member pointer value is converted to the null member pointer value + of the destination type.52) + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_pointer_to_member( const exprt &expr, const typet &type, @@ -626,15 +724,25 @@ bool cpp_typecheckt::standard_conversion_pointer_to_member( return false; } -/// Boolean conversion -/// -/// An rvalue of arithmetic, enumeration, pointer, or pointer to -/// member type can be converted to an rvalue of type bool. -/// A zero value, null pointer value, or null member pointer value is -/// converted to false; any other value is converted to true. -/// \par parameters: A typechecked expression 'expr' -/// \return True iff the boolean conversion is possible. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: standard_conversion_boolean + + Inputs: A typechecked expression 'expr' + + Outputs: True iff the boolean conversion is possible. + The result of the conversion is stored in 'new_expr'. + + + Purpose: Boolean conversion + + An rvalue of arithmetic, enumeration, pointer, or pointer to + member type can be converted to an rvalue of type bool. + A zero value, null pointer value, or null member pointer value is + converted to false; any other value is converted to true. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_boolean( const exprt &expr, exprt &new_expr) const { @@ -658,26 +766,37 @@ bool cpp_typecheckt::standard_conversion_boolean( return true; } -/// Standard Conversion Sequence -/// -/// A standard conversion sequence is a sequence of standard conversions -/// in the following order: -/// -/// * Zero or one conversion from the following set: lvalue-to-rvalue -/// conversion, array-to-pointer conversion, and function-to-pointer -/// conversion. -/// -/// * Zero or one conversion from the following set: integral -/// promotions, floating point promotion, integral conversions, -/// floating point conversions, floating-integral conversions, -/// pointer conversions, pointer to member conversions, and boolean -/// conversions. -/// -/// * Zero or one qualification conversion. -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type'. -/// \return True iff a standard conversion sequence exists. The result of the -/// conversion is stored in 'new_expr'. The reference 'rank' is incremented. +/*******************************************************************\ + +Function: standard_conversion_sequence + + Inputs: A typechecked expression 'expr', a destination + type 'type'. + + Outputs: True iff a standard conversion sequence exists. + The result of the conversion is stored in 'new_expr'. + The reference 'rank' is incremented. + + + Purpose: Standard Conversion Sequence + + A standard conversion sequence is a sequence of standard conversions + in the following order: + + * Zero or one conversion from the following set: lvalue-to-rvalue + conversion, array-to-pointer conversion, and function-to-pointer + conversion. + + * Zero or one conversion from the following set: integral + promotions, floating point promotion, integral conversions, + floating point conversions, floating-integral conversions, + pointer conversions, pointer to member conversions, and boolean + conversions. + + * Zero or one qualification conversion. + +\*******************************************************************/ + bool cpp_typecheckt::standard_conversion_sequence( const exprt &expr, const typet &type, @@ -843,11 +962,20 @@ bool cpp_typecheckt::standard_conversion_sequence( return true; } -/// User-defined conversion sequence -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type'. -/// \return True iff a user-defined conversion sequence exists. The result of -/// the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: user_defined_conversion_sequence + + Inputs: A typechecked expression 'expr', a destination + type 'type'. + + Outputs: True iff a user-defined conversion sequence exists. + The result of the conversion is stored in 'new_expr'. + + Purpose: User-defined conversion sequence + +\*******************************************************************/ + bool cpp_typecheckt::user_defined_conversion_sequence( const exprt &expr, const typet &type, @@ -1154,10 +1282,20 @@ bool cpp_typecheckt::user_defined_conversion_sequence( return new_expr.is_not_nil(); } -/// Reference-related -/// \par parameters: A typechecked expression 'expr', -/// a reference 'type'. -/// \return True iff an the reference 'type' is reference-related to 'expr'. +/*******************************************************************\ + +Function: reference_related + + Inputs: A typechecked expression 'expr', + a reference 'type'. + + Outputs: True iff an the reference 'type' is reference-related + to 'expr'. + + Purpose: Reference-related + +\*******************************************************************/ + bool cpp_typecheckt::reference_related( const exprt &expr, const typet &type) const @@ -1191,10 +1329,20 @@ bool cpp_typecheckt::reference_related( return false; } -/// Reference-compatible -/// \par parameters: A typechecked expression 'expr', a -/// reference 'type'. -/// \return True iff an the reference 'type' is reference-compatible to 'expr'. +/*******************************************************************\ + +Function: reference_compatible + + Inputs: A typechecked expression 'expr', a + reference 'type'. + + Outputs: True iff an the reference 'type' is reference-compatible + to 'expr'. + + Purpose: Reference-compatible + +\*******************************************************************/ + bool cpp_typecheckt::reference_compatible( const exprt &expr, const typet &type, @@ -1224,40 +1372,50 @@ bool cpp_typecheckt::reference_compatible( return false; } -/// Reference binding -/// -/// When a parameter of reference type binds directly (8.5.3) to an -/// argument expression, the implicit conversion sequence is the -/// identity conversion, unless the argument expression has a type -/// that is a derived class of the parameter type, in which case the -/// implicit conversion sequence is a derived-to-base Conversion -/// (13.3.3.1). -/// -/// If the parameter binds directly to the result of applying a -/// conversion function to the argument expression, the implicit -/// conversion sequence is a user-defined conversion sequence -/// (13.3.3.1.2), with the second standard conversion sequence -/// either an identity conversion or, if the conversion function -/// returns an entity of a type that is a derived class of the -/// parameter type, a derived-to-base Conversion. -/// -/// When a parameter of reference type is not bound directly to -/// an argument expression, the conversion sequence is the one -/// required to convert the argument expression to the underlying -/// type of the reference according to 13.3.3.1. Conceptually, this -/// conversion sequence corresponds to copy-initializing a temporary -/// of the underlying type with the argument expression. Any -/// difference in top-level cv-qualification is subsumed by the -/// initialization itself and does not constitute a conversion. -/// -/// A standard conversion sequence cannot be formed if it requires -/// binding a reference to non-const to an rvalue (except when -/// binding an implicit object parameter; see the special rules -/// for that case in 13.3.1). -/// \par parameters: A typechecked expression 'expr', a -/// reference 'type'. -/// \return True iff an the reference can be bound to the expression. The result -/// of the conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: reference_binding + + Inputs: A typechecked expression 'expr', a + reference 'type'. + + Outputs: True iff an the reference can be bound to the expression. + The result of the conversion is stored in 'new_expr'. + + + Purpose: Reference binding + + When a parameter of reference type binds directly (8.5.3) to an + argument expression, the implicit conversion sequence is the + identity conversion, unless the argument expression has a type + that is a derived class of the parameter type, in which case the + implicit conversion sequence is a derived-to-base Conversion + (13.3.3.1). + + If the parameter binds directly to the result of applying a + conversion function to the argument expression, the implicit + conversion sequence is a user-defined conversion sequence + (13.3.3.1.2), with the second standard conversion sequence + either an identity conversion or, if the conversion function + returns an entity of a type that is a derived class of the + parameter type, a derived-to-base Conversion. + + When a parameter of reference type is not bound directly to + an argument expression, the conversion sequence is the one + required to convert the argument expression to the underlying + type of the reference according to 13.3.3.1. Conceptually, this + conversion sequence corresponds to copy-initializing a temporary + of the underlying type with the argument expression. Any + difference in top-level cv-qualification is subsumed by the + initialization itself and does not constitute a conversion. + + A standard conversion sequence cannot be formed if it requires + binding a reference to non-const to an rvalue (except when + binding an implicit object parameter; see the special rules + for that case in 13.3.1). + +\*******************************************************************/ + bool cpp_typecheckt::reference_binding( exprt expr, const typet &type, @@ -1461,12 +1619,21 @@ bool cpp_typecheckt::reference_binding( return false; } -/// implicit conversion sequence -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type'. -/// \return True iff an implicit conversion sequence exists. The result of the -/// conversion is stored in 'new_expr'. The rank of the sequence is stored in -/// 'rank' +/*******************************************************************\ + +Function: implicit_conversion_sequence + + Inputs: A typechecked expression 'expr', a destination + type 'type'. + + Outputs: True iff an implicit conversion sequence exists. + The result of the conversion is stored in 'new_expr'. + The rank of the sequence is stored in 'rank' + + Purpose: implicit conversion sequence + +\*******************************************************************/ + bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1504,11 +1671,20 @@ bool cpp_typecheckt::implicit_conversion_sequence( return true; } -/// implicit conversion sequence -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type'. -/// \return True iff an implicit conversion sequence exists. The result of the -/// conversion is stored in 'new_expr'. +/*******************************************************************\ + +Function: implicit_conversion_sequence + + Inputs: A typechecked expression 'expr', a destination + type 'type'. + + Outputs: True iff an implicit conversion sequence exists. + The result of the conversion is stored in 'new_expr'. + + Purpose: implicit conversion sequence + +\*******************************************************************/ + bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1518,11 +1694,22 @@ bool cpp_typecheckt::implicit_conversion_sequence( return implicit_conversion_sequence(expr, type, new_expr, rank); } -/// implicit conversion sequence -/// \par parameters: A typechecked expression 'expr', a destination -/// type 'type'. -/// \return True iff an implicit conversion sequence exists. The rank of the -/// sequence is stored in 'rank' +/*******************************************************************\ + +Function: implicit_conversion_sequence + + Inputs: A typechecked expression 'expr', a destination + type 'type'. + + Outputs: True iff an implicit conversion sequence exists. + The rank of the sequence is stored in 'rank' + + + Purpose: implicit conversion sequence + + +\*******************************************************************/ + bool cpp_typecheckt::implicit_conversion_sequence( const exprt &expr, const typet &type, @@ -1532,6 +1719,18 @@ bool cpp_typecheckt::implicit_conversion_sequence( return implicit_conversion_sequence(expr, type, new_expr, rank); } +/*******************************************************************\ + +Function: cpp_typecheck_baset::implicit_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type) { exprt e=expr; @@ -1551,48 +1750,61 @@ void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type) } } -/// A reference to type "cv1 T1" is initialized by an expression of -/// type "cv2 T2" as follows: -/// -/// - If the initializer expression -/// - is an lvalue (but is not a bit-field), and "cv1 T1" is -/// reference-compatible with "cv2 T2," or -/// - has a class type (i.e., T2 is a class type) and can be -/// implicitly converted to an lvalue of type "cv3 T3," where -/// "cv1 T1" is reference-compatible with "cv3 T3" 92) (this -/// conversion is selected by enumerating the applicable conversion -/// functions (13.3.1.6) and choosing the best one through overload -/// resolution (13.3)), -/// -/// then the reference is bound directly to the initializer -/// expression lvalue in the first case, and the reference is -/// bound to the lvalue result of the conversion in the second -/// case. In these cases the reference is said to bind directly -/// to the initializer expression. -/// -/// - Otherwise, the reference shall be to a non-volatile const type -/// - If the initializer expression is an rvalue, with T2 a class -/// type, and "cv1 T1" is reference-compatible with "cv2 T2," the -/// reference is bound in one of the following ways (the choice is -/// implementation-defined): -/// -/// - The reference is bound to the object represented by the -/// rvalue (see 3.10) or to a sub-object within that object. -/// -/// - A temporary of type "cv1 T2" [sic] is created, and a -/// constructor is called to copy the entire rvalue object into -/// the temporary. The reference is bound to the temporary or -/// to a sub-object within the temporary. -/// -/// The constructor that would be used to make the copy shall be -/// callable whether or not the copy is actually done. -/// -/// Otherwise, a temporary of type "cv1 T1" is created and -/// initialized from the initializer expression using the rules for -/// a non-reference copy initialization (8.5). The reference is then -/// bound to the temporary. If T1 is reference-related to T2, cv1 -/// must be the same cv-qualification as, or greater cvqualification -/// than, cv2; otherwise, the program is ill-formed. +/*******************************************************************\ + +Function: cpp_typecheck_baset::reference_initializer + + Inputs: + + Outputs: + + Purpose: + + A reference to type "cv1 T1" is initialized by an expression of + type "cv2 T2" as follows: + + - If the initializer expression + - is an lvalue (but is not a bit-field), and "cv1 T1" is + reference-compatible with "cv2 T2," or + - has a class type (i.e., T2 is a class type) and can be + implicitly converted to an lvalue of type "cv3 T3," where + "cv1 T1" is reference-compatible with "cv3 T3" 92) (this + conversion is selected by enumerating the applicable conversion + functions (13.3.1.6) and choosing the best one through overload + resolution (13.3)), + + then the reference is bound directly to the initializer + expression lvalue in the first case, and the reference is + bound to the lvalue result of the conversion in the second + case. In these cases the reference is said to bind directly + to the initializer expression. + + - Otherwise, the reference shall be to a non-volatile const type + - If the initializer expression is an rvalue, with T2 a class + type, and "cv1 T1" is reference-compatible with "cv2 T2," the + reference is bound in one of the following ways (the choice is + implementation-defined): + + - The reference is bound to the object represented by the + rvalue (see 3.10) or to a sub-object within that object. + + - A temporary of type "cv1 T2" [sic] is created, and a + constructor is called to copy the entire rvalue object into + the temporary. The reference is bound to the temporary or + to a sub-object within the temporary. + + The constructor that would be used to make the copy shall be + callable whether or not the copy is actually done. + + Otherwise, a temporary of type "cv1 T1" is created and + initialized from the initializer expression using the rules for + a non-reference copy initialization (8.5). The reference is then + bound to the temporary. If T1 is reference-related to T2, cv1 + must be the same cv-qualification as, or greater cvqualification + than, cv2; otherwise, the program is ill-formed. + +\*******************************************************************/ + void cpp_typecheckt::reference_initializer( exprt &expr, const typet &type) @@ -1613,6 +1825,19 @@ void cpp_typecheckt::reference_initializer( throw 0; } +/*******************************************************************\ + +Function: cpp_typecheckt::cast_away_constness + + Inputs: + + Outputs: + + Purpose: + + +\*******************************************************************/ + bool cpp_typecheckt::cast_away_constness( const typet &t1, const typet &t2) const @@ -1676,6 +1901,18 @@ bool cpp_typecheckt::cast_away_constness( return !standard_conversion_qualification(e1, snt2.back(), e2); } +/*******************************************************************\ + +Function: cpp_typecheckt::const_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::const_typecast( const exprt &expr, const typet &type, @@ -1735,6 +1972,18 @@ bool cpp_typecheckt::const_typecast( return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::dynamic_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::dynamic_typecast( const exprt &expr, const typet &type, @@ -1787,6 +2036,18 @@ bool cpp_typecheckt::dynamic_typecast( return static_typecast(e, type, new_expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::reinterpret_typecastcast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::reinterpret_typecast( const exprt &expr, const typet &type, @@ -1891,6 +2152,18 @@ bool cpp_typecheckt::reinterpret_typecast( return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::static_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::static_typecast( const exprt &expr, // source expression const typet &type, // destination type diff --git a/src/cpp/cpp_typecheck_declaration.cpp b/src/cpp/cpp_typecheck_declaration.cpp index 8568b525a91..980413225b1 100644 --- a/src/cpp/cpp_typecheck_declaration.cpp +++ b/src/cpp/cpp_typecheck_declaration.cpp @@ -6,12 +6,21 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \********************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" #include "cpp_declarator_converter.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_declarationt &declaration) { // see if the declaration is empty @@ -35,6 +44,18 @@ void cpp_typecheckt::convert(cpp_declarationt &declaration) method_bodies.swap(old_method_bodies); } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_anonymous_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_anonymous_union( cpp_declarationt &declaration, codet &code) @@ -109,6 +130,18 @@ void cpp_typecheckt::convert_anonymous_union( code.swap(new_code); } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_non_template_declaration + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_non_template_declaration( cpp_declarationt &declaration) { diff --git a/src/cpp/cpp_typecheck_destructor.cpp b/src/cpp/cpp_typecheck_destructor.cpp index b8038d5c01f..4b1be9ceeb4 100644 --- a/src/cpp/cpp_typecheck_destructor.cpp +++ b/src/cpp/cpp_typecheck_destructor.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::find_dtor + + Inputs: + + Outputs: + + Note: + +\*******************************************************************/ + bool cpp_typecheckt::find_dtor(const symbolt &symbol) const { const irept &components= @@ -25,7 +34,20 @@ bool cpp_typecheckt::find_dtor(const symbolt &symbol) const return false; } -/// Note: +/*******************************************************************\ + +Function: default_dtor + + Inputs: + + Outputs: + + Purpose: + + Note: + +\*******************************************************************/ + void cpp_typecheckt::default_dtor( const symbolt &symbol, cpp_declarationt &dtor) @@ -55,9 +77,20 @@ void cpp_typecheckt::default_dtor( dtor.move_to_operands(decl); } -/// produces destructor code for a class object -/// -/// Note: +/*******************************************************************\ + +Function: cpp_typecheckt::dtor + + Inputs: + + Outputs: + + Purpose: produces destructor code for a class object + + Note: + +\*******************************************************************/ + codet cpp_typecheckt::dtor(const symbolt &symbol) { assert(symbol.type.id()==ID_struct || diff --git a/src/cpp/cpp_typecheck_enum_type.cpp b/src/cpp/cpp_typecheck_enum_type.cpp index 9284ca9b296..09c57e9e9bc 100644 --- a/src/cpp/cpp_typecheck_enum_type.cpp +++ b/src/cpp/cpp_typecheck_enum_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cpp_typecheck.h" #include "cpp_enum_type.h" +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_enum_body + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) { c_enum_typet &c_enum_type=to_c_enum_type(enum_symbol.type); @@ -80,6 +89,18 @@ void cpp_typecheckt::typecheck_enum_body(symbolt &enum_symbol) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_enum_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_enum_type(typet &type) { // first save qualifiers diff --git a/src/cpp/cpp_typecheck_expr.cpp b/src/cpp/cpp_typecheck_expr.cpp index 9f7d785e502..a29d27634d8 100644 --- a/src/cpp/cpp_typecheck_expr.cpp +++ b/src/cpp/cpp_typecheck_expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -30,6 +27,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_exception_id.h" #include "expr2cpp.h" +/*******************************************************************\ + +Function: cpp_typecheckt::find_parent + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::find_parent( const symbolt &symb, const irep_idt &base_name, @@ -47,7 +56,18 @@ bool cpp_typecheckt::find_parent( return false; } -/// Called after the operands are done +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_main + +Inputs: + +Outputs: + +Purpose: Called after the operands are done + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_cpp_name) @@ -136,6 +156,18 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr) c_typecheck_baset::typecheck_expr_main(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_trinary + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) { assert(expr.operands().size()==3); @@ -297,6 +329,18 @@ void cpp_typecheckt::typecheck_expr_trinary(if_exprt &expr) return; } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_member + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_member(exprt &expr) { typecheck_expr_member( @@ -304,6 +348,18 @@ void cpp_typecheckt::typecheck_expr_member(exprt &expr) cpp_typecheck_fargst()); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_sizeof + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) { // We need to overload, "sizeof-expression" can be mis-parsed @@ -359,11 +415,35 @@ void cpp_typecheckt::typecheck_expr_sizeof(exprt &expr) c_typecheck_baset::typecheck_expr_sizeof(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_ptrmember + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_ptrmember(exprt &expr) { typecheck_expr_ptrmember(expr, cpp_typecheck_fargst()); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_function_expr + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_function_expr( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -420,6 +500,18 @@ void cpp_typecheckt::typecheck_function_expr( typecheck_expr(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::overloadable + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheckt::overloadable(const exprt &expr) { // at least one argument must have class or enumerated type @@ -440,6 +532,18 @@ bool cpp_typecheckt::overloadable(const exprt &expr) return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::operator_is_overloaded + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + struct operator_entryt { const irep_idt id; @@ -698,6 +802,18 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr) return false; } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_address_of + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -759,6 +875,18 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr) expr.type()=reference_typet(expr.type().subtype()); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_throw + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_throw(exprt &expr) { // these are of type void @@ -785,6 +913,18 @@ void cpp_typecheckt::typecheck_expr_throw(exprt &expr) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_new + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_new(exprt &expr) { // next, find out if we do an array @@ -862,6 +1002,18 @@ void cpp_typecheckt::typecheck_expr_new(exprt &expr) sizeof_expr.add("#c_sizeof_type")=expr.type().subtype(); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_explicit_typecast + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static exprt collect_comma_expression(const exprt &src) { exprt result; @@ -964,6 +1116,18 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_explicit_constructor_call + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr) { typecheck_type(expr.type()); @@ -986,6 +1150,18 @@ void cpp_typecheckt::typecheck_expr_explicit_constructor_call(exprt &expr) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_this + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_this(exprt &expr) { if(cpp_scopes.current_scope().class_identifier.empty()) @@ -1005,6 +1181,18 @@ void cpp_typecheckt::typecheck_expr_this(exprt &expr) expr.add_source_location()=source_location; } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_delete + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_delete(exprt &expr) { if(expr.operands().size()!=1) @@ -1062,6 +1250,18 @@ void cpp_typecheckt::typecheck_expr_delete(exprt &expr) expr.set(ID_destructor, destructor_code); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_typecast + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_typecast(exprt &expr) { // should not be called @@ -1071,6 +1271,18 @@ void cpp_typecheckt::typecheck_expr_typecast(exprt &expr) #endif } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_member + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_member( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -1252,6 +1464,18 @@ void cpp_typecheckt::typecheck_expr_member( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_ptrmember + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_ptrmember( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -1290,6 +1514,18 @@ void cpp_typecheckt::typecheck_expr_ptrmember( typecheck_expr_member(expr, fargs); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_cast_expr + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_cast_expr(exprt &expr) { side_effect_expr_function_callt e = @@ -1399,6 +1635,18 @@ void cpp_typecheckt::typecheck_cast_expr(exprt &expr) expr.swap(new_expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_cpp_name + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_cpp_name( exprt &expr, const cpp_typecheck_fargst &fargs) @@ -1899,6 +2147,18 @@ void cpp_typecheckt::typecheck_expr_cpp_name( add_implicit_dereference(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::add_implicit_dereference + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::add_implicit_dereference(exprt &expr) { if(is_reference(expr.type())) @@ -1913,6 +2173,18 @@ void cpp_typecheckt::add_implicit_dereference(exprt &expr) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_side_effect_function_call + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_side_effect_function_call( side_effect_expr_function_callt &expr) { @@ -2277,8 +2549,18 @@ void cpp_typecheckt::typecheck_side_effect_function_call( expr.swap(tmp); } -/// \param type:checked arguments, type-checked function -/// \return type-adjusted function arguments +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_function_call_arguments + + Inputs: type-checked arguments, type-checked function + + Outputs: type-adjusted function arguments + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_function_call_arguments( side_effect_expr_function_callt &expr) { @@ -2332,6 +2614,18 @@ void cpp_typecheckt::typecheck_function_call_arguments( c_typecheck_baset::typecheck_function_call_arguments(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_side_effect + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_side_effect( side_effect_exprt &expr) { @@ -2366,6 +2660,18 @@ void cpp_typecheckt::typecheck_expr_side_effect( c_typecheck_baset::typecheck_expr_side_effect(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_method_application + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_method_application( side_effect_expr_function_callt &expr) { @@ -2426,6 +2732,18 @@ void cpp_typecheckt::typecheck_method_application( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_side_effect_assignment + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) { if(expr.operands().size()!=2) @@ -2513,6 +2831,18 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr) expr=new_expr; } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_side_effect_inc_dec + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_side_effect_inc_dec( side_effect_exprt &expr) { @@ -2589,6 +2919,18 @@ void cpp_typecheckt::typecheck_side_effect_inc_dec( expr.swap(new_expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_dereference + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_dereference(exprt &expr) { if(expr.operands().size()!=1) @@ -2613,6 +2955,18 @@ void cpp_typecheckt::typecheck_expr_dereference(exprt &expr) c_typecheck_baset::typecheck_expr_dereference(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_pmop + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_pmop(exprt &expr) { assert(expr.id()=="pointer-to-member"); @@ -2683,6 +3037,18 @@ void cpp_typecheckt::convert_pmop(exprt &expr) return; } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_function_identifier + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr) { if(expr.id()==ID_symbol) @@ -2702,6 +3068,18 @@ void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr) c_typecheck_baset::typecheck_expr_function_identifier(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr(exprt &expr) { bool override_constantness= @@ -2724,6 +3102,18 @@ void cpp_typecheckt::typecheck_expr(exprt &expr) expr.type().set(ID_C_constant, false); } +/*******************************************************************\ + +Function: cpp_typecheckt::explict_typecast_ambiguity + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) { // There is an ambiguity in the C++ grammar as follows: @@ -2779,6 +3169,18 @@ void cpp_typecheckt::explicit_typecast_ambiguity(exprt &expr) } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_binary_arithmetic + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_binary_arithmetic(exprt &expr) { if(expr.operands().size()!=2) @@ -2795,11 +3197,35 @@ void cpp_typecheckt::typecheck_expr_binary_arithmetic(exprt &expr) c_typecheck_baset::typecheck_expr_binary_arithmetic(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_index + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_index(exprt &expr) { c_typecheck_baset::typecheck_expr_index(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_comma + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_comma(exprt &expr) { if(expr.operands().size()!=2) @@ -2817,6 +3243,18 @@ void cpp_typecheckt::typecheck_expr_comma(exprt &expr) c_typecheck_baset::typecheck_expr_comma(expr); } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_expr_rel + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_expr_rel(binary_relation_exprt &expr) { c_typecheck_baset::typecheck_expr_rel(expr); diff --git a/src/cpp/cpp_typecheck_fargs.cpp b/src/cpp/cpp_typecheck_fargs.cpp index e4dde682732..592c538fc2c 100644 --- a/src/cpp/cpp_typecheck_fargs.cpp +++ b/src/cpp/cpp_typecheck_fargs.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck_fargs.h" #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheck_fargst::has_class_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheck_fargst::has_class_type() const { for(exprt::operandst::const_iterator it=operands.begin(); @@ -31,6 +40,18 @@ bool cpp_typecheck_fargst::has_class_type() const return false; } +/*******************************************************************\ + +Function: cpp_typecheck_fargst::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheck_fargst::build( const side_effect_expr_function_callt &function_call) { @@ -43,6 +64,18 @@ void cpp_typecheck_fargst::build( operands.push_back(function_call.op1().operands()[i]); } +/*******************************************************************\ + +Function: cpp_typecheck_fargst::exact_match + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_typecheck_fargst::match( const code_typet &code_type, unsigned &distance, diff --git a/src/cpp/cpp_typecheck_fargs.h b/src/cpp/cpp_typecheck_fargs.h index 5b6a62e0b4a..370cc10ed65 100644 --- a/src/cpp/cpp_typecheck_fargs.h +++ b/src/cpp/cpp_typecheck_fargs.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_TYPECHECK_FARGS_H #define CPROVER_CPP_CPP_TYPECHECK_FARGS_H diff --git a/src/cpp/cpp_typecheck_function.cpp b/src/cpp/cpp_typecheck_function.cpp index 5dd98b47336..a55bbf41d6b 100644 --- a/src/cpp/cpp_typecheck_function.cpp +++ b/src/cpp/cpp_typecheck_function.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_template_type.h" @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_type2name.h" #include "cpp_util.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert_parameter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_parameter( const irep_idt &mode, code_typet::parametert ¶meter) @@ -60,6 +69,18 @@ void cpp_typecheckt::convert_parameter( cpp_scopes.put_into_scope(*new_symbol); } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_parameters + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_parameters( const irep_idt &mode, code_typet &function_type) @@ -74,6 +95,18 @@ void cpp_typecheckt::convert_parameters( convert_parameter(mode, *it); } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_function(symbolt &symbol) { code_typet &function_type= @@ -138,7 +171,18 @@ void cpp_typecheckt::convert_function(symbolt &symbol) return_type = old_return_type; } -/// for function overloading +/*******************************************************************\ + +Function: cpp_typecheckt::function_identifier + + Inputs: + + Outputs: + + Purpose: for function overloading + +\*******************************************************************/ + irep_idt cpp_typecheckt::function_identifier(const typet &type) { const code_typet &function_type= diff --git a/src/cpp/cpp_typecheck_initializer.cpp b/src/cpp/cpp_typecheck_initializer.cpp index 6666af581ed..f51490e77f8 100644 --- a/src/cpp/cpp_typecheck_initializer.cpp +++ b/src/cpp/cpp_typecheck_initializer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -19,7 +16,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_typecheck.h" #include "cpp_util.h" -/// Initialize an object with a value +/*******************************************************************\ + +Function: cpp_typecheckt::convert_initializer + + Inputs: + + Outputs: + + Purpose: Initialize an object with a value + +\*******************************************************************/ + void cpp_typecheckt::convert_initializer(symbolt &symbol) { // this is needed for template arguments that are types @@ -171,6 +179,18 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol) } } +/*******************************************************************\ + +Function: cpp_typecheckt::zero_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::zero_initializer( const exprt &object, const typet &type, diff --git a/src/cpp/cpp_typecheck_linkage_spec.cpp b/src/cpp/cpp_typecheck_linkage_spec.cpp index a21a5913979..39ebc12db29 100644 --- a/src/cpp/cpp_typecheck_linkage_spec.cpp +++ b/src/cpp/cpp_typecheck_linkage_spec.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_linkage_spect &linkage_spec) { irep_idt old_linkage_spec=current_linkage_spec; diff --git a/src/cpp/cpp_typecheck_method_bodies.cpp b/src/cpp/cpp_typecheck_method_bodies.cpp index d37b686a215..0b16bebd8d8 100644 --- a/src/cpp/cpp_typecheck_method_bodies.cpp +++ b/src/cpp/cpp_typecheck_method_bodies.cpp @@ -7,11 +7,20 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_method_bodies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_method_bodies( method_bodiest &bodies) { diff --git a/src/cpp/cpp_typecheck_namespace.cpp b/src/cpp/cpp_typecheck_namespace.cpp index 437a874aebd..81fea3a3eae 100644 --- a/src/cpp/cpp_typecheck_namespace.cpp +++ b/src/cpp/cpp_typecheck_namespace.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_namespace_spect &namespace_spec) { // save the scope diff --git a/src/cpp/cpp_typecheck_resolve.cpp b/src/cpp/cpp_typecheck_resolve.cpp index a9b9953e3ac..82250a8a748 100644 --- a/src/cpp/cpp_typecheck_resolve.cpp +++ b/src/cpp/cpp_typecheck_resolve.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -28,11 +25,35 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_util.h" #include "cpp_convert_type.h" +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::cpp_typecheck_resolvet + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + cpp_typecheck_resolvet::cpp_typecheck_resolvet(cpp_typecheckt &_cpp_typecheck): cpp_typecheck(_cpp_typecheck) { } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::convert_identifiers + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::convert_identifiers( const cpp_scopest::id_sett &id_set, const wantt want, @@ -57,6 +78,18 @@ void cpp_typecheck_resolvet::convert_identifiers( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::apply_template_args + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::apply_template_args( resolve_identifierst &identifiers, const cpp_template_args_non_tct &template_args, @@ -83,7 +116,18 @@ void cpp_typecheck_resolvet::apply_template_args( } } -/// guess arguments of function templates +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::guess_function_template_args + +Inputs: + +Outputs: + +Purpose: guess arguments of function templates + +\*******************************************************************/ + void cpp_typecheck_resolvet::guess_function_template_args( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -135,6 +179,18 @@ void cpp_typecheck_resolvet::guess_function_template_args( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::remove_templates + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::remove_templates( resolve_identifierst &identifiers) { @@ -151,6 +207,18 @@ void cpp_typecheck_resolvet::remove_templates( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::remove_duplicates + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::remove_duplicates( resolve_identifierst &identifiers) { @@ -185,6 +253,18 @@ void cpp_typecheck_resolvet::remove_duplicates( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::convert_template_parameter + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + exprt cpp_typecheck_resolvet::convert_template_parameter( const cpp_idt &identifier) { @@ -206,6 +286,18 @@ exprt cpp_typecheck_resolvet::convert_template_parameter( return e; } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::convert_identifier + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + exprt cpp_typecheck_resolvet::convert_identifier( const cpp_idt &identifier, const wantt want, @@ -374,6 +466,18 @@ exprt cpp_typecheck_resolvet::convert_identifier( return e; } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::filter + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::filter( resolve_identifierst &identifiers, const wantt want) @@ -411,6 +515,18 @@ void cpp_typecheck_resolvet::filter( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::exact_match_functions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::exact_match_functions( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -436,6 +552,18 @@ void cpp_typecheck_resolvet::exact_match_functions( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::disambiguate_functions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::disambiguate_functions( resolve_identifierst &identifiers, const cpp_typecheck_fargst &fargs) @@ -581,6 +709,18 @@ void cpp_typecheck_resolvet::disambiguate_functions( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::make_constructors + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::make_constructors( resolve_identifierst &identifiers) { @@ -672,6 +812,18 @@ void cpp_typecheck_resolvet::make_constructors( identifiers.swap(new_identifiers); } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::do_builtin + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + exprt cpp_typecheck_resolvet::do_builtin( const irep_idt &base_name, const cpp_template_args_non_tct &template_args) @@ -858,9 +1010,20 @@ exprt cpp_typecheck_resolvet::do_builtin( return dest; } -/// \par parameters: a cpp_name -/// \return a base_name, and potentially template arguments for the base name; -/// as side-effect, we got to the right scope +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::resolve_scope + +Inputs: a cpp_name + +Outputs: a base_name, and potentially template arguments for + the base name; as side-effect, we got to the right + scope + +Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_typecheck_resolvet::resolve_scope( const cpp_namet &cpp_name, irep_idt &base_name, @@ -1001,7 +1164,18 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope( return cpp_typecheck.cpp_scopes.current_scope(); } -/// disambiguate partial specialization +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::disambiguate_template_classes + +Inputs: + +Outputs: + +Purpose: disambiguate partial specialization + +\*******************************************************************/ + symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( const irep_idt &base_name, const cpp_scopest::id_sett &id_set, @@ -1229,6 +1403,18 @@ symbol_typet cpp_typecheck_resolvet::disambiguate_template_classes( #endif } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::resolve_namespace + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_typecheck_resolvet::resolve_namespace( const cpp_namet &cpp_name) { @@ -1274,6 +1460,18 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_namespace( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::show_identifiers + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::show_identifiers( const irep_idt &base_name, const resolve_identifierst &identifiers, @@ -1370,6 +1568,18 @@ void cpp_typecheck_resolvet::show_identifiers( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::resolve + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + exprt cpp_typecheck_resolvet::resolve( const cpp_namet &cpp_name, const wantt want, @@ -1708,6 +1918,18 @@ exprt cpp_typecheck_resolvet::resolve( return result; } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::guess_template_args + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::guess_template_args( const exprt &template_expr, const exprt &desired_expr) @@ -1753,6 +1975,18 @@ void cpp_typecheck_resolvet::guess_template_args( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::guess_template_args + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::guess_template_args( const typet &template_type, const typet &desired_type) @@ -1894,7 +2128,18 @@ void cpp_typecheck_resolvet::guess_template_args( } } -/// Guess template arguments for function templates +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::guess_function_template_args + +Inputs: + +Outputs: + +Purpose: Guess template arguments for function templates + +\*******************************************************************/ + exprt cpp_typecheck_resolvet::guess_function_template_args( const exprt &expr, const cpp_typecheck_fargst &fargs) @@ -2034,6 +2279,18 @@ exprt cpp_typecheck_resolvet::guess_function_template_args( return template_function_instance; } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::apply_template_args + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::apply_template_args( exprt &expr, const cpp_template_args_non_tct &template_args_non_tc, @@ -2138,6 +2395,18 @@ void cpp_typecheck_resolvet::apply_template_args( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::disambiguate_functions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool cpp_typecheck_resolvet::disambiguate_functions( const exprt &expr, unsigned &args_distance, @@ -2200,6 +2469,18 @@ bool cpp_typecheck_resolvet::disambiguate_functions( return fargs.match(type, args_distance, cpp_typecheck); } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::filter_for_named_scopes + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::filter_for_named_scopes( cpp_scopest::id_sett &id_set) { @@ -2338,6 +2619,18 @@ void cpp_typecheck_resolvet::filter_for_named_scopes( id_set.swap(new_set); } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::filter_for_namespaces + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::filter_for_namespaces( cpp_scopest::id_sett &id_set) { @@ -2358,6 +2651,18 @@ void cpp_typecheck_resolvet::filter_for_namespaces( } } +/*******************************************************************\ + +Function: cpp_typecheck_resolvet::resolve_with_arguments + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void cpp_typecheck_resolvet::resolve_with_arguments( cpp_scopest::id_sett &id_set, const irep_idt &base_name, diff --git a/src/cpp/cpp_typecheck_resolve.h b/src/cpp/cpp_typecheck_resolve.h index 1b6e1af615a..6d9031b62e0 100644 --- a/src/cpp/cpp_typecheck_resolve.h +++ b/src/cpp/cpp_typecheck_resolve.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H #define CPROVER_CPP_CPP_TYPECHECK_RESOLVE_H diff --git a/src/cpp/cpp_typecheck_static_assert.cpp b/src/cpp/cpp_typecheck_static_assert.cpp index e72dc318095..3e449a9f043 100644 --- a/src/cpp/cpp_typecheck_static_assert.cpp +++ b/src/cpp/cpp_typecheck_static_assert.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_static_assertt &cpp_static_assert) { typecheck_expr(cpp_static_assert.op0()); diff --git a/src/cpp/cpp_typecheck_template.cpp b/src/cpp/cpp_typecheck_template.cpp index 5706f380e46..29acce8c65c 100644 --- a/src/cpp/cpp_typecheck_template.cpp +++ b/src/cpp/cpp_typecheck_template.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_type2name.h" @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "cpp_template_args.h" +/*******************************************************************\ + +Function: cpp_typecheckt::salvage_default_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::salvage_default_arguments( const template_typet &old_type, template_typet &new_type) @@ -39,6 +48,18 @@ void cpp_typecheckt::salvage_default_arguments( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_class_template + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_class_template( cpp_declarationt &declaration) { @@ -202,7 +223,18 @@ void cpp_typecheckt::typecheck_class_template( cpp_idt::id_classt::TEMPLATE_SCOPE); } -/// typecheck function templates +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_function_template + + Inputs: + + Outputs: + + Purpose: typecheck function templates + +\*******************************************************************/ + void cpp_typecheckt::typecheck_function_template( cpp_declarationt &declaration) { @@ -305,7 +337,19 @@ void cpp_typecheckt::typecheck_function_template( cpp_scopes.id_map[symbol_name] = &template_scope; } -/// typecheck class tempalte members; these can be methods or static members +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_class_template_member + + Inputs: + + Outputs: + + Purpose: typecheck class tempalte members; + these can be methods or static members + +\*******************************************************************/ + void cpp_typecheckt::typecheck_class_template_member( cpp_declarationt &declaration) { @@ -418,6 +462,18 @@ void cpp_typecheckt::typecheck_class_template_member( } } +/*******************************************************************\ + +Function: cpp_typecheckt::class_template_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_typecheckt::class_template_identifier( const irep_idt &base_name, const template_typet &template_type, @@ -477,6 +533,18 @@ std::string cpp_typecheckt::class_template_identifier( return identifier; } +/*******************************************************************\ + +Function: cpp_typecheckt::function_template_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cpp_typecheckt::function_template_identifier( const irep_idt &base_name, const template_typet &template_type, @@ -494,6 +562,18 @@ std::string cpp_typecheckt::function_template_identifier( return identifier; } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_class_template_specialization + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_class_template_specialization( cpp_declarationt &declaration) { @@ -615,6 +695,18 @@ void cpp_typecheckt::convert_class_template_specialization( } } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_template_function_or_member_specialization + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_template_function_or_member_specialization( cpp_declarationt &declaration) { @@ -716,6 +808,18 @@ void cpp_typecheckt::convert_template_function_or_member_specialization( } } +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_template_parameters + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_scopet &cpp_typecheckt::typecheck_template_parameters( template_typet &type) { @@ -847,8 +951,18 @@ cpp_scopet &cpp_typecheckt::typecheck_template_parameters( return template_scope; } -/// \par parameters: location, non-typechecked template arguments -/// \return typechecked template arguments +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_template_args + + Inputs: location, non-typechecked template arguments + + Outputs: typechecked template arguments + + Purpose: + +\*******************************************************************/ + cpp_template_args_tct cpp_typecheckt::typecheck_template_args( const source_locationt &source_location, const symbolt &template_symbol, @@ -986,6 +1100,18 @@ cpp_template_args_tct cpp_typecheckt::typecheck_template_args( return result; } +/*******************************************************************\ + +Function: cpp_typecheckt::convert_template_declaration + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert_template_declaration( cpp_declarationt &declaration) { diff --git a/src/cpp/cpp_typecheck_type.cpp b/src/cpp/cpp_typecheck_type.cpp index 8536e80fa73..3672acfc0d2 100644 --- a/src/cpp/cpp_typecheck_type.cpp +++ b/src/cpp/cpp_typecheck_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "cpp_convert_type.h" #include "expr2cpp.h" +/*******************************************************************\ + +Function: cpp_typecheckt::typecheck_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::typecheck_type(typet &type) { assert(type.id()!=irep_idt()); diff --git a/src/cpp/cpp_typecheck_using.cpp b/src/cpp/cpp_typecheck_using.cpp index 8a67e6a4092..9ad812ca8ec 100644 --- a/src/cpp/cpp_typecheck_using.cpp +++ b/src/cpp/cpp_typecheck_using.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cpp_typecheckt::convert(cpp_usingt &cpp_using) { // there are two forms of using clauses: diff --git a/src/cpp/cpp_typecheck_virtual_table.cpp b/src/cpp/cpp_typecheck_virtual_table.cpp index 4e766297206..ec52b1270ae 100644 --- a/src/cpp/cpp_typecheck_virtual_table.cpp +++ b/src/cpp/cpp_typecheck_virtual_table.cpp @@ -6,14 +6,19 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include #include "cpp_typecheck.h" +/*******************************************************************\ + +Function: cpp_typecheckt::do_virtual_table + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + void cpp_typecheckt::do_virtual_table(const symbolt &symbol) { assert(symbol.type.id()==ID_struct); diff --git a/src/cpp/cpp_using.h b/src/cpp/cpp_using.h index 580edec7c81..fadc71accc4 100644 --- a/src/cpp/cpp_using.h +++ b/src/cpp/cpp_using.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_CPP_USING_H #define CPROVER_CPP_CPP_USING_H diff --git a/src/cpp/cpp_util.cpp b/src/cpp/cpp_util.cpp index f57fffb71cc..1a3c8dfd773 100644 --- a/src/cpp/cpp_util.cpp +++ b/src/cpp/cpp_util.cpp @@ -11,6 +11,18 @@ #include "cpp_util.h" +/*******************************************************************\ + +Function: cpp_symbol_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt cpp_symbol_expr(const symbolt &symbol) { exprt tmp(ID_symbol, symbol.type); diff --git a/src/cpp/cpp_util.h b/src/cpp/cpp_util.h index 16400514fcb..17351354c1d 100644 --- a/src/cpp/cpp_util.h +++ b/src/cpp/cpp_util.h @@ -12,8 +12,32 @@ #include #include +/*******************************************************************\ + +Function: cpp_symbol_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt cpp_symbol_expr(const symbolt &symbol); +/*******************************************************************\ + +Function: already_typechecked + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline void already_typechecked(irept &irep) { exprt tmp("already_typechecked"); diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index d0036b58927..715809ca3c1 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -47,6 +47,18 @@ class expr2cppt:public expr2ct typedef std::unordered_set id_sett; }; +/*******************************************************************\ + +Function: expr2cppt::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_struct( const exprt &src, unsigned &precedence) @@ -111,6 +123,18 @@ std::string expr2cppt::convert_struct( return dest; } +/*******************************************************************\ + +Function: expr2cppt::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -127,6 +151,18 @@ std::string expr2cppt::convert_constant( return expr2ct::convert_constant(src, precedence); } +/*******************************************************************\ + +Function: expr2cppt::convert_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -385,6 +421,18 @@ std::string expr2cppt::convert_rec( return expr2ct::convert_rec(src, qualifiers, declarator); } +/*******************************************************************\ + +Function: expr2cppt::convert_cpp_this + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_cpp_this( const exprt &src, unsigned precedence) @@ -392,6 +440,18 @@ std::string expr2cppt::convert_cpp_this( return "this"; } +/*******************************************************************\ + +Function: expr2cppt::convert_cpp_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_cpp_new( const exprt &src, unsigned precedence) @@ -417,6 +477,18 @@ std::string expr2cppt::convert_cpp_new( return dest; } +/*******************************************************************\ + +Function: expr2cppt::convert_code_cpp_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_code_cpp_delete( const exprt &src, unsigned indent) @@ -436,6 +508,18 @@ std::string expr2cppt::convert_code_cpp_delete( return dest; } +/*******************************************************************\ + +Function: expr2cppt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -467,6 +551,18 @@ std::string expr2cppt::convert_with_precedence( return expr2ct::convert_with_precedence(src, precedence); } +/*******************************************************************\ + +Function: expr2cppt::convert_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_code( const codet &src, unsigned indent) @@ -484,6 +580,18 @@ std::string expr2cppt::convert_code( return expr2ct::convert_code(src, indent); } +/*******************************************************************\ + +Function: expr2cppt::convert_extractbit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_extractbit( const exprt &src, unsigned precedence) @@ -492,6 +600,18 @@ std::string expr2cppt::convert_extractbit( return convert(src.op0())+"["+convert(src.op1())+"]"; } +/*******************************************************************\ + +Function: expr2cppt::convert_extractbits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cppt::convert_extractbits( const exprt &src, unsigned precedence) @@ -502,6 +622,18 @@ std::string expr2cppt::convert_extractbits( convert(src.op2())+")"; } +/*******************************************************************\ + +Function: expr2cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2cpp(const exprt &expr, const namespacet &ns) { expr2cppt expr2cpp(ns); @@ -509,6 +641,18 @@ std::string expr2cpp(const exprt &expr, const namespacet &ns) return expr2cpp.convert(expr); } +/*******************************************************************\ + +Function: type2cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2cpp(const typet &type, const namespacet &ns) { expr2cppt expr2cpp(ns); diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index 54795864447..536c54f5169 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Parsing - #include #include @@ -180,6 +177,18 @@ class save_scopet new_scopet *old_scope; }; +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void new_scopet::print_rec(std::ostream &out, unsigned indent) const { for(id_mapt::const_iterator @@ -415,6 +424,18 @@ class Parser // NOLINT(readability/identifiers) unsigned int max_errors; }; +/*******************************************************************\ + +Function: Parser::add_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + new_scopet &Parser::add_id(const irept &cpp_name, new_scopet::kindt kind) { irep_idt id; @@ -428,6 +449,18 @@ new_scopet &Parser::add_id(const irept &cpp_name, new_scopet::kindt kind) return add_id(id, kind); } +/*******************************************************************\ + +Function: Parser::add_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + new_scopet &Parser::add_id(const irep_idt &id, new_scopet::kindt kind) { new_scopet &s=current_scope->id_map[id]; @@ -439,18 +472,54 @@ new_scopet &Parser::add_id(const irep_idt &id, new_scopet::kindt kind) return s; } +/*******************************************************************\ + +Function: Parser::make_sub_scope + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void Parser::make_sub_scope(const irept &cpp_name, new_scopet::kindt kind) { new_scopet &s=add_id(cpp_name, kind); current_scope=&s; } +/*******************************************************************\ + +Function: Parser::make_sub_scope + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void Parser::make_sub_scope(const irep_idt &id, new_scopet::kindt kind) { new_scopet &s=add_id(id, kind); current_scope=&s; } +/*******************************************************************\ + +Function: Parser::rString + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rString(cpp_tokent &tk) { if(lex.get_token(tk)!=TOK_STRING) @@ -459,6 +528,18 @@ bool Parser::rString(cpp_tokent &tk) return true; } +/*******************************************************************\ + +Function: Parser::merge_types + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void Parser::merge_types(const typet &src, typet &dest) { if(src.is_nil()) @@ -479,6 +560,18 @@ void Parser::merge_types(const typet &src, typet &dest) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::SyntaxError() { #define ERROR_TOKENS 4 @@ -513,6 +606,18 @@ bool Parser::SyntaxError() return ++number_of_errors < max_errors; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rProgram(cpp_itemt &item) { while(lex.LookAhead(0)!='\0') @@ -532,6 +637,18 @@ bool Parser::rProgram(cpp_itemt &item) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* definition : null.declaration @@ -579,6 +696,18 @@ bool Parser::rDefinition(cpp_itemt &item) return rDeclaration(item.make_declaration()); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rNullDeclaration(cpp_declarationt &decl) { cpp_tokent tk; @@ -591,6 +720,18 @@ bool Parser::rNullDeclaration(cpp_declarationt &decl) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* typedef : TYPEDEF type.specifier declarators ';' @@ -620,6 +761,18 @@ bool Parser::rTypedef(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* USING Identifier '=' type.specifier ';' */ @@ -672,6 +825,18 @@ bool Parser::rTypedefUsing(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rTypedefStatement(codet &statement) { statement=codet(ID_decl); @@ -679,6 +844,18 @@ bool Parser::rTypedefStatement(codet &statement) return rTypedef((cpp_declarationt &)statement.op0()); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* type.specifier : {cv.qualify} (integral.or.class.spec | name) {cv.qualify} @@ -741,6 +918,18 @@ bool Parser::rTypeSpecifier(typet &tspec, bool check) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // isTypeSpecifier() returns true if the next is probably a type specifier. bool Parser::isTypeSpecifier() @@ -770,6 +959,18 @@ bool Parser::isTypeSpecifier() return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* linkage.spec : EXTERN String definition @@ -808,6 +1009,18 @@ bool Parser::rLinkageSpec(cpp_linkage_spect &linkage_spec) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* namespace.spec : { INLINE } NAMESPACE Identifier definition @@ -861,6 +1074,18 @@ bool Parser::rNamespaceSpec(cpp_namespace_spect &namespace_spec) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* using.declaration : USING { NAMESPACE } name ';' */ @@ -889,6 +1114,18 @@ bool Parser::rUsing(cpp_usingt &cpp_using) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* static_assert.declaration : STATIC_ASSERT ( expression , expression ) ';' */ @@ -923,6 +1160,18 @@ bool Parser::rStaticAssert(cpp_static_assertt &cpp_static_assert) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* linkage.body : '{' (definition)* '}' @@ -958,6 +1207,18 @@ bool Parser::rLinkageBody(cpp_linkage_spect::itemst &items) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* template.decl : TEMPLATE '<' temp.arg.list '>' declaration @@ -1031,6 +1292,18 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) { cpp_tokent tk; @@ -1085,6 +1358,18 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* temp.arg.list : empty @@ -1117,6 +1402,18 @@ bool Parser::rTempArgList(irept &args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* temp.arg.declaration : CLASS [Identifier] {'=' type.name} @@ -1308,6 +1605,18 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* extern.template.decl : EXTERN TEMPLATE declaration @@ -1331,6 +1640,18 @@ bool Parser::rExternTemplateDecl(irept &decl) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* declaration : integral.declaration @@ -1447,6 +1768,18 @@ bool Parser::rDeclaration(cpp_declarationt &declaration) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* single declaration, for use in a condition (controlling expression of switch/while/if) */ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) @@ -1507,6 +1840,18 @@ bool Parser::rSimpleDeclaration(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rIntegralDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -1620,6 +1965,18 @@ bool Parser::rIntegralDeclaration( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rConstDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -1645,6 +2002,18 @@ bool Parser::rConstDeclaration( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rOtherDeclaration( cpp_declarationt &declaration, cpp_storage_spect &storage_spec, @@ -1822,6 +2191,18 @@ bool Parser::rOtherDeclaration( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* This returns true for an declaration like: T (a); @@ -1861,6 +2242,18 @@ bool Parser::isConstructorDecl() } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* ptr.to.member : {'::'} (identifier {'<' any* '>'} '::')+ '*' @@ -1918,6 +2311,18 @@ bool Parser::isPtrToMember(int i) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* member.spec : (FRIEND | INLINE | VIRTUAL | EXPLICIT)+ @@ -1948,6 +2353,18 @@ bool Parser::optMemberSpec(cpp_member_spect &member_spec) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* storage.spec : STATIC | EXTERN | AUTO | REGISTER | MUTABLE | ASM | THREAD_LOCAL @@ -1985,6 +2402,18 @@ bool Parser::optStorageSpec(cpp_storage_spect &storage_spec) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* cv.qualify : (CONSTEXPR | CONST | VOLATILE | RESTRICT)+ */ @@ -2057,6 +2486,18 @@ bool Parser::optCvQualify(typet &cv) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* dcl.align : ALIGNAS unary.expr @@ -2100,6 +2541,18 @@ bool Parser::optAlignas(typet &cv) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rAttribute() { cpp_tokent tk; @@ -2124,6 +2577,18 @@ bool Parser::rAttribute() return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::optAttribute(cpp_declarationt &declaration) { if(lex.LookAhead(0)!='[' || @@ -2156,6 +2621,18 @@ bool Parser::optAttribute(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* integral.or.class.spec @@ -2383,6 +2860,18 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* constructor.decl : '(' {arg.decl.list} ')' {cv.qualify} {throw.decl} @@ -2501,6 +2990,18 @@ bool Parser::rConstructorDecl( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* throw.decl : THROW '(' (name {','})* {name} ')' | THROW '(' '...' ')' @@ -2569,6 +3070,18 @@ bool Parser::optThrowDecl(irept &throw_decl) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* declarators : declarator.with.init (',' declarator.with.init)* @@ -2596,6 +3109,18 @@ bool Parser::rDeclarators( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* declarator.with.init : ':' expression @@ -2710,6 +3235,18 @@ bool Parser::rDeclaratorWithInit( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* __stdcall, __fastcall, __clrcall, __cdecl These are Visual-Studio specific. @@ -2732,6 +3269,18 @@ bool Parser::rDeclaratorQualifier() return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* declarator : (ptr.operator)* (name | '(' declarator ')') @@ -2989,6 +3538,18 @@ bool Parser::rDeclarator( return true; } +/*******************************************************************\ + +Function: Parser::optPtrOperator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* ptr.operator : (('*' | ptr.to.member)['&'] {cv.qualify})+ @@ -3114,6 +3675,18 @@ bool Parser::optPtrOperator(typet &ptrs) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* member.initializers : ':' member.init (',' member.init)* @@ -3146,6 +3719,18 @@ bool Parser::rMemberInitializers(irept &init) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* member.init : name '(' function.arguments ')' @@ -3222,6 +3807,18 @@ bool Parser::rMemberInit(exprt &init) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* name : {'::'} name2 ('::' name2)* @@ -3365,6 +3962,18 @@ bool Parser::rName(irept &name) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* operator.name : '+' | '-' | '*' | '/' | '%' | '^' | '&' | '|' | '~' @@ -3475,6 +4084,18 @@ bool Parser::rOperatorName(irept &name) return true; } +/*******************************************************************\ + +Function: Parser::rCastOperatorName + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* cast.operator.name : {cv.qualify} (integral.or.class.spec | name) {cv.qualify} @@ -3517,6 +4138,18 @@ bool Parser::rCastOperatorName(irept &name) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* ptr.to.member : {'::'} (identifier {template.args} '::')+ '*' @@ -3611,6 +4244,18 @@ bool Parser::rPtrToMember(irept &ptr_to_mem) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* template.args : '<' '>' @@ -3754,6 +4399,18 @@ bool Parser::rTemplateArgs(irept &template_args) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* arg.decl.list.or.init : arg.decl.list @@ -3800,6 +4457,18 @@ bool Parser::rArgDeclListOrInit( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* arg.decl.list : empty @@ -3853,6 +4522,18 @@ bool Parser::rArgDeclList(irept &arglist) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* arg.declaration : {userdef.keyword | REGISTER} type.specifier arg.declarator @@ -3896,6 +4577,18 @@ bool Parser::rArgDeclaration(cpp_declarationt &declaration) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* initialize.expr : expression @@ -3983,6 +4676,18 @@ bool Parser::rInitializeExpr(exprt &expr) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* function.arguments : empty @@ -4023,6 +4728,18 @@ bool Parser::rFunctionArguments(exprt &args) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* enum.spec : ENUM Identifier @@ -4110,6 +4827,18 @@ bool Parser::rEnumSpec(typet &spec) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* enum.body : Identifier {'=' expression} (',' Identifier {'=' expression})* {','} @@ -4161,6 +4890,18 @@ bool Parser::rEnumBody(irept &body) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* class.spec : {userdef.keyword} class.key class.body @@ -4269,6 +5010,18 @@ bool Parser::rClassSpec(typet &spec) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* base.specifiers : ':' base.specifier (',' base.specifier)* @@ -4344,6 +5097,18 @@ bool Parser::rBaseSpecifiers(irept &bases) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* class.body : '{' (class.members)* '}' */ @@ -4391,6 +5156,18 @@ bool Parser::rClassBody(exprt &body) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* class.member : (PUBLIC | PROTECTED | PRIVATE) ':' @@ -4471,6 +5248,18 @@ bool Parser::rClassMember(cpp_itemt &member) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* access.decl : name ';' e.g. ::; @@ -4491,6 +5280,18 @@ bool Parser::rAccessDecl(irept &mem) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* comma.expression : expression @@ -4535,6 +5336,18 @@ bool Parser::rCommaExpression(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* expression : conditional.expr {(AssignOp | '=') expression} right-to-left @@ -4616,6 +5429,18 @@ bool Parser::rExpression(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* conditional.expr : logical.or.expr {'?' comma.expression ':' conditional.expr} right-to-left @@ -4664,6 +5489,18 @@ bool Parser::rConditionalExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* logical.or.expr : logical.and.expr @@ -4703,6 +5540,18 @@ bool Parser::rLogicalOrExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* logical.and.expr : inclusive.or.expr @@ -4742,6 +5591,18 @@ bool Parser::rLogicalAndExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* inclusive.or.expr : exclusive.or.expr @@ -4781,6 +5642,18 @@ bool Parser::rInclusiveOrExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* exclusive.or.expr : and.expr @@ -4820,6 +5693,18 @@ bool Parser::rExclusiveOrExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* and.expr : equality.expr @@ -4859,6 +5744,18 @@ bool Parser::rAndExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* equality.expr : relational.expr @@ -4899,6 +5796,18 @@ bool Parser::rEqualityExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* relational.expr : shift.expr @@ -4951,6 +5860,18 @@ bool Parser::rRelationalExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* shift.expr : additive.expr @@ -4991,6 +5912,18 @@ bool Parser::rShiftExpr(exprt &exp, bool template_args) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* additive.expr : multiply.expr @@ -5038,6 +5971,18 @@ bool Parser::rAdditiveExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* multiply.expr : pm.expr @@ -5090,6 +6035,18 @@ bool Parser::rMultiplyExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* pm.expr (pointer to member .*, ->*) : cast.expr @@ -5135,6 +6092,18 @@ bool Parser::rPmExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* cast.expr : unary.expr @@ -5196,6 +6165,18 @@ bool Parser::rCastExpr(exprt &exp) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* type.name : type.specifier cast.declarator @@ -5233,6 +6214,18 @@ bool Parser::rTypeName(typet &tname) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* type.name | type.specifier { '(' type.specifier ( ',' type.specifier )* @@ -5410,6 +6403,18 @@ bool Parser::rTypeNameOrFunctionType(typet &tname) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* unary.expr : postfix.expr @@ -5523,6 +6528,18 @@ bool Parser::rUnaryExpr(exprt &exp) return rPostfixExpr(exp); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* throw.expression : THROW {expression} @@ -5561,6 +6578,18 @@ bool Parser::rThrowExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* typeid.expr : TYPEID '(' expression ')' @@ -5625,6 +6654,18 @@ bool Parser::rTypeidExpr(exprt &exp) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* sizeof.expr : SIZEOF unary.expr @@ -5699,6 +6740,18 @@ bool Parser::rSizeofExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* alignof.expr | ALIGNOF '(' type.name ')' @@ -5728,6 +6781,18 @@ bool Parser::rAlignofExpr(exprt &exp) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* noexcept.expr : NOEXCEPT '(' expression ')' @@ -5777,6 +6842,18 @@ bool Parser::isAllocateExpr(int t) return t==TOK_NEW || t==TOK_DELETE; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* allocate.expr : {Scope | userdef.keyword} NEW allocate.type @@ -5865,6 +6942,18 @@ bool Parser::rAllocateExpr(exprt &exp) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* allocate.type : {'(' function.arguments ')'} type.specifier new.declarator @@ -5962,6 +7051,18 @@ bool Parser::rAllocateType( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* new.declarator : empty @@ -5997,6 +7098,18 @@ bool Parser::rNewDeclarator(typet &decl) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* allocate.initializer : '(' {initialize.expr (',' initialize.expr)* } ')' @@ -6042,6 +7155,18 @@ bool Parser::rAllocateInitializer(exprt &init) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* postfix.exp : primary.exp @@ -6193,6 +7318,18 @@ bool Parser::rPostfixExpr(exprt &exp) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* __uuidof( expression ) __uuidof( type ) @@ -6243,6 +7380,18 @@ bool Parser::rMSCuuidof(exprt &expr) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* __if_exists ( identifier ) { token stream } __if_not_exists ( identifier ) { token stream } @@ -6293,6 +7442,18 @@ bool Parser::rMSC_if_existsExpr(exprt &expr) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rMSC_if_existsStatement(codet &code) { cpp_tokent tk1; @@ -6345,6 +7506,18 @@ bool Parser::rMSC_if_existsStatement(codet &code) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* __is_base_of ( base, derived ) __is_convertible_to ( from, to ) @@ -6397,6 +7570,18 @@ bool Parser::rTypePredicate(exprt &expr) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* primary.exp : Constant @@ -6637,6 +7822,18 @@ bool Parser::rPrimaryExpr(exprt &exp) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* var.name : {'::'} name2 ('::' name2)* @@ -6660,6 +7857,18 @@ bool Parser::rVarName(exprt &name) return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rVarNameCore(exprt &name) { #ifdef DEBUG @@ -6793,6 +8002,18 @@ bool Parser::rVarNameCore(exprt &name) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::moreVarName() { if(lex.LookAhead(0)==TOK_SCOPE) @@ -6805,6 +8026,18 @@ bool Parser::moreVarName() return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* template.args : '<' any* '>' @@ -6906,6 +8139,18 @@ bool Parser::maybeTemplateArgs() return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* function.body : compound.statement | { asm } @@ -6955,6 +8200,18 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* compound.statement : '{' (statement)* '}' @@ -7001,6 +8258,18 @@ bool Parser::rCompoundStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* statement : compound.statement @@ -7280,6 +8549,18 @@ bool Parser::rStatement(codet &statement) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* if.statement : IF '(' comma.expression ')' statement { ELSE statement } @@ -7328,6 +8609,18 @@ bool Parser::rIfStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* switch.statement : SWITCH '(' comma.expression ')' statement @@ -7361,6 +8654,18 @@ bool Parser::rSwitchStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* while.statement : WHILE '(' comma.expression ')' statement @@ -7394,6 +8699,18 @@ bool Parser::rWhileStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* do.statement : DO statement WHILE '(' comma.expression ')' ';' @@ -7433,6 +8750,18 @@ bool Parser::rDoStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* for.statement : FOR '(' expr.statement {comma.expression} ';' {comma.expression} ')' @@ -7494,6 +8823,18 @@ bool Parser::rForStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* try.statement : TRY compound.statement (exception.handler)+ ';' @@ -7588,6 +8929,18 @@ bool Parser::rTryStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rMSC_tryStatement(codet &statement) { // These are for 'structured exception handling', @@ -7643,6 +8996,18 @@ bool Parser::rMSC_tryStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rMSC_leaveStatement(codet &statement) { // These are for 'structured exception handling', @@ -7659,6 +9024,18 @@ bool Parser::rMSC_leaveStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rGCCAsmStatement(codet &statement) { cpp_tokent tk; @@ -7760,6 +9137,18 @@ bool Parser::rGCCAsmStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rMSCAsmStatement(codet &statement) { cpp_tokent tk; @@ -7828,6 +9217,18 @@ bool Parser::rMSCAsmStatement(codet &statement) return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* expr.statement : ';' @@ -7909,6 +9310,18 @@ bool Parser::rExprStatement(codet &statement) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::rCondition(exprt &statement) { cpp_token_buffert::post pos=lex.Save(); @@ -7934,6 +9347,18 @@ bool Parser::rCondition(exprt &statement) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* declaration.statement : decl.head integral.or.class.spec {cv.qualify} {declarators} ';' @@ -8012,6 +9437,18 @@ bool Parser::rDeclarationStatement(codet &statement) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* integral.decl.statement : decl.head integral.or.class.spec {cv.qualify} {declarators} ';' @@ -8057,6 +9494,18 @@ bool Parser::rIntegralDeclStatement( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* other.decl.statement :decl.head name {cv.qualify} declarators ';' @@ -8111,11 +9560,35 @@ bool Parser::rOtherDeclStatement( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::MaybeTypeNameOrClassTemplate(cpp_tokent &) { return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void Parser::SkipTo(int token) { cpp_tokent tk; @@ -8130,6 +9603,18 @@ void Parser::SkipTo(int token) } } +/*******************************************************************\ + +Function: Parser::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool Parser::operator()() { number_of_errors=0; @@ -8150,6 +9635,18 @@ bool Parser::operator()() return number_of_errors!=0; } +/*******************************************************************\ + +Function: cpp_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cpp_parse() { Parser parser(cpp_parser); diff --git a/src/cpp/recursion_counter.h b/src/cpp/recursion_counter.h index 82ec1a77bbc..fab87c254f7 100644 --- a/src/cpp/recursion_counter.h +++ b/src/cpp/recursion_counter.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_RECURSION_COUNTER_H #define CPROVER_CPP_RECURSION_COUNTER_H diff --git a/src/cpp/template_map.cpp b/src/cpp/template_map.cpp index 83d5794ff97..62d5b026207 100644 --- a/src/cpp/template_map.cpp +++ b/src/cpp/template_map.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #include #include "template_map.h" +/*******************************************************************\ + +Function: template_mapt::apply + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::apply(typet &type) const { if(type.id()==ID_array) @@ -65,6 +74,18 @@ void template_mapt::apply(typet &type) const } } +/*******************************************************************\ + +Function: template_mapt::apply + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::apply(exprt &expr) const { apply(expr.type()); @@ -85,6 +106,18 @@ void template_mapt::apply(exprt &expr) const apply(*it); } +/*******************************************************************\ + +Function: template_mapt::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt template_mapt::lookup(const irep_idt &identifier) const { type_mapt::const_iterator t_it= @@ -106,6 +139,18 @@ exprt template_mapt::lookup(const irep_idt &identifier) const return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: template_mapt::lookup_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet template_mapt::lookup_type(const irep_idt &identifier) const { type_mapt::const_iterator t_it= @@ -117,6 +162,18 @@ typet template_mapt::lookup_type(const irep_idt &identifier) const return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: template_mapt::lookup_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt template_mapt::lookup_expr(const irep_idt &identifier) const { expr_mapt::const_iterator e_it= @@ -128,6 +185,18 @@ exprt template_mapt::lookup_expr(const irep_idt &identifier) const return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: template_mapt::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::print(std::ostream &out) const { for(type_mapt::const_iterator it=type_map.begin(); @@ -141,6 +210,18 @@ void template_mapt::print(std::ostream &out) const out << it->first << " = " << it->second.pretty() << std::endl; } +/*******************************************************************\ + +Function: template_mapt::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::build( const template_typet &template_type, const cpp_template_args_tct &template_args) @@ -183,6 +264,18 @@ void template_mapt::build( } } +/*******************************************************************\ + +Function: template_mapt::set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::set( const template_parametert ¶meter, const exprt &value) @@ -209,6 +302,18 @@ void template_mapt::set( } } +/*******************************************************************\ + +Function: template_mapt::build_unassigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void template_mapt::build_unassigned( const template_typet &template_type) { @@ -239,6 +344,18 @@ void template_mapt::build_unassigned( } } +/*******************************************************************\ + +Function: template_mapt::build_template_args + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cpp_template_args_tct template_mapt::build_template_args( const template_typet &template_type) const { diff --git a/src/cpp/template_map.h b/src/cpp/template_map.h index 74531f3aaa9..c1347eca059 100644 --- a/src/cpp/template_map.h +++ b/src/cpp/template_map.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@cs.cmu.edu \*******************************************************************/ -/// \file -/// C++ Language Type Checking - #ifndef CPROVER_CPP_TEMPLATE_MAP_H #define CPROVER_CPP_TEMPLATE_MAP_H diff --git a/src/doxyfile b/src/doxygen.cfg similarity index 82% rename from src/doxyfile rename to src/doxygen.cfg index 611614a3a9b..b46c3b28f01 100644 --- a/src/doxyfile +++ b/src/doxygen.cfg @@ -14,211 +14,211 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = cprover -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = ../doc -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # and Ukrainian. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member +# If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = YES -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES @@ -228,42 +228,42 @@ BUILTIN_STL_SUPPORT = YES CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO @@ -272,368 +272,368 @@ TYPEDEF_HIDES_STRUCT = NO # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = YES +EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_MEMBERS = YES -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. -HIDE_UNDOC_CLASSES = NO +HIDE_UNDOC_CLASSES = YES -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. -QUIET = YES +QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = . +INPUT = util goto-programs pointer-analysis solvers -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.cpp *.h -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = solvers/z3/ -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = */.svn/* */.git/* +EXCLUDE_PATTERNS = */.svn/* -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO @@ -642,32 +642,32 @@ FILTER_SOURCE_FILES = NO # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES @@ -679,16 +679,16 @@ REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -697,129 +697,129 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO @@ -828,26 +828,26 @@ GENERATE_CHI = NO # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) +# This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 @@ -855,11 +855,11 @@ ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. Other possible values +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hiererachy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which @@ -869,16 +869,16 @@ ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NONE -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 @@ -887,74 +887,74 @@ FORMULA_FONTSIZE = 10 # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO @@ -963,68 +963,68 @@ LATEX_HIDE_INDICES = NO # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -1033,33 +1033,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -1068,10 +1068,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -1080,338 +1080,338 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen +# If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is enabled by default, which results in a transparent -# background. Warning: Depending on the platform used, enabling this option -# may lead to badly anti-aliased labels on the edges of a graph (i.e. they +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is enabled by default, which results in a transparent +# background. Warning: Depending on the platform used, enabling this option +# may lead to badly anti-aliased labels on the edges of a graph (i.e. they # become hard to read). DOT_TRANSPARENT = YES -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- -# The SEARCHENGINE tag specifies whether or not a search engine should be +# The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO diff --git a/src/goto-analyzer/goto_analyzer_main.cpp b/src/goto-analyzer/goto_analyzer_main.cpp index 64e14c74936..78baf16d6a1 100644 --- a/src/goto-analyzer/goto_analyzer_main.cpp +++ b/src/goto-analyzer/goto_analyzer_main.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto-Analyser Main Module - #include #include "goto_analyzer_parse_options.h" +/*******************************************************************\ + +Function: main / wmain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index d9498ea3c2a..c783243a0d3 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto-Analyser Command Line Option Processing - #include // exit() #include #include @@ -53,6 +50,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "unreachable_instructions.h" #include "static_analyzer.h" +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::goto_analyzer_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_analyzer_parse_optionst::goto_analyzer_parse_optionst( int argc, const char **argv): @@ -62,6 +71,18 @@ goto_analyzer_parse_optionst::goto_analyzer_parse_optionst( { } +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_analyzer_parse_optionst::register_languages() { register_language(new_ansi_c_language); @@ -70,6 +91,18 @@ void goto_analyzer_parse_optionst::register_languages() register_language(new_jsil_language); } +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_analyzer_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -85,6 +118,18 @@ void goto_analyzer_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::get_command_line_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_analyzer_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -132,7 +177,18 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options) #endif } -/// invoke main modules +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int goto_analyzer_parse_optionst::doit() { if(cmdline.isset("version")) @@ -306,6 +362,18 @@ int goto_analyzer_parse_optionst::doit() return 6; } +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_analyzer_parse_optionst::set_properties() { try @@ -334,6 +402,18 @@ bool goto_analyzer_parse_optionst::set_properties() return false; } +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::process_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_analyzer_parse_optionst::process_goto_program( const optionst &options) { @@ -421,7 +501,18 @@ bool goto_analyzer_parse_optionst::process_goto_program( return false; } -/// display command line help +/*******************************************************************\ + +Function: goto_analyzer_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void goto_analyzer_parse_optionst::help() { std::cout << diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 48b299049b9..538bf47ac3e 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto-Analyser Command Line Option Processing - #ifndef CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H #define CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H diff --git a/src/goto-analyzer/static_analyzer.cpp b/src/goto-analyzer/static_analyzer.cpp index ed576253247..1168cff1a73 100644 --- a/src/goto-analyzer/static_analyzer.cpp +++ b/src/goto-analyzer/static_analyzer.cpp @@ -47,6 +47,18 @@ class static_analyzert:public messaget tvt eval(goto_programt::const_targett); }; +/*******************************************************************\ + +Function: static_analyzert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool static_analyzert::operator()() { status() << "performing interval analysis" << eom; @@ -62,6 +74,18 @@ bool static_analyzert::operator()() return false; } +/*******************************************************************\ + +Function: static_analyzert::eval + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt static_analyzert::eval(goto_programt::const_targett t) { exprt guard=t->guard; @@ -72,6 +96,18 @@ tvt static_analyzert::eval(goto_programt::const_targett t) return tvt::unknown(); } +/*******************************************************************\ + +Function: static_analyzert::plain_text_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analyzert::plain_text_report() { unsigned pass=0, fail=0, unknown=0; @@ -123,6 +159,18 @@ void static_analyzert::plain_text_report() << unknown << " unknown\n"; } +/*******************************************************************\ + +Function: static_analyzert::json_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analyzert::json_report(const std::string &file_name) { json_arrayt json_result; @@ -170,6 +218,18 @@ void static_analyzert::json_report(const std::string &file_name) out << json_result; } +/*******************************************************************\ + +Function: static_analyzert::xml_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void static_analyzert::xml_report(const std::string &file_name) { xmlt xml_result; @@ -217,6 +277,18 @@ void static_analyzert::xml_report(const std::string &file_name) out << xml_result; } +/*******************************************************************\ + +Function: static_analyzer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool static_analyzer( const goto_modelt &goto_model, const optionst &options, @@ -226,6 +298,18 @@ bool static_analyzer( goto_model, options, message_handler)(); } +/*******************************************************************\ + +Function: show_intervals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_intervals( const goto_modelt &goto_model, std::ostream &out) diff --git a/src/goto-analyzer/taint_analysis.cpp b/src/goto-analyzer/taint_analysis.cpp index 7e59ac5c399..f3caa711607 100644 --- a/src/goto-analyzer/taint_analysis.cpp +++ b/src/goto-analyzer/taint_analysis.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Taint Analysis - #include #include @@ -25,6 +22,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "taint_analysis.h" #include "taint_parser.h" +/*******************************************************************\ + + Class: taint_analysist + + Purpose: + +\*******************************************************************/ + class taint_analysist:public messaget { public: @@ -47,6 +52,18 @@ class taint_analysist:public messaget void instrument(const namespacet &, goto_functionst::goto_functiont &); }; +/*******************************************************************\ + +Function: taint_analysist::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void taint_analysist::instrument( const namespacet &ns, goto_functionst &goto_functions) @@ -55,6 +72,18 @@ void taint_analysist::instrument( instrument(ns, function.second); } +/*******************************************************************\ + +Function: taint_analysist::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void taint_analysist::instrument( const namespacet &ns, goto_functionst::goto_functiont &goto_function) @@ -216,6 +245,18 @@ void taint_analysist::instrument( } } +/*******************************************************************\ + +Function: taint_analysist::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool taint_analysist::operator()( const std::string &taint_file_name, const symbol_tablet &symbol_table, @@ -403,6 +444,18 @@ bool taint_analysist::operator()( } } +/*******************************************************************\ + +Function: taint_analysis + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool taint_analysis( goto_modelt &goto_model, const std::string &taint_file_name, diff --git a/src/goto-analyzer/taint_analysis.h b/src/goto-analyzer/taint_analysis.h index f9b73d2640e..a47a974b009 100644 --- a/src/goto-analyzer/taint_analysis.h +++ b/src/goto-analyzer/taint_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Taint Analysis - #ifndef CPROVER_GOTO_ANALYZER_TAINT_ANALYSIS_H #define CPROVER_GOTO_ANALYZER_TAINT_ANALYSIS_H diff --git a/src/goto-analyzer/taint_parser.cpp b/src/goto-analyzer/taint_parser.cpp index 234a8e53c3b..e60fb2ded54 100644 --- a/src/goto-analyzer/taint_parser.cpp +++ b/src/goto-analyzer/taint_parser.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Taint Parser - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "taint_parser.h" +/*******************************************************************\ + +Function: taint_parser + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool taint_parser( const std::string &file_name, taint_parse_treet &dest, @@ -122,6 +131,18 @@ bool taint_parser( return false; } +/*******************************************************************\ + +Function: taint_parse_treet::rulet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void taint_parse_treet::rulet::output(std::ostream &out) const { if(!id.empty()) @@ -147,6 +168,18 @@ void taint_parse_treet::rulet::output(std::ostream &out) const out << '\n'; } +/*******************************************************************\ + +Function: taint_parse_treet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void taint_parse_treet::output(std::ostream &out) const { for(const auto &rule : rules) diff --git a/src/goto-analyzer/taint_parser.h b/src/goto-analyzer/taint_parser.h index 79746041265..bc02e66c1ce 100644 --- a/src/goto-analyzer/taint_parser.h +++ b/src/goto-analyzer/taint_parser.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Taint Parser - #ifndef CPROVER_GOTO_ANALYZER_TAINT_PARSER_H #define CPROVER_GOTO_ANALYZER_TAINT_PARSER_H diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 78e03822945..73514f5b5d5 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// List all unreachable instructions - #include #include @@ -26,6 +23,18 @@ Date: April 2016 typedef std::map dead_mapt; +/*******************************************************************\ + +Function: unreachable_instructions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void unreachable_instructions( const goto_programt &goto_program, dead_mapt &dest) @@ -45,6 +54,18 @@ static void unreachable_instructions( } } +/*******************************************************************\ + +Function: all_unreachable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void all_unreachable( const goto_programt &goto_program, dead_mapt &dest) @@ -54,6 +75,18 @@ static void all_unreachable( dest.insert(std::make_pair(it->location_number, it)); } +/*******************************************************************\ + +Function: output_dead_plain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void output_dead_plain( const namespacet &ns, const goto_programt &goto_program, @@ -74,6 +107,18 @@ static void output_dead_plain( goto_program.output_instruction(ns, "", os, it->second); } +/*******************************************************************\ + +Function: add_to_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void add_to_json( const namespacet &ns, const goto_programt &goto_program, @@ -121,6 +166,18 @@ static void add_to_json( } } +/*******************************************************************\ + +Function: unreachable_instructions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unreachable_instructions( const goto_modelt &goto_model, const bool json, @@ -164,6 +221,18 @@ void unreachable_instructions( os << json_result << std::endl; } +/*******************************************************************\ + +Function: json_output_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void json_output_function( const irep_idt &function, const source_locationt &first_location, @@ -183,6 +252,18 @@ static void json_output_function( json_numbert(id2string(last_location.get_line())); } +/*******************************************************************\ + +Function: list_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void list_functions( const goto_modelt &goto_model, const bool json, @@ -247,6 +328,18 @@ static void list_functions( os << json_result << std::endl; } +/*******************************************************************\ + +Function: unreachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unreachable_functions( const goto_modelt &goto_model, const bool json, @@ -255,6 +348,18 @@ void unreachable_functions( list_functions(goto_model, json, os, true); } +/*******************************************************************\ + +Function: reachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reachable_functions( const goto_modelt &goto_model, const bool json, diff --git a/src/goto-analyzer/unreachable_instructions.h b/src/goto-analyzer/unreachable_instructions.h index 9b71e4f66f5..a408e004bd8 100644 --- a/src/goto-analyzer/unreachable_instructions.h +++ b/src/goto-analyzer/unreachable_instructions.h @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// List all unreachable instructions - #ifndef CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H #define CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H diff --git a/src/goto-cc/armcc_cmdline.cpp b/src/goto-cc/armcc_cmdline.cpp index f937f2a1e25..4b58f765f17 100644 --- a/src/goto-cc/armcc_cmdline.cpp +++ b/src/goto-cc/armcc_cmdline.cpp @@ -6,17 +6,23 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// A special command line object to mimick ARM's armcc - #include #include #include "armcc_cmdline.h" -/// parses the commandline options into a cmdlinet -/// \par parameters: argument count, argument strings -/// \return none +/*******************************************************************\ + +Function: armcc_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + // see // http://infocenter.arm.com/help/topic/com.arm.doc.dui0472c/Cchbggjb.html diff --git a/src/goto-cc/armcc_cmdline.h b/src/goto-cc/armcc_cmdline.h index f8996366395..3cb108b1791 100644 --- a/src/goto-cc/armcc_cmdline.h +++ b/src/goto-cc/armcc_cmdline.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// A special command line object to mimick ARM's armcc - #ifndef CPROVER_GOTO_CC_ARMCC_CMDLINE_H #define CPROVER_GOTO_CC_ARMCC_CMDLINE_H diff --git a/src/goto-cc/armcc_mode.cpp b/src/goto-cc/armcc_mode.cpp index d8a6a015325..9eb677f631d 100644 --- a/src/goto-cc/armcc_mode.cpp +++ b/src/goto-cc/armcc_mode.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// Command line option container - #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -27,7 +24,18 @@ Author: CM Wintersteiger, 2006 #include "armcc_mode.h" #include "compile.h" -/// does it. +/*******************************************************************\ + +Function: armcc_modet::doit + + Inputs: + + Outputs: + + Purpose: does it. + +\*******************************************************************/ + int armcc_modet::doit() { if(cmdline.isset('?') || cmdline.isset("help")) @@ -189,7 +197,18 @@ int armcc_modet::doit() return compiler.doit() ? EX_USAGE : EX_OK; } -/// display command line help +/*******************************************************************\ + +Function: armcc_modet::help_mode + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void armcc_modet::help_mode() { std::cout << "goto-armcc understands the options " diff --git a/src/goto-cc/armcc_mode.h b/src/goto-cc/armcc_mode.h index d4b8c4779e9..cbbe90a2a1e 100644 --- a/src/goto-cc/armcc_mode.h +++ b/src/goto-cc/armcc_mode.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Base class for command line interpretation for CL - #ifndef CPROVER_GOTO_CC_ARMCC_MODE_H #define CPROVER_GOTO_CC_ARMCC_MODE_H diff --git a/src/goto-cc/as86_cmdline.cpp b/src/goto-cc/as86_cmdline.cpp index cd66ae60d9a..4d1210c2794 100644 --- a/src/goto-cc/as86_cmdline.cpp +++ b/src/goto-cc/as86_cmdline.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig \*******************************************************************/ -/// \file -/// A special command line object for as86 (of Bruce's C Compiler) - #include #include @@ -16,6 +13,18 @@ Author: Michael Tautschnig #include "as86_cmdline.h" +/*******************************************************************\ + +Function: as86_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + // non-as86 options const char *goto_as86_options_with_argument[]= { diff --git a/src/goto-cc/as86_cmdline.h b/src/goto-cc/as86_cmdline.h index ac03786d585..85f8d439cae 100644 --- a/src/goto-cc/as86_cmdline.h +++ b/src/goto-cc/as86_cmdline.h @@ -8,10 +8,6 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// A special command line object for as86 (of Bruce's C Compiler) Author: -/// Michael Tautschnig Date: July 2016 - #ifndef CPROVER_GOTO_CC_AS86_CMDLINE_H #define CPROVER_GOTO_CC_AS86_CMDLINE_H diff --git a/src/goto-cc/as_cmdline.cpp b/src/goto-cc/as_cmdline.cpp index 162f0d8d2aa..8a6f32c16b5 100644 --- a/src/goto-cc/as_cmdline.cpp +++ b/src/goto-cc/as_cmdline.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig \*******************************************************************/ -/// \file -/// A special command line object for GNU Assembler - #include #include @@ -16,6 +13,18 @@ Author: Michael Tautschnig #include "as_cmdline.h" +/*******************************************************************\ + +Function: as_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + // non-as options const char *goto_as_options_with_argument[]= { diff --git a/src/goto-cc/as_cmdline.h b/src/goto-cc/as_cmdline.h index fbf26957815..19dd7dc0be0 100644 --- a/src/goto-cc/as_cmdline.h +++ b/src/goto-cc/as_cmdline.h @@ -8,10 +8,6 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// A special command line object for GNU Assembler Author: Michael Tautschnig -/// Date: July 2016 - #ifndef CPROVER_GOTO_CC_AS_CMDLINE_H #define CPROVER_GOTO_CC_AS_CMDLINE_H diff --git a/src/goto-cc/as_mode.cpp b/src/goto-cc/as_mode.cpp index 3c62419a085..bb87b6c6abb 100644 --- a/src/goto-cc/as_mode.cpp +++ b/src/goto-cc/as_mode.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig \*******************************************************************/ -/// \file -/// Assembler Mode - #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -33,6 +30,18 @@ Author: Michael Tautschnig #include "as_mode.h" +/*******************************************************************\ + +Function: assembler_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string assembler_name( const cmdlinet &cmdline, const std::string &base_name) @@ -55,6 +64,18 @@ static std::string assembler_name( return result; } +/*******************************************************************\ + +Function: as_modet::as_modet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + as_modet::as_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -65,7 +86,18 @@ as_modet::as_modet( { } -/// does it. +/*******************************************************************\ + +Function: as_modet::doit + + Inputs: + + Outputs: + + Purpose: does it. + +\*******************************************************************/ + int as_modet::doit() { if(cmdline.isset('?') || @@ -252,7 +284,18 @@ int as_modet::doit() return EX_OK; } -/// run as or as86 with original command line +/*******************************************************************\ + +Function: as_modet::run_as + + Inputs: + + Outputs: + + Purpose: run as or as86 with original command line + +\*******************************************************************/ + int as_modet::run_as() { assert(!cmdline.parsed_argv.empty()); @@ -276,6 +319,18 @@ int as_modet::run_as() return run(new_argv[0], new_argv, cmdline.stdin_file, ""); } +/*******************************************************************\ + +Function: as_modet::as_hybrid_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int as_modet::as_hybrid_binary() { std::string output_file="a.out"; @@ -360,7 +415,18 @@ int as_modet::as_hybrid_binary() return result; } -/// display command line help +/*******************************************************************\ + +Function: as_modet::help_mode + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void as_modet::help_mode() { std::cout << "goto-as understands the options of as plus the following.\n\n"; diff --git a/src/goto-cc/as_mode.h b/src/goto-cc/as_mode.h index 46284da8153..04ad255a764 100644 --- a/src/goto-cc/as_mode.h +++ b/src/goto-cc/as_mode.h @@ -8,9 +8,6 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// Assembler Mode - #ifndef CPROVER_GOTO_CC_AS_MODE_H #define CPROVER_GOTO_CC_AS_MODE_H diff --git a/src/goto-cc/bcc_cmdline.cpp b/src/goto-cc/bcc_cmdline.cpp index 858923ee2f5..2ed56554270 100644 --- a/src/goto-cc/bcc_cmdline.cpp +++ b/src/goto-cc/bcc_cmdline.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig \*******************************************************************/ -/// \file -/// A special command line object for Bruce's C Compiler - #include #include @@ -16,6 +13,18 @@ Author: Michael Tautschnig #include "bcc_cmdline.h" +/*******************************************************************\ + +Function: bcc_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + // non-bcc options const char *goto_bcc_options_with_argument[]= { diff --git a/src/goto-cc/bcc_cmdline.h b/src/goto-cc/bcc_cmdline.h index 18c402bd892..578001925da 100644 --- a/src/goto-cc/bcc_cmdline.h +++ b/src/goto-cc/bcc_cmdline.h @@ -8,10 +8,6 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// A special command line object for Bruce's C Compiler Author: Michael -/// Tautschnig Date: July 2016 - #ifndef CPROVER_GOTO_CC_BCC_CMDLINE_H #define CPROVER_GOTO_CC_BCC_CMDLINE_H diff --git a/src/goto-cc/compile.cpp b/src/goto-cc/compile.cpp index dbebbcb8513..58f74669c32 100644 --- a/src/goto-cc/compile.cpp +++ b/src/goto-cc/compile.cpp @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Compile and link source and object files. - #include #include #include @@ -68,9 +65,19 @@ Date: June 2006 #define pclose _pclose #endif -/// reads and source and object files, compiles and links them into goto program -/// objects. -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::doit + + Inputs: none + + Outputs: true on error, false otherwise + + Purpose: reads and source and object files, compiles and links them + into goto program objects. + +\*******************************************************************/ + bool compilet::doit() { compiled_functions.clear(); @@ -129,8 +136,19 @@ bool compilet::doit() return false; } -/// puts input file names into a list and does preprocessing for libraries. -/// \return false on success, true on error. +/*******************************************************************\ + +Function: compilet::add_input_file + + Inputs: none + + Outputs: false on success, true on error. + + Purpose: puts input file names into a list and does preprocessing for + libraries. + +\*******************************************************************/ + bool compilet::add_input_file(const std::string &file_name) { // first of all, try to open the file @@ -270,9 +288,19 @@ bool compilet::add_input_file(const std::string &file_name) return false; } -/// tries to find a library object file that matches the given library name. -/// \par parameters: library name -/// \return true if found, false otherwise +/*******************************************************************\ + +Function: compilet::find_library + + Inputs: library name + + Outputs: true if found, false otherwise + + Purpose: tries to find a library object file that matches the given + library name. + +\*******************************************************************/ + bool compilet::find_library(const std::string &name) { std::string tmp; @@ -309,10 +337,19 @@ bool compilet::find_library(const std::string &name) return false; } -/// checking if we can load an object file -/// \par parameters: file name -/// \return true if the given file name exists and is an ELF file, false -/// otherwise +/*******************************************************************\ + +Function: compilet::is_elf_file + + Inputs: file name + + Outputs: true if the given file name exists and is an ELF file, + false otherwise + + Purpose: checking if we can load an object file + +\*******************************************************************/ + bool compilet::is_elf_file(const std::string &file_name) { std::fstream in; @@ -331,8 +368,18 @@ bool compilet::is_elf_file(const std::string &file_name) return false; } -/// parses object files and links them -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::link + + Inputs: none + + Outputs: true on error, false otherwise + + Purpose: parses object files and links them + +\*******************************************************************/ + bool compilet::link() { // "compile" hitherto uncompiled functions @@ -376,9 +423,19 @@ bool compilet::link() return false; } -/// parses source files and writes object files, or keeps the symbols in the -/// symbol_table depending on the doLink flag. -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::compile + + Inputs: none + + Outputs: true on error, false otherwise + + Purpose: parses source files and writes object files, or keeps the + symbols in the symbol_table depending on the doLink flag. + +\*******************************************************************/ + bool compilet::compile() { while(!source_files.empty()) @@ -432,8 +489,18 @@ bool compilet::compile() return false; } -/// parses a source file (low-level parsing) -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::parse + + Inputs: file_name + + Outputs: true on error, false otherwise + + Purpose: parses a source file (low-level parsing) + +\*******************************************************************/ + bool compilet::parse(const std::string &file_name) { if(file_name=="-") @@ -523,8 +590,18 @@ bool compilet::parse(const std::string &file_name) return false; } -/// parses a source file (low-level parsing) -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::parse_stdin + + Inputs: file_name + + Outputs: true on error, false otherwise + + Purpose: parses a source file (low-level parsing) + +\*******************************************************************/ + bool compilet::parse_stdin() { ansi_c_languaget language; @@ -566,10 +643,19 @@ bool compilet::parse_stdin() return false; } -/// writes the goto functions in the function table to a binary format object -/// file. -/// \par parameters: file_name, functions table -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::write_object_file + + Inputs: file_name, functions table + + Outputs: true on error, false otherwise + + Purpose: writes the goto functions in the function table to a + binary format object file. + +\*******************************************************************/ + bool compilet::write_object_file( const std::string &file_name, const symbol_tablet &lsymbol_table, @@ -578,10 +664,19 @@ bool compilet::write_object_file( return write_bin_object_file(file_name, lsymbol_table, functions); } -/// writes the goto functions in the function table to a binary format object -/// file. -/// \par parameters: file_name, functions table -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::write_bin_object_file + + Inputs: file_name, functions table + + Outputs: true on error, false otherwise + + Purpose: writes the goto functions in the function table to a + binary format object file. + +\*******************************************************************/ + bool compilet::write_bin_object_file( const std::string &file_name, const symbol_tablet &lsymbol_table, @@ -615,8 +710,18 @@ bool compilet::write_bin_object_file( return false; } -/// parses a source file -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: compilet::parse_source + + Inputs: file_name + + Outputs: true on error, false otherwise + + Purpose: parses a source file + +\*******************************************************************/ + bool compilet::parse_source(const std::string &file_name) { if(parse(file_name)) @@ -635,8 +740,18 @@ bool compilet::parse_source(const std::string &file_name) return false; } -/// constructor -/// \return nothing +/*******************************************************************\ + +Function: compilet::compilet + + Inputs: none + + Outputs: nothing + + Purpose: constructor + +\*******************************************************************/ + compilet::compilet(cmdlinet &_cmdline): language_uit(_cmdline, ui_message_handler), ui_message_handler(_cmdline, "goto-cc " CBMC_VERSION), @@ -648,8 +763,18 @@ compilet::compilet(cmdlinet &_cmdline): working_directory=get_current_working_directory(); } -/// cleans up temporary files -/// \return nothing +/*******************************************************************\ + +Function: compilet::~compilet + + Inputs: none + + Outputs: nothing + + Purpose: cleans up temporary files + +\*******************************************************************/ + compilet::~compilet() { // clean up temp dirs @@ -660,6 +785,18 @@ compilet::~compilet() delete_directory(*it); } +/*******************************************************************\ + +Function: compilet::function_body_count + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned compilet::function_body_count(const goto_functionst &functions) { int fbs=0; @@ -674,11 +811,35 @@ unsigned compilet::function_body_count(const goto_functionst &functions) return fbs; } +/*******************************************************************\ + +Function: compilet::add_compiler_specific_defines + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void compilet::add_compiler_specific_defines(configt &config) const { config.ansi_c.defines.push_back("__GOTO_CC_VERSION__=" CBMC_VERSION); } +/*******************************************************************\ + +Function: compilet::convert_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void compilet::convert_symbols(goto_functionst &dest) { goto_convert_functionst converter(symbol_table, dest, ui_message_handler); diff --git a/src/goto-cc/compile.h b/src/goto-cc/compile.h index b25c2f24c9d..936f4cd21d5 100644 --- a/src/goto-cc/compile.h +++ b/src/goto-cc/compile.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Compile and link source and object files. - #ifndef CPROVER_GOTO_CC_COMPILE_H #define CPROVER_GOTO_CC_COMPILE_H diff --git a/src/goto-cc/cw_mode.cpp b/src/goto-cc/cw_mode.cpp index 5fbacbfcfe1..18f1bf60494 100644 --- a/src/goto-cc/cw_mode.cpp +++ b/src/goto-cc/cw_mode.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// Command line option container - #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -27,7 +24,18 @@ Author: CM Wintersteiger, 2006 #include "cw_mode.h" #include "compile.h" -/// does it. +/*******************************************************************\ + +Function: cw_modet::doit + + Inputs: + + Outputs: + + Purpose: does it. + +\*******************************************************************/ + int cw_modet::doit() { if(cmdline.isset('?') || cmdline.isset("help")) @@ -178,7 +186,18 @@ int cw_modet::doit() return compiler.doit() ? EX_USAGE : EX_OK; } -/// display command line help +/*******************************************************************\ + +Function: cw_modet::help_mode + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void cw_modet::help_mode() { std::cout << "goto-cw understands the options of " diff --git a/src/goto-cc/cw_mode.h b/src/goto-cc/cw_mode.h index 58bd7129fc1..865b1f7ea15 100644 --- a/src/goto-cc/cw_mode.h +++ b/src/goto-cc/cw_mode.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Base class for command line interpretation - #ifndef CPROVER_GOTO_CC_CW_MODE_H #define CPROVER_GOTO_CC_CW_MODE_H diff --git a/src/goto-cc/gcc_cmdline.cpp b/src/goto-cc/gcc_cmdline.cpp index e25830ffbcd..f9bd0d1ead4 100644 --- a/src/goto-cc/gcc_cmdline.cpp +++ b/src/goto-cc/gcc_cmdline.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// A special command line object for the gcc-like options - #include #include #include @@ -18,9 +15,18 @@ Author: CM Wintersteiger, 2006 #include "gcc_cmdline.h" -/// parses the commandline options into a cmdlinet -/// \par parameters: argument count, argument strings -/// \return none +/*******************************************************************\ + +Function: gcc_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + // non-gcc options const char *goto_cc_options_with_separated_argument[]= { @@ -224,6 +230,18 @@ bool gcc_cmdlinet::parse(int argc, const char **argv) return result; } +/*******************************************************************\ + +Function: gcc_cmdlinet::parse_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool gcc_cmdlinet::parse_arguments( const argst &args, bool in_spec_file) @@ -421,7 +439,19 @@ bool gcc_cmdlinet::parse_arguments( return false; } -/// Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html +/*******************************************************************\ + +Function: gcc_cmdlinet::parse_specs_line + + Inputs: + + Outputs: + + Purpose: Parse GCC spec files + https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html + +\*******************************************************************/ + void gcc_cmdlinet::parse_specs_line(const std::string &line) { // initial whitespace has been stripped @@ -441,7 +471,19 @@ void gcc_cmdlinet::parse_specs_line(const std::string &line) parse_arguments(args, true); } -/// Parse GCC spec files https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html +/*******************************************************************\ + +Function: gcc_cmdlinet::parse_specs + + Inputs: + + Outputs: + + Purpose: Parse GCC spec files + https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html + +\*******************************************************************/ + void gcc_cmdlinet::parse_specs() { const std::string &specs_file_name=get_value("specs"); diff --git a/src/goto-cc/gcc_cmdline.h b/src/goto-cc/gcc_cmdline.h index 92ac348118c..2e233f032c5 100644 --- a/src/goto-cc/gcc_cmdline.h +++ b/src/goto-cc/gcc_cmdline.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// A special command line object for the gcc-like options - #ifndef CPROVER_GOTO_CC_GCC_CMDLINE_H #define CPROVER_GOTO_CC_GCC_CMDLINE_H diff --git a/src/goto-cc/gcc_mode.cpp b/src/goto-cc/gcc_mode.cpp index cc12b40e1ce..19444ef1fc5 100644 --- a/src/goto-cc/gcc_mode.cpp +++ b/src/goto-cc/gcc_mode.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// GCC Mode - #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -34,6 +31,18 @@ Author: CM Wintersteiger, 2006 #include "compile.h" #include "gcc_mode.h" +/*******************************************************************\ + +Function: compiler_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string compiler_name( const cmdlinet &cmdline, const std::string &base_name) @@ -64,6 +73,18 @@ static std::string compiler_name( return result; } +/*******************************************************************\ + +Function: linker_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::string linker_name( const cmdlinet &cmdline, const std::string &base_name) @@ -84,6 +105,18 @@ static std::string linker_name( return result; } +/*******************************************************************\ + +Function: gcc_modet::gcc_modet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + gcc_modet::gcc_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -95,6 +128,18 @@ gcc_modet::gcc_modet( { } +/*******************************************************************\ + +Function: gcc_modet::needs_preprocessing + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool gcc_modet::needs_preprocessing(const std::string &file) { if(has_suffix(file, ".c") || @@ -109,7 +154,18 @@ bool gcc_modet::needs_preprocessing(const std::string &file) return false; } -/// does it. +/*******************************************************************\ + +Function: gcc_modet::doit + + Inputs: + + Outputs: + + Purpose: does it. + +\*******************************************************************/ + int gcc_modet::doit() { if(cmdline.isset('?') || @@ -467,7 +523,18 @@ int gcc_modet::doit() return EX_OK; } -/// call gcc for preprocessing +/*******************************************************************\ + +Function: gcc_modet::preprocess + + Inputs: + + Outputs: + + Purpose: call gcc for preprocessing + +\*******************************************************************/ + int gcc_modet::preprocess( const std::string &language, const std::string &src, @@ -548,7 +615,18 @@ int gcc_modet::preprocess( return run(new_argv[0], new_argv, cmdline.stdin_file, stdout_file); } -/// run gcc or clang with original command line +/*******************************************************************\ + +Function: gcc_modet::run_gcc + + Inputs: + + Outputs: + + Purpose: run gcc or clang with original command line + +\*******************************************************************/ + int gcc_modet::run_gcc() { assert(!cmdline.parsed_argv.empty()); @@ -572,6 +650,18 @@ int gcc_modet::run_gcc() return run(new_argv[0], new_argv, cmdline.stdin_file, ""); } +/*******************************************************************\ + +Function: gcc_modet::gcc_hybrid_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int gcc_modet::gcc_hybrid_binary() { { @@ -711,6 +801,18 @@ int gcc_modet::gcc_hybrid_binary() return result; } +/*******************************************************************\ + +Function: gcc_modet::asm_output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int gcc_modet::asm_output( bool act_as_bcc, const std::list &preprocessed_source_files) @@ -795,7 +897,18 @@ int gcc_modet::asm_output( return EX_OK; } -/// display command line help +/*******************************************************************\ + +Function: gcc_modet::help_mode + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void gcc_modet::help_mode() { if(act_as_ld) diff --git a/src/goto-cc/gcc_mode.h b/src/goto-cc/gcc_mode.h index 5563639e07c..b37b87448d6 100644 --- a/src/goto-cc/gcc_mode.h +++ b/src/goto-cc/gcc_mode.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Base class for command line interpretation - #ifndef CPROVER_GOTO_CC_GCC_MODE_H #define CPROVER_GOTO_CC_GCC_MODE_H diff --git a/src/goto-cc/goto_cc_cmdline.cpp b/src/goto-cc/goto_cc_cmdline.cpp index a9090012ad1..7b3bc78cdda 100644 --- a/src/goto-cc/goto_cc_cmdline.cpp +++ b/src/goto-cc/goto_cc_cmdline.cpp @@ -8,9 +8,6 @@ Date: April 2010 \*******************************************************************/ -/// \file -/// Command line interpretation for goto-cc - #include #include #include @@ -21,12 +18,36 @@ Date: April 2010 #include "goto_cc_cmdline.h" +/*******************************************************************\ + +Function: goto_cc_cmdlinet::~goto_cc_cmdlinet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_cc_cmdlinet::~goto_cc_cmdlinet() { if(!stdin_file.empty()) remove(stdin_file.c_str()); } +/*******************************************************************\ + +Function: goto_cc_cmdlinet::in_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_cc_cmdlinet::in_list(const char *option, const char **list) { for(std::size_t i=0; list[i]!=NULL; i++) @@ -38,6 +59,18 @@ bool goto_cc_cmdlinet::in_list(const char *option, const char **list) return false; } +/*******************************************************************\ + +Function: goto_cc_cmdlinet::prefix_in_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_cc_cmdlinet::prefix_in_list( const char *option, const char **list, @@ -55,6 +88,18 @@ bool goto_cc_cmdlinet::prefix_in_list( return false; } +/*******************************************************************\ + +Function: goto_cc_cmdlinet::get_optnr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) { int optnr; @@ -108,6 +153,18 @@ std::size_t goto_cc_cmdlinet::get_optnr(const std::string &opt_string) return optnr; } +/*******************************************************************\ + +Function: goto_cc_cmdlinet::add_infile_arg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_cc_cmdlinet::add_infile_arg(const std::string &arg) { parsed_argv.push_back(argt(arg)); diff --git a/src/goto-cc/goto_cc_cmdline.h b/src/goto-cc/goto_cc_cmdline.h index f699946da68..d3608400f30 100644 --- a/src/goto-cc/goto_cc_cmdline.h +++ b/src/goto-cc/goto_cc_cmdline.h @@ -8,9 +8,6 @@ Date: April 2010 \*******************************************************************/ -/// \file -/// Command line interpretation for goto-cc - #ifndef CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H #define CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H diff --git a/src/goto-cc/goto_cc_languages.cpp b/src/goto-cc/goto_cc_languages.cpp index 0c076187ee7..a8bf5d9a07e 100644 --- a/src/goto-cc/goto_cc_languages.cpp +++ b/src/goto-cc/goto_cc_languages.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Language Registration - #include #include @@ -22,6 +19,18 @@ Author: CM Wintersteiger #include "goto_cc_mode.h" +/*******************************************************************\ + +Function: goto_cc_modet::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_cc_modet::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-cc/goto_cc_main.cpp b/src/goto-cc/goto_cc_main.cpp index 2b1745c668a..8c42b4fee4d 100644 --- a/src/goto-cc/goto_cc_main.cpp +++ b/src/goto-cc/goto_cc_main.cpp @@ -8,9 +8,6 @@ Date: May 2006 \*******************************************************************/ -/// \file -/// GOTO-CC Main Module - #include #include @@ -31,6 +28,18 @@ Date: May 2006 #include "armcc_mode.h" #include "as_mode.h" +/*******************************************************************\ + +Function: to_lower_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string to_lower_string(const std::string &s) { std::string result=s; @@ -38,6 +47,18 @@ std::string to_lower_string(const std::string &s) return result; } +/*******************************************************************\ + +Function: main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) #else diff --git a/src/goto-cc/goto_cc_mode.cpp b/src/goto-cc/goto_cc_mode.cpp index 8822122d022..a0e363ad112 100644 --- a/src/goto-cc/goto_cc_mode.cpp +++ b/src/goto-cc/goto_cc_mode.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// Command line option container - #include #include @@ -24,7 +21,18 @@ Author: CM Wintersteiger, 2006 #include "goto_cc_mode.h" -/// constructor +/*******************************************************************\ + +Function: goto_cc_modet::goto_cc_modet + + Inputs: + + Outputs: + + Purpose: constructor + +\*******************************************************************/ + goto_cc_modet::goto_cc_modet( goto_cc_cmdlinet &_cmdline, const std::string &_base_name, @@ -36,12 +44,34 @@ goto_cc_modet::goto_cc_modet( register_languages(); } -/// constructor +/*******************************************************************\ + +Function: goto_cc_modet::~goto_cc_modet + + Inputs: + + Outputs: + + Purpose: constructor + +\*******************************************************************/ + goto_cc_modet::~goto_cc_modet() { } -/// display command line help +/*******************************************************************\ + +Function: goto_cc_modet::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void goto_cc_modet::help() { std::cout << @@ -67,8 +97,18 @@ void goto_cc_modet::help() "\n"; } -/// starts the compiler -/// \return error code +/*******************************************************************\ + +Function: goto_cc_modet::main + + Inputs: argc/argv + + Outputs: error code + + Purpose: starts the compiler + +\*******************************************************************/ + int goto_cc_modet::main(int argc, const char **argv) { if(cmdline.parse(argc, argv)) @@ -106,8 +146,18 @@ int goto_cc_modet::main(int argc, const char **argv) } } -/// prints a message informing the user about incorrect options -/// \return none +/*******************************************************************\ + +Function: goto_cc_modet::usage_error + + Inputs: none + + Outputs: none + + Purpose: prints a message informing the user about incorrect options + +\*******************************************************************/ + void goto_cc_modet::usage_error() { std::cerr << "Usage error!\n\n"; diff --git a/src/goto-cc/goto_cc_mode.h b/src/goto-cc/goto_cc_mode.h index a0b6ea47a96..d25fbb750b5 100644 --- a/src/goto-cc/goto_cc_mode.h +++ b/src/goto-cc/goto_cc_mode.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Command line interpretation for goto-cc. - #ifndef CPROVER_GOTO_CC_GOTO_CC_MODE_H #define CPROVER_GOTO_CC_GOTO_CC_MODE_H diff --git a/src/goto-cc/ld_cmdline.cpp b/src/goto-cc/ld_cmdline.cpp index 4b4bf24962c..242c1245941 100644 --- a/src/goto-cc/ld_cmdline.cpp +++ b/src/goto-cc/ld_cmdline.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, 2013 \*******************************************************************/ -/// \file -/// A special command line object for the ld-like options - #include #include @@ -16,9 +13,18 @@ Author: Daniel Kroening, 2013 #include "ld_cmdline.h" -/// parses the commandline options into a cmdlinet -/// \par parameters: argument count, argument strings -/// \return none +/*******************************************************************\ + +Function: ld_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + const char *goto_ld_options_with_argument[]= { "--verbosity", diff --git a/src/goto-cc/ld_cmdline.h b/src/goto-cc/ld_cmdline.h index 18f42ec2d68..449d0104427 100644 --- a/src/goto-cc/ld_cmdline.h +++ b/src/goto-cc/ld_cmdline.h @@ -8,9 +8,6 @@ Date: Feb 2013 \*******************************************************************/ -/// \file -/// A special command line object for the ld-like options - #ifndef CPROVER_GOTO_CC_LD_CMDLINE_H #define CPROVER_GOTO_CC_LD_CMDLINE_H diff --git a/src/goto-cc/ms_cl_cmdline.cpp b/src/goto-cc/ms_cl_cmdline.cpp index 31eec139fba..fb9c8b4e23c 100644 --- a/src/goto-cc/ms_cl_cmdline.cpp +++ b/src/goto-cc/ms_cl_cmdline.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// A special command line object for the CL options - #include #include #include @@ -19,9 +16,18 @@ Author: Daniel Kroening #include "ms_cl_cmdline.h" -/// parses the commandline options into a cmdlinet -/// \par parameters: argument count, argument strings -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + const char *non_ms_cl_options[]= { "--show-symbol-table", @@ -94,7 +100,18 @@ bool ms_cl_cmdlinet::parse(const std::vector &options) return false; } -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::parse_env + + Inputs: + + Outputs: none + + Purpose: + +\*******************************************************************/ + void ms_cl_cmdlinet::parse_env() { // first do environment @@ -116,9 +133,18 @@ void ms_cl_cmdlinet::parse_env() #endif } -/// parses the commandline options into a cmdlinet -/// \par parameters: argument count, argument strings -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::parse + + Inputs: argument count, argument strings + + Outputs: none + + Purpose: parses the commandline options into a cmdlinet + +\*******************************************************************/ + bool ms_cl_cmdlinet::parse(int argc, const char **argv) { // should really use "wide" argv from wmain() @@ -132,6 +158,18 @@ bool ms_cl_cmdlinet::parse(int argc, const char **argv) return parse(options); } +/*******************************************************************\ + +Function: my_wgetline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static std::istream &my_wgetline(std::istream &in, std::wstring &dest) { // We should support this properly, @@ -167,7 +205,18 @@ static std::istream &my_wgetline(std::istream &in, std::wstring &dest) return in; } -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::process_response_file + + Inputs: + + Outputs: none + + Purpose: + +\*******************************************************************/ + void ms_cl_cmdlinet::process_response_file(const std::string &file) { std::ifstream infile(file); @@ -229,7 +278,18 @@ void ms_cl_cmdlinet::process_response_file(const std::string &file) } } -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::process_response_file_line + + Inputs: + + Outputs: none + + Purpose: + +\*******************************************************************/ + void ms_cl_cmdlinet::process_response_file_line(const std::string &line) { // In a response file, multiple compiler options and source-code files can @@ -269,7 +329,18 @@ void ms_cl_cmdlinet::process_response_file_line(const std::string &line) parse(options); } -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::process_non_cl_option + + Inputs: + + Outputs: none + + Purpose: + +\*******************************************************************/ + void ms_cl_cmdlinet::process_non_cl_option( const std::string &s) { @@ -284,7 +355,18 @@ void ms_cl_cmdlinet::process_non_cl_option( << s << "'" << std::endl; } -/// \return none +/*******************************************************************\ + +Function: ms_cl_cmdlinet::process_cl_option + + Inputs: + + Outputs: none + + Purpose: + +\*******************************************************************/ + const char *ms_cl_flags[]= { "c", // compile only diff --git a/src/goto-cc/ms_cl_cmdline.h b/src/goto-cc/ms_cl_cmdline.h index 0c05f1e7577..627309ea6ef 100644 --- a/src/goto-cc/ms_cl_cmdline.h +++ b/src/goto-cc/ms_cl_cmdline.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// A special command line object for the gcc-like options - #ifndef CPROVER_GOTO_CC_MS_CL_CMDLINE_H #define CPROVER_GOTO_CC_MS_CL_CMDLINE_H diff --git a/src/goto-cc/ms_cl_mode.cpp b/src/goto-cc/ms_cl_mode.cpp index c375ebdfec7..25dc0e039e2 100644 --- a/src/goto-cc/ms_cl_mode.cpp +++ b/src/goto-cc/ms_cl_mode.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger, 2006 \*******************************************************************/ -/// \file -/// Visual Studio CL Mode - #ifdef _WIN32 #define EX_OK 0 #define EX_USAGE 64 @@ -30,7 +27,18 @@ Author: CM Wintersteiger, 2006 #include "ms_cl_mode.h" #include "compile.h" -/// does it. +/*******************************************************************\ + +Function: ms_cl_modet::doit + + Inputs: + + Outputs: + + Purpose: does it. + +\*******************************************************************/ + static bool is_directory(const std::string &s) { if(s.empty()) @@ -171,7 +179,18 @@ int ms_cl_modet::doit() return compiler.doit() ? EX_USAGE : EX_OK; } -/// display command line help +/*******************************************************************\ + +Function: ms_cl_modet::help_mode + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void ms_cl_modet::help_mode() { std::cout << "goto-cl understands the options of CL plus the following.\n\n"; diff --git a/src/goto-cc/ms_cl_mode.h b/src/goto-cc/ms_cl_mode.h index 3c1d387441c..673c6efed35 100644 --- a/src/goto-cc/ms_cl_mode.h +++ b/src/goto-cc/ms_cl_mode.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Visual Studio CL Mode - #ifndef CPROVER_GOTO_CC_MS_CL_MODE_H #define CPROVER_GOTO_CC_MS_CL_MODE_H diff --git a/src/goto-cc/xml_binaries/read_goto_object.cpp b/src/goto-cc/xml_binaries/read_goto_object.cpp index 1f8d65b8ada..01fffa8d4b5 100644 --- a/src/goto-cc/xml_binaries/read_goto_object.cpp +++ b/src/goto-cc/xml_binaries/read_goto_object.cpp @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Read goto object files. - #include #include #include @@ -25,9 +22,19 @@ Date: June 2006 #include "xml_irep_hashing.h" #include "xml_symbol_hashing.h" -/// reads a goto object xml file back into a symbol and a function table -/// \par parameters: input stream, symbol_table, functions -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: read_goto_object + + Inputs: input stream, symbol_table, functions + + Outputs: true on error, false otherwise + + Purpose: reads a goto object xml file back into a symbol and a + function table + +\*******************************************************************/ + bool read_goto_object( std::istream &in, const std::string &filename, diff --git a/src/goto-cc/xml_binaries/read_goto_object.h b/src/goto-cc/xml_binaries/read_goto_object.h index 36981051008..15589dba852 100644 --- a/src/goto-cc/xml_binaries/read_goto_object.h +++ b/src/goto-cc/xml_binaries/read_goto_object.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Read goto object files. - #ifndef CPROVER_GOTO_CC_XML_BINARIES_READ_GOTO_OBJECT_H #define CPROVER_GOTO_CC_XML_BINARIES_READ_GOTO_OBJECT_H diff --git a/src/goto-cc/xml_binaries/xml_goto_function.cpp b/src/goto-cc/xml_binaries/xml_goto_function.cpp index ff35c86e253..27021511fa8 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function.cpp @@ -8,27 +8,42 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Convert goto functions to xml structures and back. - #include #include "xml_goto_function.h" #include "xml_goto_program.h" -/// takes a goto_function and creates an according xml structure -/// \par parameters: goto_function and an xml node -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: goto_function and an xml node + + Outputs: none + + Purpose: takes a goto_function and creates an according xml structure + +\*******************************************************************/ + void convert(const goto_functionst::goto_functiont &function, xmlt &xml) { if(function.body_available) convert(function.body, xml); } -/// constructs the goto_function according to the information in the xml -/// structure. -/// \par parameters: xml structure and a goto_function to fill -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: xml structure and a goto_function to fill + + Outputs: none + + Purpose: constructs the goto_function according to the information + in the xml structure. + +\*******************************************************************/ + void convert(const xmlt &xml, goto_functionst::goto_functiont &function) { function.body.clear(); diff --git a/src/goto-cc/xml_binaries/xml_goto_function.h b/src/goto-cc/xml_binaries/xml_goto_function.h index b15722976b8..8f9db9982c6 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function.h +++ b/src/goto-cc/xml_binaries/xml_goto_function.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Convert goto functions into xml structures and back - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_H diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp index 8d578451fac..f5ba898e55d 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.cpp @@ -9,15 +9,21 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// Convert goto functions to xml structures and back (with irep hashing) - #include "xml_goto_function_hashing.h" #include "xml_goto_program_hashing.h" -/// takes a goto_function and creates an according xml structure -/// \par parameters: goto_function and an xml node -/// \return none +/*******************************************************************\ + +Function: xml_goto_function_convertt::convert + + Inputs: goto_function and an xml node + + Outputs: none + + Purpose: takes a goto_function and creates an according xml structure + +\*******************************************************************/ + void xml_goto_function_convertt::convert( const goto_functionst::goto_functiont &function, xmlt &xml) @@ -27,10 +33,19 @@ void xml_goto_function_convertt::convert( gpconverter.convert(function.body, xml); } -/// constructs the goto_function according to the information in the xml -/// structure. -/// \par parameters: xml structure and a goto_function to fill -/// \return none +/*******************************************************************\ + +Function: xml_goto_function_convertt::convert + + Inputs: xml structure and a goto_function to fill + + Outputs: none + + Purpose: constructs the goto_function according to the information + in the xml structure. + +\*******************************************************************/ + void xml_goto_function_convertt::convert( const xmlt &xml, goto_functionst::goto_functiont &function) diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h index e558a702c68..a0b86b72376 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h @@ -9,9 +9,6 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// Convert goto functions into xml structures and back (with irep hashing). - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_goto_program.cpp b/src/goto-cc/xml_binaries/xml_goto_program.cpp index a49a9e8eb8a..ee6a53960c0 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program.cpp @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Convert goto programs to xml structures and back. - #include #include @@ -18,10 +15,19 @@ Date: June 2006 #include "xml_goto_program.h" -/// constructs the xml structure according to the goto program and the namespace -/// into the given xml object. -/// \par parameters: goto program, namespace and an xml structure to fill -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: goto program, namespace and an xml structure to fill + + Outputs: none + + Purpose: constructs the xml structure according to the goto program + and the namespace into the given xml object. + +\*******************************************************************/ + void convert(const goto_programt &goto_program, xmlt &xml) { @@ -194,11 +200,20 @@ void convert(const goto_programt &goto_program, } } -/// constructs the goto program according to the xml structure and the namespace -/// into the given goto program object. -/// \par parameters: an xml structure, namespace, function symbol -/// and a goto program to fill -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: an xml structure, namespace, function symbol + and a goto program to fill + + Outputs: none + + Purpose: constructs the goto program according to the xml structure + and the namespace into the given goto program object. + +\*******************************************************************/ + void convert(const xmlt &xml, goto_programt &goto_program) { goto_program.clear(); @@ -379,11 +394,19 @@ void convert(const xmlt &xml, goto_programt &goto_program) // std::cout << "TNI: " << goto_program.target_numbers.size() << std::endl; } -/// finds the index of the instruction labelled with the given target label in -/// the given xml-program -/// \par parameters: a target label string, the instructions list and an xml -/// program -/// \return iterator to the found instruction or .end() +/*******************************************************************\ + +Function: find_instruction + + Inputs: a target label string, the instructions list and an xml program + + Outputs: iterator to the found instruction or .end() + + Purpose: finds the index of the instruction labelled with the given + target label in the given xml-program + +\*******************************************************************/ + goto_programt::targett find_instruction( const xmlt &xml, diff --git a/src/goto-cc/xml_binaries/xml_goto_program.h b/src/goto-cc/xml_binaries/xml_goto_program.h index cd5cb4e6c17..04bab08af3e 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program.h +++ b/src/goto-cc/xml_binaries/xml_goto_program.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Convert goto programs into xml structures and back - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_H diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp index 82054b85c21..fa1ac0c2b00 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.cpp @@ -9,19 +9,25 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// Convert goto programs to xml structures and back (with irep hashing) - #include #include #include "xml_irep_hashing.h" #include "xml_goto_program_hashing.h" -/// constructs the xml structure according to the goto program and the namespace -/// into the given xml object. -/// \par parameters: goto program and an xml structure to fill -/// \return none +/*******************************************************************\ + +Function: xml_goto_program_convertt::convert + + Inputs: goto program and an xml structure to fill + + Outputs: none + + Purpose: constructs the xml structure according to the goto program + and the namespace into the given xml object. + +\*******************************************************************/ + void xml_goto_program_convertt::convert( const goto_programt &goto_program, xmlt &xml) @@ -190,10 +196,18 @@ void xml_goto_program_convertt::convert( } } -/// constructs the goto program according to the xml structure and the namespace -/// into the given goto program object. -/// \par parameters: an xml structure and a goto program to fill -/// \return none +/*******************************************************************\ + +Function: xml_goto_program_convertt::convert + + Inputs: an xml structure and a goto program to fill + + Outputs: none + + Purpose: constructs the goto program according to the xml structure + and the namespace into the given goto program object. + +\*******************************************************************/ void xml_goto_program_convertt::convert( const xmlt &xml, goto_programt &goto_program) @@ -379,11 +393,18 @@ void xml_goto_program_convertt::convert( // std::cout << "TNI: " << goto_program.target_numbers.size() << std::endl; } -/// finds the index of the instruction labelled with the given target label in -/// the given xml-program -/// \par parameters: a target label string, the instructions list and an xml -/// program -/// \return iterator to the found instruction or .end() +/*******************************************************************\ + +Function: xml_goto_program_convertt::find_instruction + + Inputs: a target label string, the instructions list and an xml program + + Outputs: iterator to the found instruction or .end() + + Purpose: finds the index of the instruction labelled with the given + target label in the given xml-program + +\*******************************************************************/ goto_programt::targett xml_goto_program_convertt::find_instruction( const xmlt &xml, goto_programt::instructionst &instructions, diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h index 63622775799..a3af286f1a7 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h @@ -9,9 +9,6 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// Convert goto programs into xml structures and back (with irep hashing) - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp index c2d3ab67720..54aa9c06bf8 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.cpp @@ -8,15 +8,24 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// XML-irep conversions with hashing - #include #include #include "xml_irep_hashing.h" #include "string_hash.h" +/*******************************************************************\ + +Function: xml_irep_convertt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xml_irep_convertt::convert( const irept &irep, xmlt &xml) @@ -45,6 +54,18 @@ void xml_irep_convertt::convert( } } +/*******************************************************************\ + +Function: xml_irep_convertt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xml_irep_convertt::convert( const xmlt &xml, irept &irep) @@ -91,6 +112,18 @@ void xml_irep_convertt::convert( } } +/*******************************************************************\ + +Function: xml_irep_convertt::reference_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xml_irep_convertt::reference_convert( const irept &irep, xmlt &xml) @@ -111,6 +144,17 @@ void xml_irep_convertt::reference_convert( } } +/*******************************************************************\ + +Function: xml_irep_convertt::add_with_childs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ unsigned long xml_irep_convertt::add_with_childs(const irept &iwi) { unsigned long id=insert((unsigned long)&iwi, iwi); @@ -147,9 +191,19 @@ unsigned long xml_irep_convertt::add_with_childs(const irept &iwi) return id; } -/// resolves references to ireps from an irep after reading an irep hash map -/// into memory. -/// \return none +/*******************************************************************\ + +Function: xml_irep_convertt::resolve_references + + Inputs: none + + Outputs: none + + Purpose: resolves references to ireps from an irep after reading + an irep hash map into memory. + +\*******************************************************************/ + void xml_irep_convertt::resolve_references(const irept &cur) { if(cur.id() == "__REFERENCE__") @@ -178,9 +232,18 @@ void xml_irep_convertt::resolve_references(const irept &cur) resolve_references(iti->second); } -/// converts the hash value to a readable string -/// \par parameters: an irep pointer -/// \return a new string +/*******************************************************************\ + +Function: xml_irep_convertt::long_to_string + + Inputs: an irep pointer + + Outputs: a new string + + Purpose: converts the hash value to a readable string + +\*******************************************************************/ + std::string xml_irep_convertt::long_to_string(const unsigned long l) { std::stringstream s; @@ -188,10 +251,19 @@ std::string xml_irep_convertt::long_to_string(const unsigned long l) return s.str(); } -/// converts the string to an unsigned long that used to give a pointer to an -/// irep in an old compilation -/// \par parameters: a string -/// \return an unsigned long +/*******************************************************************\ + +Function: xml_irep_convertt::string_to_long + + Inputs: a string + + Outputs: an unsigned long + + Purpose: converts the string to an unsigned long that used to give + a pointer to an irep in an old compilation + +\*******************************************************************/ + unsigned long xml_irep_convertt::string_to_long(const std::string &s) { std::stringstream ss(s); @@ -200,27 +272,54 @@ unsigned long xml_irep_convertt::string_to_long(const std::string &s) return res; } -/// finds an irep in the ireps hash set by its id -/// \par parameters: an id -/// \return an iterator into the ireps hash set +/*******************************************************************\ + +Function: xml_irep_convertt::find_irep_by_id + + Inputs: an id + + Outputs: an iterator into the ireps hash set + + Purpose: finds an irep in the ireps hash set by its id + +\*******************************************************************/ + xml_irep_convertt::ireps_containert::id_containert::const_iterator xml_irep_convertt::find_irep_by_id(const unsigned int id) { return ireps_container.id_container.find(id); } -/// finds an irep in the ireps hash set by checking contents -/// \par parameters: an irep -/// \return an iterator into the ireps hash set -xml_irep_convertt::ireps_containert::content_containert::const_iterator +/*******************************************************************\ + +Function: xml_irep_convertt::find_irep_by_content + + Inputs: an irep + + Outputs: an iterator into the ireps hash set + + Purpose: finds an irep in the ireps hash set by checking contents + +\*******************************************************************/ + + xml_irep_convertt::ireps_containert::content_containert::const_iterator xml_irep_convertt::find_irep_by_content(const irept &irep) { return ireps_container.content_container.find(irep); } -/// inserts an irep into the hashtable -/// \par parameters: an unsigned long and an irep -/// \return true on success, false otherwise +/*******************************************************************\ + +Function: xml_irep_convertt::insert + + Inputs: an unsigned long and an irep + + Outputs: true on success, false otherwise + + Purpose: inserts an irep into the hashtable + +\*******************************************************************/ + unsigned long xml_irep_convertt::insert( unsigned long id, const irept &i) @@ -247,9 +346,18 @@ unsigned long xml_irep_convertt::insert( } } -/// inserts an irep into the hashtable -/// \par parameters: a string and an irep -/// \return true on success, false otherwise +/*******************************************************************\ + +Function: xml_irep_convertt::insert + + Inputs: a string and an irep + + Outputs: true on success, false otherwise + + Purpose: inserts an irep into the hashtable + +\*******************************************************************/ + unsigned long xml_irep_convertt::insert( const std::string &id, const irept &i) @@ -257,9 +365,19 @@ unsigned long xml_irep_convertt::insert( return insert(string_to_long(id), i); } -/// converts the current hash map of ireps into the given xml structure -/// \par parameters: an xml node -/// \return nothing +/*******************************************************************\ + +Function: xml_irep_convertt::convert_map + + Inputs: an xml node + + Outputs: nothing + + Purpose: converts the current hash map of ireps into the given xml + structure + +\*******************************************************************/ + void xml_irep_convertt::convert_map(xmlt &xml) { ireps_containert::id_containert::iterator hit= @@ -274,10 +392,19 @@ void xml_irep_convertt::convert_map(xmlt &xml) } } -/// converts the current hash map of ireps into xml nodes and outputs them to -/// the stream -/// \par parameters: an output stream -/// \return nothing +/*******************************************************************\ + +Function: xml_irep_convertt::output_map + + Inputs: an output stream + + Outputs: nothing + + Purpose: converts the current hash map of ireps into xml nodes and + outputs them to the stream + +\*******************************************************************/ + void xml_irep_convertt::output_map(std::ostream &out, unsigned indent) { ireps_containert::id_containert::iterator hit= diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.h b/src/goto-cc/xml_binaries/xml_irep_hashing.h index 2391580a61b..6fc074c9941 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.h +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.h @@ -8,9 +8,6 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// XML-irep conversions with hashing - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_IREP_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_IREP_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_symbol.cpp b/src/goto-cc/xml_binaries/xml_symbol.cpp index e62ebe7f657..051d6b38d4f 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol.cpp @@ -8,15 +8,21 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Compile and link source and object files. - #include "xml_irep.h" #include "xml_symbol.h" -/// converts a symbol to an xml symbol node -/// \par parameters: a symbol and an xml node -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: a symbol and an xml node + + Outputs: none + + Purpose: converts a symbol to an xml symbol node + +\*******************************************************************/ + void convert(const symbolt &sym, xmlt &root) { xmlt &xmlsym = root.new_element("symbol"); @@ -62,9 +68,18 @@ void convert(const symbolt &sym, xmlt &root) xmlloc.name = "location"; // convert overwrote this } -/// converts an xml symbol node to a symbol -/// \par parameters: an xml node and a symbol -/// \return none +/*******************************************************************\ + +Function: convert + + Inputs: an xml node and a symbol + + Outputs: none + + Purpose: converts an xml symbol node to a symbol + +\*******************************************************************/ + void convert(const xmlt &xmlsym, symbolt &symbol) { symbol.name=xmlsym.get_attribute("name"); diff --git a/src/goto-cc/xml_binaries/xml_symbol.h b/src/goto-cc/xml_binaries/xml_symbol.h index 0044cf98000..d50f8b75610 100644 --- a/src/goto-cc/xml_binaries/xml_symbol.h +++ b/src/goto-cc/xml_binaries/xml_symbol.h @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Converts symbols to xml structures and back. - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_H diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp index 862522451e1..ab6c17ab412 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.cpp @@ -8,15 +8,21 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// XML-symbol conversions with irep hashing - #include "xml_symbol_hashing.h" #include "xml_irep_hashing.h" -/// converts a symbol to an xml symbol node -/// \par parameters: a symbol and an xml node -/// \return none +/*******************************************************************\ + +Function: xml_symbol_convertt::convert + + Inputs: a symbol and an xml node + + Outputs: none + + Purpose: converts a symbol to an xml symbol node + +\*******************************************************************/ + void xml_symbol_convertt::convert(const symbolt &sym, xmlt &root) { xmlt &xmlsym = root.new_element("symbol"); @@ -25,9 +31,18 @@ void xml_symbol_convertt::convert(const symbolt &sym, xmlt &root) irepconverter.reference_convert(irepcache.back(), xmlsym); } -/// converts an xml symbol node to a symbol -/// \par parameters: an xml node and a symbol -/// \return none +/*******************************************************************\ + +Function: xml_symbol_convertt::convert + + Inputs: an xml node and a symbol + + Outputs: none + + Purpose: converts an xml symbol node to a symbol + +\*******************************************************************/ + void xml_symbol_convertt::convert(const xmlt &xmlsym, symbolt &symbol) { irept t; diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.h b/src/goto-cc/xml_binaries/xml_symbol_hashing.h index bb5f3e9a060..0ade830430e 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.h +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.h @@ -8,9 +8,6 @@ Date: July 2006 \*******************************************************************/ -/// \file -/// XML-symbol conversions with irep hashing - #ifndef CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_HASHING_H #define CPROVER_GOTO_CC_XML_BINARIES_XML_SYMBOL_HASHING_H diff --git a/src/goto-diff/change_impact.cpp b/src/goto-diff/change_impact.cpp index 2006c69822a..6ca431c0f1d 100644 --- a/src/goto-diff/change_impact.cpp +++ b/src/goto-diff/change_impact.cpp @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Data and control-dependencies of syntactic diff - #include #include @@ -50,6 +47,18 @@ Date: April 2016 queue.push(entry); } +/*******************************************************************\ + +Function: full_slicert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::operator()( goto_functionst &goto_functions, const namespacet &ns, @@ -135,6 +144,18 @@ void full_slicert::operator()( } +/*******************************************************************\ + +Function: full_slicert::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::fixedpoint( goto_functionst &goto_functions, queuet &queue, @@ -185,6 +206,18 @@ void full_slicert::fixedpoint( } +/*******************************************************************\ + +Function: full_slicert::add_dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::add_dependencies( const cfgt::nodet &node, queuet &queue, @@ -286,6 +319,18 @@ class change_impactt goto_programt::const_targett &target) const; }; +/*******************************************************************\ + +Function: change_impactt::change_impactt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + change_impactt::change_impactt( const goto_modelt &model_old, const goto_modelt &model_new, @@ -312,6 +357,18 @@ change_impactt::change_impactt( new_dep_graph(new_goto_functions, ns_new); } +/*******************************************************************\ + +Function: change_impactt::change_impact + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::change_impact(const irep_idt &function) { unified_difft::goto_program_difft diff; @@ -344,6 +401,18 @@ void change_impactt::change_impact(const irep_idt &function) new_change_impact[function]); } +/*******************************************************************\ + +Function: change_impactt::change_impact + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::change_impact( const goto_programt &old_goto_program, const goto_programt &new_goto_program, @@ -424,6 +493,18 @@ void change_impactt::change_impact( } +/*******************************************************************\ + +Function: change_impactt::propogate_dep_forward + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::propogate_dep_forward( const dependence_grapht::nodet &d_node, const dependence_grapht &dep_graph, @@ -451,6 +532,18 @@ void change_impactt::propogate_dep_forward( } } +/*******************************************************************\ + +Function: change_impactt::propogate_dep_back + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::propogate_dep_back( const dependence_grapht::nodet &d_node, const dependence_grapht &dep_graph, @@ -481,6 +574,18 @@ void change_impactt::propogate_dep_back( } } +/*******************************************************************\ + +Function: change_impactt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::operator()() { // sorted iteration over intersection(old functions, new functions) @@ -551,6 +656,18 @@ void change_impactt::operator()() } } +/*******************************************************************\ + +Function: change_impact::output_change_impact + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::output_change_impact( const irep_idt &function, const goto_program_change_impactt &c_i, @@ -596,6 +713,18 @@ void change_impactt::output_change_impact( } } +/*******************************************************************\ + +Function: change_impact::output_change_impact + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::output_change_impact( const irep_idt &function, const goto_program_change_impactt &o_c_i, @@ -712,6 +841,18 @@ void change_impactt::output_change_impact( } } +/*******************************************************************\ + +Function: change_impactt::output_instruction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impactt::output_instruction(char prefix, const goto_programt &goto_program, const namespacet &ns, @@ -735,6 +876,18 @@ void change_impactt::output_instruction(char prefix, } } +/*******************************************************************\ + +Function: change_impact + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void change_impact( const goto_modelt &model_old, const goto_modelt &model_new, diff --git a/src/goto-diff/change_impact.h b/src/goto-diff/change_impact.h index d56e57184e1..234ec15a7c8 100644 --- a/src/goto-diff/change_impact.h +++ b/src/goto-diff/change_impact.h @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Data and control-dependencies of syntactic diff - #ifndef CPROVER_GOTO_DIFF_CHANGE_IMPACT_H #define CPROVER_GOTO_DIFF_CHANGE_IMPACT_H diff --git a/src/goto-diff/goto_diff.h b/src/goto-diff/goto_diff.h index 2b6a9ac923d..bb6a7bb05cc 100644 --- a/src/goto-diff/goto_diff.h +++ b/src/goto-diff/goto_diff.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Base Class - #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_H diff --git a/src/goto-diff/goto_diff_base.cpp b/src/goto-diff/goto_diff_base.cpp index cd945b11a7a..7c6a0e5bf4e 100644 --- a/src/goto-diff/goto_diff_base.cpp +++ b/src/goto-diff/goto_diff_base.cpp @@ -6,13 +6,22 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Base Class - #include #include "goto_diff.h" +/*******************************************************************\ + +Function: goto_difft::output_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &goto_difft::output_functions(std::ostream &out) const { switch(ui) @@ -76,6 +85,18 @@ std::ostream &goto_difft::output_functions(std::ostream &out) const return out; } +/*******************************************************************\ + +Function: goto_difft::convert_function_group + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_difft::convert_function_group( json_arrayt &result, const irep_id_sett &function_group) const @@ -87,6 +108,18 @@ void goto_difft::convert_function_group( } } +/*******************************************************************\ + +Function: goto_difft::convert_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_difft::convert_function( json_objectt &result, const irep_idt &function_name) const diff --git a/src/goto-diff/goto_diff_languages.cpp b/src/goto-diff/goto_diff_languages.cpp index d1ad10c5a0b..c467ab92cd3 100644 --- a/src/goto-diff/goto_diff_languages.cpp +++ b/src/goto-diff/goto_diff_languages.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Language Registration - #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_diff_languages.h" +/*******************************************************************\ + +Function: goto_diff_languagest::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_diff_languagest::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-diff/goto_diff_languages.h b/src/goto-diff/goto_diff_languages.h index 7bd4c24e525..b0489e85544 100644 --- a/src/goto-diff/goto_diff_languages.h +++ b/src/goto-diff/goto_diff_languages.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Languages - #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_LANGUAGES_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_LANGUAGES_H diff --git a/src/goto-diff/goto_diff_main.cpp b/src/goto-diff/goto_diff_main.cpp index 52897394b06..96655ea5455 100644 --- a/src/goto-diff/goto_diff_main.cpp +++ b/src/goto-diff/goto_diff_main.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Main Module - #include #ifdef IREP_HASH_STATS @@ -17,6 +14,18 @@ Author: Peter Schrammel #include "goto_diff_parse_options.h" +/*******************************************************************\ + +Function: main / wmain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef IREP_HASH_STATS extern unsigned long long irep_hash_cnt; extern unsigned long long irep_cmp_cnt; diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index 9f9cd2c6227..f0266b006e4 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Command Line Option Processing - #include #include // exit() #include @@ -47,6 +44,18 @@ Author: Peter Schrammel #include "unified_diff.h" #include "change_impact.h" +/*******************************************************************\ + +Function: goto_diff_parse_optionst::goto_diff_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_diff_parse_optionst::goto_diff_parse_optionst(int argc, const char **argv): parse_options_baset(GOTO_DIFF_OPTIONS, argc, argv), goto_diff_languagest(cmdline, ui_message_handler), @@ -55,6 +64,18 @@ goto_diff_parse_optionst::goto_diff_parse_optionst(int argc, const char **argv): { } +/*******************************************************************\ + +Function: goto_diff_parse_optionst::goto_diff_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ::goto_diff_parse_optionst::goto_diff_parse_optionst( int argc, const char **argv, @@ -66,6 +87,18 @@ ::goto_diff_parse_optionst::goto_diff_parse_optionst( { } +/*******************************************************************\ + +Function: goto_diff_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_diff_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -81,6 +114,18 @@ void goto_diff_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } +/*******************************************************************\ + +Function: goto_diff_parse_optionst::get_command_line_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_diff_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -235,7 +280,18 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options) } } -/// invoke main modules +/*******************************************************************\ + +Function: goto_diff_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int goto_diff_parse_optionst::doit() { if(cmdline.isset("version")) @@ -329,6 +385,18 @@ int goto_diff_parse_optionst::doit() return 0; } +/*******************************************************************\ + +Function: goto_diff_parse_optionst::get_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int goto_diff_parse_optionst::get_goto_program( const optionst &options, goto_diff_languagest &languages, @@ -386,6 +454,18 @@ int goto_diff_parse_optionst::get_goto_program( return -1; // no error, continue } +/*******************************************************************\ + +Function: goto_diff_parse_optionst::process_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_diff_parse_optionst::process_goto_program( const optionst &options, goto_modelt &goto_model) @@ -472,7 +552,18 @@ bool goto_diff_parse_optionst::process_goto_program( return false; } -/// display command line help +/*******************************************************************\ + +Function: goto_diff_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void goto_diff_parse_optionst::help() { std::cout << diff --git a/src/goto-diff/goto_diff_parse_options.h b/src/goto-diff/goto_diff_parse_options.h index 505de8410f4..e78bd1537e7 100644 --- a/src/goto-diff/goto_diff_parse_options.h +++ b/src/goto-diff/goto_diff_parse_options.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// GOTO-DIFF Command Line Option Processing - #ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H #define CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H diff --git a/src/goto-diff/syntactic_diff.cpp b/src/goto-diff/syntactic_diff.cpp index 030d35e0f3c..4c0e831dfdc 100644 --- a/src/goto-diff/syntactic_diff.cpp +++ b/src/goto-diff/syntactic_diff.cpp @@ -6,11 +6,20 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Syntactic GOTO-DIFF - #include "syntactic_diff.h" +/*******************************************************************\ + +Function: syntactic_difft::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool syntactic_difft::operator()() { forall_goto_functions(it, goto_model1.goto_functions) diff --git a/src/goto-diff/syntactic_diff.h b/src/goto-diff/syntactic_diff.h index 8496eb8165e..dd10374dc4b 100644 --- a/src/goto-diff/syntactic_diff.h +++ b/src/goto-diff/syntactic_diff.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Syntactic GOTO-DIFF - #ifndef CPROVER_GOTO_DIFF_SYNTACTIC_DIFF_H #define CPROVER_GOTO_DIFF_SYNTACTIC_DIFF_H diff --git a/src/goto-diff/unified_diff.cpp b/src/goto-diff/unified_diff.cpp index b30b3653893..8cf1f8f27b3 100644 --- a/src/goto-diff/unified_diff.cpp +++ b/src/goto-diff/unified_diff.cpp @@ -8,15 +8,24 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Unified diff (using LCSS) of goto functions - #include #include #include "unified_diff.h" +/*******************************************************************\ + +Function: unified_difft::unified_difft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unified_difft::unified_difft(const goto_modelt &model_old, const goto_modelt &model_new): old_goto_functions(model_old.goto_functions), @@ -26,6 +35,18 @@ unified_difft::unified_difft(const goto_modelt &model_old, { } +/*******************************************************************\ + +Function: unified_difft::get_diff + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unified_difft::get_diff( const irep_idt &function, goto_program_difft &dest) const @@ -61,6 +82,18 @@ void unified_difft::get_diff( dest); } +/*******************************************************************\ + +Function: unified_difft::get_diff + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unified_difft::get_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -100,6 +133,18 @@ void unified_difft::get_diff( } } +/*******************************************************************\ + +Function: unified_difft::output_diff + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unified_difft::output_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -161,6 +206,18 @@ void unified_difft::output_diff( } } +/*******************************************************************\ + +Function: unified_difft::lcss + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unified_difft::lcss( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -314,6 +371,18 @@ void unified_difft::lcss( differences.push_back(differencet::SAME); } +/*******************************************************************\ + +Function: unified_difft::unified_diff + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unified_difft::unified_diff( const irep_idt &identifier, const goto_programt &old_goto_program, @@ -338,6 +407,18 @@ void unified_difft::unified_diff( lcss(identifier, old_goto_program, new_goto_program, differences); } +/*******************************************************************\ + +Function: unified_difft::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool unified_difft::operator()() { typedef std::map #include diff --git a/src/goto-instrument/accelerate/accelerate.h b/src/goto-instrument/accelerate/accelerate.h index d3aac4ac124..03c61a3fa39 100644 --- a/src/goto-instrument/accelerate/accelerate.h +++ b/src/goto-instrument/accelerate/accelerate.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATE_H diff --git a/src/goto-instrument/accelerate/acceleration_utils.cpp b/src/goto-instrument/accelerate/acceleration_utils.cpp index 36dd90068b0..1d42ebf1945 100644 --- a/src/goto-instrument/accelerate/acceleration_utils.cpp +++ b/src/goto-instrument/accelerate/acceleration_utils.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include #include diff --git a/src/goto-instrument/accelerate/acceleration_utils.h b/src/goto-instrument/accelerate/acceleration_utils.h index e05c7ed48da..de378ee7509 100644 --- a/src/goto-instrument/accelerate/acceleration_utils.h +++ b/src/goto-instrument/accelerate/acceleration_utils.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATION_UTILS_H diff --git a/src/goto-instrument/accelerate/accelerator.h b/src/goto-instrument/accelerate/accelerator.h index 57f17b5a618..143c4cbfbab 100644 --- a/src/goto-instrument/accelerate/accelerator.h +++ b/src/goto-instrument/accelerate/accelerator.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ACCELERATOR_H diff --git a/src/goto-instrument/accelerate/all_paths_enumerator.cpp b/src/goto-instrument/accelerate/all_paths_enumerator.cpp index 5ec92bc49f5..b8db795bdfd 100644 --- a/src/goto-instrument/accelerate/all_paths_enumerator.cpp +++ b/src/goto-instrument/accelerate/all_paths_enumerator.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include "all_paths_enumerator.h" diff --git a/src/goto-instrument/accelerate/all_paths_enumerator.h b/src/goto-instrument/accelerate/all_paths_enumerator.h index 3bd1b6b9ac6..8f8d37b84f3 100644 --- a/src/goto-instrument/accelerate/all_paths_enumerator.h +++ b/src/goto-instrument/accelerate/all_paths_enumerator.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ALL_PATHS_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ALL_PATHS_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/cone_of_influence.cpp b/src/goto-instrument/accelerate/cone_of_influence.cpp index e7689e6ed65..0f0b969e342 100644 --- a/src/goto-instrument/accelerate/cone_of_influence.cpp +++ b/src/goto-instrument/accelerate/cone_of_influence.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/cone_of_influence.h b/src/goto-instrument/accelerate/cone_of_influence.h index bc29c24d593..4c9ac072e38 100644 --- a/src/goto-instrument/accelerate/cone_of_influence.h +++ b/src/goto-instrument/accelerate/cone_of_influence.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_CONE_OF_INFLUENCE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_CONE_OF_INFLUENCE_H diff --git a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp index fe004b782d2..e2ede0567cb 100644 --- a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp +++ b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include #include diff --git a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h index 168c2c99888..bbf01917b5e 100644 --- a/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h +++ b/src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_DISJUNCTIVE_POLYNOMIAL_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_DISJUNCTIVE_POLYNOMIAL_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp b/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp index b514a2d4c88..d47c0c6287a 100644 --- a/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp +++ b/src/goto-instrument/accelerate/enumerating_loop_acceleration.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include "enumerating_loop_acceleration.h" diff --git a/src/goto-instrument/accelerate/enumerating_loop_acceleration.h b/src/goto-instrument/accelerate/enumerating_loop_acceleration.h index f84d3fbd23b..8c7d3614c32 100644 --- a/src/goto-instrument/accelerate/enumerating_loop_acceleration.h +++ b/src/goto-instrument/accelerate/enumerating_loop_acceleration.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_ENUMERATING_LOOP_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_ENUMERATING_LOOP_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/linearize.cpp b/src/goto-instrument/accelerate/linearize.cpp index 87c4db589cb..24d06e18559 100644 --- a/src/goto-instrument/accelerate/linearize.cpp +++ b/src/goto-instrument/accelerate/linearize.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include "linearize.h" #include diff --git a/src/goto-instrument/accelerate/linearize.h b/src/goto-instrument/accelerate/linearize.h index 90192ce1dfe..047937d0e76 100644 --- a/src/goto-instrument/accelerate/linearize.h +++ b/src/goto-instrument/accelerate/linearize.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_LINEARIZE_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_LINEARIZE_H diff --git a/src/goto-instrument/accelerate/loop_acceleration.h b/src/goto-instrument/accelerate/loop_acceleration.h index 67350ebf752..5cee315435a 100644 --- a/src/goto-instrument/accelerate/loop_acceleration.h +++ b/src/goto-instrument/accelerate/loop_acceleration.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_LOOP_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_LOOP_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/overflow_instrumenter.cpp b/src/goto-instrument/accelerate/overflow_instrumenter.cpp index efe9c978429..6e126aeb581 100644 --- a/src/goto-instrument/accelerate/overflow_instrumenter.cpp +++ b/src/goto-instrument/accelerate/overflow_instrumenter.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/overflow_instrumenter.h b/src/goto-instrument/accelerate/overflow_instrumenter.h index a20cd823031..718cff5c054 100644 --- a/src/goto-instrument/accelerate/overflow_instrumenter.h +++ b/src/goto-instrument/accelerate/overflow_instrumenter.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_OVERFLOW_INSTRUMENTER_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_OVERFLOW_INSTRUMENTER_H diff --git a/src/goto-instrument/accelerate/path.cpp b/src/goto-instrument/accelerate/path.cpp index effa48f7684..b0e176c5213 100644 --- a/src/goto-instrument/accelerate/path.cpp +++ b/src/goto-instrument/accelerate/path.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/path.h b/src/goto-instrument/accelerate/path.h index 7dae7fcf989..dc7249b3dc9 100644 --- a/src/goto-instrument/accelerate/path.h +++ b/src/goto-instrument/accelerate/path.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_H diff --git a/src/goto-instrument/accelerate/path_acceleration.h b/src/goto-instrument/accelerate/path_acceleration.h index 868dc3c6602..60898789349 100644 --- a/src/goto-instrument/accelerate/path_acceleration.h +++ b/src/goto-instrument/accelerate/path_acceleration.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ACCELERATION_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ACCELERATION_H diff --git a/src/goto-instrument/accelerate/path_enumerator.h b/src/goto-instrument/accelerate/path_enumerator.h index 8afe105272c..417d32d01e4 100644 --- a/src/goto-instrument/accelerate/path_enumerator.h +++ b/src/goto-instrument/accelerate/path_enumerator.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_PATH_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/polynomial.cpp b/src/goto-instrument/accelerate/polynomial.cpp index b37cfaafe82..3e51f25325c 100644 --- a/src/goto-instrument/accelerate/polynomial.cpp +++ b/src/goto-instrument/accelerate/polynomial.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/polynomial.h b/src/goto-instrument/accelerate/polynomial.h index ac8ceb05034..2e60953f02a 100644 --- a/src/goto-instrument/accelerate/polynomial.h +++ b/src/goto-instrument/accelerate/polynomial.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_H diff --git a/src/goto-instrument/accelerate/polynomial_accelerator.cpp b/src/goto-instrument/accelerate/polynomial_accelerator.cpp index 8df57513d1e..ccf24d6e475 100644 --- a/src/goto-instrument/accelerate/polynomial_accelerator.cpp +++ b/src/goto-instrument/accelerate/polynomial_accelerator.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include #include diff --git a/src/goto-instrument/accelerate/polynomial_accelerator.h b/src/goto-instrument/accelerate/polynomial_accelerator.h index 7530b66b849..b75b7fcae6f 100644 --- a/src/goto-instrument/accelerate/polynomial_accelerator.h +++ b/src/goto-instrument/accelerate/polynomial_accelerator.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_ACCELERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_POLYNOMIAL_ACCELERATOR_H diff --git a/src/goto-instrument/accelerate/sat_path_enumerator.cpp b/src/goto-instrument/accelerate/sat_path_enumerator.cpp index 505a281f73f..2a64a2d5949 100644 --- a/src/goto-instrument/accelerate/sat_path_enumerator.cpp +++ b/src/goto-instrument/accelerate/sat_path_enumerator.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include #include diff --git a/src/goto-instrument/accelerate/sat_path_enumerator.h b/src/goto-instrument/accelerate/sat_path_enumerator.h index c8b8b1747e9..61998bc3420 100644 --- a/src/goto-instrument/accelerate/sat_path_enumerator.h +++ b/src/goto-instrument/accelerate/sat_path_enumerator.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SAT_PATH_ENUMERATOR_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SAT_PATH_ENUMERATOR_H diff --git a/src/goto-instrument/accelerate/scratch_program.cpp b/src/goto-instrument/accelerate/scratch_program.cpp index 93c16f88489..c09410eb77d 100644 --- a/src/goto-instrument/accelerate/scratch_program.cpp +++ b/src/goto-instrument/accelerate/scratch_program.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/scratch_program.h b/src/goto-instrument/accelerate/scratch_program.h index da860f39e1a..2523a3184e3 100644 --- a/src/goto-instrument/accelerate/scratch_program.h +++ b/src/goto-instrument/accelerate/scratch_program.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SCRATCH_PROGRAM_H diff --git a/src/goto-instrument/accelerate/subsumed.h b/src/goto-instrument/accelerate/subsumed.h index abd2daea6f7..bcc30cdbc5e 100644 --- a/src/goto-instrument/accelerate/subsumed.h +++ b/src/goto-instrument/accelerate/subsumed.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_SUBSUMED_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_SUBSUMED_H diff --git a/src/goto-instrument/accelerate/trace_automaton.cpp b/src/goto-instrument/accelerate/trace_automaton.cpp index 6dbef396249..086b1be7d31 100644 --- a/src/goto-instrument/accelerate/trace_automaton.cpp +++ b/src/goto-instrument/accelerate/trace_automaton.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/trace_automaton.h b/src/goto-instrument/accelerate/trace_automaton.h index 6536193fb1d..5aa57841b3c 100644 --- a/src/goto-instrument/accelerate/trace_automaton.h +++ b/src/goto-instrument/accelerate/trace_automaton.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_TRACE_AUTOMATON_H diff --git a/src/goto-instrument/accelerate/util.cpp b/src/goto-instrument/accelerate/util.cpp index 7075d92558e..6ebd487c277 100644 --- a/src/goto-instrument/accelerate/util.cpp +++ b/src/goto-instrument/accelerate/util.cpp @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #include #include diff --git a/src/goto-instrument/accelerate/util.h b/src/goto-instrument/accelerate/util.h index 768a1b1bfe9..26c3eea0424 100644 --- a/src/goto-instrument/accelerate/util.h +++ b/src/goto-instrument/accelerate/util.h @@ -6,9 +6,6 @@ Author: Matt Lewis \*******************************************************************/ -/// \file -/// Loop Acceleration - #ifndef CPROVER_GOTO_INSTRUMENT_ACCELERATE_UTIL_H #define CPROVER_GOTO_INSTRUMENT_ACCELERATE_UTIL_H diff --git a/src/goto-instrument/alignment_checks.cpp b/src/goto-instrument/alignment_checks.cpp index a2bb369a04f..1418982cd8d 100644 --- a/src/goto-instrument/alignment_checks.cpp +++ b/src/goto-instrument/alignment_checks.cpp @@ -6,15 +6,24 @@ Module: Alignment Checks \*******************************************************************/ -/// \file -/// Alignment Checks - #include #include #include #include "alignment_checks.h" +/*******************************************************************\ + +Function: print_struct_alignment_problems + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void print_struct_alignment_problems( const symbol_tablet &symbol_table, std::ostream &out) diff --git a/src/goto-instrument/alignment_checks.h b/src/goto-instrument/alignment_checks.h index 43362cb95f8..37324939844 100644 --- a/src/goto-instrument/alignment_checks.h +++ b/src/goto-instrument/alignment_checks.h @@ -6,9 +6,6 @@ Module: Alignment Checks \*******************************************************************/ -/// \file -/// Alignment Checks - #ifndef CPROVER_GOTO_INSTRUMENT_ALIGNMENT_CHECKS_H #define CPROVER_GOTO_INSTRUMENT_ALIGNMENT_CHECKS_H diff --git a/src/goto-instrument/branch.cpp b/src/goto-instrument/branch.cpp index 689a9f48432..6bd6c64c72a 100644 --- a/src/goto-instrument/branch.cpp +++ b/src/goto-instrument/branch.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Branch Instrumentation - #include #include #include "function.h" #include "branch.h" +/*******************************************************************\ + +Function: branch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void branch( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/branch.h b/src/goto-instrument/branch.h index 842f3092b7a..acb014b1d93 100644 --- a/src/goto-instrument/branch.h +++ b/src/goto-instrument/branch.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Branch Instrumentation - #ifndef CPROVER_GOTO_INSTRUMENT_BRANCH_H #define CPROVER_GOTO_INSTRUMENT_BRANCH_H diff --git a/src/goto-instrument/call_sequences.cpp b/src/goto-instrument/call_sequences.cpp index 8a0ebddf4ed..d8c651bd1a7 100644 --- a/src/goto-instrument/call_sequences.cpp +++ b/src/goto-instrument/call_sequences.cpp @@ -8,9 +8,6 @@ Date: April 2013 \*******************************************************************/ -/// \file -/// Printing function call sequences for Ofer - #include #include #include @@ -20,6 +17,18 @@ Date: April 2013 #include "call_sequences.h" +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_call_sequences( const irep_idt &function, const goto_programt &goto_program, @@ -61,6 +70,18 @@ void show_call_sequences( } } +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_call_sequences( const irep_idt &function, const goto_programt &goto_program) @@ -97,6 +118,18 @@ void show_call_sequences( std::cout << std::endl; } +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_call_sequences(const goto_functionst &goto_functions) { // do per function @@ -105,6 +138,18 @@ void show_call_sequences(const goto_functionst &goto_functions) show_call_sequences(f_it->first, f_it->second.body); } +/*******************************************************************\ + +Function: check_call_sequence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class check_call_sequencet { public: @@ -281,6 +326,18 @@ void check_call_sequencet::operator()() std::cout << "sequence not feasible\n"; } +/*******************************************************************\ + +Function: check_call_sequence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void check_call_sequence(const goto_functionst &goto_functions) { // read the sequence from stdin @@ -300,6 +357,18 @@ void check_call_sequence(const goto_functionst &goto_functions) check_call_sequencet(goto_functions, sequence)(); } +/*******************************************************************\ + +Function: list_calls_and_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void list_calls_and_arguments( const namespacet &ns, const irep_idt &function, @@ -346,6 +415,18 @@ static void list_calls_and_arguments( } } +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void list_calls_and_arguments( const namespacet &ns, const goto_functionst &goto_functions) diff --git a/src/goto-instrument/call_sequences.h b/src/goto-instrument/call_sequences.h index 7d432ddbb4b..ecfc5921ef8 100644 --- a/src/goto-instrument/call_sequences.h +++ b/src/goto-instrument/call_sequences.h @@ -8,9 +8,6 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Memory-mapped I/O Instrumentation for Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H #define CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H diff --git a/src/goto-instrument/code_contracts.cpp b/src/goto-instrument/code_contracts.cpp index 963c90ef968..46914d78fb0 100644 --- a/src/goto-instrument/code_contracts.cpp +++ b/src/goto-instrument/code_contracts.cpp @@ -8,9 +8,6 @@ Date: February 2016 \*******************************************************************/ -/// \file -/// Verify and use annotated invariants and pre/post-conditions - #include #include #include @@ -62,6 +59,18 @@ class code_contractst const source_locationt &source_location); }; +/*******************************************************************\ + +Function: check_apply_invariants + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void check_apply_invariants( goto_functionst::goto_functiont &goto_function, const local_may_aliast &local_may_alias, @@ -160,6 +169,18 @@ static void check_apply_invariants( loop_end->guard.make_not(); } +/*******************************************************************\ + +Function: code_contractst::apply_contract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void code_contractst::apply_contract( goto_programt &goto_program, goto_programt::targett target) @@ -220,6 +241,18 @@ void code_contractst::apply_contract( summarized.insert(function); } +/*******************************************************************\ + +Function: code_contractst::code_contracts + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void code_contractst::code_contracts( goto_functionst::goto_functiont &goto_function) { @@ -243,6 +276,18 @@ void code_contractst::code_contracts( apply_contract(goto_function.body, it); } +/*******************************************************************\ + +Function: code_contractst::new_tmp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &code_contractst::new_tmp_symbol( const typet &type, const source_locationt &source_location) @@ -256,6 +301,18 @@ const symbolt &code_contractst::new_tmp_symbol( symbol_table); } +/*******************************************************************\ + +Function: code_contractst::add_contract_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void code_contractst::add_contract_check( const irep_idt &function, goto_programt &dest) @@ -379,6 +436,18 @@ void code_contractst::add_contract_check( dest.destructive_insert(dest.instructions.begin(), check); } +/*******************************************************************\ + +Function: code_contractst::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void code_contractst::operator()() { Forall_goto_functions(it, goto_functions) @@ -399,6 +468,18 @@ void code_contractst::operator()() goto_functions.update(); } +/*******************************************************************\ + +Function: code_contracts + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void code_contracts( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/code_contracts.h b/src/goto-instrument/code_contracts.h index 006f4702480..8886bd29545 100644 --- a/src/goto-instrument/code_contracts.h +++ b/src/goto-instrument/code_contracts.h @@ -8,9 +8,6 @@ Date: February 2016 \*******************************************************************/ -/// \file -/// Verify and use annotated invariants and pre/post-conditions - #ifndef CPROVER_GOTO_INSTRUMENT_CODE_CONTRACTS_H #define CPROVER_GOTO_INSTRUMENT_CODE_CONTRACTS_H diff --git a/src/goto-instrument/concurrency.cpp b/src/goto-instrument/concurrency.cpp index e04ff9c8695..69a6813a013 100644 --- a/src/goto-instrument/concurrency.cpp +++ b/src/goto-instrument/concurrency.cpp @@ -8,9 +8,6 @@ Date: October 2012 \*******************************************************************/ -/// \file -/// Encoding for Threaded Goto Programs - #include #include #include @@ -76,6 +73,18 @@ class concurrency_instrumentationt thread_local_varst thread_local_vars; }; +/*******************************************************************\ + +Function: concurrency_instrumentationt::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::instrument(exprt &expr) { std::set symbols; @@ -109,6 +118,18 @@ void concurrency_instrumentationt::instrument(exprt &expr) } } +/*******************************************************************\ + +Function: concurrency_instrumentationt::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::instrument( goto_programt &goto_program, const is_threadedt &is_threaded) @@ -137,6 +158,18 @@ void concurrency_instrumentationt::instrument( } } +/*******************************************************************\ + +Function: concurrency_instrumentationt::collect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::collect(const exprt &expr) { std::set symbols; @@ -179,6 +212,18 @@ void concurrency_instrumentationt::collect(const exprt &expr) } } +/*******************************************************************\ + +Function: concurrency_instrumentationt::collect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::collect( const goto_programt &goto_program, const is_threadedt &is_threaded) @@ -197,11 +242,35 @@ void concurrency_instrumentationt::collect( } } +/*******************************************************************\ + +Function: concurrency_instrumentationt::add_array_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::add_array_symbols() { // for( } +/*******************************************************************\ + +Function: concurrency_instrumentationt::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency_instrumentationt::instrument( goto_functionst &goto_functions) { @@ -220,6 +289,18 @@ void concurrency_instrumentationt::instrument( instrument(f_it->second.body, is_threaded); } +/*******************************************************************\ + +Function: concurrency + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void concurrency( value_setst &value_sets, class symbol_tablet &symbol_table, diff --git a/src/goto-instrument/concurrency.h b/src/goto-instrument/concurrency.h index cf09d4da68b..e751a62f3d4 100644 --- a/src/goto-instrument/concurrency.h +++ b/src/goto-instrument/concurrency.h @@ -8,9 +8,6 @@ Date: February 2006 \*******************************************************************/ -/// \file -/// Encoding for Threaded Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_CONCURRENCY_H #define CPROVER_GOTO_INSTRUMENT_CONCURRENCY_H diff --git a/src/goto-instrument/count_eloc.cpp b/src/goto-instrument/count_eloc.cpp index d986d335e9f..a54bc11f2ad 100644 --- a/src/goto-instrument/count_eloc.cpp +++ b/src/goto-instrument/count_eloc.cpp @@ -8,9 +8,6 @@ Date: December 2012 \*******************************************************************/ -/// \file -/// Count effective lines of code - #include #include @@ -25,6 +22,18 @@ typedef std::unordered_set linest; typedef std::unordered_map filest; typedef std::unordered_map working_dirst; +/*******************************************************************\ + +Function: collect_eloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void collect_eloc( const goto_functionst &goto_functions, working_dirst &dest) @@ -43,6 +52,18 @@ static void collect_eloc( } } +/*******************************************************************\ + +Function: count_eloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void count_eloc(const goto_functionst &goto_functions) { std::size_t eloc=0; @@ -57,6 +78,18 @@ void count_eloc(const goto_functionst &goto_functions) std::cout << "Effective lines of code: " << eloc << '\n'; } +/*******************************************************************\ + +Function: list_eloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void list_eloc(const goto_functionst &goto_functions) { working_dirst eloc_map; @@ -74,6 +107,18 @@ void list_eloc(const goto_functionst &goto_functions) } } +/*******************************************************************\ + +Function: print_path_lengths + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void print_path_lengths(const goto_functionst &goto_functions) { const irep_idt &entry_point=goto_functions.entry_point(); diff --git a/src/goto-instrument/count_eloc.h b/src/goto-instrument/count_eloc.h index 38760038836..87c1dea18ef 100644 --- a/src/goto-instrument/count_eloc.h +++ b/src/goto-instrument/count_eloc.h @@ -8,9 +8,6 @@ Date: December 2012 \*******************************************************************/ -/// \file -/// Count effective lines of code - #ifndef CPROVER_GOTO_INSTRUMENT_COUNT_ELOC_H #define CPROVER_GOTO_INSTRUMENT_COUNT_ELOC_H diff --git a/src/goto-instrument/cover.cpp b/src/goto-instrument/cover.cpp index a7c37f959ae..c3c5e0a5c06 100644 --- a/src/goto-instrument/cover.cpp +++ b/src/goto-instrument/cover.cpp @@ -8,9 +8,6 @@ Date: May 2016 \*******************************************************************/ -/// \file -/// Coverage Instrumentation - #include #include #include @@ -104,6 +101,18 @@ class basic_blockst } }; +/*******************************************************************\ + +Function: coverage_goalst::get_coverage + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool coverage_goalst::get_coverage_goals( const std::string &coverage_file, message_handlert &message_handler, @@ -156,11 +165,35 @@ bool coverage_goalst::get_coverage_goals( return false; } +/*******************************************************************\ + +Function: coverage_goalst::add_goal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void coverage_goalst::add_goal(source_locationt goal) { existing_goals.push_back(goal); } +/*******************************************************************\ + +Function: coverage_goalst::is_existing_goal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool coverage_goalst::is_existing_goal(source_locationt source_location) const { for(const auto &existing_loc : existing_goals) @@ -173,6 +206,18 @@ bool coverage_goalst::is_existing_goal(source_locationt source_location) const return false; } +/*******************************************************************\ + +Function: as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const char *as_string(coverage_criteriont c) { switch(c) @@ -189,6 +234,18 @@ const char *as_string(coverage_criteriont c) } } +/*******************************************************************\ + +Function: is_condition + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_condition(const exprt &src) { if(src.type().id()!=ID_bool) @@ -202,6 +259,18 @@ bool is_condition(const exprt &src) return true; } +/*******************************************************************\ + +Function: collect_conditions_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void collect_conditions_rec(const exprt &src, std::set &dest) { if(src.id()==ID_address_of) @@ -216,6 +285,18 @@ void collect_conditions_rec(const exprt &src, std::set &dest) dest.insert(src); } +/*******************************************************************\ + +Function: collect_conditions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set collect_conditions(const exprt &src) { std::set result; @@ -223,6 +304,18 @@ std::set collect_conditions(const exprt &src) return result; } +/*******************************************************************\ + +Function: collect_conditions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set collect_conditions(const goto_programt::const_targett t) { switch(t->type) @@ -243,6 +336,18 @@ std::set collect_conditions(const goto_programt::const_targett t) return std::set(); } +/*******************************************************************\ + +Function: collect_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void collect_operands(const exprt &src, std::vector &dest) { for(const exprt &op : src.operands()) @@ -254,7 +359,19 @@ void collect_operands(const exprt &src, std::vector &dest) } } -/// To recursively collect controlling exprs for for mcdc coverage. +/*******************************************************************\ + +Function: collect_mcdc_controlling_rec + + Inputs: + + Outputs: + + Purpose: To recursively collect controlling exprs for + for mcdc coverage. + +\*******************************************************************/ + void collect_mcdc_controlling_rec( const exprt &src, const std::vector &conditions, @@ -365,6 +482,18 @@ void collect_mcdc_controlling_rec( } } +/*******************************************************************\ + +Function: collect_mcdc_controlling + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set collect_mcdc_controlling( const std::set &decisions) { @@ -376,8 +505,19 @@ std::set collect_mcdc_controlling( return result; } -/// To replace the i-th expr of ''operands'' with each expr inside -/// ''replacement_exprs''. +/*******************************************************************\ + +Function: replacement_conjunction + + Inputs: + + Outputs: + + Purpose: To replace the i-th expr of ''operands'' with each + expr inside ''replacement_exprs''. + +\*******************************************************************/ + std::set replacement_conjunction( const std::set &replacement_exprs, const std::vector &operands, @@ -398,8 +538,20 @@ std::set replacement_conjunction( return result; } -/// This nested method iteratively applies ''collect_mcdc_controlling'' to every -/// non-atomic expr within a decision +/*******************************************************************\ + +Function: collect_mcdc_controlling_nested + + Inputs: + + Outputs: + + Purpose: This nested method iteratively applies + ''collect_mcdc_controlling'' to every non-atomic expr + within a decision + +\*******************************************************************/ + std::set collect_mcdc_controlling_nested( const std::set &decisions) { @@ -493,10 +645,20 @@ std::set collect_mcdc_controlling_nested( return result; } -/// The sign of expr ''e'' within the super-expr ''E'' -/// \par parameters: E should be the pre-processed output by -/// ''collect_mcdc_controlling_nested'' -/// \return +1 : not negated -1 : negated +/*******************************************************************\ + +Function: sign_of_expr + + Inputs: E should be the pre-processed output by + ''collect_mcdc_controlling_nested'' + + Outputs: +1 : not negated + -1 : negated + + Purpose: The sign of expr ''e'' within the super-expr ''E'' + +\*******************************************************************/ + std::set sign_of_expr(const exprt &e, const exprt &E) { std::set signs; @@ -551,9 +713,21 @@ std::set sign_of_expr(const exprt &e, const exprt &E) return signs; } -/// After the ''collect_mcdc_controlling_nested'', there can be the recurrence -/// of the same expr in the resulted set of exprs, and this method will remove -/// the repetitive ones. +/*******************************************************************\ + +Function: remove_repetition + + Inputs: + + Outputs: + + Purpose: After the ''collect_mcdc_controlling_nested'', there + can be the recurrence of the same expr in the resulted + set of exprs, and this method will remove the + repetitive ones. + +\*******************************************************************/ + void remove_repetition(std::set &exprs) { // to obtain the set of atomic conditions @@ -640,7 +814,19 @@ void remove_repetition(std::set &exprs) exprs=new_exprs; } -/// To evaluate the value of expr ''src'', according to the atomic expr values +/*******************************************************************\ + +Function: eval_expr + + Inputs: + + Outputs: + + Purpose: To evaluate the value of expr ''src'', according to + the atomic expr values + +\*******************************************************************/ + bool eval_expr( const std::map &atomic_exprs, const exprt &src) @@ -687,7 +873,18 @@ bool eval_expr( } } -/// To obtain values of atomic exprs within the super expr +/*******************************************************************\ + +Function: values_of_atomic_exprs + + Inputs: + + Outputs: + + Purpose: To obtain values of atomic exprs within the super expr + +\*******************************************************************/ + std::map values_of_atomic_exprs( const exprt &e, const std::set &conditions) @@ -712,10 +909,22 @@ std::map values_of_atomic_exprs( return atomic_exprs; } -/// To check if the two input controlling exprs are mcdc pairs regarding an -/// atomic expr ''c''. A mcdc pair of (e1, e2) regarding ''c'' means that ''e1'' -/// and ''e2'' result in different ''decision'' values, and this is caused by -/// the different choice of ''c'' value. +/*******************************************************************\ + +Function: is_mcdc_pair + + Inputs: + + Outputs: + + Purpose: To check if the two input controlling exprs are mcdc + pairs regarding an atomic expr ''c''. A mcdc pair of + (e1, e2) regarding ''c'' means that ''e1'' and ''e2'' + result in different ''decision'' values, and this is + caused by the different choice of ''c'' value. + +\*******************************************************************/ + bool is_mcdc_pair( const exprt &e1, const exprt &e2, @@ -776,8 +985,19 @@ bool is_mcdc_pair( return false; } -/// To check if we can find the mcdc pair of the input ''expr_set'' regarding -/// the atomic expr ''c'' +/*******************************************************************\ + +Function: has_mcdc_pair + + Inputs: + + Outputs: + + Purpose: To check if we can find the mcdc pair of the + input ''expr_set'' regarding the atomic expr ''c'' + +\*******************************************************************/ + bool has_mcdc_pair( const exprt &c, const std::set &expr_set, @@ -797,12 +1017,24 @@ bool has_mcdc_pair( return false; } -/// This method minimizes the controlling conditions for mcdc coverage. The -/// minimum is in a sense that by deleting any controlling condition in the set, -/// the mcdc coverage for the decision will be not complete. -/// \par parameters: The input ''controlling'' should have been processed by -/// ''collect_mcdc_controlling_nested'' and -/// ''remove_repetition'' +/*******************************************************************\ + +Function: minimize_mcdc_controlling + + Inputs: The input ''controlling'' should have been processed by + ''collect_mcdc_controlling_nested'' + and + ''remove_repetition'' + + Outputs: + + Purpose: This method minimizes the controlling conditions for + mcdc coverage. The minimum is in a sense that by deleting + any controlling condition in the set, the mcdc coverage + for the decision will be not complete. + +\*******************************************************************/ + void minimize_mcdc_controlling( std::set &controlling, const exprt &decision) @@ -880,6 +1112,18 @@ void minimize_mcdc_controlling( } } +/*******************************************************************\ + +Function: collect_decisions_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void collect_decisions_rec(const exprt &src, std::set &dest) { if(src.id()==ID_address_of) @@ -909,6 +1153,18 @@ void collect_decisions_rec(const exprt &src, std::set &dest) } } +/*******************************************************************\ + +Function: collect_decisions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set collect_decisions(const exprt &src) { std::set result; @@ -916,6 +1172,18 @@ std::set collect_decisions(const exprt &src) return result; } +/*******************************************************************\ + +Function: collect_decisions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set collect_decisions(const goto_programt::const_targett t) { switch(t->type) @@ -936,6 +1204,18 @@ std::set collect_decisions(const goto_programt::const_targett t) return std::set(); } +/*******************************************************************\ + +Function: instrument_cover_goals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrument_cover_goals( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -952,10 +1232,21 @@ void instrument_cover_goals( false); } -/// Call a goto_program trivial unless it has: * Any declarations * At least 2 -/// branches * At least 5 assignments -/// \par parameters: Program `goto_program` -/// \return Returns true if trivial +/*******************************************************************\ + +Function: program_is_trivial + + Inputs: Program `goto_program` + + Outputs: Returns true if trivial + + Purpose: Call a goto_program trivial unless it has: + * Any declarations + * At least 2 branches + * At least 5 assignments + +\*******************************************************************/ + bool program_is_trivial(const goto_programt &goto_program) { unsigned long count_assignments=0, count_goto=0; @@ -978,6 +1269,18 @@ bool program_is_trivial(const goto_programt &goto_program) return true; } +/*******************************************************************\ + +Function: instrument_cover_goals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrument_cover_goals( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -1322,6 +1625,18 @@ void instrument_cover_goals( } } +/*******************************************************************\ + +Function: instrument_cover_goals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrument_cover_goals( const symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -1347,6 +1662,18 @@ void instrument_cover_goals( } } +/*******************************************************************\ + +Function: instrument_cover_goals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrument_cover_goals( const symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -1364,6 +1691,18 @@ void instrument_cover_goals( false); } +/*******************************************************************\ + +Function: instrument_cover_goals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool instrument_cover_goals( const cmdlinet &cmdline, const symbol_tablet &symbol_table, diff --git a/src/goto-instrument/cover.h b/src/goto-instrument/cover.h index 06fc0ede321..28d057ea43a 100644 --- a/src/goto-instrument/cover.h +++ b/src/goto-instrument/cover.h @@ -8,9 +8,6 @@ Date: May 2016 \*******************************************************************/ -/// \file -/// Coverage Instrumentation - #ifndef CPROVER_GOTO_INSTRUMENT_COVER_H #define CPROVER_GOTO_INSTRUMENT_COVER_H diff --git a/src/goto-instrument/document_properties.cpp b/src/goto-instrument/document_properties.cpp index 4e0a07f89f2..183caa6fdb9 100644 --- a/src/goto-instrument/document_properties.cpp +++ b/src/goto-instrument/document_properties.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Subgoal Documentation - #include #include @@ -68,6 +65,18 @@ class document_propertiest void doit(); }; +/*******************************************************************\ + +Function: document_propertiest::strip_space + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void document_propertiest::strip_space(std::list &lines) { unsigned strip=50; @@ -97,6 +106,18 @@ void document_propertiest::strip_space(std::list &lines) } } +/*******************************************************************\ + +Function: escape_latex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string escape_latex(const std::string &s, bool alltt) { std::string dest; @@ -118,6 +139,18 @@ std::string escape_latex(const std::string &s, bool alltt) return dest; } +/*******************************************************************\ + +Function: escape_html + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string escape_html(const std::string &s) { std::string dest; @@ -136,6 +169,18 @@ std::string escape_html(const std::string &s) return dest; } +/*******************************************************************\ + +Function: is_empty + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_empty(const std::string &s) { for(unsigned i=0; i claim_sett; @@ -359,6 +428,18 @@ void document_propertiest::doit() } } +/*******************************************************************\ + +Function: document_properties_html + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void document_properties_html( const goto_functionst &goto_functions, std::ostream &out) @@ -366,6 +447,18 @@ void document_properties_html( document_propertiest(goto_functions, out).html(); } +/*******************************************************************\ + +Function: document_properties_latex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void document_properties_latex( const goto_functionst &goto_functions, std::ostream &out) diff --git a/src/goto-instrument/document_properties.h b/src/goto-instrument/document_properties.h index 35406ae2f30..deeae63b645 100644 --- a/src/goto-instrument/document_properties.h +++ b/src/goto-instrument/document_properties.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Documentation of Properties - #ifndef CPROVER_GOTO_INSTRUMENT_DOCUMENT_PROPERTIES_H #define CPROVER_GOTO_INSTRUMENT_DOCUMENT_PROPERTIES_H diff --git a/src/goto-instrument/dot.cpp b/src/goto-instrument/dot.cpp index 4f56ca26337..455381c4c51 100644 --- a/src/goto-instrument/dot.cpp +++ b/src/goto-instrument/dot.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dump Goto-Program as DOT Graph - #include #include #include @@ -65,10 +62,19 @@ class dott std::set &); }; -/// writes the dot graph that corresponds to the goto program to the output -/// stream. -/// \par parameters: output stream, name and goto program -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: dott::write_dot_subgraph + + Inputs: output stream, name and goto program + + Outputs: true on error, false otherwise + + Purpose: writes the dot graph that corresponds to the goto program + to the output stream. + +\*******************************************************************/ + void dott::write_dot_subgraph( std::ostream &out, const std::string &name, @@ -220,6 +226,18 @@ void dott::write_dot_subgraph( subgraphscount++; } +/*******************************************************************\ + +Function: dott::do_dot_function_calls + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dott::do_dot_function_calls( std::ostream &out) { @@ -259,6 +277,18 @@ void dott::do_dot_function_calls( } } +/*******************************************************************\ + +Function: dott::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dott::output(std::ostream &out) { out << "digraph G {" << std::endl; @@ -275,9 +305,19 @@ void dott::output(std::ostream &out) out << "}" << std::endl; } -/// escapes a string. beware, this might not work for all kinds of strings. -/// \par parameters: a string -/// \return the escaped string +/*******************************************************************\ + +Function: dott::escape + + Inputs: a string + + Outputs: the escaped string + + Purpose: escapes a string. beware, this might not work for all + kinds of strings. + +\*******************************************************************/ + std::string &dott::escape(std::string &str) { for(std::string::size_type i=0; i #include @@ -27,12 +24,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "dump_c.h" +/*******************************************************************\ + +Function: operator<< + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + inline std::ostream &operator << (std::ostream &out, dump_ct &src) { src(out); return out; } +/*******************************************************************\ + +Function: dump_ct::operator() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::operator()(std::ostream &os) { std::stringstream func_decl_stream; @@ -274,7 +295,18 @@ void dump_ct::operator()(std::ostream &os) os << func_body_stream.str(); } -/// declare compound types +/*******************************************************************\ + +Function: dump_ct::convert_compound_declarations + +Inputs: + +Outputs: + +Purpose: declare compound types + +\*******************************************************************/ + void dump_ct::convert_compound_declaration( const symbolt &symbol, std::ostream &os_body) @@ -289,6 +321,18 @@ void dump_ct::convert_compound_declaration( convert_compound(symbol.type, symbol_typet(symbol.name), true, os_body); } +/*******************************************************************\ + +Function: dump_ct::convert_compound + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::convert_compound( const typet &type, const typet &unresolved, @@ -342,6 +386,18 @@ void dump_ct::convert_compound( convert_compound_enum(type, os); } +/*******************************************************************\ + +Function: dump_ct::convert_compound + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::convert_compound( const struct_union_typet &type, const typet &unresolved, @@ -498,6 +554,18 @@ void dump_ct::convert_compound( os << std::endl; } +/*******************************************************************\ + +Function: dump_ct::convert_compound_enum + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::convert_compound_enum( const typet &type, std::ostream &os) @@ -541,6 +609,18 @@ void dump_ct::convert_compound_enum( os << ";\n\n"; } +/*******************************************************************\ + +Function: dump_ct::cleanup_decl + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::cleanup_decl( code_declt &decl, std::list &local_static, @@ -581,6 +661,18 @@ void dump_ct::cleanup_decl( decl.swap(b.op0()); } +/*******************************************************************\ + +Function: dump_ct::convert_global_variables + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::convert_global_variable( const symbolt &symbol, std::ostream &os, @@ -644,6 +736,18 @@ void dump_ct::convert_global_variable( } } +/*******************************************************************\ + +Function: dump_ct::convert_function_declarations + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::convert_function_declaration( const symbolt &symbol, const bool skip_main, @@ -712,6 +816,18 @@ void dump_ct::convert_function_declaration( } } +/*******************************************************************\ + +Function: find_block_position_rec + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static bool find_block_position_rec( const irep_idt &identifier, codet &root, @@ -791,6 +907,18 @@ static bool find_block_position_rec( return false; } +/*******************************************************************\ + +Function: dump_ct::insert_local_static_decls + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::insert_local_static_decls( code_blockt &b, const std::list &local_static, @@ -825,6 +953,18 @@ void dump_ct::insert_local_static_decls( } } +/*******************************************************************\ + +Function: dump_ct::insert_local_type_decls + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::insert_local_type_decls( code_blockt &b, const std::list &type_decls) @@ -862,6 +1002,18 @@ void dump_ct::insert_local_type_decls( } } +/*******************************************************************\ + +Function: dump_ct::cleanup_expr + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::cleanup_expr(exprt &expr) { Forall_operands(it, expr) @@ -1009,6 +1161,18 @@ void dump_ct::cleanup_expr(exprt &expr) } } +/*******************************************************************\ + +Function: dump_ct::cleanup_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void dump_ct::cleanup_type(typet &type) { Forall_subtypes(it, type) @@ -1034,6 +1198,18 @@ void dump_ct::cleanup_type(typet &type) !type.get(ID_tag).empty()); } +/*******************************************************************\ + +Function: dump_ct::type_to_string + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + std::string dump_ct::type_to_string(const typet &type) { std::string ret; @@ -1043,6 +1219,18 @@ std::string dump_ct::type_to_string(const typet &type) return ret; } +/*******************************************************************\ + +Function: dump_ct::expr_to_string + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + std::string dump_ct::expr_to_string(const exprt &expr) { std::string ret; @@ -1052,6 +1240,18 @@ std::string dump_ct::expr_to_string(const exprt &expr) return ret; } +/*******************************************************************\ + +Function: dump_c + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dump_c( const goto_functionst &src, const bool use_system_headers, @@ -1062,6 +1262,18 @@ void dump_c( out << goto2c; } +/*******************************************************************\ + +Function: dump_cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dump_cpp( const goto_functionst &src, const bool use_system_headers, diff --git a/src/goto-instrument/dump_c.h b/src/goto-instrument/dump_c.h index 263165aec97..ff0efd496a6 100644 --- a/src/goto-instrument/dump_c.h +++ b/src/goto-instrument/dump_c.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dump C from Goto Program - #ifndef CPROVER_GOTO_INSTRUMENT_DUMP_C_H #define CPROVER_GOTO_INSTRUMENT_DUMP_C_H diff --git a/src/goto-instrument/dump_c_class.h b/src/goto-instrument/dump_c_class.h index 4f47cd4cad4..c8c77da5102 100644 --- a/src/goto-instrument/dump_c_class.h +++ b/src/goto-instrument/dump_c_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dump Goto-Program as C/C++ Source - #ifndef CPROVER_GOTO_INSTRUMENT_DUMP_C_CLASS_H #define CPROVER_GOTO_INSTRUMENT_DUMP_C_CLASS_H diff --git a/src/goto-instrument/full_slicer.cpp b/src/goto-instrument/full_slicer.cpp index ca8de0f2cf7..887805ad80a 100644 --- a/src/goto-instrument/full_slicer.cpp +++ b/src/goto-instrument/full_slicer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicing - #include #include #ifdef DEBUG_FULL_SLICERT @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "full_slicer_class.h" +/*******************************************************************\ + +Function: full_slicert::add_dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::add_dependencies( const cfgt::nodet &node, queuet &queue, @@ -34,6 +43,18 @@ void full_slicert::add_dependencies( add_to_queue(queue, dep_node_to_cfg[it->first], node.PC); } +/*******************************************************************\ + +Function: full_slicert::add_dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::add_function_calls( const cfgt::nodet &node, queuet &queue, @@ -58,6 +79,18 @@ void full_slicert::add_function_calls( add_to_queue(queue, it->first, node.PC); } +/*******************************************************************\ + +Function: full_slicert::add_decl_dead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::add_decl_dead( const cfgt::nodet &node, queuet &queue, @@ -89,6 +122,18 @@ void full_slicert::add_decl_dead( } } +/*******************************************************************\ + +Function: full_slicert::add_jumps + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::add_jumps( queuet &queue, jumpst &jumps, @@ -212,6 +257,18 @@ void full_slicert::add_jumps( } } +/*******************************************************************\ + +Function: full_slicert::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::fixedpoint( goto_functionst &goto_functions, queuet &queue, @@ -261,6 +318,18 @@ void full_slicert::fixedpoint( } } +/*******************************************************************\ + +Function: implicit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool implicit(goto_programt::const_targett target) { // some variables are used during symbolic execution only @@ -281,6 +350,18 @@ static bool implicit(goto_programt::const_targett target) return s.get_identifier()==CPROVER_PREFIX "rounding_mode"; } +/*******************************************************************\ + +Function: full_slicert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicert::operator()( goto_functionst &goto_functions, const namespacet &ns, @@ -365,6 +446,18 @@ void full_slicert::operator()( goto_functions.update(); } +/*******************************************************************\ + +Function: full_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicer( goto_functionst &goto_functions, const namespacet &ns, @@ -373,6 +466,18 @@ void full_slicer( full_slicert()(goto_functions, ns, criterion); } +/*******************************************************************\ + +Function: full_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void full_slicer( goto_functionst &goto_functions, const namespacet &ns) @@ -381,6 +486,18 @@ void full_slicer( full_slicert()(goto_functions, ns, a); } +/*******************************************************************\ + +Function: property_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void property_slicer( goto_functionst &goto_functions, const namespacet &ns, @@ -390,6 +507,18 @@ void property_slicer( full_slicert()(goto_functions, ns, p); } +/*******************************************************************\ + +Function: slicing_criteriont::~slicing_criteriont + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + slicing_criteriont::~slicing_criteriont() { } diff --git a/src/goto-instrument/full_slicer.h b/src/goto-instrument/full_slicer.h index 9e39786c5a2..d590025c8c4 100644 --- a/src/goto-instrument/full_slicer.h +++ b/src/goto-instrument/full_slicer.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicing - #ifndef CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H #define CPROVER_GOTO_INSTRUMENT_FULL_SLICER_H diff --git a/src/goto-instrument/full_slicer_class.h b/src/goto-instrument/full_slicer_class.h index de1c50b54f4..93894513f57 100644 --- a/src/goto-instrument/full_slicer_class.h +++ b/src/goto-instrument/full_slicer_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto Program Slicing - #ifndef CPROVER_GOTO_INSTRUMENT_FULL_SLICER_CLASS_H #define CPROVER_GOTO_INSTRUMENT_FULL_SLICER_CLASS_H @@ -35,6 +32,14 @@ echo 'digraph g {' > c.dot ; cat c.goto | \ dot -Tpdf -oc-red.pdf c-red.dot #endif +/*******************************************************************\ + + Class: full_slicert + + Purpose: + +\*******************************************************************/ + class full_slicert { public: diff --git a/src/goto-instrument/function.cpp b/src/goto-instrument/function.cpp index 77eae15902a..1ad749814bd 100644 --- a/src/goto-instrument/function.cpp +++ b/src/goto-instrument/function.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Entering and Exiting - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "function.h" +/*******************************************************************\ + +Function: function_to_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + code_function_callt function_to_call( symbol_tablet &symbol_table, const irep_idt &id, @@ -78,6 +87,18 @@ code_function_callt function_to_call( return call; } +/*******************************************************************\ + +Function: function_enter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void function_enter( symbol_tablet &symbol_table, goto_functionst &goto_functions, @@ -105,6 +126,18 @@ void function_enter( } } +/*******************************************************************\ + +Function: function_exit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void function_exit( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/function.h b/src/goto-instrument/function.h index 88b486df6b0..207555a7cb5 100644 --- a/src/goto-instrument/function.h +++ b/src/goto-instrument/function.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Entering and Exiting - #ifndef CPROVER_GOTO_INSTRUMENT_FUNCTION_H #define CPROVER_GOTO_INSTRUMENT_FUNCTION_H diff --git a/src/goto-instrument/function_modifies.cpp b/src/goto-instrument/function_modifies.cpp index f4d18c4a1e7..0d5148c92c8 100644 --- a/src/goto-instrument/function_modifies.cpp +++ b/src/goto-instrument/function_modifies.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Modifies - #include #include "function_modifies.h" +/*******************************************************************\ + +Function: function_modifiest::get_modifies_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void function_modifiest::get_modifies_lhs( const local_may_aliast &local_may_alias, const goto_programt::const_targett t, @@ -42,6 +51,18 @@ void function_modifiest::get_modifies_lhs( } } +/*******************************************************************\ + +Function: function_modifiest::get_modifies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void function_modifiest::get_modifies( const local_may_aliast &local_may_alias, const goto_programt::const_targett i_it, @@ -69,6 +90,18 @@ void function_modifiest::get_modifies( } } +/*******************************************************************\ + +Function: function_modifiest::get_modifies_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void function_modifiest::get_modifies_function( const exprt &function, modifiest &modifies) diff --git a/src/goto-instrument/function_modifies.h b/src/goto-instrument/function_modifies.h index 64becb1412c..b4f44cda6d3 100644 --- a/src/goto-instrument/function_modifies.h +++ b/src/goto-instrument/function_modifies.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Modifies - #ifndef CPROVER_GOTO_INSTRUMENT_FUNCTION_MODIFIES_H #define CPROVER_GOTO_INSTRUMENT_FUNCTION_MODIFIES_H diff --git a/src/goto-instrument/goto_instrument_languages.cpp b/src/goto-instrument/goto_instrument_languages.cpp index 2193318b136..4cc03bca860 100644 --- a/src/goto-instrument/goto_instrument_languages.cpp +++ b/src/goto-instrument/goto_instrument_languages.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Language Registration - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_instrument_parse_options.h" +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::register_languages() { register_language(new_ansi_c_language); diff --git a/src/goto-instrument/goto_instrument_main.cpp b/src/goto-instrument/goto_instrument_main.cpp index fb394efbb3d..f25cbbcf9d8 100644 --- a/src/goto-instrument/goto_instrument_main.cpp +++ b/src/goto-instrument/goto_instrument_main.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Main Module - #include #include "goto_instrument_parse_options.h" +/*******************************************************************\ + +Function: main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 94de6aebc4f..bebf863c862 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Main Module - #include #include #include @@ -94,6 +91,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "model_argc_argv.h" #include "undefined_functions.h" +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::eval_verbosity() { unsigned int v=8; @@ -108,7 +117,18 @@ void goto_instrument_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } -/// invoke main modules +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int goto_instrument_parse_optionst::doit() { if(cmdline.isset("version")) @@ -794,6 +814,18 @@ int goto_instrument_parse_optionst::doit() } } +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( bool force) { @@ -816,9 +848,21 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( remove_instanceof(symbol_table, goto_functions); } -/// Remove function pointers that can be resolved by analysing const variables -/// (i.e. can be resolved using remove_const_function_pointers). Function -/// pointers that cannot be resolved will be left as function pointers. +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::do_remove_const_function_pointers_only + + Inputs: + + Outputs: + + Purpose: Remove function pointers that can be resolved by analysing + const variables (i.e. can be resolved using + remove_const_function_pointers). Function pointers that cannot + be resolved will be left as function pointers. + +\*******************************************************************/ + void goto_instrument_parse_optionst::do_remove_const_function_pointers_only() { // Don't bother if we've already done a full function pointer @@ -837,6 +881,18 @@ void goto_instrument_parse_optionst::do_remove_const_function_pointers_only() true); // abort if we can't resolve via const pointers } +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::do_partial_inlining + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::do_partial_inlining() { if(partial_inlining_done) @@ -852,6 +908,18 @@ void goto_instrument_parse_optionst::do_partial_inlining() } } +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::do_remove_returns + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::do_remove_returns() { if(remove_returns_done) @@ -863,6 +931,18 @@ void goto_instrument_parse_optionst::do_remove_returns() remove_returns(symbol_table, goto_functions); } +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::get_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::get_goto_program() { status() << "Reading GOTO program from `" << cmdline.args[0] << "'" << eom; @@ -875,6 +955,18 @@ void goto_instrument_parse_optionst::get_goto_program() config.set_from_symbol_table(symbol_table); } +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::instrument_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_instrument_parse_optionst::instrument_goto_program() { optionst options; @@ -1437,7 +1529,18 @@ void goto_instrument_parse_optionst::instrument_goto_program() goto_functions.update(); } -/// display command line help +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void goto_instrument_parse_optionst::help() { std::cout << diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index 5d695c202e0..788bf543953 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Command Line Parsing - #ifndef CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H #define CPROVER_GOTO_INSTRUMENT_GOTO_INSTRUMENT_PARSE_OPTIONS_H diff --git a/src/goto-instrument/goto_program2code.cpp b/src/goto-instrument/goto_program2code.cpp index 8bb99be23c4..400aca3b407 100644 --- a/src/goto-instrument/goto_program2code.cpp +++ b/src/goto-instrument/goto_program2code.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dump Goto-Program as C/C++ Source - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program2code.h" +/*******************************************************************\ + +Function: skip_typecast + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static const exprt &skip_typecast(const exprt &expr) { if(expr.id()!=ID_typecast) @@ -28,6 +37,18 @@ static const exprt &skip_typecast(const exprt &expr) return skip_typecast(to_typecast_expr(expr).op()); } +/*******************************************************************\ + +Function: goto_program2codet::operator() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::operator()() { // labels stored for cleanup @@ -55,6 +76,18 @@ void goto_program2codet::operator()() cleanup_code(toplevel_block, ID_nil); } +/*******************************************************************\ + +Function: goto_program2codet::build_loop_map + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::build_loop_map() { loop_map.clear(); @@ -91,6 +124,18 @@ void goto_program2codet::build_loop_map() } } +/*******************************************************************\ + +Function: goto_program2codet::build_dead_map + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::build_dead_map() { dead_map.clear(); @@ -102,6 +147,18 @@ void goto_program2codet::build_dead_map() target->location_number; } +/*******************************************************************\ + +Function: goto_program2codet::scan_for_varargs + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::scan_for_varargs() { va_list_expr.clear(); @@ -143,6 +200,18 @@ void goto_program2codet::scan_for_varargs() } } +/*******************************************************************\ + +Function: goto_program2codet::convert_instruction + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_instruction( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -247,6 +316,18 @@ goto_programt::const_targett goto_program2codet::convert_instruction( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_labels + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::convert_labels( goto_programt::const_targett target, codet &dest) @@ -289,6 +370,18 @@ void goto_program2codet::convert_labels( latest_block->copy_to_operands(code_skipt()); } +/*******************************************************************\ + +Function: goto_program2codet::convert_assign + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_assign( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -304,6 +397,18 @@ goto_programt::const_targett goto_program2codet::convert_assign( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_assign_varargs + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_assign_varargs( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -399,6 +504,18 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_assign_rec + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::convert_assign_rec( const code_assignt &assign, codet &dest) @@ -422,6 +539,18 @@ void goto_program2codet::convert_assign_rec( dest.copy_to_operands(assign); } +/*******************************************************************\ + +Function: goto_program2codet::convert_return + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_return( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -452,6 +581,18 @@ goto_programt::const_targett goto_program2codet::convert_return( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_decl + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_decl( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -514,6 +655,18 @@ goto_programt::const_targett goto_program2codet::convert_decl( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_do_while + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_do_while( goto_programt::const_targett target, goto_programt::const_targett loop_end, @@ -539,6 +692,18 @@ goto_programt::const_targett goto_program2codet::convert_do_while( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -562,6 +727,18 @@ goto_programt::const_targett goto_program2codet::convert_goto( return convert_goto_goto(target, dest); } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto_while + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto_while( goto_programt::const_targett target, goto_programt::const_targett loop_end, @@ -661,6 +838,18 @@ goto_programt::const_targett goto_program2codet::convert_goto_while( return target; } +/*******************************************************************\ + +Function: goto_program2codet::get_cases + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::get_cases( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -763,6 +952,18 @@ goto_programt::const_targett goto_program2codet::get_cases( return cases_it; } +/*******************************************************************\ + +Function: goto_program2codet::set_block_end_points + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool goto_program2codet::set_block_end_points( goto_programt::const_targett upper_bound, const cfg_dominatorst &dominators, @@ -813,6 +1014,18 @@ bool goto_program2codet::set_block_end_points( return false; } +/*******************************************************************\ + +Function: goto_program2codet::remove_default + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + bool goto_program2codet::remove_default( const cfg_dominatorst &dominators, const cases_listt &cases, @@ -875,6 +1088,18 @@ bool goto_program2codet::remove_default( return false; } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto_switch + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto_switch( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1054,6 +1279,18 @@ goto_programt::const_targett goto_program2codet::convert_goto_switch( return max_target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto_if + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto_if( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1130,6 +1367,18 @@ goto_programt::const_targett goto_program2codet::convert_goto_if( return --target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto_break_continue + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto_break_continue( goto_programt::const_targett target, codet &dest) @@ -1218,6 +1467,18 @@ goto_programt::const_targett goto_program2codet::convert_goto_break_continue( return convert_goto_goto(target, dest); } +/*******************************************************************\ + +Function: goto_program2codet::convert_goto_goto + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_goto_goto( goto_programt::const_targett target, codet &dest) @@ -1277,6 +1538,18 @@ goto_programt::const_targett goto_program2codet::convert_goto_goto( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_start_thread + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_start_thread( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1395,6 +1668,18 @@ goto_programt::const_targett goto_program2codet::convert_start_thread( return thread_end; } +/*******************************************************************\ + +Function: goto_program2codet::convert_throw + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_throw( goto_programt::const_targett target, codet &dest) @@ -1404,6 +1689,18 @@ goto_programt::const_targett goto_program2codet::convert_throw( return target; } +/*******************************************************************\ + +Function: goto_program2codet::convert_catch + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + goto_programt::const_targett goto_program2codet::convert_catch( goto_programt::const_targett target, goto_programt::const_targett upper_bound, @@ -1414,6 +1711,18 @@ goto_programt::const_targett goto_program2codet::convert_catch( return target; } +/*******************************************************************\ + +Function: goto_program2codet::add_local_types + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::add_local_types(const typet &type) { if(type.id()==ID_symbol) @@ -1469,6 +1778,18 @@ void goto_program2codet::add_local_types(const typet &type) } } +/*******************************************************************\ + +Function: goto_program2codet::cleanup_code + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::cleanup_code( codet &code, const irep_idt parent_stmt) @@ -1556,6 +1877,18 @@ void goto_program2codet::cleanup_code( } } +/*******************************************************************\ + +Function: goto_program2codet::cleanup_function_call + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::cleanup_function_call( const exprt &function, code_function_callt::argumentst &arguments) @@ -1586,6 +1919,18 @@ void goto_program2codet::cleanup_function_call( } } +/*******************************************************************\ + +Function: goto_program2codet::cleanup_code_block + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::cleanup_code_block( codet &code, const irep_idt parent_stmt) @@ -1639,6 +1984,18 @@ void goto_program2codet::cleanup_code_block( } } +/*******************************************************************\ + +Function: goto_program2codet::remove_const + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::remove_const(typet &type) { if(type.get_bool(ID_C_constant)) @@ -1673,6 +2030,18 @@ void goto_program2codet::remove_const(typet &type) } } +/*******************************************************************\ + +Function: has_labels + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static bool has_labels(const codet &code) { if(code.get_statement()==ID_label) @@ -1685,6 +2054,18 @@ static bool has_labels(const codet &code) return false; } +/*******************************************************************\ + +Function: move_label_ifthenelse + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static bool move_label_ifthenelse( exprt &expr, exprt &label_dest) @@ -1710,6 +2091,18 @@ static bool move_label_ifthenelse( return true; } +/*******************************************************************\ + +Function: goto_program2codet::cleanup_code_ifthenelse + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::cleanup_code_ifthenelse( codet &code, const irep_idt parent_stmt) @@ -1806,6 +2199,18 @@ void goto_program2codet::cleanup_code_ifthenelse( code=code_skipt(); } +/*******************************************************************\ + +Function: goto_program2codet::cleanup_expr + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast) { // we might have to do array -> pointer conversions diff --git a/src/goto-instrument/goto_program2code.h b/src/goto-instrument/goto_program2code.h index f8aa1eed53f..d39dfc4e5d1 100644 --- a/src/goto-instrument/goto_program2code.h +++ b/src/goto-instrument/goto_program2code.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dump Goto-Program as C/C++ Source - #ifndef CPROVER_GOTO_INSTRUMENT_GOTO_PROGRAM2CODE_H #define CPROVER_GOTO_INSTRUMENT_GOTO_PROGRAM2CODE_H diff --git a/src/goto-instrument/havoc_loops.cpp b/src/goto-instrument/havoc_loops.cpp index e1213ec1831..88cb37075ad 100644 --- a/src/goto-instrument/havoc_loops.cpp +++ b/src/goto-instrument/havoc_loops.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Havoc Loops - #include #include @@ -62,6 +59,18 @@ class havoc_loopst goto_programt::targett get_loop_exit(const loopt &); }; +/*******************************************************************\ + +Function: havoc_loopst::get_loop_exit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) { assert(!loop.empty()); @@ -80,6 +89,18 @@ goto_programt::targett havoc_loopst::get_loop_exit(const loopt &loop) return ++last; } +/*******************************************************************\ + +Function: havoc_loopst::build_havoc_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void havoc_loopst::build_havoc_code( const goto_programt::targett loop_head, const modifiest &modifies, @@ -101,6 +122,18 @@ void havoc_loopst::build_havoc_code( } } +/*******************************************************************\ + +Function: havoc_loopst::havoc_loop + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void havoc_loopst::havoc_loop( const goto_programt::targett loop_head, const loopt &loop) @@ -145,6 +178,18 @@ void havoc_loopst::havoc_loop( remove_skip(goto_function.body); } +/*******************************************************************\ + +Function: havoc_loopst::get_modifies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void havoc_loopst::get_modifies( const loopt &loop, modifiest &modifies) @@ -175,6 +220,18 @@ void havoc_loopst::get_modifies( } } +/*******************************************************************\ + +Function: havoc_loopst::havoc_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void havoc_loopst::havoc_loops() { // iterate over the (natural) loops in the function @@ -183,6 +240,18 @@ void havoc_loopst::havoc_loops() havoc_loop(loop.first, loop.second); } +/*******************************************************************\ + +Function: havoc_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void havoc_loops(goto_functionst &goto_functions) { function_modifiest function_modifies(goto_functions); diff --git a/src/goto-instrument/havoc_loops.h b/src/goto-instrument/havoc_loops.h index dc3245a1162..901e75d4fe5 100644 --- a/src/goto-instrument/havoc_loops.h +++ b/src/goto-instrument/havoc_loops.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Havoc Loops - #ifndef CPROVER_GOTO_INSTRUMENT_HAVOC_LOOPS_H #define CPROVER_GOTO_INSTRUMENT_HAVOC_LOOPS_H diff --git a/src/goto-instrument/horn_encoding.cpp b/src/goto-instrument/horn_encoding.cpp index a1842b28a92..c72f5db9af8 100644 --- a/src/goto-instrument/horn_encoding.cpp +++ b/src/goto-instrument/horn_encoding.cpp @@ -8,13 +8,22 @@ Date: June 2015 \*******************************************************************/ -/// \file -/// Horn-clause Encoding - #include #include "horn_encoding.h" +/*******************************************************************\ + +Function: horn_encoding + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void horn_encoding( const goto_functionst &, const namespacet &, diff --git a/src/goto-instrument/horn_encoding.h b/src/goto-instrument/horn_encoding.h index 44160c35ceb..e6db93159be 100644 --- a/src/goto-instrument/horn_encoding.h +++ b/src/goto-instrument/horn_encoding.h @@ -6,9 +6,6 @@ Module: Horn-clause Encoding \*******************************************************************/ -/// \file -/// Horn-clause Encoding - #ifndef CPROVER_GOTO_INSTRUMENT_HORN_ENCODING_H #define CPROVER_GOTO_INSTRUMENT_HORN_ENCODING_H diff --git a/src/goto-instrument/interrupt.cpp b/src/goto-instrument/interrupt.cpp index 93b11352792..8fa40380617 100644 --- a/src/goto-instrument/interrupt.cpp +++ b/src/goto-instrument/interrupt.cpp @@ -8,9 +8,6 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Interrupt Instrumentation - #include #include #include @@ -26,6 +23,18 @@ Date: September 2011 #include #endif +/*******************************************************************\ + +Function: poential_race_on_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool potential_race_on_read( const rw_set_baset &code_rw_set, const rw_set_baset &isr_rw_set) @@ -40,6 +49,18 @@ bool potential_race_on_read( return false; } +/*******************************************************************\ + +Function: poential_race_on_write + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool potential_race_on_write( const rw_set_baset &code_rw_set, const rw_set_baset &isr_rw_set) @@ -57,6 +78,18 @@ bool potential_race_on_write( return false; } +/*******************************************************************\ + +Function: interrupt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interrupt( value_setst &value_sets, const symbol_tablet &symbol_table, @@ -152,6 +185,18 @@ void interrupt( } } +/*******************************************************************\ + +Function: get_isr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt get_isr( const symbol_tablet &symbol_table, const irep_idt &interrupt_handler) @@ -186,6 +231,18 @@ symbol_exprt get_isr( return isr; } +/*******************************************************************\ + +Function: interrupt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interrupt( value_setst &value_sets, const symbol_tablet &symbol_table, diff --git a/src/goto-instrument/interrupt.h b/src/goto-instrument/interrupt.h index 711c4fa32df..b37cfcf8854 100644 --- a/src/goto-instrument/interrupt.h +++ b/src/goto-instrument/interrupt.h @@ -8,9 +8,6 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Interrupt Instrumentation for Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_INTERRUPT_H #define CPROVER_GOTO_INSTRUMENT_INTERRUPT_H diff --git a/src/goto-instrument/k_induction.cpp b/src/goto-instrument/k_induction.cpp index fcedf66e412..50abfe492f4 100644 --- a/src/goto-instrument/k_induction.cpp +++ b/src/goto-instrument/k_induction.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// k-induction - #include #include @@ -52,6 +49,18 @@ class k_inductiont const loopt &); }; +/*******************************************************************\ + +Function: k_inductiont::process_loop + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void k_inductiont::process_loop( const goto_programt::targett loop_head, const loopt &loop) @@ -137,6 +146,18 @@ void k_inductiont::process_loop( remove_skip(goto_function.body); } +/*******************************************************************\ + +Function: k_inductiont::k_induction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void k_inductiont::k_induction() { // iterate over the (natural) loops in the function @@ -148,6 +169,18 @@ void k_inductiont::k_induction() process_loop(l_it->first, l_it->second); } +/*******************************************************************\ + +Function: k_induction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void k_induction( goto_functionst &goto_functions, bool base_case, bool step_case, diff --git a/src/goto-instrument/k_induction.h b/src/goto-instrument/k_induction.h index e5af8b0c43f..5c5918f923a 100644 --- a/src/goto-instrument/k_induction.h +++ b/src/goto-instrument/k_induction.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// k-induction - #ifndef CPROVER_GOTO_INSTRUMENT_K_INDUCTION_H #define CPROVER_GOTO_INSTRUMENT_K_INDUCTION_H diff --git a/src/goto-instrument/loop_utils.cpp b/src/goto-instrument/loop_utils.cpp index 27e27979585..90981198321 100644 --- a/src/goto-instrument/loop_utils.cpp +++ b/src/goto-instrument/loop_utils.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Helper functions for k-induction and loop invariants - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "loop_utils.h" +/*******************************************************************\ + +Function: get_loop_exit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett get_loop_exit(const loopt &loop) { assert(!loop.empty()); @@ -34,6 +43,18 @@ goto_programt::targett get_loop_exit(const loopt &loop) return ++last; } +/*******************************************************************\ + +Function: build_havoc_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void build_havoc_code( const goto_programt::targett loop_head, const modifiest &modifies, @@ -55,6 +76,18 @@ void build_havoc_code( } } +/*******************************************************************\ + +Function: get_modifies_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void get_modifies_lhs( const local_may_aliast &local_may_alias, goto_programt::const_targett t, @@ -85,6 +118,18 @@ static void get_modifies_lhs( } } +/*******************************************************************\ + +Function: get_modifies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_modifies( const local_may_aliast &local_may_alias, const loopt &loop, diff --git a/src/goto-instrument/loop_utils.h b/src/goto-instrument/loop_utils.h index 57407ecec1b..e6558291c4d 100644 --- a/src/goto-instrument/loop_utils.h +++ b/src/goto-instrument/loop_utils.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Helper functions for k-induction and loop invariants - #ifndef CPROVER_GOTO_INSTRUMENT_LOOP_UTILS_H #define CPROVER_GOTO_INSTRUMENT_LOOP_UTILS_H diff --git a/src/goto-instrument/mmio.cpp b/src/goto-instrument/mmio.cpp index 99112118d35..b66633146a0 100644 --- a/src/goto-instrument/mmio.cpp +++ b/src/goto-instrument/mmio.cpp @@ -8,9 +8,6 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Memory-mapped I/O Instrumentation for Goto Programs - #include #include @@ -33,6 +30,18 @@ Date: September 2011 #include "mmio.h" +/*******************************************************************\ + +Function: mmio + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mmio( value_setst &value_sets, const symbol_tablet &symbol_table, @@ -162,6 +171,18 @@ void mmio( } } +/*******************************************************************\ + +Function: mmio + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mmio( value_setst &value_sets, class symbol_tablet &symbol_table, diff --git a/src/goto-instrument/mmio.h b/src/goto-instrument/mmio.h index eab567f9873..bb3684c4a34 100644 --- a/src/goto-instrument/mmio.h +++ b/src/goto-instrument/mmio.h @@ -8,9 +8,6 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Memory-mapped I/O Instrumentation for Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_MMIO_H #define CPROVER_GOTO_INSTRUMENT_MMIO_H diff --git a/src/goto-instrument/model_argc_argv.cpp b/src/goto-instrument/model_argc_argv.cpp index cc82ab8642a..113c6d46a81 100644 --- a/src/goto-instrument/model_argc_argv.cpp +++ b/src/goto-instrument/model_argc_argv.cpp @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Initialize command line arguments - #include #include @@ -29,6 +26,18 @@ Date: April 2016 #include "model_argc_argv.h" +/*******************************************************************\ + +Function: model_argc_argv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool model_argc_argv( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/model_argc_argv.h b/src/goto-instrument/model_argc_argv.h index 08a214f6fd6..0b47c68555e 100644 --- a/src/goto-instrument/model_argc_argv.h +++ b/src/goto-instrument/model_argc_argv.h @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Initialize command line arguments - #ifndef CPROVER_GOTO_INSTRUMENT_MODEL_ARGC_ARGV_H #define CPROVER_GOTO_INSTRUMENT_MODEL_ARGC_ARGV_H diff --git a/src/goto-instrument/nondet_static.cpp b/src/goto-instrument/nondet_static.cpp index db5aab9ef39..90eb8ab3c08 100644 --- a/src/goto-instrument/nondet_static.cpp +++ b/src/goto-instrument/nondet_static.cpp @@ -9,9 +9,6 @@ Date: November 2011 \*******************************************************************/ -/// \file -/// Nondeterministic initialization of certain global scope variables - #include #include #include @@ -21,6 +18,18 @@ Date: November 2011 #include "nondet_static.h" +/*******************************************************************\ + +Function: nondet_static + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_static( const namespacet &ns, goto_functionst &goto_functions, @@ -71,6 +80,18 @@ void nondet_static( } +/*******************************************************************\ + +Function: nondet_static + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_static( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/goto-instrument/nondet_static.h b/src/goto-instrument/nondet_static.h index 97f3f0e683b..274b9cc5c91 100644 --- a/src/goto-instrument/nondet_static.h +++ b/src/goto-instrument/nondet_static.h @@ -9,9 +9,6 @@ Date: November 2011 \*******************************************************************/ -/// \file -/// Nondeterministic initialization of certain global scope variables - #ifndef CPROVER_GOTO_INSTRUMENT_NONDET_STATIC_H #define CPROVER_GOTO_INSTRUMENT_NONDET_STATIC_H diff --git a/src/goto-instrument/nondet_volatile.cpp b/src/goto-instrument/nondet_volatile.cpp index d85868275d2..43969dfa9d2 100644 --- a/src/goto-instrument/nondet_volatile.cpp +++ b/src/goto-instrument/nondet_volatile.cpp @@ -8,14 +8,23 @@ Date: September 2011 \*******************************************************************/ -/// \file -/// Volatile Variables - #include #include #include "nondet_volatile.h" +/*******************************************************************\ + +Function: is_volatile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_volatile( const symbol_tablet &symbol_table, const typet &src) @@ -34,6 +43,18 @@ bool is_volatile( return false; } +/*******************************************************************\ + +Function: nondet_volatile_rhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) { Forall_operands(it, expr) @@ -54,6 +75,18 @@ void nondet_volatile_rhs(const symbol_tablet &symbol_table, exprt &expr) } } +/*******************************************************************\ + +Function: nondet_volatile_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr) { if(expr.id()==ID_if) @@ -77,6 +110,18 @@ void nondet_volatile_lhs(const symbol_tablet &symbol_table, exprt &expr) } } +/*******************************************************************\ + +Function: nondet_volatile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_volatile( symbol_tablet &symbol_table, goto_programt &goto_program) @@ -119,6 +164,18 @@ void nondet_volatile( } } +/*******************************************************************\ + +Function: nondet_volatile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void nondet_volatile( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/nondet_volatile.h b/src/goto-instrument/nondet_volatile.h index 8cb3930fd56..1a4457d6842 100644 --- a/src/goto-instrument/nondet_volatile.h +++ b/src/goto-instrument/nondet_volatile.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Volatile Variables - #ifndef CPROVER_GOTO_INSTRUMENT_NONDET_VOLATILE_H #define CPROVER_GOTO_INSTRUMENT_NONDET_VOLATILE_H diff --git a/src/goto-instrument/object_id.cpp b/src/goto-instrument/object_id.cpp index f63581bcd38..9df8b426df2 100644 --- a/src/goto-instrument/object_id.cpp +++ b/src/goto-instrument/object_id.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Object Identifiers - #include "object_id.h" +/*******************************************************************\ + +Function: get_objects_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + enum class get_modet { LHS_R, LHS_W, READ }; void get_objects_rec( @@ -69,27 +78,87 @@ void get_objects_rec( } } +/*******************************************************************\ + +Function: get_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_objects(const exprt &expr, object_id_sett &dest) { get_objects_rec(get_modet::READ, expr, dest, ""); } +/*******************************************************************\ + +Function: get_objects_r + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_objects_r(const code_assignt &assign, object_id_sett &dest) { get_objects_rec(get_modet::LHS_R, assign.lhs(), dest, ""); get_objects_rec(get_modet::READ, assign.rhs(), dest, ""); } +/*******************************************************************\ + +Function: get_objects_w + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_objects_w(const code_assignt &assign, object_id_sett &dest) { get_objects_rec(get_modet::LHS_W, assign.lhs(), dest, ""); } +/*******************************************************************\ + +Function: get_objects_w_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_objects_w(const exprt &lhs, object_id_sett &dest) { get_objects_rec(get_modet::LHS_W, lhs, dest, ""); } +/*******************************************************************\ + +Function: get_objects_r_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_objects_r_lhs(const exprt &lhs, object_id_sett &dest) { get_objects_rec(get_modet::LHS_R, lhs, dest, ""); diff --git a/src/goto-instrument/object_id.h b/src/goto-instrument/object_id.h index f7c597a798b..ac928e29b5f 100644 --- a/src/goto-instrument/object_id.h +++ b/src/goto-instrument/object_id.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Object Identifiers - #ifndef CPROVER_GOTO_INSTRUMENT_OBJECT_ID_H #define CPROVER_GOTO_INSTRUMENT_OBJECT_ID_H diff --git a/src/goto-instrument/points_to.cpp b/src/goto-instrument/points_to.cpp index a7d28a06229..da29e800292 100644 --- a/src/goto-instrument/points_to.cpp +++ b/src/goto-instrument/points_to.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-sensitive, location-insensitive points-to analysis - #include "points_to.h" +/*******************************************************************\ + +Function: points_tot::fixedpoint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void points_tot::fixedpoint() { // this loop iterates until fixed-point @@ -33,6 +42,18 @@ void points_tot::fixedpoint() while(added); } +/*******************************************************************\ + +Function: points_tot::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void points_tot::output(std::ostream &out) const { for(value_mapt::const_iterator @@ -54,6 +75,18 @@ void points_tot::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: points_tot::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool points_tot::transform(const cfgt::nodet &e) { bool result=false; diff --git a/src/goto-instrument/points_to.h b/src/goto-instrument/points_to.h index 8b4a47d980a..4805de2343c 100644 --- a/src/goto-instrument/points_to.h +++ b/src/goto-instrument/points_to.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Field-sensitive, location-insensitive points-to analysis - #ifndef CPROVER_GOTO_INSTRUMENT_POINTS_TO_H #define CPROVER_GOTO_INSTRUMENT_POINTS_TO_H @@ -19,6 +16,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "object_id.h" +/*******************************************************************\ + + Class: points_tot + + Purpose: + +\*******************************************************************/ + class points_tot { public: diff --git a/src/goto-instrument/race_check.cpp b/src/goto-instrument/race_check.cpp index 952657ff0e9..8f26d89bf56 100644 --- a/src/goto-instrument/race_check.cpp +++ b/src/goto-instrument/race_check.cpp @@ -8,9 +8,6 @@ Date: February 2006 \*******************************************************************/ -/// \file -/// Race Detection for Threaded Goto Programs - #include #include #include @@ -67,6 +64,18 @@ class w_guardst symbol_tablet &symbol_table; }; +/*******************************************************************\ + +Function: w_guardst::get_guard_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) { const irep_idt identifier=id2string(object)+"$w_guard"; @@ -91,6 +100,18 @@ const symbolt &w_guardst::get_guard_symbol(const irep_idt &object) return *symbol_ptr; } +/*******************************************************************\ + +Function: w_guardst::add_initialization + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void w_guardst::add_initialization(goto_programt &goto_program) const { goto_programt::targett t=goto_program.instructions.begin(); @@ -111,6 +132,18 @@ void w_guardst::add_initialization(goto_programt &goto_program) const } } +/*******************************************************************\ + +Function: comment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string comment(const rw_set_baset::entryt &entry, bool write) { std::string result; @@ -124,6 +157,18 @@ std::string comment(const rw_set_baset::entryt &entry, bool write) return result; } +/*******************************************************************\ + +Function: is_shared + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_shared( const namespacet &ns, const symbol_exprt &symbol_expr) @@ -144,6 +189,18 @@ bool is_shared( return symbol.is_shared(); } +/*******************************************************************\ + +Function: race_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_shared_entries( const namespacet &ns, const rw_set_baset &rw_set) @@ -165,6 +222,18 @@ bool has_shared_entries( return false; } +/*******************************************************************\ + +Function: race_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void race_check( value_setst &value_sets, symbol_tablet &symbol_table, @@ -270,6 +339,18 @@ void race_check( remove_skip(goto_program); } +/*******************************************************************\ + +Function: race_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void race_check( value_setst &value_sets, symbol_tablet &symbol_table, @@ -291,6 +372,18 @@ void race_check( goto_program.update(); } +/*******************************************************************\ + +Function: race_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void race_check( value_setst &value_sets, symbol_tablet &symbol_table, diff --git a/src/goto-instrument/race_check.h b/src/goto-instrument/race_check.h index 442d142ddc0..1c7cd3e5be8 100644 --- a/src/goto-instrument/race_check.h +++ b/src/goto-instrument/race_check.h @@ -8,9 +8,6 @@ Date: February 2006 \*******************************************************************/ -/// \file -/// Race Detection for Threaded Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_RACE_CHECK_H #define CPROVER_GOTO_INSTRUMENT_RACE_CHECK_H diff --git a/src/goto-instrument/reachability_slicer.cpp b/src/goto-instrument/reachability_slicer.cpp index 72b63fa76c4..073f9284add 100644 --- a/src/goto-instrument/reachability_slicer.cpp +++ b/src/goto-instrument/reachability_slicer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicer - #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "reachability_slicer.h" #include "reachability_slicer_class.h" +/*******************************************************************\ + +Function: reachability_slicert::fixedpoint_assertions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reachability_slicert::fixedpoint_assertions( const is_threadedt &is_threaded, slicing_criteriont &criterion) @@ -55,6 +64,18 @@ void reachability_slicert::fixedpoint_assertions( } } +/*******************************************************************\ + +Function: reachability_slicert::slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reachability_slicert::slice(goto_functionst &goto_functions) { // now replace those instructions that do not reach any assertions @@ -80,6 +101,18 @@ void reachability_slicert::slice(goto_functionst &goto_functions) goto_functions.update(); } +/*******************************************************************\ + +Function: reachability_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reachability_slicer(goto_functionst &goto_functions) { reachability_slicert s; @@ -87,6 +120,18 @@ void reachability_slicer(goto_functionst &goto_functions) s(goto_functions, a); } +/*******************************************************************\ + +Function: reachability_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void reachability_slicer( goto_functionst &goto_functions, const std::list &properties) diff --git a/src/goto-instrument/reachability_slicer.h b/src/goto-instrument/reachability_slicer.h index 4d82e4b194e..e45aa81f27e 100644 --- a/src/goto-instrument/reachability_slicer.h +++ b/src/goto-instrument/reachability_slicer.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicing - #ifndef CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H #define CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H diff --git a/src/goto-instrument/reachability_slicer_class.h b/src/goto-instrument/reachability_slicer_class.h index 4f21049892e..224259b57cd 100644 --- a/src/goto-instrument/reachability_slicer_class.h +++ b/src/goto-instrument/reachability_slicer_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto Program Slicing - #ifndef CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_CLASS_H #define CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_CLASS_H @@ -19,6 +16,14 @@ Author: Daniel Kroening, kroening@kroening.com class slicing_criteriont; +/*******************************************************************\ + + Class: reachability_slicert + + Purpose: + +\*******************************************************************/ + class reachability_slicert { public: diff --git a/src/goto-instrument/rw_set.cpp b/src/goto-instrument/rw_set.cpp index 85c13d540b2..531a3ea70b4 100644 --- a/src/goto-instrument/rw_set.cpp +++ b/src/goto-instrument/rw_set.cpp @@ -8,9 +8,6 @@ Date: February 2006 \*******************************************************************/ -/// \file -/// Race Detection for Threaded Goto Programs - #include #include #include @@ -21,6 +18,18 @@ Date: February 2006 #include "rw_set.h" +/*******************************************************************\ + +Function: rw_set_baset::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_set_baset::output(std::ostream &out) const { out << "READ:" << std::endl; @@ -44,6 +53,18 @@ void rw_set_baset::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: rw_set_loct::compute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void _rw_set_loct::compute() { if(target->is_assign()) @@ -76,12 +97,36 @@ void _rw_set_loct::compute() } } +/*******************************************************************\ + +Function: rw_set_loct::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void _rw_set_loct::assign(const exprt &lhs, const exprt &rhs) { read(rhs); read_write_rec(lhs, false, true, "", guardt()); } +/*******************************************************************\ + +Function: rw_set_loct::read_write_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void _rw_set_loct::read_write_rec( const exprt &expr, bool r, bool w, @@ -195,6 +240,18 @@ void _rw_set_loct::read_write_rec( } } +/*******************************************************************\ + +Function: rw_set_functiont::compute_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rw_set_functiont::compute_rec(const exprt &function) { if(function.id()==ID_symbol) diff --git a/src/goto-instrument/rw_set.h b/src/goto-instrument/rw_set.h index eba731d705c..9322efbfc3e 100644 --- a/src/goto-instrument/rw_set.h +++ b/src/goto-instrument/rw_set.h @@ -8,9 +8,6 @@ Date: February 2006 \*******************************************************************/ -/// \file -/// Race Detection for Threaded Goto Programs - #ifndef CPROVER_GOTO_INSTRUMENT_RW_SET_H #define CPROVER_GOTO_INSTRUMENT_RW_SET_H diff --git a/src/goto-instrument/show_locations.cpp b/src/goto-instrument/show_locations.cpp index 73ea3bd2f89..411422e07fd 100644 --- a/src/goto-instrument/show_locations.cpp +++ b/src/goto-instrument/show_locations.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show program locations - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "show_locations.h" +/*******************************************************************\ + +Function: show_locations + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_locations( ui_message_handlert::uit ui, const irep_idt function_id, @@ -62,6 +71,18 @@ void show_locations( } } +/*******************************************************************\ + +Function: show_locations + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_locations( ui_message_handlert::uit ui, const goto_functionst &goto_functions) diff --git a/src/goto-instrument/show_locations.h b/src/goto-instrument/show_locations.h index 3f71b19ca48..60861add675 100644 --- a/src/goto-instrument/show_locations.h +++ b/src/goto-instrument/show_locations.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show program locations - #ifndef CPROVER_GOTO_INSTRUMENT_SHOW_LOCATIONS_H #define CPROVER_GOTO_INSTRUMENT_SHOW_LOCATIONS_H diff --git a/src/goto-instrument/skip_loops.cpp b/src/goto-instrument/skip_loops.cpp index 55a7e4cd3cc..f79fae9d7b4 100644 --- a/src/goto-instrument/skip_loops.cpp +++ b/src/goto-instrument/skip_loops.cpp @@ -8,9 +8,6 @@ Date: January 2016 \*******************************************************************/ -/// \file -/// Skip over selected loops by adding gotos - #include #include @@ -21,6 +18,18 @@ Date: January 2016 typedef std::set loop_idst; typedef std::map loop_mapt; +/*******************************************************************\ + +Function: skip_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool skip_loops( goto_programt &goto_program, const loop_idst &loop_ids, @@ -62,6 +71,18 @@ static bool skip_loops( return false; } +/*******************************************************************\ + +Function: skip_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool parse_loop_ids( const std::string &loop_ids, loop_mapt &loop_map) @@ -90,6 +111,18 @@ static bool parse_loop_ids( return false; } +/*******************************************************************\ + +Function: skip_loops + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool skip_loops( goto_functionst &goto_functions, const std::string &loop_ids, diff --git a/src/goto-instrument/skip_loops.h b/src/goto-instrument/skip_loops.h index c5e84c6172c..d2c9af8996f 100644 --- a/src/goto-instrument/skip_loops.h +++ b/src/goto-instrument/skip_loops.h @@ -8,9 +8,6 @@ Date: January 2016 \*******************************************************************/ -/// \file -/// Skip over selected loops by adding gotos - #ifndef CPROVER_GOTO_INSTRUMENT_SKIP_LOOPS_H #define CPROVER_GOTO_INSTRUMENT_SKIP_LOOPS_H diff --git a/src/goto-instrument/stack_depth.cpp b/src/goto-instrument/stack_depth.cpp index e422b54184d..0c5e0f81146 100644 --- a/src/goto-instrument/stack_depth.cpp +++ b/src/goto-instrument/stack_depth.cpp @@ -8,9 +8,6 @@ Date: November 2011 \*******************************************************************/ -/// \file -/// Stack depth checks - #include #include #include @@ -21,6 +18,18 @@ Date: November 2011 #include "stack_depth.h" +/*******************************************************************\ + +Function: add_stack_depth_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) { const irep_idt identifier="$stack_depth"; @@ -42,6 +51,18 @@ symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table) return symbol_exprt(identifier, type); } +/*******************************************************************\ + +Function: stack_depth + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void stack_depth( goto_programt &goto_program, const symbol_exprt &symbol, @@ -82,6 +103,18 @@ void stack_depth( goto_program.insert_before_swap(last, minus_ins); } +/*******************************************************************\ + +Function: stack_depth + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void stack_depth( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-instrument/stack_depth.h b/src/goto-instrument/stack_depth.h index 8d0414121d7..f24964ff611 100644 --- a/src/goto-instrument/stack_depth.h +++ b/src/goto-instrument/stack_depth.h @@ -8,9 +8,6 @@ Date: November 2011 \*******************************************************************/ -/// \file -/// Stack depth checks - #ifndef CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H #define CPROVER_GOTO_INSTRUMENT_STACK_DEPTH_H diff --git a/src/goto-instrument/thread_instrumentation.cpp b/src/goto-instrument/thread_instrumentation.cpp index 8a78c2208d8..4c23234d051 100644 --- a/src/goto-instrument/thread_instrumentation.cpp +++ b/src/goto-instrument/thread_instrumentation.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "thread_instrumentation.h" +/*******************************************************************\ + +Function: has_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool has_start_thread(const goto_programt &goto_program) { for(const auto &instruction : goto_program.instructions) @@ -19,6 +31,18 @@ static bool has_start_thread(const goto_programt &goto_program) return false; } +/*******************************************************************\ + +Function: thread_exit_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void thread_exit_instrumentation(goto_programt &goto_program) { if(goto_program.instructions.empty()) @@ -52,6 +76,18 @@ void thread_exit_instrumentation(goto_programt &goto_program) end->function=function; } +/*******************************************************************\ + +Function: thread_exit_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void thread_exit_instrumentation(goto_functionst &goto_functions) { // we'll look for START THREAD @@ -81,6 +117,18 @@ void thread_exit_instrumentation(goto_functionst &goto_functions) } } +/*******************************************************************\ + +Function: mutex_init_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mutex_init_instrumentation( const symbol_tablet &symbol_table, goto_programt &goto_program, @@ -117,6 +165,18 @@ void mutex_init_instrumentation( } } +/*******************************************************************\ + +Function: mutex_init_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mutex_init_instrumentation( const symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-instrument/undefined_functions.cpp b/src/goto-instrument/undefined_functions.cpp index 6bf53e0e5c9..53fff3ff84b 100644 --- a/src/goto-instrument/undefined_functions.cpp +++ b/src/goto-instrument/undefined_functions.cpp @@ -8,15 +8,24 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// Handling of functions without body - #include #include #include "undefined_functions.h" +/*******************************************************************\ + +Function: list_undefined_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void list_undefined_functions( const goto_functionst &goto_functions, const namespacet &ns, @@ -28,6 +37,18 @@ void list_undefined_functions( os << it->first << std::endl; } +/*******************************************************************\ + +Function: undefined_function_abort_path + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void undefined_function_abort_path(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) diff --git a/src/goto-instrument/undefined_functions.h b/src/goto-instrument/undefined_functions.h index 85c6ba77552..7b700c839a0 100644 --- a/src/goto-instrument/undefined_functions.h +++ b/src/goto-instrument/undefined_functions.h @@ -8,9 +8,6 @@ Date: July 2016 \*******************************************************************/ -/// \file -/// Handling of functions without body - #ifndef CPROVER_UNDEFINED_FUNCTIONS_H #define CPROVER_UNDEFINED_FUNCTIONS_H diff --git a/src/goto-instrument/uninitialized.cpp b/src/goto-instrument/uninitialized.cpp index 74dbf389d81..c048a518440 100644 --- a/src/goto-instrument/uninitialized.cpp +++ b/src/goto-instrument/uninitialized.cpp @@ -8,9 +8,6 @@ Date: January 2010 \*******************************************************************/ -/// \file -/// Detection for Uninitialized Local Variables - #include #include #include @@ -19,6 +16,14 @@ Date: January 2010 #include "uninitialized.h" +/*******************************************************************\ + + Class: uninitializedt + + Purpose: + +\*******************************************************************/ + class uninitializedt { public: @@ -42,7 +47,19 @@ class uninitializedt void get_tracking(goto_programt::const_targett i_it); }; -/// which variables need tracking, i.e., are uninitialized and may be read? +/*******************************************************************\ + +Function: uninitializedt::get_tracking + + Inputs: + + Outputs: + + Purpose: which variables need tracking, + i.e., are uninitialized and may be read? + +\*******************************************************************/ + void uninitializedt::get_tracking(goto_programt::const_targett i_it) { std::list objects=objects_read(*i_it); @@ -63,6 +80,18 @@ void uninitializedt::get_tracking(goto_programt::const_targett i_it) } } +/*******************************************************************\ + +Function: uninitializedt::add_assertions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void uninitializedt::add_assertions(goto_programt &goto_program) { uninitialized_analysis(goto_program, ns); @@ -194,6 +223,18 @@ void uninitializedt::add_assertions(goto_programt &goto_program) } } +/*******************************************************************\ + +Function: add_uninitialized_locals_assertions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_uninitialized_locals_assertions( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -206,6 +247,18 @@ void add_uninitialized_locals_assertions( } } +/*******************************************************************\ + +Function: show_uninitialized + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_uninitialized( const class symbol_tablet &symbol_table, const goto_functionst &goto_functions, diff --git a/src/goto-instrument/uninitialized.h b/src/goto-instrument/uninitialized.h index 11437eee972..1f4b27b5964 100644 --- a/src/goto-instrument/uninitialized.h +++ b/src/goto-instrument/uninitialized.h @@ -8,9 +8,6 @@ Date: January 2010 \*******************************************************************/ -/// \file -/// Detection for Uninitialized Local Variables - #ifndef CPROVER_GOTO_INSTRUMENT_UNINITIALIZED_H #define CPROVER_GOTO_INSTRUMENT_UNINITIALIZED_H diff --git a/src/goto-instrument/unwind.cpp b/src/goto-instrument/unwind.cpp index d9ef9e1924d..1ae2451c3a6 100644 --- a/src/goto-instrument/unwind.cpp +++ b/src/goto-instrument/unwind.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Loop unwinding - #ifdef DEBUG #include #endif @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "unwind.h" #include "loop_utils.h" +/*******************************************************************\ + +Function: parse_unwindset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_unwindset(const std::string &us, unwind_sett &unwind_set) { assert(unwind_set.empty()); @@ -55,6 +64,18 @@ void parse_unwindset(const std::string &us, unwind_sett &unwind_set) } } +/*******************************************************************\ + +Function: copy_segment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_unwindt::copy_segment( const goto_programt::const_targett start, const goto_programt::const_targett end, // exclusive @@ -109,6 +130,18 @@ void goto_unwindt::copy_segment( } } +/*******************************************************************\ + +Function: unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_unwindt::unwind( goto_programt &goto_program, const goto_programt::const_targett loop_head, @@ -121,6 +154,18 @@ void goto_unwindt::unwind( iteration_points); } +/*******************************************************************\ + +Function: unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_unwindt::unwind( goto_programt &goto_program, const goto_programt::const_targett loop_head, @@ -289,6 +334,18 @@ void goto_unwindt::unwind( goto_program.destructive_insert(loop_exit, copies); } +/*******************************************************************\ + +Function: get_k + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int goto_unwindt::get_k( const irep_idt func, const unsigned loop_id, @@ -312,6 +369,18 @@ int goto_unwindt::get_k( return k; } +/*******************************************************************\ + +Function: unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_unwindt::unwind( goto_programt &goto_program, const unwind_sett &unwind_set, @@ -361,6 +430,18 @@ void goto_unwindt::unwind( } } +/*******************************************************************\ + +Function: operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_unwindt::operator()( goto_functionst &goto_functions, const unwind_sett &unwind_set, @@ -386,6 +467,18 @@ void goto_unwindt::operator()( } } +/*******************************************************************\ + +Function: show_log_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // call after calling goto_functions.update()! jsont goto_unwindt::unwind_logt::output_log_json() const { diff --git a/src/goto-instrument/unwind.h b/src/goto-instrument/unwind.h index 16ee2cf9455..99719f7ddf1 100644 --- a/src/goto-instrument/unwind.h +++ b/src/goto-instrument/unwind.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Loop unwinding - #ifndef CPROVER_GOTO_INSTRUMENT_UNWIND_H #define CPROVER_GOTO_INSTRUMENT_UNWIND_H diff --git a/src/goto-instrument/wmm/abstract_event.cpp b/src/goto-instrument/wmm/abstract_event.cpp index 41e8efb78f2..e080ba3ef3c 100644 --- a/src/goto-instrument/wmm/abstract_event.cpp +++ b/src/goto-instrument/wmm/abstract_event.cpp @@ -8,11 +8,20 @@ Date: 2012 \*******************************************************************/ -/// \file -/// abstract events - #include "abstract_event.h" +/*******************************************************************\ + +Function: abstract_eventt::unsafe_pair_lwfence_param + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt &next, memory_modelt model, bool lwsync_met) const @@ -98,6 +107,18 @@ bool abstract_eventt::unsafe_pair_lwfence_param(const abstract_eventt &next, return true; } +/*******************************************************************\ + +Function: abstract_eventt::unsafe_pair_asm + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool abstract_eventt::unsafe_pair_asm(const abstract_eventt &next, memory_modelt model, unsigned char met) const diff --git a/src/goto-instrument/wmm/abstract_event.h b/src/goto-instrument/wmm/abstract_event.h index a271c709ea1..ba0c0f5f1ff 100644 --- a/src/goto-instrument/wmm/abstract_event.h +++ b/src/goto-instrument/wmm/abstract_event.h @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// abstract events - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_ABSTRACT_EVENT_H #define CPROVER_GOTO_INSTRUMENT_WMM_ABSTRACT_EVENT_H @@ -19,6 +16,10 @@ Date: 2012 #include "wmm.h" +/*******************************************************************\ + abstract event +\*******************************************************************/ + class abstract_eventt:public graph_nodet { protected: diff --git a/src/goto-instrument/wmm/cycle_collection.cpp b/src/goto-instrument/wmm/cycle_collection.cpp index 1012ae40cdc..c8110665ead 100644 --- a/src/goto-instrument/wmm/cycle_collection.cpp +++ b/src/goto-instrument/wmm/cycle_collection.cpp @@ -8,15 +8,22 @@ Date: 2012 \*******************************************************************/ -/// \file -/// collection of cycles in graph of abstract events - #include #include "event_graph.h" -/// after the collection, eliminates the executions forbidden by an indirect -/// thin-air +/*******************************************************************\ + +Function: event_grapht::graph_explorert::filter_thin_air + + Inputs: + + Outputs: + + Purpose: after the collection, eliminates the executions forbidden + by an indirect thin-air + +\*******************************************************************/ void event_grapht::graph_explorert::filter_thin_air( std::set &set_of_cycles) { @@ -47,7 +54,18 @@ void event_grapht::graph_explorert::filter_thin_air( #endif } -/// Tarjan 1972 adapted and modified for events +/*******************************************************************\ + +Function: event_grapht::graph_explorert::collect_cycles + + Inputs: + + Outputs: + + Purpose: Tarjan 1972 adapted and modified for events + +\*******************************************************************/ + void event_grapht::graph_explorert::collect_cycles( std::set &set_of_cycles, memory_modelt model) @@ -105,8 +123,20 @@ void event_grapht::graph_explorert::collect_cycles( filter_thin_air(set_of_cycles); } -/// extracts a (whole, unreduced) cycle from the stack. Note: it may not be a -/// real cycle yet -- we cannot check the size before a call to this function. +/*******************************************************************\ + +Function: event_grapht::graph_explorert::extract_cycle + + Inputs: + + Outputs: + + Purpose: extracts a (whole, unreduced) cycle from the stack. + Note: it may not be a real cycle yet -- we cannot check + the size before a call to this function. + +\*******************************************************************/ + event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( event_idt vertex, event_idt source, @@ -146,8 +176,18 @@ event_grapht::critical_cyclet event_grapht::graph_explorert::extract_cycle( return new_cycle; } -/// see event_grapht::collect_cycles -/// \param get_po_only: used for po-transitivity +/*******************************************************************\ + +Function: event_grapht::graph_explorert::backtrack + + Inputs: get_po_only: used for po-transitivity + + Outputs: + + Purpose: see event_grapht::collect_cycles + +\*******************************************************************/ + bool event_grapht::graph_explorert::backtrack( std::set &set_of_cycles, event_idt source, diff --git a/src/goto-instrument/wmm/data_dp.cpp b/src/goto-instrument/wmm/data_dp.cpp index d220174c422..ce700dc1f8a 100644 --- a/src/goto-instrument/wmm/data_dp.cpp +++ b/src/goto-instrument/wmm/data_dp.cpp @@ -8,15 +8,23 @@ Date: 2012 \*******************************************************************/ -/// \file -/// data dependencies - #include #include "data_dp.h" #include "abstract_event.h" -/// insertion +/*******************************************************************\ + +Function: data_dpt::dp_analysis + + Inputs: + + Outputs: + + Purpose: insertion + +\*******************************************************************/ + void data_dpt::dp_analysis( const datat &read, bool local_read, @@ -58,6 +66,18 @@ void data_dpt::dp_analysis( } } +/*******************************************************************\ + +Function: data_dpt::dp_analysis + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void data_dpt::dp_analysis( const abstract_eventt &read, const abstract_eventt &write) @@ -67,7 +87,18 @@ void data_dpt::dp_analysis( dp_analysis(d_read, read.local, d_write, write.local); } -/// search in N^2 +/*******************************************************************\ + +Function: data_dpt::dp + + Inputs: + + Outputs: + + Purpose: search in N^2 + +\*******************************************************************/ + bool data_dpt::dp(const abstract_eventt &e1, const abstract_eventt &e2) const { for(const_iterator it1=begin(); it1!=end(); ++it1) @@ -112,7 +143,18 @@ bool data_dpt::dp(const abstract_eventt &e1, const abstract_eventt &e2) const return false; } -/// merge in N^3 +/*******************************************************************\ + +Function: data_dpt::dp_merge + + Inputs: + + Outputs: + + Purpose: merge in N^3 + +\*******************************************************************/ + void data_dpt::dp_merge() { if(size()<2) @@ -156,6 +198,18 @@ void data_dpt::dp_merge() dp_merge(); } +/*******************************************************************\ + +Function: data_dpt::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void data_dpt::print(messaget &message) { #ifdef DEBUG diff --git a/src/goto-instrument/wmm/data_dp.h b/src/goto-instrument/wmm/data_dp.h index abd7641fb9c..6b352acccfd 100644 --- a/src/goto-instrument/wmm/data_dp.h +++ b/src/goto-instrument/wmm/data_dp.h @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// data dependencies - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_DATA_DP_H #define CPROVER_GOTO_INSTRUMENT_WMM_DATA_DP_H @@ -21,6 +18,10 @@ Date: 2012 class abstract_eventt; class messaget; +/*******************************************************************\ + data dependencies +\*******************************************************************/ + struct datat { irep_idt id; diff --git a/src/goto-instrument/wmm/event_graph.cpp b/src/goto-instrument/wmm/event_graph.cpp index 8a73a6560e4..dce7b3de474 100644 --- a/src/goto-instrument/wmm/event_graph.cpp +++ b/src/goto-instrument/wmm/event_graph.cpp @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// graph of abstract events - #include "event_graph.h" #include @@ -25,6 +22,18 @@ static const char *colour_map[NB_COLOURS]= "deeppink", "indigo", "olivedrab"}; #define print_colour(u) colour_map[u%NB_COLOURS] +/*******************************************************************\ + +Function: event_grapht::print_rec_graph + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void event_grapht::print_rec_graph(std::ofstream &file, event_idt node_id, std::set &visited) { @@ -53,6 +62,18 @@ void event_grapht::print_rec_graph(std::ofstream &file, event_idt node_id, } } +/*******************************************************************\ + +Function: event_grapht::print_graph + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void event_grapht::print_graph() { assert(po_order.size()>0); @@ -66,9 +87,19 @@ void event_grapht::print_graph() file << "}" << std::endl; } -/// copies the segment -/// \param begin: top of the subgraph -/// \param end: bottom of the subgraph +/*******************************************************************\ + +Function: event_grapht::copy_segment + + Inputs: begin: top of the subgraph + end: bottom of the subgraph + + Outputs: + + Purpose: copies the segment + +\*******************************************************************/ + void event_grapht::explore_copy_segment(std::set &explored, event_idt begin, event_idt end) const { @@ -183,6 +214,18 @@ event_idt event_grapht::copy_segment(event_idt begin, event_idt end) return orig2copy[end]; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::check_AC + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::check_AC( const_iterator s_it, const abstract_eventt &first, @@ -224,6 +267,18 @@ bool event_grapht::critical_cyclet::check_AC( return AC; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::check_BC + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::check_BC( const_iterator it, const abstract_eventt &first, @@ -277,6 +332,18 @@ bool event_grapht::critical_cyclet::check_BC( return BC; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::is_unsafe + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) { egraph.message.debug() << "cycle is safe?" << messaget::eom; @@ -558,7 +625,18 @@ bool event_grapht::critical_cyclet::is_unsafe(memory_modelt model, bool fast) return unsafe_met; } -/// same as is_unsafe, but with ASM fences +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::is_unsafe_asm + + Inputs: + + Outputs: + + Purpose: same as is_unsafe, but with ASM fences + +\*******************************************************************/ + bool event_grapht::critical_cyclet::is_unsafe_asm( memory_modelt model, bool fast) @@ -892,6 +970,18 @@ bool event_grapht::critical_cyclet::is_unsafe_asm( return unsafe_met; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::is_not_uniproc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::is_not_uniproc() const { const_iterator it=begin(); @@ -930,6 +1020,18 @@ bool event_grapht::critical_cyclet::is_not_uniproc() const return (it!=end()); } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::is_not_weak_uniproc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::is_not_weak_uniproc() const { const_iterator it=begin(); @@ -967,6 +1069,18 @@ bool event_grapht::critical_cyclet::is_not_weak_uniproc() const return (it!=end()); } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::is_not_thin_air + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool event_grapht::critical_cyclet::is_not_thin_air() const { // assert(size()>2); @@ -1015,6 +1129,18 @@ bool event_grapht::critical_cyclet::is_not_thin_air() const return true; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print() const { std::string cycle="Cycle: "; @@ -1023,6 +1149,18 @@ std::string event_grapht::critical_cyclet::print() const return cycle + " End of cycle."; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_unsafes + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_unsafes() const { std::string name="Unsafe pairs: "; @@ -1070,6 +1208,18 @@ std::string event_grapht::critical_cyclet::print_unsafes() const return name; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_events + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_events() const { std::string cycle="Cycle: "; @@ -1082,6 +1232,18 @@ std::string event_grapht::critical_cyclet::print_events() const return cycle+" End of cycle."; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_output() const { std::string cycle; @@ -1095,6 +1257,18 @@ std::string event_grapht::critical_cyclet::print_output() const return cycle; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_detail + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_detail( const critical_cyclet &reduced, std::map &map_id2var, @@ -1124,6 +1298,18 @@ std::string event_grapht::critical_cyclet::print_detail( return cycle; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_all + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_all( memory_modelt model, std::map &map_id2var, @@ -1154,6 +1340,18 @@ std::string event_grapht::critical_cyclet::print_all( return cycle; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::hide_internals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void event_grapht::critical_cyclet::hide_internals( critical_cyclet &reduced) const { @@ -1230,6 +1428,18 @@ void event_grapht::critical_cyclet::hide_internals( } } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string event_grapht::critical_cyclet::print_name( const critical_cyclet &reduced, memory_modelt model) const @@ -1535,6 +1745,18 @@ std::string event_grapht::critical_cyclet::print_name( return name; } +/*******************************************************************\ + +Function: event_grapht::critical_cyclet::print_dot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void event_grapht::critical_cyclet::print_dot( std::ostream &str, unsigned colour, diff --git a/src/goto-instrument/wmm/event_graph.h b/src/goto-instrument/wmm/event_graph.h index 7670059ed43..4ae9c067264 100644 --- a/src/goto-instrument/wmm/event_graph.h +++ b/src/goto-instrument/wmm/event_graph.h @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// graph of abstract events - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_EVENT_GRAPH_H #define CPROVER_GOTO_INSTRUMENT_WMM_EVENT_GRAPH_H @@ -28,6 +25,10 @@ Date: 2012 class messaget; class namespacet; +/*******************************************************************\ + graph of abstract events +\*******************************************************************/ + typedef grapht wmm_grapht; typedef wmm_grapht::node_indext event_idt; diff --git a/src/goto-instrument/wmm/fence.cpp b/src/goto-instrument/wmm/fence.cpp index 7c820f238f9..34c0c387ac5 100644 --- a/src/goto-instrument/wmm/fence.cpp +++ b/src/goto-instrument/wmm/fence.cpp @@ -8,9 +8,6 @@ Date: February 2012 \*******************************************************************/ -/// \file -/// Fences for instrumentation - #include #include "fence.h" diff --git a/src/goto-instrument/wmm/fence.h b/src/goto-instrument/wmm/fence.h index 0e08d23be28..5d14c2cc7a3 100644 --- a/src/goto-instrument/wmm/fence.h +++ b/src/goto-instrument/wmm/fence.h @@ -8,9 +8,6 @@ Date: February 2012 \*******************************************************************/ -/// \file -/// Fences for instrumentation - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_FENCE_H #define CPROVER_GOTO_INSTRUMENT_WMM_FENCE_H diff --git a/src/goto-instrument/wmm/goto2graph.cpp b/src/goto-instrument/wmm/goto2graph.cpp index 9907a47d9ab..efcd626cb10 100644 --- a/src/goto-instrument/wmm/goto2graph.cpp +++ b/src/goto-instrument/wmm/goto2graph.cpp @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// Turns a goto-program into an abstract event graph - #include #include #include @@ -33,7 +30,18 @@ Date: 2012 // #define PRINT_UNSAFES -/// is local variable? +/*******************************************************************\ + +Function: instrumentert::local + + Inputs: + + Outputs: + + Purpose: is local variable? + +\*******************************************************************/ + bool inline instrumentert::local(const irep_idt &id) { std::string identifier=id2string(id); @@ -87,8 +95,20 @@ bool inline instrumentert::cfg_visitort::local(const irep_idt &i) return instrumenter.local(i); } -/// goes through CFG and build a static abstract event graph overapproximating -/// the read/write relations for any executions +/*******************************************************************\ + +Function: instrumentert::goto2graph_cfg + + Inputs: + + Outputs: + + Purpose: goes through CFG and build a static abstract event + graph overapproximating the read/write relations for any + executions + +\*******************************************************************/ + unsigned instrumentert::goto2graph_cfg( value_setst &value_sets, memory_modelt model, @@ -149,6 +169,18 @@ unsigned instrumentert::goto2graph_cfg( return visitor.max_thread; } +/*******************************************************************\ + +Function: instrumentert::cfg_visitort::visit_cfg_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_function( /* value_sets and options */ value_setst &value_sets, @@ -287,6 +319,18 @@ void instrumentert::cfg_visitort::visit_cfg_function( } } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_propagate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::cfg_visitort::visit_cfg_propagate( goto_programt::instructionst::iterator i_it) { @@ -299,11 +343,34 @@ void inline instrumentert::cfg_visitort::visit_cfg_propagate( in_pos[i_it].insert(node); } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_thread() const { } -/// references the first and last edges of the function +/*******************************************************************\ + +Function: instrumentert::visit_cfg_reference_function + + Inputs: + + Outputs: + + Purpose: references the first and last edges of the function + +\*******************************************************************/ + /* OBSOLETE */ /* Note: can be merged with visit_cfg_body */ /* Warning: we iterate here over the successive instructions of the @@ -392,6 +459,18 @@ void inline instrumentert::cfg_visitort::visit_cfg_reference_function( std::make_pair(in_nodes, out_nodes); } +/*******************************************************************\ + +Function: alt_copy_segment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + event_idt alt_copy_segment(wmm_grapht &alt_egraph, event_idt begin, event_idt end) { @@ -401,6 +480,18 @@ event_idt alt_copy_segment(wmm_grapht &alt_egraph, return end; } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_visitort::contains_shared_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool instrumentert::cfg_visitort::contains_shared_array( goto_programt::const_targett targ, goto_programt::const_targett i_it, @@ -449,7 +540,18 @@ bool instrumentert::cfg_visitort::contains_shared_array( } -/// strategy: fwd/bwd alternation +/*******************************************************************\ + +Function: instrumentert::visit_cfg_visitort::visit_cfg_body + + Inputs: + + Outputs: + + Purpose: strategy: fwd/bwd alternation + +\*******************************************************************/ + void inline instrumentert::cfg_visitort::visit_cfg_body( goto_programt::const_targett i_it, loop_strategyt replicate_body, @@ -495,6 +597,18 @@ void inline instrumentert::cfg_visitort::visit_cfg_body( } } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_visitort::visit_cfg_duplicate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::cfg_visitort::visit_cfg_duplicate( goto_programt::const_targett targ, goto_programt::const_targett i_it) @@ -558,7 +672,18 @@ void inline instrumentert::cfg_visitort::visit_cfg_duplicate( } } -/// strategy: fwd/bwd alternation +/*******************************************************************\ + +Function: instrumentert::visit_cfg_visitort::visit_cfg_backedge + + Inputs: + + Outputs: + + Purpose: strategy: fwd/bwd alternation + +\*******************************************************************/ + void inline instrumentert::cfg_visitort::visit_cfg_backedge( goto_programt::const_targett targ, goto_programt::const_targett i_it) @@ -625,6 +750,18 @@ void inline instrumentert::cfg_visitort::visit_cfg_backedge( } } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_goto( goto_programt::instructionst::iterator i_it, loop_strategyt replicate_body, @@ -654,6 +791,18 @@ void instrumentert::cfg_visitort::visit_cfg_goto( } } +/*******************************************************************\ + +Function: intrumentert::visit_cfg_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_function_call( value_setst &value_sets, goto_programt::instructionst::iterator i_it, @@ -721,6 +870,18 @@ void instrumentert::cfg_visitort::visit_cfg_function_call( } } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_lwfence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_lwfence( goto_programt::instructionst::iterator i_it) { @@ -753,6 +914,18 @@ void instrumentert::cfg_visitort::visit_cfg_lwfence( updated.insert(i_it); } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_lwfence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_asm_fence( goto_programt::instructionst::iterator i_it) { @@ -793,6 +966,18 @@ void instrumentert::cfg_visitort::visit_cfg_asm_fence( updated.insert(i_it); } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_assign( value_setst &value_sets, namespacet &ns, @@ -1110,6 +1295,18 @@ void instrumentert::cfg_visitort::visit_cfg_assign( } } +/*******************************************************************\ + +Function: instrumentert::visit_cfg_fence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_fence( goto_programt::instructionst::iterator i_it) { @@ -1145,12 +1342,36 @@ void instrumentert::cfg_visitort::visit_cfg_fence( updated.insert(i_it); } +/*******************************************************************\ + +Function: intrumentert::visit_cfg_skip + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_visitort::visit_cfg_skip( goto_programt::instructionst::iterator i_it) { visit_cfg_propagate(i_it); } +/*******************************************************************\ + +Function: intrumentert::add_instr_to_interleaving + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::add_instr_to_interleaving( goto_programt::instructionst::iterator it, goto_programt &interleaving) @@ -1183,6 +1404,18 @@ void inline instrumentert::add_instr_to_interleaving( current_instruction->swap(new_instruction); } +/*******************************************************************\ + +Function: instrumentert::is_cfg_spurious + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc) { message.debug() << "spurious by CFG? " << messaget::eom; @@ -1324,6 +1557,18 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc) #endif } +/*******************************************************************\ + +Function: instrumentert::cfg_cycles_filter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::cfg_cycles_filter() { if(!set_of_cycles.empty()) @@ -1371,6 +1616,18 @@ void instrumentert::cfg_cycles_filter() message.status() << "No cycle to filter" << messaget::eom; } +/*******************************************************************\ + +Function: instrumentert::print_outputs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::print_outputs_local( const std::set &set, std::ofstream &dot, @@ -1530,7 +1787,18 @@ void instrumentert::print_outputs(memory_modelt model, bool hide_internals) table.close(); } -/// Note: can be distributed (#define DISTRIBUTED) +/*******************************************************************\ + +Function: instrumentert::collect_cycles_by_SCCs + + Inputs: + + Outputs: + + Purpose: Note: can be distributed (#define DISTRIBUTED) + +\*******************************************************************/ + #if 1 // #ifdef _WIN32 void instrumentert::collect_cycles_by_SCCs(memory_modelt model) diff --git a/src/goto-instrument/wmm/goto2graph.h b/src/goto-instrument/wmm/goto2graph.h index 49adbfdb640..46193c5239a 100644 --- a/src/goto-instrument/wmm/goto2graph.h +++ b/src/goto-instrument/wmm/goto2graph.h @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// Instrumenter - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_GOTO2GRAPH_H #define CPROVER_GOTO_INSTRUMENT_WMM_GOTO2GRAPH_H diff --git a/src/goto-instrument/wmm/instrumenter_pensieve.h b/src/goto-instrument/wmm/instrumenter_pensieve.h index 1e954344322..7a5210448fe 100644 --- a/src/goto-instrument/wmm/instrumenter_pensieve.h +++ b/src/goto-instrument/wmm/instrumenter_pensieve.h @@ -6,9 +6,6 @@ Module: Instrumenter \*******************************************************************/ -/// \file -/// Instrumenter - #ifndef CPROVER_GOTO_INSTRUMENT_WMM_INSTRUMENTER_PENSIEVE_H #define CPROVER_GOTO_INSTRUMENT_WMM_INSTRUMENTER_PENSIEVE_H diff --git a/src/goto-instrument/wmm/instrumenter_strategies.cpp b/src/goto-instrument/wmm/instrumenter_strategies.cpp index 258eec8df0b..f06ed867ab5 100644 --- a/src/goto-instrument/wmm/instrumenter_strategies.cpp +++ b/src/goto-instrument/wmm/instrumenter_strategies.cpp @@ -8,9 +8,6 @@ Date: 2012 \*******************************************************************/ -/// \file -/// Strategies for picking the abstract events to instrument - #include #include @@ -22,6 +19,18 @@ Date: 2012 #include #endif +/*******************************************************************\ + +Function: instrumentert::instrument_with_strategy + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) { var_to_instr.clear(); @@ -81,6 +90,18 @@ void instrumentert::instrument_with_strategy(instrumentation_strategyt strategy) message.debug() << "no cycles to instrument" << messaget::eom; } +/*******************************************************************\ + +Function: instrumentert::instrument_all_inserter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_all_inserter( const std::set &set_of_cycles) { @@ -109,6 +130,18 @@ void inline instrumentert::instrument_all_inserter( } } +/*******************************************************************\ + +Function: instrumentert::instrument_one_event_per_cycle + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_one_event_per_cycle_inserter( const std::set &set_of_cycles) { @@ -160,6 +193,18 @@ void inline instrumentert::instrument_one_event_per_cycle_inserter( } } +/*******************************************************************\ + +Function: instrumentert::instrument_one_read_per_cycle + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_one_read_per_cycle_inserter( const std::set &set_of_cycles) { @@ -167,6 +212,18 @@ void inline instrumentert::instrument_one_read_per_cycle_inserter( throw "read first strategy not implemented yet"; } +/*******************************************************************\ + +Function: instrumentert::instrument_one_write_per_cycle + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_one_write_per_cycle_inserter( const std::set &set_of_cycles) { @@ -174,7 +231,18 @@ void inline instrumentert::instrument_one_write_per_cycle_inserter( throw "write first strategy not implemented yet"; } -/// cost function +/*******************************************************************\ + +Function: instrumentert::cost + + Inputs: + + Outputs: + + Purpose: cost function + +\*******************************************************************/ + unsigned inline instrumentert::cost( const event_grapht::critical_cyclet::delayt &e) { @@ -190,6 +258,18 @@ unsigned inline instrumentert::cost( return 3; } +/*******************************************************************\ + +Function: instrumentert::instrument_minimum_interference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_minimum_interference_inserter( const std::set &set_of_cycles) { @@ -354,6 +434,18 @@ void inline instrumentert::instrument_minimum_interference_inserter( #endif } +/*******************************************************************\ + +Function: instrumentert::instrument_my_events_inserter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline instrumentert::instrument_my_events_inserter( const std::set &set, const std::set &my_events) @@ -386,6 +478,18 @@ void inline instrumentert::instrument_my_events_inserter( } } +/*******************************************************************\ + +Function: instrumentert::instrument_my_events + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void instrumentert::instrument_my_events( const std::set &my_events) { @@ -404,6 +508,18 @@ void instrumentert::instrument_my_events( message.debug() << "no cycles to instrument" << messaget::eom; } +/*******************************************************************\ + +Function: extract_my_events + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set instrumentert::extract_my_events() { std::ifstream file; diff --git a/src/goto-instrument/wmm/pair_collection.cpp b/src/goto-instrument/wmm/pair_collection.cpp index 9226226fccd..4748ac2d2e7 100644 --- a/src/goto-instrument/wmm/pair_collection.cpp +++ b/src/goto-instrument/wmm/pair_collection.cpp @@ -9,10 +9,6 @@ Date: 2013 \*******************************************************************/ -/// \file -/// collection of pairs (for Pensieve's static delay-set analysis) in graph of -/// abstract events - #include #include @@ -22,6 +18,18 @@ Date: 2013 #define OUTPUT(s, fence, file, line, id, type) \ s< #include @@ -33,6 +30,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" #include "format_strings.h" +/*******************************************************************\ + +Function: goto_convertt::do_prob_uniform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_prob_uniform( const exprt &lhs, const exprt &function, @@ -111,6 +120,18 @@ void goto_convertt::do_prob_uniform( copy(assignment, ASSIGN, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_prob_coin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_prob_coin( const exprt &lhs, const exprt &function, @@ -188,6 +209,18 @@ void goto_convertt::do_prob_coin( copy(assignment, ASSIGN, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_printf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_printf( const exprt &lhs, const exprt &function, @@ -223,6 +256,18 @@ void goto_convertt::do_printf( assert(false); } +/*******************************************************************\ + +Function: goto_convertt::do_scanf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_scanf( const exprt &lhs, const exprt &function, @@ -326,6 +371,18 @@ void goto_convertt::do_scanf( assert(false); } +/*******************************************************************\ + +Function: goto_convertt::do_input + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_input( const exprt &lhs, const exprt &function, @@ -347,6 +404,18 @@ void goto_convertt::do_input( copy(input_code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_output( const exprt &lhs, const exprt &function, @@ -368,6 +437,18 @@ void goto_convertt::do_output( copy(output_code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_atomic_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_atomic_begin( const exprt &lhs, const exprt &function, @@ -392,6 +473,18 @@ void goto_convertt::do_atomic_begin( t->source_location=function.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::do_atomic_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_atomic_end( const exprt &lhs, const exprt &function, @@ -416,6 +509,18 @@ void goto_convertt::do_atomic_end( t->source_location=function.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::do_cpp_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_cpp_new( const exprt &lhs, const side_effect_exprt &rhs, @@ -536,6 +641,18 @@ void goto_convertt::do_cpp_new( dest.destructive_append(tmp_initializer); } +/*******************************************************************\ + +Function: set_class_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void set_class_identifier( struct_exprt &expr, const namespacet &ns, @@ -561,6 +678,18 @@ void set_class_identifier( } } +/*******************************************************************\ + +Function: goto_convertt::do_java_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_java_new( const exprt &lhs, const side_effect_exprt &rhs, @@ -616,6 +745,18 @@ void goto_convertt::do_java_new( t_i->source_location=location; } +/*******************************************************************\ + +Function: goto_convertt::do_java_new_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_java_new_array( const exprt &lhs, const side_effect_exprt &rhs, @@ -795,7 +936,19 @@ void goto_convertt::do_java_new_array( } } -/// builds a goto program for object initialization after new +/*******************************************************************\ + +Function: goto_convertt::cpp_new_initializer + + Inputs: + + Outputs: + + Purpose: builds a goto program for object initialization + after new + +\*******************************************************************/ + void goto_convertt::cpp_new_initializer( const exprt &lhs, const side_effect_exprt &rhs, @@ -824,6 +977,18 @@ void goto_convertt::cpp_new_initializer( } } +/*******************************************************************\ + +Function: goto_convertt::get_array_argument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_convertt::get_array_argument(const exprt &src) { if(src.id()==ID_typecast) @@ -860,6 +1025,18 @@ exprt goto_convertt::get_array_argument(const exprt &src) return src.op0().op0(); } +/*******************************************************************\ + +Function: goto_convertt::do_array_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_array_set( const exprt &lhs, const exprt &function, @@ -880,6 +1057,18 @@ void goto_convertt::do_array_set( copy(array_set_statement, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_array_copy + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_array_copy( const exprt &lhs, const exprt &function, @@ -900,6 +1089,18 @@ void goto_convertt::do_array_copy( copy(array_copy_statement, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::do_array_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_array_equal( const exprt &lhs, const exprt &function, @@ -943,6 +1144,18 @@ void goto_convertt::do_array_equal( } } +/*******************************************************************\ + +Function: is_lvalue + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_lvalue(const exprt &expr) { if(expr.id()==ID_index) @@ -957,6 +1170,18 @@ bool is_lvalue(const exprt &expr) return false; } +/*******************************************************************\ + +Function: make_va_list + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt make_va_list(const exprt &expr) { // we first strip any typecast @@ -972,7 +1197,19 @@ exprt make_va_list(const exprt &expr) return expr; } -/// add function calls to function queue for later processing +/*******************************************************************\ + +Function: goto_convertt::do_function_call_symbol + + Inputs: + + Outputs: + + Purpose: add function calls to function queue for later + processing + +\*******************************************************************/ + void goto_convertt::do_function_call_symbol( const exprt &lhs, const symbol_exprt &function, diff --git a/src/goto-programs/cfg.h b/src/goto-programs/cfg.h index 364e13b7b74..2fc7522a67d 100644 --- a/src/goto-programs/cfg.h +++ b/src/goto-programs/cfg.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Control Flow Graph - #ifndef CPROVER_GOTO_PROGRAMS_CFG_H #define CPROVER_GOTO_PROGRAMS_CFG_H @@ -17,6 +14,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" +/*******************************************************************\ + + Class: cfg_baset + + Purpose: + +\*******************************************************************/ + class empty_cfg_nodet { }; @@ -131,6 +136,14 @@ class cfg_baset:public grapht< cfg_base_nodet > bool nodes_empty(P &program) const { return program.instructions.empty(); } }; +/*******************************************************************\ + + Class: concurrent_cfg_baset + + Purpose: + +\*******************************************************************/ + template @@ -144,6 +157,14 @@ class concurrent_cfg_baset:public virtual cfg_baset typename cfg_baset::entryt &entry); }; +/*******************************************************************\ + + Class: procedure_local_cfg_baset + + Purpose: + +\*******************************************************************/ + template @@ -158,6 +179,14 @@ class procedure_local_cfg_baset:public virtual cfg_baset typename cfg_baset::entryt &entry); }; +/*******************************************************************\ + + Class: procedure_local_concurrent_cfg_baset + + Purpose: + +\*******************************************************************/ + template @@ -167,6 +196,18 @@ class procedure_local_concurrent_cfg_baset: { }; +/*******************************************************************\ + +Function: cfg_baset::compute_edges_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges_goto( const goto_programt &goto_program, @@ -183,6 +224,18 @@ void cfg_baset::compute_edges_goto( this->add_edge(entry, entry_map[t]); } +/*******************************************************************\ + +Function: cfg_baset::compute_edges_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges_catch( const goto_programt &goto_program, @@ -201,6 +254,18 @@ void cfg_baset::compute_edges_catch( this->add_edge(entry, entry_map[t]); } +/*******************************************************************\ + +Function: cfg_baset::compute_edges_throw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges_throw( const goto_programt &goto_program, @@ -211,6 +276,18 @@ void cfg_baset::compute_edges_throw( // no (trivial) successors } +/*******************************************************************\ + +Function: cfg_baset::compute_edges_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges_start_thread( const goto_programt &goto_program, @@ -222,6 +299,18 @@ void cfg_baset::compute_edges_start_thread( this->add_edge(entry, entry_map[next_PC]); } +/*******************************************************************\ + +Function: concurrent_cfg_baset::compute_edges_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void concurrent_cfg_baset::compute_edges_start_thread( const goto_programt &goto_program, @@ -240,6 +329,18 @@ void concurrent_cfg_baset::compute_edges_start_thread( this->add_edge(entry, this->entry_map[t]); } +/*******************************************************************\ + +Function: cfg_baset::compute_edges_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges_function_call( const goto_functionst &goto_functions, @@ -291,6 +392,18 @@ void cfg_baset::compute_edges_function_call( this->add_edge(entry, entry_map[next_PC]); } +/*******************************************************************\ + +Function: procedure_local_cfg_baset::compute_edges_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void procedure_local_cfg_baset::compute_edges_function_call( const goto_functionst &goto_functions, @@ -309,6 +422,18 @@ void procedure_local_cfg_baset::compute_edges_function_call( this->add_edge(entry, this->entry_map[next_PC]); } +/*******************************************************************\ + +Function: cfg_baset::compute_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges( const goto_functionst &goto_functions, @@ -383,6 +508,18 @@ void cfg_baset::compute_edges( } } +/*******************************************************************\ + +Function: cfg_baset::compute_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges( const goto_functionst &goto_functions, @@ -394,6 +531,18 @@ void cfg_baset::compute_edges( compute_edges(goto_functions, goto_program, it); } +/*******************************************************************\ + +Function: cfg_baset::compute_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void cfg_baset::compute_edges( const goto_functionst &goto_functions) diff --git a/src/goto-programs/class_hierarchy.cpp b/src/goto-programs/class_hierarchy.cpp index 10a16760b98..1311a3e7fdc 100644 --- a/src/goto-programs/class_hierarchy.cpp +++ b/src/goto-programs/class_hierarchy.cpp @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Class Hierarchy - #include #include @@ -18,6 +15,18 @@ Date: April 2016 #include "class_hierarchy.h" +/*******************************************************************\ + +Function: class_hierarchyt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void class_hierarchyt::operator()(const symbol_tablet &symbol_table) { forall_symbols(it, symbol_table.symbols) @@ -43,6 +52,18 @@ void class_hierarchyt::operator()(const symbol_tablet &symbol_table) } } +/*******************************************************************\ + +Function: class_hierarchyt::get_children_trans_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void class_hierarchyt::get_children_trans_rec( const irep_idt &c, idst &dest) const @@ -60,6 +81,18 @@ void class_hierarchyt::get_children_trans_rec( get_children_trans_rec(child, dest); } +/*******************************************************************\ + +Function: class_hierarchyt::get_parents_trans_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void class_hierarchyt::get_parents_trans_rec( const irep_idt &c, idst &dest) const @@ -77,6 +110,18 @@ void class_hierarchyt::get_parents_trans_rec( get_parents_trans_rec(child, dest); } +/*******************************************************************\ + +Function: class_hierarchyt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void class_hierarchyt::output(std::ostream &out) const { for(const auto &c : class_map) diff --git a/src/goto-programs/class_hierarchy.h b/src/goto-programs/class_hierarchy.h index 5cd33b4d864..bef2c7ec7eb 100644 --- a/src/goto-programs/class_hierarchy.h +++ b/src/goto-programs/class_hierarchy.h @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Class Hierarchy - #ifndef CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H #define CPROVER_GOTO_PROGRAMS_CLASS_HIERARCHY_H diff --git a/src/goto-programs/class_identifier.cpp b/src/goto-programs/class_identifier.cpp index bbdc94c8533..6e814174e51 100644 --- a/src/goto-programs/class_identifier.cpp +++ b/src/goto-programs/class_identifier.cpp @@ -6,17 +6,24 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Extract class identifier - #include "class_identifier.h" #include #include -/// \par parameters: Struct expression -/// \return Member expression giving the clsid field of the input, or its -/// parent, grandparent, etc. +/*******************************************************************\ + +Function: build_class_identifier + + Inputs: Struct expression + + Outputs: Member expression giving the clsid field of the input, + or its parent, grandparent, etc. + + Purpose: + +\*******************************************************************/ + static exprt build_class_identifier( const exprt &src, const namespacet &ns) @@ -49,9 +56,19 @@ static exprt build_class_identifier( } } -/// \par parameters: Pointer expression of any pointer type, including void*, -/// and a recommended access type if the pointer is void-typed. -/// \return Member expression to access a class identifier, as above. +/*******************************************************************\ + +Function: get_class_identifier_field + + Inputs: Pointer expression of any pointer type, including void*, + and a recommended access type if the pointer is void-typed. + + Outputs: Member expression to access a class identifier, as above. + + Purpose: + +\*******************************************************************/ + exprt get_class_identifier_field( const exprt &this_expr_in, const symbol_typet &suggested_type, diff --git a/src/goto-programs/class_identifier.h b/src/goto-programs/class_identifier.h index ccc679b8e1f..8ae6dc4ce71 100644 --- a/src/goto-programs/class_identifier.h +++ b/src/goto-programs/class_identifier.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Extract class identifier - #ifndef CPROVER_GOTO_PROGRAMS_CLASS_IDENTIFIER_H #define CPROVER_GOTO_PROGRAMS_CLASS_IDENTIFIER_H diff --git a/src/goto-programs/compute_called_functions.cpp b/src/goto-programs/compute_called_functions.cpp index 251a89c5054..0c1acc08d22 100644 --- a/src/goto-programs/compute_called_functions.cpp +++ b/src/goto-programs/compute_called_functions.cpp @@ -6,14 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Query Called Functions - #include #include "compute_called_functions.h" -/// get all functions whose address is taken +/*******************************************************************\ + +Function: compute_address_taken_functions + + Inputs: + + Outputs: + + Purpose: get all functions whose address is taken + +\*******************************************************************/ + void compute_address_taken_functions( const exprt &src, std::set &address_taken) @@ -32,7 +40,18 @@ void compute_address_taken_functions( } } -/// get all functions in the expression +/*******************************************************************\ + +Function: compute_functions + + Inputs: + + Outputs: + + Purpose: get all functions in the expression + +\*******************************************************************/ + void compute_functions( const exprt &src, std::set &address_taken) @@ -45,7 +64,18 @@ void compute_functions( address_taken.insert(to_symbol_expr(src).get_identifier()); } -/// get all functions whose address is taken +/*******************************************************************\ + +Function: compute_address_taken_functions + + Inputs: + + Outputs: + + Purpose: get all functions whose address is taken + +\*******************************************************************/ + void compute_address_taken_functions( const goto_programt &goto_program, std::set &address_taken) @@ -57,7 +87,18 @@ void compute_address_taken_functions( } } -/// get all functions whose address is taken +/*******************************************************************\ + +Function: compute_address_taken_functions + + Inputs: + + Outputs: + + Purpose: get all functions whose address is taken + +\*******************************************************************/ + void compute_address_taken_functions( const goto_functionst &goto_functions, std::set &address_taken) @@ -66,7 +107,18 @@ void compute_address_taken_functions( compute_address_taken_functions(it->second.body, address_taken); } -/// computes the functions that are (potentially) called +/*******************************************************************\ + +Function: compute_called_functions + + Inputs: + + Outputs: + + Purpose: computes the functions that are (potentially) called + +\*******************************************************************/ + void compute_called_functions( const goto_functionst &goto_functions, std::set &functions) @@ -111,7 +163,18 @@ void compute_called_functions( } } -/// computes the functions that are (potentially) called +/*******************************************************************\ + +Function: compute_called_functions + + Inputs: + + Outputs: + + Purpose: computes the functions that are (potentially) called + +\*******************************************************************/ + void compute_called_functions( const goto_modelt &goto_model, std::set &functions) diff --git a/src/goto-programs/compute_called_functions.h b/src/goto-programs/compute_called_functions.h index 6f92b420b37..40dba2b894e 100644 --- a/src/goto-programs/compute_called_functions.h +++ b/src/goto-programs/compute_called_functions.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Query Called Functions - #ifndef CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H diff --git a/src/goto-programs/convert_nondet.cpp b/src/goto-programs/convert_nondet.cpp index 9e1a6d388c5..7762b13a9f3 100644 --- a/src/goto-programs/convert_nondet.cpp +++ b/src/goto-programs/convert_nondet.cpp @@ -6,9 +6,6 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ -/// \file -/// Convert side_effect_expr_nondett expressions - #include "goto-programs/convert_nondet.h" #include "goto-programs/goto_convert.h" #include "goto-programs/goto_model.h" @@ -18,15 +15,26 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com #include "util/irep_ids.h" -/// Checks an instruction to see whether it contains an assignment from -/// side_effect_expr_nondet. If so, replaces the instruction with a range of -/// instructions to properly nondet-initialize the lhs. -/// \param goto_program: The goto program to modify. -/// \param target: One of the steps in that goto program. -/// \param symbol_table: The global symbol table. -/// \param message_handler: Handles logging. -/// \param max_nondet_array_length: Maximum size of new nondet arrays. -/// \return The next instruction to process with this function. +/*******************************************************************\ + +Function: insert_nondet_init_code + + Inputs: + goto_program: The goto program to modify. + target: One of the steps in that goto program. + symbol_table: The global symbol table. + message_handler: Handles logging. + max_nondet_array_length: Maximum size of new nondet arrays. + + Outputs: The next instruction to process with this function. + + Purpose: Checks an instruction to see whether it contains an assignment + from side_effect_expr_nondet. If so, replaces the instruction + with a range of instructions to properly nondet-initialize + the lhs. + +\*******************************************************************/ + static goto_programt::targett insert_nondet_init_code( goto_programt &goto_program, const goto_programt::targett &target, @@ -100,13 +108,22 @@ static goto_programt::targett insert_nondet_init_code( return next_instr; } -/// For each instruction in the goto program, checks if it is an assignment from -/// nondet and replaces it with the appropriate composite initialization code if -/// so. -/// \param goto_program: The goto program to modify. -/// \param symbol_table: The global symbol table. -/// \param message_handler: Handles logging. -/// \param max_nondet_array_length: Maximum size of new nondet arrays. +/*******************************************************************\ + +Function: convert_nondet + + Inputs: + goto_program: The goto program to modify. + symbol_table: The global symbol table. + message_handler: Handles logging. + max_nondet_array_length: Maximum size of new nondet arrays. + + Purpose: For each instruction in the goto program, checks if it is + an assignment from nondet and replaces it with the appropriate + composite initialization code if so. + +\*******************************************************************/ + static void convert_nondet( goto_programt &goto_program, symbol_tablet &symbol_table, diff --git a/src/goto-programs/convert_nondet.h b/src/goto-programs/convert_nondet.h index 2d083c58bf7..919d977a94e 100644 --- a/src/goto-programs/convert_nondet.h +++ b/src/goto-programs/convert_nondet.h @@ -6,9 +6,6 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ -/// \file -/// Convert side_effect_expr_nondett expressions - #ifndef CPROVER_GOTO_PROGRAMS_CONVERT_NONDET_H #define CPROVER_GOTO_PROGRAMS_CONVERT_NONDET_H @@ -18,12 +15,21 @@ class goto_functionst; class symbol_tablet; class message_handlert; -/// Replace calls to nondet library functions with an internal nondet -/// representation. -/// \param goto_functions: The set of goto programs to modify. -/// \param symbol_table: The symbol table to query/update. -/// \param message_handler: For error logging. -/// \param max_nondet_array_length: The maximum length of any new arrays. +/*******************************************************************\ + +Function: convert_nondet + + Inputs: + goto_functions: The set of goto programs to modify. + symbol_table: The symbol table to query/update. + message_handler: For error logging. + max_nondet_array_length: The maximum length of any new arrays. + + Purpose: Replace calls to nondet library functions with an internal + nondet representation. + +\*******************************************************************/ + void convert_nondet( goto_functionst &goto_functions, symbol_tablet &symbol_table, diff --git a/src/goto-programs/destructor.cpp b/src/goto-programs/destructor.cpp index 956734ddee2..ba1fe127a5f 100644 --- a/src/goto-programs/destructor.cpp +++ b/src/goto-programs/destructor.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Destructor Calls - #include #include #include "destructor.h" +/*******************************************************************\ + +Function: get_destructor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + code_function_callt get_destructor( const namespacet &ns, const typet &type) diff --git a/src/goto-programs/destructor.h b/src/goto-programs/destructor.h index 3fd62efb0c4..2ea310361f3 100644 --- a/src/goto-programs/destructor.h +++ b/src/goto-programs/destructor.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Destructor Calls - #ifndef CPROVER_GOTO_PROGRAMS_DESTRUCTOR_H #define CPROVER_GOTO_PROGRAMS_DESTRUCTOR_H diff --git a/src/goto-programs/elf_reader.cpp b/src/goto-programs/elf_reader.cpp index 1668a88c8b5..9a2212bfbfc 100644 --- a/src/goto-programs/elf_reader.cpp +++ b/src/goto-programs/elf_reader.cpp @@ -6,13 +6,22 @@ Module: Read ELF \*******************************************************************/ -/// \file -/// Read ELF - #include #include "elf_reader.h" +/*******************************************************************\ + +Function: elf_readert::elf_readert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + elf_readert::elf_readert(std::istream &_in):in(_in) { // read 32-bit header @@ -121,6 +130,18 @@ elf_readert::elf_readert(std::istream &_in):in(_in) } } +/*******************************************************************\ + +Function: elf_readert::get_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string elf_readert::get_string(std::streampos index) const { in.seekg(string_table_offset+index); @@ -139,6 +160,18 @@ std::string elf_readert::get_string(std::streampos index) const return result; } +/*******************************************************************\ + +Function: elf_readert::has_section + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool elf_readert::has_section(const std::string &name) const { for(unsigned i=0; i #include @@ -18,6 +15,18 @@ Author: CM Wintersteiger #include "format_strings.h" +/*******************************************************************\ + +Function: parse_flags + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_flags( std::string::const_iterator &it, format_tokent &curtok) @@ -43,6 +52,18 @@ void parse_flags( } } +/*******************************************************************\ + +Function: parse_field_width + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_field_width( std::string::const_iterator &it, format_tokent &curtok) @@ -58,6 +79,18 @@ void parse_field_width( curtok.field_width=string2integer(tmp); } +/*******************************************************************\ + +Function: parse_precision + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_precision( std::string::const_iterator &it, format_tokent &curtok) @@ -80,6 +113,18 @@ void parse_precision( } } +/*******************************************************************\ + +Function: parse_length_modifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_length_modifier( std::string::const_iterator &it, format_tokent &curtok) @@ -115,6 +160,18 @@ void parse_length_modifier( } } +/*******************************************************************\ + +Function: parse_conversion_specifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_conversion_specifier( const std::string &arg_string, std::string::const_iterator &it, @@ -180,6 +237,18 @@ void parse_conversion_specifier( it++; } +/*******************************************************************\ + +Function: parse_format_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + format_token_listt parse_format_string(const std::string &arg_string) { format_token_listt token_list; @@ -218,6 +287,18 @@ format_token_listt parse_format_string(const std::string &arg_string) return token_list; } +/*******************************************************************\ + +Function: get_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet get_type(const format_tokent &token) { switch(token.type) diff --git a/src/goto-programs/format_strings.h b/src/goto-programs/format_strings.h index 8c233324ecf..6283b77f19b 100644 --- a/src/goto-programs/format_strings.h +++ b/src/goto-programs/format_strings.h @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Format String Parser - #ifndef CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H #define CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H diff --git a/src/goto-programs/goto_asm.cpp b/src/goto-programs/goto_asm.cpp index 63492b5d9ce..782d601a29e 100644 --- a/src/goto-programs/goto_asm.cpp +++ b/src/goto-programs/goto_asm.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Assembler -> Goto - #include "goto_convert_class.h" +/*******************************************************************\ + +Function: goto_convertt::convert_asm + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_asm( const code_asmt &code, goto_programt &dest) diff --git a/src/goto-programs/goto_clean_expr.cpp b/src/goto-programs/goto_clean_expr.cpp index eae048c62a4..c7fa8637194 100644 --- a/src/goto-programs/goto_clean_expr.cpp +++ b/src/goto-programs/goto_clean_expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" +/*******************************************************************\ + +Function: goto_convertt::make_compound_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt goto_convertt::make_compound_literal( const exprt &expr, goto_programt &dest) @@ -60,6 +69,18 @@ symbol_exprt goto_convertt::make_compound_literal( return result; } +/*******************************************************************\ + +Function: goto_convertt::needs_cleaning + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_convertt::needs_cleaning(const exprt &expr) { if(expr.id()==ID_dereference || @@ -104,7 +125,18 @@ bool goto_convertt::needs_cleaning(const exprt &expr) return false; } -/// re-write boolean operators into ?: +/*******************************************************************\ + +Function: goto_convertt::rewrite_boolean + + Inputs: + + Outputs: + + Purpose: re-write boolean operators into ?: + +\*******************************************************************/ + void goto_convertt::rewrite_boolean(exprt &expr) { assert(expr.id()==ID_and || expr.id()==ID_or); @@ -160,6 +192,18 @@ void goto_convertt::rewrite_boolean(exprt &expr) expr.swap(tmp); } +/*******************************************************************\ + +Function: goto_convertt::clean_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::clean_expr( exprt &expr, goto_programt &dest, @@ -437,6 +481,18 @@ void goto_convertt::clean_expr( } } +/*******************************************************************\ + +Function: goto_convertt::clean_expr_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::clean_expr_address_of( exprt &expr, goto_programt &dest) @@ -500,6 +556,18 @@ void goto_convertt::clean_expr_address_of( clean_expr_address_of(*it, dest); } +/*******************************************************************\ + +Function: goto_convertt::remove_gcc_conditional_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_gcc_conditional_expression( exprt &expr, goto_programt &dest) diff --git a/src/goto-programs/goto_convert.cpp b/src/goto-programs/goto_convert.cpp index 6aec28ea24f..25118d0b223 100644 --- a/src/goto-programs/goto_convert.cpp +++ b/src/goto-programs/goto_convert.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" #include "destructor.h" +/*******************************************************************\ + +Function: is_empty + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool is_empty(const goto_programt &goto_program) { forall_goto_program_instructions(it, goto_program) @@ -37,8 +46,19 @@ static bool is_empty(const goto_programt &goto_program) return true; } -/// Populate the CATCH instructions with the targets corresponding to their -/// associated labels +/*******************************************************************\ + +Function: finish_catch_push_targets + + Inputs: + + Outputs: + + Purpose: Populate the CATCH instructions with the targets + corresponding to their associated labels + +\*******************************************************************/ + static void finish_catch_push_targets(goto_programt &dest) { std::map label_targets; @@ -229,6 +249,18 @@ void goto_convertt::finish_gotos(goto_programt &dest) targets.gotos.clear(); } +/*******************************************************************\ + +Function: goto_convertt::finish_computed_gotos + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::finish_computed_gotos(goto_programt &goto_program) { for(auto &g_it : targets.computed_gotos) @@ -268,9 +300,21 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) targets.computed_gotos.clear(); } -/// For each if(x) goto z; goto y; z: emitted, see if any destructor statements -/// were inserted between goto z and z, and if not, simplify into if(!x) goto y; -/// \par parameters: Destination goto program +/*******************************************************************\ + +Function: goto_convertt::finish_guarded_gotos + + Inputs: Destination goto program + + Outputs: + + Purpose: For each if(x) goto z; goto y; z: emitted, + see if any destructor statements were inserted + between goto z and z, and if not, simplify into + if(!x) goto y; + +\*******************************************************************/ + void goto_convertt::finish_guarded_gotos(goto_programt &dest) { for(auto &gg : guarded_gotos) @@ -300,11 +344,35 @@ void goto_convertt::finish_guarded_gotos(goto_programt &dest) } } +/*******************************************************************\ + +Function: goto_convertt::goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::goto_convert(const codet &code, goto_programt &dest) { goto_convert_rec(code, dest); } +/*******************************************************************\ + +Function: goto_convertt::goto_convert_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::goto_convert_rec( const codet &code, goto_programt &dest) @@ -317,6 +385,18 @@ void goto_convertt::goto_convert_rec( finish_catch_push_targets(dest); } +/*******************************************************************\ + +Function: goto_convertt::copy + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::copy( const codet &code, goto_program_instruction_typet type, @@ -327,6 +407,18 @@ void goto_convertt::copy( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convert::convert_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_label( const code_labelt &code, goto_programt &dest) @@ -362,6 +454,18 @@ void goto_convertt::convert_label( target->labels.push_front(label); } +/*******************************************************************\ + +Function: goto_convert::convert_gcc_local_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_local_label( const codet &code, goto_programt &dest) @@ -369,6 +473,18 @@ void goto_convertt::convert_gcc_local_label( // ignore for now } +/*******************************************************************\ + +Function: goto_convert::convert_switch_case + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_switch_case( const code_switch_caset &code, goto_programt &dest) @@ -408,6 +524,18 @@ void goto_convertt::convert_switch_case( } } +/*******************************************************************\ + +Function: goto_convert::convert_gcc_switch_case_range + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_switch_case_range( const codet &code, goto_programt &dest) @@ -441,7 +569,18 @@ void goto_convertt::convert_gcc_switch_case_range( #endif } -/// converts 'code' and appends the result to 'dest' +/*******************************************************************\ + +Function: goto_convertt::convert + + Inputs: + + Outputs: + + Purpose: converts 'code' and appends the result to 'dest' + +\*******************************************************************/ + void goto_convertt::convert( const codet &code, goto_programt &dest) @@ -575,6 +714,18 @@ void goto_convertt::convert( } } +/*******************************************************************\ + +Function: goto_convertt::convert_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_block( const code_blockt &code, goto_programt &dest) @@ -606,6 +757,18 @@ void goto_convertt::convert_block( targets.destructor_stack.resize(old_stack_size); } +/*******************************************************************\ + +Function: goto_convertt::convert_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_expression( const code_expressiont &code, goto_programt &dest) @@ -649,6 +812,18 @@ void goto_convertt::convert_expression( } } +/*******************************************************************\ + +Function: goto_convertt::convert_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_decl( const code_declt &code, goto_programt &dest) @@ -718,6 +893,18 @@ void goto_convertt::convert_decl( } } +/*******************************************************************\ + +Function: goto_convertt::convert_decl_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_decl_type( const codet &code, goto_programt &dest) @@ -725,6 +912,18 @@ void goto_convertt::convert_decl_type( // we remove these } +/*******************************************************************\ + +Function: goto_convertt::convert_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assign( const code_assignt &code, goto_programt &dest) @@ -812,6 +1011,18 @@ void goto_convertt::convert_assign( } } +/*******************************************************************\ + +Function: goto_convertt::convert_init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_init( const codet &code, goto_programt &dest) @@ -830,6 +1041,18 @@ void goto_convertt::convert_init( convert(to_code_assign(assignment), dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_cpp_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_cpp_delete( const codet &code, goto_programt &dest) @@ -895,6 +1118,18 @@ void goto_convertt::convert_cpp_delete( convert(delete_call, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assert( const code_assertt &code, goto_programt &dest) @@ -910,6 +1145,18 @@ void goto_convertt::convert_assert( t->source_location.set("user-provided", true); } +/*******************************************************************\ + +Function: goto_convertt::convert_skip + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_skip( const codet &code, goto_programt &dest) @@ -919,6 +1166,18 @@ void goto_convertt::convert_skip( t->code=code; } +/*******************************************************************\ + +Function: goto_convertt::convert_assume + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assume( const code_assumet &code, goto_programt &dest) @@ -932,6 +1191,18 @@ void goto_convertt::convert_assume( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_loop_invariant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_loop_invariant( const codet &code, goto_programt::targett loop) @@ -955,12 +1226,24 @@ void goto_convertt::convert_loop_invariant( loop->guard.add(ID_C_spec_loop_invariant).swap(invariant); } -void goto_convertt::convert_for( - const code_fort &code, - goto_programt &dest) -{ - // turn for(A; c; B) { P } into - // A; while(c) { P; B; } +/*******************************************************************\ + +Function: goto_convertt::convert_for + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void goto_convertt::convert_for( + const code_fort &code, + goto_programt &dest) +{ + // turn for(A; c; B) { P } into + // A; while(c) { P; B; } //----------------------------- // A; // u: sideeffects in c @@ -1054,6 +1337,18 @@ void goto_convertt::convert_for( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_while + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_while( const code_whilet &code, goto_programt &dest) @@ -1114,6 +1409,18 @@ void goto_convertt::convert_while( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_dowhile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_dowhile( const codet &code, goto_programt &dest) @@ -1186,6 +1493,18 @@ void goto_convertt::convert_dowhile( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::case_guard + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_convertt::case_guard( const exprt &value, const exprt::operandst &case_op) @@ -1213,6 +1532,18 @@ exprt goto_convertt::case_guard( return dest; } +/*******************************************************************\ + +Function: goto_convertt::convert_switch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_switch( const code_switcht &code, goto_programt &dest) @@ -1296,6 +1627,18 @@ void goto_convertt::convert_switch( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_break + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_break( const code_breakt &code, goto_programt &dest) @@ -1317,6 +1660,18 @@ void goto_convertt::convert_break( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_return( const code_returnt &code, goto_programt &dest) @@ -1387,6 +1742,18 @@ void goto_convertt::convert_return( t->source_location=new_code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_continue + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_continue( const code_continuet &code, goto_programt &dest) @@ -1408,6 +1775,18 @@ void goto_convertt::convert_continue( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_goto( const codet &code, goto_programt &dest) @@ -1421,6 +1800,18 @@ void goto_convertt::convert_goto( targets.gotos.push_back(std::make_pair(t, targets.destructor_stack)); } +/*******************************************************************\ + +Function: goto_convertt::convert_gcc_computed_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_computed_goto( const codet &code, goto_programt &dest) @@ -1434,6 +1825,18 @@ void goto_convertt::convert_gcc_computed_goto( targets.computed_gotos.push_back(t); } +/*******************************************************************\ + +Function: goto_convertt::convert_non_deterministic_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_non_deterministic_goto( const codet &code, goto_programt &dest) @@ -1441,6 +1844,18 @@ void goto_convertt::convert_non_deterministic_goto( convert_goto(code, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_notify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_notify( const codet &code, goto_programt &dest) @@ -1458,6 +1873,18 @@ void goto_convertt::convert_specc_notify( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_event + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_event( const exprt &op, std::set &events) @@ -1484,6 +1911,18 @@ void goto_convertt::convert_specc_event( } } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_wait + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_wait( const codet &code, goto_programt &dest) @@ -1512,6 +1951,18 @@ void goto_convertt::convert_specc_wait( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_par + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_par( const codet &code, goto_programt &dest) @@ -1519,6 +1970,18 @@ void goto_convertt::convert_specc_par( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_start_thread( const codet &code, goto_programt &dest) @@ -1558,6 +2021,18 @@ void goto_convertt::convert_start_thread( } } +/*******************************************************************\ + +Function: goto_convertt::convert_end_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_end_thread( const codet &code, goto_programt &dest) @@ -1572,6 +2047,18 @@ void goto_convertt::convert_end_thread( copy(code, END_THREAD, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_atomic_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_atomic_begin( const codet &code, goto_programt &dest) @@ -1586,6 +2073,18 @@ void goto_convertt::convert_atomic_begin( copy(code, ATOMIC_BEGIN, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_atomic_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_atomic_end( const codet &code, goto_programt &dest) @@ -1600,6 +2099,18 @@ void goto_convertt::convert_atomic_end( copy(code, ATOMIC_END, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_bp_enforce + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_bp_enforce( const codet &code, goto_programt &dest) @@ -1659,6 +2170,18 @@ void goto_convertt::convert_bp_enforce( dest.destructive_append(tmp); } +/*******************************************************************\ + +Function: goto_convertt::convert_bp_abortif + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_bp_abortif( const codet &code, goto_programt &dest) @@ -1682,6 +2205,18 @@ void goto_convertt::convert_bp_abortif( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_ifthenelse( const code_ifthenelset &code, goto_programt &dest) @@ -1733,6 +2268,18 @@ void goto_convertt::convert_ifthenelse( generate_ifthenelse(tmp_guard, tmp_then, tmp_else, source_location, dest); } +/*******************************************************************\ + +Function: goto_convertt::collect_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::collect_operands( const exprt &expr, const irep_idt &id, @@ -1750,16 +2297,36 @@ void goto_convertt::collect_operands( } } -/// This is (believed to be) faster than using std::list.size -/// \par parameters: Goto program 'g' -/// \return True if 'g' has one instruction +/*******************************************************************\ + +Function: is_size_one + + Inputs: Goto program 'g' + + Outputs: True if 'g' has one instruction + + Purpose: This is (believed to be) faster than using std::list.size + +\*******************************************************************/ + static inline bool is_size_one(const goto_programt &g) { return (!g.instructions.empty()) && ++g.instructions.begin()==g.instructions.end(); } -/// if(guard) true_case; else false_case; +/*******************************************************************\ + +Function: goto_convertt::generate_ifthenelse + + Inputs: + + Outputs: + + Purpose: if(guard) true_case; else false_case; + +\*******************************************************************/ + void goto_convertt::generate_ifthenelse( const exprt &guard, goto_programt &true_case, @@ -1900,7 +2467,18 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(tmp_z); } -/// if(guard) goto target; +/*******************************************************************\ + +Function: goto_convertt::generate_conditional_branch + + Inputs: + + Outputs: + + Purpose: if(guard) goto target; + +\*******************************************************************/ + static bool has_and_or(const exprt &expr) { forall_operands(it, expr) @@ -1951,7 +2529,18 @@ void goto_convertt::generate_conditional_branch( } } -/// if(guard) goto target_true; else goto target_false; +/*******************************************************************\ + +Function: goto_convertt::generate_conditional_branch + + Inputs: + + Outputs: + + Purpose: if(guard) goto target_true; else goto target_false; + +\*******************************************************************/ + void goto_convertt::generate_conditional_branch( const exprt &guard, goto_programt::targett target_true, @@ -2029,6 +2618,18 @@ void goto_convertt::generate_conditional_branch( t_false->source_location=source_location; } +/*******************************************************************\ + +Function: goto_convertt::get_string_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_convertt::get_string_constant( const exprt &expr, irep_idt &value) @@ -2070,6 +2671,18 @@ bool goto_convertt::get_string_constant( return true; } +/*******************************************************************\ + +Function: goto_convertt::get_string_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt goto_convertt::get_string_constant(const exprt &expr) { irep_idt result; @@ -2086,6 +2699,18 @@ irep_idt goto_convertt::get_string_constant(const exprt &expr) return result; } +/*******************************************************************\ + +Function: goto_convertt::get_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_convertt::get_constant(const exprt &expr) { if(expr.id()==ID_symbol) @@ -2112,6 +2737,18 @@ exprt goto_convertt::get_constant(const exprt &expr) return expr; } +/*******************************************************************\ + +Function: goto_convertt::new_tmp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbolt &goto_convertt::new_tmp_symbol( const typet &type, const std::string &suffix, @@ -2135,6 +2772,18 @@ symbolt &goto_convertt::new_tmp_symbol( return new_symbol; } +/*******************************************************************\ + +Function: goto_convertt::make_temp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::make_temp_symbol( exprt &expr, const std::string &suffix, @@ -2155,6 +2804,18 @@ void goto_convertt::make_temp_symbol( expr=new_symbol.symbol_expr(); } +/*******************************************************************\ + +Function: goto_convertt::new_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::new_name(symbolt &symbol) { // rename it @@ -2164,6 +2825,18 @@ void goto_convertt::new_name(symbolt &symbol) symbol_table.add(symbol); } +/*******************************************************************\ + +Function: goto_convertt::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &goto_convertt::lookup(const irep_idt &identifier) { const symbolt *symbol; @@ -2175,6 +2848,18 @@ const symbolt &goto_convertt::lookup(const irep_idt &identifier) return *symbol; } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( const codet &code, symbol_tablet &symbol_table, @@ -2207,6 +2892,18 @@ void goto_convert( } } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( symbol_tablet &symbol_table, goto_programt &dest, diff --git a/src/goto-programs/goto_convert.h b/src/goto-programs/goto_convert.h index c0196486ae4..499c24aa572 100644 --- a/src/goto-programs/goto_convert.h +++ b/src/goto-programs/goto_convert.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_H diff --git a/src/goto-programs/goto_convert_class.h b/src/goto-programs/goto_convert_class.h index c765109a75e..b018810e76e 100644 --- a/src/goto-programs/goto_convert_class.h +++ b/src/goto-programs/goto_convert_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_CLASS_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_CLASS_H diff --git a/src/goto-programs/goto_convert_exceptions.cpp b/src/goto-programs/goto_convert_exceptions.cpp index 0f17c7c011c..63f503e8a0b 100644 --- a/src/goto-programs/goto_convert_exceptions.cpp +++ b/src/goto-programs/goto_convert_exceptions.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include "goto_convert_class.h" +/*******************************************************************\ + +Function: goto_convertt::convert_msc_try_finally + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_msc_try_finally( const codet &code, goto_programt &dest) @@ -51,6 +60,18 @@ void goto_convertt::convert_msc_try_finally( dest.destructive_append(tmp); } +/*******************************************************************\ + +Function: goto_convertt::convert_msc_try_except + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_msc_try_except( const codet &code, goto_programt &dest) @@ -67,6 +88,18 @@ void goto_convertt::convert_msc_try_except( // todo: generate exception tracking } +/*******************************************************************\ + +Function: goto_convertt::convert_msc_leave + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_msc_leave( const codet &code, goto_programt &dest) @@ -93,6 +126,18 @@ void goto_convertt::convert_msc_leave( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_java_try_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_java_try_catch( const codet &code, goto_programt &dest) @@ -148,6 +193,18 @@ void goto_convertt::convert_java_try_catch( dest.destructive_append(end); } +/*******************************************************************\ + +Function: goto_convertt::convert_try_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_try_catch( const codet &code, goto_programt &dest) @@ -201,6 +258,18 @@ void goto_convertt::convert_try_catch( dest.destructive_append(end); } +/*******************************************************************\ + +Function: goto_convertt::convert_CPROVER_try_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_CPROVER_try_catch( const codet &code, goto_programt &dest) @@ -238,6 +307,18 @@ void goto_convertt::convert_CPROVER_try_catch( dest.destructive_append(tmp); } +/*******************************************************************\ + +Function: goto_convertt::convert_CPROVER_throw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_CPROVER_throw( const codet &code, goto_programt &dest) @@ -275,6 +356,18 @@ void goto_convertt::convert_CPROVER_throw( } } +/*******************************************************************\ + +Function: goto_convertt::convert_CPROVER_try_finally + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_CPROVER_try_finally( const codet &code, goto_programt &dest) @@ -299,6 +392,18 @@ void goto_convertt::convert_CPROVER_try_finally( convert(to_code(code.op1()), dest); } +/*******************************************************************\ + +Function: goto_convertt::exception_flag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt goto_convertt::exception_flag() { irep_idt id="$exception_flag"; @@ -321,6 +426,18 @@ symbol_exprt goto_convertt::exception_flag() return symbol_exprt(id, bool_typet()); } +/*******************************************************************\ + +Function: goto_convertt::unwind_destructor_stack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::unwind_destructor_stack( const source_locationt &source_location, std::size_t final_stack_size, diff --git a/src/goto-programs/goto_convert_function_call.cpp b/src/goto-programs/goto_convert_function_call.cpp index 0443b4536bb..6fe2b42bbc1 100644 --- a/src/goto-programs/goto_convert_function_call.cpp +++ b/src/goto-programs/goto_convert_function_call.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" +/*******************************************************************\ + +Function: goto_convertt::convert_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_function_call( const code_function_callt &function_call, goto_programt &dest) @@ -32,6 +41,18 @@ void goto_convertt::convert_function_call( dest); } +/*******************************************************************\ + +Function: goto_convertt::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_function_call( const exprt &lhs, const exprt &function, @@ -88,6 +109,18 @@ void goto_convertt::do_function_call( } } +/*******************************************************************\ + +Function: goto_convertt::do_function_call_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_function_call_if( const exprt &lhs, const if_exprt &function, @@ -152,6 +185,18 @@ void goto_convertt::do_function_call_if( dest.destructive_append(tmp_z); } +/*******************************************************************\ + +Function: goto_convertt::do_function_call_other + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::do_function_call_other( const exprt &lhs, const exprt &function, diff --git a/src/goto-programs/goto_convert_functions.cpp b/src/goto-programs/goto_convert_functions.cpp index ba8c13aa9e4..b25d8870f09 100644 --- a/src/goto-programs/goto_convert_functions.cpp +++ b/src/goto-programs/goto_convert_functions.cpp @@ -18,6 +18,18 @@ Date: June 2003 #include "goto_convert_functions.h" #include "goto_inline.h" +/*******************************************************************\ + +Function: goto_convert_functionst::goto_convert_functionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_convert_functionst::goto_convert_functionst( symbol_tablet &_symbol_table, goto_functionst &_functions, @@ -27,10 +39,34 @@ goto_convert_functionst::goto_convert_functionst( { } +/*******************************************************************\ + +Function: goto_convert_functionst::~goto_convert_functionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_convert_functionst::~goto_convert_functionst() { } +/*******************************************************************\ + +Function: goto_convert_functionst::goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert_functionst::goto_convert() { // warning! hash-table iterators are not stable @@ -69,6 +105,18 @@ void goto_convert_functionst::goto_convert() #endif } +/*******************************************************************\ + +Function: goto_convert_functionst::hide + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_convert_functionst::hide(const goto_programt &goto_program) { forall_goto_program_instructions(i_it, goto_program) @@ -81,6 +129,18 @@ bool goto_convert_functionst::hide(const goto_programt &goto_program) return false; } +/*******************************************************************\ + +Function: goto_convert_functionst::add_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert_functionst::add_return( goto_functionst::goto_functiont &f, const source_locationt &source_location) @@ -134,6 +194,18 @@ void goto_convert_functionst::add_return( t->source_location=source_location; } +/*******************************************************************\ + +Function: goto_convert_functionst::convert_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert_functionst::convert_function(const irep_idt &identifier) { const symbolt &symbol=ns.lookup(identifier); @@ -220,6 +292,18 @@ void goto_convert_functionst::convert_function(const irep_idt &identifier) f.make_hidden(); } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( symbol_tablet &symbol_table, goto_modelt &goto_model, @@ -229,6 +313,18 @@ void goto_convert( goto_model.symbol_table.swap(symbol_table); } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( symbol_tablet &symbol_table, goto_functionst &functions, @@ -261,6 +357,18 @@ void goto_convert( } } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( const irep_idt &identifier, symbol_tablet &symbol_table, diff --git a/src/goto-programs/goto_convert_functions.h b/src/goto-programs/goto_convert_functions.h index 2b7b128eab6..9678c928609 100644 --- a/src/goto-programs/goto_convert_functions.h +++ b/src/goto-programs/goto_convert_functions.h @@ -8,9 +8,6 @@ Date: June 2003 \*******************************************************************/ -/// \file -/// Goto Programs with Functions - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_GOTO_CONVERT_FUNCTIONS_H diff --git a/src/goto-programs/goto_convert_new_switch_case.cpp b/src/goto-programs/goto_convert_new_switch_case.cpp index 3f90e14c515..4a81a4176a2 100644 --- a/src/goto-programs/goto_convert_new_switch_case.cpp +++ b/src/goto-programs/goto_convert_new_switch_case.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" #include "destructor.h" +/*******************************************************************\ + +Function: is_empty + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool is_empty(const goto_programt &goto_program) { forall_goto_program_instructions(it, goto_program) @@ -35,6 +44,18 @@ static bool is_empty(const goto_programt &goto_program) return true; } +/*******************************************************************\ + +Function: goto_convertt::finish_gotos + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::finish_gotos() { for(const auto &target : targets.gotos) @@ -108,6 +129,18 @@ void goto_convertt::finish_gotos() targets.gotos.clear(); } +/*******************************************************************\ + +Function: goto_convertt::finish_computed_gotos + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::finish_computed_gotos(goto_programt &goto_program) { for(const auto &target : targets.computed_gotos) @@ -147,11 +180,35 @@ void goto_convertt::finish_computed_gotos(goto_programt &goto_program) targets.computed_gotos.clear(); } +/*******************************************************************\ + +Function: goto_convertt::goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::goto_convert(const codet &code, goto_programt &dest) { goto_convert_rec(code, dest); } +/*******************************************************************\ + +Function: goto_convertt::goto_convert_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::goto_convert_rec( const codet &code, goto_programt &dest) @@ -162,6 +219,18 @@ void goto_convertt::goto_convert_rec( finish_computed_gotos(dest); } +/*******************************************************************\ + +Function: goto_convertt::copy + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::copy( const codet &code, goto_program_instruction_typet type, @@ -172,6 +241,18 @@ void goto_convertt::copy( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convert::convert_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_label( const code_labelt &code, goto_programt &dest) @@ -208,6 +289,18 @@ void goto_convertt::convert_label( target->labels.push_front(label); } +/*******************************************************************\ + +Function: goto_convert::convert_gcc_local_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_local_label( const codet &code, goto_programt &dest) @@ -215,6 +308,18 @@ void goto_convertt::convert_gcc_local_label( // ignore for now } +/*******************************************************************\ + +Function: goto_convert::convert_switch_case + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_switch_case( const code_switch_caset &code, goto_programt &dest) @@ -260,6 +365,18 @@ void goto_convertt::convert_switch_case( } } +/*******************************************************************\ + +Function: goto_convert::convert_gcc_switch_case_range + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_switch_case_range( const codet &code, goto_programt &dest) @@ -293,7 +410,18 @@ void goto_convertt::convert_gcc_switch_case_range( #endif } -/// converts 'code' and appends the result to 'dest' +/*******************************************************************\ + +Function: goto_convertt::convert + + Inputs: + + Outputs: + + Purpose: converts 'code' and appends the result to 'dest' + +\*******************************************************************/ + void goto_convertt::convert( const codet &code, goto_programt &dest) @@ -428,6 +556,18 @@ void goto_convertt::convert( } } +/*******************************************************************\ + +Function: goto_convertt::convert_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_block( const code_blockt &code, goto_programt &dest) @@ -451,6 +591,18 @@ void goto_convertt::convert_block( targets.destructor_stack.resize(old_stack_size); } +/*******************************************************************\ + +Function: goto_convertt::convert_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_expression( const code_expressiont &code, goto_programt &dest) @@ -494,6 +646,18 @@ void goto_convertt::convert_expression( } } +/*******************************************************************\ + +Function: goto_convertt::convert_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_decl( const code_declt &code, goto_programt &dest) @@ -563,6 +727,18 @@ void goto_convertt::convert_decl( } } +/*******************************************************************\ + +Function: goto_convertt::convert_decl_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_decl_type( const codet &code, goto_programt &dest) @@ -570,6 +746,18 @@ void goto_convertt::convert_decl_type( // we remove these } +/*******************************************************************\ + +Function: goto_convertt::convert_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assign( const code_assignt &code, goto_programt &dest) @@ -657,6 +845,18 @@ void goto_convertt::convert_assign( } } +/*******************************************************************\ + +Function: goto_convertt::convert_init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_init( const codet &code, goto_programt &dest) @@ -675,6 +875,18 @@ void goto_convertt::convert_init( convert(to_code_assign(assignment), dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_cpp_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_cpp_delete( const codet &code, goto_programt &dest) @@ -740,6 +952,18 @@ void goto_convertt::convert_cpp_delete( convert(delete_call, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assert( const code_assertt &code, goto_programt &dest) @@ -755,6 +979,18 @@ void goto_convertt::convert_assert( t->source_location.set("user-provided", true); } +/*******************************************************************\ + +Function: goto_convertt::convert_skip + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_skip( const codet &code, goto_programt &dest) @@ -764,6 +1000,18 @@ void goto_convertt::convert_skip( t->code=code; } +/*******************************************************************\ + +Function: goto_convertt::convert_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_assume( const code_assumet &code, goto_programt &dest) @@ -777,6 +1025,18 @@ void goto_convertt::convert_assume( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_for + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_for( const code_fort &code, goto_programt &dest) @@ -873,6 +1133,18 @@ void goto_convertt::convert_for( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_while + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_while( const code_whilet &code, goto_programt &dest) @@ -930,6 +1202,18 @@ void goto_convertt::convert_while( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_dowhile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_dowhile( const codet &code, goto_programt &dest) @@ -999,6 +1283,18 @@ void goto_convertt::convert_dowhile( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::case_guard + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_convertt::case_guard( const exprt &value, const exprt::operandst &case_op) @@ -1026,6 +1322,18 @@ exprt goto_convertt::case_guard( return dest; } +/*******************************************************************\ + +Function: goto_convertt::convert_switch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_switch( const code_switcht &code, goto_programt &dest) @@ -1124,6 +1432,18 @@ void goto_convertt::convert_switch( old_targets.restore(targets); } +/*******************************************************************\ + +Function: goto_convertt::convert_break + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_break( const code_breakt &code, goto_programt &dest) @@ -1145,6 +1465,18 @@ void goto_convertt::convert_break( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_return( const code_returnt &code, goto_programt &dest) @@ -1215,6 +1547,18 @@ void goto_convertt::convert_return( t->source_location=new_code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_continue + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_continue( const code_continuet &code, goto_programt &dest) @@ -1236,6 +1580,18 @@ void goto_convertt::convert_continue( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_goto( const codet &code, goto_programt &dest) @@ -1249,6 +1605,18 @@ void goto_convertt::convert_goto( targets.gotos.push_back(t); } +/*******************************************************************\ + +Function: goto_convertt::convert_gcc_computed_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_gcc_computed_goto( const codet &code, goto_programt &dest) @@ -1262,6 +1630,18 @@ void goto_convertt::convert_gcc_computed_goto( targets.computed_gotos.push_back(t); } +/*******************************************************************\ + +Function: goto_convertt::convert_non_deterministic_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_non_deterministic_goto( const codet &code, goto_programt &dest) @@ -1269,6 +1649,18 @@ void goto_convertt::convert_non_deterministic_goto( convert_goto(code, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_notify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_notify( const codet &code, goto_programt &dest) @@ -1286,6 +1678,18 @@ void goto_convertt::convert_specc_notify( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_event + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_event( const exprt &op, std::set &events) @@ -1312,6 +1716,18 @@ void goto_convertt::convert_specc_event( } } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_wait + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_wait( const codet &code, goto_programt &dest) @@ -1340,6 +1756,18 @@ void goto_convertt::convert_specc_wait( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_specc_par + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_specc_par( const codet &code, goto_programt &dest) @@ -1347,6 +1775,18 @@ void goto_convertt::convert_specc_par( copy(code, OTHER, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_start_thread( const codet &code, goto_programt &dest) @@ -1386,6 +1826,18 @@ void goto_convertt::convert_start_thread( } } +/*******************************************************************\ + +Function: goto_convertt::convert_end_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_end_thread( const codet &code, goto_programt &dest) @@ -1400,6 +1852,18 @@ void goto_convertt::convert_end_thread( copy(code, END_THREAD, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_atomic_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_atomic_begin( const codet &code, goto_programt &dest) @@ -1414,6 +1878,18 @@ void goto_convertt::convert_atomic_begin( copy(code, ATOMIC_BEGIN, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_atomic_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_atomic_end( const codet &code, goto_programt &dest) @@ -1428,6 +1904,18 @@ void goto_convertt::convert_atomic_end( copy(code, ATOMIC_END, dest); } +/*******************************************************************\ + +Function: goto_convertt::convert_bp_enforce + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_bp_enforce( const codet &code, goto_programt &dest) @@ -1488,6 +1976,18 @@ void goto_convertt::convert_bp_enforce( dest.destructive_append(tmp); } +/*******************************************************************\ + +Function: goto_convertt::convert_bp_abortif + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_bp_abortif( const codet &code, goto_programt &dest) @@ -1511,6 +2011,18 @@ void goto_convertt::convert_bp_abortif( t->source_location=code.source_location(); } +/*******************************************************************\ + +Function: goto_convertt::convert_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::convert_ifthenelse( const code_ifthenelset &code, goto_programt &dest) @@ -1562,6 +2074,18 @@ void goto_convertt::convert_ifthenelse( generate_ifthenelse(tmp_guard, tmp_then, tmp_else, source_location, dest); } +/*******************************************************************\ + +Function: goto_convertt::collect_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::collect_operands( const exprt &expr, const irep_idt &id, @@ -1579,7 +2103,18 @@ void goto_convertt::collect_operands( } } -/// if(guard) true_case; else false_case; +/*******************************************************************\ + +Function: goto_convertt::generate_ifthenelse + + Inputs: + + Outputs: + + Purpose: if(guard) true_case; else false_case; + +\*******************************************************************/ + void goto_convertt::generate_ifthenelse( const exprt &guard, goto_programt &true_case, @@ -1699,7 +2234,18 @@ void goto_convertt::generate_ifthenelse( dest.destructive_append(tmp_z); } -/// if(guard) goto target; +/*******************************************************************\ + +Function: goto_convertt::generate_conditional_branch + + Inputs: + + Outputs: + + Purpose: if(guard) goto target; + +\*******************************************************************/ + static bool has_and_or(const exprt &expr) { forall_operands(it, expr) @@ -1750,7 +2296,18 @@ void goto_convertt::generate_conditional_branch( } } -/// if(guard) goto target_true; else goto target_false; +/*******************************************************************\ + +Function: goto_convertt::generate_conditional_branch + + Inputs: + + Outputs: + + Purpose: if(guard) goto target_true; else goto target_false; + +\*******************************************************************/ + void goto_convertt::generate_conditional_branch( const exprt &guard, goto_programt::targett target_true, @@ -1828,6 +2385,18 @@ void goto_convertt::generate_conditional_branch( t_false->source_location=source_location; } +/*******************************************************************\ + +Function: goto_convertt::get_string_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irep_idt goto_convertt::get_string_constant( const exprt &expr) { @@ -1873,6 +2442,18 @@ const irep_idt goto_convertt::get_string_constant( throw 0; } +/*******************************************************************\ + +Function: goto_convertt::get_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_convertt::get_constant(const exprt &expr) { if(expr.id()==ID_symbol) @@ -1899,6 +2480,18 @@ exprt goto_convertt::get_constant(const exprt &expr) return expr; } +/*******************************************************************\ + +Function: goto_convertt::new_tmp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbolt &goto_convertt::new_tmp_symbol( const typet &type, const std::string &suffix, @@ -1926,6 +2519,18 @@ symbolt &goto_convertt::new_tmp_symbol( return *symbol_ptr; } +/*******************************************************************\ + +Function: goto_convertt::make_temp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::make_temp_symbol( exprt &expr, const std::string &suffix, @@ -1946,6 +2551,18 @@ void goto_convertt::make_temp_symbol( expr=new_symbol.symbol_expr(); } +/*******************************************************************\ + +Function: goto_convertt::new_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::new_name(symbolt &symbol) { // rename it @@ -1955,6 +2572,18 @@ void goto_convertt::new_name(symbolt &symbol) symbol_table.add(symbol); } +/*******************************************************************\ + +Function: goto_convertt::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &goto_convertt::lookup(const irep_idt &identifier) const { const symbolt *symbol; @@ -1966,6 +2595,18 @@ const symbolt &goto_convertt::lookup(const irep_idt &identifier) const return *symbol; } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( const codet &code, symbol_tablet &symbol_table, @@ -2000,6 +2641,18 @@ void goto_convert( throw 0; } +/*******************************************************************\ + +Function: goto_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convert( symbol_tablet &symbol_table, goto_programt &dest, diff --git a/src/goto-programs/goto_convert_side_effect.cpp b/src/goto-programs/goto_convert_side_effect.cpp index 6d7e95e747b..dbebb856ec1 100644 --- a/src/goto-programs/goto_convert_side_effect.cpp +++ b/src/goto-programs/goto_convert_side_effect.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_convert_class.h" +/*******************************************************************\ + +Function: goto_convertt::has_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_convertt::has_function_call(const exprt &expr) { forall_operands(it, expr) @@ -33,6 +42,18 @@ bool goto_convertt::has_function_call(const exprt &expr) return false; } +/*******************************************************************\ + +Function: goto_convertt::remove_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_assignment( side_effect_exprt &expr, goto_programt &dest, @@ -136,6 +157,18 @@ void goto_convertt::remove_assignment( expr.make_nil(); } +/*******************************************************************\ + +Function: goto_convertt::remove_pre + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_pre( side_effect_exprt &expr, goto_programt &dest, @@ -223,6 +256,18 @@ void goto_convertt::remove_pre( expr.make_nil(); } +/*******************************************************************\ + +Function: goto_convertt::remove_post + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_post( side_effect_exprt &expr, goto_programt &dest, @@ -329,6 +374,18 @@ void goto_convertt::remove_post( dest.destructive_append(tmp2); } +/*******************************************************************\ + +Function: goto_convertt::remove_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_function_call( side_effect_exprt &expr, goto_programt &dest, @@ -409,6 +466,18 @@ void goto_convertt::remove_function_call( static_cast(expr)=new_symbol.symbol_expr(); } +/*******************************************************************\ + +Function: goto_convertt::replace_new_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::replace_new_object( const exprt &object, exprt &dest) @@ -420,6 +489,18 @@ void goto_convertt::replace_new_object( replace_new_object(object, *it); } +/*******************************************************************\ + +Function: goto_convertt::remove_cpp_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_cpp_new( side_effect_exprt &expr, goto_programt &dest, @@ -450,6 +531,18 @@ void goto_convertt::remove_cpp_new( convert(call, dest); } +/*******************************************************************\ + +Function: goto_convertt::remove_cpp_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_cpp_delete( side_effect_exprt &expr, goto_programt &dest, @@ -469,6 +562,18 @@ void goto_convertt::remove_cpp_delete( expr.make_nil(); } +/*******************************************************************\ + +Function: goto_convertt::remove_malloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_malloc( side_effect_exprt &expr, goto_programt &dest, @@ -506,6 +611,18 @@ void goto_convertt::remove_malloc( convert(call, dest); } +/*******************************************************************\ + +Function: goto_convertt::remove_temporary_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_temporary_object( side_effect_exprt &expr, goto_programt &dest, @@ -546,6 +663,18 @@ void goto_convertt::remove_temporary_object( static_cast(expr)=new_symbol.symbol_expr(); } +/*******************************************************************\ + +Function: goto_convertt::remove_statement_expression + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_statement_expression( side_effect_exprt &expr, goto_programt &dest, @@ -636,6 +765,18 @@ void goto_convertt::remove_statement_expression( static_cast(expr)=tmp_symbol_expr; } +/*******************************************************************\ + +Function: goto_convertt::remove_push_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_push_catch( side_effect_exprt &expr, goto_programt &dest) @@ -647,6 +788,18 @@ void goto_convertt::remove_push_catch( expr.make_nil(); } +/*******************************************************************\ + +Function: goto_convertt::remove_side_effect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_convertt::remove_side_effect( side_effect_exprt &expr, goto_programt &dest, diff --git a/src/goto-programs/goto_functions.cpp b/src/goto-programs/goto_functions.cpp index 9c14c8bc6bc..d11868339b3 100644 --- a/src/goto-programs/goto_functions.cpp +++ b/src/goto-programs/goto_functions.cpp @@ -8,11 +8,20 @@ Date: June 2003 \*******************************************************************/ -/// \file -/// Goto Programs with Functions - #include "goto_functions.h" +/*******************************************************************\ + +Function: get_local_identifiers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_local_identifiers( const goto_function_templatet &goto_function, std::set &dest) diff --git a/src/goto-programs/goto_functions.h b/src/goto-programs/goto_functions.h index 7fc9f70628a..096fab391ec 100644 --- a/src/goto-programs/goto_functions.h +++ b/src/goto-programs/goto_functions.h @@ -8,9 +8,6 @@ Date: June 2003 \*******************************************************************/ -/// \file -/// Goto Programs with Functions - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H diff --git a/src/goto-programs/goto_functions_template.h b/src/goto-programs/goto_functions_template.h index 3ea7a7bad83..9333cce06b3 100644 --- a/src/goto-programs/goto_functions_template.h +++ b/src/goto-programs/goto_functions_template.h @@ -8,9 +8,6 @@ Date: June 2003 \*******************************************************************/ -/// \file -/// Goto Programs with Functions - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_TEMPLATE_H #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_TEMPLATE_H @@ -161,6 +158,18 @@ class goto_functions_templatet } }; +/*******************************************************************\ + +Function: goto_functions_templatet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void goto_functions_templatet::output( const namespacet &ns, @@ -181,6 +190,18 @@ void goto_functions_templatet::output( } } +/*******************************************************************\ + +Function: goto_functions_templatet::compute_location_numbers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void goto_functions_templatet::compute_location_numbers() { @@ -193,6 +214,18 @@ void goto_functions_templatet::compute_location_numbers() it->second.body.compute_location_numbers(nr); } +/*******************************************************************\ + +Function: goto_functions_templatet::compute_incoming_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void goto_functions_templatet::compute_incoming_edges() { @@ -203,6 +236,18 @@ void goto_functions_templatet::compute_incoming_edges() it->second.body.compute_incoming_edges(); } +/*******************************************************************\ + +Function: goto_functions_templatet::compute_target_numbers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void goto_functions_templatet::compute_target_numbers() { @@ -213,6 +258,18 @@ void goto_functions_templatet::compute_target_numbers() it->second.body.compute_target_numbers(); } +/*******************************************************************\ + +Function: goto_functions_templatet::compute_loop_numbers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void goto_functions_templatet::compute_loop_numbers() { diff --git a/src/goto-programs/goto_inline.cpp b/src/goto-programs/goto_inline.cpp index 58db12c1838..01c0f1bf392 100644 --- a/src/goto-programs/goto_inline.cpp +++ b/src/goto-programs/goto_inline.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Inlining - #include #include @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_inline.h" #include "goto_inline_class.h" +/*******************************************************************\ + +Function: goto_inline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inline( goto_modelt &goto_model, message_handlert &message_handler, @@ -34,6 +43,18 @@ void goto_inline( adjust_function); } +/*******************************************************************\ + +Function: goto_inline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inline( goto_functionst &goto_functions, const namespacet &ns, @@ -97,13 +118,28 @@ void goto_inline( } } -/// Inline all function calls to functions either marked as "inlined" or -/// smaller than smallfunc_limit (by instruction count). -/// \param goto_model: Source of the symbol table and function map to use. -/// \param message_handler: Message handler used by goto_inlinet. -/// \param smallfunc_limit: The maximum number of instructions in functions to -/// be inlined. -/// \param adjust_function: Tell goto_inlinet to adjust function. +/*******************************************************************\ + +Function: goto_partial_inline + + Inputs: + goto_model: + Source of the symbol table and function map to use. + message_handler: + Message handler used by goto_inlinet. + smallfunc_limit: + The maximum number of instructions in functions to be inlined. + adjust_function: + Tell goto_inlinet to adjust function. + + Outputs: + + Purpose: + Inline all function calls to functions either marked as "inlined" or + smaller than smallfunc_limit (by instruction count). + +\*******************************************************************/ + void goto_partial_inline( goto_modelt &goto_model, message_handlert &message_handler, @@ -119,15 +155,31 @@ void goto_partial_inline( adjust_function); } -/// Inline all function calls to functions either marked as "inlined" or -/// smaller than smallfunc_limit (by instruction count). -/// \param goto_functions: The function map to use to find functions containing -/// calls and function bodies. -/// \param ns: Namespace used by goto_inlinet. -/// \param message_handler: Message handler used by goto_inlinet. -/// \param smallfunc_limit: The maximum number of instructions in functions to -/// be inlined. -/// \param adjust_function: Tell goto_inlinet to adjust function. +/*******************************************************************\ + +Function: goto_partial_inline + + Inputs: + goto_functions: + The function map to use to find functions containing calls and function + bodies. + ns: + Namespace used by goto_inlinet. + message_handler: + Message handler used by goto_inlinet. + smallfunc_limit: + The maximum number of instructions in functions to be inlined. + adjust_function: + Tell goto_inlinet to adjust function. + + Outputs: + + Purpose: + Inline all function calls to functions either marked as "inlined" or + smaller than smallfunc_limit (by instruction count). + +\*******************************************************************/ + void goto_partial_inline( goto_functionst &goto_functions, const namespacet &ns, @@ -207,12 +259,24 @@ void goto_partial_inline( goto_inline.goto_inline(inline_map, false); } -/// Inline all function calls made from a particular function -/// \param goto_model: Source of the symbol table and function map to use. -/// \param function: The function whose calls to inline. -/// \param message_handler: Message handler used by goto_inlinet. -/// \param adjust_function: Tell goto_inlinet to adjust function. -/// \param caching: Tell goto_inlinet to cache. +/*******************************************************************\ + +Function: goto_function_inline + + Inputs: + goto_model: Source of the symbol table and function map to use. + function: The function whose calls to inline. + message_handler: Message handler used by goto_inlinet. + adjust_function: Tell goto_inlinet to adjust function. + caching: Tell goto_inlinet to cache. + + Outputs: + + Purpose: + Inline all function calls made from a particular function + +\*******************************************************************/ + void goto_function_inline( goto_modelt &goto_model, const irep_idt function, @@ -230,13 +294,25 @@ void goto_function_inline( caching); } -/// Inline all function calls made from a particular function -/// \param goto_functions: The function map to use to find function bodies. -/// \param function: The function whose calls to inline. -/// \param ns: Namespace used by goto_inlinet. -/// \param message_handler: Message handler used by goto_inlinet. -/// \param adjust_function: Tell goto_inlinet to adjust function. -/// \param caching: Tell goto_inlinet to cache. +/*******************************************************************\ + +Function: goto_function_inline + + Inputs: + goto_functions: The function map to use to find function bodies. + function: The function whose calls to inline. + ns: Namespace used by goto_inlinet. + message_handler: Message handler used by goto_inlinet. + adjust_function: Tell goto_inlinet to adjust function. + caching: Tell goto_inlinet to cache. + + Outputs: + + Purpose: + Inline all function calls made from a particular function + +\*******************************************************************/ + void goto_function_inline( goto_functionst &goto_functions, const irep_idt function, @@ -281,6 +357,18 @@ void goto_function_inline( goto_inline.goto_inline(function, goto_function, inline_map, true); } +/*******************************************************************\ + +Function: goto_function_inline_and_log + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + jsont goto_function_inline_and_log( goto_functionst &goto_functions, const irep_idt function, diff --git a/src/goto-programs/goto_inline.h b/src/goto-programs/goto_inline.h index 3319aa36172..5d3dd54fa6d 100644 --- a/src/goto-programs/goto_inline.h +++ b/src/goto-programs/goto_inline.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Inlining - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H #define CPROVER_GOTO_PROGRAMS_GOTO_INLINE_H diff --git a/src/goto-programs/goto_inline_class.cpp b/src/goto-programs/goto_inline_class.cpp index 5536da22378..f7c8e4509af 100644 --- a/src/goto-programs/goto_inline_class.cpp +++ b/src/goto-programs/goto_inline_class.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Function Inlining - #ifdef DEBUG #include #endif @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_inline.h" #include "goto_inline_class.h" +/*******************************************************************\ + +Function: goto_inlinet::parameter_assignments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::parameter_assignments( const goto_programt::targett target, const irep_idt &function_name, // name of called function @@ -158,6 +167,18 @@ void goto_inlinet::parameter_assignments( } } +/*******************************************************************\ + +Function: goto_inlinet::parameter_destruction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::parameter_destruction( const goto_programt::targett target, const irep_idt &function_name, // name of called function @@ -202,6 +223,18 @@ void goto_inlinet::parameter_destruction( } } +/*******************************************************************\ + +Function: goto_inlinet::replace_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::replace_return( goto_programt &dest, // inlining this const exprt &lhs, // lhs in caller @@ -315,6 +348,18 @@ void goto_inlinet::replace_return( } } +/*******************************************************************\ + +Function: replace_location + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void replace_location( source_locationt &dest, const source_locationt &new_location) @@ -338,6 +383,18 @@ void replace_location( dest.set_property_id(property_id); } +/*******************************************************************\ + +Function: replace_location + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void replace_location( exprt &dest, const source_locationt &new_location) @@ -349,6 +406,18 @@ void replace_location( replace_location(dest.add_source_location(), new_location); } +/*******************************************************************\ + +Function: goto_inlinet::insert_function_body + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::insert_function_body( const goto_functiont &goto_function, goto_programt &dest, @@ -450,6 +519,18 @@ void goto_inlinet::insert_function_body( dest.destructive_insert(target, tmp); } +/*******************************************************************\ + +Function: goto_inlinet::insert_function_nobody + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::insert_function_nobody( goto_programt &dest, const exprt &lhs, @@ -503,6 +584,18 @@ void goto_inlinet::insert_function_nobody( dest.destructive_insert(target, tmp); } +/*******************************************************************\ + +Function: goto_inlinet::expand_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::expand_function_call( goto_programt &dest, const inline_mapt &inline_map, @@ -628,6 +721,18 @@ void goto_inlinet::expand_function_call( } } +/*******************************************************************\ + +Function: goto_inlinet::get_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::get_call( goto_programt::const_targett it, exprt &lhs, @@ -657,11 +762,35 @@ void goto_inlinet::get_call( } } +/*******************************************************************\ + +Function: goto_inlinet::is_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_inlinet::is_call(goto_programt::const_targett it) { return it->is_function_call() || is_bp_call(it); } +/*******************************************************************\ + +Function: goto_inlinet::is_bp_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_inlinet::is_bp_call(goto_programt::const_targett it) { if(!it->is_other()) @@ -673,6 +802,18 @@ bool goto_inlinet::is_bp_call(goto_programt::const_targett it) it->code.op0().op1().get(ID_statement)==ID_function_call; } +/*******************************************************************\ + +Function: goto_inline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline( const inline_mapt &inline_map, const bool force_full) @@ -692,6 +833,18 @@ void goto_inlinet::goto_inline( } } +/*******************************************************************\ + +Function: goto_inline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline( const irep_idt identifier, goto_functiont &goto_function, @@ -707,6 +860,18 @@ void goto_inlinet::goto_inline( force_full); } +/*******************************************************************\ + +Function: goto_inline + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline_nontransitive( const irep_idt identifier, goto_functiont &goto_function, @@ -761,6 +926,18 @@ void goto_inlinet::goto_inline_nontransitive( finished_set.insert(identifier); } +/*******************************************************************\ + +Function: goto_inline_transitive + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const goto_inlinet::goto_functiont &goto_inlinet::goto_inline_transitive( const irep_idt identifier, const goto_functiont &goto_function, @@ -822,6 +999,18 @@ const goto_inlinet::goto_functiont &goto_inlinet::goto_inline_transitive( return cached; } +/*******************************************************************\ + +Function: is_ignored + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_inlinet::is_ignored(const irep_idt id) const { return @@ -833,6 +1022,18 @@ bool goto_inlinet::is_ignored(const irep_idt id) const id=="__CPROVER_cover"; } +/*******************************************************************\ + +Function: check_inline_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_inlinet::check_inline_map( const irep_idt identifier, const inline_mapt &inline_map) const @@ -879,6 +1080,18 @@ bool goto_inlinet::check_inline_map( return true; } +/*******************************************************************\ + +Function: check_inline_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_inlinet::check_inline_map(const inline_mapt &inline_map) const { forall_goto_functions(f_it, goto_functions) @@ -890,6 +1103,18 @@ bool goto_inlinet::check_inline_map(const inline_mapt &inline_map) const return true; } +/*******************************************************************\ + +Function: output_inline_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::output_inline_map( std::ostream &out, const inline_mapt &inline_map) @@ -936,6 +1161,18 @@ void goto_inlinet::output_inline_map( } } +/*******************************************************************\ + +Function: output_cache + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::output_cache(std::ostream &out) const { for(auto it=cache.begin(); it!=cache.end(); it++) @@ -947,6 +1184,18 @@ void goto_inlinet::output_cache(std::ostream &out) const } } +/*******************************************************************\ + +Function: cleanup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // remove segment that refer to the given goto program void goto_inlinet::goto_inline_logt::cleanup( const goto_programt &goto_program) @@ -955,6 +1204,18 @@ void goto_inlinet::goto_inline_logt::cleanup( log_map.erase(it); } +/*******************************************************************\ + +Function: cleanup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline_logt::cleanup( const goto_functionst::function_mapt &function_map) { @@ -970,6 +1231,18 @@ void goto_inlinet::goto_inline_logt::cleanup( } } +/*******************************************************************\ + +Function: add_segment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline_logt::add_segment( const goto_programt &goto_program, const unsigned begin_location_number, @@ -997,6 +1270,18 @@ void goto_inlinet::goto_inline_logt::add_segment( log_map[start]=info; } +/*******************************************************************\ + +Function: copy_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_inlinet::goto_inline_logt::copy_from( const goto_programt &from, const goto_programt &to) @@ -1036,6 +1321,18 @@ void goto_inlinet::goto_inline_logt::copy_from( } } +/*******************************************************************\ + +Function: output_inline_log_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // call after goto_functions.update()! jsont goto_inlinet::goto_inline_logt::output_inline_log_json() const { diff --git a/src/goto-programs/goto_model.h b/src/goto-programs/goto_model.h index 6e9ebbc6f37..37b491dc996 100644 --- a/src/goto-programs/goto_model.h +++ b/src/goto-programs/goto_model.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbol Table + CFG - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_MODEL_H #define CPROVER_GOTO_PROGRAMS_GOTO_MODEL_H diff --git a/src/goto-programs/goto_program.cpp b/src/goto-programs/goto_program.cpp index be564d3715d..c1b72dc7bbf 100644 --- a/src/goto-programs/goto_program.cpp +++ b/src/goto-programs/goto_program.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include @@ -17,13 +14,23 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program.h" -/// See below. -/// \param ns: the namespace to resolve the expressions in -/// \param identifier: the identifier used to find a symbol to identify the -/// source language -/// \param out: the stream to write the goto string to -/// \param it: an iterator pointing to the instruction to convert -/// \return See below. +/*******************************************************************\ + +Function: goto_programt::output_instruction + + Inputs: + ns - the namespace to resolve the expressions in + identifier - the identifier used to find a symbol to identify the + source language + out - the stream to write the goto string to + it - an iterator pointing to the instruction to convert + + Outputs: See below. + + Purpose: See below. + +\*******************************************************************/ + std::ostream &goto_programt::output_instruction( const class namespacet &ns, const irep_idt &identifier, @@ -33,15 +40,26 @@ std::ostream &goto_programt::output_instruction( return output_instruction(ns, identifier, out, *it); } -/// Writes to out a two line string representation of the specific instruction. -/// It is of the format: // {location} file {source file} line {line in source -/// file} {representation of the instruction} -/// \param ns: the namespace to resolve the expressions in -/// \param identifier: the identifier used to find a symbol to identify the -/// source language -/// \param out: the stream to write the goto string to -/// \param instruction: the instruction to convert -/// \return Appends to out a two line representation of the instruction +/*******************************************************************\ + +Function: goto_programt::output_instruction + + Inputs: + ns - the namespace to resolve the expressions in + identifier - the identifier used to find a symbol to identify the + source language + out - the stream to write the goto string to + instruction - the instruction to convert + + Outputs: Appends to out a two line representation of the instruction + + Purpose: Writes to out a two line string representation of the specific + instruction. It is of the format: + // {location} file {source file} line {line in source file} + {representation of the instruction} + +\*******************************************************************/ + std::ostream &goto_programt::output_instruction( const namespacet &ns, const irep_idt &identifier, @@ -211,6 +229,18 @@ std::ostream &goto_programt::output_instruction( return out; } +/*******************************************************************\ + +Function: goto_programt::get_decl_identifiers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_programt::get_decl_identifiers( decl_identifierst &decl_identifiers) const { @@ -226,6 +256,18 @@ void goto_programt::get_decl_identifiers( } } +/*******************************************************************\ + +Function: parse_lhs_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_lhs_read(const exprt &src, std::list &dest) { if(src.id()==ID_dereference) @@ -253,6 +295,18 @@ void parse_lhs_read(const exprt &src, std::list &dest) } } +/*******************************************************************\ + +Function: expressions_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::list expressions_read( const goto_programt::instructiont &instruction) { @@ -298,6 +352,18 @@ std::list expressions_read( return dest; } +/*******************************************************************\ + +Function: expressions_written + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::list expressions_written( const goto_programt::instructiont &instruction) { @@ -326,6 +392,18 @@ std::list expressions_written( return dest; } +/*******************************************************************\ + +Function: get_objects_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void objects_read( const exprt &src, std::list &dest) @@ -350,6 +428,18 @@ void objects_read( } } +/*******************************************************************\ + +Function: objects_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::list objects_read( const goto_programt::instructiont &instruction) { @@ -363,6 +453,18 @@ std::list objects_read( return dest; } +/*******************************************************************\ + +Function: objects_written + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void objects_written( const exprt &src, std::list &dest) @@ -377,6 +479,18 @@ void objects_written( dest.push_back(src); } +/*******************************************************************\ + +Function: objects_written + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::list objects_written( const goto_programt::instructiont &instruction) { @@ -390,6 +504,18 @@ std::list objects_written( return dest; } +/*******************************************************************\ + +Function: as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string as_string( const class namespacet &ns, const goto_programt::instructiont &i) diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index 8e966283953..83fb020c096 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Concrete Goto Program - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_H diff --git a/src/goto-programs/goto_program_irep.cpp b/src/goto-programs/goto_program_irep.cpp index c93484fa644..3ddc09e27a3 100644 --- a/src/goto-programs/goto_program_irep.cpp +++ b/src/goto-programs/goto_program_irep.cpp @@ -8,15 +8,24 @@ Date: May 2007 \*******************************************************************/ -/// \file -/// goto_programt -> irep conversion - #include #include #include "goto_program_irep.h" +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const goto_programt::instructiont &instruction, irept &irep) { irep.set(ID_code, instruction.code); @@ -53,6 +62,18 @@ void convert(const goto_programt::instructiont &instruction, irept &irep) } } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const irept &irep, goto_programt::instructiont &instruction) @@ -73,6 +94,18 @@ void convert( instruction.labels.push_back(lsub.id()); } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const goto_programt &program, irept &irep) { irep.id("goto-program"); @@ -84,6 +117,18 @@ void convert(const goto_programt &program, irept &irep) } } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const irept &irep, goto_programt &program) { assert(irep.id()=="goto-program"); diff --git a/src/goto-programs/goto_program_irep.h b/src/goto-programs/goto_program_irep.h index 4659e62f9d4..aef5c1f9f0a 100644 --- a/src/goto-programs/goto_program_irep.h +++ b/src/goto-programs/goto_program_irep.h @@ -8,9 +8,6 @@ Date: May 2007 \*******************************************************************/ -/// \file -/// goto_programt -> irep conversion - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_IREP_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_IREP_H diff --git a/src/goto-programs/goto_program_template.cpp b/src/goto-programs/goto_program_template.cpp index bc4522a6841..80fc9089c74 100644 --- a/src/goto-programs/goto_program_template.cpp +++ b/src/goto-programs/goto_program_template.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto Program Template - #include #include "goto_program_template.h" +/*******************************************************************\ + +Function: operator<< + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<(std::ostream &out, goto_program_instruction_typet t) { switch(t) diff --git a/src/goto-programs/goto_program_template.h b/src/goto-programs/goto_program_template.h index af121f78444..fc36d573ef9 100644 --- a/src/goto-programs/goto_program_template.h +++ b/src/goto-programs/goto_program_template.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Goto Program Template - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_TEMPLATE_H #define CPROVER_GOTO_PROGRAMS_GOTO_PROGRAM_TEMPLATE_H diff --git a/src/goto-programs/goto_trace.cpp b/src/goto-programs/goto_trace.cpp index aa55b2643f4..d3ddb767d0c 100644 --- a/src/goto-programs/goto_trace.cpp +++ b/src/goto-programs/goto_trace.cpp @@ -8,9 +8,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #include #include @@ -22,6 +19,18 @@ Author: Daniel Kroening #include "goto_trace.h" +/*******************************************************************\ + +Function: goto_tracet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_tracet::output( const class namespacet &ns, std::ostream &out) const @@ -30,6 +39,18 @@ void goto_tracet::output( step.output(ns, out); } +/*******************************************************************\ + +Function: goto_tracet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_trace_stept::output( const namespacet &ns, std::ostream &out) const @@ -116,6 +137,18 @@ void goto_trace_stept::output( out << "\n"; } +/*******************************************************************\ + +Function: trace_value_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string trace_value_binary( const exprt &expr, const namespacet &ns) @@ -179,6 +212,18 @@ std::string trace_value_binary( return "?"; } +/*******************************************************************\ + +Function: trace_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void trace_value( std::ostream &out, const namespacet &ns, @@ -209,6 +254,18 @@ void trace_value( << "\n"; } +/*******************************************************************\ + +Function: show_state_header + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_state_header( std::ostream &out, const goto_trace_stept &state, @@ -227,6 +284,18 @@ void show_state_header( out << "----------------------------------------------------" << "\n"; } +/*******************************************************************\ + +Function: is_index_member_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_index_member_symbol(const exprt &src) { if(src.id()==ID_index) @@ -239,6 +308,18 @@ bool is_index_member_symbol(const exprt &src) return false; } +/*******************************************************************\ + +Function: show_goto_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_goto_trace( std::ostream &out, const namespacet &ns, diff --git a/src/goto-programs/goto_trace.h b/src/goto-programs/goto_trace.h index 02f230e8943..7bcbc1077b8 100644 --- a/src/goto-programs/goto_trace.h +++ b/src/goto-programs/goto_trace.h @@ -8,9 +8,6 @@ Date: July 2005 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #ifndef CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_GOTO_TRACE_H diff --git a/src/goto-programs/graphml_witness.cpp b/src/goto-programs/graphml_witness.cpp index 791e7574987..ae10705e232 100644 --- a/src/goto-programs/graphml_witness.cpp +++ b/src/goto-programs/graphml_witness.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Witnesses for Traces and Proofs - #include #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening #include "graphml_witness.h" +/*******************************************************************\ + +Function: graphml_witnesst::remove_l0_l1 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void graphml_witnesst::remove_l0_l1(exprt &expr) { if(expr.id()==ID_symbol) @@ -44,6 +53,18 @@ void graphml_witnesst::remove_l0_l1(exprt &expr) remove_l0_l1(*it); } +/*******************************************************************\ + +Function: graphml_witnesst::convert_assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string graphml_witnesst::convert_assign_rec( const irep_idt &identifier, const code_assignt &assign) @@ -135,6 +156,18 @@ std::string graphml_witnesst::convert_assign_rec( return result; } +/*******************************************************************\ + +Function: filter_out + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool filter_out( const goto_tracet &goto_trace, const goto_tracet::stepst::const_iterator &prev_it, @@ -170,7 +203,18 @@ static bool filter_out( return false; } -/// counterexample witness +/*******************************************************************\ + +Function: graphml_witnesst::operator() + + Inputs: + + Outputs: + + Purpose: counterexample witness + +\*******************************************************************/ + void graphml_witnesst::operator()(const goto_tracet &goto_trace) { graphml.key_values["sourcecodelang"]="C"; @@ -354,7 +398,18 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) } } -/// proof witness +/*******************************************************************\ + +Function: graphml_witnesst::operator() + + Inputs: + + Outputs: + + Purpose: proof witness + +\*******************************************************************/ + void graphml_witnesst::operator()(const symex_target_equationt &equation) { graphml.key_values["sourcecodelang"]="C"; diff --git a/src/goto-programs/graphml_witness.h b/src/goto-programs/graphml_witness.h index 053eb801146..65a6b8e5406 100644 --- a/src/goto-programs/graphml_witness.h +++ b/src/goto-programs/graphml_witness.h @@ -6,9 +6,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Witnesses for Traces and Proofs - #ifndef CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H #define CPROVER_GOTO_PROGRAMS_GRAPHML_WITNESS_H diff --git a/src/goto-programs/initialize_goto_model.cpp b/src/goto-programs/initialize_goto_model.cpp index faff5da8a38..52a6caeeba2 100644 --- a/src/goto-programs/initialize_goto_model.cpp +++ b/src/goto-programs/initialize_goto_model.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Get a Goto Program - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "read_goto_binary.h" #include "initialize_goto_model.h" +/*******************************************************************\ + +Function: initialize_goto_model + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool initialize_goto_model( goto_modelt &goto_model, const cmdlinet &cmdline, diff --git a/src/goto-programs/initialize_goto_model.h b/src/goto-programs/initialize_goto_model.h index 9aa1c8ef126..2b4b03615ca 100644 --- a/src/goto-programs/initialize_goto_model.h +++ b/src/goto-programs/initialize_goto_model.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Initialize a Goto Program - #ifndef CPROVER_GOTO_PROGRAMS_INITIALIZE_GOTO_MODEL_H #define CPROVER_GOTO_PROGRAMS_INITIALIZE_GOTO_MODEL_H diff --git a/src/goto-programs/interpreter.cpp b/src/goto-programs/interpreter.cpp index aca343b4cfb..149f4002651 100644 --- a/src/goto-programs/interpreter.cpp +++ b/src/goto-programs/interpreter.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interpreter for GOTO Programs - #include #include #include @@ -30,6 +27,18 @@ Author: Daniel Kroening, kroening@kroening.com const size_t interpretert::npos=std::numeric_limits::max(); +/*******************************************************************\ + +Function: interpretert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::operator()() { status() << "0- Initialize:" << eom; @@ -52,8 +61,20 @@ void interpretert::operator()() command(); } -/// Initializes the memory map of the interpreter and [optionally] runs up to -/// the entry point (thus doing the cprover initialization) +/*******************************************************************\ + +Function: interpretert::initialize + + Inputs: + + Outputs: + + Purpose: Initializes the memory map of the interpreter and + [optionally] runs up to the entry point (thus doing + the cprover initialization) + +\*******************************************************************/ + void interpretert::initialize(bool init) { build_memory_map(); @@ -94,7 +115,19 @@ void interpretert::initialize(bool init) } } -/// displays the current position of the pc and corresponding code +/*******************************************************************\ + +Function: interpretert::show_state + + Inputs: + + Outputs: + + Purpose: displays the current position of the pc and corresponding + code + +\*******************************************************************/ + void interpretert::show_state() { if(!show) @@ -117,7 +150,18 @@ void interpretert::show_state() status() << eom; } -/// reads a user command and executes it. +/*******************************************************************\ + +Function: interpretert::command + + Inputs: + + Outputs: + + Purpose: reads a user command and executes it. + +\*******************************************************************/ + void interpretert::command() { #define BUFSIZE 100 @@ -222,7 +266,18 @@ void interpretert::command() show_state(); } -/// executes a single step and updates the program counter +/*******************************************************************\ + +Function: interpretert::step + + Inputs: + + Outputs: + + Purpose: executes a single step and updates the program counter + +\*******************************************************************/ + void interpretert::step() { total_steps++; @@ -358,7 +413,18 @@ void interpretert::step() pc=next_pc; } -/// executes a goto instruction +/*******************************************************************\ + +Function: interpretert::execute_goto + + Inputs: + + Outputs: + + Purpose: executes a goto instruction + +\*******************************************************************/ + void interpretert::execute_goto() { if(evaluate_boolean(pc->guard)) @@ -373,7 +439,18 @@ void interpretert::execute_goto() } } -/// executes side effects of 'other' instructions +/*******************************************************************\ + +Function: interpretert::execute_other + + Inputs: + + Outputs: + + Purpose: executes side effects of 'other' instructions + +\*******************************************************************/ + void interpretert::execute_other() { const irep_idt &statement=pc->code.get_statement(); @@ -406,13 +483,35 @@ void interpretert::execute_other() throw "unexpected OTHER statement: "+id2string(statement); } +/*******************************************************************\ + +Function: interpretert::execute_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::execute_decl() { assert(pc->code.get_statement()==ID_decl); } -/// retrieves the member at offset -/// \par parameters: an object and a memory offset +/*******************************************************************\ + +Function: interpretert::get_component_id + + Inputs: an object and a memory offset + + Outputs: + + Purpose: retrieves the member at offset + +\*******************************************************************/ + irep_idt interpretert::get_component_id( const irep_idt &object, unsigned offset) @@ -435,7 +534,18 @@ irep_idt interpretert::get_component_id( return object; } -/// returns the type object corresponding to id +/*******************************************************************\ + +Function: interpretert::get_type + + Inputs: + + Outputs: + + Purpose: returns the type object corresponding to id + +\*******************************************************************/ + typet interpretert::get_type(const irep_idt &id) const { dynamic_typest::const_iterator it=dynamic_types.find(id); @@ -444,8 +554,19 @@ typet interpretert::get_type(const irep_idt &id) const return it->second; } -/// retrives the constant value at memory location offset as an object of type -/// type +/*******************************************************************\ + +Function: interpretert::get_value + + Inputs: + + Outputs: + + Purpose: retrives the constant value at memory location offset + as an object of type type + +\*******************************************************************/ + exprt interpretert::get_value( const typet &type, std::size_t offset, @@ -506,8 +627,19 @@ exprt interpretert::get_value( return get_value(type, rhs); } -/// returns the value at offset in the form of type given a memory buffer rhs -/// which is typically a structured type +/*******************************************************************\ + + Function: interpretert::get_value + + Inputs: + + Outputs: + + Purpose: returns the value at offset in the form of type given a + memory buffer rhs which is typically a structured type + +\*******************************************************************/ + exprt interpretert::get_value( const typet &type, mp_vectort &rhs, @@ -633,7 +765,18 @@ exprt interpretert::get_value( return from_integer(rhs[offset], type); } -/// executes the assign statement at the current pc value +/*******************************************************************\ + +Function: interpretert::execute_assign + + Inputs: + + Outputs: + + Purpose: executes the assign statement at the current pc value + +\*******************************************************************/ + void interpretert::execute_assign() { const code_assignt &code_assign= @@ -683,7 +826,19 @@ void interpretert::execute_assign() } } -/// sets the memory at address with the given rhs value (up to sizeof(rhs)) +/*******************************************************************\ + +Function: interpretert::assign + + Inputs: + + Outputs: + + Purpose: sets the memory at address with the given rhs value + (up to sizeof(rhs)) + +\*******************************************************************/ + void interpretert::assign( mp_integer address, const mp_vectort &rhs) @@ -708,12 +863,36 @@ void interpretert::assign( } } +/*******************************************************************\ + +Function: interpretert::execute_assume + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::execute_assume() { if(!evaluate_boolean(pc->guard)) throw "assumption failed"; } +/*******************************************************************\ + +Function: interpretert::execute_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::execute_assert() { if(!evaluate_boolean(pc->guard)) @@ -726,6 +905,18 @@ void interpretert::execute_assert() } } +/*******************************************************************\ + +Function: interpretert::execute_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::execute_function_call() { const code_function_callt &function_call= @@ -836,7 +1027,18 @@ void interpretert::execute_function_call() } } -/// Creates a memory map of all static symbols in the program +/*******************************************************************\ + +Function: interpretert::build_memory_map + + Inputs: + + Outputs: + + Purpose: Creates a memory map of all static symbols in the program + +\*******************************************************************/ + void interpretert::build_memory_map() { // put in a dummy for NULL @@ -854,6 +1056,18 @@ void interpretert::build_memory_map() stack_pointer=memory.size(); } +/*******************************************************************\ + +Function: interpretert::build_memory_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::build_memory_map(const symbolt &symbol) { size_t size=0; @@ -876,7 +1090,18 @@ void interpretert::build_memory_map(const symbolt &symbol) } } -/// turns a variable length array type into a fixed array type +/*******************************************************************\ + +Function: interpretert::concretize_type + + Inputs: + + Outputs: + + Purpose: turns a variable length array type into a fixed array type + +\*******************************************************************/ + typet interpretert::concretize_type(const typet &type) { if(type.id()==ID_array) @@ -901,8 +1126,19 @@ typet interpretert::concretize_type(const typet &type) return type; } -/// Populates dynamic entries of the memory map -/// \return Updates the memory map to include variable id if it does not exist +/*******************************************************************\ + +Function: interpretert::build_memory_map + + Inputs: + + Outputs: Updates the memory map to include variable id if it does + not exist + + Purpose: Populates dynamic entries of the memory map + +\*******************************************************************/ + mp_integer interpretert::build_memory_map( const irep_idt &id, const typet &type) @@ -954,10 +1190,21 @@ bool interpretert::unbounded_size(const typet &type) return false; } -/// Retrieves the actual size of the provided structured type. Unbounded objects -/// get allocated 2^32 address space each (of a 2^64 sized space). -/// \param type: a structured type -/// \return Size of the given type +/*******************************************************************\ + +Function: interpretert::get_size + + Inputs: + type - a structured type + + Outputs: Size of the given type + + Purpose: Retrieves the actual size of the provided structured type. + Unbounded objects get allocated 2^32 address space each + (of a 2^64 sized space). + +\*******************************************************************/ + size_t interpretert::get_size(const typet &type) { if(unbounded_size(type)) @@ -1053,6 +1300,18 @@ exprt interpretert::get_value(const irep_idt &id) return get_value(get_type, integer2size_t(whole_lhs_object_address)); } +/*******************************************************************\ + +Function: interpreter + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpreter( const symbol_tablet &symbol_table, const goto_functionst &goto_functions, @@ -1065,8 +1324,19 @@ void interpreter( interpreter(); } -/// Prints the current state of the memory map Since messaget mdofifies class -/// members, print functions are nonconst +/*******************************************************************\ + +Function: interpretert::print_memory + + Inputs: + + Outputs: + + Purpose: Prints the current state of the memory map + Since messaget mdofifies class members, print functions are nonconst + +\*******************************************************************/ + void interpretert::print_memory(bool input_flags) { for(const auto &cell_address : memory) diff --git a/src/goto-programs/interpreter.h b/src/goto-programs/interpreter.h index 8d598852b1a..1888a009969 100644 --- a/src/goto-programs/interpreter.h +++ b/src/goto-programs/interpreter.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interpreter for GOTO Programs - #ifndef CPROVER_GOTO_PROGRAMS_INTERPRETER_H #define CPROVER_GOTO_PROGRAMS_INTERPRETER_H diff --git a/src/goto-programs/interpreter_class.h b/src/goto-programs/interpreter_class.h index 9456037a474..d1051eeb93f 100644 --- a/src/goto-programs/interpreter_class.h +++ b/src/goto-programs/interpreter_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interpreter for GOTO Programs - #ifndef CPROVER_GOTO_PROGRAMS_INTERPRETER_CLASS_H #define CPROVER_GOTO_PROGRAMS_INTERPRETER_CLASS_H diff --git a/src/goto-programs/interpreter_evaluate.cpp b/src/goto-programs/interpreter_evaluate.cpp index 12aca4b57b5..b711be84ba2 100644 --- a/src/goto-programs/interpreter_evaluate.cpp +++ b/src/goto-programs/interpreter_evaluate.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Interpreter for GOTO Programs - #include #include #include @@ -21,8 +18,19 @@ Author: Daniel Kroening, kroening@kroening.com #include "interpreter_class.h" -/// reads a memory address and loads it into the dest variable marks cell as -/// read before written if cell has never been written +/*******************************************************************\ + +Function: interpretert::read + + Inputs: + + Outputs: + + Purpose: reads a memory address and loads it into the dest variable + marks cell as read before written if cell has never been written + +\*******************************************************************/ + void interpretert::read( mp_integer address, mp_vectort &dest) const @@ -74,7 +82,18 @@ void interpretert::read_unbounded( } } -/// reserves memory block of size at address +/*******************************************************************\ + +Function: interpretert::allocate + + Inputs: + + Outputs: + + Purpose: reserves memory block of size at address + +\*******************************************************************/ + void interpretert::allocate( mp_integer address, size_t size) @@ -91,7 +110,18 @@ void interpretert::allocate( } } -/// Clears memoy r/w flag initialization +/*******************************************************************\ + +Function: interpretert::clear_input_flags + + Inputs: + + Outputs: + + Purpose: Clears memoy r/w flag initialization + +\*******************************************************************/ + void interpretert::clear_input_flags() { for(auto &cell : memory) @@ -101,7 +131,18 @@ void interpretert::clear_input_flags() } } -/// \return Number of leaf primitive types; returns true on error +/*******************************************************************\ + +Function: interpretert::count_type_leaves + + Inputs: Type + + Outputs: Number of leaf primitive types; returns true on error + + Purpose: + +\*******************************************************************/ + bool interpretert::count_type_leaves(const typet &ty, mp_integer &result) { if(ty.id()==ID_struct) @@ -136,15 +177,25 @@ bool interpretert::count_type_leaves(const typet &ty, mp_integer &result) } } -/// Supposing the caller has an mp_vector representing a value with type -/// 'source_type', this yields the offset into that vector at which to find a -/// value at *byte* address 'offset'. We need this because the interpreter's -/// memory map uses unlabelled variable-width values -- for example, a C value { -/// { 1, 2 }, 3, 4 } of type struct { int x[2]; char y; unsigned long z; } would -/// be represented [1,2,3,4], with the source type needed alongside to figure -/// out which member is targeted by a byte-extract operation. -/// \par parameters: 'source_type', 'offset' (unit: bytes), -/// \return Offset into a vector of interpreter values; returns true on error +/*******************************************************************\ + +Function: interpretert::byte_offset_to_memory_offset + + Inputs: 'source_type', 'offset' (unit: bytes), + + Outputs: Offset into a vector of interpreter values; returns true on error + + Purpose: Supposing the caller has an mp_vector representing + a value with type 'source_type', this yields the offset into that + vector at which to find a value at *byte* address 'offset'. + We need this because the interpreter's memory map uses unlabelled + variable-width values -- for example, a C value { { 1, 2 }, 3, 4 } + of type struct { int x[2]; char y; unsigned long z; } + would be represented [1,2,3,4], with the source type needed alongside + to figure out which member is targeted by a byte-extract operation. + +\*******************************************************************/ + bool interpretert::byte_offset_to_memory_offset( const typet &source_type, mp_integer offset, @@ -219,12 +270,21 @@ bool interpretert::byte_offset_to_memory_offset( } } -/// Similarly to the above, the interpreter's memory objects contain mp_integers -/// that represent variable-sized struct members. This counts the size of type -/// leaves to determine the byte offset corresponding to a memory offset. -/// \par parameters: An interpreter memory offset and the type to interpret that -/// memory -/// \return The corresponding byte offset. Returns true on error +/*******************************************************************\ + +Function: interpretert::memory_offset_to_byte_offset + + Inputs: An interpreter memory offset and the type to interpret that memory + + Outputs: The corresponding byte offset. Returns true on error + + Purpose: Similarly to the above, the interpreter's memory objects contain + mp_integers that represent variable-sized struct members. This + counts the size of type leaves to determine the byte offset + corresponding to a memory offset. + +\*******************************************************************/ + bool interpretert::memory_offset_to_byte_offset( const typet &source_type, mp_integer cell_offset, @@ -296,6 +356,18 @@ bool interpretert::memory_offset_to_byte_offset( } } +/*******************************************************************\ + +Function: interpretert::evaluate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void interpretert::evaluate( const exprt &expr, mp_vectort &dest) @@ -1064,6 +1136,18 @@ void interpretert::evaluate( << eom; } +/*******************************************************************\ + +Function: interpretert::evaluate_address + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer interpretert::evaluate_address( const exprt &expr, bool fail_quietly) diff --git a/src/goto-programs/json_goto_trace.cpp b/src/goto-programs/json_goto_trace.cpp index eaa84f6654b..694466aec2b 100644 --- a/src/goto-programs/json_goto_trace.cpp +++ b/src/goto-programs/json_goto_trace.cpp @@ -8,9 +8,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening #include "json_goto_trace.h" +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/json_goto_trace.h b/src/goto-programs/json_goto_trace.h index 102569b50e6..a4a3f2757fe 100644 --- a/src/goto-programs/json_goto_trace.h +++ b/src/goto-programs/json_goto_trace.h @@ -8,9 +8,6 @@ Date: November 2005 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #ifndef CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_JSON_GOTO_TRACE_H diff --git a/src/goto-programs/link_to_library.cpp b/src/goto-programs/link_to_library.cpp index f78abb5dc39..c3ead7e6ecb 100644 --- a/src/goto-programs/link_to_library.cpp +++ b/src/goto-programs/link_to_library.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Library Linking - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "compute_called_functions.h" #include "goto_convert_functions.h" +/*******************************************************************\ + +Function: link_to_library + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void link_to_library( goto_modelt &goto_model, message_handlert &message_handler) @@ -27,6 +36,18 @@ void link_to_library( message_handler); } +/*******************************************************************\ + +Function: link_to_library + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void link_to_library( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/goto-programs/link_to_library.h b/src/goto-programs/link_to_library.h index c45c5efbfa2..cb266e5d8fa 100644 --- a/src/goto-programs/link_to_library.h +++ b/src/goto-programs/link_to_library.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Library Linking - #ifndef CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H #define CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H diff --git a/src/goto-programs/loop_ids.cpp b/src/goto-programs/loop_ids.cpp index 46ca3ad3e8e..723ffe329aa 100644 --- a/src/goto-programs/loop_ids.cpp +++ b/src/goto-programs/loop_ids.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Loop IDs - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "loop_ids.h" +/*******************************************************************\ + +Function: show_loop_ids + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_loop_ids( ui_message_handlert::uit ui, const goto_modelt &goto_model) @@ -25,6 +34,18 @@ void show_loop_ids( show_loop_ids(ui, goto_model.goto_functions); } +/*******************************************************************\ + +Function: show_loop_ids + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_loop_ids( ui_message_handlert::uit ui, const goto_programt &goto_program) @@ -92,6 +113,18 @@ void show_loop_ids_json( } } +/*******************************************************************\ + +Function: show_loop_ids + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_loop_ids( ui_message_handlert::uit ui, const goto_functionst &goto_functions) diff --git a/src/goto-programs/loop_ids.h b/src/goto-programs/loop_ids.h index a9f439286d7..da17118698c 100644 --- a/src/goto-programs/loop_ids.h +++ b/src/goto-programs/loop_ids.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Loop IDs - #ifndef CPROVER_GOTO_PROGRAMS_LOOP_IDS_H #define CPROVER_GOTO_PROGRAMS_LOOP_IDS_H diff --git a/src/goto-programs/osx_fat_reader.cpp b/src/goto-programs/osx_fat_reader.cpp index 93bc0f93dbc..aa9594ec203 100644 --- a/src/goto-programs/osx_fat_reader.cpp +++ b/src/goto-programs/osx_fat_reader.cpp @@ -6,9 +6,6 @@ Module: Read Mach-O \*******************************************************************/ -/// \file -/// Read Mach-O - #include #include @@ -18,6 +15,18 @@ Module: Read Mach-O #include #endif +/*******************************************************************\ + +Function: is_osx_fat_magic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_osx_fat_magic(char hdr[4]) { #ifdef __APPLE__ @@ -34,6 +43,18 @@ bool is_osx_fat_magic(char hdr[4]) return false; } +/*******************************************************************\ + +Function: osx_fat_readert::osx_fat_readert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + osx_fat_readert::osx_fat_readert(std::ifstream &in) : has_gb_arch(false) { @@ -73,6 +94,18 @@ osx_fat_readert::osx_fat_readert(std::ifstream &in) : #endif } +/*******************************************************************\ + +Function: osx_fat_readert::extract_gb + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool osx_fat_readert::extract_gb( const std::string &source, const std::string &dest) const diff --git a/src/goto-programs/osx_fat_reader.h b/src/goto-programs/osx_fat_reader.h index 715fc9f1eec..e164548607b 100644 --- a/src/goto-programs/osx_fat_reader.h +++ b/src/goto-programs/osx_fat_reader.h @@ -6,9 +6,6 @@ Module: Read OS X Fat Binaries \*******************************************************************/ -/// \file -/// Read OS X Fat Binaries - #ifndef CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H #define CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H diff --git a/src/goto-programs/parameter_assignments.cpp b/src/goto-programs/parameter_assignments.cpp index 98d9f80a1c3..2052bdb09d8 100644 --- a/src/goto-programs/parameter_assignments.cpp +++ b/src/goto-programs/parameter_assignments.cpp @@ -8,9 +8,6 @@ Date: September 2015 \*******************************************************************/ -/// \file -/// Add parameter assignments - #include #include @@ -35,7 +32,18 @@ class parameter_assignmentst goto_programt &goto_program); }; -/// turns x=f(...) into f(...); lhs=f#return_value; +/*******************************************************************\ + +Function: parameter_assignmentst::do_function_calls + +Inputs: + +Outputs: + +Purpose: turns x=f(...) into f(...); lhs=f#return_value; + +\*******************************************************************/ + void parameter_assignmentst::do_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -90,13 +98,36 @@ void parameter_assignmentst::do_function_calls( } } +/*******************************************************************\ + +Function: parameter_assignmentst::operator() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void parameter_assignmentst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) do_function_calls(goto_functions, it->second.body); } -/// removes returns +/*******************************************************************\ + +Function: parameter_assignments + +Inputs: + +Outputs: + +Purpose: removes returns + +\*******************************************************************/ + void parameter_assignments( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -105,7 +136,18 @@ void parameter_assignments( rr(goto_functions); } -/// removes returns +/*******************************************************************\ + +Function: parameter_assignments + +Inputs: + +Outputs: + +Purpose: removes returns + +\*******************************************************************/ + void parameter_assignments(goto_modelt &goto_model) { parameter_assignmentst rr(goto_model.symbol_table); diff --git a/src/goto-programs/parameter_assignments.h b/src/goto-programs/parameter_assignments.h index 61eb180d7cd..b9cafe8f932 100644 --- a/src/goto-programs/parameter_assignments.h +++ b/src/goto-programs/parameter_assignments.h @@ -8,9 +8,6 @@ Date: September 2015 \*******************************************************************/ -/// \file -/// Add parameter assignments - #ifndef CPROVER_GOTO_PROGRAMS_PARAMETER_ASSIGNMENTS_H #define CPROVER_GOTO_PROGRAMS_PARAMETER_ASSIGNMENTS_H diff --git a/src/goto-programs/pointer_arithmetic.cpp b/src/goto-programs/pointer_arithmetic.cpp index f396f1b1e06..0639a0dbca4 100644 --- a/src/goto-programs/pointer_arithmetic.cpp +++ b/src/goto-programs/pointer_arithmetic.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_arithmetic.h" +/*******************************************************************\ + +Function: pointer_arithmetict::pointer_arithmetict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + pointer_arithmetict::pointer_arithmetict(const exprt &src) { pointer.make_nil(); @@ -18,6 +30,18 @@ pointer_arithmetict::pointer_arithmetict(const exprt &src) read(src); } +/*******************************************************************\ + +Function: pointer_arithmetict::read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_arithmetict::read(const exprt &src) { if(src.id()==ID_plus) @@ -63,6 +87,18 @@ void pointer_arithmetict::read(const exprt &src) make_pointer(src); } +/*******************************************************************\ + +Function: pointer_arithmetict::add_to_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_arithmetict::add_to_offset(const exprt &src) { if(offset.is_nil()) @@ -80,6 +116,18 @@ void pointer_arithmetict::add_to_offset(const exprt &src) } } +/*******************************************************************\ + +Function: pointer_arithmetict::make_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_arithmetict::make_pointer(const exprt &src) { if(pointer.is_nil()) diff --git a/src/goto-programs/property_checker.cpp b/src/goto-programs/property_checker.cpp index 7c39bc34e06..de790db2dd4 100644 --- a/src/goto-programs/property_checker.cpp +++ b/src/goto-programs/property_checker.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Property Checker Interface - #include "property_checker.h" +/*******************************************************************\ + +Function: property_checkert::as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string property_checkert::as_string(resultt result) { switch(result) @@ -24,12 +33,36 @@ std::string property_checkert::as_string(resultt result) return ""; } +/*******************************************************************\ + +Function: property_checkert::property_checkert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + property_checkert::property_checkert( message_handlert &_message_handler): messaget(_message_handler) { } +/*******************************************************************\ + +Function: property_checkert::initialize_property_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void property_checkert::initialize_property_map( const goto_functionst &goto_functions) { diff --git a/src/goto-programs/property_checker.h b/src/goto-programs/property_checker.h index fd89606a752..c6a4dbe40b5 100644 --- a/src/goto-programs/property_checker.h +++ b/src/goto-programs/property_checker.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Property Checker Interface - #ifndef CPROVER_GOTO_PROGRAMS_PROPERTY_CHECKER_H #define CPROVER_GOTO_PROGRAMS_PROPERTY_CHECKER_H diff --git a/src/goto-programs/read_bin_goto_object.cpp b/src/goto-programs/read_bin_goto_object.cpp index faad12665ae..9c92b403cf1 100644 --- a/src/goto-programs/read_bin_goto_object.cpp +++ b/src/goto-programs/read_bin_goto_object.cpp @@ -8,9 +8,6 @@ Date: June 2006 \*******************************************************************/ -/// \file -/// Read goto object files. - #include #include #include @@ -19,9 +16,18 @@ Date: June 2006 #include "goto_functions.h" #include "read_bin_goto_object.h" -/// read goto binary format v3 -/// \par parameters: input stream, symbol_table, functions -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: read_goto_object_v3 + + Inputs: input stream, symbol_table, functions + + Outputs: true on error, false otherwise + + Purpose: read goto binary format v3 + +\*******************************************************************/ + bool read_bin_goto_object_v3( std::istream &in, const std::string &filename, @@ -162,9 +168,18 @@ bool read_bin_goto_object_v3( return false; } -/// reads a goto binary file back into a symbol and a function table -/// \par parameters: input stream, symbol table, functions -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: read_goto_object + + Inputs: input stream, symbol table, functions + + Outputs: true on error, false otherwise + + Purpose: reads a goto binary file back into a symbol and a function table + +\*******************************************************************/ + bool read_bin_goto_object( std::istream &in, const std::string &filename, diff --git a/src/goto-programs/read_bin_goto_object.h b/src/goto-programs/read_bin_goto_object.h index e7b684b3cc4..a4b679427d7 100644 --- a/src/goto-programs/read_bin_goto_object.h +++ b/src/goto-programs/read_bin_goto_object.h @@ -8,9 +8,6 @@ Date: May 2007 \*******************************************************************/ -/// \file -/// Read goto object files. - #ifndef CPROVER_GOTO_PROGRAMS_READ_BIN_GOTO_OBJECT_H #define CPROVER_GOTO_PROGRAMS_READ_BIN_GOTO_OBJECT_H diff --git a/src/goto-programs/read_goto_binary.cpp b/src/goto-programs/read_goto_binary.cpp index ec7eaf8f826..b5919d93eee 100644 --- a/src/goto-programs/read_goto_binary.cpp +++ b/src/goto-programs/read_goto_binary.cpp @@ -6,9 +6,6 @@ Module: Read Goto Programs \*******************************************************************/ -/// \file -/// Read Goto Programs - #if defined(__linux__) || \ defined(__FreeBSD_kernel__) || \ defined(__GNU__) || \ @@ -37,6 +34,18 @@ Module: Read Goto Programs #include "elf_reader.h" #include "osx_fat_reader.h" +/*******************************************************************\ + +Function: read_goto_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool read_goto_binary( const std::string &filename, goto_modelt &dest, @@ -46,6 +55,18 @@ bool read_goto_binary( filename, dest.symbol_table, dest.goto_functions, message_handler); } +/*******************************************************************\ + +Function: read_goto_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool read_goto_binary( const std::string &filename, symbol_tablet &symbol_table, @@ -151,6 +172,18 @@ bool read_goto_binary( return true; } +/*******************************************************************\ + +Function: is_goto_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_goto_binary(const std::string &filename) { #ifdef _MSC_VER @@ -212,6 +245,18 @@ bool is_goto_binary(const std::string &filename) return false; } +/*******************************************************************\ + +Function: rename_symbols_in_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void rename_symbols_in_function( goto_functionst::goto_functiont &function, const rename_symbolt &rename_symbol) @@ -226,6 +271,18 @@ static void rename_symbols_in_function( } } +/*******************************************************************\ + +Function: link_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool link_functions( symbol_tablet &dest_symbol_table, goto_functionst &dest_functions, @@ -327,9 +384,18 @@ static bool link_functions( return false; } -/// reads an object file -/// \par parameters: a file_name -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: read_object_and_link + + Inputs: a file_name + + Outputs: true on error, false otherwise + + Purpose: reads an object file + +\*******************************************************************/ + bool read_object_and_link( const std::string &file_name, symbol_tablet &symbol_table, @@ -369,9 +435,18 @@ bool read_object_and_link( return false; } -/// reads an object file -/// \par parameters: a file_name -/// \return true on error, false otherwise +/*******************************************************************\ + +Function: read_object_and_link + + Inputs: a file_name + + Outputs: true on error, false otherwise + + Purpose: reads an object file + +\*******************************************************************/ + bool read_object_and_link( const std::string &file_name, goto_modelt &goto_model, diff --git a/src/goto-programs/read_goto_binary.h b/src/goto-programs/read_goto_binary.h index bbaba7a5c11..f926179b134 100644 --- a/src/goto-programs/read_goto_binary.h +++ b/src/goto-programs/read_goto_binary.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Read Goto Programs - #ifndef CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H #define CPROVER_GOTO_PROGRAMS_READ_GOTO_BINARY_H diff --git a/src/goto-programs/remove_asm.cpp b/src/goto-programs/remove_asm.cpp index 9966051d176..a77d1e0e418 100644 --- a/src/goto-programs/remove_asm.cpp +++ b/src/goto-programs/remove_asm.cpp @@ -9,9 +9,6 @@ Date: December 2014 \*******************************************************************/ -/// \file -/// Remove 'asm' statements by compiling into suitable standard code - #include #include @@ -51,6 +48,18 @@ class remove_asmt goto_programt &dest); }; +/*******************************************************************\ + +Function: remove_asmt::gcc_asm_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_asmt::gcc_asm_function_call( const irep_idt &function_base_name, const codet &code, @@ -109,7 +118,18 @@ void remove_asmt::gcc_asm_function_call( } } -/// removes assembler +/*******************************************************************\ + +Function: remove_asmt::process_instruction + +Inputs: + +Outputs: + +Purpose: removes assembler + +\*******************************************************************/ + void remove_asmt::process_instruction( goto_programt::instructiont &instruction, goto_programt &dest) @@ -282,7 +302,18 @@ void remove_asmt::process_instruction( } } -/// removes assembler +/*******************************************************************\ + +Function: remove_asmt::process_function + +Inputs: + +Outputs: + +Purpose: removes assembler + +\*******************************************************************/ + void remove_asmt::process_function( goto_functionst::goto_functiont &goto_function) { @@ -302,7 +333,18 @@ void remove_asmt::process_function( } } -/// removes assembler +/*******************************************************************\ + +Function: remove_asmt:operator() + +Inputs: + +Outputs: + +Purpose: removes assembler + +\*******************************************************************/ + void remove_asmt::operator()() { Forall_goto_functions(it, goto_functions) @@ -311,7 +353,18 @@ void remove_asmt::operator()() } } -/// removes assembler +/*******************************************************************\ + +Function: remove_asm + +Inputs: + +Outputs: + +Purpose: removes assembler + +\*******************************************************************/ + void remove_asm( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -319,7 +372,18 @@ void remove_asm( remove_asmt(symbol_table, goto_functions)(); } -/// removes assembler +/*******************************************************************\ + +Function: remove_asm + +Inputs: + +Outputs: + +Purpose: removes assembler + +\*******************************************************************/ + void remove_asm(goto_modelt &goto_model) { remove_asmt(goto_model.symbol_table, goto_model.goto_functions)(); diff --git a/src/goto-programs/remove_asm.h b/src/goto-programs/remove_asm.h index 7717ba59ca0..a0de50fc699 100644 --- a/src/goto-programs/remove_asm.h +++ b/src/goto-programs/remove_asm.h @@ -9,9 +9,6 @@ Date: December 2014 \*******************************************************************/ -/// \file -/// Remove 'asm' statements by compiling into suitable standard code - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H #define CPROVER_GOTO_PROGRAMS_REMOVE_ASM_H diff --git a/src/goto-programs/remove_complex.cpp b/src/goto-programs/remove_complex.cpp index bb031082bd0..44539fb5f1e 100644 --- a/src/goto-programs/remove_complex.cpp +++ b/src/goto-programs/remove_complex.cpp @@ -8,13 +8,22 @@ Date: September 2014 \*******************************************************************/ -/// \file -/// Remove 'complex' data type - #include #include "remove_complex.h" +/*******************************************************************\ + +Function: complex_member + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static exprt complex_member(const exprt &expr, irep_idt id) { if(expr.id()==ID_struct && expr.operands().size()==2) @@ -36,6 +45,18 @@ static exprt complex_member(const exprt &expr, irep_idt id) } } +/*******************************************************************\ + +Function: have_to_remove_complex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool have_to_remove_complex(const typet &type); static bool have_to_remove_complex(const exprt &expr) @@ -73,6 +94,18 @@ static bool have_to_remove_complex(const exprt &expr) return false; } +/*******************************************************************\ + +Function: have_to_remove_complex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool have_to_remove_complex(const typet &type) { if(type.id()==ID_struct || type.id()==ID_union) @@ -96,7 +129,18 @@ static bool have_to_remove_complex(const typet &type) return false; } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + static void remove_complex(typet &); static void remove_complex(exprt &expr) @@ -230,7 +274,18 @@ static void remove_complex(exprt &expr) remove_complex(expr.type()); } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + static void remove_complex(typet &type) { if(!have_to_remove_complex(type)) @@ -272,21 +327,54 @@ static void remove_complex(typet &type) } } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + static void remove_complex(symbolt &symbol) { remove_complex(symbol.value); remove_complex(symbol.type); } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + void remove_complex(symbol_tablet &symbol_table) { Forall_symbols(it, symbol_table.symbols) remove_complex(it->second); } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + static void remove_complex( goto_functionst::goto_functiont &goto_function) { @@ -299,14 +387,36 @@ static void remove_complex( } } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + static void remove_complex(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) remove_complex(it->second); } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + void remove_complex( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -315,7 +425,18 @@ void remove_complex( remove_complex(goto_functions); } -/// removes complex data type +/*******************************************************************\ + +Function: remove_complex + +Inputs: + +Outputs: + +Purpose: removes complex data type + +\*******************************************************************/ + void remove_complex(goto_modelt &goto_model) { remove_complex(goto_model.symbol_table, goto_model.goto_functions); diff --git a/src/goto-programs/remove_complex.h b/src/goto-programs/remove_complex.h index 098470ecc1a..c42784318cf 100644 --- a/src/goto-programs/remove_complex.h +++ b/src/goto-programs/remove_complex.h @@ -8,9 +8,6 @@ Date: September 2014 \*******************************************************************/ -/// \file -/// Remove the 'complex' data type by compilation into structs - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_COMPLEX_H #define CPROVER_GOTO_PROGRAMS_REMOVE_COMPLEX_H diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp index 3e9824cad30..c0a7d8d5380 100644 --- a/src/goto-programs/remove_const_function_pointers.cpp +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -6,9 +6,6 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ -/// \file -/// Goto Programs - #include #include #include @@ -19,12 +16,23 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com debug() << "Case " << __LINE__ << " : " << message << "\n" \ << irep.pretty() << eom; -/// To take a function call on a function pointer, and if possible resolve it to -/// a small collection of possible values. -/// \param message_handler: The message handler for messaget -/// \param base_expression: The function call through a function pointer -/// \param ns: The namespace to use to resolve types -/// \param symbol_table: The symbol table to look up symbols in +/*******************************************************************\ + +Function: remove_const_function_pointerst::remove_const_function_pointerst + + Inputs: + message_handler - The message handler for messaget + base_expression - The function call through a function pointer + ns - The namespace to use to resolve types + symbol_table - The symbol table to look up symbols in + + Outputs: + + Purpose: To take a function call on a function pointer, and if possible + resolve it to a small collection of possible values. + +\*******************************************************************/ + remove_const_function_pointerst::remove_const_function_pointerst( message_handlert &message_handler, const exprt &base_expression, @@ -36,16 +44,28 @@ remove_const_function_pointerst::remove_const_function_pointerst( symbol_table(symbol_table) {} -/// To take a function call on a function pointer, and if possible resolve it to -/// a small collection of possible values. It will resolve function pointers -/// that are const and: - assigned directly to a function - assigned to a value -/// in an array of functions - assigned to a const struct component Or -/// variations within. -/// \param out_functions: The functions that (symbols of type ID_code) the base -/// expression could take. -/// \return Returns true if it was able to resolve the call, false if not. If it -/// returns true, out_functions will be populated by all the possible values -/// the function pointer could be. +/*******************************************************************\ + +Function: remove_const_function_pointerst::operator() + + Inputs: + out_functions - The functions that (symbols of type ID_code) the base + expression could take. + + Outputs: Returns true if it was able to resolve the call, false if not. + If it returns true, out_functions will be populated by all the + possible values the function pointer could be. + + Purpose: To take a function call on a function pointer, and if possible + resolve it to a small collection of possible values. It will + resolve function pointers that are const and: + - assigned directly to a function + - assigned to a value in an array of functions + - assigned to a const struct component + Or variations within. + +\*******************************************************************/ + bool remove_const_function_pointerst::operator()( functionst &out_functions) { @@ -54,13 +74,23 @@ bool remove_const_function_pointerst::operator()( return try_resolve_function_call(non_symbol_expression, out_functions); } -/// To collapse the symbols down to their values where possible This takes a -/// very general approach, recreating the expr tree exactly as it was and -/// ignoring what type of expressions are found and instead recurses over all -/// the operands. -/// \param expression: The expression to resolve symbols in -/// \return Returns a modified version of the expression, with all const symbols -/// resolved to their actual values. +/*******************************************************************\ + +Function: remove_const_function_pointerst::replace_const_symbols + + Inputs: + expression - The expression to resolve symbols in + + Outputs: Returns a modified version of the expression, with all + const symbols resolved to their actual values. + + Purpose: To collapse the symbols down to their values where possible + This takes a very general approach, recreating the expr tree + exactly as it was and ignoring what type of expressions are found + and instead recurses over all the operands. + +\*******************************************************************/ + exprt remove_const_function_pointerst::replace_const_symbols( const exprt &expression) const { @@ -99,9 +129,19 @@ exprt remove_const_function_pointerst::replace_const_symbols( } } -/// Look up a symbol in the symbol table and return its value -/// \param symbol_expr: The symbol expression -/// \return The expression value of the symbol. +/*******************************************************************\ + +Function: remove_const_function_pointerst::resolve_symbol + + Inputs: + symbol_expr - The symbol expression + + Outputs: The expression value of the symbol. + + Purpose: Look up a symbol in the symbol table and return its value + +\*******************************************************************/ + exprt remove_const_function_pointerst::resolve_symbol( const symbol_exprt &symbol_expr) const { @@ -110,14 +150,25 @@ exprt remove_const_function_pointerst::resolve_symbol( return symbol.value; } -/// To resolve an expression to the specific function calls it can be. This is -/// different to try_resolve_expression which isn't explicitly looking for -/// functions and is instead just trying to squash particular exprt structures. -/// \param expr: The expression to get the possible function calls -/// \param out_functions: The functions this expression could be resolved to -/// \return Returns true if it was able to resolve the expression to some -/// specific functions. If this is the case, out_functions will contain the -/// possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_function_call + + Inputs: + expr - The expression to get the possible function calls + out_functions - The functions this expression could be resolved to + + Outputs: Returns true if it was able to resolve the expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. This is different to try_resolve_expression which isn't + explicitly looking for functions and is instead just trying + to squash particular exprt structures. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_function_call( const exprt &expr, functionst &out_functions) { @@ -182,12 +233,23 @@ bool remove_const_function_pointerst::try_resolve_function_call( } } -/// To resolve a collection of expressions to the specific function calls they -/// can be. Returns a collection if and only if all of them can be resolved. -/// \param exprs: The expressions to evaluate -/// \param out_functions: The functions these expressions resolve to -/// \return Returns true if able to resolve each of the expressions down to one -/// or more functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_function_calls + + Inputs: + exprs - The expressions to evaluate + out_functions - The functions these expressions resolve to + + Outputs: Returns true if able to resolve each of the expressions down + to one or more functions. + + Purpose: To resolve a collection of expressions to the specific function + calls they can be. Returns a collection if and only if all of + them can be resolved. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_function_calls( const expressionst &exprs, functionst &out_functions) { @@ -212,17 +274,27 @@ bool remove_const_function_pointerst::try_resolve_function_calls( return true; } -/// To resolve an expression to the specific function calls it can be. -/// Specifically, this function deals with index expressions where it squashes -/// its array and squash its index If we can get a precise number for the index, -/// we try_resolve_function_call on its value otherwise -/// try_resolve_function_call on each and return the union of them all -/// \param index_expr: The index expression to resolve to possible function -/// calls -/// \param out_functions: The functions this expression could be -/// \return Returns true if it was able to resolve the index expression to some -/// specific functions. If this is the case, out_functions will contain the -/// possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_of_function_call + + Inputs: + index_expr - The index expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the index expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with index expressions + where it squashes its array and squash its index + If we can get a precise number for the index, we + try_resolve_function_call on its value otherwise + try_resolve_function_call on each and return the union of them all + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_index_of_function_call( const index_exprt &index_expr, functionst &out_functions) { @@ -246,15 +318,24 @@ bool remove_const_function_pointerst::try_resolve_index_of_function_call( return try_resolve_function_calls(potential_array_values, out_functions); } -/// To resolve an expression to the specific function calls it can be. -/// Specifically, this function deals with member expressions by using -/// try_resolve_member and then recursing on its value. -/// \param member_expr: The member expression to resolve to possible function -/// calls -/// \param out_functions: The functions this expression could be -/// \return Returns true if it was able to resolve the member expression to some -/// specific functions. If this is the case, out_functions will contain the -/// possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_member_function_call + + Inputs: + member_expr - The member expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the member expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with member expressions + by using try_resolve_member and then recursing on its value. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_member_function_call( const member_exprt &member_expr, functionst &out_functions) { @@ -278,14 +359,24 @@ bool remove_const_function_pointerst::try_resolve_member_function_call( return try_resolve_function_calls(potential_component_values, out_functions); } -/// To resolve an expression to the specific function calls it can be. -/// Specifically, this function deals with address_of expressions. -/// \param address_expr: The address_of expression to resolve to possible -/// function calls -/// \param out_functions: The functions this expression could be -/// \return Returns true if it was able to resolve the address_of expression to -/// some specific functions. If this is the case, out_functions will contain -/// the possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_address_of_function_call + + Inputs: + address_expr - The address_of expression to resolve to possible function + calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the address_of expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with address_of expressions. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_address_of_function_call( const address_of_exprt &address_expr, functionst &out_functions) { @@ -298,15 +389,24 @@ bool remove_const_function_pointerst::try_resolve_address_of_function_call( return resolved; } -/// To resolve an expression to the specific function calls it can be. -/// Specifically, this function deals with dereference expressions by using -/// try_resolve_dereferebce and then recursing on its value. -/// \param deref_expr: The dereference expression to resolve to possible -/// function calls -/// \param out_functions: The functions this expression could be -/// \return Returns true if it was able to resolve the dereference expression to -/// some specific functions. If this is the case, out_functions will contain -/// the possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference_function_call + + Inputs: + deref_expr - The dereference expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the dereference expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with dereference expressions + by using try_resolve_dereferebce and then recursing on its value. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_dereference_function_call( const dereference_exprt &deref_expr, functionst &out_functions) { @@ -330,15 +430,24 @@ bool remove_const_function_pointerst::try_resolve_dereference_function_call( return try_resolve_function_calls(potential_deref_values, out_functions); } -/// To resolve an expression to the specific function calls it can be. -/// Specifically, this function deals with typecast expressions by looking at -/// the type cast values. -/// \param typecast_expr: The typecast expression to resolve to possible -/// function calls -/// \param out_functions: The functions this expression could be -/// \return Returns true if it was able to resolve the typecast expression to -/// some specific functions. If this is the case, out_functions will contain -/// the possible functions. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_typecast_function_call + + Inputs: + typecast_expr - The typecast expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the typecast expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with typecast expressions + by looking at the type cast values. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_typecast_function_call( const typecast_exprt &typecast_expr, functionst &out_functions) { @@ -362,20 +471,33 @@ bool remove_const_function_pointerst::try_resolve_typecast_function_call( } } -/// To squash various expr types to simplify the expression. ID_index -> dig to -/// find ID_array and get the values out of it ID_member -> dig to find -/// ID_struct and extract the component value ID_dereference -> dig to find -/// ID_address_of and extract the value ID_typecast -> return the value -/// ID_symbol -> return false, const symbols are squashed first and non const -/// symbols cannot be squashed Everything else -> unchanged -/// \param expr: The expression to try and squash -/// \param out_resolved_expression: The squashed version of this expression -/// \param out_is_const: Is the squashed expression constant -/// \return Returns true providing the squashing went OK (note it may not have -/// squashed anything). The out_resolved_expression will in this case be all -/// the possible squashed versions of the supplied expression. The -/// out_is_const will return whether the squashed value is suitably const -/// (e.g. if we squashed a struct access, was the struct const). +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_expression + + Inputs: + expr - The expression to try and squash + out_resolved_expression - The squashed version of this expression + out_is_const - Is the squashed expression constant + + Outputs: Returns true providing the squashing went OK (note it + may not have squashed anything). The out_resolved_expression will in + this case be all the possible squashed versions of the supplied + expression. + The out_is_const will return whether the squashed value is suitably + const (e.g. if we squashed a struct access, was the struct const). + + Purpose: To squash various expr types to simplify the expression. + ID_index -> dig to find ID_array and get the values out of it + ID_member -> dig to find ID_struct and extract the component value + ID_dereference -> dig to find ID_address_of and extract the value + ID_typecast -> return the value + ID_symbol -> return false, const symbols are squashed first and + non const symbols cannot be squashed + Everything else -> unchanged + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_expression( const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) { @@ -437,14 +559,25 @@ bool remove_const_function_pointerst::try_resolve_expression( } } -/// Given an index into an array, resolve, if possible, the index that is being -/// accessed. This deals with symbols and typecasts to constant values. -/// \param expr: The expression of the index of the index expression (e.g. -/// index_exprt::index()) -/// \param out_array_index: The constant value the index takes -/// \return Returns true if was able to find a constant value for the index -/// expression. If true, then out_array_index will be the index within the -/// array that the function pointer is pointing to. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_value + + Inputs: + expr - The expression of the index of the index expression (e.g. + index_exprt::index()) + out_array_index - The constant value the index takes + + Outputs: Returns true if was able to find a constant value for the index + expression. If true, then out_array_index will be the index within + the array that the function pointer is pointing to. + + Purpose: Given an index into an array, resolve, if possible, the index + that is being accessed. This deals with symbols and typecasts to + constant values. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_index_value( const exprt &expr, mp_integer &out_array_index) { @@ -477,16 +610,28 @@ bool remove_const_function_pointerst::try_resolve_index_value( } } -/// To squash an index access by first finding the array it is accessing Then if -/// the index can be resolved, return the squashed value. If the index can't be -/// determined then squash each value in the array and return them all. -/// \param index_expr: The index expression to to resolve -/// \param out_expressions: The expressions this expression could be -/// \param out_is_const: Is the squashed expression constant -/// \return Returns true if it was able to squash the index expression If this -/// is the case, out_expressions will contain the possible values this -/// index_of could return The out_is_const will return whether either the -/// array itself is const, or the values of the array are const. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_of + + Inputs: + index_expr - The index expression to to resolve + out_expressions - The expressions this expression could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the index expression + If this is the case, out_expressions will contain + the possible values this index_of could return + The out_is_const will return whether either the array itself + is const, or the values of the array are const. + + Purpose: To squash an index access by first finding the array it is accessing + Then if the index can be resolved, return the squashed value. If + the index can't be determined then squash each value in the array + and return them all. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_index_of( const index_exprt &index_expr, expressionst &out_expressions, @@ -583,14 +728,26 @@ bool remove_const_function_pointerst::try_resolve_index_of( } } -/// To squash an member access by first finding the struct it is accessing Then -/// return the squashed value of the relevant component. -/// \param member_expr: The member expression to resolve. -/// \param out_expressions: The expressions this component could be -/// \param out_is_const: Is the squashed expression constant -/// \return Returns true if it was able to squash the member expression If this -/// is the case, out_expressions will contain the possible values this member -/// could return The out_is_const will return whether the struct is const. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_member + + Inputs: + member_expr - The member expression to resolve. + out_expressions - The expressions this component could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the member expression + If this is the case, out_expressions will contain + the possible values this member could return + The out_is_const will return whether the struct + is const. + + Purpose: To squash an member access by first finding the struct it is accessing + Then return the squashed value of the relevant component. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_member( const member_exprt &member_expr, expressionst &out_expressions, @@ -648,16 +805,27 @@ bool remove_const_function_pointerst::try_resolve_member( } } -/// To squash a dereference access by first finding the address_of the -/// dereference is dereferencing. Then return the squashed value of the relevant -/// component. -/// \param deref_expr: The dereference expression to resolve. -/// \param out_expressions: The expressions this dereference could be -/// \param out_is_const: Is the squashed expression constant -/// \return Returns true if it was able to squash the dereference expression If -/// this is the case, out_expressions will contain the possible values this -/// dereference could return The out_is_const will return whether the object -/// that gets dereferenced is constant. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference + + Inputs: + deref_expr - The dereference expression to resolve. + out_expressions - The expressions this dereference could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the dereference expression + If this is the case, out_expressions will contain + the possible values this dereference could return + The out_is_const will return whether the object that gets + dereferenced is constant. + + Purpose: To squash a dereference access by first finding the address_of + the dereference is dereferencing. + Then return the squashed value of the relevant component. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_dereference( const dereference_exprt &deref_expr, expressionst &out_expressions, @@ -722,13 +890,23 @@ bool remove_const_function_pointerst::try_resolve_dereference( } } -/// To squash a typecast access. -/// \param typecast_expr: The typecast expression to resolve. -/// \param out_expressions: The expressions this typecast could be -/// \param out_is_const: Is the squashed expression constant -/// \return Returns true if it was able to squash the typecast expression If -/// this is the case, out_expressions will contain the possible values after -/// removing the typecast. +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference + + Inputs: + typecast_expr - The typecast expression to resolve. + out_expressions - The expressions this typecast could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the typecast expression + If this is the case, out_expressions will contain + the possible values after removing the typecast. + + Purpose: To squash a typecast access. + +\*******************************************************************/ + bool remove_const_function_pointerst::try_resolve_typecast( const typecast_exprt &typecast_expr, expressionst &out_expressions, @@ -756,19 +934,39 @@ bool remove_const_function_pointerst::try_resolve_typecast( } } -/// To evaluate the const-ness of the expression type. -/// \param expression: The expression to check -/// \return Returns true if the type of the expression is constant. +/*******************************************************************\ + +Function: remove_const_function_pointerst::is_expression_const + + Inputs: + expression - The expression to check + + Outputs: Returns true if the type of the expression is constant. + + Purpose: To evaluate the const-ness of the expression type. + +\*******************************************************************/ + bool remove_const_function_pointerst::is_const_expression( const exprt &expression) const { return is_const_type(expression.type()); } -/// To evaluate the const-ness of the type. -/// \param type: The type to check -/// \return Returns true if the type has ID_C_constant or is an array since -/// arrays are implicitly const in C. +/*******************************************************************\ + +Function: remove_const_function_pointerst::is_type_const + + Inputs: + type - The type to check + + Outputs: Returns true if the type has ID_C_constant or is an array + since arrays are implicitly const in C. + + Purpose: To evaluate the const-ness of the type. + +\*******************************************************************/ + bool remove_const_function_pointerst::is_const_type(const typet &type) const { c_qualifierst qualifers(type); @@ -783,11 +981,21 @@ bool remove_const_function_pointerst::is_const_type(const typet &type) const } } -/// To extract the value of the specific component within a struct -/// \param struct_expr: The expression of the structure being accessed -/// \param member_expr: The expression saying which component is being accessed -/// \return Returns the value of a specific component for a given struct -/// expression. +/*******************************************************************\ + +Function: remove_const_function_pointerst::get_component_value + + Inputs: + struct_expr - The expression of the structure being accessed + member_expr - The expression saying which component is being accessed + + Outputs: Returns the value of a specific component for a given struct + expression. + + Purpose: To extract the value of the specific component within a struct + +\*******************************************************************/ + exprt remove_const_function_pointerst::get_component_value( const struct_exprt &struct_expr, const member_exprt &member_expr) { diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h index 45ed1c16fba..6516fb6ec64 100644 --- a/src/goto-programs/remove_const_function_pointers.h +++ b/src/goto-programs/remove_const_function_pointers.h @@ -6,9 +6,6 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ -/// \file -/// Goto Programs - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_exceptions.cpp b/src/goto-programs/remove_exceptions.cpp index 7793927fee8..ee7e467d3ff 100644 --- a/src/goto-programs/remove_exceptions.cpp +++ b/src/goto-programs/remove_exceptions.cpp @@ -8,9 +8,6 @@ Date: December 2016 \*******************************************************************/ -/// \file -/// Remove exception handling - #ifdef DEBUG #include #endif @@ -69,8 +66,19 @@ class remove_exceptionst const goto_functionst::function_mapt::iterator &); }; -/// adds exceptional return variables for every function that may escape -/// exceptions +/*******************************************************************\ + +Function: remove_exceptionst::add_exceptional_returns + +Inputs: + +Outputs: + +Purpose: adds exceptional return variables for every function that + may escape exceptions + +\*******************************************************************/ + void remove_exceptionst::add_exceptional_returns( const goto_functionst::function_mapt::iterator &func_it) { @@ -171,8 +179,19 @@ void remove_exceptionst::add_exceptional_returns( } } -/// at the beginning of each handler in function f adds exc=f#exception_value; -/// f#exception_value=NULL; +/*******************************************************************\ + +Function: remove_exceptionst::instrument_exception_handler + +Inputs: + +Outputs: + +Purpose: at the beginning of each handler in function f + adds exc=f#exception_value; f#exception_value=NULL; + +\*******************************************************************/ + void remove_exceptionst::instrument_exception_handler( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it) @@ -216,8 +235,19 @@ void remove_exceptionst::instrument_exception_handler( instr_it->make_skip(); } -/// finds the instruction where the exceptional output is set or the end of the -/// function if no such output exists +/*******************************************************************\ + +Function: get_exceptional_output + +Inputs: + +Outputs: + +Purpose: finds the instruction where the exceptional output is set + or the end of the function if no such output exists + +\*******************************************************************/ + static goto_programt::targett get_exceptional_output( goto_programt &goto_program) { @@ -238,8 +268,19 @@ static goto_programt::targett get_exceptional_output( return goto_program.get_end_function(); } -/// instruments each throw with conditional GOTOS to the corresponding -/// exception handlers +/*******************************************************************\ + +Function: remove_exceptionst::instrument_throw + +Inputs: + +Outputs: + +Purpose: instruments each throw with conditional GOTOS to the + corresponding exception handlers + +\*******************************************************************/ + void remove_exceptionst::instrument_throw( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it, @@ -326,8 +367,19 @@ void remove_exceptionst::instrument_throw( instr_it->code=assignment; } -/// instruments each function call that may escape exceptions with conditional -/// GOTOS to the corresponding exception handlers +/*******************************************************************\ + +Function: remove_exceptionst::instrument_function_call + +Inputs: + +Outputs: + +Purpose: instruments each function call that may escape exceptions + with conditional GOTOS to the corresponding exception handlers + +\*******************************************************************/ + void remove_exceptionst::instrument_function_call( const goto_functionst::function_mapt::iterator &func_it, const goto_programt::instructionst::iterator &instr_it, @@ -424,9 +476,20 @@ void remove_exceptionst::instrument_function_call( } } -/// instruments throws, function calls that may escape exceptions and exception -/// handlers. Additionally, it re-computes the live-range of local variables in -/// order to add DEAD instructions. +/*******************************************************************\ + +Function: remove_exceptionst::instrument_exceptions + +Inputs: + +Outputs: + +Purpose: instruments throws, function calls that may escape exceptions + and exception handlers. Additionally, it re-computes + the live-range of local variables in order to add DEAD instructions. + +\*******************************************************************/ + void remove_exceptionst::instrument_exceptions( const goto_functionst::function_mapt::iterator &func_it) { @@ -509,6 +572,18 @@ void remove_exceptionst::instrument_exceptions( } } +/*******************************************************************\ + +Function: remove_exceptionst::operator() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void remove_exceptionst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) @@ -517,7 +592,18 @@ void remove_exceptionst::operator()(goto_functionst &goto_functions) instrument_exceptions(it); } -/// removes throws/CATCH-POP/CATCH-PUSH +/*******************************************************************\ + +Function: remove_exceptions + +Inputs: + +Outputs: + +Purpose: removes throws/CATCH-POP/CATCH-PUSH + +\*******************************************************************/ + void remove_exceptions( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -529,7 +615,18 @@ void remove_exceptions( remove_exceptions(goto_functions); } -/// removes throws/CATCH-POP/CATCH-PUSH +/*******************************************************************\ + +Function: remove_exceptions + +Inputs: + +Outputs: + +Purpose: removes throws/CATCH-POP/CATCH-PUSH + +\*******************************************************************/ + void remove_exceptions(goto_modelt &goto_model) { std::map> exceptions_map; diff --git a/src/goto-programs/remove_exceptions.h b/src/goto-programs/remove_exceptions.h index 47cf349cf13..89162b5833d 100644 --- a/src/goto-programs/remove_exceptions.h +++ b/src/goto-programs/remove_exceptions.h @@ -8,9 +8,6 @@ Date: December 2016 \*******************************************************************/ -/// \file -/// Remove function exceptional returns - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_EXCEPTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_EXCEPTIONS_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 183574c8ce3..2d5be9c0ab2 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include @@ -29,6 +26,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "compute_called_functions.h" #include "remove_const_function_pointers.h" +/*******************************************************************\ + + Class: remove_function_pointerst + + Purpose: + +\*******************************************************************/ + class remove_function_pointerst:public messaget { public: @@ -89,6 +94,18 @@ class remove_function_pointerst:public messaget } }; +/*******************************************************************\ + +Function: remove_function_pointerst::remove_function_pointerst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + remove_function_pointerst::remove_function_pointerst( message_handlert &_message_handler, symbol_tablet &_symbol_table, @@ -108,6 +125,18 @@ remove_function_pointerst::remove_function_pointerst( type_map[f_it->first]=f_it->second.type; } +/*******************************************************************\ + +Function: remove_function_pointerst::arg_is_type_compatible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool remove_function_pointerst::arg_is_type_compatible( const typet &call_type, const typet &function_type) @@ -140,6 +169,18 @@ bool remove_function_pointerst::arg_is_type_compatible( return false; } +/*******************************************************************\ + +Function: remove_function_pointerst::is_type_compatible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool remove_function_pointerst::is_type_compatible( bool return_value_used, const code_typet &call_type, @@ -190,6 +231,18 @@ bool remove_function_pointerst::is_type_compatible( return true; } +/*******************************************************************\ + +Function: remove_function_pointerst::fix_argument_types + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointerst::fix_argument_types( code_function_callt &function_call) { @@ -215,6 +268,18 @@ void remove_function_pointerst::fix_argument_types( } } +/*******************************************************************\ + +Function: remove_function_pointerst::fix_return_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointerst::fix_return_type( code_function_callt &function_call, goto_programt &dest) @@ -254,6 +319,18 @@ void remove_function_pointerst::fix_return_type( old_lhs, typecast_exprt(tmp_symbol_expr, old_lhs.type())); } +/*******************************************************************\ + +Function: remove_function_pointerst::remove_function_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointerst::remove_function_pointer( goto_programt &goto_program, goto_programt::targett target) @@ -433,6 +510,18 @@ void remove_function_pointerst::remove_function_pointer( << functions.size() << " possible targets" << eom; } +/*******************************************************************\ + +Function: remove_function_pointerst::remove_function_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool remove_function_pointerst::remove_function_pointers( goto_programt &goto_program) { @@ -460,6 +549,18 @@ bool remove_function_pointerst::remove_function_pointers( return did_something; } +/*******************************************************************\ + +Function: remove_function_pointerst::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointerst::operator()(goto_functionst &functions) { bool did_something=false; @@ -479,6 +580,18 @@ void remove_function_pointerst::operator()(goto_functionst &functions) functions.compute_location_numbers(); } +/*******************************************************************\ + +Function: remove_function_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool remove_function_pointers(message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, @@ -497,6 +610,18 @@ bool remove_function_pointers(message_handlert &_message_handler, return rfp.remove_function_pointers(goto_program); } +/*******************************************************************\ + +Function: remove_function_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointers( message_handlert &_message_handler, symbol_tablet &symbol_table, @@ -515,6 +640,18 @@ void remove_function_pointers( rfp(goto_functions); } +/*******************************************************************\ + +Function: remove_function_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_function_pointers(message_handlert &_message_handler, goto_modelt &goto_model, bool add_safety_assertion, diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index 3038a940637..e8eea37ea75 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -8,9 +8,6 @@ Date: June 2003 \*******************************************************************/ -/// \file -/// Remove Indirect Function Calls - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_instanceof.cpp b/src/goto-programs/remove_instanceof.cpp index 8a033668f6a..8e6c9f5de20 100644 --- a/src/goto-programs/remove_instanceof.cpp +++ b/src/goto-programs/remove_instanceof.cpp @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Remove Instance-of Operators - #include "class_hierarchy.h" #include "class_identifier.h" #include "remove_instanceof.h" @@ -57,10 +54,19 @@ class remove_instanceoft bool contains_instanceof(const exprt &); }; -/// Avoid breaking sharing by checking for instanceof before calling -/// lower_instanceof. -/// \par parameters: Expression `expr` -/// \return Returns true if `expr` contains any instanceof ops +/*******************************************************************\ + +Function: remove_instanceoft::contains_instanceof + + Inputs: Expression `expr` + + Outputs: Returns true if `expr` contains any instanceof ops + + Purpose: Avoid breaking sharing by checking for instanceof + before calling lower_instanceof. + +\*******************************************************************/ + bool remove_instanceoft::contains_instanceof( const exprt &expr) { @@ -72,12 +78,24 @@ bool remove_instanceoft::contains_instanceof( return false; } -/// Replaces an expression like e instanceof A with e.@class_identifier == "A" -/// Or a big-or of similar expressions if we know of subtypes that also satisfy -/// the given test. -/// \par parameters: Expression to lower `expr` and the `goto_program` and -/// instruction `this_inst` it belongs to. -/// \return Side-effect on `expr` replacing it with an explicit clsid test +/*******************************************************************\ + +Function: remove_instanceoft::lower_instanceof + + Inputs: Expression to lower `expr` and the `goto_program` and + instruction `this_inst` it belongs to. + + Outputs: Side-effect on `expr` replacing it with an explicit clsid test + + Purpose: Replaces an expression like + e instanceof A + with + e.@class_identifier == "A" + Or a big-or of similar expressions if we know of subtypes + that also satisfy the given test. + +\*******************************************************************/ + void remove_instanceoft::lower_instanceof( exprt &expr, goto_programt &goto_program, @@ -146,12 +164,20 @@ void remove_instanceoft::lower_instanceof( } } -/// See function above -/// \par parameters: GOTO program instruction `target` whose instanceof -/// expressions, -/// if any, should be replaced with explicit tests, and the -/// `goto_program` it is part of. -/// \return Side-effect on `target` as above. +/*******************************************************************\ + +Function: remove_instanceoft::lower_instanceof + + Inputs: GOTO program instruction `target` whose instanceof expressions, + if any, should be replaced with explicit tests, and the + `goto_program` it is part of. + + Outputs: Side-effect on `target` as above. + + Purpose: See function above + +\*******************************************************************/ + void remove_instanceoft::lower_instanceof( goto_programt &goto_program, goto_programt::targett target, @@ -172,10 +198,18 @@ void remove_instanceoft::lower_instanceof( lower_instanceof(target->guard, goto_program, target, inst_switch); } -/// See function above -/// \par parameters: `goto_program`, all of whose instanceof expressions will -/// be replaced by explicit class-identifier tests. -/// \return Side-effect on `goto_program` as above. +/*******************************************************************\ + +Function: remove_instanceoft::lower_instanceof + + Inputs: `goto_program`, all of whose instanceof expressions will + be replaced by explicit class-identifier tests. + + Outputs: Side-effect on `goto_program` as above. + + Purpose: See function above + +\*******************************************************************/ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program) { instanceof_instt inst_switch; @@ -196,9 +230,19 @@ bool remove_instanceoft::lower_instanceof(goto_programt &goto_program) return false; } -/// See function above -/// \return Side-effects on this->goto_functions, replacing every instanceof in -/// every function with an explicit test. +/*******************************************************************\ + +Function: remove_instanceoft::lower_instanceof + + Inputs: None + + Outputs: Side-effects on this->goto_functions, replacing every + instanceof in every function with an explicit test. + + Purpose: See function above + +\*******************************************************************/ + void remove_instanceoft::lower_instanceof() { bool changed=false; @@ -208,12 +252,22 @@ void remove_instanceoft::lower_instanceof() goto_functions.compute_location_numbers(); } -/// See function above -/// \par parameters: `goto_functions`, a function map, and the corresponding -/// `symbol_table`. -/// \return Side-effects on goto_functions, replacing every instanceof in every -/// function with an explicit test. Extra auxiliary variables may be -/// introduced into `symbol_table`. +/*******************************************************************\ + +Function: remove_instanceof + + Inputs: `goto_functions`, a function map, and the corresponding + `symbol_table`. + + Outputs: Side-effects on goto_functions, replacing every + instanceof in every function with an explicit test. + Extra auxiliary variables may be introduced into + `symbol_table`. + + Purpose: See function above + +\*******************************************************************/ + void remove_instanceof( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-programs/remove_instanceof.h b/src/goto-programs/remove_instanceof.h index 15a02bf35b2..7b4682ba9bf 100644 --- a/src/goto-programs/remove_instanceof.h +++ b/src/goto-programs/remove_instanceof.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Remove Instance-of Operators - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_INSTANCEOF_H #define CPROVER_GOTO_PROGRAMS_REMOVE_INSTANCEOF_H diff --git a/src/goto-programs/remove_returns.cpp b/src/goto-programs/remove_returns.cpp index fd8f49df4bc..9ca6554275c 100644 --- a/src/goto-programs/remove_returns.cpp +++ b/src/goto-programs/remove_returns.cpp @@ -8,9 +8,6 @@ Date: September 2009 \*******************************************************************/ -/// \file -/// Remove function return values - #include #include @@ -48,7 +45,18 @@ class remove_returnst goto_programt &goto_program); }; -/// turns 'return x' into an assignment to fkt#return_value +/*******************************************************************\ + +Function: remove_returnst::replace_returns + +Inputs: + +Outputs: + +Purpose: turns 'return x' into an assignment to fkt#return_value + +\*******************************************************************/ + void remove_returnst::replace_returns( goto_functionst::function_mapt::iterator f_it) { @@ -113,7 +121,18 @@ void remove_returnst::replace_returns( } } -/// turns x=f(...) into f(...); lhs=f#return_value; +/*******************************************************************\ + +Function: remove_returnst::do_function_calls + +Inputs: + +Outputs: + +Purpose: turns x=f(...) into f(...); lhs=f#return_value; + +\*******************************************************************/ + void remove_returnst::do_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -189,6 +208,18 @@ void remove_returnst::do_function_calls( } } +/*******************************************************************\ + +Function: remove_returnst::operator() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void remove_returnst::operator()(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) @@ -198,7 +229,18 @@ void remove_returnst::operator()(goto_functionst &goto_functions) } } -/// removes returns +/*******************************************************************\ + +Function: remove_returns + +Inputs: + +Outputs: + +Purpose: removes returns + +\*******************************************************************/ + void remove_returns( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -207,13 +249,36 @@ void remove_returns( rr(goto_functions); } -/// removes returns +/*******************************************************************\ + +Function: remove_returns + +Inputs: + +Outputs: + +Purpose: removes returns + +\*******************************************************************/ + void remove_returns(goto_modelt &goto_model) { remove_returnst rr(goto_model.symbol_table); rr(goto_model.goto_functions); } +/*******************************************************************\ + +Function: original_return_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + code_typet original_return_type( const symbol_tablet &symbol_table, const irep_idt &function_id) @@ -242,7 +307,18 @@ code_typet original_return_type( return type; } -/// turns 'return x' into an assignment to fkt#return_value +/*******************************************************************\ + +Function: remove_returnst::restore_returns + +Inputs: + +Outputs: + +Purpose: turns 'return x' into an assignment to fkt#return_value + +\*******************************************************************/ + bool remove_returnst::restore_returns( goto_functionst::function_mapt::iterator f_it) { @@ -315,7 +391,18 @@ bool remove_returnst::restore_returns( return false; } -/// turns f(...); lhs=f#return_value; into x=f(...) +/*******************************************************************\ + +Function: remove_returnst::undo_function_calls + +Inputs: + +Outputs: + +Purpose: turns f(...); lhs=f#return_value; into x=f(...) + +\*******************************************************************/ + void remove_returnst::undo_function_calls( goto_functionst &goto_functions, goto_programt &goto_program) @@ -374,6 +461,18 @@ void remove_returnst::undo_function_calls( } } +/*******************************************************************\ + +Function: remove_returnst::restore() + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void remove_returnst::restore(goto_functionst &goto_functions) { // restore all types first @@ -388,7 +487,18 @@ void remove_returnst::restore(goto_functionst &goto_functions) } } -/// restores return statements +/*******************************************************************\ + +Function: restore_returns + +Inputs: + +Outputs: + +Purpose: restores return statements + +\*******************************************************************/ + void restore_returns( symbol_tablet &symbol_table, goto_functionst &goto_functions) diff --git a/src/goto-programs/remove_returns.h b/src/goto-programs/remove_returns.h index d4e50cae57b..453d8a7be7f 100644 --- a/src/goto-programs/remove_returns.h +++ b/src/goto-programs/remove_returns.h @@ -8,9 +8,6 @@ Date: September 2009 \*******************************************************************/ -/// \file -/// Remove function returns - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H diff --git a/src/goto-programs/remove_skip.cpp b/src/goto-programs/remove_skip.cpp index 816960b1ea0..dedeb8aca2a 100644 --- a/src/goto-programs/remove_skip.cpp +++ b/src/goto-programs/remove_skip.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include "remove_skip.h" +/*******************************************************************\ + +Function: is_skip + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool is_skip(goto_programt::instructionst::iterator it) { // we won't remove labelled statements @@ -67,7 +76,18 @@ static bool is_skip(goto_programt::instructionst::iterator it) return false; } -/// remove unnecessary skip statements +/*******************************************************************\ + +Function: remove_skip + + Inputs: + + Outputs: + + Purpose: remove unnecessary skip statements + +\*******************************************************************/ + void remove_skip(goto_programt &goto_program) { // This needs to be a fixed-point, as @@ -154,7 +174,18 @@ void remove_skip(goto_programt &goto_program) while(goto_program.instructions.size() #include @@ -32,10 +29,19 @@ class remove_static_init_loopst const symbol_tablet &symbol_table; }; -/// unwind static initialization loops of Java enums as far as the enum has -/// elements, thus flattening them completely -/// \par parameters: goto_functions and options -/// \return side effect is adding loops to unwindset +/*******************************************************************\ + +Function: unwind_enum_static + + Inputs: goto_functions and options + + Outputs: side effect is adding loops to unwindset + + Purpose: unwind static initialization loops of Java enums as far as + the enum has elements, thus flattening them completely + +\*******************************************************************/ + void remove_static_init_loopst::unwind_enum_static( const goto_functionst &goto_functions, optionst &options) @@ -89,10 +95,19 @@ void remove_static_init_loopst::unwind_enum_static( } } -/// this is the entry point for the removal of loops in static initialization -/// code of Java enums -/// \par parameters: symbol table, goto_functions and options -/// \return side effect is adding loops to unwindset +/*******************************************************************\ + +Function: remove_static_init_loops + + Inputs: symbol table, goto_functions and options + + Outputs: side effect is adding loops to unwindset + + Purpose: this is the entry point for the removal of loops in static + initialization code of Java enums + +\*******************************************************************/ + void remove_static_init_loops( const symbol_tablet &symbol_table, const goto_functionst &goto_functions, diff --git a/src/goto-programs/remove_static_init_loops.h b/src/goto-programs/remove_static_init_loops.h index eee270215a2..dd07ec6a670 100644 --- a/src/goto-programs/remove_static_init_loops.h +++ b/src/goto-programs/remove_static_init_loops.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Unwind loops in static initializers - #include #include diff --git a/src/goto-programs/remove_unreachable.cpp b/src/goto-programs/remove_unreachable.cpp index 41ec75d39d0..14f92e97be1 100644 --- a/src/goto-programs/remove_unreachable.cpp +++ b/src/goto-programs/remove_unreachable.cpp @@ -6,15 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #include #include #include "remove_unreachable.h" -/// remove unreachable code +/*******************************************************************\ + +Function: remove_unreachable + + Inputs: + + Outputs: + + Purpose: remove unreachable code + +\*******************************************************************/ + void remove_unreachable(goto_programt &goto_program) { std::set reachable; diff --git a/src/goto-programs/remove_unreachable.h b/src/goto-programs/remove_unreachable.h index 7e04c4df98f..694cd8c0af8 100644 --- a/src/goto-programs/remove_unreachable.h +++ b/src/goto-programs/remove_unreachable.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Transformation - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H #define CPROVER_GOTO_PROGRAMS_REMOVE_UNREACHABLE_H diff --git a/src/goto-programs/remove_unused_functions.cpp b/src/goto-programs/remove_unused_functions.cpp index 986f615ba6b..860af2e1d73 100644 --- a/src/goto-programs/remove_unused_functions.cpp +++ b/src/goto-programs/remove_unused_functions.cpp @@ -6,13 +6,22 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Unused function removal - #include #include "remove_unused_functions.h" +/*******************************************************************\ + +Function: remove_unused_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_unused_functions( goto_functionst &functions, message_handlert &message_handler) @@ -45,6 +54,18 @@ void remove_unused_functions( functions.function_map.erase(f); } +/*******************************************************************\ + +Function: find_used_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_used_functions( const irep_idt &start, goto_functionst &functions, diff --git a/src/goto-programs/remove_unused_functions.h b/src/goto-programs/remove_unused_functions.h index 550d657f299..b571de4e059 100644 --- a/src/goto-programs/remove_unused_functions.h +++ b/src/goto-programs/remove_unused_functions.h @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Unused function removal - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_UNUSED_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_UNUSED_FUNCTIONS_H diff --git a/src/goto-programs/remove_vector.cpp b/src/goto-programs/remove_vector.cpp index 827bbb322dd..f7b63e42d4f 100644 --- a/src/goto-programs/remove_vector.cpp +++ b/src/goto-programs/remove_vector.cpp @@ -8,13 +8,22 @@ Date: September 2014 \*******************************************************************/ -/// \file -/// Remove 'vector' data type - #include #include "remove_vector.h" +/*******************************************************************\ + +Function: have_to_remove_vector + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static bool have_to_remove_vector(const typet &type); static bool have_to_remove_vector(const exprt &expr) @@ -42,6 +51,18 @@ static bool have_to_remove_vector(const exprt &expr) return false; } +/*******************************************************************\ + +Function: have_to_remove_vector + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static bool have_to_remove_vector(const typet &type) { if(type.id()==ID_struct || type.id()==ID_union) @@ -66,7 +87,18 @@ static bool have_to_remove_vector(const typet &type) return false; } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + static void remove_vector(typet &); static void remove_vector(exprt &expr) @@ -142,7 +174,18 @@ static void remove_vector(exprt &expr) remove_vector(expr.type()); } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + static void remove_vector(typet &type) { if(!have_to_remove_vector(type)) @@ -180,21 +223,54 @@ static void remove_vector(typet &type) } } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + static void remove_vector(symbolt &symbol) { remove_vector(symbol.value); remove_vector(symbol.type); } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + static void remove_vector(symbol_tablet &symbol_table) { Forall_symbols(it, symbol_table.symbols) remove_vector(it->second); } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + void remove_vector(goto_functionst::goto_functiont &goto_function) { remove_vector(goto_function.type); @@ -206,14 +282,36 @@ void remove_vector(goto_functionst::goto_functiont &goto_function) } } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + static void remove_vector(goto_functionst &goto_functions) { Forall_goto_functions(it, goto_functions) remove_vector(it->second); } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + void remove_vector( symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -222,7 +320,18 @@ void remove_vector( remove_vector(goto_functions); } -/// removes vector data type +/*******************************************************************\ + +Function: remove_vector + +Inputs: + +Outputs: + +Purpose: removes vector data type + +\*******************************************************************/ + void remove_vector(goto_modelt &goto_model) { remove_vector(goto_model.symbol_table, goto_model.goto_functions); diff --git a/src/goto-programs/remove_vector.h b/src/goto-programs/remove_vector.h index 960d75953a8..ffcb58421b4 100644 --- a/src/goto-programs/remove_vector.h +++ b/src/goto-programs/remove_vector.h @@ -8,9 +8,6 @@ Date: September 2014 \*******************************************************************/ -/// \file -/// Remove the 'vector' data type by compilation into arrays - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_VECTOR_H #define CPROVER_GOTO_PROGRAMS_REMOVE_VECTOR_H diff --git a/src/goto-programs/remove_virtual_functions.cpp b/src/goto-programs/remove_virtual_functions.cpp index e766b089274..fde2f5f8405 100644 --- a/src/goto-programs/remove_virtual_functions.cpp +++ b/src/goto-programs/remove_virtual_functions.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Remove Virtual Function (Method) Calls - #include #include @@ -16,6 +13,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "class_identifier.h" #include "remove_virtual_functions.h" +/*******************************************************************\ + + Class: remove_virtual_functionst + + Purpose: + +\*******************************************************************/ + class remove_virtual_functionst { public: @@ -62,6 +67,18 @@ class remove_virtual_functionst const irep_idt &component_name) const; }; +/*******************************************************************\ + +Function: remove_virtual_functionst::remove_virtual_functionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + remove_virtual_functionst::remove_virtual_functionst( const symbol_tablet &_symbol_table, const goto_functionst &goto_functions): @@ -71,6 +88,18 @@ remove_virtual_functionst::remove_virtual_functionst( class_hierarchy(symbol_table); } +/*******************************************************************\ + +Function: remove_virtual_functionst::remove_virtual_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_virtual_functionst::remove_virtual_function( goto_programt &goto_program, goto_programt::targett target) @@ -202,17 +231,28 @@ void remove_virtual_functionst::remove_virtual_function( target->make_skip(); } -/// Used by get_functions to track the most-derived parent that provides an -/// override of a given function. -/// \par parameters: `this_id`: class name -/// `last_method_defn`: the most-derived parent of `this_id` to define the -/// requested function -/// `component_name`: name of the function searched for -/// \return `functions` is assigned a list of {class name, function symbol} -/// pairs indicating that if `this` is of the given class, then the call will -/// target the given function. Thus if A <: B <: C and A and C provide -/// overrides of `f` (but B does not), get_child_functions_rec("C", C.f, "f") -/// -> [{"C", C.f}, {"B", C.f}, {"A", A.f}] +/*******************************************************************\ + +Function: remove_virtual_functionst::get_child_functions_rec + + Inputs: `this_id`: class name + `last_method_defn`: the most-derived parent of `this_id` + to define the requested function + `component_name`: name of the function searched for + + Outputs: `functions` is assigned a list of {class name, function symbol} + pairs indicating that if `this` is of the given class, then the + call will target the given function. Thus if A <: B <: C and A + and C provide overrides of `f` (but B does not), + get_child_functions_rec("C", C.f, "f") -> [{"C", C.f}, + {"B", C.f}, + {"A", A.f}] + + Purpose: Used by get_functions to track the most-derived parent that + provides an override of a given function. + +\*******************************************************************/ + void remove_virtual_functionst::get_child_functions_rec( const irep_idt &this_id, const symbol_exprt &last_method_defn, @@ -250,6 +290,18 @@ void remove_virtual_functionst::get_child_functions_rec( } } +/*******************************************************************\ + +Function: remove_virtual_functionst::get_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_virtual_functionst::get_functions( const exprt &function, functionst &functions) @@ -300,6 +352,18 @@ void remove_virtual_functionst::get_functions( functions.push_back(root_function); } +/*******************************************************************\ + +Function: remove_virtual_functionst::get_method + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt remove_virtual_functionst::get_method( const irep_idt &class_id, const irep_idt &component_name) const @@ -314,6 +378,18 @@ exprt remove_virtual_functionst::get_method( return symbol->symbol_expr(); } +/*******************************************************************\ + +Function: remove_virtual_functionst::remove_virtual_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool remove_virtual_functionst::remove_virtual_functions( goto_programt &goto_program) { @@ -340,6 +416,18 @@ bool remove_virtual_functionst::remove_virtual_functions( return did_something; } +/*******************************************************************\ + +Function: remove_virtual_functionst::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_virtual_functionst::operator()(goto_functionst &functions) { bool did_something=false; @@ -359,6 +447,18 @@ void remove_virtual_functionst::operator()(goto_functionst &functions) functions.compute_location_numbers(); } +/*******************************************************************\ + +Function: remove_virtual_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_virtual_functions( const symbol_tablet &symbol_table, goto_functionst &goto_functions) @@ -369,6 +469,18 @@ void remove_virtual_functions( rvf(goto_functions); } +/*******************************************************************\ + +Function: remove_virtual_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_virtual_functions(goto_modelt &goto_model) { remove_virtual_functions( diff --git a/src/goto-programs/remove_virtual_functions.h b/src/goto-programs/remove_virtual_functions.h index af83cf57e4d..0fec71a318f 100644 --- a/src/goto-programs/remove_virtual_functions.h +++ b/src/goto-programs/remove_virtual_functions.h @@ -8,9 +8,6 @@ Date: April 2016 \*******************************************************************/ -/// \file -/// Remove Virtual Function (Method) Calls - #ifndef CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_REMOVE_VIRTUAL_FUNCTIONS_H diff --git a/src/goto-programs/replace_java_nondet.cpp b/src/goto-programs/replace_java_nondet.cpp index 02a989d307a..b0514d60a7b 100644 --- a/src/goto-programs/replace_java_nondet.cpp +++ b/src/goto-programs/replace_java_nondet.cpp @@ -6,9 +6,6 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ -/// \file -/// Replace Java Nondet expressions - #include "goto-programs/replace_java_nondet.h" #include "goto-programs/goto_convert.h" #include "goto-programs/goto_model.h" @@ -19,8 +16,15 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com #include #include -/// Holds information about any discovered nondet methods, with extreme type- -/// safety. +/*******************************************************************\ + + Class: nondet_instruction_infot + + Purpose: Holds information about any discovered nondet methods, + with extreme type-safety. + +\*******************************************************************/ + class nondet_instruction_infot final { public: @@ -47,11 +51,22 @@ class nondet_instruction_infot final is_nullablet is_nullable; }; -/// Checks whether the function call is one of our nondet library functions. -/// \param function_call: The function call declaration to check. -/// \return A structure detailing whether the function call appears to be one of -/// our nondet library methods, and if so, whether or not it allows null -/// results. +/*******************************************************************\ + +Function: is_nondet_returning_object + + Inputs: + function_call: The function call declaration to check. + + Outputs: A structure detailing whether the function call appears to + be one of our nondet library methods, and if so, whether + or not it allows null results. + + Purpose: Checks whether the function call is one of our nondet + library functions. + +\*******************************************************************/ + static nondet_instruction_infot is_nondet_returning_object( const code_function_callt &function_call) { @@ -70,10 +85,21 @@ static nondet_instruction_infot is_nondet_returning_object( nondet_instruction_infot::is_nullablet(!match_results[1].matched)); } -/// Check whether the instruction is a function call which matches one of the -/// recognised nondet library methods, and return some information about it. -/// \param instr: A goto-program instruction to check. -/// \return A structure detailing the properties of the nondet method. +/*******************************************************************\ + +Function: get_nondet_instruction_info + + Inputs: + instr: A goto-program instruction to check. + + Outputs: A structure detailing the properties of the nondet method. + + Purpose: Check whether the instruction is a function call which + matches one of the recognised nondet library methods, and + return some information about it. + +\*******************************************************************/ + static nondet_instruction_infot get_nondet_instruction_info( const goto_programt::const_targett &instr) { @@ -90,21 +116,43 @@ static nondet_instruction_infot get_nondet_instruction_info( return is_nondet_returning_object(function_call); } -/// Return whether the expression is a symbol with the specified identifier. -/// \param expr: The expression which may be a symbol. -/// \param identifier: Some identifier. -/// \return True if the expression is a symbol with the specified identifier. +/*******************************************************************\ + +Function: is_symbol_with_id + + Inputs: + expr: The expression which may be a symbol. + identifier: Some identifier. + + Outputs: True if the expression is a symbol with the specified identifier. + + Purpose: Return whether the expression is a symbol with the specified + identifier. + +\*******************************************************************/ + static bool is_symbol_with_id(const exprt& expr, const irep_idt& identifier) { return expr.id()==ID_symbol && to_symbol_expr(expr).get_identifier()==identifier; } -/// Return whether the expression is a typecast with the specified identifier. -/// \param expr: The expression which may be a typecast. -/// \param identifier: Some identifier. -/// \return True if the expression is a typecast with one operand, and the -/// typecast's identifier matches the specified identifier. +/*******************************************************************\ + +Function: is_typecast_with_id + + Inputs: + expr: The expression which may be a typecast. + identifier: Some identifier. + + Outputs: True if the expression is a typecast with one operand, and the + typecast's identifier matches the specified identifier. + + Purpose: Return whether the expression is a typecast with the specified + identifier. + +\*******************************************************************/ + static bool is_typecast_with_id(const exprt& expr, const irep_idt& identifier) { if(!(expr.id()==ID_typecast && expr.operands().size()==1)) @@ -121,12 +169,22 @@ static bool is_typecast_with_id(const exprt& expr, const irep_idt& identifier) return op_symbol.get_identifier()==identifier; } -/// Return whether the instruction is an assignment, and the rhs is a symbol or -/// typecast expression with the specified identifier. -/// \param instr: A goto program instruction. -/// \param identifier: Some identifier. -/// \return True if the expression is a typecast with one operand, and the -/// typecast's identifier matches the specified identifier. +/*******************************************************************\ + +Function: is_assignment_from + + Inputs: + instr: A goto program instruction. + identifier: Some identifier. + + Outputs: True if the expression is a typecast with one operand, and the + typecast's identifier matches the specified identifier. + + Purpose: Return whether the instruction is an assignment, and the rhs is a + symbol or typecast expression with the specified identifier. + +\*******************************************************************/ + static bool is_assignment_from( const goto_programt::instructiont &instr, const irep_idt &identifier) @@ -141,13 +199,23 @@ static bool is_assignment_from( is_typecast_with_id(rhs, identifier); } -/// Given an iterator into a list of instructions, modify the list to replace -/// 'nondet' library functions with CBMC-native nondet expressions, and return -/// an iterator to the next instruction to check. -/// \param goto_program: The goto program to modify. -/// \param target: A single step of the goto program which may be erased and -/// replaced. -/// \return The next instruction to process, probably with this function. +/*******************************************************************\ + +Function: check_and_replace_target + + Inputs: + goto_program: The goto program to modify. + target: A single step of the goto program which may be erased and + replaced. + + Outputs: The next instruction to process, probably with this function. + + Purpose: Given an iterator into a list of instructions, modify the list to + replace 'nondet' library functions with CBMC-native nondet + expressions, and return an iterator to the next instruction to check. + +\*******************************************************************/ + static goto_programt::targett check_and_replace_target( goto_programt &goto_program, const goto_programt::targett &target) @@ -219,10 +287,20 @@ static goto_programt::targett check_and_replace_target( return after_matching_assignment; } -/// Checks each instruction in the goto program to see whether it is a method -/// returning nondet. If it is, replaces the function call with an irep -/// representing a nondet side effect with an appropriate type. -/// \param goto_program: The goto program to modify. +/*******************************************************************\ + +Function: replace_java_nondet + + Inputs: + goto_program: The goto program to modify. + + Purpose: Checks each instruction in the goto program to see whether + it is a method returning nondet. If it is, replaces the + function call with an irep representing a nondet side + effect with an appropriate type. + +\*******************************************************************/ + static void replace_java_nondet(goto_programt &goto_program) { for(auto instruction_iterator=goto_program.instructions.begin(), diff --git a/src/goto-programs/replace_java_nondet.h b/src/goto-programs/replace_java_nondet.h index cc924e9e974..077f95ab84c 100644 --- a/src/goto-programs/replace_java_nondet.h +++ b/src/goto-programs/replace_java_nondet.h @@ -6,17 +6,23 @@ Author: Reuben Thomas, reuben.thomas@diffblue.com \*******************************************************************/ -/// \file -/// Replace Java Nondet expressions - #ifndef CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H #define CPROVER_GOTO_PROGRAMS_REPLACE_JAVA_NONDET_H class goto_functionst; -/// Replace calls to nondet library functions with an internal nondet -/// representation. -/// \param goto_functions: The set of goto programs to modify. +/*******************************************************************\ + +Function: replace_java_nondet + + Inputs: + goto_functions: The set of goto programs to modify. + + Purpose: Replace calls to nondet library functions with an internal + nondet representation. + +\*******************************************************************/ + void replace_java_nondet(goto_functionst &goto_functions); #endif diff --git a/src/goto-programs/safety_checker.cpp b/src/goto-programs/safety_checker.cpp index b1236c08dc7..275cffbbe09 100644 --- a/src/goto-programs/safety_checker.cpp +++ b/src/goto-programs/safety_checker.cpp @@ -6,16 +6,37 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Safety Checker Interface - #include "safety_checker.h" +/*******************************************************************\ + +Function: safety_checkert::safety_checkert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::safety_checkert(const namespacet &_ns): ns(_ns) { } +/*******************************************************************\ + +Function: safety_checkert::safety_checkert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + safety_checkert::safety_checkert( const namespacet &_ns, message_handlert &_message_handler): diff --git a/src/goto-programs/safety_checker.h b/src/goto-programs/safety_checker.h index bb1492d6f53..e7f5e0b81ea 100644 --- a/src/goto-programs/safety_checker.h +++ b/src/goto-programs/safety_checker.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Safety Checker Interface - #ifndef CPROVER_GOTO_PROGRAMS_SAFETY_CHECKER_H #define CPROVER_GOTO_PROGRAMS_SAFETY_CHECKER_H diff --git a/src/goto-programs/set_properties.cpp b/src/goto-programs/set_properties.cpp index 303d8a9367d..fc79d4dcfe7 100644 --- a/src/goto-programs/set_properties.cpp +++ b/src/goto-programs/set_properties.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Set Properties - #include #include #include "set_properties.h" +/*******************************************************************\ + +Function: set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void set_properties( goto_programt &goto_program, std::unordered_set &property_set) @@ -39,11 +48,35 @@ void set_properties( } } +/*******************************************************************\ + +Function: label_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void label_properties(goto_modelt &goto_model) { label_properties(goto_model.goto_functions); } +/*******************************************************************\ + +Function: label_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void label_properties( goto_programt &goto_program, std::map &property_counters) @@ -86,12 +119,36 @@ void label_properties( } } +/*******************************************************************\ + +Function: label_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void label_properties(goto_programt &goto_program) { std::map property_counters; label_properties(goto_program, property_counters); } +/*******************************************************************\ + +Function: set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void set_properties( goto_modelt &goto_model, const std::list &properties) @@ -99,6 +156,18 @@ void set_properties( set_properties(goto_model.goto_functions, properties); } +/*******************************************************************\ + +Function: set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void set_properties( goto_functionst &goto_functions, const std::list &properties) @@ -115,6 +184,18 @@ void set_properties( throw "property "+id2string(*property_set.begin())+" not found"; } +/*******************************************************************\ + +Function: label_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void label_properties(goto_functionst &goto_functions) { std::map property_counters; @@ -127,11 +208,35 @@ void label_properties(goto_functionst &goto_functions) label_properties(it->second.body, property_counters); } +/*******************************************************************\ + +Function: make_assertions_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void make_assertions_false(goto_modelt &goto_model) { make_assertions_false(goto_model.goto_functions); } +/*******************************************************************\ + +Function: make_assertions_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void make_assertions_false( goto_functionst &goto_functions) { diff --git a/src/goto-programs/set_properties.h b/src/goto-programs/set_properties.h index 53d1bee93d7..8f302b79bee 100644 --- a/src/goto-programs/set_properties.h +++ b/src/goto-programs/set_properties.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Set the properties to check - #ifndef CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H #define CPROVER_GOTO_PROGRAMS_SET_PROPERTIES_H diff --git a/src/goto-programs/show_goto_functions.cpp b/src/goto-programs/show_goto_functions.cpp index 516d2e6a3d2..2b07d6d6db8 100644 --- a/src/goto-programs/show_goto_functions.cpp +++ b/src/goto-programs/show_goto_functions.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Show goto functions - #include #include @@ -26,6 +23,18 @@ Author: Peter Schrammel #include "goto_functions.h" #include "goto_model.h" +/*******************************************************************\ + +Function: cbmc_parseoptionst::show_goto_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_goto_functions( const namespacet &ns, ui_message_handlert::uit ui, @@ -53,6 +62,18 @@ void show_goto_functions( } } +/*******************************************************************\ + +Function: show_goto_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_goto_functions( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_goto_functions.h b/src/goto-programs/show_goto_functions.h index 4f63fde97a6..a496682961e 100644 --- a/src/goto-programs/show_goto_functions.h +++ b/src/goto-programs/show_goto_functions.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Show the goto functions - #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_H diff --git a/src/goto-programs/show_goto_functions_json.cpp b/src/goto-programs/show_goto_functions_json.cpp index da9c2424322..47a19e0662a 100644 --- a/src/goto-programs/show_goto_functions_json.cpp +++ b/src/goto-programs/show_goto_functions_json.cpp @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Program - #include #include @@ -23,15 +20,37 @@ Author: Thomas Kiley #include "goto_model.h" #include "show_goto_functions_json.h" -/// For outputing the GOTO program in a readable JSON format. -/// \param ns: the namespace to use to resolve names with +/*******************************************************************\ + +Function: show_goto_functions_jsont::show_goto_functions_jsont + + Inputs: + ns - the namespace to use to resolve names with + + Outputs: + + Purpose: For outputing the GOTO program in a readable JSON format. + +\*******************************************************************/ + show_goto_functions_jsont::show_goto_functions_jsont(const namespacet &ns): ns(ns) {} -/// Walks through all of the functions in the program and returns a JSON object -/// representing all their functions -/// \param goto_functions: the goto functions that make up the program +/*******************************************************************\ + +Function: show_goto_functions_jsont::convert + + Inputs: + goto_functions - the goto functions that make up the program + + Outputs: + + Purpose: Walks through all of the functions in the program and returns + a JSON object representing all their functions + +\*******************************************************************/ + json_objectt show_goto_functions_jsont::convert( const goto_functionst &goto_functions) { @@ -110,13 +129,24 @@ json_objectt show_goto_functions_jsont::convert( return json_result; } -/// Print the json object generated by -/// show_goto_functions_jsont::show_goto_functions to the provided stream (e.g. -/// std::cout) -/// \param goto_functions: the goto functions that make up the program -/// \param out: the stream to write the object to -/// \param append: should a command and newline be appended to the stream before -/// writing the JSON object. Defaults to true +/*******************************************************************\ + +Function: show_goto_functions_jsont::operator() + + Inputs: + goto_functions - the goto functions that make up the program + out - the stream to write the object to + append - should a command and newline be appended to the stream + before writing the JSON object. Defaults to true + + Outputs: + + Purpose: Print the json object generated by + show_goto_functions_jsont::show_goto_functions to the provided + stream (e.g. std::cout) + +\*******************************************************************/ + void show_goto_functions_jsont::operator()( const goto_functionst &goto_functions, std::ostream &out, diff --git a/src/goto-programs/show_goto_functions_json.h b/src/goto-programs/show_goto_functions_json.h index 0f2c7a9e8e5..b6313247f43 100644 --- a/src/goto-programs/show_goto_functions_json.h +++ b/src/goto-programs/show_goto_functions_json.h @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Program - #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_JSON_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_JSON_H diff --git a/src/goto-programs/show_goto_functions_xml.cpp b/src/goto-programs/show_goto_functions_xml.cpp index cce37c8d2c4..7ccdd71a4ff 100644 --- a/src/goto-programs/show_goto_functions_xml.cpp +++ b/src/goto-programs/show_goto_functions_xml.cpp @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Program - #include #include @@ -24,19 +21,51 @@ Author: Thomas Kiley #include "show_goto_functions_xml.h" -/// For outputing the GOTO program in a readable xml format. -/// \param ns: the namespace to use to resolve names with +/*******************************************************************\ + +Function: show_goto_functions_xmlt::show_goto_functions_xmlt + + Inputs: + ns - the namespace to use to resolve names with + + Outputs: + + Purpose: For outputing the GOTO program in a readable xml format. + +\*******************************************************************/ + show_goto_functions_xmlt::show_goto_functions_xmlt(const namespacet &ns): ns(ns) {} -/// Walks through all of the functions in the program and returns an xml object -/// representing all their functions. Produces output like this: -/// -/// -/// // 34 file main.c line 1 s = { 'a', 'b', 'c', 0 }; -/// -/// \param goto_functions: the goto functions that make up the program +/*******************************************************************\ + +Function: show_goto_functions_xmlt::convert + + Inputs: + goto_functions - the goto functions that make up the program + + Outputs: + + Purpose: Walks through all of the functions in the program and returns + an xml object representing all their functions. Produces output + like this: + + + + + + + // 34 file main.c line 1 + s = { 'a', 'b', 'c', 0 }; + + + + + + +\*******************************************************************/ + xmlt show_goto_functions_xmlt::convert( const goto_functionst &goto_functions) { @@ -85,13 +114,24 @@ xmlt show_goto_functions_xmlt::convert( return xml_functions; } -/// Print the xml object generated by -/// show_goto_functions_xmlt::show_goto_functions to the provided stream (e.g. -/// std::cout) -/// \param goto_functions: the goto functions that make up the program -/// \param out: the stream to write the object to -/// \param append: should a command and newline be appended to the stream before -/// writing the xml object. Defaults to true +/*******************************************************************\ + +Function: show_goto_functions_xmlt::operator() + + Inputs: + goto_functions - the goto functions that make up the program + out - the stream to write the object to + append - should a command and newline be appended to the stream + before writing the xml object. Defaults to true + + Outputs: + + Purpose: Print the xml object generated by + show_goto_functions_xmlt::show_goto_functions to the provided + stream (e.g. std::cout) + +\*******************************************************************/ + void show_goto_functions_xmlt::operator()( const goto_functionst &goto_functions, std::ostream &out, diff --git a/src/goto-programs/show_goto_functions_xml.h b/src/goto-programs/show_goto_functions_xml.h index 1d47bba0b55..6e170b5f32d 100644 --- a/src/goto-programs/show_goto_functions_xml.h +++ b/src/goto-programs/show_goto_functions_xml.h @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Program - #ifndef CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_XML_H #define CPROVER_GOTO_PROGRAMS_SHOW_GOTO_FUNCTIONS_XML_H diff --git a/src/goto-programs/show_properties.cpp b/src/goto-programs/show_properties.cpp index feaeb4e9a06..b6b03d1a7a4 100644 --- a/src/goto-programs/show_properties.cpp +++ b/src/goto-programs/show_properties.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show Claims - #include #include @@ -22,6 +19,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" #include "goto_model.h" +/*******************************************************************\ + +Function: cbmc_parseoptionst::show_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_properties( const namespacet &ns, const irep_idt &identifier, @@ -84,6 +93,18 @@ void show_properties( } +/*******************************************************************\ + +Function: cbmc_parseoptionst::show_properties_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_properties_json( json_arrayt &json_properties, const namespacet &ns, @@ -120,6 +141,18 @@ void show_properties_json( } } +/*******************************************************************\ + +Function: show_properties_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_properties_json( const namespacet &ns, const goto_functionst &goto_functions) @@ -139,6 +172,18 @@ void show_properties_json( std::cout << ",\n" << json_result; } +/*******************************************************************\ + +Function: show_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_properties( const namespacet &ns, ui_message_handlert::uit ui, @@ -152,6 +197,18 @@ void show_properties( show_properties(ns, fct.first, ui, fct.second.body); } +/*******************************************************************\ + +Function: show_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_properties( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_properties.h b/src/goto-programs/show_properties.h index b5564818195..0feff5f6a3d 100644 --- a/src/goto-programs/show_properties.h +++ b/src/goto-programs/show_properties.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show the properties - #ifndef CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H #define CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H diff --git a/src/goto-programs/show_symbol_table.cpp b/src/goto-programs/show_symbol_table.cpp index 60460147e52..cf24e4677ca 100644 --- a/src/goto-programs/show_symbol_table.cpp +++ b/src/goto-programs/show_symbol_table.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show the symbol table - #include #include @@ -18,10 +15,34 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_model.h" #include "show_symbol_table.h" +/*******************************************************************\ + +Function: show_symbol_table_xml_ui + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_symbol_table_xml_ui() { } +/*******************************************************************\ + +Function: show_symbol_table_plain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_symbol_table_plain( const goto_modelt &goto_model, std::ostream &out) @@ -109,6 +130,18 @@ void show_symbol_table_plain( } } +/*******************************************************************\ + +Function: show_symbol_table + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_symbol_table( const goto_modelt &goto_model, ui_message_handlert::uit ui) diff --git a/src/goto-programs/show_symbol_table.h b/src/goto-programs/show_symbol_table.h index 5ad717e7049..6e3b387f863 100644 --- a/src/goto-programs/show_symbol_table.h +++ b/src/goto-programs/show_symbol_table.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show the symbol table - #ifndef CPROVER_GOTO_PROGRAMS_SHOW_SYMBOL_TABLE_H #define CPROVER_GOTO_PROGRAMS_SHOW_SYMBOL_TABLE_H diff --git a/src/goto-programs/slice_global_inits.cpp b/src/goto-programs/slice_global_inits.cpp index 5496a8266a3..5e58888d366 100644 --- a/src/goto-programs/slice_global_inits.cpp +++ b/src/goto-programs/slice_global_inits.cpp @@ -8,9 +8,6 @@ Date: December 2016 \*******************************************************************/ -/// \file -/// Remove initializations of unused global variables - #include #include @@ -25,6 +22,18 @@ Date: December 2016 #include "slice_global_inits.h" +/*******************************************************************\ + +Function: slice_global_inits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void slice_global_inits( const namespacet &ns, goto_functionst &goto_functions) diff --git a/src/goto-programs/slice_global_inits.h b/src/goto-programs/slice_global_inits.h index 25a96121961..7907c31c49b 100644 --- a/src/goto-programs/slice_global_inits.h +++ b/src/goto-programs/slice_global_inits.h @@ -8,9 +8,6 @@ Date: December 2016 \*******************************************************************/ -/// \file -/// Remove initializations of unused global variables - #ifndef CPROVER_GOTO_PROGRAMS_SLICE_GLOBAL_INITS_H #define CPROVER_GOTO_PROGRAMS_SLICE_GLOBAL_INITS_H diff --git a/src/goto-programs/string_abstraction.cpp b/src/goto-programs/string_abstraction.cpp index c217243f108..5c7a1868578 100644 --- a/src/goto-programs/string_abstraction.cpp +++ b/src/goto-programs/string_abstraction.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// String Abstraction - #include #include @@ -22,6 +19,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_arithmetic.h" #include "string_abstraction.h" +/*******************************************************************\ + +Function: string_abstractiont::build_wrap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_wrap( const exprt &object, exprt &dest, bool write) @@ -51,6 +60,18 @@ bool string_abstractiont::build_wrap( return false; } +/*******************************************************************\ + +Function: string_abstractiont::is_ptr_string_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::is_ptr_string_struct(const typet &type) const { return type.id()==ID_pointer && @@ -62,6 +83,18 @@ static inline bool is_ptr_argument(const typet &type) return type.id()==ID_pointer; } +/*******************************************************************\ + +Function: string_abstraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstraction( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -71,6 +104,18 @@ void string_abstraction( string_abstraction(dest); } +/*******************************************************************\ + +Function: string_abstraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstraction( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -80,6 +125,18 @@ void string_abstraction( string_abstraction(dest); } +/*******************************************************************\ + +Function: string_abstractiont::string_abstractiont + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + string_abstractiont::string_abstractiont( symbol_tablet &_symbol_table, message_handlert &_message_handler): @@ -109,6 +166,18 @@ string_abstractiont::string_abstractiont( string_struct=s; } +/*******************************************************************\ + +Function: string_abstractiont::build_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet string_abstractiont::build_type(whatt what) { typet type; @@ -123,6 +192,18 @@ typet string_abstractiont::build_type(whatt what) return type; } +/*******************************************************************\ + +Function: string_abstractiont::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::operator()(goto_functionst &dest) { Forall_goto_functions(it, dest) @@ -148,6 +229,18 @@ void string_abstractiont::operator()(goto_functionst &dest) } } +/*******************************************************************\ + +Function: string_abstractiont::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::operator()(goto_programt &dest) { abstract(dest); @@ -158,6 +251,18 @@ void string_abstractiont::operator()(goto_programt &dest) initialization.clear(); } +/*******************************************************************\ + +Function: string_abstractiont::add_str_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::add_str_arguments( const irep_idt &name, goto_functionst::goto_functiont &fct) @@ -197,6 +302,18 @@ void string_abstractiont::add_str_arguments( symb_parameters.end(), str_args.begin(), str_args.end()); } +/*******************************************************************\ + +Function: string_abstractiont::add_argument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::add_argument( code_typet::parameterst &str_args, const symbolt &fct_symbol, @@ -225,6 +342,18 @@ void string_abstractiont::add_argument( symbol_table.move(new_symbol); } +/*******************************************************************\ + +Function: string_abstractiont::abstract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::abstract(goto_programt &dest) { locals.clear(); @@ -240,6 +369,18 @@ void string_abstractiont::abstract(goto_programt &dest) locals.clear(); } +/*******************************************************************\ + +Function: string_abstractiont::declare_define_locals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::declare_define_locals(goto_programt &dest) { typedef std::unordered_map @@ -276,6 +417,18 @@ void string_abstractiont::declare_define_locals(goto_programt &dest) } } +/*******************************************************************\ + +Function: string_abstractiont::make_decl_and_def + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::make_decl_and_def(goto_programt &dest, goto_programt::targett ref_instr, const irep_idt &identifier, @@ -311,6 +464,18 @@ void string_abstractiont::make_decl_and_def(goto_programt &dest, } } +/*******************************************************************\ + +Function: string_abstractiont::make_val_or_dummy_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest, goto_programt::targett ref_instr, const symbolt &symbol, const typet &source_type) @@ -380,6 +545,18 @@ exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest, return nil_exprt(); } +/*******************************************************************\ + +Function: string_abstractiont::add_dummy_symbol_and_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt string_abstractiont::add_dummy_symbol_and_value( goto_programt &dest, goto_programt::targett ref_instr, @@ -446,6 +623,18 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value( return sym_expr; } +/*******************************************************************\ + +Function: string_abstractiont::abstract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::abstract( goto_programt &dest, goto_programt::targett it) @@ -493,6 +682,18 @@ goto_programt::targett string_abstractiont::abstract( return it; } +/*******************************************************************\ + +Function: string_abstractiont::abstract_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::abstract_assign( goto_programt &dest, goto_programt::targett target) @@ -520,6 +721,18 @@ goto_programt::targett string_abstractiont::abstract_assign( return target; } +/*******************************************************************\ + +Function: string_abstractiont::abstract_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::abstract_function_call( goto_programt &dest, goto_programt::targett target) @@ -573,6 +786,18 @@ void string_abstractiont::abstract_function_call( arguments.insert(arguments.end(), str_args.begin(), str_args.end()); } +/*******************************************************************\ + +Function: string_abstractiont::has_string_macros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::has_string_macros(const exprt &expr) { if(expr.id()=="is_zero_string" || @@ -587,6 +812,18 @@ bool string_abstractiont::has_string_macros(const exprt &expr) return false; } +/*******************************************************************\ + +Function: string_abstractiont::replace_string_macros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::replace_string_macros( exprt &expr, bool lhs, @@ -615,6 +852,18 @@ void string_abstractiont::replace_string_macros( replace_string_macros(*it, lhs, source_location); } +/*******************************************************************\ + +Function: string_abstractiont::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt string_abstractiont::build( const exprt &pointer, whatt what, @@ -652,6 +901,18 @@ exprt string_abstractiont::build( return result; } +/*******************************************************************\ + +Function: string_abstractiont::build_abstraction_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &string_abstractiont::build_abstraction_type(const typet &type) { const typet &eff_type=ns.follow(type); @@ -671,6 +932,18 @@ const typet &string_abstractiont::build_abstraction_type(const typet &type) std::make_pair(eff_type, map_entry->second)).first->second; } +/*******************************************************************\ + +Function: string_abstractiont::build_abstraction_type_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &string_abstractiont::build_abstraction_type_rec(const typet &type, const abstraction_types_mapt &known) { @@ -735,6 +1008,18 @@ const typet &string_abstractiont::build_abstraction_type_rec(const typet &type, return map_entry.first->second; } +/*******************************************************************\ + +Function: string_abstractiont::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build(const exprt &object, exprt &dest, bool write) { const typet &abstract_type=build_abstraction_type(object.type()); @@ -799,6 +1084,18 @@ bool string_abstractiont::build(const exprt &object, exprt &dest, bool write) return true; } +/*******************************************************************\ + +Function: string_abstractiont::build_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_if(const if_exprt &o_if, exprt &dest, bool write) { @@ -827,6 +1124,18 @@ bool string_abstractiont::build_if(const if_exprt &o_if, return false; } +/*******************************************************************\ + +Function: string_abstractiont::build_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_array(const array_exprt &object, exprt &dest, bool write) { @@ -851,6 +1160,18 @@ bool string_abstractiont::build_array(const array_exprt &object, return true; } +/*******************************************************************\ + +Function: string_abstractiont::build_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_pointer(const exprt &object, exprt &dest, bool write) { @@ -883,6 +1204,18 @@ bool string_abstractiont::build_pointer(const exprt &object, return true; } +/*******************************************************************\ + +Function: string_abstractiont::build_unknown + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt string_abstractiont::build_unknown(whatt what, bool write) { typet type=build_type(what); @@ -907,6 +1240,18 @@ exprt string_abstractiont::build_unknown(whatt what, bool write) return result; } +/*******************************************************************\ + +Function: string_abstractiont::build_unknown + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt string_abstractiont::build_unknown(const typet &type, bool write) { if(write) @@ -934,6 +1279,18 @@ exprt string_abstractiont::build_unknown(const typet &type, bool write) return ns.lookup(identifier).symbol_expr(); } +/*******************************************************************\ + +Function: string_abstractiont::build_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest) { const symbolt &symbol=ns.lookup(sym.get_identifier()); @@ -961,6 +1318,18 @@ bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest) return false; } +/*******************************************************************\ + +Function: string_abstractiont::build_new_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::build_new_symbol(const symbolt &symbol, const irep_idt &identifier, const typet &type) { @@ -992,6 +1361,18 @@ void string_abstractiont::build_new_symbol(const symbolt &symbol, } } +/*******************************************************************\ + +Function: string_abstractiont::build_symbol_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_abstractiont::build_symbol_constant( const mp_integer &zero_length, const mp_integer &buf_size, @@ -1037,6 +1418,18 @@ bool string_abstractiont::build_symbol_constant( return false; } +/*******************************************************************\ + +Function: string_abstractiont::move_lhs_arithmetic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_abstractiont::move_lhs_arithmetic(exprt &lhs, exprt &rhs) { if(lhs.id()==ID_minus) @@ -1049,6 +1442,18 @@ void string_abstractiont::move_lhs_arithmetic(exprt &lhs, exprt &rhs) } } +/*******************************************************************\ + +Function: string_abstractiont::abstract_pointer_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::abstract_pointer_assign( goto_programt &dest, goto_programt::targett target) @@ -1094,6 +1499,18 @@ goto_programt::targett string_abstractiont::abstract_pointer_assign( } } +/*******************************************************************\ + +Function: string_abstractiont::abstract_char_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::abstract_char_assign( goto_programt &dest, goto_programt::targett target) @@ -1155,6 +1572,18 @@ goto_programt::targett string_abstractiont::abstract_char_assign( return target; } +/*******************************************************************\ + +Function: string_abstractiont::char_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::char_assign( goto_programt &dest, goto_programt::targett target, @@ -1192,6 +1621,18 @@ goto_programt::targett string_abstractiont::char_assign( return target; } +/*******************************************************************\ + +Function: string_abstractiont::value_assignments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::value_assignments( goto_programt &dest, goto_programt::targett target, @@ -1239,6 +1680,18 @@ goto_programt::targett string_abstractiont::value_assignments( return target; } +/*******************************************************************\ + +Function: string_abstractiont::value_assignments_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::value_assignments_if( goto_programt &dest, goto_programt::targett target, @@ -1277,6 +1730,18 @@ goto_programt::targett string_abstractiont::value_assignments_if( return last; } +/*******************************************************************\ + +Function: string_abstractiont::value_assignments_string_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_programt::targett string_abstractiont::value_assignments_string_struct( goto_programt &dest, goto_programt::targett target, @@ -1323,6 +1788,18 @@ goto_programt::targett string_abstractiont::value_assignments_string_struct( return last; } +/*******************************************************************\ + +Function: string_abstractiont::member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt string_abstractiont::member(const exprt &a, whatt what) { if(a.is_nil()) diff --git a/src/goto-programs/string_abstraction.h b/src/goto-programs/string_abstraction.h index 9443b09d68b..ebc716accc3 100644 --- a/src/goto-programs/string_abstraction.h +++ b/src/goto-programs/string_abstraction.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// String Abstraction - #ifndef CPROVER_GOTO_PROGRAMS_STRING_ABSTRACTION_H #define CPROVER_GOTO_PROGRAMS_STRING_ABSTRACTION_H @@ -19,6 +16,14 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_functions.h" +/*******************************************************************\ + + Class: string_abstractiont + + Purpose: + +\*******************************************************************/ + class string_abstractiont:public messaget { public: diff --git a/src/goto-programs/string_instrumentation.cpp b/src/goto-programs/string_instrumentation.cpp index 0796b361341..5a6596a97cd 100644 --- a/src/goto-programs/string_instrumentation.cpp +++ b/src/goto-programs/string_instrumentation.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// String Abstraction - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "string_instrumentation.h" +/*******************************************************************\ + +Function: is_zero_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt is_zero_string( const exprt &what, bool write) @@ -33,6 +42,18 @@ exprt is_zero_string( return result; } +/*******************************************************************\ + +Function: zero_string_length + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt zero_string_length( const exprt &what, bool write) @@ -43,6 +64,18 @@ exprt zero_string_length( return result; } +/*******************************************************************\ + +Function: buffer_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt buffer_size(const exprt &what) { exprt result("buffer_size", size_type()); @@ -50,6 +83,18 @@ exprt buffer_size(const exprt &what) return result; } +/*******************************************************************\ + + Class: string_instrumentationt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class string_instrumentationt:public messaget { public: @@ -152,6 +197,18 @@ class string_instrumentationt:public messaget const mp_integer &limit); }; +/*******************************************************************\ + +Function: string_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentation( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -161,6 +218,18 @@ void string_instrumentation( string_instrumentation(dest); } +/*******************************************************************\ + +Function: string_instrumentation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentation( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -170,6 +239,18 @@ void string_instrumentation( string_instrumentation(dest); } +/*******************************************************************\ + +Function: string_instrumentationt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::operator()(goto_functionst &dest) { for(goto_functionst::function_mapt::iterator @@ -181,12 +262,36 @@ void string_instrumentationt::operator()(goto_functionst &dest) } } +/*******************************************************************\ + +Function: string_instrumentationt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::operator()(goto_programt &dest) { Forall_goto_program_instructions(it, dest) instrument(dest, it); } +/*******************************************************************\ + +Function: string_instrumentationt::instrument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::instrument( goto_programt &dest, goto_programt::targett it) @@ -206,6 +311,18 @@ void string_instrumentationt::instrument( } } +/*******************************************************************\ + +Function: string_instrumentationt::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_function_call( goto_programt &dest, goto_programt::targett target) @@ -258,6 +375,18 @@ void string_instrumentationt::do_function_call( } } +/*******************************************************************\ + +Function: string_instrumentationt::do_sprintf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_sprintf( goto_programt &dest, goto_programt::targett target, @@ -300,6 +429,18 @@ void string_instrumentationt::do_sprintf( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_snprintf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_snprintf( goto_programt &dest, goto_programt::targett target, @@ -343,6 +484,18 @@ void string_instrumentationt::do_snprintf( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_fscanf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_fscanf( goto_programt &dest, goto_programt::targett target, @@ -376,6 +529,18 @@ void string_instrumentationt::do_fscanf( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_format_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_format_string_read( goto_programt &dest, goto_programt::const_targett target, @@ -479,6 +644,18 @@ void string_instrumentationt::do_format_string_read( } } +/*******************************************************************\ + +Function: string_instrumentationt::do_format_string_write + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_format_string_write( goto_programt &dest, goto_programt::const_targett target, @@ -629,6 +806,18 @@ void string_instrumentationt::do_format_string_write( } } +/*******************************************************************\ + +Function: string_instrumentationt::do_strncmp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strncmp( goto_programt &dest, goto_programt::targett target, @@ -636,6 +825,18 @@ void string_instrumentationt::do_strncmp( { } +/*******************************************************************\ + +Function: string_instrumentationt::do_strchr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strchr( goto_programt &dest, goto_programt::targett target, @@ -663,6 +864,18 @@ void string_instrumentationt::do_strchr( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_strrchr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strrchr( goto_programt &dest, goto_programt::targett target, @@ -690,6 +903,18 @@ void string_instrumentationt::do_strrchr( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_strstr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strstr( goto_programt &dest, goto_programt::targett target, @@ -724,6 +949,18 @@ void string_instrumentationt::do_strstr( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_strtok + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strtok( goto_programt &dest, goto_programt::targett target, @@ -758,6 +995,18 @@ void string_instrumentationt::do_strtok( dest.insert_before_swap(target, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::do_strerror + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::do_strerror( goto_programt &dest, goto_programt::targett it, @@ -854,6 +1103,18 @@ void string_instrumentationt::do_strerror( dest.insert_before_swap(it, tmp); } +/*******************************************************************\ + +Function: string_instrumentationt::invalidate_buffer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void string_instrumentationt::invalidate_buffer( goto_programt &dest, goto_programt::const_targett target, diff --git a/src/goto-programs/string_instrumentation.h b/src/goto-programs/string_instrumentation.h index 261b8dcdb1f..cd52bb54a84 100644 --- a/src/goto-programs/string_instrumentation.h +++ b/src/goto-programs/string_instrumentation.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// String Abstraction - #ifndef CPROVER_GOTO_PROGRAMS_STRING_INSTRUMENTATION_H #define CPROVER_GOTO_PROGRAMS_STRING_INSTRUMENTATION_H diff --git a/src/goto-programs/system_library_symbols.cpp b/src/goto-programs/system_library_symbols.cpp index 91e099b170d..250eb3b1cdb 100644 --- a/src/goto-programs/system_library_symbols.cpp +++ b/src/goto-programs/system_library_symbols.cpp @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Programs - #include "system_library_symbols.h" #include #include @@ -20,9 +17,20 @@ system_library_symbolst::system_library_symbolst() init_system_library_map(); } -/// To generate a map of header file names -> list of symbols The symbol names -/// are reserved as the header and source files will be compiled in to the goto -/// program. +/*******************************************************************\ + +Function: system_library_symbolst::init_system_library_map + +Inputs: + +Outputs: + +Purpose: To generate a map of header file names -> list of symbols + The symbol names are reserved as the header and source files + will be compiled in to the goto program. + +\*******************************************************************/ + void system_library_symbolst::init_system_library_map() { // ctype.h @@ -232,10 +240,22 @@ void system_library_symbolst::init_system_library_map() add_to_system_library("sys/wait.h", sys_wait_syms); } -/// To add the symbols from a specific header file to the system library map. -/// The symbol is used as the key so that we can easily look up symbols. -/// \param header_file: the name of the header file the symbol came from -/// \param symbols: a list of the names of the symbols in the header file +/*******************************************************************\ + +Function: system_library_symbolst::add_to_system_library + +Inputs: + header_file - the name of the header file the symbol came from + symbols - a list of the names of the symbols in the header file + +Outputs: + +Purpose: To add the symbols from a specific header file to the + system library map. The symbol is used as the key so that + we can easily look up symbols. + +\*******************************************************************/ + void system_library_symbolst::add_to_system_library( irep_idt header_file, std::list symbols) @@ -247,10 +267,21 @@ void system_library_symbolst::add_to_system_library( } -/// To find out if a symbol is an internal symbol. -/// \param symbol: the symbol to check -/// \return True if the symbol is an internal symbol. If specific system headers -/// need to be included, the out_system_headers will contain the headers. +/*******************************************************************\ + +Function: system_library_symbolst::is_symbol_internal_symbol + +Inputs: + symbol - the symbol to check + +Outputs: True if the symbol is an internal symbol. If specific system + headers need to be included, the out_system_headers will contain + the headers. + +Purpose: To find out if a symbol is an internal symbol. + +\*******************************************************************/ + bool system_library_symbolst::is_symbol_internal_symbol( const symbolt &symbol, std::set &out_system_headers) const diff --git a/src/goto-programs/system_library_symbols.h b/src/goto-programs/system_library_symbols.h index f5236314f21..9438e052a76 100644 --- a/src/goto-programs/system_library_symbols.h +++ b/src/goto-programs/system_library_symbols.h @@ -6,9 +6,6 @@ Author: Thomas Kiley \*******************************************************************/ -/// \file -/// Goto Programs - #ifndef CPROVER_GOTO_PROGRAMS_SYSTEM_LIBRARY_SYMBOLS_H #define CPROVER_GOTO_PROGRAMS_SYSTEM_LIBRARY_SYMBOLS_H diff --git a/src/goto-programs/vcd_goto_trace.cpp b/src/goto-programs/vcd_goto_trace.cpp index d6c39603cc4..9a3bbf443f7 100644 --- a/src/goto-programs/vcd_goto_trace.cpp +++ b/src/goto-programs/vcd_goto_trace.cpp @@ -8,9 +8,6 @@ Date: June 2011 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs in VCD (Value Change Dump) Format - #include #include #include @@ -21,6 +18,18 @@ Date: June 2011 #include "vcd_goto_trace.h" +/*******************************************************************\ + +Function: output_vcd + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string as_vcd_binary( const exprt &expr, const namespacet &ns) @@ -81,6 +90,18 @@ std::string as_vcd_binary( return ""; } +/*******************************************************************\ + +Function: output_vcd + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void output_vcd( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/vcd_goto_trace.h b/src/goto-programs/vcd_goto_trace.h index 0f7990b92bd..5b9a3680cb6 100644 --- a/src/goto-programs/vcd_goto_trace.h +++ b/src/goto-programs/vcd_goto_trace.h @@ -8,9 +8,6 @@ Date: June 2011 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs in VCD (Value Change Dump) Format - #ifndef CPROVER_GOTO_PROGRAMS_VCD_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_VCD_GOTO_TRACE_H diff --git a/src/goto-programs/wp.cpp b/src/goto-programs/wp.cpp index ea6ddd6a286..4290734e2f5 100644 --- a/src/goto-programs/wp.cpp +++ b/src/goto-programs/wp.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Weakest Preconditions - // #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "wp.h" +/*******************************************************************\ + +Function: has_nondet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_nondet(const exprt &dest) { forall_operands(it, dest) @@ -35,6 +44,18 @@ bool has_nondet(const exprt &dest) return false; } +/*******************************************************************\ + +Function: approximate_nondet_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void approximate_nondet_rec(exprt &dest, unsigned &count) { if(dest.id()==ID_side_effect && @@ -50,13 +71,36 @@ void approximate_nondet_rec(exprt &dest, unsigned &count) approximate_nondet_rec(*it, count); } +/*******************************************************************\ + +Function: approximate_nondet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void approximate_nondet(exprt &dest) { static unsigned count=0; // not proper, should be quantified approximate_nondet_rec(dest, count); } -/// consider possible aliasing +/*******************************************************************\ + +Function: aliasing + + Inputs: + + Outputs: + + Purpose: consider possible aliasing + +\*******************************************************************/ + enum class aliasingt { A_MAY, A_MUST, A_MUSTNOT }; aliasingt aliasing( @@ -111,7 +155,19 @@ aliasingt aliasing( return aliasingt::A_MAY; } -/// replace 'what' by 'by' in 'dest', considering possible aliasing +/*******************************************************************\ + +Function: substitute_rec + + Inputs: + + Outputs: + + Purpose: replace 'what' by 'by' in 'dest', + considering possible aliasing + +\*******************************************************************/ + void substitute_rec( exprt &dest, const exprt &what, @@ -161,6 +217,18 @@ void substitute_rec( } } +/*******************************************************************\ + +Function: rewrite_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rewrite_assignment(exprt &lhs, exprt &rhs) { if(lhs.id()==ID_member) // turn s.x:=e into s:=(s with .x=e) @@ -199,6 +267,18 @@ void rewrite_assignment(exprt &lhs, exprt &rhs) } } +/*******************************************************************\ + +Function: wp_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt wp_assign( const code_assignt &code, const exprt &post, @@ -220,6 +300,18 @@ exprt wp_assign( return pre; } +/*******************************************************************\ + +Function: wp_assume + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt wp_assume( const code_assumet &code, const exprt &post, @@ -228,6 +320,18 @@ exprt wp_assume( return implies_exprt(code.assumption(), post); } +/*******************************************************************\ + +Function: wp_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt wp_decl( const code_declt &code, const exprt &post, @@ -241,6 +345,18 @@ exprt wp_decl( return wp_assign(assignment, post, ns); } +/*******************************************************************\ + +Function: wp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt wp( const codet &code, const exprt &post, diff --git a/src/goto-programs/wp.h b/src/goto-programs/wp.h index 836832efbc1..741298b9507 100644 --- a/src/goto-programs/wp.h +++ b/src/goto-programs/wp.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Weakest Preconditions - #ifndef CPROVER_GOTO_PROGRAMS_WP_H #define CPROVER_GOTO_PROGRAMS_WP_H diff --git a/src/goto-programs/write_goto_binary.cpp b/src/goto-programs/write_goto_binary.cpp index 045aa9984fa..f5649e992d3 100644 --- a/src/goto-programs/write_goto_binary.cpp +++ b/src/goto-programs/write_goto_binary.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Write GOTO binaries - #include #include @@ -17,7 +14,18 @@ Author: CM Wintersteiger #include "write_goto_binary.h" -/// Writes a goto program to disc, using goto binary format ver 2 +/*******************************************************************\ + +Function: goto_programt::write_goto_binary_v3 + + Inputs: + + Outputs: + + Purpose: Writes a goto program to disc, using goto binary format ver 2 + +\*******************************************************************/ + bool write_goto_binary_v3( std::ostream &out, const symbol_tablet &lsymbol_table, @@ -119,7 +127,18 @@ bool write_goto_binary_v3( return false; } -/// Writes a goto program to disc +/*******************************************************************\ + +Function: goto_programt::write_goto_binary + + Inputs: + + Outputs: + + Purpose: Writes a goto program to disc + +\*******************************************************************/ + bool write_goto_binary( std::ostream &out, const symbol_tablet &lsymbol_table, @@ -153,7 +172,18 @@ bool write_goto_binary( return false; } -/// Writes a goto program to disc +/*******************************************************************\ + +Function: goto_programt::write_goto_binary + + Inputs: + + Outputs: + + Purpose: Writes a goto program to disc + +\*******************************************************************/ + bool write_goto_binary( const std::string &filename, const symbol_tablet &symbol_table, diff --git a/src/goto-programs/write_goto_binary.h b/src/goto-programs/write_goto_binary.h index fd3acd9cb77..5b5f0aef18c 100644 --- a/src/goto-programs/write_goto_binary.h +++ b/src/goto-programs/write_goto_binary.h @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Write GOTO binaries - #ifndef CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H #define CPROVER_GOTO_PROGRAMS_WRITE_GOTO_BINARY_H diff --git a/src/goto-programs/xml_goto_trace.cpp b/src/goto-programs/xml_goto_trace.cpp index 25e61157e9d..8b1bdb0e885 100644 --- a/src/goto-programs/xml_goto_trace.cpp +++ b/src/goto-programs/xml_goto_trace.cpp @@ -8,9 +8,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #include #include @@ -21,6 +18,18 @@ Author: Daniel Kroening #include "xml_goto_trace.h" +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const namespacet &ns, const goto_tracet &goto_trace, diff --git a/src/goto-programs/xml_goto_trace.h b/src/goto-programs/xml_goto_trace.h index ce77b09c450..123e0d69877 100644 --- a/src/goto-programs/xml_goto_trace.h +++ b/src/goto-programs/xml_goto_trace.h @@ -8,9 +8,6 @@ Date: November 2005 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #ifndef CPROVER_GOTO_PROGRAMS_XML_GOTO_TRACE_H #define CPROVER_GOTO_PROGRAMS_XML_GOTO_TRACE_H diff --git a/src/goto-symex/adjust_float_expressions.cpp b/src/goto-symex/adjust_float_expressions.cpp index 67eb4a06b56..46dee137447 100644 --- a/src/goto-symex/adjust_float_expressions.cpp +++ b/src/goto-symex/adjust_float_expressions.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "adjust_float_expressions.h" +/*******************************************************************\ + +Function: have_to_adjust_float_expressions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool have_to_adjust_float_expressions( const exprt &expr, const namespacet &ns) @@ -75,8 +84,19 @@ static bool have_to_adjust_float_expressions( return false; } -/// This adds the rounding mode to floating-point operations, including those in -/// vectors and complex numbers. +/*******************************************************************\ + +Function: adjust_float_expressions + + Inputs: + + Outputs: + + Purpose: This adds the rounding mode to floating-point operations, + including those in vectors and complex numbers. + +\*******************************************************************/ + void adjust_float_expressions( exprt &expr, const namespacet &ns) @@ -179,6 +199,18 @@ void adjust_float_expressions( } } +/*******************************************************************\ + +Function: adjust_float_expressions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static void adjust_float_expressions( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -190,6 +222,18 @@ static void adjust_float_expressions( } } +/*******************************************************************\ + +Function: adjust_float_expressions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void adjust_float_expressions( goto_functionst &goto_functions, const namespacet &ns) @@ -198,6 +242,18 @@ void adjust_float_expressions( adjust_float_expressions(it->second, ns); } +/*******************************************************************\ + +Function: adjust_float_expressions + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void adjust_float_expressions(goto_modelt &goto_model) { namespacet ns(goto_model.symbol_table); diff --git a/src/goto-symex/adjust_float_expressions.h b/src/goto-symex/adjust_float_expressions.h index 5cfd01d740f..f8547c59fa8 100644 --- a/src/goto-symex/adjust_float_expressions.h +++ b/src/goto-symex/adjust_float_expressions.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H #define CPROVER_GOTO_SYMEX_ADJUST_FLOAT_EXPRESSIONS_H diff --git a/src/goto-symex/auto_objects.cpp b/src/goto-symex/auto_objects.cpp index dab9cdfa9b3..1b3e6f2d636 100644 --- a/src/goto-symex/auto_objects.cpp +++ b/src/goto-symex/auto_objects.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::make_auto_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_symext::make_auto_object(const typet &type) { dynamic_counter++; @@ -34,6 +43,18 @@ exprt goto_symext::make_auto_object(const typet &type) return symbol_exprt(symbol.name, symbol.type); } +/*******************************************************************\ + +Function: goto_symext::initialize_auto_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::initialize_auto_object( const exprt &expr, statet &state) @@ -80,6 +101,18 @@ void goto_symext::initialize_auto_object( } } +/*******************************************************************\ + +Function: goto_symext::trigger_auto_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::trigger_auto_object( const exprt &expr, statet &state) diff --git a/src/goto-symex/build_goto_trace.cpp b/src/goto-symex/build_goto_trace.cpp index 6139c4dcdab..d5c7b62c60a 100644 --- a/src/goto-symex/build_goto_trace.cpp +++ b/src/goto-symex/build_goto_trace.cpp @@ -8,9 +8,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening #include "build_goto_trace.h" +/*******************************************************************\ + +Function: build_full_lhs_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt build_full_lhs_rec( const prop_convt &prop_conv, const namespacet &ns, @@ -101,6 +110,18 @@ exprt build_full_lhs_rec( return src_original; } +/*******************************************************************\ + +Function: adjust_lhs_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt adjust_lhs_object( const prop_convt &prop_conv, const namespacet &ns, @@ -109,8 +130,19 @@ exprt adjust_lhs_object( return nil_exprt(); } -/// set internal field for variable assignment related to dynamic_object[0-9] -/// and dynamic_[0-9]_array. +/*******************************************************************\ + +Function: set_internal_dynamic_object + + Inputs: + + Outputs: + + Purpose: set internal field for variable assignment related to + dynamic_object[0-9] and dynamic_[0-9]_array. + +\*******************************************************************/ + void set_internal_dynamic_object( const exprt &expr, goto_trace_stept &goto_trace_step, @@ -134,8 +166,20 @@ void set_internal_dynamic_object( } } -/// set internal for variables assignments related to dynamic_object and CPROVER -/// internal functions (e.g., __CPROVER_initialize) +/*******************************************************************\ + +Function: update_internal_field + + Inputs: + + Outputs: + + Purpose: set internal for variables assignments related to + dynamic_object and CPROVER internal functions + (e.g., __CPROVER_initialize) + +\*******************************************************************/ + void update_internal_field( const symex_target_equationt::SSA_stept &SSA_step, goto_trace_stept &goto_trace_step, @@ -170,6 +214,18 @@ void update_internal_field( } } +/*******************************************************************\ + +Function: build_goto_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void build_goto_trace( const symex_target_equationt &target, symex_target_equationt::SSA_stepst::const_iterator end_step, @@ -347,6 +403,18 @@ void build_goto_trace( s_it.step_nr=++step_nr; } +/*******************************************************************\ + +Function: build_goto_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void build_goto_trace( const symex_target_equationt &target, const prop_convt &prop_conv, diff --git a/src/goto-symex/build_goto_trace.h b/src/goto-symex/build_goto_trace.h index 16df35f7e7e..f7350d41ffe 100644 --- a/src/goto-symex/build_goto_trace.h +++ b/src/goto-symex/build_goto_trace.h @@ -8,9 +8,6 @@ Date: July 2005 \*******************************************************************/ -/// \file -/// Traces of GOTO Programs - #ifndef CPROVER_GOTO_SYMEX_BUILD_GOTO_TRACE_H #define CPROVER_GOTO_SYMEX_BUILD_GOTO_TRACE_H diff --git a/src/goto-symex/goto_symex.cpp b/src/goto-symex/goto_symex.cpp index 0ed472967c1..a3d55220e8d 100644 --- a/src/goto-symex/goto_symex.cpp +++ b/src/goto-symex/goto_symex.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include "goto_symex.h" @@ -16,12 +13,36 @@ Author: Daniel Kroening, kroening@kroening.com unsigned goto_symext::nondet_count=0; unsigned goto_symext::dynamic_counter=0; +/*******************************************************************\ + +Function: goto_symext::do_simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::do_simplify(exprt &expr) { if(options.get_bool_option("simplify")) simplify(expr, ns); } +/*******************************************************************\ + +Function: goto_symext::replace_nondet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::replace_nondet(exprt &expr) { if(expr.id()==ID_side_effect && diff --git a/src/goto-symex/goto_symex.h b/src/goto-symex/goto_symex.h index f45d722ebf7..f8c2cda0bf9 100644 --- a/src/goto-symex/goto_symex.h +++ b/src/goto-symex/goto_symex.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_GOTO_SYMEX_H #define CPROVER_GOTO_SYMEX_GOTO_SYMEX_H diff --git a/src/goto-symex/goto_symex_state.cpp b/src/goto-symex/goto_symex_state.cpp index 98976299aed..7b9b206902b 100644 --- a/src/goto-symex/goto_symex_state.cpp +++ b/src/goto-symex/goto_symex_state.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" +/*******************************************************************\ + +Function: goto_symex_statet::goto_symex_statet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + goto_symex_statet::goto_symex_statet(): depth(0), symex_target(NULL), @@ -31,6 +40,18 @@ goto_symex_statet::goto_symex_statet(): new_frame(); } +/*******************************************************************\ + +Function: goto_symex_statet::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::initialize(const goto_functionst &goto_functions) { goto_functionst::function_mapt::const_iterator it= @@ -46,6 +67,18 @@ void goto_symex_statet::initialize(const goto_functionst &goto_functions) top().calling_location.pc=top().end_of_function; } +/*******************************************************************\ + +Function: goto_symex_statet::level0t::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::level0t::operator()( ssa_exprt &ssa_expr, const namespacet &ns, @@ -78,6 +111,18 @@ void goto_symex_statet::level0t::operator()( ssa_expr.set_level_0(thread_nr); } +/*******************************************************************\ + +Function: goto_symex_statet::level1t::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::level1t::operator()(ssa_exprt &ssa_expr) { // already renamed? @@ -94,8 +139,19 @@ void goto_symex_statet::level1t::operator()(ssa_exprt &ssa_expr) ssa_expr.set_level_1(it->second.second); } -/// This function determines what expressions are to be propagated as -/// "constants" +/*******************************************************************\ + +Function: goto_symex_statet::constant_propagation + + Inputs: + + Outputs: + + Purpose: This function determines what expressions are to + be propagated as "constants" + +\*******************************************************************/ + bool goto_symex_statet::constant_propagation(const exprt &expr) const { if(expr.is_constant()) @@ -184,7 +240,19 @@ bool goto_symex_statet::constant_propagation(const exprt &expr) const return false; } -/// this function determines which reference-typed expressions are constant +/*******************************************************************\ + +Function: goto_symex_statet::constant_propagation_reference + + Inputs: + + Outputs: + + Purpose: this function determines which reference-typed + expressions are constant + +\*******************************************************************/ + bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -209,7 +277,18 @@ bool goto_symex_statet::constant_propagation_reference(const exprt &expr) const return false; } -/// write to a variable +/*******************************************************************\ + +Function: goto_symex_statet::assignment + + Inputs: + + Outputs: + + Purpose: write to a variable + +\*******************************************************************/ + static bool check_renaming(const exprt &expr); static bool check_renaming(const typet &type) @@ -382,6 +461,18 @@ void goto_symex_statet::assignment( #endif } +/*******************************************************************\ + +Function: goto_symex_statet::propagationt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::propagationt::operator()(exprt &expr) { if(expr.id()==ID_symbol) @@ -403,6 +494,18 @@ void goto_symex_statet::propagationt::operator()(exprt &expr) } } +/*******************************************************************\ + +Function: goto_symex_statet::set_ssa_indices + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::set_ssa_indices( ssa_exprt &ssa_expr, const namespacet &ns, @@ -436,6 +539,18 @@ void goto_symex_statet::set_ssa_indices( } } +/*******************************************************************\ + +Function: goto_symex_statet::rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::rename( exprt &expr, const namespacet &ns, @@ -527,7 +642,18 @@ void goto_symex_statet::rename( } } -/// thread encoding +/*******************************************************************\ + +Function: goto_symex_statet::l2_thread_read_encoding + + Inputs: + + Outputs: + + Purpose: thread encoding + +\*******************************************************************/ + bool goto_symex_statet::l2_thread_read_encoding( ssa_exprt &expr, const namespacet &ns) @@ -672,7 +798,18 @@ bool goto_symex_statet::l2_thread_read_encoding( return true; } -/// thread encoding +/*******************************************************************\ + +Function: goto_symex_statet::l2_thread_write_encoding + + Inputs: + + Outputs: + + Purpose: thread encoding + +\*******************************************************************/ + bool goto_symex_statet::l2_thread_write_encoding( const ssa_exprt &expr, const namespacet &ns) @@ -709,6 +846,18 @@ bool goto_symex_statet::l2_thread_write_encoding( return threads.size()>1; } +/*******************************************************************\ + +Function: goto_symex_statet::rename_address + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::rename_address( exprt &expr, const namespacet &ns, @@ -786,6 +935,18 @@ void goto_symex_statet::rename_address( } } +/*******************************************************************\ + +Function: goto_symex_statet::rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::rename( typet &type, const irep_idt &l1_identifier, @@ -857,6 +1018,18 @@ void goto_symex_statet::rename( l1_type_entry.first->second=type; } +/*******************************************************************\ + +Function: goto_symex_statet::get_original_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::get_original_name(exprt &expr) const { get_original_name(expr.type()); @@ -869,6 +1042,18 @@ void goto_symex_statet::get_original_name(exprt &expr) const get_original_name(*it); } +/*******************************************************************\ + +Function: goto_symex_statet::get_original_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::get_original_name(typet &type) const { // rename all the symbols with their last known value @@ -897,6 +1082,18 @@ void goto_symex_statet::get_original_name(typet &type) const } } +/*******************************************************************\ + +Function: goto_symex_statet::get_l1_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::get_l1_name(exprt &expr) const { // do not reset the type ! @@ -909,6 +1106,18 @@ void goto_symex_statet::get_l1_name(exprt &expr) const get_l1_name(*it); } +/*******************************************************************\ + +Function: goto_symex_statet::switch_to_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symex_statet::switch_to_thread(unsigned t) { assert(source.thread_nr #include "memory_model.h" +/*******************************************************************\ + +Function: memory_model_baset::memory_model_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + memory_model_baset::memory_model_baset(const namespacet &_ns): partial_order_concurrencyt(_ns), var_cnt(0) { } +/*******************************************************************\ + +Function: memory_model_baset::~memory_model_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + memory_model_baset::~memory_model_baset() { } +/*******************************************************************\ + +Function: memory_model_baset::nondet_bool_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt memory_model_baset::nondet_bool_symbol( const std::string &prefix) { @@ -31,6 +64,18 @@ symbol_exprt memory_model_baset::nondet_bool_symbol( bool_typet()); } +/*******************************************************************\ + +Function: memory_model_baset::po + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool memory_model_baset::po(event_it e1, event_it e2) { // within same thread @@ -43,6 +88,18 @@ bool memory_model_baset::po(event_it e1, event_it e2) } } +/*******************************************************************\ + +Function: memory_model_baset::read_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_baset::read_from(symex_target_equationt &equation) { // We iterate over all the reads, and diff --git a/src/goto-symex/memory_model.h b/src/goto-symex/memory_model.h index 083a75efa5b..b72c3672613 100644 --- a/src/goto-symex/memory_model.h +++ b/src/goto-symex/memory_model.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory models for partial order concurrency - #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_H diff --git a/src/goto-symex/memory_model_pso.cpp b/src/goto-symex/memory_model_pso.cpp index 2f4b59c8682..629451fc80b 100644 --- a/src/goto-symex/memory_model_pso.cpp +++ b/src/goto-symex/memory_model_pso.cpp @@ -6,11 +6,20 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory model for partial order concurrency - #include "memory_model_pso.h" +/*******************************************************************\ + +Function: memory_model_psot::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_psot::operator()(symex_target_equationt &equation) { print(8, "Adding PSO constraints"); @@ -26,6 +35,18 @@ void memory_model_psot::operator()(symex_target_equationt &equation) #endif } +/*******************************************************************\ + +Function: memory_model_psot::program_order_is_relaxed + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool memory_model_psot::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const diff --git a/src/goto-symex/memory_model_pso.h b/src/goto-symex/memory_model_pso.h index ca3cab0cd14..386a035bdcb 100644 --- a/src/goto-symex/memory_model_pso.h +++ b/src/goto-symex/memory_model_pso.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory models for partial order concurrency - #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_PSO_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_PSO_H diff --git a/src/goto-symex/memory_model_sc.cpp b/src/goto-symex/memory_model_sc.cpp index 3afac35b90f..7c131269802 100644 --- a/src/goto-symex/memory_model_sc.cpp +++ b/src/goto-symex/memory_model_sc.cpp @@ -6,13 +6,22 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory model for partial order concurrency - #include #include "memory_model_sc.h" +/*******************************************************************\ + +Function: memory_model_sct::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::operator()(symex_target_equationt &equation) { print(8, "Adding SC constraints"); @@ -26,12 +35,36 @@ void memory_model_sct::operator()(symex_target_equationt &equation) from_read(equation); } +/*******************************************************************\ + +Function: memory_model_sct::before + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt memory_model_sct::before(event_it e1, event_it e2) { return partial_order_concurrencyt::before( e1, e2, AX_PROPAGATION); } +/*******************************************************************\ + +Function: memory_model_sct::program_order_is_relaxed + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool memory_model_sct::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const @@ -42,6 +75,18 @@ bool memory_model_sct::program_order_is_relaxed( return false; } +/*******************************************************************\ + +Function: memory_model_sct::build_per_thread_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::build_per_thread_map( const symex_target_equationt &equation, per_thread_mapt &dest) const @@ -63,6 +108,18 @@ void memory_model_sct::build_per_thread_map( } } +/*******************************************************************\ + +Function: memory_model_sct::thread_spawn + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::thread_spawn( symex_target_equationt &equation, const per_thread_mapt &per_thread_map) @@ -146,6 +203,18 @@ void memory_model_sct::thread_spawn( } #endif +/*******************************************************************\ + +Function: memory_model_sct::program_order + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::program_order( symex_target_equationt &equation) { @@ -193,6 +262,18 @@ void memory_model_sct::program_order( } } +/*******************************************************************\ + +Function: memory_model_sct::write_serialization_external + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::write_serialization_external( symex_target_equationt &equation) { @@ -245,6 +326,18 @@ void memory_model_sct::write_serialization_external( } } +/*******************************************************************\ + +Function: memory_model_sct::from_read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_sct::from_read(symex_target_equationt &equation) { // from-read: (w', w) in ws and (w', r) in rf -> (r, w) in fr diff --git a/src/goto-symex/memory_model_sc.h b/src/goto-symex/memory_model_sc.h index 33e2edcb461..66709ae22be 100644 --- a/src/goto-symex/memory_model_sc.h +++ b/src/goto-symex/memory_model_sc.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory models for partial order concurrency - #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_SC_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_SC_H diff --git a/src/goto-symex/memory_model_tso.cpp b/src/goto-symex/memory_model_tso.cpp index f01b3900372..1fec15c9bdd 100644 --- a/src/goto-symex/memory_model_tso.cpp +++ b/src/goto-symex/memory_model_tso.cpp @@ -6,14 +6,23 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory model for partial order concurrency - #include #include #include "memory_model_tso.h" +/*******************************************************************\ + +Function: memory_model_tsot::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_tsot::operator()(symex_target_equationt &equation) { print(8, "Adding TSO constraints"); @@ -29,12 +38,36 @@ void memory_model_tsot::operator()(symex_target_equationt &equation) #endif } +/*******************************************************************\ + +Function: memory_model_tsot::before + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt memory_model_tsot::before(event_it e1, event_it e2) { return partial_order_concurrencyt::before( e1, e2, AX_SC_PER_LOCATION | AX_PROPAGATION); } +/*******************************************************************\ + +Function: memory_model_tsot::program_order_is_relaxed + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool memory_model_tsot::program_order_is_relaxed( partial_order_concurrencyt::event_it e1, partial_order_concurrencyt::event_it e2) const @@ -51,6 +84,18 @@ bool memory_model_tsot::program_order_is_relaxed( return e1->is_shared_write() && e2->is_shared_read(); } +/*******************************************************************\ + +Function: memory_model_tsot::program_order + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_model_tsot::program_order( symex_target_equationt &equation) { diff --git a/src/goto-symex/memory_model_tso.h b/src/goto-symex/memory_model_tso.h index 87592e471f6..11de873e02a 100644 --- a/src/goto-symex/memory_model_tso.h +++ b/src/goto-symex/memory_model_tso.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Memory models for partial order concurrency - #ifndef CPROVER_GOTO_SYMEX_MEMORY_MODEL_TSO_H #define CPROVER_GOTO_SYMEX_MEMORY_MODEL_TSO_H diff --git a/src/goto-symex/partial_order_concurrency.cpp b/src/goto-symex/partial_order_concurrency.cpp index 8cb323fec37..568a799b098 100644 --- a/src/goto-symex/partial_order_concurrency.cpp +++ b/src/goto-symex/partial_order_concurrency.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Add constraints to equation encoding partial orders on events - #include #include @@ -16,15 +13,51 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #include "partial_order_concurrency.h" +/*******************************************************************\ + +Function: partial_order_concurrencyt::~partial_order_concurrencyt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + partial_order_concurrencyt::partial_order_concurrencyt( const namespacet &_ns):ns(_ns) { } +/*******************************************************************\ + +Function: partial_order_concurrencyt::~partial_order_concurrencyt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + partial_order_concurrencyt::~partial_order_concurrencyt() { } +/*******************************************************************\ + +Function: partial_order_concurrencyt::add_init_writes + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void partial_order_concurrencyt::add_init_writes( symex_target_equationt &equation) { @@ -74,6 +107,18 @@ void partial_order_concurrencyt::add_init_writes( equation.SSA_steps.splice(equation.SSA_steps.begin(), init_steps); } +/*******************************************************************\ + +Function: partial_order_concurrencyt::build_event_lists + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void partial_order_concurrencyt::build_event_lists( symex_target_equationt &equation) { @@ -124,6 +169,18 @@ void partial_order_concurrencyt::build_event_lists( } } +/*******************************************************************\ + +Function: partial_order_concurrencyt::rw_clock_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt partial_order_concurrencyt::rw_clock_id( event_it event, axiomt axiom) @@ -138,6 +195,18 @@ irep_idt partial_order_concurrencyt::rw_clock_id( return ""; } +/*******************************************************************\ + +Function: partial_order_concurrencyt::clock + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_exprt partial_order_concurrencyt::clock( event_it event, axiomt axiom) @@ -161,6 +230,18 @@ symbol_exprt partial_order_concurrencyt::clock( return symbol_exprt(identifier, clock_type); } +/*******************************************************************\ + +Function: partial_order_concurrencyt::build_clock_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void partial_order_concurrencyt::build_clock_type( const symex_target_equationt &equation) { @@ -171,6 +252,18 @@ void partial_order_concurrencyt::build_clock_type( clock_type=unsignedbv_typet(integer2unsigned(width)); } +/*******************************************************************\ + +Function: partial_order_concurrencyt::before + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt partial_order_concurrencyt::before( event_it e1, event_it e2, unsigned axioms) { @@ -205,6 +298,18 @@ exprt partial_order_concurrencyt::before( return conjunction(ops); } +/*******************************************************************\ + +Function: partial_order_concurrencyt::add_constraint + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void partial_order_concurrencyt::add_constraint( symex_target_equationt &equation, const exprt &cond, diff --git a/src/goto-symex/partial_order_concurrency.h b/src/goto-symex/partial_order_concurrency.h index 5163451e210..86817ba5360 100644 --- a/src/goto-symex/partial_order_concurrency.h +++ b/src/goto-symex/partial_order_concurrency.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk \*******************************************************************/ -/// \file -/// Add constraints to equation encoding partial orders on events - #ifndef CPROVER_GOTO_SYMEX_PARTIAL_ORDER_CONCURRENCY_H #define CPROVER_GOTO_SYMEX_PARTIAL_ORDER_CONCURRENCY_H diff --git a/src/goto-symex/postcondition.cpp b/src/goto-symex/postcondition.cpp index 43aa79f6aa5..c93aa52a407 100644 --- a/src/goto-symex/postcondition.cpp +++ b/src/goto-symex/postcondition.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include #include "goto_symex_state.h" #include "postcondition.h" +/*******************************************************************\ + + Class: postconditiont + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class postconditiont { public: @@ -46,6 +55,18 @@ class postconditiont bool is_used(const exprt &expr, const irep_idt &identifier); }; +/*******************************************************************\ + +Function: postcondition + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void postcondition( const namespacet &ns, const value_sett &value_set, @@ -65,6 +86,18 @@ void postcondition( } } +/*******************************************************************\ + +Function: postconditiont::is_used_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool postconditiont::is_used_address_of( const exprt &expr, const irep_idt &identifier) @@ -95,6 +128,18 @@ bool postconditiont::is_used_address_of( return false; } +/*******************************************************************\ + +Function: postconditiont::compute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void postconditiont::compute(exprt &dest) { // weaken due to assignment @@ -104,6 +149,18 @@ void postconditiont::compute(exprt &dest) strengthen(dest); } +/*******************************************************************\ + +Function: postconditiont::strengthen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void postconditiont::weaken(exprt &dest) { if(dest.id()==ID_and && @@ -126,6 +183,18 @@ void postconditiont::weaken(exprt &dest) // otherwise, no weakening needed } +/*******************************************************************\ + +Function: postconditiont::strengthen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void postconditiont::strengthen(exprt &dest) { const irep_idt &lhs_identifier=SSA_step.ssa_lhs.get_object_name(); @@ -147,6 +216,18 @@ void postconditiont::strengthen(exprt &dest) } } +/*******************************************************************\ + +Function: postconditiont::is_used + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool postconditiont::is_used( const exprt &expr, const irep_idt &identifier) diff --git a/src/goto-symex/postcondition.h b/src/goto-symex/postcondition.h index 4f154a572cf..3e84235da47 100644 --- a/src/goto-symex/postcondition.h +++ b/src/goto-symex/postcondition.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Generate Equation using Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_POSTCONDITION_H #define CPROVER_GOTO_SYMEX_POSTCONDITION_H diff --git a/src/goto-symex/precondition.cpp b/src/goto-symex/precondition.cpp index 091408f0afc..15cc3e180a2 100644 --- a/src/goto-symex/precondition.cpp +++ b/src/goto-symex/precondition.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" #include "precondition.h" +/*******************************************************************\ + + Class: preconditiont + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class preconditiont { public: @@ -48,6 +57,18 @@ class preconditiont void compute_address_of(exprt &dest); }; +/*******************************************************************\ + +Function: precondition + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void precondition( const namespacet &ns, value_setst &value_sets, @@ -68,6 +89,18 @@ void precondition( } } +/*******************************************************************\ + +Function: preconditiont::compute_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void preconditiont::compute_address_of(exprt &dest) { if(dest.id()==ID_symbol) @@ -92,11 +125,35 @@ void preconditiont::compute_address_of(exprt &dest) } } +/*******************************************************************\ + +Function: preconditiont::compute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void preconditiont::compute(exprt &dest) { compute_rec(dest); } +/*******************************************************************\ + +Function: preconditiont::compute_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void preconditiont::compute_rec(exprt &dest) { if(dest.id()==ID_address_of) diff --git a/src/goto-symex/precondition.h b/src/goto-symex/precondition.h index 8adebcbd8c3..0d8b0caa23d 100644 --- a/src/goto-symex/precondition.h +++ b/src/goto-symex/precondition.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Generate Equation using Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_PRECONDITION_H #define CPROVER_GOTO_SYMEX_PRECONDITION_H diff --git a/src/goto-symex/rewrite_union.cpp b/src/goto-symex/rewrite_union.cpp index aa691f17411..f0a329af5ae 100644 --- a/src/goto-symex/rewrite_union.cpp +++ b/src/goto-symex/rewrite_union.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "rewrite_union.h" +/*******************************************************************\ + +Function: have_to_rewrite_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool have_to_rewrite_union( const exprt &expr, const namespacet &ns) @@ -42,8 +51,19 @@ static bool have_to_rewrite_union( return false; } -/// We rewrite u.c for unions u into byte_extract(u, 0), and { .c = v } into -/// byte_update(NIL, 0, v) +/*******************************************************************\ + +Function: rewrite_union + + Inputs: + + Outputs: + + Purpose: We rewrite u.c for unions u into byte_extract(u, 0), + and { .c = v } into byte_update(NIL, 0, v) + +\*******************************************************************/ + void rewrite_union( exprt &expr, const namespacet &ns) @@ -77,6 +97,18 @@ void rewrite_union( } } +/*******************************************************************\ + +Function: rewrite_union + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + static void rewrite_union( goto_functionst::goto_functiont &goto_function, const namespacet &ns) @@ -88,6 +120,18 @@ static void rewrite_union( } } +/*******************************************************************\ + +Function: rewrite_union + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void rewrite_union( goto_functionst &goto_functions, const namespacet &ns) @@ -96,6 +140,18 @@ void rewrite_union( rewrite_union(it->second, ns); } +/*******************************************************************\ + +Function: rewrite_union + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + void rewrite_union(goto_modelt &goto_model) { namespacet ns(goto_model.symbol_table); diff --git a/src/goto-symex/rewrite_union.h b/src/goto-symex/rewrite_union.h index d2c9b1772b4..7215e0bf0a4 100644 --- a/src/goto-symex/rewrite_union.h +++ b/src/goto-symex/rewrite_union.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_REWRITE_UNION_H #define CPROVER_GOTO_SYMEX_REWRITE_UNION_H diff --git a/src/goto-symex/slice.cpp b/src/goto-symex/slice.cpp index a398264963e..483e76211bc 100644 --- a/src/goto-symex/slice.cpp +++ b/src/goto-symex/slice.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicer for symex traces - #include #include "slice.h" #include "symex_slice_class.h" +/*******************************************************************\ + +Function: symex_slicet::get_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::get_symbols(const exprt &expr) { get_symbols(expr.type()); @@ -25,11 +34,35 @@ void symex_slicet::get_symbols(const exprt &expr) depends.insert(to_symbol_expr(expr).get_identifier()); } +/*******************************************************************\ + +Function: symex_slicet::get_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::get_symbols(const typet &type) { // TODO } +/*******************************************************************\ + +Function: symex_slicet::slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::slice( symex_target_equationt &equation, const expr_listt &exprs) @@ -41,6 +74,18 @@ void symex_slicet::slice( slice(equation); } +/*******************************************************************\ + +Function: symex_slicet::slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::slice(symex_target_equationt &equation) { for(symex_target_equationt::SSA_stepst::reverse_iterator @@ -50,6 +95,18 @@ void symex_slicet::slice(symex_target_equationt &equation) slice(*it); } +/*******************************************************************\ + +Function: symex_slicet::slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) { get_symbols(SSA_step.guard); @@ -108,6 +165,18 @@ void symex_slicet::slice(symex_target_equationt::SSA_stept &SSA_step) } } +/*******************************************************************\ + +Function: symex_slicet::slice_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::slice_assignment( symex_target_equationt::SSA_stept &SSA_step) { @@ -123,6 +192,18 @@ void symex_slicet::slice_assignment( get_symbols(SSA_step.ssa_rhs); } +/*******************************************************************\ + +Function: symex_slicet::slice_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slicet::slice_decl( symex_target_equationt::SSA_stept &SSA_step) { @@ -136,11 +217,20 @@ void symex_slicet::slice_decl( } } -/// Collect the open variables, i.e., variables that are used in RHS but never -/// written in LHS -/// \param equation: symex trace -/// \param open_variables: target set -/// \return None. But open_variables is modified as a side-effect. +/*******************************************************************\ + +Function: symex_slice_classt::collect_open_variables + + Inputs: equation - symex trace + open_variables - target set + + Outputs: None. But open_variables is modified as a side-effect. + + Purpose: Collect the open variables, i.e., variables that are used + in RHS but never written in LHS + +\*******************************************************************/ + void symex_slicet::collect_open_variables( const symex_target_equationt &equation, symbol_sett &open_variables) @@ -205,17 +295,38 @@ void symex_slicet::collect_open_variables( open_variables.erase(lhs.begin(), lhs.end()); } +/*******************************************************************\ + +Function: slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void slice(symex_target_equationt &equation) { symex_slicet symex_slice; symex_slice.slice(equation); } -/// Collect the open variables, i.e. variables that are used in RHS but never -/// written in LHS -/// \param equation: symex trace -/// \param open_variables: target set -/// \return None. But open_variables is modified as a side-effect. +/*******************************************************************\ + +Function: collect_open_variables + + Inputs: equation - symex trace + open_variables - target set + + Outputs: None. But open_variables is modified as a side-effect. + + Purpose: Collect the open variables, i.e. variables that are used + in RHS but never written in LHS + +\*******************************************************************/ + void collect_open_variables( const symex_target_equationt &equation, symbol_sett &open_variables) @@ -224,10 +335,19 @@ void collect_open_variables( symex_slice.collect_open_variables(equation, open_variables); } -/// Slice the symex trace with respect to a list of expressions -/// \param equation: symex trace to be sliced -/// \param expression: list of expressions, targets for slicing -/// \return None. But equation is modified as a side-effect. +/*******************************************************************\ + +Function: slice + + Inputs: equation - symex trace to be sliced + expression - list of expressions, targets for slicing + + Outputs: None. But equation is modified as a side-effect. + + Purpose: Slice the symex trace with respect to a list of expressions + +\*******************************************************************/ + void slice(symex_target_equationt &equation, const expr_listt &expressions) { @@ -235,6 +355,18 @@ void slice(symex_target_equationt &equation, symex_slice.slice(equation, expressions); } +/*******************************************************************\ + +Function: simple_slice + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void simple_slice(symex_target_equationt &equation) { // just find the last assertion diff --git a/src/goto-symex/slice.h b/src/goto-symex/slice.h index 2bc887a0c9f..1fd15969274 100644 --- a/src/goto-symex/slice.h +++ b/src/goto-symex/slice.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicer for symex traces - #ifndef CPROVER_GOTO_SYMEX_SLICE_H #define CPROVER_GOTO_SYMEX_SLICE_H diff --git a/src/goto-symex/slice_by_trace.cpp b/src/goto-symex/slice_by_trace.cpp index 20bce31beb8..07a4f81b96a 100644 --- a/src/goto-symex/slice_by_trace.cpp +++ b/src/goto-symex/slice_by_trace.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicer for symex traces - #include #include #include @@ -24,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "slice_by_trace.h" +/*******************************************************************\ + +Function: slice_by_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::slice_by_trace( std::string trace_files, symex_target_equationt &equation) @@ -118,6 +127,18 @@ void symex_slice_by_tracet::slice_by_trace( std::cout << "Finished slicing by trace..." << std::endl; } +/*******************************************************************\ + +Function: read_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::read_trace(std::string filename) { std::cout << "Reading trace from file " << filename << std::endl; @@ -163,6 +184,18 @@ void symex_slice_by_tracet::read_trace(std::string filename) t.push_back(t_e); } +/*******************************************************************\ + +Function: parse_alphabet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_slice_by_tracet::parse_alphabet(std::string read_line) { if((read_line==":") || (read_line == ":exact") || @@ -183,6 +216,18 @@ bool symex_slice_by_tracet::parse_alphabet(std::string read_line) return false; } +/*******************************************************************\ + +Function: parse_events + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::parse_events(std::string read_line) { if(read_line=="") @@ -231,6 +276,18 @@ void symex_slice_by_tracet::parse_events(std::string read_line) sigma.push_back(es); } +/*******************************************************************\ + +Function: compute_ts_back + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::compute_ts_back( symex_target_equationt &equation) { @@ -373,11 +430,35 @@ void symex_slice_by_tracet::compute_ts_back( } } +/*******************************************************************\ + +Function: compute_ts_fd + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::compute_ts_fd( symex_target_equationt &equation) { } +/*******************************************************************\ + +Function: slice_SSA_steps + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::slice_SSA_steps( symex_target_equationt &equation, std::set implications) @@ -495,6 +576,18 @@ void symex_slice_by_tracet::slice_SSA_steps( << " non-trace, non-location SSA_steps)" << std::endl; } +/*******************************************************************\ + +Function: matches + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_slice_by_tracet::matches( event_sett s, irep_idt event) @@ -503,6 +596,18 @@ bool symex_slice_by_tracet::matches( return ((s.second && present) || (!s.second && !present)); } +/*******************************************************************\ + +Function: assign_merges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_slice_by_tracet::assign_merges( symex_target_equationt &equation) { @@ -533,6 +638,18 @@ void symex_slice_by_tracet::assign_merges( } } +/*******************************************************************\ + +Function: implied_guards + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set symex_slice_by_tracet::implied_guards(exprt e) { std::set s; @@ -615,6 +732,18 @@ std::set symex_slice_by_tracet::implied_guards(exprt e) return s; } +/*******************************************************************\ + +Function: symex_slice_by_tracet::implies_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_slice_by_tracet::implies_false(const exprt e) { std::set imps=implied_guards(e); diff --git a/src/goto-symex/slice_by_trace.h b/src/goto-symex/slice_by_trace.h index eb5f706694c..8223e6589e1 100644 --- a/src/goto-symex/slice_by_trace.h +++ b/src/goto-symex/slice_by_trace.h @@ -6,9 +6,6 @@ Author: Alex Groce (agroce@gmail.com) \*******************************************************************/ -/// \file -/// Slicer for matching with trace files - #ifndef CPROVER_GOTO_SYMEX_SLICE_BY_TRACE_H #define CPROVER_GOTO_SYMEX_SLICE_BY_TRACE_H diff --git a/src/goto-symex/symex_assign.cpp b/src/goto-symex/symex_assign.cpp index 4daf5a9303c..61b6ad28488 100644 --- a/src/goto-symex/symex_assign.cpp +++ b/src/goto-symex/symex_assign.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com // #define USE_UPDATE +/*******************************************************************\ + +Function: goto_symext::symex_assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_rec( statet &state, const code_assignt &code) @@ -31,6 +40,18 @@ void goto_symext::symex_assign_rec( symex_assign(state, deref_code); } +/*******************************************************************\ + +Function: goto_symext::symex_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign( statet &state, const code_assignt &code) @@ -93,6 +114,18 @@ void goto_symext::symex_assign( } } +/*******************************************************************\ + +Function: goto_symext::add_to_lhs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt goto_symext::add_to_lhs( const exprt &lhs, const exprt &what) @@ -123,6 +156,18 @@ exprt goto_symext::add_to_lhs( return new_lhs; } +/*******************************************************************\ + +Function: goto_symext::symex_assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_rec( statet &state, const exprt &lhs, @@ -201,6 +246,18 @@ void goto_symext::symex_assign_rec( throw "assignment to `"+lhs.id_string()+"' not handled"; } +/*******************************************************************\ + +Function: goto_symext::symex_assign_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_symbol( statet &state, const ssa_exprt &lhs, // L1 @@ -257,6 +314,18 @@ void goto_symext::symex_assign_symbol( assignment_type); } +/*******************************************************************\ + +Function: goto_symext::symex_assign_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_typecast( statet &state, const typecast_exprt &lhs, @@ -278,6 +347,18 @@ void goto_symext::symex_assign_typecast( state, lhs.op0(), new_full_lhs, rhs_typecasted, guard, assignment_type); } +/*******************************************************************\ + +Function: goto_symext::symex_assign_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_array( statet &state, const index_exprt &lhs, @@ -334,6 +415,18 @@ void goto_symext::symex_assign_array( #endif } +/*******************************************************************\ + +Function: goto_symext::symex_assign_struct_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_struct_member( statet &state, const member_exprt &lhs, @@ -408,6 +501,18 @@ void goto_symext::symex_assign_struct_member( #endif } +/*******************************************************************\ + +Function: goto_symext::symex_assign_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_if( statet &state, const if_exprt &lhs, @@ -441,6 +546,18 @@ void goto_symext::symex_assign_if( } } +/*******************************************************************\ + +Function: goto_symext::symex_assign_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assign_byte_extract( statet &state, const byte_extract_exprt &lhs, diff --git a/src/goto-symex/symex_atomic_section.cpp b/src/goto-symex/symex_atomic_section.cpp index c243cafbcd4..7f4e239f676 100644 --- a/src/goto-symex/symex_atomic_section.cpp +++ b/src/goto-symex/symex_atomic_section.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_atomic_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_atomic_begin(statet &state) { if(state.guard.is_false()) @@ -31,6 +40,18 @@ void goto_symext::symex_atomic_begin(statet &state) state.source); } +/*******************************************************************\ + +Function: goto_symext::symex_atomic_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_atomic_end(statet &state) { if(state.guard.is_false()) diff --git a/src/goto-symex/symex_builtin_functions.cpp b/src/goto-symex/symex_builtin_functions.cpp index 6dd3de38591..c5bdd32d0f2 100644 --- a/src/goto-symex/symex_builtin_functions.cpp +++ b/src/goto-symex/symex_builtin_functions.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include @@ -29,6 +26,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" #include "goto_symex_state.h" +/*******************************************************************\ + +Function: goto_symext::symex_malloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline static typet c_sizeof_type_rec(const exprt &expr) { const irept &sizeof_type=expr.find(ID_C_c_sizeof_type); @@ -186,6 +195,18 @@ void goto_symext::symex_malloc( symex_assign_rec(state, code_assignt(lhs, rhs)); } +/*******************************************************************\ + +Function: goto_symext::symex_gcc_builtin_va_arg_next + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt get_symbol(const exprt &src) { if(src.id()==ID_typecast) @@ -250,6 +271,18 @@ void goto_symext::symex_gcc_builtin_va_arg_next( symex_assign_rec(state, code_assignt(lhs, rhs)); } +/*******************************************************************\ + +Function: goto_symext::get_string_argument_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt get_string_argument_rec(const exprt &src) { if(src.id()==ID_typecast) @@ -276,6 +309,18 @@ irep_idt get_string_argument_rec(const exprt &src) return ""; } +/*******************************************************************\ + +Function: goto_symext::get_string_argument + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt get_string_argument(const exprt &src, const namespacet &ns) { exprt tmp=src; @@ -283,6 +328,18 @@ irep_idt get_string_argument(const exprt &src, const namespacet &ns) return get_string_argument_rec(tmp); } +/*******************************************************************\ + +Function: goto_symext::symex_printf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_printf( statet &state, const exprt &lhs, @@ -310,6 +367,18 @@ void goto_symext::symex_printf( state.source, "printf", format_string, args); } +/*******************************************************************\ + +Function: goto_symext::symex_input + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_input( statet &state, const codet &code) @@ -335,6 +404,18 @@ void goto_symext::symex_input( target.input(state.guard.as_expr(), state.source, input_id, args); } +/*******************************************************************\ + +Function: goto_symext::symex_output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_output( statet &state, const codet &code) @@ -360,6 +441,18 @@ void goto_symext::symex_output( target.output(state.guard.as_expr(), state.source, output_id, args); } +/*******************************************************************\ + +Function: goto_symext::symex_cpp_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_cpp_new( statet &state, const exprt &lhs, @@ -420,6 +513,18 @@ void goto_symext::symex_cpp_new( symex_assign_rec(state, code_assignt(lhs, rhs)); } +/*******************************************************************\ + +Function: goto_symext::symex_cpp_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_cpp_delete( statet &state, const codet &code) @@ -427,6 +532,18 @@ void goto_symext::symex_cpp_delete( // bool do_array=code.get(ID_statement)==ID_cpp_delete_array; } +/*******************************************************************\ + +Function: goto_symext::symex_trace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_trace( statet &state, const code_function_callt &code) @@ -466,6 +583,18 @@ void goto_symext::symex_trace( } } +/*******************************************************************\ + +Function: goto_symext::symex_fkt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_fkt( statet &state, const code_function_callt &code) @@ -489,6 +618,18 @@ void goto_symext::symex_fkt( #endif } +/*******************************************************************\ + +Function: goto_symext::symex_macro + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_macro( statet &state, const code_function_callt &code) diff --git a/src/goto-symex/symex_catch.cpp b/src/goto-symex/symex_catch.cpp index c36deb71645..ffddd6314e8 100644 --- a/src/goto-symex/symex_catch.cpp +++ b/src/goto-symex/symex_catch.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_catch(statet &state) { // there are two variants: 'push' and 'pop' diff --git a/src/goto-symex/symex_clean_expr.cpp b/src/goto-symex/symex_clean_expr.cpp index 1e3be8d8d3f..e3e650d7b99 100644 --- a/src/goto-symex/symex_clean_expr.cpp +++ b/src/goto-symex/symex_clean_expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::process_array_expr_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::process_array_expr_rec( exprt &expr, const typet &type) const @@ -73,6 +82,18 @@ void goto_symext::process_array_expr_rec( } } +/*******************************************************************\ + +Function: goto_symext::process_array_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::process_array_expr(exprt &expr) { // This may change the type of the expression! @@ -122,6 +143,18 @@ void goto_symext::process_array_expr(exprt &expr) process_array_expr(*it); } +/*******************************************************************\ + +Function: goto_symext::replace_array_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::replace_array_equal(exprt &expr) { if(expr.id()==ID_array_equal) @@ -147,6 +180,18 @@ void goto_symext::replace_array_equal(exprt &expr) replace_array_equal(*it); } +/*******************************************************************\ + +Function: goto_symext::clean_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::clean_expr( exprt &expr, statet &state, diff --git a/src/goto-symex/symex_dead.cpp b/src/goto-symex/symex_dead.cpp index 11bcadcfbd7..ec9440bc5e8 100644 --- a/src/goto-symex/symex_dead.cpp +++ b/src/goto-symex/symex_dead.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_dead + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_dead(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; diff --git a/src/goto-symex/symex_decl.cpp b/src/goto-symex/symex_decl.cpp index 436a2d6e55c..4d5e162a4d9 100644 --- a/src/goto-symex/symex_decl.cpp +++ b/src/goto-symex/symex_decl.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_decl(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -38,6 +47,18 @@ void goto_symext::symex_decl(statet &state) symex_decl(state, to_symbol_expr(code.op0())); } +/*******************************************************************\ + +Function: goto_symext::symex_decl + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_decl(statet &state, const symbol_exprt &expr) { // We increase the L2 renaming to make these non-deterministic. diff --git a/src/goto-symex/symex_dereference.cpp b/src/goto-symex/symex_dereference.cpp index 28186bd97fd..513655f44b9 100644 --- a/src/goto-symex/symex_dereference.cpp +++ b/src/goto-symex/symex_dereference.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" #include "symex_dereference_state.h" +/*******************************************************************\ + +Function: goto_symext::dereference_rec_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::dereference_rec_address_of( exprt &expr, statet &state, @@ -63,6 +72,18 @@ void goto_symext::dereference_rec_address_of( } } +/*******************************************************************\ + +Function: goto_symext::is_index_member_symbol_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_symext::is_index_member_symbol_if(const exprt &expr) { // Could be member, could be if, could be index. @@ -88,7 +109,18 @@ bool goto_symext::is_index_member_symbol_if(const exprt &expr) return false; } -/// Evaluate an ID_address_of expression +/*******************************************************************\ + +Function: goto_symext::address_arithmetic + + Inputs: + + Outputs: + + Purpose: Evaluate an ID_address_of expression + +\*******************************************************************/ + exprt goto_symext::address_arithmetic( const exprt &expr, statet &state, @@ -226,6 +258,18 @@ exprt goto_symext::address_arithmetic( return result; } +/*******************************************************************\ + +Function: goto_symext::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::dereference_rec( exprt &expr, statet &state, @@ -340,6 +384,18 @@ void goto_symext::dereference_rec( } } +/*******************************************************************\ + +Function: goto_symext::dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::dereference( exprt &expr, statet &state, diff --git a/src/goto-symex/symex_dereference_state.cpp b/src/goto-symex/symex_dereference_state.cpp index fd4ff4218f4..cd69913e6a2 100644 --- a/src/goto-symex/symex_dereference_state.cpp +++ b/src/goto-symex/symex_dereference_state.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include "symex_dereference_state.h" +/*******************************************************************\ + +Function: symex_dereference_statet::dereference_failure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_dereference_statet::dereference_failure( const std::string &property, const std::string &msg, @@ -20,6 +29,18 @@ void symex_dereference_statet::dereference_failure( { } +/*******************************************************************\ + +Function: symex_dereference_statet::has_failed_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_dereference_statet::has_failed_symbol( const exprt &expr, const symbolt *&symbol) @@ -77,6 +98,18 @@ bool symex_dereference_statet::has_failed_symbol( return false; } +/*******************************************************************\ + +Function: symex_dereference_statet::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_dereference_statet::get_value_set( const exprt &expr, value_setst::valuest &value_set) diff --git a/src/goto-symex/symex_dereference_state.h b/src/goto-symex/symex_dereference_state.h index 315afb00a70..0afaf8a696f 100644 --- a/src/goto-symex/symex_dereference_state.h +++ b/src/goto-symex/symex_dereference_state.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #ifndef CPROVER_GOTO_SYMEX_SYMEX_DEREFERENCE_STATE_H #define CPROVER_GOTO_SYMEX_SYMEX_DEREFERENCE_STATE_H @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + + Class: symex_dereference_statet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + class symex_dereference_statet: public dereference_callbackt { diff --git a/src/goto-symex/symex_function_call.cpp b/src/goto-symex/symex_function_call.cpp index e1de5516f74..00636ae339b 100644 --- a/src/goto-symex/symex_function_call.cpp +++ b/src/goto-symex/symex_function_call.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #include #include #include @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::get_unwind_recursion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_symext::get_unwind_recursion( const irep_idt &identifier, const unsigned thread_nr, @@ -34,6 +43,18 @@ bool goto_symext::get_unwind_recursion( return false; } +/*******************************************************************\ + +Function: goto_symext::parameter_assignments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::parameter_assignments( const irep_idt function_identifier, const goto_functionst::goto_functiont &goto_function, @@ -169,6 +190,18 @@ void goto_symext::parameter_assignments( } } +/*******************************************************************\ + +Function: goto_symext::symex_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_function_call( const goto_functionst &goto_functions, statet &state, @@ -186,6 +219,18 @@ void goto_symext::symex_function_call( throw "unexpected function for symex_function_call: "+function.id_string(); } +/*******************************************************************\ + +Function: goto_symext::symex_function_call_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_function_call_symbol( const goto_functionst &goto_functions, statet &state, @@ -214,7 +259,18 @@ void goto_symext::symex_function_call_symbol( symex_function_call_code(goto_functions, state, code); } -/// do function call by inlining +/*******************************************************************\ + +Function: goto_symext::symex_function_call_code + + Inputs: + + Outputs: + + Purpose: do function call by inlining + +\*******************************************************************/ + void goto_symext::symex_function_call_code( const goto_functionst &goto_functions, statet &state, @@ -317,7 +373,18 @@ void goto_symext::symex_function_call_code( state.source.pc=goto_function.body.instructions.begin(); } -/// pop one call frame +/*******************************************************************\ + +Function: goto_symext::pop_frame + + Inputs: + + Outputs: + + Purpose: pop one call frame + +\*******************************************************************/ + void goto_symext::pop_frame(statet &state) { assert(!state.call_stack().empty()); @@ -357,7 +424,18 @@ void goto_symext::pop_frame(statet &state) state.pop_frame(); } -/// do function call by inlining +/*******************************************************************\ + +Function: goto_symext::symex_end_of_function + + Inputs: + + Outputs: + + Purpose: do function call by inlining + +\*******************************************************************/ + void goto_symext::symex_end_of_function(statet &state) { // first record the return @@ -368,8 +446,20 @@ void goto_symext::symex_end_of_function(statet &state) pop_frame(state); } -/// preserves locality of local variables of a given function by applying L1 -/// renaming to the local identifiers +/*******************************************************************\ + +Function: goto_symext::locality + + Inputs: + + Outputs: + + Purpose: preserves locality of local variables of a given + function by applying L1 renaming to the local + identifiers + +\*******************************************************************/ + void goto_symext::locality( const irep_idt function_identifier, statet &state, @@ -427,6 +517,18 @@ void goto_symext::locality( } } +/*******************************************************************\ + +Function: goto_symext::return_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::return_assignment(statet &state) { statet::framet &frame=state.top(); diff --git a/src/goto-symex/symex_goto.cpp b/src/goto-symex/symex_goto.cpp index 270871afc1d..0f6328bdc44 100644 --- a/src/goto-symex/symex_goto.cpp +++ b/src/goto-symex/symex_goto.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_goto(statet &state) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -197,6 +206,18 @@ void goto_symext::symex_goto(statet &state) } } +/*******************************************************************\ + +Function: goto_symext::symex_step_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_step_goto(statet &state, bool taken) { const goto_programt::instructiont &instruction=*state.source.pc; @@ -214,6 +235,18 @@ void goto_symext::symex_step_goto(statet &state, bool taken) target.assumption(state.guard.as_expr(), guard, state.source); } +/*******************************************************************\ + +Function: goto_symext::merge_gotos + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::merge_gotos(statet &state) { statet::framet &frame=state.top(); @@ -238,6 +271,18 @@ void goto_symext::merge_gotos(statet &state) frame.goto_state_map.erase(state_map_it); } +/*******************************************************************\ + +Function: goto_symext::merge_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::merge_goto( const statet::goto_statet &goto_state, statet &state) @@ -258,6 +303,18 @@ void goto_symext::merge_goto( state.depth=std::min(state.depth, goto_state.depth); } +/*******************************************************************\ + +Function: goto_symext::merge_value_sets + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::merge_value_sets( const statet::goto_statet &src, statet &dest) @@ -271,6 +328,18 @@ void goto_symext::merge_value_sets( dest.value_set.make_union(src.value_set); } +/*******************************************************************\ + +Function: goto_symext::phi_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::phi_function( const statet::goto_statet &goto_state, statet &dest_state) @@ -372,6 +441,18 @@ void goto_symext::phi_function( } } +/*******************************************************************\ + +Function: goto_symext::loop_bound_exceeded + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::loop_bound_exceeded( statet &state, const exprt &guard) @@ -411,6 +492,18 @@ void goto_symext::loop_bound_exceeded( } } +/*******************************************************************\ + +Function: goto_symext::get_unwind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_symext::get_unwind( const symex_targett::sourcet &source, unsigned unwind) diff --git a/src/goto-symex/symex_main.cpp b/src/goto-symex/symex_main.cpp index 7351b89a836..2cb7ac09290 100644 --- a/src/goto-symex/symex_main.cpp +++ b/src/goto-symex/symex_main.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -20,12 +17,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::new_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::new_name(symbolt &symbol) { get_new_name(symbol, ns); new_symbol_table.add(symbol); } +/*******************************************************************\ + +Function: goto_symext::vcc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::vcc( const exprt &vcc_expr, const std::string &msg, @@ -53,6 +74,18 @@ void goto_symext::vcc( target.assertion(state.guard.as_expr(), expr, msg, state.source); } +/*******************************************************************\ + +Function: goto_symext::symex_assume + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_assume(statet &state, const exprt &cond) { exprt simplified_cond=cond; @@ -82,6 +115,18 @@ void goto_symext::symex_assume(statet &state, const exprt &cond) symex_atomic_end(state); } +/*******************************************************************\ + +Function: goto_symext::rewrite_quantifiers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::rewrite_quantifiers(exprt &expr, statet &state) { if(expr.id()==ID_forall) @@ -98,7 +143,18 @@ void goto_symext::rewrite_quantifiers(exprt &expr, statet &state) } } -/// symex from given state +/*******************************************************************\ + +Function: goto_symext::operator() + + Inputs: + + Outputs: + + Purpose: symex from given state + +\*******************************************************************/ + void goto_symext::operator()( statet &state, const goto_functionst &goto_functions, @@ -134,7 +190,18 @@ void goto_symext::operator()( state.dirty=0; } -/// symex starting from given program +/*******************************************************************\ + +Function: goto_symext::operator() + + Inputs: + + Outputs: + + Purpose: symex starting from given program + +\*******************************************************************/ + void goto_symext::operator()( const goto_functionst &goto_functions, const goto_programt &goto_program) @@ -143,7 +210,18 @@ void goto_symext::operator()( operator() (state, goto_functions, goto_program); } -/// symex from entry point +/*******************************************************************\ + +Function: goto_symext::operator() + + Inputs: + + Outputs: + + Purpose: symex from entry point + +\*******************************************************************/ + void goto_symext::operator()(const goto_functionst &goto_functions) { goto_functionst::function_mapt::const_iterator it= @@ -157,7 +235,18 @@ void goto_symext::operator()(const goto_functionst &goto_functions) operator()(goto_functions, body); } -/// do just one step +/*******************************************************************\ + +Function: goto_symext::symex_step + + Inputs: + + Outputs: + + Purpose: do just one step + +\*******************************************************************/ + void goto_symext::symex_step( const goto_functionst &goto_functions, statet &state) diff --git a/src/goto-symex/symex_other.cpp b/src/goto-symex/symex_other.cpp index 73e913aa098..315447093ea 100644 --- a/src/goto-symex/symex_other.cpp +++ b/src/goto-symex/symex_other.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_other + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_other( const goto_functionst &goto_functions, statet &state) diff --git a/src/goto-symex/symex_slice_class.h b/src/goto-symex/symex_slice_class.h index 413a0bdc472..c669ded9ed2 100644 --- a/src/goto-symex/symex_slice_class.h +++ b/src/goto-symex/symex_slice_class.h @@ -6,15 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Slicer for symex traces - #ifndef CPROVER_GOTO_SYMEX_SYMEX_SLICE_CLASS_H #define CPROVER_GOTO_SYMEX_SYMEX_SLICE_CLASS_H #include "symex_target_equation.h" #include "slice.h" +/*******************************************************************\ + + Class: symex_slicet + + Purpose: + +\*******************************************************************/ + class symex_slicet { public: diff --git a/src/goto-symex/symex_start_thread.cpp b/src/goto-symex/symex_start_thread.cpp index e5891d79242..67cb147964c 100644 --- a/src/goto-symex/symex_start_thread.cpp +++ b/src/goto-symex/symex_start_thread.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_start_thread + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_start_thread(statet &state) { if(state.guard.is_false()) diff --git a/src/goto-symex/symex_target.cpp b/src/goto-symex/symex_target.cpp index cc03c29eaad..808ec3d2004 100644 --- a/src/goto-symex/symex_target.cpp +++ b/src/goto-symex/symex_target.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include "symex_target.h" +/*******************************************************************\ + +Function: operator < + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool operator<( const symex_targett::sourcet &a, const symex_targett::sourcet &b) diff --git a/src/goto-symex/symex_target.h b/src/goto-symex/symex_target.h index 24a8daee0e2..2aae977f71f 100644 --- a/src/goto-symex/symex_target.h +++ b/src/goto-symex/symex_target.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Generate Equation using Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_H #define CPROVER_GOTO_SYMEX_SYMEX_TARGET_H diff --git a/src/goto-symex/symex_target_equation.cpp b/src/goto-symex/symex_target_equation.cpp index 7b1ff044622..e522affb3ac 100644 --- a/src/goto-symex/symex_target_equation.cpp +++ b/src/goto-symex/symex_target_equation.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include @@ -21,16 +18,51 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_symex_state.h" #include "symex_target_equation.h" +/*******************************************************************\ + +Function: symex_target_equationt::symex_target_equationt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_target_equationt::symex_target_equationt( const namespacet &_ns):ns(_ns) { } +/*******************************************************************\ + +Function: symex_target_equationt::~symex_target_equationt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_target_equationt::~symex_target_equationt() { } -/// read from a shared variable +/*******************************************************************\ + +Function: symex_target_equationt::shared_read + + Inputs: + + Outputs: + + Purpose: read from a shared variable + +\*******************************************************************/ + void symex_target_equationt::shared_read( const exprt &guard, const ssa_exprt &ssa_object, @@ -49,7 +81,18 @@ void symex_target_equationt::shared_read( merge_ireps(SSA_step); } -/// write to a sharedvariable +/*******************************************************************\ + +Function: symex_target_equationt::shared_write + + Inputs: + + Outputs: + + Purpose: write to a sharedvariable + +\*******************************************************************/ + void symex_target_equationt::shared_write( const exprt &guard, const ssa_exprt &ssa_object, @@ -68,7 +111,18 @@ void symex_target_equationt::shared_write( merge_ireps(SSA_step); } -/// spawn a new thread +/*******************************************************************\ + +Function: symex_target_equationt::spawn + + Inputs: + + Outputs: + + Purpose: spawn a new thread + +\*******************************************************************/ + void symex_target_equationt::spawn( const exprt &guard, const sourcet &source) @@ -82,6 +136,18 @@ void symex_target_equationt::spawn( merge_ireps(SSA_step); } +/*******************************************************************\ + +Function: symex_target_equationt::memory_barrier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_target_equationt::memory_barrier( const exprt &guard, const sourcet &source) @@ -95,7 +161,18 @@ void symex_target_equationt::memory_barrier( merge_ireps(SSA_step); } -/// start an atomic section +/*******************************************************************\ + +Function: symex_target_equationt::atomic_begin + + Inputs: + + Outputs: + + Purpose: start an atomic section + +\*******************************************************************/ + void symex_target_equationt::atomic_begin( const exprt &guard, unsigned atomic_section_id, @@ -111,7 +188,18 @@ void symex_target_equationt::atomic_begin( merge_ireps(SSA_step); } -/// end an atomic section +/*******************************************************************\ + +Function: symex_target_equationt::atomic_end + + Inputs: + + Outputs: + + Purpose: end an atomic section + +\*******************************************************************/ + void symex_target_equationt::atomic_end( const exprt &guard, unsigned atomic_section_id, @@ -127,7 +215,18 @@ void symex_target_equationt::atomic_end( merge_ireps(SSA_step); } -/// write to a variable +/*******************************************************************\ + +Function: symex_target_equationt::assignment + + Inputs: + + Outputs: + + Purpose: write to a variable + +\*******************************************************************/ + void symex_target_equationt::assignment( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -158,7 +257,18 @@ void symex_target_equationt::assignment( merge_ireps(SSA_step); } -/// declare a fresh variable +/*******************************************************************\ + +Function: symex_target_equationt::decl + + Inputs: + + Outputs: + + Purpose: declare a fresh variable + +\*******************************************************************/ + void symex_target_equationt::decl( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -185,7 +295,18 @@ void symex_target_equationt::decl( merge_ireps(SSA_step); } -/// declare a fresh variable +/*******************************************************************\ + +Function: symex_target_equationt::dead + + Inputs: + + Outputs: + + Purpose: declare a fresh variable + +\*******************************************************************/ + void symex_target_equationt::dead( const exprt &guard, const ssa_exprt &ssa_lhs, @@ -194,7 +315,18 @@ void symex_target_equationt::dead( // we currently don't record these } -/// just record a location +/*******************************************************************\ + +Function: symex_target_equationt::location + + Inputs: + + Outputs: + + Purpose: just record a location + +\*******************************************************************/ + void symex_target_equationt::location( const exprt &guard, const sourcet &source) @@ -209,7 +341,18 @@ void symex_target_equationt::location( merge_ireps(SSA_step); } -/// just record a location +/*******************************************************************\ + +Function: symex_target_equationt::function_call + + Inputs: + + Outputs: + + Purpose: just record a location + +\*******************************************************************/ + void symex_target_equationt::function_call( const exprt &guard, const irep_idt &identifier, @@ -226,7 +369,18 @@ void symex_target_equationt::function_call( merge_ireps(SSA_step); } -/// just record a location +/*******************************************************************\ + +Function: symex_target_equationt::function_return + + Inputs: + + Outputs: + + Purpose: just record a location + +\*******************************************************************/ + void symex_target_equationt::function_return( const exprt &guard, const irep_idt &identifier, @@ -243,7 +397,18 @@ void symex_target_equationt::function_return( merge_ireps(SSA_step); } -/// just record output +/*******************************************************************\ + +Function: symex_target_equationt::output + + Inputs: + + Outputs: + + Purpose: just record output + +\*******************************************************************/ + void symex_target_equationt::output( const exprt &guard, const sourcet &source, @@ -262,7 +427,18 @@ void symex_target_equationt::output( merge_ireps(SSA_step); } -/// just record formatted output +/*******************************************************************\ + +Function: symex_target_equationt::output_fmt + + Inputs: + + Outputs: + + Purpose: just record formatted output + +\*******************************************************************/ + void symex_target_equationt::output_fmt( const exprt &guard, const sourcet &source, @@ -284,7 +460,18 @@ void symex_target_equationt::output_fmt( merge_ireps(SSA_step); } -/// just record input +/*******************************************************************\ + +Function: symex_target_equationt::input + + Inputs: + + Outputs: + + Purpose: just record input + +\*******************************************************************/ + void symex_target_equationt::input( const exprt &guard, const sourcet &source, @@ -303,7 +490,18 @@ void symex_target_equationt::input( merge_ireps(SSA_step); } -/// record an assumption +/*******************************************************************\ + +Function: symex_target_equationt::assumption + + Inputs: + + Outputs: + + Purpose: record an assumption + +\*******************************************************************/ + void symex_target_equationt::assumption( const exprt &guard, const exprt &cond, @@ -320,7 +518,18 @@ void symex_target_equationt::assumption( merge_ireps(SSA_step); } -/// record an assertion +/*******************************************************************\ + +Function: symex_target_equationt::assertion + + Inputs: + + Outputs: + + Purpose: record an assertion + +\*******************************************************************/ + void symex_target_equationt::assertion( const exprt &guard, const exprt &cond, @@ -339,7 +548,18 @@ void symex_target_equationt::assertion( merge_ireps(SSA_step); } -/// record a goto instruction +/*******************************************************************\ + +Function: symex_target_equationt::goto_instruction + + Inputs: + + Outputs: + + Purpose: record a goto instruction + +\*******************************************************************/ + void symex_target_equationt::goto_instruction( const exprt &guard, const exprt &cond, @@ -356,7 +576,18 @@ void symex_target_equationt::goto_instruction( merge_ireps(SSA_step); } -/// record a constraint +/*******************************************************************\ + +Function: symex_target_equationt::constraint + + Inputs: + + Outputs: + + Purpose: record a constraint + +\*******************************************************************/ + void symex_target_equationt::constraint( const exprt &cond, const std::string &msg, @@ -375,6 +606,18 @@ void symex_target_equationt::constraint( merge_ireps(SSA_step); } +/*******************************************************************\ + +Function: symex_target_equationt::convert + + Inputs: converter + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_target_equationt::convert( prop_convt &prop_conv) { @@ -388,9 +631,18 @@ void symex_target_equationt::convert( convert_constraints(prop_conv); } -/// converts assignments -/// \par parameters: decision procedure -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_assignments + + Inputs: decision procedure + + Outputs: - + + Purpose: converts assignments + +\*******************************************************************/ + void symex_target_equationt::convert_assignments( decision_proceduret &decision_procedure) const { @@ -401,8 +653,18 @@ void symex_target_equationt::convert_assignments( } } -/// converts declarations -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_decls + + Inputs: converter + + Outputs: - + + Purpose: converts declarations + +\*******************************************************************/ + void symex_target_equationt::convert_decls( prop_convt &prop_conv) const { @@ -417,8 +679,18 @@ void symex_target_equationt::convert_decls( } } -/// converts guards -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_guards + + Inputs: converter + + Outputs: - + + Purpose: converts guards + +\*******************************************************************/ + void symex_target_equationt::convert_guards( prop_convt &prop_conv) { @@ -431,8 +703,18 @@ void symex_target_equationt::convert_guards( } } -/// converts assumptions -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_assumptions + + Inputs: converter + + Outputs: - + + Purpose: converts assumptions + +\*******************************************************************/ + void symex_target_equationt::convert_assumptions( prop_convt &prop_conv) { @@ -448,8 +730,18 @@ void symex_target_equationt::convert_assumptions( } } -/// converts goto instructions -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_goto_instructions + + Inputs: converter + + Outputs: - + + Purpose: converts goto instructions + +\*******************************************************************/ + void symex_target_equationt::convert_goto_instructions( prop_convt &prop_conv) { @@ -465,9 +757,18 @@ void symex_target_equationt::convert_goto_instructions( } } -/// converts constraints -/// \par parameters: decision procedure -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_constraints + + Inputs: decision procedure + + Outputs: - + + Purpose: converts constraints + +\*******************************************************************/ + void symex_target_equationt::convert_constraints( decision_proceduret &decision_procedure) const { @@ -483,8 +784,18 @@ void symex_target_equationt::convert_constraints( } } -/// converts assertions -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_assertions + + Inputs: converter + + Outputs: - + + Purpose: converts assertions + +\*******************************************************************/ + void symex_target_equationt::convert_assertions( prop_convt &prop_conv) { @@ -550,9 +861,18 @@ void symex_target_equationt::convert_assertions( prop_conv.set_to_true(disjunction(disjuncts)); } -/// converts I/O -/// \par parameters: decision procedure -/// \return - +/*******************************************************************\ + +Function: symex_target_equationt::convert_io + + Inputs: decision procedure + + Outputs: - + + Purpose: converts I/O + +\*******************************************************************/ + void symex_target_equationt::convert_io( decision_proceduret &dec_proc) { @@ -583,6 +903,18 @@ void symex_target_equationt::convert_io( } +/*******************************************************************\ + +Function: symex_target_equationt::merge_ireps + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_target_equationt::merge_ireps(SSA_stept &SSA_step) { merge_irep(SSA_step.guard); @@ -600,6 +932,18 @@ void symex_target_equationt::merge_ireps(SSA_stept &SSA_step) // converted_io_args is merged in convert_io } +/*******************************************************************\ + +Function: symex_target_equationt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_target_equationt::output(std::ostream &out) const { for(const auto &step : SSA_steps) @@ -609,6 +953,18 @@ void symex_target_equationt::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: symex_target_equationt::SSA_stept::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_target_equationt::SSA_stept::output( const namespacet &ns, std::ostream &out) const @@ -703,6 +1059,18 @@ void symex_target_equationt::SSA_stept::output( out << "Guard: " << from_expr(ns, "", guard) << std::endl; } +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<( std::ostream &out, const symex_target_equationt &equation) @@ -711,6 +1079,18 @@ std::ostream &operator<<( return out; } +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<( std::ostream &out, const symex_target_equationt::SSA_stept &step) diff --git a/src/goto-symex/symex_target_equation.h b/src/goto-symex/symex_target_equation.h index abee81346a7..e7f0274aac1 100644 --- a/src/goto-symex/symex_target_equation.h +++ b/src/goto-symex/symex_target_equation.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Generate Equation using Symbolic Execution - #ifndef CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H #define CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H diff --git a/src/goto-symex/symex_throw.cpp b/src/goto-symex/symex_throw.cpp index a29ce901440..e5091c566f2 100644 --- a/src/goto-symex/symex_throw.cpp +++ b/src/goto-symex/symex_throw.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include "goto_symex.h" +/*******************************************************************\ + +Function: goto_symext::symex_throw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_symext::symex_throw(statet &state) { #if 0 diff --git a/src/java_bytecode/character_refine_preprocess.cpp b/src/java_bytecode/character_refine_preprocess.cpp index 8c0723599d5..f4e896eea11 100644 --- a/src/java_bytecode/character_refine_preprocess.cpp +++ b/src/java_bytecode/character_refine_preprocess.cpp @@ -9,17 +9,22 @@ Date: March 2017 \*******************************************************************/ -/// \file -/// Preprocess a goto-programs so that calls to the java Character library are -/// replaced by simple expressions. - #include #include #include "character_refine_preprocess.h" -/// converts based on a function on expressions -/// \param expr_function: A reference to a function on expressions -/// \param target: A position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_function + + Inputs: + expr_function - A reference to a function on expressions + target - A position in a goto program + + Purpose: converts based on a function on expressions + +\*******************************************************************/ + codet character_refine_preprocesst::convert_char_function( exprt (*expr_function)(const exprt &chr, const typet &type), conversion_inputt &target) @@ -32,12 +37,22 @@ codet character_refine_preprocesst::convert_char_function( return code_assignt(result, expr_function(arg, type)); } -/// The returned expression is true when the first argument is in the interval -/// defined by the lower and upper bounds (included) -/// \param arg: Expression we want to bound -/// \param lower_bound: Integer lower bound -/// \param upper_bound: Integer upper bound -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::in_interval_expr + + Inputs: + arg - Expression we want to bound + lower_bound - Integer lower bound + upper_bound - Integer upper bound + + Outputs: A Boolean expression + + Purpose: The returned expression is true when the first argument is in the + interval defined by the lower and upper bounds (included) + +\*******************************************************************/ + exprt character_refine_preprocesst::in_interval_expr( const exprt &chr, const mp_integer &lower_bound, @@ -48,11 +63,21 @@ exprt character_refine_preprocesst::in_interval_expr( binary_relation_exprt(chr, ID_le, from_integer(upper_bound, chr.type()))); } -/// The returned expression is true when the given character is equal to one of -/// the element in the list -/// \param chr: An expression of type character -/// \param list: A list of integer representing unicode characters -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::in_list_expr + + Inputs: + chr - An expression of type character + list - A list of integer representing unicode characters + + Outputs: A Boolean expression + + Purpose: The returned expression is true when the given character + is equal to one of the element in the list + +\*******************************************************************/ + exprt character_refine_preprocesst::in_list_expr( const exprt &chr, const std::list &list) { @@ -62,11 +87,21 @@ exprt character_refine_preprocesst::in_list_expr( return disjunction(ops); } -/// Determines the number of char values needed to represent the specified -/// character (Unicode code point). -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A integer expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_char_count + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A integer expression of the given type + + Purpose: Determines the number of char values needed to represent + the specified character (Unicode code point). + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_char_count( const exprt &chr, const typet &type) { @@ -75,9 +110,18 @@ exprt character_refine_preprocesst::expr_of_char_count( return if_exprt(small, from_integer(1, type), from_integer(2, type)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.charCount:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_count + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.charCount:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_char_count( conversion_inputt &target) { @@ -85,17 +129,37 @@ codet character_refine_preprocesst::convert_char_count( &character_refine_preprocesst::expr_of_char_count, target); } -/// Casts the given expression to the given type -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_char_value + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Casts the given expression to the given type + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_char_value( const exprt &chr, const typet &type) { return typecast_exprt(chr, type); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.charValue:()C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_value + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.charValue:()C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_char_value( conversion_inputt &target) { @@ -103,9 +167,18 @@ codet character_refine_preprocesst::convert_char_value( &character_refine_preprocesst::expr_of_char_value, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.compare:(CC)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_compare + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.compare:(CC)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_compare(conversion_inputt &target) { const code_function_callt &function_call=target; @@ -125,9 +198,18 @@ codet character_refine_preprocesst::convert_compare(conversion_inputt &target) } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.digit:(CI)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.digit:(CI)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_digit_char( conversion_inputt &target) { @@ -199,19 +281,37 @@ codet character_refine_preprocesst::convert_digit_char( return code_assignt(result, tc_expr); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.digit:(II)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_is_digit_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.digit:(II)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_digit_int(conversion_inputt &target) { return convert_digit_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.forDigit:(II)C -/// -/// TODO: For now the radix argument is ignored -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_for_digit + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.forDigit:(II)C + + TODO: For now the radix argument is ignored + +\*******************************************************************/ + codet character_refine_preprocesst::convert_for_digit(conversion_inputt &target) { const code_function_callt &function_call=target; @@ -228,9 +328,18 @@ codet character_refine_preprocesst::convert_for_digit(conversion_inputt &target) return code_assignt(result, if_exprt(small, value1, value2)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getDirectionality:(C)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_get_directionality_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getDirectionality:(C)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_directionality_char( conversion_inputt &target) { @@ -239,39 +348,75 @@ codet character_refine_preprocesst::convert_get_directionality_char( return target; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getDirectionality:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_is_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getDirectionality:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_directionality_int( conversion_inputt &target) { return convert_get_directionality_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getNumericValue:(C)I -/// -/// TODO: For now this is only for ASCII characters +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_get_numeric_value_char + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getNumericValue:(C)I + + TODO: For now this is only for ASCII characters + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_numeric_value_char( conversion_inputt &target) { return convert_digit_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getNumericValue:(C)I -/// -/// TODO: For now this is only for ASCII characters -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_get_numeric_value_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getNumericValue:(C)I + + TODO: For now this is only for ASCII characters + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_numeric_value_int( conversion_inputt &target) { return convert_digit_int(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getType:(C)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_get_type_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getType:(C)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_type_char( conversion_inputt &target) { @@ -280,29 +425,58 @@ codet character_refine_preprocesst::convert_get_type_char( return target; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.getType:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_get_type_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.getType:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_get_type_int( conversion_inputt &target) { return convert_get_type_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.hashCode:()I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_hash_code + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.hashCode:()I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_hash_code(conversion_inputt &target) { return convert_char_value(target); } -/// Returns the leading surrogate (a high surrogate code unit) of the surrogate -/// pair representing the specified supplementary character (Unicode code point) -/// in the UTF-16 encoding. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_high_surrogate + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Returns the leading surrogate (a high surrogate code unit) + of the surrogate pair representing the specified + supplementary character (Unicode code point) in the UTF-16 + encoding. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_high_surrogate( const exprt &chr, const typet &type) { @@ -314,8 +488,17 @@ exprt character_refine_preprocesst::expr_of_high_surrogate( return high_surrogate; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.highSurrogate:(C)Z +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_high_surrogate + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.highSurrogate:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_high_surrogate( conversion_inputt &target) { @@ -323,34 +506,66 @@ codet character_refine_preprocesst::convert_high_surrogate( &character_refine_preprocesst::expr_of_high_surrogate, target); } -/// Determines if the specified character is an ASCII lowercase character. -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_ascii_lower_case + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is an ASCII lowercase + character. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_ascii_lower_case( const exprt &chr, const typet &type) { return in_interval_expr(chr, 'a', 'z'); } -/// Determines if the specified character is an ASCII uppercase character. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_ascii_upper_case + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is an ASCII uppercase + character. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_ascii_upper_case( const exprt &chr, const typet &type) { return in_interval_expr(chr, 'A', 'Z'); } -/// Determines if the specified character is a letter. -/// -/// TODO: for now this is only for ASCII characters, the -/// following unicode categories are not yet considered: -/// TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_letter + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines if the specified character is a letter. + + TODO: for now this is only for ASCII characters, the + following unicode categories are not yet considered: + TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_letter( const exprt &chr, const typet &type) { @@ -359,25 +574,45 @@ exprt character_refine_preprocesst::expr_of_is_letter( expr_of_is_ascii_lower_case(chr, type)); } -/// Determines if the specified character (Unicode code point) is alphabetic. -/// -/// TODO: for now this is only for ASCII characters, the -/// following unicode categorise are not yet considered: -/// TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER -/// and contributory property Other_Alphabetic as defined by the -/// Unicode Standard. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_alphabetic + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines if the specified character (Unicode code point) + is alphabetic. + + TODO: for now this is only for ASCII characters, the + following unicode categorise are not yet considered: + TITLECASE_LETTER MODIFIER_LETTER OTHER_LETTER LETTER_NUMBER + and contributory property Other_Alphabetic as defined by the + Unicode Standard. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_alphabetic( const exprt &chr, const typet &type) { return expr_of_is_letter(chr, type); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isAlphabetic:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_alphabetic + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isAlphabetic:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_alphabetic( conversion_inputt &target) { @@ -385,12 +620,22 @@ codet character_refine_preprocesst::convert_is_alphabetic( &character_refine_preprocesst::expr_of_is_alphabetic, target); } -/// Determines whether the specified character (Unicode code point) is in the -/// Basic Multilingual Plane (BMP). Such code points can be represented using a -/// single char. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_bmp_code_point + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines whether the specified character (Unicode code + point) is in the Basic Multilingual Plane (BMP). Such code + points can be represented using a single char. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_bmp_code_point( const exprt &chr, const typet &type) { @@ -398,9 +643,18 @@ exprt character_refine_preprocesst::expr_of_is_bmp_code_point( return is_bmp; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isBmpCodePoint:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_bmp_code_point + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isBmpCodePoint:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_bmp_code_point( conversion_inputt &target) { @@ -408,10 +662,20 @@ codet character_refine_preprocesst::convert_is_bmp_code_point( &character_refine_preprocesst::expr_of_is_bmp_code_point, target); } -/// Determines if a character is defined in Unicode. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_for_is_defined + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines if a character is defined in Unicode. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_defined( const exprt &chr, const typet &type) { @@ -443,9 +707,18 @@ exprt character_refine_preprocesst::expr_of_is_defined( return not_exprt(disjunction(intervals)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isDefined:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_defined_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isDefined:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_defined_char( conversion_inputt &target) { @@ -453,29 +726,48 @@ codet character_refine_preprocesst::convert_is_defined_char( &character_refine_preprocesst::expr_of_is_defined, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isDefined:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_is_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isDefined:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_defined_int( conversion_inputt &target) { return convert_is_defined_char(target); } -/// Determines if the specified character is a digit. A character is a digit if -/// its general category type, provided by Character.getType(ch), is -/// DECIMAL_DIGIT_NUMBER. -/// -/// TODO: for now we only support these ranges of digits: -/// '\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9') -/// '\u0660' through '\u0669', Arabic-Indic digits -/// '\u06F0' through '\u06F9', Extended Arabic-Indic digits -/// '\u0966' through '\u096F', Devanagari digits -/// '\uFF10' through '\uFF19', Fullwidth digits -/// Many other character ranges contain digits as well. -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_digit + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines if the specified character is a digit. + A character is a digit if its general category type, + provided by Character.getType(ch), is DECIMAL_DIGIT_NUMBER. + + TODO: for now we only support these ranges of digits: + '\u0030' through '\u0039', ISO-LATIN-1 digits ('0' through '9') + '\u0660' through '\u0669', Arabic-Indic digits + '\u06F0' through '\u06F9', Extended Arabic-Indic digits + '\u0966' through '\u096F', Devanagari digits + '\uFF10' through '\uFF19', Fullwidth digits + Many other character ranges contain digits as well. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_digit( const exprt &chr, const typet &type) { @@ -490,9 +782,18 @@ exprt character_refine_preprocesst::expr_of_is_digit( return digit; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isDigit:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isDigit:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_digit_char( conversion_inputt &target) { @@ -500,44 +801,85 @@ codet character_refine_preprocesst::convert_is_digit_char( &character_refine_preprocesst::expr_of_is_digit, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.digit:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_digit_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.digit:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_digit_int( conversion_inputt &target) { return convert_is_digit_char(target); } -/// Determines if the given char value is a Unicode high-surrogate code unit -/// (also known as leading-surrogate code unit). -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_high_surrogate + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the given char value is a Unicode + high-surrogate code unit (also known as leading-surrogate + code unit). + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_high_surrogate( const exprt &chr, const typet &type) { return in_interval_expr(chr, 0xD800, 0xDBFF); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isHighSurrogate:(C)Z -/// \param target: a position in a goto program -codet character_refine_preprocesst::convert_is_high_surrogate( +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_high_surrogate + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isHighSurrogate:(C)Z + +\*******************************************************************/ + +codet character_refine_preprocesst::convert_is_high_surrogate( conversion_inputt &target) { return convert_char_function( &character_refine_preprocesst::expr_of_is_high_surrogate, target); } -/// Determines if the character is one of ignorable in a Java identifier, that -/// is, it is in one of these ranges: '\u0000' through '\u0008' '\u000E' through -/// '\u001B' '\u007F' through '\u009F' -/// -/// TODO: For now, we ignore the FORMAT general category value -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_identifier_ignorable + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the character is one of ignorable in a Java + identifier, that is, it is in one of these ranges: + '\u0000' through '\u0008' + '\u000E' through '\u001B' + '\u007F' through '\u009F' + + TODO: For now, we ignore the FORMAT general category value + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_identifier_ignorable( const exprt &chr, const typet &type) { @@ -549,11 +891,21 @@ exprt character_refine_preprocesst::expr_of_is_identifier_ignorable( return ignorable; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isIdentifierIgnorable:(C)Z -/// -/// TODO: For now, we ignore the FORMAT general category value -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_identifier_ignorable_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isIdentifierIgnorable:(C)Z + + TODO: For now, we ignore the FORMAT general category value + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_identifier_ignorable_char( conversion_inputt &target) { @@ -561,20 +913,39 @@ codet character_refine_preprocesst::convert_is_identifier_ignorable_char( &character_refine_preprocesst::expr_of_is_identifier_ignorable, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isIdentifierIgnorable:(I)Z -/// -/// TODO: For now, we ignore the FORMAT general category value -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_identifier_ignorable_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isIdentifierIgnorable:(I)Z + + TODO: For now, we ignore the FORMAT general category value + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_identifier_ignorable_int( conversion_inputt &target) { return convert_is_identifier_ignorable_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isIdeographic:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_ideographic + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isIdeographic:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_ideographic( conversion_inputt &target) { @@ -586,9 +957,18 @@ codet character_refine_preprocesst::convert_is_ideographic( return code_assignt(result, is_ideograph); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isISOControl:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_ISO_control_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isISOControl:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_ISO_control_char( conversion_inputt &target) { @@ -601,21 +981,39 @@ codet character_refine_preprocesst::convert_is_ISO_control_char( return code_assignt(result, iso); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isISOControl:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_ISO_control_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isISOControl:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_ISO_control_int( conversion_inputt &target) { return convert_is_ISO_control_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isJavaIdentifierPart:(C)Z -/// -/// TODO: For now we do not allow currency symbol, connecting punctuation, -/// combining mark, non-spacing mark -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_java_identifier_part_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isJavaIdentifierPart:(C)Z + + TODO: For now we do not allow currency symbol, connecting punctuation, + combining mark, non-spacing mark + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_identifier_part_char( conversion_inputt &target) { @@ -623,22 +1021,40 @@ codet character_refine_preprocesst::convert_is_java_identifier_part_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_part, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method isJavaIdentifierPart:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_java_identifier_part_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method isJavaIdentifierPart:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_identifier_part_int( conversion_inputt &target) { return convert_is_unicode_identifier_part_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method isJavaIdentifierStart:(C)Z -/// -/// TODO: For now we only allow letters and letter numbers. -/// The java specification for this function is not precise on the -/// other characters. -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_java_identifier_start_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method isJavaIdentifierStart:(C)Z + + TODO: For now we only allow letters and letter numbers. + The java specification for this function is not precise on the + other characters. + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_identifier_start_char( conversion_inputt &target) { @@ -646,36 +1062,72 @@ codet character_refine_preprocesst::convert_is_java_identifier_start_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_start, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method isJavaIdentifierStart:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_char_is_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method isJavaIdentifierStart:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_identifier_start_int( conversion_inputt &target) { return convert_is_java_identifier_start_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isJavaLetter:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_java_letter + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isJavaLetter:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_letter( conversion_inputt &target) { return convert_is_java_identifier_start_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method isJavaLetterOrDigit:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_java_letter_or_digit + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method isJavaLetterOrDigit:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_java_letter_or_digit( conversion_inputt &target) { return convert_is_java_identifier_part_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLetter:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_letter_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLetter:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_letter_char( conversion_inputt &target) { @@ -683,28 +1135,56 @@ codet character_refine_preprocesst::convert_is_letter_char( &character_refine_preprocesst::expr_of_is_letter, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLetter:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_letter_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLetter:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_letter_int( conversion_inputt &target) { return convert_is_letter_char(target); } -/// Determines if the specified character is a letter or digit. -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_letter_or_digit + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines if the specified character is a letter or digit. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_letter_or_digit( const exprt &chr, const typet &type) { return or_exprt(expr_of_is_letter(chr, type), expr_of_is_digit(chr, type)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLetterOrDigit:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_letter_or_digit_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLetterOrDigit:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_letter_or_digit_char( conversion_inputt &target) { @@ -712,20 +1192,38 @@ codet character_refine_preprocesst::convert_is_letter_or_digit_char( &character_refine_preprocesst::expr_of_is_digit, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLetterOrDigit:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_letter_or_digit_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLetterOrDigit:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_letter_or_digit_int( conversion_inputt &target) { return convert_is_letter_or_digit_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLowerCase:(C)Z -/// -/// TODO: For now we only consider ASCII characters -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_lower_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLowerCase:(C)Z + + TODO: For now we only consider ASCII characters + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_lower_case_char( conversion_inputt &target) { @@ -733,20 +1231,38 @@ codet character_refine_preprocesst::convert_is_lower_case_char( &character_refine_preprocesst::expr_of_is_ascii_lower_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLowerCase:(I)Z -/// -/// TODO: For now we only consider ASCII characters -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_lower_case_int() + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLowerCase:(I)Z + + TODO: For now we only consider ASCII characters + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_lower_case_int( conversion_inputt &target) { return convert_is_lower_case_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isLowSurrogate:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_low_surrogate + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isLowSurrogate:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_low_surrogate( conversion_inputt &target) { @@ -758,24 +1274,43 @@ codet character_refine_preprocesst::convert_is_low_surrogate( return code_assignt(result, is_low_surrogate); } -/// Determines whether the character is mirrored according to the Unicode -/// specification. -/// -/// TODO: For now only ASCII characters are considered -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_mirrored + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Determines whether the character is mirrored according to + the Unicode specification. + + TODO: For now only ASCII characters are considered + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_mirrored( const exprt &chr, const typet &type) { return in_list_expr(chr, {0x28, 0x29, 0x3C, 0x3E, 0x5B, 0x5D, 0x7B, 0x7D}); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isMirrored:(C)Z -/// -/// TODO: For now only ASCII characters are considered -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_mirrored_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isMirrored:(C)Z + + TODO: For now only ASCII characters are considered + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_mirrored_char( conversion_inputt &target) { @@ -783,30 +1318,59 @@ codet character_refine_preprocesst::convert_is_mirrored_char( &character_refine_preprocesst::expr_of_is_mirrored, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isMirrored:(I)Z -/// -/// TODO: For now only ASCII characters are considered -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_mirrored_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isMirrored:(I)Z + + TODO: For now only ASCII characters are considered + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_mirrored_int( conversion_inputt &target) { return convert_is_mirrored_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSpace:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_space + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isSpace:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_space(conversion_inputt &target) { return convert_is_whitespace_char(target); } -/// Determines if the specified character is white space according to Unicode -/// (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_space_char + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is white space + according to Unicode (SPACE_SEPARATOR, LINE_SEPARATOR, or + PARAGRAPH_SEPARATOR) + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_space_char( const exprt &chr, const typet &type) { @@ -817,9 +1381,18 @@ exprt character_refine_preprocesst::expr_of_is_space_char( return or_exprt(condition0, condition1); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSpaceChar:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_space_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isSpaceChar:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_space_char( conversion_inputt &target) { @@ -827,29 +1400,58 @@ codet character_refine_preprocesst::convert_is_space_char( &character_refine_preprocesst::expr_of_is_space_char, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSpaceChar:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_space_char_int() + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isSpaceChar:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_space_char_int( conversion_inputt &target) { return convert_is_space_char(target); } -/// Determines whether the specified character (Unicode code point) is in the -/// supplementary character range. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_supplementary_code_point + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines whether the specified character (Unicode code + point) is in the supplementary character range. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_supplementary_code_point( const exprt &chr, const typet &type) { return binary_relation_exprt(chr, ID_gt, from_integer(0xFFFF, chr.type())); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSupplementaryCodePoint:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_supplementary_code_point + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isSupplementaryCodePoint:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_supplementary_code_point( conversion_inputt &target) { @@ -857,19 +1459,39 @@ codet character_refine_preprocesst::convert_is_supplementary_code_point( &character_refine_preprocesst::expr_of_is_supplementary_code_point, target); } -/// Determines if the given char value is a Unicode surrogate code unit. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_surrogate + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the given char value is a Unicode surrogate + code unit. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_surrogate( const exprt &chr, const typet &type) { return in_interval_expr(chr, 0xD800, 0xDFFF); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSurrogate:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_surrogate + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isSurrogate:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_surrogate( conversion_inputt &target) { @@ -877,9 +1499,18 @@ codet character_refine_preprocesst::convert_is_surrogate( &character_refine_preprocesst::expr_of_is_surrogate, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isSurrogatePair:(CC)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_surrogate_pair + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isSurrogatePair:(CC)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_surrogate_pair( conversion_inputt &target) { @@ -893,10 +1524,20 @@ codet character_refine_preprocesst::convert_is_surrogate_pair( return code_assignt(result, and_exprt(is_high_surrogate, is_low_surrogate)); } -/// Determines if the specified character is a titlecase character. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_title_case + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is a titlecase character. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_title_case( const exprt &chr, const typet &type) { @@ -910,9 +1551,18 @@ exprt character_refine_preprocesst::expr_of_is_title_case( return disjunction(conditions); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isTitleCase:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_title_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isTitleCase:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_title_case_char( conversion_inputt &target) { @@ -920,20 +1570,39 @@ codet character_refine_preprocesst::convert_is_title_case_char( &character_refine_preprocesst::expr_of_is_title_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isTitleCase:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_title_case_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isTitleCase:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_title_case_int( conversion_inputt &target) { return convert_is_title_case_char(target); } -/// Determines if the specified character is in the LETTER_NUMBER category of -/// Unicode -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_letter_number + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is in the LETTER_NUMBER + category of Unicode + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_letter_number( const exprt &chr, const typet &type) { @@ -954,13 +1623,23 @@ exprt character_refine_preprocesst::expr_of_is_letter_number( } -/// Determines if the character may be part of a Unicode identifier. -/// -/// TODO: For now we do not allow connecting punctuation, combining mark, -/// non-spacing mark -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_unicode_identifier_part + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the character may be part of a Unicode identifier. + + TODO: For now we do not allow connecting punctuation, combining mark, + non-spacing mark + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_unicode_identifier_part( const exprt &chr, const typet &type) { @@ -971,9 +1650,19 @@ exprt character_refine_preprocesst::expr_of_is_unicode_identifier_part( return disjunction(conditions); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUnicodeIdentifierPart:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_unicode_identifier_part_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isUnicodeIdentifierPart:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_unicode_identifier_part_char( conversion_inputt &target) { @@ -981,20 +1670,40 @@ codet character_refine_preprocesst::convert_is_unicode_identifier_part_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_part, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUnicodeIdentifierPart:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_unicode_identifier_part_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isUnicodeIdentifierPart:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_unicode_identifier_part_int( conversion_inputt &target) { return convert_is_unicode_identifier_part_char(target); } -/// Determines if the specified character is permissible as the first character -/// in a Unicode identifier. -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_unicode_identifier_start + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is permissible as the + first character in a Unicode identifier. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_unicode_identifier_start( const exprt &chr, const typet &type) { @@ -1002,9 +1711,19 @@ exprt character_refine_preprocesst::expr_of_is_unicode_identifier_start( expr_of_is_letter(chr, type), expr_of_is_letter_number(chr, type)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUnicodeIdentifierStart:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_unicode_identifier_start_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isUnicodeIdentifierStart:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_unicode_identifier_start_char( conversion_inputt &target) { @@ -1012,20 +1731,39 @@ codet character_refine_preprocesst::convert_is_unicode_identifier_start_char( &character_refine_preprocesst::expr_of_is_unicode_identifier_start, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUnicodeIdentifierStart:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_unicode_identifier_start_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method + Character.isUnicodeIdentifierStart:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_unicode_identifier_start_int( conversion_inputt &target) { return convert_is_unicode_identifier_start_char(target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUpperCase:(C)Z -/// -/// TODO: For now we only consider ASCII characters -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_upper_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isUpperCase:(C)Z + + TODO: For now we only consider ASCII characters + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_upper_case_char( conversion_inputt &target) { @@ -1033,29 +1771,58 @@ codet character_refine_preprocesst::convert_is_upper_case_char( &character_refine_preprocesst::expr_of_is_ascii_upper_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isUpperCase:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_upper_case_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isUpperCase:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_upper_case_int( conversion_inputt &target) { return convert_is_upper_case_char(target); } -/// Determines whether the specified code point is a valid Unicode code point -/// value. That is, in the range of integers from 0 to 0x10FFFF -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_valid_code_point + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines whether the specified code point is a valid + Unicode code point value. + That is, in the range of integers from 0 to 0x10FFFF + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_valid_code_point( const exprt &chr, const typet &type) { return binary_relation_exprt(chr, ID_le, from_integer(0x10FFFF, chr.type())); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isValidCodePoint:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_valid_code_point + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isValidCodePoint:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_valid_code_point( conversion_inputt &target) { @@ -1063,14 +1830,26 @@ codet character_refine_preprocesst::convert_is_valid_code_point( &character_refine_preprocesst::expr_of_is_valid_code_point, target); } -/// Determines if the specified character is white space according to Java. It -/// is the case when it one of the following: * a Unicode space character -/// (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a -/// non-breaking space ('\u00A0', '\u2007', '\u202F'). * it is one of these: -/// U+0009 U+000A U+000B U+000C U+000D U+001C U+001D U+001E U+001F -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A Boolean expression +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_is_whitespace + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A Boolean expression + + Purpose: Determines if the specified character is white space according + to Java. It is the case when it one of the following: + * a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or + PARAGRAPH_SEPARATOR) but is not also a non-breaking space + ('\u00A0', '\u2007', '\u202F'). + * it is one of these: U+0009 U+000A U+000B U+000C U+000D + U+001C U+001D U+001E U+001F + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_is_whitespace( const exprt &chr, const typet &type) { @@ -1085,9 +1864,18 @@ exprt character_refine_preprocesst::expr_of_is_whitespace( return disjunction(conditions); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isWhitespace:(C)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_whitespace_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isWhitespace:(C)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_whitespace_char( conversion_inputt &target) { @@ -1095,21 +1883,41 @@ codet character_refine_preprocesst::convert_is_whitespace_char( &character_refine_preprocesst::expr_of_is_whitespace, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.isWhitespace:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_is_whitespace_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.isWhitespace:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_is_whitespace_int( conversion_inputt &target) { return convert_is_whitespace_char(target); } -/// Returns the trailing surrogate (a low surrogate code unit) of the surrogate -/// pair representing the specified supplementary character (Unicode code point) -/// in the UTF-16 encoding. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A integer expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_low_surrogate + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A integer expression of the given type + + Purpose: Returns the trailing surrogate (a low surrogate code unit) + of the surrogate pair representing the specified + supplementary character (Unicode code point) in the UTF-16 + encoding. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_low_surrogate( const exprt &chr, const typet &type) { @@ -1118,9 +1926,18 @@ exprt character_refine_preprocesst::expr_of_low_surrogate( return plus_exprt(uDC00, mod_exprt(chr, u0400)); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.lowSurrogate:(I)Z -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_low_surrogate + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.lowSurrogate:(I)Z + +\*******************************************************************/ + codet character_refine_preprocesst::convert_low_surrogate( conversion_inputt &target) { @@ -1128,11 +1945,21 @@ codet character_refine_preprocesst::convert_low_surrogate( &character_refine_preprocesst::expr_of_low_surrogate, target); } -/// Returns the value obtained by reversing the order of the bytes in the -/// specified char value. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A character expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_reverse_bytes + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A character expression of the given type + + Purpose: Returns the value obtained by reversing the order of the + bytes in the specified char value. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_reverse_bytes( const exprt &chr, const typet &type) { @@ -1141,9 +1968,18 @@ exprt character_refine_preprocesst::expr_of_reverse_bytes( return plus_exprt(first_byte, second_byte); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.reverseBytes:(C)C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_reverse_bytes + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.reverseBytes:(C)C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_reverse_bytes( conversion_inputt &target) { @@ -1151,14 +1987,26 @@ codet character_refine_preprocesst::convert_reverse_bytes( &character_refine_preprocesst::expr_of_reverse_bytes, target); } -/// Converts the specified character (Unicode code point) to its UTF-16 -/// representation stored in a char array. If the specified code point is a BMP -/// (Basic Multilingual Plane or Plane 0) value, the resulting char array has -/// the same value as codePoint. If the specified code point is a supplementary -/// code point, the resulting char array has the corresponding surrogate pair. -/// \param expr: An expression of type character -/// \param type: A type for the output -/// \return A character array expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_to_chars + + Inputs: + expr - An expression of type character + type - A type for the output + + Outputs: A character array expression of the given type + + Purpose: Converts the specified character (Unicode code point) to + its UTF-16 representation stored in a char array. + If the specified code point is a BMP (Basic Multilingual + Plane or Plane 0) value, the resulting char array has the + same value as codePoint. + If the specified code point is a supplementary code point, + the resulting char array has the corresponding surrogate pair. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_to_chars( const exprt &chr, const typet &type) { @@ -1174,18 +2022,36 @@ exprt character_refine_preprocesst::expr_of_to_chars( return if_exprt(expr_of_is_bmp_code_point(chr, type), case1, case2); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toChars:(I)[C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_chars + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toChars:(I)[C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_chars(conversion_inputt &target) { return convert_char_function( &character_refine_preprocesst::expr_of_to_chars, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toCodePoint:(CC)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_code_point + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toCodePoint:(CC)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_code_point( conversion_inputt &target) { @@ -1211,14 +2077,24 @@ codet character_refine_preprocesst::convert_to_code_point( return code_assignt(result, pair_value); } -/// Converts the character argument to lowercase. -/// -/// TODO: For now we only consider ASCII characters but ultimately -/// we should use case mapping information from the -/// UnicodeData file -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_to_lower_case + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Converts the character argument to lowercase. + + TODO: For now we only consider ASCII characters but ultimately + we should use case mapping information from the + UnicodeData file + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_to_lower_case( const exprt &chr, const typet &type) { @@ -1229,9 +2105,18 @@ exprt character_refine_preprocesst::expr_of_to_lower_case( return res; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toLowerCase:(C)C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_lower_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toLowerCase:(C)C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_lower_case_char( conversion_inputt &target) { @@ -1239,19 +2124,38 @@ codet character_refine_preprocesst::convert_to_lower_case_char( &character_refine_preprocesst::expr_of_to_lower_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toLowerCase:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_lower_case_int() + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toLowerCase:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_lower_case_int( conversion_inputt &target) { return convert_to_lower_case_char(target); } -/// Converts the character argument to titlecase. -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_to_title_case + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Converts the character argument to titlecase. + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_to_title_case( const exprt &chr, const typet &type) { @@ -1285,9 +2189,18 @@ exprt character_refine_preprocesst::expr_of_to_title_case( return res; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toTitleCase:(C)C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_title_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toTitleCase:(C)C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_title_case_char( conversion_inputt &target) { @@ -1295,23 +2208,42 @@ codet character_refine_preprocesst::convert_to_title_case_char( &character_refine_preprocesst::expr_of_to_title_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toTitleCase:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_title_case_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toTitleCase:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_title_case_int( conversion_inputt &target) { return convert_to_title_case_char(target); } -/// Converts the character argument to uppercase. -/// -/// TODO: For now we only consider ASCII characters but ultimately -/// we should use case mapping information from the -/// UnicodeData file -/// \param chr: An expression of type character -/// \param type: A type for the output -/// \return An expression of the given type +/*******************************************************************\ + +Function: character_refine_preprocesst::expr_of_to_upper_case + + Inputs: + chr - An expression of type character + type - A type for the output + + Outputs: An expression of the given type + + Purpose: Converts the character argument to uppercase. + + TODO: For now we only consider ASCII characters but ultimately + we should use case mapping information from the + UnicodeData file + +\*******************************************************************/ + exprt character_refine_preprocesst::expr_of_to_upper_case( const exprt &chr, const typet &type) { @@ -1322,9 +2254,18 @@ exprt character_refine_preprocesst::expr_of_to_upper_case( return res; } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toUpperCase:(C)C -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_upper_case_char + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toUpperCase:(C)C + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_upper_case_char( conversion_inputt &target) { @@ -1332,21 +2273,41 @@ codet character_refine_preprocesst::convert_to_upper_case_char( &character_refine_preprocesst::expr_of_to_upper_case, target); } -/// Converts function call to an assignment of an expression corresponding to -/// the java method Character.toUpperCase:(I)I -/// \param target: a position in a goto program +/*******************************************************************\ + +Function: character_refine_preprocesst::convert_to_upper_case_int + + Inputs: + target - a position in a goto program + + Purpose: Converts function call to an assignment of an expression + corresponding to the java method Character.toUpperCase:(I)I + +\*******************************************************************/ + codet character_refine_preprocesst::convert_to_upper_case_int( conversion_inputt &target) { return convert_to_upper_case_char(target); } -/// replace function calls to functions of the Character by an affectation if -/// possible, returns the same code otherwise. For this method to have an effect -/// initialize_conversion_table must have been called before. -/// \param code: the code of a function call -/// \return code where character function call get replaced by an simple -/// instruction +/*******************************************************************\ + +Function: character_refine_preprocesst::replace_character_call + + Inputs: + code - the code of a function call + + Outputs: code where character function call get replaced by + an simple instruction + + Purpose: replace function calls to functions of the Character by + an affectation if possible, returns the same code otherwise. + For this method to have an effect initialize_conversion_table + must have been called before. + +\*******************************************************************/ + codet character_refine_preprocesst::replace_character_call( const code_function_callt &code) const { @@ -1362,7 +2323,15 @@ codet character_refine_preprocesst::replace_character_call( return code; } -/// fill maps with correspondance from java method names to conversion functions +/*******************************************************************\ + +Function: character_refine_preprocesst::initialize_conversion_table + + Purpose: fill maps with correspondance from java method names to + conversion functions + +\*******************************************************************/ + void character_refine_preprocesst::initialize_conversion_table() { // All methods are listed here in alphabetic order diff --git a/src/java_bytecode/character_refine_preprocess.h b/src/java_bytecode/character_refine_preprocess.h index 2f41b2ec932..45f76a5d5b6 100644 --- a/src/java_bytecode/character_refine_preprocess.h +++ b/src/java_bytecode/character_refine_preprocess.h @@ -11,12 +11,6 @@ Date: March 2017 \*******************************************************************/ -/// \file -/// Preprocess a goto-programs so that calls to the java Character library are -/// replaced by simple expressions. For now support is limited to character in -/// the ASCII range, some methods may have incorrect specifications outside of -/// this range. - #ifndef CPROVER_JAVA_BYTECODE_CHARACTER_REFINE_PREPROCESS_H #define CPROVER_JAVA_BYTECODE_CHARACTER_REFINE_PREPROCESS_H diff --git a/src/java_bytecode/ci_lazy_methods.cpp b/src/java_bytecode/ci_lazy_methods.cpp index dc71b1c0cd1..5cafa74ac73 100644 --- a/src/java_bytecode/ci_lazy_methods.cpp +++ b/src/java_bytecode/ci_lazy_methods.cpp @@ -6,28 +6,42 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Context-insensitive lazy methods container - #include #include "ci_lazy_methods.h" -/// Notes `method_symbol_name` is referenced from some reachable function, and -/// should therefore be elaborated. -/// \par parameters: `method_symbol_name`: method name; must exist in symbol -/// table. +/*******************************************************************\ + +Function: ci_lazy_methodst::add_needed_method + + Inputs: `method_symbol_name`: method name; must exist in symbol table. + + Outputs: + + Purpose: Notes `method_symbol_name` is referenced from some reachable + function, and should therefore be elaborated. + +\*******************************************************************/ + void ci_lazy_methodst::add_needed_method(const irep_idt &method_symbol_name) { needed_methods.push_back(method_symbol_name); } -/// Notes class `class_symbol_name` will be instantiated, or a static field -/// belonging to it will be accessed. Also notes that its static initializer is -/// therefore reachable. -/// \par parameters: `class_symbol_name`: class name; must exist in symbol -/// table. -/// \return Returns true if `class_symbol_name` is new (not seen before). +/*******************************************************************\ + +Function: java_bytecode_parsert::parse + + Inputs: `class_symbol_name`: class name; must exist in symbol table. + + Outputs: Returns true if `class_symbol_name` is new (not seen before). + + Purpose: Notes class `class_symbol_name` will be instantiated, or + a static field belonging to it will be accessed. Also notes + that its static initializer is therefore reachable. + +\*******************************************************************/ + bool ci_lazy_methodst::add_needed_class(const irep_idt &class_symbol_name) { if(!needed_classes.insert(class_symbol_name).second) diff --git a/src/java_bytecode/ci_lazy_methods.h b/src/java_bytecode/ci_lazy_methods.h index e64a3f2467c..54c4664c694 100644 --- a/src/java_bytecode/ci_lazy_methods.h +++ b/src/java_bytecode/ci_lazy_methods.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Context-insensitive lazy methods container - #ifndef CPROVER_JAVA_BYTECODE_CI_LAZY_METHODS_H #define CPROVER_JAVA_BYTECODE_CI_LAZY_METHODS_H diff --git a/src/java_bytecode/expr2java.cpp b/src/java_bytecode/expr2java.cpp index 4ea68803020..e5a1d921bfa 100644 --- a/src/java_bytecode/expr2java.cpp +++ b/src/java_bytecode/expr2java.cpp @@ -21,6 +21,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "java_types.h" #include "expr2java.h" +/*******************************************************************\ + +Function: expr2javat::convert_code_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_code_function_call( const code_function_callt &src, unsigned indent) @@ -91,6 +103,18 @@ std::string expr2javat::convert_code_function_call( return dest; } +/*******************************************************************\ + +Function: expr2javat::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_struct( const exprt &src, unsigned &precedence) @@ -155,6 +179,18 @@ std::string expr2javat::convert_struct( return dest; } +/*******************************************************************\ + +Function: expr2javat::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_constant( const constant_exprt &src, unsigned &precedence) @@ -238,6 +274,18 @@ std::string expr2javat::convert_constant( return expr2ct::convert_constant(src, precedence); } +/*******************************************************************\ + +Function: expr2javat::convert_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_rec( const typet &src, const c_qualifierst &qualifiers, @@ -312,6 +360,18 @@ std::string expr2javat::convert_rec( return expr2ct::convert_rec(src, qualifiers, declarator); } +/*******************************************************************\ + +Function: expr2javat::convert_java_this + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_java_this( const exprt &src, unsigned precedence) @@ -319,6 +379,18 @@ std::string expr2javat::convert_java_this( return "this"; } +/*******************************************************************\ + +Function: expr2javat::convert_java_instanceof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_java_instanceof( const exprt &src, unsigned precedence) @@ -332,6 +404,18 @@ std::string expr2javat::convert_java_instanceof( return convert(src.op0())+" instanceof "+convert(src.op1().type()); } +/*******************************************************************\ + +Function: expr2javat::convert_java_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_java_new( const exprt &src, unsigned precedence) @@ -357,6 +441,18 @@ std::string expr2javat::convert_java_new( return dest; } +/*******************************************************************\ + +Function: expr2javat::convert_code_java_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_code_java_delete( const exprt &src, unsigned indent) @@ -376,6 +472,18 @@ std::string expr2javat::convert_code_java_delete( return dest; } +/*******************************************************************\ + +Function: expr2javat::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_with_precedence( const exprt &src, unsigned &precedence) @@ -411,6 +519,18 @@ std::string expr2javat::convert_with_precedence( return expr2ct::convert_with_precedence(src, precedence); } +/*******************************************************************\ + +Function: expr2javat::convert_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2javat::convert_code( const codet &src, unsigned indent) @@ -427,6 +547,18 @@ std::string expr2javat::convert_code( return expr2ct::convert_code(src, indent); } +/*******************************************************************\ + +Function: expr2java + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2java(const exprt &expr, const namespacet &ns) { expr2javat expr2java(ns); @@ -434,6 +566,18 @@ std::string expr2java(const exprt &expr, const namespacet &ns) return expr2java.convert(expr); } +/*******************************************************************\ + +Function: type2java + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2java(const typet &type, const namespacet &ns) { expr2javat expr2java(ns); diff --git a/src/java_bytecode/jar_file.cpp b/src/java_bytecode/jar_file.cpp index ecfd759932e..ee08a50838a 100644 --- a/src/java_bytecode/jar_file.cpp +++ b/src/java_bytecode/jar_file.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "jar_file.h" +/*******************************************************************\ + +Function: jar_filet::open + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jar_filet::open( java_class_loader_limitt &class_loader_limit, const std::string &filename) @@ -56,6 +68,18 @@ void jar_filet::open( } } +/*******************************************************************\ + +Function: jar_filet::~jar_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + jar_filet::~jar_filet() { if(mz_ok) @@ -65,6 +89,18 @@ jar_filet::~jar_filet() } } +/*******************************************************************\ + +Function: jar_filet::get_entry + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string jar_filet::get_entry(const irep_idt &name) { if(!mz_ok) @@ -94,6 +130,18 @@ std::string jar_filet::get_entry(const irep_idt &name) return dest; } +/*******************************************************************\ + +Function: jar_filet::get_manifest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + jar_filet::manifestt jar_filet::get_manifest() { auto entry=filtered_jar.find("META-INF/MANIFEST.MF"); diff --git a/src/java_bytecode/jar_file.h b/src/java_bytecode/jar_file.h index 819acf336fd..3ecdfc80d0f 100644 --- a/src/java_bytecode/jar_file.h +++ b/src/java_bytecode/jar_file.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAR File Reading - #ifndef CPROVER_JAVA_BYTECODE_JAR_FILE_H #define CPROVER_JAVA_BYTECODE_JAR_FILE_H diff --git a/src/java_bytecode/java_bytecode_convert_class.cpp b/src/java_bytecode/java_bytecode_convert_class.cpp index e68409c1d49..c92c016bd02 100644 --- a/src/java_bytecode/java_bytecode_convert_class.cpp +++ b/src/java_bytecode/java_bytecode_convert_class.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Conversion - #ifdef DEBUG #include #endif @@ -77,6 +74,18 @@ class java_bytecode_convert_classt:public messaget void add_array_types(); }; +/*******************************************************************\ + +Function: java_bytecode_convert_classt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_classt::convert(const classt &c) { std::string qualified_classname="java::"+id2string(c.name); @@ -162,6 +171,18 @@ void java_bytecode_convert_classt::convert(const classt &c) java_root_class(*class_symbol); } +/*******************************************************************\ + +Function: java_bytecode_convert_classt::generate_class_stub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_classt::generate_class_stub( const irep_idt &class_name) { @@ -196,6 +217,18 @@ void java_bytecode_convert_classt::generate_class_stub( } } +/*******************************************************************\ + +Function: java_bytecode_convert_classt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_classt::convert( symbolt &class_symbol, const fieldt &f) @@ -257,6 +290,18 @@ void java_bytecode_convert_classt::convert( } } +/*******************************************************************\ + +Function: java_bytecode_convert_classt::add_array_types + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_classt::add_array_types() { const std::string letters="ijsbcfdza"; @@ -414,6 +459,18 @@ void java_bytecode_convert_classt::add_array_types() } } +/*******************************************************************\ + +Function: java_bytecode_convert_class + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_convert_class( const java_bytecode_parse_treet &parse_tree, symbol_tablet &symbol_table, diff --git a/src/java_bytecode/java_bytecode_convert_class.h b/src/java_bytecode/java_bytecode_convert_class.h index 60fd9ad4fdd..b3b71426b1d 100644 --- a/src/java_bytecode/java_bytecode_convert_class.h +++ b/src/java_bytecode/java_bytecode_convert_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Conversion - #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_CLASS_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_CLASS_H diff --git a/src/java_bytecode/java_bytecode_convert_method.cpp b/src/java_bytecode/java_bytecode_convert_method.cpp index 654f3bfae94..181176dfbaa 100644 --- a/src/java_bytecode/java_bytecode_convert_method.cpp +++ b/src/java_bytecode/java_bytecode_convert_method.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Conversion - #ifdef DEBUG #include #endif @@ -61,14 +58,24 @@ class patternt const char *p; }; -/// See above -/// \par parameters: `ftype`: Function type whose parameters should be named -/// `name_prefix`: Prefix for parameter names, typically the parent function's -/// name. -/// `symbol_table`: Global symbol table -/// \return Assigns parameter names (side-effects on `ftype`) to function stub -/// parameters, which are initially nameless as method conversion hasn't -/// happened. Also creates symbols in `symbol_table`. +/*******************************************************************\ + +Function: assign_parameter_names + + Inputs: `ftype`: Function type whose parameters should be named + `name_prefix`: Prefix for parameter names, typically the + parent function's name. + `symbol_table`: Global symbol table + + Outputs: Assigns parameter names (side-effects on `ftype`) to + function stub parameters, which are initially nameless + as method conversion hasn't happened. + Also creates symbols in `symbol_table`. + + Purpose: See above + +\*******************************************************************/ + void assign_parameter_names( code_typet &ftype, const irep_idt &name_prefix, @@ -154,7 +161,18 @@ exprt::operandst java_bytecode_convert_methodt::pop(std::size_t n) return operands; } -/// removes minimum(n, stack.size()) elements from the stack +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::pop_residue + +Inputs: + +Outputs: + +Purpose: removes minimum(n, stack.size()) elements from the stack + +\*******************************************************************/ + void java_bytecode_convert_methodt::pop_residue(std::size_t n) { std::size_t residue_size=std::min(n, stack.size()); @@ -234,14 +252,25 @@ const exprt java_bytecode_convert_methodt::variable( } } -/// This creates a method symbol in the symtab, but doesn't actually perform -/// method conversion just yet. The caller should call -/// java_bytecode_convert_method later to give the symbol/method a body. -/// \par parameters: `class_symbol`: class this method belongs to -/// `method_identifier`: fully qualified method name, including type signature -/// (e.g. "x.y.z.f:(I)") -/// `m`: parsed method object to convert -/// `symbol_table`: global symbol table (will be modified) +/*******************************************************************\ + +Function: java_bytecode_convert_method_lazy + + Inputs: `class_symbol`: class this method belongs to + `method_identifier`: fully qualified method name, including + type signature (e.g. "x.y.z.f:(I)") + `m`: parsed method object to convert + `symbol_table`: global symbol table (will be modified) + + Outputs: + + Purpose: This creates a method symbol in the symtab, but doesn't + actually perform method conversion just yet. The caller + should call java_bytecode_convert_method later to give the + symbol/method a body. + +\*******************************************************************/ + void java_bytecode_convert_method_lazy( const symbolt &class_symbol, const irep_idt &method_identifier, @@ -293,6 +322,18 @@ void java_bytecode_convert_method_lazy( symbol_table.add(method_symbol); } +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_methodt::convert( const symbolt &class_symbol, const methodt &m) @@ -444,6 +485,18 @@ void java_bytecode_convert_methodt::convert( symbol_table.add(method_symbol); } +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::get_bytecode_info + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const bytecode_infot &java_bytecode_convert_methodt::get_bytecode_info( const irep_idt &statement) { @@ -518,12 +571,20 @@ codet java_bytecode_convert_methodt::get_array_bounds_check( return bounds_checks; } -/// Find all goto statements in 'repl' that target 'old_label' and redirect them -/// to 'new_label'. -/// \par parameters: 'repl', a block of code in which to perform replacement, -/// and -/// an old_label that should be replaced throughout by new_label. -/// \return None (side-effects on repl) +/*******************************************************************\ + +Function: replace_goto_target + + Inputs: 'repl', a block of code in which to perform replacement, and + an old_label that should be replaced throughout by new_label. + + Outputs: None (side-effects on repl) + + Purpose: Find all goto statements in 'repl' that target 'old_label' + and redirect them to 'new_label'. + +\*******************************************************************/ + void java_bytecode_convert_methodt::replace_goto_target( codet &repl, const irep_idt &old_label, @@ -544,20 +605,27 @@ void java_bytecode_convert_methodt::replace_goto_target( } } -/// 'tree' describes a tree of code_blockt objects; this_block is the -/// corresponding block (thus they are both trees with the same shape). The -/// caller is looking for the single block in the tree that most closely -/// encloses bytecode address range [address_start,address_limit). -/// 'next_block_start_address' is the start address of 'tree's successor sibling -/// and is used to determine when the range spans out of its bounds. -/// \par parameters: 'tree', a code block descriptor, and 'this_block', the -/// corresponding -/// actual code_blockt. 'address_start' and 'address_limit', the Java -/// bytecode offsets searched for. 'next_block_start_address', the -/// bytecode offset of tree/this_block's successor sibling, or UINT_MAX -/// if none exists. -/// \return Returns the code_blockt most closely enclosing the given address -/// range. +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::get_block_for_pcrange + + Inputs: 'tree', a code block descriptor, and 'this_block', the corresponding + actual code_blockt. 'address_start' and 'address_limit', the Java + bytecode offsets searched for. 'next_block_start_address', the + bytecode offset of tree/this_block's successor sibling, or UINT_MAX + if none exists. + + Outputs: Returns the code_blockt most closely enclosing the given address range. + + Purpose: 'tree' describes a tree of code_blockt objects; this_block is the + corresponding block (thus they are both trees with the same shape). + The caller is looking for the single block in the tree that most + closely encloses bytecode address range [address_start,address_limit). + 'next_block_start_address' is the start address of 'tree's successor + sibling and is used to determine when the range spans out of its bounds. + +\*******************************************************************/ + code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange( block_tree_nodet &tree, code_blockt &this_block, @@ -576,20 +644,29 @@ code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange( false); } -/// As above, but this version can additionally create a new branch in the -/// block_tree-node and code_blockt trees to envelop the requested address -/// range. For example, if the tree was initially flat, with nodes (1-10), -/// (11-20), (21-30) and the caller asked for range 13-28, this would build a -/// surrounding tree node, leaving the tree of shape (1-10), ^( (11-20), (21-30) -/// )^, and return a reference to the new branch highlighted with ^^. 'tree' and -/// 'this_block' trees are always maintained with equal shapes. ('this_block' -/// may additionally contain code_declt children which are ignored for this -/// purpose) -/// \par parameters: See above, plus the bytecode address map 'amap' and -/// 'allow_merge' -/// which is always true except when called from get_block_for_pcrange -/// \return See above, plus potential side-effects on 'tree' and 'this_block' as -/// descibed in 'Purpose' +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::get_or_create_block_for_pcrange + + Inputs: See above, plus the bytecode address map 'amap' and 'allow_merge' + which is always true except when called from get_block_for_pcrange + + Outputs: See above, plus potential side-effects on 'tree' and 'this_block' + as descibed in 'Purpose' + + Purpose: As above, but this version can additionally create a new branch + in the block_tree-node and code_blockt trees to envelop the requested + address range. For example, if the tree was initially flat, with + nodes (1-10), (11-20), (21-30) and the caller asked for range 13-28, + this would build a surrounding tree node, leaving the tree of shape + (1-10), ^( (11-20), (21-30) )^, and return a reference to the + new branch highlighted with ^^. + 'tree' and 'this_block' trees are always maintained with equal + shapes. ('this_block' may additionally contain code_declt children + which are ignored for this purpose) + +\*******************************************************************/ + code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange( block_tree_nodet &tree, code_blockt &this_block, @@ -807,11 +884,20 @@ static void gather_symbol_live_ranges( } } -/// See above -/// \par parameters: `se`: Symbol expression referring to a static field -/// `basename`: The static field's basename -/// \return Creates a symbol table entry for the static field if one doesn't -/// exist already. +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::check_static_field_stub + + Inputs: `se`: Symbol expression referring to a static field + `basename`: The static field's basename + + Outputs: Creates a symbol table entry for the static field if one + doesn't exist already. + + Purpose: See above + +\*******************************************************************/ + void java_bytecode_convert_methodt::check_static_field_stub( const symbol_exprt &symbol_expr, const irep_idt &basename) @@ -835,11 +921,20 @@ void java_bytecode_convert_methodt::check_static_field_stub( } } -/// Determine whether a `new` or static access against `classname` should be -/// prefixed with a static initialization check. -/// \param classname: Class name -/// \return Returns true if the given class or one of its parents has a static -/// initializer +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::class_needs_clinit + + Inputs: classname: Class name + + Outputs: Returns true if the given class or one of its parents + has a static initializer + + Purpose: Determine whether a `new` or static access against `classname` + should be prefixed with a static initialization check. + +\*******************************************************************/ + bool java_bytecode_convert_methodt::class_needs_clinit( const irep_idt &classname) { @@ -877,13 +972,22 @@ bool java_bytecode_convert_methodt::class_needs_clinit( return false; } -/// Create a ::clinit_wrapper the first time a static initializer might be -/// called. The wrapper method checks whether static init has already taken -/// place, calls the actual method if not, and initializes super- -/// classes and interfaces. -/// \param classname: Class name -/// \return Returns a symbol_exprt pointing to the given class' clinit wrapper -/// if one is required, or nil otherwise. +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::get_or_create_clinit_wrapper + + Inputs: classname: Class name + + Outputs: Returns a symbol_exprt pointing to the given class' clinit + wrapper if one is required, or nil otherwise. + + Purpose: Create a ::clinit_wrapper the first time a static initializer + might be called. The wrapper method checks whether static init + has already taken place, calls the actual method if + not, and initializes super-classes and interfaces. + +\*******************************************************************/ + exprt java_bytecode_convert_methodt::get_or_create_clinit_wrapper( const irep_idt &classname) { @@ -959,11 +1063,21 @@ exprt java_bytecode_convert_methodt::get_or_create_clinit_wrapper( return wrapper_method_symbol.symbol_expr(); } -/// Each static access to classname should be prefixed with a check for -/// necessary static init; this returns a call implementing that check. -/// \param classname: Class name -/// \return Returns a function call to the given class' static initializer -/// wrapper if one is needed, or a skip instruction otherwise. +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::get_clinit_call + + Inputs: classname: Class name + + Outputs: Returns a function call to the given class' static initializer + wrapper if one is needed, or a skip instruction otherwise. + + Purpose: Each static access to classname should be prefixed with a check + for necessary static init; this returns a call implementing + that check. + +\*******************************************************************/ + codet java_bytecode_convert_methodt::get_clinit_call( const irep_idt &classname) { @@ -975,6 +1089,18 @@ codet java_bytecode_convert_methodt::get_clinit_call( return ret; } +/*******************************************************************\ + +Function: get_bytecode_type_width + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static unsigned get_bytecode_type_width(const typet &ty) { if(ty.id()==ID_pointer) @@ -982,6 +1108,18 @@ static unsigned get_bytecode_type_width(const typet &ty) return ty.get_unsigned_int(ID_width); } +/*******************************************************************\ + +Function: java_bytecode_convert_methodt::convert_instructions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + codet java_bytecode_convert_methodt::convert_instructions( const methodt &method, const code_typet &method_type, @@ -2595,6 +2733,18 @@ codet java_bytecode_convert_methodt::convert_instructions( return code; } +/*******************************************************************\ + +Function: java_bytecode_convert_method + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_convert_method( const symbolt &class_symbol, const java_bytecode_parse_treet::methodt &method, diff --git a/src/java_bytecode/java_bytecode_convert_method.h b/src/java_bytecode/java_bytecode_convert_method.h index ba0926e301a..43c1cdec380 100644 --- a/src/java_bytecode/java_bytecode_convert_method.h +++ b/src/java_bytecode/java_bytecode_convert_method.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Conversion - #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_H diff --git a/src/java_bytecode/java_bytecode_convert_method_class.h b/src/java_bytecode/java_bytecode_convert_method_class.h index 17393900c64..61299ff31d3 100644 --- a/src/java_bytecode/java_bytecode_convert_method_class.h +++ b/src/java_bytecode/java_bytecode_convert_method_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Conversion - #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_CLASS_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_METHOD_CLASS_H diff --git a/src/java_bytecode/java_bytecode_internal_additions.cpp b/src/java_bytecode/java_bytecode_internal_additions.cpp index bae844d6532..c0d019a4cc4 100644 --- a/src/java_bytecode/java_bytecode_internal_additions.cpp +++ b/src/java_bytecode/java_bytecode_internal_additions.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_bytecode_internal_additions.h" +/*******************************************************************\ + +Function: java_internal_additions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_internal_additions(symbol_tablet &dest) { // add __CPROVER_rounding_mode diff --git a/src/java_bytecode/java_bytecode_language.cpp b/src/java_bytecode/java_bytecode_language.cpp index 6f90fd70cf7..c38b8d735fa 100644 --- a/src/java_bytecode/java_bytecode_language.cpp +++ b/src/java_bytecode/java_bytecode_language.cpp @@ -28,9 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr2java.h" -/// Consume options that are java bytecode specific. -/// \param Command:line options -/// \return None +/*******************************************************************\ + +Function: java_bytecode_languaget::get_language_options + + Inputs: Command-line options + + Outputs: None + + Purpose: Consume options that are java bytecode specific. + +\*******************************************************************/ + void java_bytecode_languaget::get_language_options(const cmdlinet &cmd) { assume_inputs_non_null=cmd.isset("java-assume-inputs-non-null"); @@ -78,17 +87,52 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd) java_cp_include_files=".*"; } +/*******************************************************************\ + +Function: java_bytecode_languaget::extensions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set java_bytecode_languaget::extensions() const { return { "class", "jar" }; } +/*******************************************************************\ + +Function: java_bytecode_languaget::modules_provided + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_languaget::modules_provided(std::set &modules) { // modules.insert(translation_unit(parse_path)); } -/// ANSI-C preprocessing +/*******************************************************************\ + +Function: java_bytecode_languaget::preprocess + + Inputs: + + Outputs: + + Purpose: ANSI-C preprocessing + +\*******************************************************************/ + bool java_bytecode_languaget::preprocess( std::istream &instream, const std::string &path, @@ -98,6 +142,18 @@ bool java_bytecode_languaget::preprocess( return true; } +/*******************************************************************\ + +Function: java_bytecode_languaget::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::parse( std::istream &instream, const std::string &path) @@ -152,18 +208,27 @@ bool java_bytecode_languaget::parse( return false; } -/// Find a virtual callee, if one is defined and the callee type is known to -/// exist. -/// \par parameters: `needed_classes`: set of classes that can be instantiated. -/// Any potential callee not in this set will be ignored. -/// `call_basename`: unqualified function name with type signature (e.g. -/// "f:(I)") -/// `classname`: class name that may define or override a function named -/// `call_basename`. -/// `symbol_table`: global symtab -/// \return Returns the fully qualified name of `classname`'s definition of -/// `call_basename` if found and `classname` is present in `needed_classes`, -/// or irep_idt() otherwise. +/*******************************************************************\ + +Function: get_virtual_method_target + + Inputs: `needed_classes`: set of classes that can be instantiated. + Any potential callee not in this set will be ignored. + `call_basename`: unqualified function name with type + signature (e.g. "f:(I)") + `classname`: class name that may define or override a + function named `call_basename`. + `symbol_table`: global symtab + + Outputs: Returns the fully qualified name of `classname`'s definition + of `call_basename` if found and `classname` is present in + `needed_classes`, or irep_idt() otherwise. + + Purpose: Find a virtual callee, if one is defined and the callee type + is known to exist. + +\*******************************************************************/ + static irep_idt get_virtual_method_target( const std::set &needed_classes, const irep_idt &call_basename, @@ -180,17 +245,27 @@ static irep_idt get_virtual_method_target( return irep_idt(); } -/// Find possible callees, excluding types that are not known to be -/// instantiated. -/// \par parameters: `c`: function call whose potential target functions should -/// be determined. -/// `needed_classes`: set of classes that can be instantiated. Any potential -/// callee not in this set will be ignored. -/// `symbol_table`: global symtab -/// `class_hierarchy`: global class hierarchy -/// \return Populates `needed_methods` with all possible `c` callees, taking -/// `needed_classes` into account (virtual function overrides defined on -/// classes that are not 'needed' are ignored) +/*******************************************************************\ + +Function: get_virtual_method_target + + Inputs: `c`: function call whose potential target functions should + be determined. + `needed_classes`: set of classes that can be instantiated. + Any potential callee not in this set will be ignored. + `symbol_table`: global symtab + `class_hierarchy`: global class hierarchy + + Outputs: Populates `needed_methods` with all possible `c` callees, + taking `needed_classes` into account (virtual function + overrides defined on classes that are not 'needed' are + ignored) + + Purpose: Find possible callees, excluding types that are not known + to be instantiated. + +\*******************************************************************/ + static void get_virtual_method_targets( const code_function_callt &c, const std::set &needed_classes, @@ -265,10 +340,19 @@ static void get_virtual_method_targets( } } -/// See output -/// \par parameters: `e`: expression tree to search -/// \return Populates `result` with pointers to each function call within e that -/// calls a virtual function. +/*******************************************************************\ + +Function: gather_virtual_callsites + + Inputs: `e`: expression tree to search + + Outputs: Populates `result` with pointers to each function call + within e that calls a virtual function. + + Purpose: See output + +\*******************************************************************/ + static void gather_virtual_callsites( const exprt &e, std::vector &result) @@ -284,11 +368,20 @@ static void gather_virtual_callsites( gather_virtual_callsites(*it, result); } -/// See output -/// \par parameters: `e`: expression tree to search -/// `symbol_table`: global symtab -/// \return Populates `needed` with global variable symbols referenced from `e` -/// or its children. +/*******************************************************************\ + +Function: gather_needed_globals + + Inputs: `e`: expression tree to search + `symbol_table`: global symtab + + Outputs: Populates `needed` with global variable symbols referenced + from `e` or its children. + + Purpose: See output + +\*******************************************************************/ + static void gather_needed_globals( const exprt &e, const symbol_tablet &symbol_table, @@ -312,13 +405,22 @@ static void gather_needed_globals( gather_needed_globals(*opit, symbol_table, needed); } -/// See output -/// \par parameters: `class_type`: root of class tree to search -/// `ns`: global namespace -/// \return Populates `lazy_methods` with all Java reference types reachable -/// starting at `class_type`. For example if `class_type` is -/// `symbol_typet("java::A")` and A has a B field, then `B` (but not `A`) will -/// noted as a needed class. +/*******************************************************************\ + +Function: gather_field_types + + Inputs: `class_type`: root of class tree to search + `ns`: global namespace + + Outputs: Populates `lazy_methods` with all Java reference types + reachable starting at `class_type`. For example if + `class_type` is `symbol_typet("java::A")` and A has a B + field, then `B` (but not `A`) will noted as a needed class. + + Purpose: See output + +\*******************************************************************/ + static void gather_field_types( const typet &class_type, const namespacet &ns, @@ -342,14 +444,23 @@ static void gather_field_types( } } -/// See output -/// \par parameters: `entry_points`: list of fully-qualified function names that -/// we should assume are reachable -/// `ns`: global namespace -/// `ch`: global class hierarchy -/// \return Populates `lazy_methods` with all Java reference types whose -/// references may be passed, directly or indirectly, to any of the functions -/// in `entry_points`. +/*******************************************************************\ + +Function: initialize_needed_classes + + Inputs: `entry_points`: list of fully-qualified function names that + we should assume are reachable + `ns`: global namespace + `ch`: global class hierarchy + + Outputs: Populates `lazy_methods` with all Java reference types + whose references may be passed, directly or indirectly, + to any of the functions in `entry_points`. + + Purpose: See output + +\*******************************************************************/ + static void initialize_needed_classes( const std::vector &entry_points, const namespacet &ns, @@ -384,6 +495,18 @@ static void initialize_needed_classes( lazy_methods.add_needed_class("java::java.lang.Object"); } +/*******************************************************************\ + +Function: java_bytecode_languaget::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -445,19 +568,32 @@ bool java_bytecode_languaget::typecheck( return false; } -/// Uses a simple context-insensitive ('ci') analysis to determine which methods -/// may be reachable from the main entry point. In brief, static methods are -/// reachable if we find a callsite in another reachable site, while virtual -/// methods are reachable if we find a virtual callsite targeting a compatible -/// type *and* a constructor callsite indicating an object of that type may be -/// instantiated (or evidence that an object of that type exists before the main -/// function is entered, such as being passed as a parameter). -/// \par parameters: `symbol_table`: global symbol table -/// `lazy_methods`: map from method names to relevant symbol and parsed-method -/// objects. -/// \return Elaborates lazily-converted methods that may be reachable starting -/// from the main entry point (usually provided with the --function command- -/// line option) (side-effect on the symbol_table). Returns false on success. +/*******************************************************************\ + +Function: java_bytecode_languaget::do_ci_lazy_method_conversion + + Inputs: `symbol_table`: global symbol table + `lazy_methods`: map from method names to relevant symbol + and parsed-method objects. + + Outputs: Elaborates lazily-converted methods that may be reachable + starting from the main entry point (usually provided with + the --function command-line option) (side-effect on the + symbol_table). Returns false on success. + + Purpose: Uses a simple context-insensitive ('ci') analysis to + determine which methods may be reachable from the main + entry point. In brief, static methods are reachable if we + find a callsite in another reachable site, while virtual + methods are reachable if we find a virtual callsite + targeting a compatible type *and* a constructor callsite + indicating an object of that type may be instantiated (or + evidence that an object of that type exists before the + main function is entered, such as being passed as a + parameter). + +\*******************************************************************/ + bool java_bytecode_languaget::do_ci_lazy_method_conversion( symbol_tablet &symbol_table, lazy_methodst &lazy_methods) @@ -604,11 +740,22 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion( return false; } -/// Provide feedback to `language_filest` so that when asked for a lazy method, -/// it can delegate to this instance of java_bytecode_languaget. -/// \return Populates `methods` with the complete list of lazy methods that are -/// available to convert (those which are valid parameters for -/// `convert_lazy_method`) +/*******************************************************************\ + +Function: java_bytecode_languaget::lazy_methods_provided + + Inputs: None + + Outputs: Populates `methods` with the complete list of lazy methods + that are available to convert (those which are valid + parameters for `convert_lazy_method`) + + Purpose: Provide feedback to `language_filest` so that when asked + for a lazy method, it can delegate to this instance of + java_bytecode_languaget. + +\*******************************************************************/ + void java_bytecode_languaget::lazy_methods_provided( std::set &methods) const { @@ -616,15 +763,26 @@ void java_bytecode_languaget::lazy_methods_provided( methods.insert(kv.first); } -/// Promote a lazy-converted method (one whose type is known but whose body -/// hasn't been converted) into a fully- elaborated one. -/// \par parameters: `id`: method ID to convert -/// `symtab`: global symbol table -/// \return Amends the symbol table entry for function `id`, which should be a -/// lazy method provided by this instance of `java_bytecode_languaget`. It -/// should initially have a nil value. After this method completes, it will -/// have a value representing the method body, identical to that produced -/// using eager method conversion. +/*******************************************************************\ + +Function: java_bytecode_languaget::convert_lazy_method + + Inputs: `id`: method ID to convert + `symtab`: global symbol table + + Outputs: Amends the symbol table entry for function `id`, which + should be a lazy method provided by this instance of + `java_bytecode_languaget`. It should initially have a nil + value. After this method completes, it will have a value + representing the method body, identical to that produced + using eager method conversion. + + Purpose: Promote a lazy-converted method (one whose type is known + but whose body hasn't been converted) into a fully- + elaborated one. + +\*******************************************************************/ + void java_bytecode_languaget::convert_lazy_method( const irep_idt &id, symbol_tablet &symtab) @@ -639,9 +797,18 @@ void java_bytecode_languaget::convert_lazy_method( string_preprocess); } -/// Replace methods of the String library that are in the symbol table by code -/// generated by string_preprocess. -/// \param context: a symbol table +/*******************************************************************\ + +Function: java_bytecode_languaget::replace_string_methods + + Inputs: + context - a symbol table + + Purpose: Replace methods of the String library that are in the symbol table + by code generated by string_preprocess. + +\*******************************************************************/ + void java_bytecode_languaget::replace_string_methods( symbol_tablet &context) { @@ -667,6 +834,18 @@ void java_bytecode_languaget::replace_string_methods( } } +/*******************************************************************\ + +Function: java_bytecode_languaget::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::final(symbol_tablet &symbol_table) { /* @@ -693,16 +872,52 @@ bool java_bytecode_languaget::final(symbol_tablet &symbol_table) max_nondet_array_length)); } +/*******************************************************************\ + +Function: java_bytecode_languaget::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_languaget::show_parse(std::ostream &out) { java_class_loader(main_class).output(out); } +/*******************************************************************\ + +Function: new_java_bytecode_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *new_java_bytecode_language() { return new java_bytecode_languaget; } +/*******************************************************************\ + +Function: java_bytecode_languaget::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::from_expr( const exprt &expr, std::string &code, @@ -712,6 +927,18 @@ bool java_bytecode_languaget::from_expr( return false; } +/*******************************************************************\ + +Function: java_bytecode_languaget::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::from_type( const typet &type, std::string &code, @@ -721,6 +948,18 @@ bool java_bytecode_languaget::from_type( return false; } +/*******************************************************************\ + +Function: java_bytecode_languaget::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_languaget::to_expr( const std::string &code, const std::string &module, @@ -768,6 +1007,18 @@ bool java_bytecode_languaget::to_expr( return true; // fail for now } +/*******************************************************************\ + +Function: java_bytecode_languaget::~java_bytecode_languaget + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + java_bytecode_languaget::~java_bytecode_languaget() { } diff --git a/src/java_bytecode/java_bytecode_parse_tree.cpp b/src/java_bytecode/java_bytecode_parse_tree.cpp index 325d6df9caf..63fb5674f85 100644 --- a/src/java_bytecode/java_bytecode_parse_tree.cpp +++ b/src/java_bytecode/java_bytecode_parse_tree.cpp @@ -17,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_bytecode_parse_tree.h" +/*******************************************************************\ + +Function: java_bytecode_parse_treet::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::classt::swap( classt &other) { @@ -31,6 +43,18 @@ void java_bytecode_parse_treet::classt::swap( other.annotations.swap(annotations); } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::classt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::output(std::ostream &out) const { parsed_class.output(out); @@ -42,6 +66,18 @@ void java_bytecode_parse_treet::output(std::ostream &out) const out << " " << *it << '\n'; } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::classt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::classt::output(std::ostream &out) const { for(const auto &annotation : annotations) @@ -77,6 +113,18 @@ void java_bytecode_parse_treet::classt::output(std::ostream &out) const out << '\n'; } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::annotationt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::annotationt::output(std::ostream &out) const { symbol_tablet symbol_table; @@ -102,6 +150,18 @@ void java_bytecode_parse_treet::annotationt::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::annotationt::element_value_pairt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::annotationt::element_value_pairt::output( std::ostream &out) const { @@ -112,6 +172,18 @@ void java_bytecode_parse_treet::annotationt::element_value_pairt::output( out << expr2java(value, ns); } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::methodt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::methodt::output(std::ostream &out) const { symbol_tablet symbol_table; @@ -191,6 +263,18 @@ void java_bytecode_parse_treet::methodt::output(std::ostream &out) const out << '\n'; } +/*******************************************************************\ + +Function: java_bytecode_parse_treet::fieldt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parse_treet::fieldt::output(std::ostream &out) const { for(const auto &annotation : annotations) diff --git a/src/java_bytecode/java_bytecode_parser.cpp b/src/java_bytecode/java_bytecode_parser.cpp index 5ec3f841270..dd458860c97 100644 --- a/src/java_bytecode/java_bytecode_parser.cpp +++ b/src/java_bytecode/java_bytecode_parser.cpp @@ -200,6 +200,18 @@ class java_bytecode_parsert:public parsert #define VTYPE_INFO_OBJECT 7 #define VTYPE_INFO_UNINIT 8 +/*******************************************************************\ + +Function: java_bytecode_parsert::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_parsert::parse() { try @@ -228,6 +240,18 @@ bool java_bytecode_parsert::parse() return false; } +/*******************************************************************\ + +Function: java_bytecode_parsert::rClassFile + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #define ACC_PUBLIC 0x0001 #define ACC_PRIVATE 0x0002 #define ACC_PROTECTED 0x0004 @@ -305,6 +329,18 @@ void java_bytecode_parsert::rClassFile() parse_tree.loading_successful=true; } +/*******************************************************************\ + +Function: java_bytecode_parsert::get_class_refs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::get_class_refs() { // Get the class references for the benefit of a dependency @@ -347,6 +383,18 @@ void java_bytecode_parsert::get_class_refs() } } +/*******************************************************************\ + +Function: java_bytecode_parsert::get_class_refs_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::get_class_refs_rec(const typet &src) { if(src.id()==ID_code) @@ -379,6 +427,18 @@ void java_bytecode_parsert::get_class_refs_rec(const typet &src) get_class_refs_rec(src.subtype()); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rconstant_pool + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rconstant_pool() { u2 constant_pool_count=read_u2(); @@ -598,6 +658,18 @@ void java_bytecode_parsert::rconstant_pool() } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rinterfaces + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rinterfaces(classt &parsed_class) { u2 interfaces_count=read_u2(); @@ -607,6 +679,18 @@ void java_bytecode_parsert::rinterfaces(classt &parsed_class) .push_back(constant(read_u2()).type().get(ID_C_base_name)); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rfields + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rfields(classt &parsed_class) { u2 fields_count=read_u2(); @@ -638,6 +722,18 @@ void java_bytecode_parsert::rfields(classt &parsed_class) } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rbytecode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #define T_BOOLEAN 4 #define T_CHAR 5 #define T_FLOAT 6 @@ -879,6 +975,18 @@ void java_bytecode_parsert::rbytecode( } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rmethod_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rmethod_attribute(methodt &method) { u2 attribute_name_index=read_u2(); @@ -947,6 +1055,18 @@ void java_bytecode_parsert::rmethod_attribute(methodt &method) skip_bytes(attribute_length); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rfield_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rfield_attribute(fieldt &field) { u2 attribute_name_index=read_u2(); @@ -963,6 +1083,18 @@ void java_bytecode_parsert::rfield_attribute(fieldt &field) skip_bytes(attribute_length); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rcode_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rcode_attribute(methodt &method) { u2 attribute_name_index=read_u2(); @@ -1167,6 +1299,18 @@ void java_bytecode_parsert::read_verification_type_info( } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rRuntimeAnnotation_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rRuntimeAnnotation_attribute( annotationst &annotations) { @@ -1180,6 +1324,18 @@ void java_bytecode_parsert::rRuntimeAnnotation_attribute( } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rRuntimeAnnotation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rRuntimeAnnotation( annotationt &annotation) { @@ -1188,6 +1344,18 @@ void java_bytecode_parsert::rRuntimeAnnotation( relement_value_pairs(annotation.element_value_pairs); } +/*******************************************************************\ + +Function: java_bytecode_parsert::relement_value_pairs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::relement_value_pairs( annotationt::element_value_pairst &element_value_pairs) { @@ -1203,6 +1371,18 @@ void java_bytecode_parsert::relement_value_pairs( } } +/*******************************************************************\ + +Function: java_bytecode_parsert::relement_value_pair + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::relement_value_pair( annotationt::element_value_pairt &element_value_pair) { @@ -1262,6 +1442,18 @@ void java_bytecode_parsert::relement_value_pair( } } +/*******************************************************************\ + +Function: java_bytecode_parsert::rclass_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rclass_attribute(classt &parsed_class) { u2 attribute_name_index=read_u2(); @@ -1310,6 +1502,18 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class) skip_bytes(attribute_length); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rmethods + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_parsert::rmethods(classt &parsed_class) { u2 methods_count=read_u2(); @@ -1318,6 +1522,18 @@ void java_bytecode_parsert::rmethods(classt &parsed_class) rmethod(parsed_class); } +/*******************************************************************\ + +Function: java_bytecode_parsert::rmethod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #define ACC_PUBLIC 0x0001 #define ACC_PRIVATE 0x0002 #define ACC_PROTECTED 0x0004 @@ -1362,6 +1578,18 @@ void java_bytecode_parsert::rmethod(classt &parsed_class) rmethod_attribute(method); } +/*******************************************************************\ + +Function: java_bytecode_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_parse( std::istream &istream, java_bytecode_parse_treet &parse_tree, @@ -1378,6 +1606,18 @@ bool java_bytecode_parse( return parser_result; } +/*******************************************************************\ + +Function: java_bytecode_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_parse( const std::string &file, java_bytecode_parse_treet &parse_tree, diff --git a/src/java_bytecode/java_bytecode_typecheck.cpp b/src/java_bytecode/java_bytecode_typecheck.cpp index 2386cdc87f0..4f09e366452 100644 --- a/src/java_bytecode/java_bytecode_typecheck.cpp +++ b/src/java_bytecode/java_bytecode_typecheck.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Conversion / Type Checking - #include #include #include @@ -16,16 +13,52 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr2java.h" #include "java_bytecode_typecheck.h" +/*******************************************************************\ + +Function: java_bytecode_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string java_bytecode_typecheckt::to_string(const exprt &expr) { return expr2java(expr, ns); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string java_bytecode_typecheckt::to_string(const typet &type) { return type2java(type, ns); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_non_type_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_non_type_symbol(symbolt &symbol) { assert(!symbol.is_type); @@ -33,6 +66,18 @@ void java_bytecode_typecheckt::typecheck_non_type_symbol(symbolt &symbol) typecheck_expr(symbol.value); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck() { // The hash table iterators are not stable, @@ -67,6 +112,18 @@ void java_bytecode_typecheckt::typecheck() } } +/*******************************************************************\ + +Function: java_bytecode_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_typecheck( symbol_tablet &symbol_table, message_handlert &message_handler, @@ -77,6 +134,18 @@ bool java_bytecode_typecheck( return java_bytecode_typecheck.typecheck_main(); } +/*******************************************************************\ + +Function: java_bytecode_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool java_bytecode_typecheck( exprt &expr, message_handlert &message_handler, diff --git a/src/java_bytecode/java_bytecode_typecheck.h b/src/java_bytecode/java_bytecode_typecheck.h index fa35ba5eda9..618b6fce44d 100644 --- a/src/java_bytecode/java_bytecode_typecheck.h +++ b/src/java_bytecode/java_bytecode_typecheck.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Language Type Checking - #ifndef CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_TYPECHECK_H #define CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_TYPECHECK_H diff --git a/src/java_bytecode/java_bytecode_typecheck_code.cpp b/src/java_bytecode/java_bytecode_typecheck_code.cpp index 431e39234f5..788f5fa592b 100644 --- a/src/java_bytecode/java_bytecode_typecheck_code.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_code.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Conversion / Type Checking - #include "java_bytecode_typecheck.h" +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_code(codet &code) { const irep_idt &statement=code.get_statement(); diff --git a/src/java_bytecode/java_bytecode_typecheck_expr.cpp b/src/java_bytecode/java_bytecode_typecheck_expr.cpp index d1d0e988d49..11e488ff7fe 100644 --- a/src/java_bytecode/java_bytecode_typecheck_expr.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Conversion / Type Checking - #include #include @@ -22,6 +19,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_pointer_casts.h" #include "java_types.h" +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr(exprt &expr) { if(expr.id()==ID_code) @@ -50,6 +59,18 @@ void java_bytecode_typecheckt::typecheck_expr(exprt &expr) typecheck_expr_member(to_member_expr(expr)); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr_java_new + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr_java_new(side_effect_exprt &expr) { assert(expr.operands().empty()); @@ -57,6 +78,18 @@ void java_bytecode_typecheckt::typecheck_expr_java_new(side_effect_exprt &expr) typecheck_type(type); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr_java_new_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr_java_new_array( side_effect_exprt &expr) { @@ -84,9 +117,18 @@ static std::string escape_non_alnum(const std::string &toescape) return escaped.str(); } -/// Convert UCS-2 or UTF-16 to an array expression. -/// \par parameters: `in`: wide string to convert -/// \return Returns a Java char array containing the same wchars. +/*******************************************************************\ + +Function: utf16_to_array + + Inputs: `in`: wide string to convert + + Outputs: Returns a Java char array containing the same wchars. + + Purpose: Convert UCS-2 or UTF-16 to an array expression. + +\*******************************************************************/ + static array_exprt utf16_to_array(const std::wstring &in) { const auto jchar=java_char_type(); @@ -96,6 +138,18 @@ static array_exprt utf16_to_array(const std::wstring &in) return ret; } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr_java_string_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr) { const irep_idt value=expr.get(ID_value); @@ -210,6 +264,18 @@ void java_bytecode_typecheckt::typecheck_expr_java_string_literal(exprt &expr) expr=address_of_exprt(new_symbol.symbol_expr()); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr) { irep_idt identifier=expr.get_identifier(); @@ -258,6 +324,18 @@ void java_bytecode_typecheckt::typecheck_expr_symbol(symbol_exprt &expr) } } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_expr_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_expr_member(member_exprt &expr) { // The member might be in a parent class or an opaque class, which we resolve diff --git a/src/java_bytecode/java_bytecode_typecheck_type.cpp b/src/java_bytecode/java_bytecode_typecheck_type.cpp index 79b2146f07a..647aa35a45e 100644 --- a/src/java_bytecode/java_bytecode_typecheck_type.cpp +++ b/src/java_bytecode/java_bytecode_typecheck_type.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Bytecode Conversion / Type Checking - #include #include "java_bytecode_typecheck.h" +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_type(typet &type) { if(type.id()==ID_symbol) @@ -53,6 +62,18 @@ void java_bytecode_typecheckt::typecheck_type(typet &type) } } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_type_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_bytecode_typecheckt::typecheck_type_symbol(symbolt &symbol) { assert(symbol.is_type); diff --git a/src/java_bytecode/java_class_loader.cpp b/src/java_bytecode/java_class_loader.cpp index 645974aadb2..fdd37c4b312 100644 --- a/src/java_bytecode/java_class_loader.cpp +++ b/src/java_bytecode/java_class_loader.cpp @@ -18,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_class_loader.h" #include "jar_file.h" +/*******************************************************************\ + +Function: java_class_loadert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + java_bytecode_parse_treet &java_class_loadert::operator()( const irep_idt &class_name) { @@ -60,6 +72,18 @@ java_bytecode_parse_treet &java_class_loadert::operator()( return class_map[class_name]; } +/*******************************************************************\ + +Function: java_class_loadert::set_java_cp_include_files + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_class_loadert::set_java_cp_include_files( std::string &_java_cp_include_files) { @@ -67,6 +91,18 @@ void java_class_loadert::set_java_cp_include_files( jar_pool.set_message_handler(get_message_handler()); } +/*******************************************************************\ + +Function: java_class_loadert::get_parse_tree + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + java_bytecode_parse_treet &java_class_loadert::get_parse_tree( java_class_loader_limitt &class_loader_limit, const irep_idt &class_name) @@ -160,6 +196,18 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( return parse_tree; } +/*******************************************************************\ + +Function: java_class_loadert::load_entire_jar + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_class_loadert::load_entire_jar( java_class_loader_limitt &class_loader_limit, const std::string &file) @@ -176,6 +224,18 @@ void java_class_loadert::load_entire_jar( jar_files.pop_front(); } +/*******************************************************************\ + +Function: java_class_loadert::read_jar_file + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_class_loadert::read_jar_file( java_class_loader_limitt &class_loader_limit, const irep_idt &file) @@ -211,6 +271,18 @@ void java_class_loadert::read_jar_file( } } +/*******************************************************************\ + +Function: java_class_loadert::file_to_class_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string java_class_loadert::file_to_class_name(const std::string &file) { std::string result=file; @@ -238,6 +310,18 @@ std::string java_class_loadert::file_to_class_name(const std::string &file) return result; } +/*******************************************************************\ + +Function: java_class_loadert::class_name_to_file + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string java_class_loadert::class_name_to_file(const irep_idt &class_name) { std::string result=id2string(class_name); diff --git a/src/java_bytecode/java_class_loader_limit.cpp b/src/java_bytecode/java_class_loader_limit.cpp index 7ba1d4fe0ee..3a9ed66d3d5 100644 --- a/src/java_bytecode/java_class_loader_limit.cpp +++ b/src/java_bytecode/java_class_loader_limit.cpp @@ -6,15 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// limit class path loading - #include #include "java_class_loader_limit.h" -/// initializes class with either regex matcher or match set -/// \par parameters: parameter from `java-cp-include-files` +/*******************************************************************\ + +Function: java_class_loader_limitt::setup_class_load_limit + + Inputs: parameter from `java-cp-include-files` + + Outputs: + + Purpose: initializes class with either regex matcher or match set + +\*******************************************************************/ + void java_class_loader_limitt::setup_class_load_limit( std::string &java_cp_include_files) { @@ -47,8 +54,18 @@ void java_class_loader_limitt::setup_class_load_limit( } } -/// \par parameters: class file name -/// \return true if file should be loaded, else false +/*******************************************************************\ + +Function: java_class_loader_limitt::load_class_file + + Inputs: class file name + + Outputs: true if file should be loaded, else false + + Purpose: + +\*******************************************************************/ + bool java_class_loader_limitt::load_class_file(const irep_idt &file_name) { if(regex_match) diff --git a/src/java_bytecode/java_class_loader_limit.h b/src/java_bytecode/java_class_loader_limit.h index 149561f29e4..fa5e21ffd95 100644 --- a/src/java_bytecode/java_class_loader_limit.h +++ b/src/java_bytecode/java_class_loader_limit.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// limit class path loading - #ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H diff --git a/src/java_bytecode/java_entry_point.cpp b/src/java_bytecode/java_entry_point.cpp index b72605654f2..8d7b479ff60 100644 --- a/src/java_bytecode/java_entry_point.cpp +++ b/src/java_bytecode/java_entry_point.cpp @@ -33,6 +33,18 @@ Author: Daniel Kroening, kroening@kroening.com #define INITIALIZE CPROVER_PREFIX "initialize" +/*******************************************************************\ + +Function: create_initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void create_initialize(symbol_tablet &symbol_table) { symbolt initialize; @@ -73,6 +85,18 @@ static bool should_init_symbol(const symbolt &sym) return has_prefix(id2string(sym.name), "java::java.lang.String.Literal"); } +/*******************************************************************\ + +Function: java_static_lifetime_init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_static_lifetime_init( symbol_tablet &symbol_table, const source_locationt &source_location, @@ -131,6 +155,18 @@ void java_static_lifetime_init( } } +/*******************************************************************\ + +Function: java_build_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt::operandst java_build_arguments( const symbolt &function, code_blockt &init_code, @@ -198,6 +234,18 @@ exprt::operandst java_build_arguments( return main_arguments; } +/*******************************************************************\ + +Function: java_record_outputs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void java_record_outputs( const symbolt &function, const exprt::operandst &main_arguments, @@ -446,14 +494,24 @@ main_function_resultt get_main_symbol( return res; // give up with error } -/// find entry point and create initialization code for function -/// symbol_table -/// main class -/// message_handler -/// \param assume_init_pointers_not_null: allow pointers in initialization code -/// to be null -/// max_nondet_array_length -/// \return true if error occurred on entry point search +/*******************************************************************\ + +Function: java_entry_point + + Inputs: + symbol_table + main class + message_handler + assume_init_pointers_not_null - allow pointers in initialization code to be + null + max_nondet_array_length + + Outputs: true if error occurred on entry point search + + Purpose: find entry point and create initialization code for function + +\*******************************************************************/ + bool java_entry_point( symbol_tablet &symbol_table, const irep_idt &main_class, diff --git a/src/java_bytecode/java_local_variable_table.cpp b/src/java_bytecode/java_local_variable_table.cpp index ee7d061f9d6..85e9766d5ab 100644 --- a/src/java_bytecode/java_local_variable_table.cpp +++ b/src/java_bytecode/java_local_variable_table.cpp @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Java local variable table processing - #include "java_bytecode_convert_method_class.h" #include "java_types.h" @@ -144,11 +141,20 @@ struct is_predecessor_oft // Helper routines for the find-initialisers code below: -/// See above -/// `start`: Variable to find the predecessors of `predecessor_map`: Map from -/// local variables to sets of predecessors -/// \param Outputs: `result`: populated with all transitive predecessors of -/// `start` found in `predecessor_map` +/*******************************************************************\ + +Function: gather_transitive_predecessors + + Inputs: `start`: Variable to find the predecessors of + `predecessor_map`: Map from local variables + to sets of predecessors + Outputs: `result`: populated with all transitive predecessors of + `start` found in `predecessor_map` + + Purpose: See above + +\*******************************************************************/ + static void gather_transitive_predecessors( local_variable_with_holest *start, const predecessor_mapt &predecessor_map, @@ -163,11 +169,20 @@ static void gather_transitive_predecessors( gather_transitive_predecessors(pred, predecessor_map, result); } -/// See above -/// \par parameters: `inst`: Java bytecode instruction -/// `slotidx`: local variable slot number -/// \return Returns true if `inst` is any form of store instruction targeting -/// slot `slotidx` +/*******************************************************************\ + +Function: is_store_to_slot + + Inputs: `inst`: Java bytecode instruction + `slotidx`: local variable slot number + + Outputs: Returns true if `inst` is any form of store instruction + targeting slot `slotidx` + + Purpose: See above + +\*******************************************************************/ + static bool is_store_to_slot( const java_bytecode_convert_methodt::instructiont &inst, unsigned slotidx) @@ -194,10 +209,19 @@ static bool is_store_to_slot( return storeslotidx==slotidx; } -/// See above -/// \par parameters: `from`, `to`: bounds of a gap in `var`'s live range, -/// inclusive and exclusive respectively -/// \return Adds a hole to `var`, unless it would be of zero size. +/*******************************************************************\ + +Function: maybe_add_hole + + Inputs: `from`, `to`: bounds of a gap in `var`'s live range, + inclusive and exclusive respectively + + Outputs: Adds a hole to `var`, unless it would be of zero size. + + Purpose: See above + +\*******************************************************************/ + static void maybe_add_hole( local_variable_with_holest &var, unsigned from, @@ -208,13 +232,22 @@ static void maybe_add_hole( var.holes.push_back({from, to-from}); } -/// See above -/// \par parameters: `firstvar`-`varlimit`: range of local variable table -/// entries to consider -/// \return `live_variable_at_address` is populated with a sequence of local -/// variable table entry pointers, such that `live_variable_at_address[addr]` -/// yields the unique table entry covering that address. Asserts if entries -/// overlap. +/*******************************************************************\ + +Function: populate_variable_address_map + + Inputs: `firstvar`-`varlimit`: range of local variable table + entries to consider + + Outputs: `live_variable_at_address` is populated with a sequence of + local variable table entry pointers, such that + `live_variable_at_address[addr]` yields the unique table + entry covering that address. Asserts if entries overlap. + + Purpose: See above + +\*******************************************************************/ + static void populate_variable_address_map( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -236,20 +269,32 @@ static void populate_variable_address_map( } } -/// Usually a live variable range begins with a store instruction initialising -/// the relevant local variable slot, but instead of or in addition to this, -/// control flow edges may exist from bytecode addresses that fall under a table -/// entry which differs, but which has the same variable name and type -/// descriptor. This indicates a split live range, and will be recorded in the -/// predecessor map. -/// \par parameters: `firstvar`-`varlimit`: range of local variable table -/// entries to consider -/// `live_variable_at_address`: map from bytecode address to table entry (drawn -/// from firstvar-varlimit) live at that address -/// `amap`: map from bytecode address to instructions -/// \return Populates `predecessor_map` with a graph from local variable table -/// entries to their predecessors (table entries which may flow together and -/// thus may be considered the same live range). +/*******************************************************************\ + +Function: populate_predecessor_map + + Inputs: `firstvar`-`varlimit`: range of local variable table + entries to consider + `live_variable_at_address`: map from bytecode address + to table entry (drawn from firstvar-varlimit) live + at that address + `amap`: map from bytecode address to instructions + + Outputs: Populates `predecessor_map` with a graph from local variable + table entries to their predecessors (table entries which + may flow together and thus may be considered the same live + range). + + Purpose: Usually a live variable range begins with a store + instruction initialising the relevant local variable slot, + but instead of or in addition to this, control flow edges + may exist from bytecode addresses that fall under a + table entry which differs, but which has the same variable + name and type descriptor. This indicates a split live + range, and will be recorded in the predecessor map. + +\*******************************************************************/ + static void populate_predecessor_map( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -348,14 +393,24 @@ static void populate_predecessor_map( } } -/// Used to find out where to put a variable declaration that subsumes several -/// variable live ranges. -/// \par parameters: `merge_vars`: Set of variables we want the common dominator -/// for. -/// `dominator_analysis`: Already-initialised dominator tree -/// \return Returns the bytecode address of the closest common dominator of all -/// given variable table entries. In the worst case the function entry point -/// should always satisfy this criterion. +/*******************************************************************\ + +Function: get_common_dominator + + Inputs: `merge_vars`: Set of variables we want the common dominator + for. + `dominator_analysis`: Already-initialised dominator tree + + Outputs: Returns the bytecode address of the closest common + dominator of all given variable table entries. + In the worst case the function entry point should always + satisfy this criterion. + + Purpose: Used to find out where to put a variable declaration that + subsumes several variable live ranges. + +\*******************************************************************/ + static unsigned get_common_dominator( const std::set &merge_vars, const java_cfg_dominatorst &dominator_analysis) @@ -405,14 +460,24 @@ static unsigned get_common_dominator( throw "variable live ranges with no common dominator?"; } -/// See above -/// \par parameters: `merge_vars`: a set of 2+ variable table entries to merge -/// `expanded_live_range_start`: address where the merged variable will be -/// declared -/// \return Adds holes to `merge_into`, indicating where gaps in the variable's -/// live range fall. For example, if the declaration happens at address 10 and -/// the entries in `merge_into` have live ranges [(20-30), (40-50)] then holes -/// will be added at (10-20) and (30-40). +/*******************************************************************\ + +Function: populate_live_range_holes + + Inputs: `merge_vars`: a set of 2+ variable table entries to merge + `expanded_live_range_start`: address where the merged + variable will be declared + + Outputs: Adds holes to `merge_into`, indicating where gaps in the + variable's live range fall. For example, if the + declaration happens at address 10 and the entries in + `merge_into` have live ranges [(20-30), (40-50)] then + holes will be added at (10-20) and (30-40). + + Purpose: See above + +\*******************************************************************/ + static void populate_live_range_holes( local_variable_with_holest &merge_into, const std::set &merge_vars, @@ -435,13 +500,22 @@ static void populate_live_range_holes( } } -/// See above -/// \par parameters: `merge_vars`: a set of 2+ variable table entries to merge -/// `dominator_analysis`: already-calculated dominator tree -/// \return Populates `merge_into` as a combined variable table entry, with live -/// range holes if the `merge_vars` entries do not cover a contiguous address -/// range, beginning the combined live range at the common dominator of all -/// `merge_vars`. +/*******************************************************************\ + +Function: merge_variable_table_entries + + Inputs: `merge_vars`: a set of 2+ variable table entries to merge + `dominator_analysis`: already-calculated dominator tree + + Outputs: Populates `merge_into` as a combined variable table entry, + with live range holes if the `merge_vars` entries do not + cover a contiguous address range, beginning the combined + live range at the common dominator of all `merge_vars`. + + Purpose: See above + +\*******************************************************************/ + static void merge_variable_table_entries( local_variable_with_holest &merge_into, const std::set &merge_vars, @@ -485,17 +559,28 @@ static void merge_variable_table_entries( v->var.length=0; } -/// Given a sequence of users of the same local variable slot, this figures out -/// which ones are related by control flow, and combines them into a single -/// entry with holes, such that after combination we can create a single -/// declaration per variable table entry, placed at the live range's start -/// address, which may be moved back so that the declaration dominates all uses. -/// \par parameters: `firstvar`-`varlimit`: sequence of variable table entries, -/// all of which should concern the same slot index. -/// `amap`: Map from bytecode address to instruction -/// \return Side-effect: merges variable table entries which flow into one -/// another (e.g. there are branches from one live range to another without -/// re-initialising the local slot). +/*******************************************************************\ + +Function: find_initialisers_for_slot + + Inputs: `firstvar`-`varlimit`: sequence of variable table entries, + all of which should concern the same slot index. + `amap`: Map from bytecode address to instruction + + Outputs: Side-effect: merges variable table entries which flow into + one another (e.g. there are branches from one live range + to another without re-initialising the local slot). + + Purpose: Given a sequence of users of the same local variable slot, + this figures out which ones are related by control flow, + and combines them into a single entry with holes, such that + after combination we can create a single + declaration per variable table entry, + placed at the live range's start address, which may + be moved back so that the declaration dominates all uses. + +\*******************************************************************/ + void java_bytecode_convert_methodt::find_initialisers_for_slot( local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, @@ -562,13 +647,23 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot( } } -/// Walk a vector, a contiguous block of entries with equal slot index at a -/// time. -/// \par parameters: `it1` and `it2`, which are iterators into the same vector, -/// of which `itend` is the end() iterator. -/// \return Moves `it1` and `it2` to delimit a sequence of variable table -/// entries with slot index equal to it2->var.index on entering this function, -/// or to both equal itend if it2==itend on entry. +/*******************************************************************\ + +Function: walk_to_next_index + + Inputs: `it1` and `it2`, which are iterators into the same vector, + of which `itend` is the end() iterator. + + Outputs: Moves `it1` and `it2` to delimit a sequence of variable + table entries with slot index equal to it2->var.index + on entering this function, or to both equal itend if + it2==itend on entry. + + Purpose: Walk a vector, a contiguous block of entries with equal + slot index at a time. + +\*******************************************************************/ + static void walk_to_next_index( local_variable_table_with_holest::iterator &it1, local_variable_table_with_holest::iterator &it2, @@ -587,12 +682,21 @@ static void walk_to_next_index( it1=old_it2; } -/// See `find_initialisers_for_slot` above for more detail. -/// \par parameters: `vars`: Local variable table -/// `amap`: Map from bytecode index to instruction -/// `dominator_analysis`: Already computed dominator tree for the Java function -/// described by `amap` -/// \return Combines entries in `vars` which flow together +/*******************************************************************\ + +Function: find_initialisers + + Inputs: `vars`: Local variable table + `amap`: Map from bytecode index to instruction + `dominator_analysis`: Already computed dominator tree for + the Java function described by `amap` + + Outputs: Combines entries in `vars` which flow together + + Purpose: See `find_initialisers_for_slot` above for more detail. + +\*******************************************************************/ + void java_bytecode_convert_methodt::find_initialisers( local_variable_table_with_holest &vars, const address_mapt &amap, @@ -611,9 +715,18 @@ void java_bytecode_convert_methodt::find_initialisers( find_initialisers_for_slot(it1, it2, amap, dominator_analysis); } -/// See above -/// \par parameters: `vars_with_holes`: variable table -/// \return Removes zero-size entries from `vars_with_holes` +/*******************************************************************\ + +Function: cleanup_var_table + + Inputs: `vars_with_holes`: variable table + + Outputs: Removes zero-size entries from `vars_with_holes` + + Purpose: See above + +\*******************************************************************/ + static void cleanup_var_table( std::vector &vars_with_holes) { @@ -636,12 +749,22 @@ static void cleanup_var_table( vars_with_holes.resize(vars_with_holes.size()-toremove); } -/// See `find_initialisers_for_slot` above for more detail. -/// \par parameters: `m`: Java method -/// `amap`: Map from bytecode indices to instructions in `m` -/// \return Populates `this->vars_with_holes` equal to -/// `this->local_variable_table`, only with variable table entries that flow -/// together combined. Also symbol-table registers all locals. +/*******************************************************************\ + +Function: setup_local_variables + + Inputs: `m`: Java method + `amap`: Map from bytecode indices to instructions in `m` + + Outputs: Populates `this->vars_with_holes` equal to + `this->local_variable_table`, only with variable table + entries that flow together combined. + Also symbol-table registers all locals. + + Purpose: See `find_initialisers_for_slot` above for more detail. + +\*******************************************************************/ + void java_bytecode_convert_methodt::setup_local_variables( const methodt &m, const address_mapt &amap) @@ -704,12 +827,22 @@ void java_bytecode_convert_methodt::setup_local_variables( } } -/// See above -/// \par parameters: `address`: Address to find a variable table entry for -/// `var_list`: List of candidates that use the slot we're interested in -/// \return Returns the list entry covering this address (taking live range -/// holes into account), or creates/returns an anonymous variable entry if -/// nothing covers `address`. +/*******************************************************************\ + +Function: find_variable_for_slot + + Inputs: `address`: Address to find a variable table entry for + `var_list`: List of candidates that use the slot we're + interested in + + Outputs: Returns the list entry covering this address (taking live + range holes into account), or creates/returns an anonymous + variable entry if nothing covers `address`. + + Purpose: See above + +\*******************************************************************/ + const java_bytecode_convert_methodt::variablet & java_bytecode_convert_methodt::find_variable_for_slot( size_t address, diff --git a/src/java_bytecode/java_object_factory.cpp b/src/java_bytecode/java_object_factory.cpp index 50f40922d79..31d5741140a 100644 --- a/src/java_bytecode/java_object_factory.cpp +++ b/src/java_bytecode/java_object_factory.cpp @@ -28,6 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_types.h" #include "java_utils.h" +/*******************************************************************\ + +Function: new_tmp_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static symbolt &new_tmp_symbol( symbol_tablet &symbol_table, const source_locationt &loc, @@ -118,18 +130,27 @@ class java_object_factoryt update_in_placet); }; -/// Generates code for allocating a dynamic object. This is used in -/// allocate_object and for allocating strings in the library preprocessing. -/// \param target_expr: expression to which the necessary memory will be -/// allocated -/// \param allocate_type: type of the object allocated -/// \param symbol_table: symbol table -/// \param loc: location in the source -/// \param output_code: code block to which the necessary code is added -/// \param symbols_created: created symbols to be declared by the caller -/// \param cast_needed: Boolean flags saying where we need to cast the malloc -/// site -/// \return Expression representing the malloc site allocated. +/*******************************************************************\ + +Function: allocate_dynamic_object + + Inputs: + target_expr - expression to which the necessary memory will be allocated + allocate_type - type of the object allocated + symbol_table - symbol table + loc - location in the source + output_code - code block to which the necessary code is added + symbols_created - created symbols to be declared by the caller + cast_needed - Boolean flags saying where we need to cast the malloc site + + Outputs: Expression representing the malloc site allocated. + + Purpose: Generates code for allocating a dynamic object. + This is used in allocate_object and for allocating strings + in the library preprocessing. + +\*******************************************************************/ + exprt allocate_dynamic_object( const exprt &target_expr, const typet &allocate_type, @@ -181,18 +202,27 @@ exprt allocate_dynamic_object( } } -/// Generates code for allocating a dynamic object. This is a static version of -/// allocate_dynamic_object that can be called from outside java_object_factory -/// and which takes care of creating the associated declarations. -/// \param target_expr: expression to which the necessary memory will be -/// allocated -/// \param allocate_type: type of the object allocated -/// \param symbol_table: symbol table -/// \param loc: location in the source -/// \param output_code: code block to which the necessary code is added -/// \param cast_needed: Boolean flags saying where we need to cast the malloc -/// site -/// \return Expression representing the malloc site allocated. +/*******************************************************************\ + +Function: allocate_dynamic_object_with_decl + + Inputs: + target_expr - expression to which the necessary memory will be allocated + allocate_type - type of the object allocated + symbol_table - symbol table + loc - location in the source + output_code - code block to which the necessary code is added + cast_needed - Boolean flags saying where we need to cast the malloc site + + Outputs: Expression representing the malloc site allocated. + + Purpose: Generates code for allocating a dynamic object. + This is a static version of allocate_dynamic_object that can + be called from outside java_object_factory and which takes care + of creating the associated declarations. + +\*******************************************************************/ + exprt allocate_dynamic_object_with_decl( const exprt &target_expr, const typet &allocate_type, @@ -224,15 +254,25 @@ exprt allocate_dynamic_object_with_decl( return result; } -/// Returns false if we can't figure out the size of allocate_type. -/// allocate_type may differ from target_expr, e.g. for target_expr having type -/// int* and allocate_type being an int[10]. -/// \param assignments: The code block to add code to -/// \param target_expr: The expression which we are allocating a symbol for -/// \param allocate_type: -/// \param create_dynamic_objects: Whether to create a symbol with static -/// lifetime or -/// \return the allocated object +/*******************************************************************\ + +Function: java_object_factoryt::allocate_object + + Inputs: + assignments - The code block to add code to + target_expr - The expression which we are allocating a symbol for + allocate_type - + create_dynamic_objects - Whether to create a symbol with static + lifetime or + + Outputs: the allocated object + + Purpose: Returns false if we can't figure out the size of allocate_type. + allocate_type may differ from target_expr, e.g. for target_expr + having type int* and allocate_type being an int[10]. + +\*******************************************************************/ + exprt java_object_factoryt::allocate_object( code_blockt &assignments, const exprt &target_expr, @@ -269,9 +309,20 @@ exprt java_object_factoryt::allocate_object( } } -/// Adds an instruction to `init_code` null-initialising `expr`. -/// \par parameters: `expr`: pointer-typed lvalue expression to initialise -/// `ptr_type`: pointer type to write +/*******************************************************************\ + +Function: java_object_factoryt::get_null_assignment + + Inputs: `expr`: pointer-typed lvalue expression to initialise + `ptr_type`: pointer type to write + + Outputs: + + Purpose: Adds an instruction to `init_code` null-initialising + `expr`. + +\*******************************************************************/ + code_assignt java_object_factoryt::get_null_assignment( const exprt &expr, const pointer_typet &ptr_type) @@ -282,17 +333,29 @@ code_assignt java_object_factoryt::get_null_assignment( return code; } -/// Initialises an object tree rooted at `expr`, allocating child objects as -/// necessary and nondet-initialising their members, or if MUST_UPDATE_IN_PLACE -/// is set, re-initialising already-allocated objects. -/// \par parameters: `expr`: pointer-typed lvalue expression to initialise -/// `target_type`: structure type to initialise, which may not match *expr (for -/// example, expr might be void*) -/// `create_dynamic_objects`: if true, use malloc to allocate objects; otherwise -/// generate fresh static symbols. -/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch -/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: -/// invalid input +/*******************************************************************\ + +Function: java_object_factoryt::gen_pointer_target_init + + Inputs: `expr`: pointer-typed lvalue expression to initialise + `target_type`: structure type to initialise, which may + not match *expr (for example, expr might be void*) + `create_dynamic_objects`: if true, use malloc to allocate + objects; otherwise generate fresh static symbols. + `update_in_place`: + NO_UPDATE_IN_PLACE: initialise `expr` from scratch + MUST_UPDATE_IN_PLACE: reinitialise an existing object + MAY_UPDATE_IN_PLACE: invalid input + + Outputs: + + Purpose: Initialises an object tree rooted at `expr`, allocating + child objects as necessary and nondet-initialising their + members, or if MUST_UPDATE_IN_PLACE is set, re-initialising + already-allocated objects. + +\*******************************************************************/ + void java_object_factoryt::gen_pointer_target_init( code_blockt &assignments, const exprt &expr, @@ -346,25 +409,40 @@ void java_object_factoryt::gen_pointer_target_init( } } -/// Initialises a primitive or object tree rooted at `expr`, allocating child -/// objects as necessary and nondet-initialising their members, or if -/// MUST_UPDATE_IN_PLACE is set, re-initialising already-allocated objects. -/// \par parameters: `expr`: lvalue expression to initialise -/// `is_sub`: If true, `expr` is a substructure of a larger object, which in -/// Java necessarily means a base class. not match *expr (for example, expr -/// might be void*) -/// `class_identifier`: clsid to initialise @java.lang.Object. @class_identifier -/// `skip_classid`: if true, skip initialising @class_identifier -/// `create_dynamic_objects`: if true, use malloc to allocate objects; otherwise -/// generate fresh static symbols. -/// `override`: If true, initialise with `override_type` instead of -/// `expr.type()`. Used at the moment for reference arrays, which are -/// implemented as void* arrays but should be init'd as their true type with -/// appropriate casts. -/// `override_type`: Override type per above -/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch -/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: -/// generate a runtime nondet branch between the NO_ and MUST_ cases. +/*******************************************************************\ + +Function: java_object_factoryt::gen_nondet_init + + Inputs: `expr`: lvalue expression to initialise + `is_sub`: If true, `expr` is a substructure of a larger + object, which in Java necessarily means a base class. + not match *expr (for example, expr might be void*) + `class_identifier`: clsid to initialise @java.lang.Object. + @class_identifier + `skip_classid`: if true, skip initialising @class_identifier + `create_dynamic_objects`: if true, use malloc to allocate + objects; otherwise generate fresh static symbols. + `override`: If true, initialise with `override_type` instead + of `expr.type()`. Used at the moment for + reference arrays, which are implemented as void* + arrays but should be init'd as their true type with + appropriate casts. + `override_type`: Override type per above + `update_in_place`: + NO_UPDATE_IN_PLACE: initialise `expr` from scratch + MUST_UPDATE_IN_PLACE: reinitialise an existing object + MAY_UPDATE_IN_PLACE: generate a runtime nondet branch + between the NO_ and MUST_ cases. + + Outputs: + + Purpose: Initialises a primitive or object tree rooted at `expr`, + allocating child objects as necessary and nondet-initialising + their members, or if MUST_UPDATE_IN_PLACE is set, + re-initialising already-allocated objects. + +\*******************************************************************/ + void java_object_factoryt::gen_nondet_init( code_blockt &assignments, const exprt &expr, @@ -568,15 +646,24 @@ void java_object_factoryt::gen_nondet_init( } } -/// Allocates a fresh array. Single-use herem at the moment, but useful to keep -/// as a separate function for downstream branches. -/// \par parameters: `lhs`, symbol to assign the new array structure -/// `max_length_expr`, maximum length of the new array (minimum is fixed at zero -/// for now) -/// `element_type`, actual element type of the array (the array for all -/// reference types will have void* type, but this will be annotated as the -/// true member type) -/// \return Appends instructions to `assignments` +/*******************************************************************\ + +Function: java_object_factoryt::allocate_nondet_length_array + + Inputs: `lhs`, symbol to assign the new array structure + `max_length_expr`, maximum length of the new array + (minimum is fixed at zero for now) + `element_type`, actual element type of the array (the array + for all reference types will have void* type, but this + will be annotated as the true member type) + + Outputs: Appends instructions to `assignments` + + Purpose: Allocates a fresh array. Single-use herem at the moment, but + useful to keep as a separate function for downstream branches. + +\*******************************************************************/ + void java_object_factoryt::allocate_nondet_length_array( code_blockt &assignments, const exprt &lhs, @@ -621,8 +708,20 @@ void java_object_factoryt::allocate_nondet_length_array( assignments.copy_to_operands(assign); } -/// create code to initialize a Java array with size `max_nondet_array_length`, -/// loop over elements and initialize them +/*******************************************************************\ + +Function: java_object_factoryt::gen_nondet_array_init + + Inputs: + + Outputs: + + Purpose: create code to initialize a Java array with size + `max_nondet_array_length`, loop over elements and initialize + them + +\*******************************************************************/ + void java_object_factoryt::gen_nondet_array_init( code_blockt &assignments, const exprt &expr, @@ -742,16 +841,28 @@ void java_object_factoryt::gen_nondet_array_init( assignments.move_to_operands(init_done_label); } -/// Similar to `gen_nondet_init` above, but always creates a fresh static global -/// object or primitive nondet expression. -/// \par parameters: `type`: type of new object to create -/// `allow_null`: if true, may return null; otherwise always allocates an object -/// `max_nondet_array_length`: upper bound on size of initialised arrays. -/// `loc`: source location for all generated code -/// `message_handler`: logging -/// \return `symbol_table` gains any new symbols created, as per gen_nondet_init -/// above. `init_code` gains any instructions requried to initialise either -/// the returned value or its child objects +/*******************************************************************\ + +Function: object_factory + + Inputs: `type`: type of new object to create + `allow_null`: if true, may return null; otherwise always + allocates an object + `max_nondet_array_length`: upper bound on size of initialised + arrays. + `loc`: source location for all generated code + `message_handler`: logging + + Outputs: `symbol_table` gains any new symbols created, as per + gen_nondet_init above. + `init_code` gains any instructions requried to initialise + either the returned value or its child objects + + Purpose: Similar to `gen_nondet_init` above, but always creates a + fresh static global object or primitive nondet expression. + +\*******************************************************************/ + exprt object_factory( const typet &type, const irep_idt base_name, @@ -815,25 +926,39 @@ exprt object_factory( return object; } -/// Initialises a primitive or object tree rooted at `expr`, allocating child -/// objects as necessary and nondet-initialising their members, or if MAY_ or -/// MUST_UPDATE_IN_PLACE is set, re-initialising already-allocated objects. -/// \par parameters: `expr`: lvalue expression to initialise -/// `loc`: source location for all generated code -/// `skip_classid`: if true, skip initialising @class_identifier -/// `create_dyn_objs`: if true, use malloc to allocate objects; otherwise -/// generate fresh static symbols. -/// `assume_non_null`: never initialise pointer members with null, unless forced -/// to by recursive datatypes -/// `message_handler`: logging -/// `max_nondet_array_length`: upper bound on size of initialised arrays. -/// `update_in_place`: NO_UPDATE_IN_PLACE: initialise `expr` from scratch -/// MUST_UPDATE_IN_PLACE: reinitialise an existing object MAY_UPDATE_IN_PLACE: -/// generate a runtime nondet branch between the NO_ and MUST_ cases. -/// \return `init_code` gets an instruction sequence to initialise or -/// reinitialise `expr` and child objects it refers to. `symbol_table` is -/// modified with any new symbols created. This includes any necessary -/// temporaries, and if `create_dyn_objs` is false, any allocated objects. +/*******************************************************************\ + +Function: gen_nondet_init + + Inputs: `expr`: lvalue expression to initialise + `loc`: source location for all generated code + `skip_classid`: if true, skip initialising @class_identifier + `create_dyn_objs`: if true, use malloc to allocate + objects; otherwise generate fresh static symbols. + `assume_non_null`: never initialise pointer members with + null, unless forced to by recursive datatypes + `message_handler`: logging + `max_nondet_array_length`: upper bound on size of initialised + arrays. + `update_in_place`: + NO_UPDATE_IN_PLACE: initialise `expr` from scratch + MUST_UPDATE_IN_PLACE: reinitialise an existing object + MAY_UPDATE_IN_PLACE: generate a runtime nondet branch + between the NO_ and MUST_ cases. + + Outputs: `init_code` gets an instruction sequence to initialise or + reinitialise `expr` and child objects it refers to. + `symbol_table` is modified with any new symbols created. This + includes any necessary temporaries, and if `create_dyn_objs` + is false, any allocated objects. + + Purpose: Initialises a primitive or object tree rooted at `expr`, + allocating child objects as necessary and nondet-initialising + their members, or if MAY_ or MUST_UPDATE_IN_PLACE is set, + re-initialising already-allocated objects. + +\*******************************************************************/ + void gen_nondet_init( const exprt &expr, code_blockt &init_code, diff --git a/src/java_bytecode/java_pointer_casts.cpp b/src/java_bytecode/java_pointer_casts.cpp index c2f04e4d1a5..174bad0a9b1 100644 --- a/src/java_bytecode/java_pointer_casts.cpp +++ b/src/java_bytecode/java_pointer_casts.cpp @@ -6,17 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// JAVA Pointer Casts - #include #include #include #include "java_pointer_casts.h" -/// dereference pointer expression -/// \return dereferenced pointer +/*******************************************************************\ + +Function: clean_deref + + Inputs: pointer + + Outputs: dereferenced pointer + + Purpose: dereference pointer expression + +\*******************************************************************/ + static exprt clean_deref(const exprt &ptr) { return ptr.id()==ID_address_of @@ -24,9 +31,19 @@ static exprt clean_deref(const exprt &ptr) : dereference_exprt(ptr, ptr.type().subtype()); } -/// \par parameters: pointer -/// target type to search -/// \return true iff a super class with target type is found +/*******************************************************************\ + +Function: find_superclass_with_type + + Inputs: pointer + target type to search + + Outputs: true iff a super class with target type is found + + Purpose: + +\*******************************************************************/ + bool find_superclass_with_type( exprt &ptr, const typet &target_type, @@ -60,8 +77,18 @@ bool find_superclass_with_type( } -/// \par parameters: input expression -/// \return recursively search target of typecast +/*******************************************************************\ + +Function: look_through_casts + + Inputs: input expression + + Outputs: recursively search target of typecast + + Purpose: + +\*******************************************************************/ + static const exprt &look_through_casts(const exprt &in) { if(in.id()==ID_typecast) @@ -74,10 +101,20 @@ static const exprt &look_through_casts(const exprt &in) } -/// \par parameters: raw pointer -/// target type -/// namespace -/// \return cleaned up typecast expression +/*******************************************************************\ + +Function: make_clean_pointer_cast + + Inputs: raw pointer + target type + namespace + + Outputs: cleaned up typecast expression + + Purpose: + +\*******************************************************************/ + exprt make_clean_pointer_cast( const exprt &rawptr, const typet &target_type, diff --git a/src/java_bytecode/java_pointer_casts.h b/src/java_bytecode/java_pointer_casts.h index eff1f6ccef8..7b5d23a3c8a 100644 --- a/src/java_bytecode/java_pointer_casts.h +++ b/src/java_bytecode/java_pointer_casts.h @@ -6,9 +6,6 @@ Author: DiffBlue \*******************************************************************/ -/// \file -/// JAVA Pointer Casts - #ifndef CPROVER_JAVA_BYTECODE_JAVA_POINTER_CASTS_H #define CPROVER_JAVA_BYTECODE_JAVA_POINTER_CASTS_H diff --git a/src/java_bytecode/java_string_library_preprocess.cpp b/src/java_bytecode/java_string_library_preprocess.cpp index 3fefade428f..6af2b4fe3e7 100644 --- a/src/java_bytecode/java_string_library_preprocess.cpp +++ b/src/java_bytecode/java_string_library_preprocess.cpp @@ -11,11 +11,6 @@ Date: April 2017 \*******************************************************************/ -/// \file -/// Java_string_libraries_preprocess, gives code for methods on strings of the -/// java standard library. In particular methods from java.lang.String, -/// java.lang.StringBuilder, java.lang.StringBuffer. - #include #include #include @@ -27,8 +22,19 @@ Date: April 2017 #include "java_string_library_preprocess.h" -/// \param type: a type -/// \param tag: a string +/*******************************************************************\ + +Function: java_string_library_preprocesst::java_type_matches_tag + + Inputs: + type - a type + tag - a string + + Output: Boolean telling whether the type is a struct with the given + tag or a symbolic type with the tag prefixed by "java::" + +\*******************************************************************/ + bool java_string_library_preprocesst::java_type_matches_tag( const typet &type, const std::string &tag) { @@ -45,7 +51,16 @@ bool java_string_library_preprocesst::java_type_matches_tag( return false; } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_pointer_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java string pointer + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_pointer_type( const typet &type) { @@ -58,21 +73,49 @@ bool java_string_library_preprocesst::is_java_string_pointer_type( return false; } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java string + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_type( const typet &type) { return java_type_matches_tag(type, "java.lang.String"); } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_builder_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java StringBuilder + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_builder_type( const typet &type) { return java_type_matches_tag(type, "java.lang.StringBuilder"); } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_builder_pointer_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java StringBuilder + pointers + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_builder_pointer_type( const typet &type) { @@ -85,14 +128,33 @@ bool java_string_library_preprocesst::is_java_string_builder_pointer_type( return false; } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_buffer_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java StringBuffer + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_buffer_type( const typet &type) { return java_type_matches_tag(type, "java.lang.StringBuffer"); } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_string_buffer_pointer_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java StringBuffer + pointers + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_string_buffer_pointer_type( const typet &type) { @@ -105,14 +167,33 @@ bool java_string_library_preprocesst::is_java_string_buffer_pointer_type( return false; } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_char_sequence_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java char sequence + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_char_sequence_type( const typet &type) { return java_type_matches_tag(type, "java.lang.CharSequence"); } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_char_sequence_pointer_type + + Inputs: a type + + Output: Boolean telling whether the type is that of a pointer + to a java char sequence + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_char_sequence_pointer_type( const typet &type) { @@ -125,16 +206,33 @@ bool java_string_library_preprocesst::is_java_char_sequence_pointer_type( return false; } -/// \par parameters: a type +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_char_array_type + + Inputs: a type + + Output: Boolean telling whether the type is that of java char array + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_char_array_type( const typet &type) { return java_type_matches_tag(type, "array[char]"); } -/// \par parameters: a type -/// \return Boolean telling whether the type is that of a pointer to a java char -/// array +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_java_char_array_pointer_type + + Inputs: a type + + Outputs: Boolean telling whether the type is that of a pointer + to a java char array + +\*******************************************************************/ + bool java_string_library_preprocesst::is_java_char_array_pointer_type( const typet &type) { @@ -147,7 +245,17 @@ bool java_string_library_preprocesst::is_java_char_array_pointer_type( return false; } -/// \param symbol_table: a symbol_table containing an entry for java Strings +/*******************************************************************\ + +Function: java_string_library_preprocesst::string_data_type + + Inputs: + symbol_table - a symbol_table containing an entry for java Strings + + Output: the type of data fields in java Strings. + +\*******************************************************************/ + typet string_data_type(symbol_tablet symbol_table) { symbolt sym=symbol_table.lookup("java::java.lang.String"); @@ -158,15 +266,32 @@ typet string_data_type(symbol_tablet symbol_table) return data_type; } -/// \return the type of the length field in java Strings. +/*******************************************************************\ + +Function: java_string_library_preprocesst::string_length_type + + Outputs: the type of the length field in java Strings. + +\*******************************************************************/ + typet string_length_type() { return java_int_type(); } -/// Add to the symbol table type declaration for a String-like Java class. -/// \param class_name: a name for the class such as "java.lang.String" -/// \param symbol_table: symbol table to which the class will be added +/*******************************************************************\ + +Function: java_string_library_preprocesst::add_string_type + + Inputs: + class_name - a name for the class such as "java.lang.String" + symbol_table - symbol table to which the class will be added + + Purpose: Add to the symbol table type declaration for a String-like + Java class. + +\*******************************************************************/ + void java_string_library_preprocesst::add_string_type( const irep_idt &class_name, symbol_tablet &symbol_table) { @@ -198,11 +323,22 @@ void java_string_library_preprocesst::add_string_type( string_symbol->is_type=true; } -/// add a symbol in the table with static lifetime and name containing -/// `cprover_string_array` and given type -/// \param type: an array type -/// \param location: a location in the program -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: fresh_array + + Inputs: + type - an array type + location - a location in the program + symbol_table - symbol table + + Output: a new symbol + + Purpose: add a symbol in the table with static lifetime and name + containing `cprover_string_array` and given type + +\*******************************************************************/ + symbol_exprt java_string_library_preprocesst::fresh_array( const typet &type, const source_locationt &location, @@ -219,10 +355,19 @@ symbol_exprt java_string_library_preprocesst::fresh_array( return array_symbol.symbol_expr(); } -/// declare a function with the given name and type -/// \param function_name: a name -/// \param type: a type -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::declare_function + + Inputs: + function_name - a name + type - a type + symbol_table - symbol table + + Purpose: declare a function with the given name and type + +\*******************************************************************/ + void java_string_library_preprocesst::declare_function( irep_idt function_name, const typet &type, symbol_tablet &symbol_table) { @@ -236,12 +381,24 @@ void java_string_library_preprocesst::declare_function( symbol_table.add(func_symbol); } -/// calls string_refine_preprocesst::process_operands with a list of parameters. -/// \param params: a list of function parameters -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \param init_code: code block, in which declaration of some arguments may be -/// added +/*******************************************************************\ + +Function: string_refine_preprocesst::process_arguments + + Inputs: + params - a list of function parameters + loc - location in the source + symbol_table - symbol table + init_code - code block, in which declaration of some arguments + may be added + + Output: a list of expressions + + Purpose: calls string_refine_preprocesst::process_operands with a + list of parameters. + +\*******************************************************************/ + exprt::operandst java_string_library_preprocesst::process_parameters( const code_typet::parameterst ¶ms, const source_locationt &loc, @@ -257,13 +414,23 @@ exprt::operandst java_string_library_preprocesst::process_parameters( return process_operands(ops, loc, symbol_table, init_code); } -/// Creates a string_exprt from the input exprt and adds it to processed_ops -/// \param processed_ops: the list of processed operands to populate -/// \param op_to_process: a list of expressions -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \param init_code: code block, in which declaration of some arguments may be -/// added +/*******************************************************************\ + +Function: java_string_library_preprocesst::process_single_operand + + Inputs: + processed_ops - the list of processed operands to populate + op_to_process - a list of expressions + loc - location in the source + symbol_table - symbol table + init_code - code block, in which declaration of some arguments + may be added + + Purpose: Creates a string_exprt from the input exprt and adds it to + processed_ops + +\*******************************************************************/ + void java_string_library_preprocesst::process_single_operand( exprt::operandst &processed_ops, const exprt &op_to_process, @@ -285,16 +452,28 @@ void java_string_library_preprocesst::process_single_operand( processed_ops.push_back(string_expr); } -/// for each expression that is of a type implementing strings, we declare a new -/// `cprover_string` whose contents is deduced from the expression and replace -/// the expression by this cprover_string in the output list; in the other case -/// the expression is kept as is for the output list. Also does the same thing -/// for char array references. -/// \param operands: a list of expressions -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \param init_code: code block, in which declaration of some arguments may be -/// added +/*******************************************************************\ + +Function: java_string_library_preprocesst::process_operands + + Inputs: + operands - a list of expressions + loc - location in the source + symbol_table - symbol table + init_code - code block, in which declaration of some arguments + may be added + + Output: a list of expressions + + Purpose: for each expression that is of a type implementing strings, + we declare a new `cprover_string` whose contents is deduced + from the expression and replace the + expression by this cprover_string in the output list; + in the other case the expression is kept as is for the output list. + Also does the same thing for char array references. + +\*******************************************************************/ + exprt::operandst java_string_library_preprocesst::process_operands( const exprt::operandst &operands, const source_locationt &loc, @@ -321,14 +500,25 @@ exprt::operandst java_string_library_preprocesst::process_operands( return ops; } -/// Converts the operands of the equals function to string expressions and -/// outputs these conversions. As a side effect of the conversions it adds some -/// code to init_code. -/// \param operands: a list of expressions -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \param init_code: code block, in which declaration of some arguments may be -/// added +/*******************************************************************\ + +Function: java_string_library_preprocesst::process_equals_function_operands + + Inputs: + operands - a list of expressions + loc - location in the source + symbol_table - symbol table + init_code - code block, in which declaration of some arguments + may be added + + Output: a list of expressions + + Purpose: Converts the operands of the equals function to string + expressions and outputs these conversions. As a side effect + of the conversions it adds some code to init_code. + +\*******************************************************************/ + exprt::operandst java_string_library_preprocesst::process_equals_function_operands( const exprt::operandst &operands, @@ -354,9 +544,20 @@ exprt::operandst return ops; } -/// Finds the type of the data component -/// \param type: a type containing a "data" component -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::get_data_type + + Inputs: + type - a type containing a "data" component + symbol_table - symbol table + + Output: type of the "data" component + + Purpose: Finds the type of the data component + +\*******************************************************************/ + typet java_string_library_preprocesst::get_data_type( const typet &type, const symbol_tablet &symbol_table) { @@ -377,9 +578,20 @@ typet java_string_library_preprocesst::get_data_type( } } -/// Finds the type of the length component -/// \param type: a type containing a "length" component -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::get_length_type + + Inputs: + type - a type containing a "length" component + symbol_table - symbol table + + Output: type of the "length" component + + Purpose: Finds the type of the length component + +\*******************************************************************/ + typet java_string_library_preprocesst::get_length_type( const typet &type, const symbol_tablet &symbol_table) { @@ -400,9 +612,20 @@ typet java_string_library_preprocesst::get_length_type( } } -/// access length member -/// \param expr: an expression of structured type with length component -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::get_length + + Inputs: + expr - an expression of structured type with length component + symbol_table - symbol table + + Output: expression representing the "length" member + + Purpose: access length member + +\*******************************************************************/ + exprt java_string_library_preprocesst::get_length( const exprt &expr, const symbol_tablet &symbol_table) { @@ -410,21 +633,43 @@ exprt java_string_library_preprocesst::get_length( expr, "length", get_length_type(expr.type(), symbol_table)); } -/// access data member -/// \param expr: an expression of structured type with length component -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::get_data + + Inputs: + expr - an expression of structured type with length component + symbol_table - symbol table + + Output: expression representing the "data" member + + Purpose: access data member + +\*******************************************************************/ + exprt java_string_library_preprocesst::get_data( const exprt &expr, const symbol_tablet &symbol_table) { return member_exprt(expr, "data", get_data_type(expr.type(), symbol_table)); } -/// we declare a new `cprover_string` whose contents is deduced from the char -/// array. -/// \param array_pointer: an expression of type char array pointer -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \param code: code block, in which some assignments will be added +/*******************************************************************\ + +Function: string_refine_preprocesst::replace_char_array + + Inputs: + array_pointer - an expression of type char array pointer + loc - location in the source + symbol_table - symbol table + code - code block, in which some assignments will be added + + Output: a string expression + + Purpose: we declare a new `cprover_string` whose contents is deduced + from the char array. + +\*******************************************************************/ + string_exprt java_string_library_preprocesst::replace_char_array( const exprt &array_pointer, const source_locationt &loc, @@ -459,11 +704,22 @@ string_exprt java_string_library_preprocesst::replace_char_array( return string_expr; } -/// add a symbol with static lifetime and name containing `cprover_string` and -/// given type -/// \param type: a type for refined strings -/// \param loc: a location in the program -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::fresh_string + + Inputs: + type - a type for refined strings + loc - a location in the program + symbol_table - symbol table + + Output: a new symbol + + Purpose: add a symbol with static lifetime and name containing + `cprover_string` and given type + +\*******************************************************************/ + symbol_exprt java_string_library_preprocesst::fresh_string( const typet &type, const source_locationt &loc, symbol_tablet &symbol_table) { @@ -473,11 +729,22 @@ symbol_exprt java_string_library_preprocesst::fresh_string( return string_symbol.symbol_expr(); } -/// add symbols with prefix cprover_string_length and cprover_string_data and -/// construct a string_expr from them. -/// \param loc: a location in the program -/// \param symbol_table: symbol table -/// \param code: code block to which allocation instruction will be added +/*******************************************************************\ + +Function: java_string_library_preprocesst::fresh_string_expr + + Inputs: + loc - a location in the program + symbol_table - symbol table + code - code block to which allocation instruction will be added + + Output: a new string_expr + + Purpose: add symbols with prefix cprover_string_length and + cprover_string_data and construct a string_expr from them. + +\*******************************************************************/ + string_exprt java_string_library_preprocesst::fresh_string_expr( const source_locationt &loc, symbol_tablet &symbol_table, code_blockt &code) { @@ -498,11 +765,22 @@ string_exprt java_string_library_preprocesst::fresh_string_expr( return str; } -/// add symbols with prefix cprover_string_length and cprover_string_data and -/// construct a string_expr from them. -/// \param loc: a location in the program -/// \param symbol_table: symbol table -/// \param code: code block to which allocation instruction will be added +/*******************************************************************\ + +Function: java_string_library_preprocesst::fresh_string_expr_symbol + + Inputs: + loc - a location in the program + symbol_table - symbol table + code - code block to which allocation instruction will be added + + Output: a new expression of refined string type + + Purpose: add symbols with prefix cprover_string_length and + cprover_string_data and construct a string_expr from them. + +\*******************************************************************/ + exprt java_string_library_preprocesst::fresh_string_expr_symbol( const source_locationt &loc, symbol_tablet &symbol_table, code_blockt &code) { @@ -517,11 +795,22 @@ exprt java_string_library_preprocesst::fresh_string_expr_symbol( return sym.symbol_expr(); } -/// declare a new String and allocate it -/// \param type: a type for string -/// \param loc: a location in the program -/// \param symbol_table: symbol table -/// \param code: code block to which allocation instruction will be added +/*******************************************************************\ + +Function: java_string_library_preprocesst::allocate_fresh_string + + Inputs: + type - a type for string + loc - a location in the program + symbol_table - symbol table + code - code block to which allocation instruction will be added + + Output: a new string + + Purpose: declare a new String and allocate it + +\*******************************************************************/ + exprt java_string_library_preprocesst::allocate_fresh_string( const typet &type, const source_locationt &loc, @@ -535,11 +824,22 @@ exprt java_string_library_preprocesst::allocate_fresh_string( return str; } -/// declare a new character array and allocate it -/// \param type: a type for string -/// \param loc: a location in the program -/// \param symbol_table: symbol table -/// \param code: code block to which allocation instruction will be added +/*******************************************************************\ + +Function: java_string_library_preprocesst::allocate_fresh_array + + Inputs: + type - a type for string + loc - a location in the program + symbol_table - symbol table + code - code block to which allocation instruction will be added + + Output: a new array + + Purpose: declare a new character array and allocate it + +\*******************************************************************/ + exprt java_string_library_preprocesst::allocate_fresh_array( const typet &type, const source_locationt &loc, @@ -553,10 +853,20 @@ exprt java_string_library_preprocesst::allocate_fresh_array( return array; } -/// \param function_name: the name of the function -/// \param arguments: a list of arguments -/// \param type: return type of the function -/// \param symbol_table: a symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_function_application + + Inputs: + function_name - the name of the function + arguments - a list of arguments + type - return type of the function + symbol_table - a symbol table + + Output: a function application representing: function_name(arguments) + +\*******************************************************************/ + exprt java_string_library_preprocesst::make_function_application( const irep_idt &function_name, const exprt::operandst &arguments, @@ -575,11 +885,23 @@ exprt java_string_library_preprocesst::make_function_application( return call; } -/// assign the result of a function call -/// \param lhs: an expression -/// \param function_name: the name of the function -/// \param arguments: a list of arguments -/// \param symbol_table: a symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::code_assign_function_application + + Inputs: + lhs - an expression + function_name - the name of the function + arguments - a list of arguments + symbol_table - a symbol table + + Output: the following code: + > lhs=function_name_length(arguments) + + Purpose: assign the result of a function call + +\*******************************************************************/ + codet java_string_library_preprocesst::code_assign_function_application( const exprt &lhs, const irep_idt &function_name, @@ -591,11 +913,23 @@ codet java_string_library_preprocesst::code_assign_function_application( return code_assignt(lhs, fun_app); } -/// return the result of a function call -/// \param function_name: the name of the function -/// \param arguments: a list of arguments -/// \param type: the return type -/// \param symbol_table: a symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::code_return_function_application + + Inputs: + function_name - the name of the function + arguments - a list of arguments + type - the return type + symbol_table - a symbol table + + Output: the following code: + > return function_name_length(arguments) + + Purpose: return the result of a function call + +\*******************************************************************/ + codet java_string_library_preprocesst::code_return_function_application( const irep_idt &function_name, const exprt::operandst &arguments, @@ -607,10 +941,22 @@ codet java_string_library_preprocesst::code_return_function_application( return code_returnt(fun_app); } -/// \param string_expr: a string expression -/// \param function_name: the name of the function -/// \param arguments: arguments of the function -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst::code_assign_function_to_string_expr + + Inputs: + string_expr - a string expression + function_name - the name of the function + arguments - arguments of the function + symbol_table - symbol table + + Output: return the following code: + > str.length <- function_name_length(arguments) + > str.data <- function_name_data(arguments) + +\*******************************************************************/ + codet java_string_library_preprocesst::code_assign_function_to_string_expr( const string_exprt &string_expr, const irep_idt &function_name, @@ -630,11 +976,24 @@ codet java_string_library_preprocesst::code_assign_function_to_string_expr( return code_blockt({assign_fun_length, assign_fun_data}); } -/// \param function_name: the name of the function -/// \param arguments: arguments of the function -/// \param loc: a location in the program -/// \param symbol_table: symbol table -/// \param code: code block in which we add instructions +/*******************************************************************\ + +Function: java_string_library_preprocesst::string_expr_of_function_application + + Inputs: + function_name - the name of the function + arguments - arguments of the function + loc - a location in the program + symbol_table - symbol table + code - code block in which we add instructions + + Output: return a string expr str and add the following code: + > array str.data + > str.length <- function_name_length(arguments) + > str.data <- function_name_data(arguments) + +\*******************************************************************/ + string_exprt java_string_library_preprocesst:: string_expr_of_function_application( const irep_idt &function_name, @@ -649,12 +1008,25 @@ string_exprt java_string_library_preprocesst:: return string_expr; } -/// Produce code for an assignemnrt of a string expr to a Java string, -/// component-wise. -/// \param lhs: expression representing the java string to assign to -/// \param rhs_array: pointer to the array to assign -/// \param rhs_length: length of the array to assign -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + code_assign_components_to_java_string + + Inputs: + lhs - expression representing the java string to assign to + rhs_array - pointer to the array to assign + rhs_length - length of the array to assign + symbol_table - symbol table + + Output: return the following code: + > lhs = { {Object}, length=rhs_length, data=rhs_array } + + Purpose: Produce code for an assignemnrt of a string expr to a + Java string, component-wise. + +\*******************************************************************/ + codet java_string_library_preprocesst::code_assign_components_to_java_string( const exprt &lhs, const exprt &rhs_array, @@ -684,10 +1056,24 @@ codet java_string_library_preprocesst::code_assign_components_to_java_string( return code; } -/// Produce code for an assignemnt of a string expr to a Java string. -/// \param lhs: an expression representing a java string -/// \param rhs: a string expression -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + code_assign_string_expr_to_java_string + + Inputs: + lhs - an expression representing a java string + rhs - a string expression + symbol_table - symbol table + + Output: return the following code: + > lhs = { {Object}, length=rhs.length, data=rhs.data } + + Purpose: Produce code for an assignemnt of a string expr to a Java + string. + +\*******************************************************************/ + codet java_string_library_preprocesst::code_assign_string_expr_to_java_string( const exprt &lhs, const string_exprt &rhs, @@ -697,11 +1083,26 @@ codet java_string_library_preprocesst::code_assign_string_expr_to_java_string( lhs, address_of_exprt(rhs.content()), rhs.length(), symbol_table); } -/// Produce code for an assignment of a string from a string expr. -/// \param lhs: an expression representing a java string -/// \param rhs: a string expression -/// \param loc: a location in the program -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + code_assign_string_expr_to_new_java_string + + Inputs: + lhs - an expression representing a java string + rhs - a string expression + loc - a location in the program + symbol_table - symbol table + + Output: return the following code: + > data = new array[]; + > *data = rhs.data; + > lhs = { {Object} , length=rhs.length, data=data} + + Purpose: Produce code for an assignment of a string from a string expr. + +\*******************************************************************/ + codet java_string_library_preprocesst:: code_assign_string_expr_to_new_java_string( const exprt &lhs, @@ -724,9 +1125,22 @@ codet java_string_library_preprocesst:: return code; } -/// \param lhs: a string expression -/// \param rhs: an expression representing a java string -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + code_assign_java_string_to_string_expr + + Inputs: + lhs - a string expression + rhs - an expression representing a java string + symbol_table - symbol table + + Output: return the following code: + > lhs.length=rhs->length + > lhs.data=*(rhs->data) + +\*******************************************************************/ + codet java_string_library_preprocesst::code_assign_java_string_to_string_expr( const string_exprt &lhs, const exprt &rhs, symbol_tablet &symbol_table) { @@ -753,10 +1167,23 @@ codet java_string_library_preprocesst::code_assign_java_string_to_string_expr( return code; } -/// \param lhs: an expression representing a java string -/// \param tmp_string: a temporary string to hold the literal -/// \param s: the literal to be assigned -/// \param symbol_table: symbol table +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + code_assign_string_literal_to_string_expr + + Inputs: + lhs - an expression representing a java string + tmp_string - a temporary string to hold the literal + s - the literal to be assigned + symbol_table - symbol table + + Output: return the following code: + > tmp_string = "s" + > lhs = (string_expr) tmp_string + +\*******************************************************************/ + codet java_string_library_preprocesst:: code_assign_string_literal_to_string_expr( const string_exprt &lhs, @@ -771,13 +1198,25 @@ codet java_string_library_preprocesst:: return code; } -/// \param type: type of the function called -/// \param loc: location in the program -/// \param symbol_table: symbol table -/// \return code for the StringBuilder.append(Object) function: > string1 = -/// arguments[1].toString() > string_expr1 = string_to_string_expr(string1) > -/// string_expr2 = concat(this, string_expr1) > this = -/// string_expr_to_string(string_expr2) > return this +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + make_string_builder_append_object_code + + Inputs: + type - type of the function called + loc - location in the program + symbol_table - symbol table + + Outputs: code for the StringBuilder.append(Object) function: + > string1 = arguments[1].toString() + > string_expr1 = string_to_string_expr(string1) + > string_expr2 = concat(this, string_expr1) + > this = string_expr_to_string(string_expr2) + > return this + +\*******************************************************************/ + codet java_string_library_preprocesst::make_string_builder_append_object_code( const code_typet &type, const source_locationt &loc, @@ -830,13 +1269,24 @@ codet java_string_library_preprocesst::make_string_builder_append_object_code( return code; } -/// Used to provide code for the Java String.equals(Object) function. -/// \param type: type of the function call -/// \param loc: location in the program_invocation_name -/// \param symbol_table: symbol table -/// \return Code corresponding to: > string_expr1 = {this->length; *this->data} -/// > string_expr2 = {arg->length; *arg->data} > return -/// cprover_string_equal(string_expr1, string_expr2) +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_equals_code + + Inputs: + type - type of the function call + loc - location in the program_invocation_name + symbol_table - symbol table + + Outputs: Code corresponding to: + > string_expr1 = {this->length; *this->data} + > string_expr2 = {arg->length; *arg->data} + > return cprover_string_equal(string_expr1, string_expr2) + + Purpose: Used to provide code for the Java String.equals(Object) function. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_equals_function_code( const code_typet &type, const source_locationt &loc, @@ -857,14 +1307,28 @@ codet java_string_library_preprocesst::make_equals_function_code( return code; } -/// Used to provide code for the Java StringBuilder.append(F) function. -/// \param type: type of the function call -/// \param loc: location in the program_invocation_name -/// \param symbol_table: symbol table -/// \return Code corresponding to: > string1 = arguments[1].toString() > -/// string_expr1 = string_to_string_expr(string1) > string_expr2 = -/// concat(this, string_expr1) > this = string_expr_to_string(string_expr2) > -/// return this +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + make_string_builder_append_float_code + + Inputs: + type - type of the function call + loc - location in the program_invocation_name + symbol_table - symbol table + + Outputs: Code corresponding to: + > string1 = arguments[1].toString() + > string_expr1 = string_to_string_expr(string1) + > string_expr2 = concat(this, string_expr1) + > this = string_expr_to_string(string_expr2) + > return this + + Purpose: Used to provide code for the Java StringBuilder.append(F) + function. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_string_builder_append_float_code( const code_typet &type, const source_locationt &loc, @@ -922,10 +1386,20 @@ codet java_string_library_preprocesst::make_string_builder_append_float_code( return code; } -/// construct a Java string literal from a constant string value -/// \param s: a string -/// \return an expression representing a Java string literal with the given -/// content. +/*******************************************************************\ + +Function: java_string_library_preprocesst::string_literal + + Inputs: + s - a string + + Outputs: an expression representing a Java string literal with the + given content. + + Purpose: construct a Java string literal from a constant string value + +\*******************************************************************/ + exprt java_string_library_preprocesst::string_literal(const std::string &s) { exprt string_literal(ID_java_string_literal); @@ -933,20 +1407,37 @@ exprt java_string_library_preprocesst::string_literal(const std::string &s) return string_literal; } -/// Provide code for the Float.toString(F) function. -/// \param type: type of the function call -/// \param loc: location in the program_invocation_name -/// \param symbol_table: symbol table -/// \return Code corresponding to: > String * str; > str = MALLOC(String); > -/// String * tmp_string; > int string_expr_length; > char[] -/// string_expr_content; > CPROVER_string string_expr_sym; > if -/// arguments[1]==NaN > then {tmp_string="NaN"; -/// string_expr=(string_expr)tmp_string} > if arguments[1]==Infinity > then -/// {tmp_string="Infinity"; string_expr=(string_expr)tmp_string} > if -/// 1e-3 then -/// string_expr=cprover_float_to_string(arguments[1]) > else -/// string_expr=cprover_float_to_scientific_notation_string(arg[1]) > -/// string_expr_sym=string_expr; > str=(String*) string_expr; > return str; +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_float_to_string_code + + Inputs: + type - type of the function call + loc - location in the program_invocation_name + symbol_table - symbol table + + Outputs: Code corresponding to: + > String * str; + > str = MALLOC(String); + > String * tmp_string; + > int string_expr_length; + > char[] string_expr_content; + > CPROVER_string string_expr_sym; + > if arguments[1]==NaN + > then {tmp_string="NaN"; string_expr=(string_expr)tmp_string} + > if arguments[1]==Infinity + > then {tmp_string="Infinity"; string_expr=(string_expr)tmp_string} + > if 1e-3 then string_expr=cprover_float_to_string(arguments[1]) + > else string_expr=cprover_float_to_scientific_notation_string(arg[1]) + > string_expr_sym=string_expr; + > str=(String*) string_expr; + > return str; + + Purpose: Provide code for the Float.toString(F) function. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_float_to_string_code( const code_typet &type, const source_locationt &loc, @@ -1045,18 +1536,30 @@ codet java_string_library_preprocesst::make_float_to_string_code( return code; } -/// Generate the goto code for string initialization. -/// \param function_name: name of the function to be called -/// \param type: the type of the function call -/// \param loc: location in program -/// \param symbol_table: the symbol table to populate -/// \param ignore_first_arg: boolean flag telling that the first argument should -/// not be part of the arguments of the call (but only used to be assigned the -/// result) -/// \return code for the String.(args) function: > cprover_string_length = -/// fun(arg).length; > cprover_string_array = fun(arg).data; > this->length = -/// cprover_string_length; > this->data = cprover_string_array; > -/// cprover_string = {.=cprover_string_length, .=cprover_string_array}; +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_init_function_from_call + + Inputs: + function_name - name of the function to be called + type - the type of the function call + loc - location in program + symbol_table - the symbol table to populate + ignore_first_arg - boolean flag telling that the first argument + should not be part of the arguments of the call + (but only used to be assigned the result) + + Outputs: code for the String.(args) function: + > cprover_string_length = fun(arg).length; + > cprover_string_array = fun(arg).data; + > this->length = cprover_string_length; + > this->data = cprover_string_array; + > cprover_string = {.=cprover_string_length, .=cprover_string_array}; + + Purpose: Generate the goto code for string initialization. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_init_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1093,13 +1596,24 @@ codet java_string_library_preprocesst::make_init_function_from_call( return code; } -/// Call a cprover internal function, assign the result to object `this` and -/// return it. -/// \param function_name: name of the function to be called -/// \param type: the type of the function call -/// \param loc: location in program -/// \param symbol_table: the symbol table to populate -/// \return Code calling function with the given function name. +/*******************************************************************\ + +Function: java_string_library_preprocesst:: + make_assign_and_return_function_from_call + + Inputs: + function_name - name of the function to be called + type - the type of the function call + loc - location in program + symbol_table - the symbol table to populate + + Outputs: Code calling function with the given function name. + + Purpose: Call a cprover internal function, assign the result to + object `this` and return it. + +\*******************************************************************/ + codet java_string_library_preprocesst:: make_assign_and_return_function_from_call( const irep_idt &function_name, @@ -1118,13 +1632,24 @@ codet java_string_library_preprocesst:: return code; } -/// Call a cprover internal function and assign the result to object `this`. -/// \param function_name: name of the function to be called -/// \param type: the type of the function call -/// \param loc: location in program -/// \param symbol_table: the symbol table to populate -/// \return Code assigning result of a call to the function with given function -/// name. +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_assign_function_from_call + + Inputs: + function_name - name of the function to be called + type - the type of the function call + loc - location in program + symbol_table - the symbol table to populate + + Outputs: Code assigning result of a call to the function with given + function name. + + Purpose: Call a cprover internal function and assign the result to + object `this`. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_assign_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1138,13 +1663,25 @@ codet java_string_library_preprocesst::make_assign_function_from_call( return code; } -/// Used to provide our own implementation of the -/// java.lang.String.toCharArray:()[C function. -/// \param type: type of the function called -/// \param loc: location in the source -/// \param symbol_table: the symbol table -/// \return Code corresponding to > return_tmp0 = malloc(array[char]); > -/// return_tmp0->data=&((s->data)[0]) > return_tmp0->length=s->length +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_string_to_char_array_code + + Inputs: + type - type of the function called + loc - location in the source + symbol_table - the symbol table + + Outputs: Code corresponding to + > return_tmp0 = malloc(array[char]); + > return_tmp0->data=&((s->data)[0]) + > return_tmp0->length=s->length + + Purpose: Used to provide our own implementation of the + java.lang.String.toCharArray:()[C function. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_string_to_char_array_code( const code_typet &type, const source_locationt &loc, @@ -1184,13 +1721,24 @@ codet java_string_library_preprocesst::make_string_to_char_array_code( return code; } -/// Provide code for a function that calls a function from the solver and simply -/// returns it. -/// \param function_name: name of the function to be called -/// \param type: type of the function -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \return Code corresponding to: > return function_name(args); +/*******************************************************************\ + +Function: java_string_library_preprocesst::make_function_from_call + + Inputs: + function_name - name of the function to be called + type - type of the function + loc - location in the source + symbol_table - symbol table + + Outputs: Code corresponding to: + > return function_name(args); + + Purpose: Provide code for a function that calls a function from the + solver and simply returns it. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_function_from_call( const irep_idt &function_name, const code_typet &type, @@ -1205,14 +1753,28 @@ codet java_string_library_preprocesst::make_function_from_call( return code; } -/// Provide code for a function that calls a function from the solver and return -/// the string_expr result as a Java string. -/// \param function_name: name of the function to be called -/// \param type: type of the function -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \return Code corresponding to: > string_expr = function_name(args) > string -/// = new String > string = string_expr_to_string(string) > return string +/*******************************************************************\ + +Function: + java_string_library_preprocesst::make_string_returning_function_from_call + + Inputs: + function_name - name of the function to be called + type - type of the function + loc - location in the source + symbol_table - symbol table + + Outputs: Code corresponding to: + > string_expr = function_name(args) + > string = new String + > string = string_expr_to_string(string) + > return string + + Purpose: Provide code for a function that calls a function from the + solver and return the string_expr result as a Java string. + +\*******************************************************************/ + codet java_string_library_preprocesst:: make_string_returning_function_from_call( const irep_idt &function_name, @@ -1245,14 +1807,28 @@ codet java_string_library_preprocesst:: return code; } -/// Generates code for a function which copies a string object to a new string -/// object. -/// \param type: type of the function -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \return Code corresponding to: > string_expr = string_to_string_expr(arg0) > -/// string_expr_sym = { string_expr.length; string_expr.content } > str = new -/// String > str = string_expr_to_string(string_expr) > return str +/*******************************************************************\ + +Function: + java_string_library_preprocesst::make_copy_string_code + + Inputs: + type - type of the function + loc - location in the source + symbol_table - symbol table + + Outputs: Code corresponding to: + > string_expr = string_to_string_expr(arg0) + > string_expr_sym = { string_expr.length; string_expr.content } + > str = new String + > str = string_expr_to_string(string_expr) + > return str + + Purpose: Generates code for a function which copies a string object to a new + string object. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_copy_string_code( const code_typet &type, const source_locationt &loc, @@ -1284,14 +1860,26 @@ codet java_string_library_preprocesst::make_copy_string_code( return code; } -/// Generates code for a constructor of a string object from another string -/// object. -/// \param type: type of the function -/// \param loc: location in the source -/// \param symbol_table: symbol table -/// \return Code corresponding to: > string_expr = -/// java_string_to_string_expr(arg1) > string_expr_sym = { string_expr.length; -/// string_expr.content } > this = string_expr_to_java_string(string_expr) +/*******************************************************************\ + +Function: + java_string_library_preprocesst::make_copy_constructor_code + + Inputs: + type - type of the function + loc - location in the source + symbol_table - symbol table + + Outputs: Code corresponding to: + > string_expr = java_string_to_string_expr(arg1) + > string_expr_sym = { string_expr.length; string_expr.content } + > this = string_expr_to_java_string(string_expr) + + Purpose: Generates code for a constructor of a string object from another + string object. + +\*******************************************************************/ + codet java_string_library_preprocesst::make_copy_constructor_code( const code_typet &type, const source_locationt &loc, @@ -1321,14 +1909,25 @@ codet java_string_library_preprocesst::make_copy_constructor_code( return code; } -/// Should be called to provide code for string functions that are used in the -/// code but for which no implementation is provided. -/// \param function_id: name of the function -/// \param type: its type -/// \param loc: location in the program -/// \param symbol_table: a symbol table -/// \return Code for the body of the String functions if they are part of the -/// supported String functions, nil_exprt otherwise. +/*******************************************************************\ + +Function: java_string_library_preprocesst::code_for_function + + Inputs: + function_id - name of the function + type - its type + loc - location in the program + symbol_table - a symbol table + + Outputs: Code for the body of the String functions if they are part + of the supported String functions, nil_exprt otherwise. + + Purpose: Should be called to provide code for string functions that + are used in the code but for which no implementation is + provided. + +\*******************************************************************/ + exprt java_string_library_preprocesst::code_for_function( const irep_idt &function_id, const code_typet &type, @@ -1366,17 +1965,35 @@ exprt java_string_library_preprocesst::code_for_function( return nil_exprt(); } -/// Check whether a class name is known as a string type. -/// \param class_name: name of the class -/// \return True if the type is one that is known to our preprocessing, false -/// otherwise +/*******************************************************************\ + +Function: java_string_library_preprocesst::is_known_string_type + + Inputs: + class_name - name of the class + + Outputs: True if the type is one that is known to our preprocessing, + false otherwise + + Purpose: Check whether a class name is known as a string type. + +\*******************************************************************/ + bool java_string_library_preprocesst::is_known_string_type( irep_idt class_name) { return string_types.find(class_name)!=string_types.end(); } -/// fill maps with correspondence from java method names to conversion functions +/*******************************************************************\ + +Function: java_string_library_preprocesst::initialize_conversion_table + + Purpose: fill maps with correspondence from java method names to + conversion functions + +\*******************************************************************/ + void java_string_library_preprocesst::initialize_conversion_table() { character_preprocess.initialize_conversion_table(); diff --git a/src/java_bytecode/java_string_library_preprocess.h b/src/java_bytecode/java_string_library_preprocess.h index b9449e18cd6..16ab5cfc6a9 100644 --- a/src/java_bytecode/java_string_library_preprocess.h +++ b/src/java_bytecode/java_string_library_preprocess.h @@ -8,9 +8,6 @@ Date: March 2017 \*******************************************************************/ -/// \file -/// Produce code for simple implementation of String Java libraries - #ifndef CPROVER_JAVA_BYTECODE_JAVA_STRING_LIBRARY_PREPROCESS_H #define CPROVER_JAVA_BYTECODE_JAVA_STRING_LIBRARY_PREPROCESS_H diff --git a/src/java_bytecode/java_types.cpp b/src/java_bytecode/java_types.cpp index 5e434b8a603..9d78c7a36a7 100644 --- a/src/java_bytecode/java_types.cpp +++ b/src/java_bytecode/java_types.cpp @@ -16,46 +16,154 @@ Author: Daniel Kroening, kroening@kroening.com #include "java_types.h" +/*******************************************************************\ + +Function: java_int_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_int_type() { return signedbv_typet(32); } +/*******************************************************************\ + +Function: java_void_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_void_type() { return void_typet(); } +/*******************************************************************\ + +Function: java_long_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_long_type() { return signedbv_typet(64); } +/*******************************************************************\ + +Function: java_short_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_short_type() { return signedbv_typet(16); } +/*******************************************************************\ + +Function: java_byte_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_byte_type() { return signedbv_typet(8); } +/*******************************************************************\ + +Function: java_char_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_char_type() { return unsignedbv_typet(16); } +/*******************************************************************\ + +Function: java_float_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_float_type() { return ieee_float_spect::single_precision().to_type(); } +/*******************************************************************\ + +Function: java_double_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_double_type() { return ieee_float_spect::double_precision().to_type(); } +/*******************************************************************\ + +Function: java_boolean_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_boolean_type() { // The Java standard doesn't really prescribe the width @@ -64,11 +172,35 @@ typet java_boolean_type() return c_bool_typet(8); } +/*******************************************************************\ + +Function: java_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + reference_typet java_reference_type(const typet &subtype) { return reference_typet(subtype); } +/*******************************************************************\ + +Function: java_array_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + pointer_typet java_array_type(const char subtype) { std::string subtype_str; @@ -98,19 +230,52 @@ pointer_typet java_array_type(const char subtype) return pointer_typet(symbol_type); } -/// See above -/// \par parameters: Struct tag 'tag' -/// \return True if the given struct is a Java array +/*******************************************************************\ + +Function: is_java_array_tag + + Inputs: Struct tag 'tag' + + Outputs: True if the given struct is a Java array + + Purpose: See above + +\*******************************************************************/ + bool is_java_array_tag(const irep_idt& tag) { return has_prefix(id2string(tag), "java::array["); } +/*******************************************************************\ + +Function: is_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_reference_type(const char t) { return 'a' == t; } +/*******************************************************************\ + +Function: java_type_from_char + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_type_from_char(char t) { switch(t) @@ -129,7 +294,19 @@ typet java_type_from_char(char t) } } -/// Java does not support byte/short return types. These are always promoted. +/*******************************************************************\ + +Function: java_bytecode_promotion + + Inputs: + + Outputs: + + Purpose: Java does not support byte/short return types. + These are always promoted. + +\*******************************************************************/ + typet java_bytecode_promotion(const typet &type) { if(type==java_boolean_type() || @@ -141,7 +318,19 @@ typet java_bytecode_promotion(const typet &type) return type; } -/// Java does not support byte/short return types. These are always promoted. +/*******************************************************************\ + +Function: java_bytecode_promotion + + Inputs: + + Outputs: + + Purpose: Java does not support byte/short return types. + These are always promoted. + +\*******************************************************************/ + exprt java_bytecode_promotion(const exprt &expr) { typet new_type=java_bytecode_promotion(expr.type()); @@ -152,6 +341,18 @@ exprt java_bytecode_promotion(const exprt &expr) return typecast_exprt(expr, new_type); } +/*******************************************************************\ + +Function: java_type_from_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet java_type_from_string(const std::string &src) { if(src.empty()) @@ -252,6 +453,18 @@ typet java_type_from_string(const std::string &src) } } +/*******************************************************************\ + +Function: java_char_from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + char java_char_from_type(const typet &type) { const irep_idt &id=type.id(); @@ -284,6 +497,18 @@ char java_char_from_type(const typet &type) return 'a'; } +/*******************************************************************\ + +Function: java_classname + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // java/lang/Object -> java.lang.Object static std::string slash_to_dot(const std::string &src) { @@ -294,6 +519,18 @@ static std::string slash_to_dot(const std::string &src) return result; } +/*******************************************************************\ + +Function: java_classname + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symbol_typet java_classname(const std::string &id) { if(!id.empty() && id[0]=='[') diff --git a/src/jsil/expr2jsil.cpp b/src/jsil/expr2jsil.cpp index 811a9a1608b..e100aa13432 100644 --- a/src/jsil/expr2jsil.cpp +++ b/src/jsil/expr2jsil.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include "expr2jsil.h" @@ -21,6 +18,18 @@ class expr2jsilt:public expr2ct protected: }; +/*******************************************************************\ + +Function: expr2jsil + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string expr2jsil(const exprt &expr, const namespacet &ns) { expr2jsilt expr2jsil(ns); @@ -28,6 +37,18 @@ std::string expr2jsil(const exprt &expr, const namespacet &ns) return expr2jsil.convert(expr); } +/*******************************************************************\ + +Function: type2jsil + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type2jsil(const typet &type, const namespacet &ns) { expr2jsilt expr2jsil(ns); diff --git a/src/jsil/expr2jsil.h b/src/jsil/expr2jsil.h index f8f99620380..b1b41df2198 100644 --- a/src/jsil/expr2jsil.h +++ b/src/jsil/expr2jsil.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_EXPR2JSIL_H #define CPROVER_JSIL_EXPR2JSIL_H diff --git a/src/jsil/jsil_convert.cpp b/src/jsil/jsil_convert.cpp index aa4ff02fffc..4e013b6f34e 100644 --- a/src/jsil/jsil_convert.cpp +++ b/src/jsil/jsil_convert.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language Conversion - #include #include @@ -34,6 +31,18 @@ class jsil_convertt:public messaget bool convert_code(const symbolt &symbol, codet &code); }; +/*******************************************************************\ + +Function: jsil_convertt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_convertt::operator()(const jsil_parse_treet &parse_tree) { for(jsil_parse_treet::itemst::const_iterator @@ -65,6 +74,18 @@ bool jsil_convertt::operator()(const jsil_parse_treet &parse_tree) return false; } +/*******************************************************************\ + +Function: jsil_convertt::convert_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_convertt::convert_code(const symbolt &symbol, codet &code) { if(code.get_statement()==ID_block) @@ -116,6 +137,18 @@ bool jsil_convertt::convert_code(const symbolt &symbol, codet &code) return false; } +/*******************************************************************\ + +Function: jsil_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_convert( const jsil_parse_treet &parse_tree, symbol_tablet &symbol_table, diff --git a/src/jsil/jsil_convert.h b/src/jsil/jsil_convert.h index 601d64e1b35..7c50b694ecd 100644 --- a/src/jsil/jsil_convert.h +++ b/src/jsil/jsil_convert.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language Conversion - #ifndef CPROVER_JSIL_JSIL_CONVERT_H #define CPROVER_JSIL_JSIL_CONVERT_H diff --git a/src/jsil/jsil_entry_point.cpp b/src/jsil/jsil_entry_point.cpp index ba1860ce6fc..4959326bf02 100644 --- a/src/jsil/jsil_entry_point.cpp +++ b/src/jsil/jsil_entry_point.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include #include @@ -22,6 +19,18 @@ Author: Michael Tautschnig, tautschn@amazon.com #define INITIALIZE CPROVER_PREFIX "initialize" +/*******************************************************************\ + +Function: create_initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void create_initialize(symbol_tablet &symbol_table) { symbolt initialize; @@ -49,6 +58,18 @@ static void create_initialize(symbol_tablet &symbol_table) throw "failed to add " CPROVER_PREFIX "initialize"; } +/*******************************************************************\ + +Function: jsil_entry_point + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_entry_point( symbol_tablet &symbol_table, message_handlert &message_handler) diff --git a/src/jsil/jsil_entry_point.h b/src/jsil/jsil_entry_point.h index fd9453769da..c374d395626 100644 --- a/src/jsil/jsil_entry_point.h +++ b/src/jsil/jsil_entry_point.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_ENTRY_POINT_H #define CPROVER_JSIL_JSIL_ENTRY_POINT_H diff --git a/src/jsil/jsil_internal_additions.cpp b/src/jsil/jsil_internal_additions.cpp index e44195713c9..9f583fbb56b 100644 --- a/src/jsil/jsil_internal_additions.cpp +++ b/src/jsil/jsil_internal_additions.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include #include @@ -19,6 +16,18 @@ Author: Michael Tautschnig, tautschn@amazon.com #include "jsil_internal_additions.h" +/*******************************************************************\ + +Function: jsil_internal_additions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_internal_additions(symbol_tablet &dest) { // add __CPROVER_rounding_mode diff --git a/src/jsil/jsil_internal_additions.h b/src/jsil/jsil_internal_additions.h index 1aed9edd692..f57cc098189 100644 --- a/src/jsil/jsil_internal_additions.h +++ b/src/jsil/jsil_internal_additions.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_INTERNAL_ADDITIONS_H #define CPROVER_JSIL_JSIL_INTERNAL_ADDITIONS_H diff --git a/src/jsil/jsil_language.cpp b/src/jsil/jsil_language.cpp index baa9cebee0c..6c022e65069 100644 --- a/src/jsil/jsil_language.cpp +++ b/src/jsil/jsil_language.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include @@ -21,17 +18,52 @@ Author: Michael Tautschnig, tautschn@amazon.com #include "jsil_language.h" +/*******************************************************************\ + +Function: jsil_languaget::extensions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::set jsil_languaget::extensions() const { return { "jsil" }; } +/*******************************************************************\ + +Function: jsil_languaget::modules_provided + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_languaget::modules_provided(std::set &modules) { modules.insert(get_base_name(parse_path, true)); } -/// Adding symbols for all procedure declarations +/*******************************************************************\ + +Function: jsil_languaget::interfaces + + Inputs: + + Outputs: + + Purpose: Adding symbols for all procedure declarations + +\*******************************************************************/ + bool jsil_languaget::interfaces(symbol_tablet &symbol_table) { if(jsil_convert(parse_tree, symbol_table, get_message_handler())) @@ -41,6 +73,18 @@ bool jsil_languaget::interfaces(symbol_tablet &symbol_table) return false; } +/*******************************************************************\ + +Function: jsil_languaget::preprocess + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::preprocess( std::istream &instream, const std::string &path, @@ -50,6 +94,18 @@ bool jsil_languaget::preprocess( return true; } +/*******************************************************************\ + +Function: jsil_languaget::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::parse( std::istream &instream, const std::string &path) @@ -75,7 +131,18 @@ bool jsil_languaget::parse( return result; } -/// Converting from parse tree and type checking. +/*******************************************************************\ + +Function: jsil_languaget::typecheck + + Inputs: + + Outputs: + + Purpose: Converting from parse tree and type checking. + +\*******************************************************************/ + bool jsil_languaget::typecheck( symbol_tablet &symbol_table, const std::string &module) @@ -86,6 +153,18 @@ bool jsil_languaget::typecheck( return false; } +/*******************************************************************\ + +Function: jsil_languaget::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::final(symbol_tablet &symbol_table) { if(jsil_entry_point( @@ -96,16 +175,52 @@ bool jsil_languaget::final(symbol_tablet &symbol_table) return false; } +/*******************************************************************\ + +Function: jsil_languaget::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_languaget::show_parse(std::ostream &out) { parse_tree.output(out); } +/*******************************************************************\ + +Function: new_jsil_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *new_jsil_language() { return new jsil_languaget; } +/*******************************************************************\ + +Function: jsil_languaget::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::from_expr( const exprt &expr, std::string &code, @@ -115,6 +230,18 @@ bool jsil_languaget::from_expr( return false; } +/*******************************************************************\ + +Function: jsil_languaget::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::from_type( const typet &type, std::string &code, @@ -124,6 +251,18 @@ bool jsil_languaget::from_type( return false; } +/*******************************************************************\ + +Function: jsil_languaget::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_languaget::to_expr( const std::string &code, const std::string &module, @@ -168,6 +307,18 @@ bool jsil_languaget::to_expr( return result; } +/*******************************************************************\ + +Function: jsil_languaget::~jsil_languaget + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + jsil_languaget::~jsil_languaget() { } diff --git a/src/jsil/jsil_language.h b/src/jsil/jsil_language.h index 2f6f376525b..349f0b58740 100644 --- a/src/jsil/jsil_language.h +++ b/src/jsil/jsil_language.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_LANGUAGE_H #define CPROVER_JSIL_JSIL_LANGUAGE_H diff --git a/src/jsil/jsil_parse_tree.cpp b/src/jsil/jsil_parse_tree.cpp index 75573ad0637..874e36ccef6 100644 --- a/src/jsil/jsil_parse_tree.cpp +++ b/src/jsil/jsil_parse_tree.cpp @@ -6,15 +6,24 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include "jsil_types.h" #include "jsil_parse_tree.h" +/*******************************************************************\ + +Function: insert_at_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool insert_at_label( const codet &code, const irep_idt &label, @@ -40,6 +49,18 @@ static bool insert_at_label( return true; } +/*******************************************************************\ + +Function: jsil_declarationt::to_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_declarationt::to_symbol(symbolt &symbol) const { symbol.clear(); @@ -80,6 +101,18 @@ void jsil_declarationt::to_symbol(symbolt &symbol) const symbol.value.swap(code); } +/*******************************************************************\ + +Function: jsil_declarationt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_declarationt::output(std::ostream &out) const { out << "Declarator: " << find(ID_declarator).pretty() << "\n"; @@ -88,6 +121,18 @@ void jsil_declarationt::output(std::ostream &out) const out << "Value: " << find(ID_value).pretty() << "\n"; } +/*******************************************************************\ + +Function: jsil_parse_treet::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_parse_treet::output(std::ostream &out) const { for(itemst::const_iterator diff --git a/src/jsil/jsil_parse_tree.h b/src/jsil/jsil_parse_tree.h index 55ee57de51b..5a83cf18e8b 100644 --- a/src/jsil/jsil_parse_tree.h +++ b/src/jsil/jsil_parse_tree.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_PARSE_TREE_H #define CPROVER_JSIL_JSIL_PARSE_TREE_H diff --git a/src/jsil/jsil_parser.cpp b/src/jsil/jsil_parser.cpp index de11bc731e8..e6d17c1e13c 100644 --- a/src/jsil/jsil_parser.cpp +++ b/src/jsil/jsil_parser.cpp @@ -6,13 +6,22 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include "jsil_parser.h" jsil_parsert jsil_parser; +/*******************************************************************\ + +Function: yyjsilerror + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + extern char *yyjsiltext; int yyjsilerror(const std::string &error) diff --git a/src/jsil/jsil_parser.h b/src/jsil/jsil_parser.h index 2aad7767e34..7cf55a32f69 100644 --- a/src/jsil/jsil_parser.h +++ b/src/jsil/jsil_parser.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_PARSER_H #define CPROVER_JSIL_JSIL_PARSER_H diff --git a/src/jsil/jsil_typecheck.cpp b/src/jsil/jsil_typecheck.cpp index e71c98a28c3..a644f1acf99 100644 --- a/src/jsil/jsil_typecheck.cpp +++ b/src/jsil/jsil_typecheck.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include #include @@ -18,22 +15,69 @@ Author: Michael Tautschnig, tautschn@amazon.com #include "jsil_typecheck.h" +/*******************************************************************\ + +Function: java_bytecode_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string jsil_typecheckt::to_string(const exprt &expr) { return expr2jsil(expr, ns); } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string jsil_typecheckt::to_string(const typet &type) { return type2jsil(type, ns); } -/// Prefix parameters and variables with a procedure name +/*******************************************************************\ + +Function: jsil_typecheckt::add_prefix + + Inputs: + + Outputs: + + Purpose: Prefix parameters and variables with a procedure name + +\*******************************************************************/ + irep_idt jsil_typecheckt::add_prefix(const irep_idt &ds) { return id2string(proc_name) + "::" + id2string(ds); } +/*******************************************************************\ + +Function: jsil_typecheckt::update_expr_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::update_expr_type(exprt &expr, const typet &type) { expr.type()=type; @@ -56,6 +100,18 @@ void jsil_typecheckt::update_expr_type(exprt &expr, const typet &type) } } +/*******************************************************************\ + +Function: jsil_typecheckt::make_type_compatible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::make_type_compatible( exprt &expr, const typet &type, @@ -95,6 +151,18 @@ void jsil_typecheckt::make_type_compatible( } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_type(typet &type) { if(type.id()==ID_code) @@ -133,6 +201,18 @@ void jsil_typecheckt::typecheck_type(typet &type) } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr(exprt &expr) { // first do sub-nodes @@ -142,12 +222,36 @@ void jsil_typecheckt::typecheck_expr(exprt &expr) typecheck_expr_main(expr); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_expr_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_operands(exprt &expr) { Forall_operands(it, expr) typecheck_expr(*it); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_expr_main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_main(exprt &expr) { if(expr.id()==ID_code) @@ -265,6 +369,18 @@ void jsil_typecheckt::typecheck_expr_main(exprt &expr) } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_expr_side_effect_throw + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_side_effect_throw( side_effect_expr_throwt &expr) { @@ -274,6 +390,18 @@ void jsil_typecheckt::typecheck_expr_side_effect_throw( typecheck_symbol_expr(s); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_expr_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_constant(exprt &expr) { if(expr.id()==ID_null) @@ -284,6 +412,18 @@ void jsil_typecheckt::typecheck_expr_constant(exprt &expr) expr.type()=jsil_empty_type(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_proto_field + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_proto_field(exprt &expr) { if(expr.operands().size()!=2) @@ -300,6 +440,18 @@ void jsil_typecheckt::typecheck_expr_proto_field(exprt &expr) expr.type()=jsil_value_or_empty_type(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_proto_field + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_proto_obj(exprt &expr) { if(expr.operands().size()!=2) @@ -316,6 +468,18 @@ void jsil_typecheckt::typecheck_expr_proto_obj(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_delete + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_delete(exprt &expr) { if(expr.operands().size()!=2) @@ -332,6 +496,18 @@ void jsil_typecheckt::typecheck_expr_delete(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_hasfield + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_index(exprt &expr) { if(expr.operands().size()!=2) @@ -352,6 +528,18 @@ void jsil_typecheckt::typecheck_expr_index(exprt &expr) expr.type()=jsil_value_type(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_hasfield + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_has_field(exprt &expr) { if(expr.operands().size()!=2) @@ -368,6 +556,18 @@ void jsil_typecheckt::typecheck_expr_has_field(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_field + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_field(exprt &expr) { if(expr.operands().size()!=1) @@ -383,6 +583,18 @@ void jsil_typecheckt::typecheck_expr_field(exprt &expr) expr.type()=string_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_base + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_base(exprt &expr) { if(expr.operands().size()!=1) @@ -398,6 +610,18 @@ void jsil_typecheckt::typecheck_expr_base(exprt &expr) expr.type()=jsil_value_type(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_ref + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_ref(exprt &expr) { if(expr.operands().size()!=3) @@ -428,6 +652,18 @@ void jsil_typecheckt::typecheck_expr_ref(exprt &expr) } } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_concatenation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_concatenation(exprt &expr) { if(expr.operands().size()!=2) @@ -444,6 +680,18 @@ void jsil_typecheckt::typecheck_expr_concatenation(exprt &expr) expr.type()=string_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_subtype + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_subtype(exprt &expr) { if(expr.operands().size()!=2) @@ -460,6 +708,18 @@ void jsil_typecheckt::typecheck_expr_subtype(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_binary_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_binary_boolean(exprt &expr) { if(expr.operands().size()!=2) @@ -476,6 +736,18 @@ void jsil_typecheckt::typecheck_expr_binary_boolean(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_binary_arith + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_binary_arith(exprt &expr) { if(expr.operands().size()!=2) @@ -493,6 +765,18 @@ void jsil_typecheckt::typecheck_expr_binary_arith(exprt &expr) expr.type()=floatbv_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_exp_binary_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_exp_binary_equal(exprt &expr) { if(expr.operands().size()!=2) @@ -508,6 +792,18 @@ void jsil_typecheckt::typecheck_exp_binary_equal(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_binary_compare + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_binary_compare(exprt &expr) { if(expr.operands().size()!=2) @@ -524,6 +820,18 @@ void jsil_typecheckt::typecheck_expr_binary_compare(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_unary_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_unary_boolean(exprt &expr) { if(expr.operands().size()!=1) @@ -539,6 +847,18 @@ void jsil_typecheckt::typecheck_expr_unary_boolean(exprt &expr) expr.type()=bool_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_unary_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_unary_string(exprt &expr) { if(expr.operands().size()!=1) @@ -554,6 +874,18 @@ void jsil_typecheckt::typecheck_expr_unary_string(exprt &expr) expr.type()=floatbv_typet(); } +/*******************************************************************\ + +Function: jsil_typecheck_baset::typecheck_expr_unary_num + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_expr_unary_num(exprt &expr) { if(expr.operands().size()!=1) @@ -567,6 +899,18 @@ void jsil_typecheckt::typecheck_expr_unary_num(exprt &expr) make_type_compatible(expr.op0(), floatbv_typet(), true); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_symbol_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr) { irep_idt identifier=symbol_expr.get_identifier(); @@ -645,6 +989,18 @@ void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr) } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_code(codet &code) { const irep_idt &statement=code.get_statement(); @@ -693,18 +1049,54 @@ void jsil_typecheckt::typecheck_code(codet &code) } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_return + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_return(code_returnt &code) { if(code.has_return_value()) typecheck_expr(code.return_value()); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_block(codet &code) { Forall_operands(it, code) typecheck_code(to_code(*it)); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_try_catch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_try_catch(code_try_catcht &code) { // A special case of try catch with one catch clause @@ -723,6 +1115,18 @@ void jsil_typecheckt::typecheck_try_catch(code_try_catcht &code) typecheck_code(code.get_catch_code(0)); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_function_call( code_function_callt &call) { @@ -825,6 +1229,18 @@ void jsil_typecheckt::typecheck_function_call( } } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_ifthenelse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) { exprt &cond=code.cond(); @@ -837,6 +1253,18 @@ void jsil_typecheckt::typecheck_ifthenelse(code_ifthenelset &code) typecheck_code(to_code(code.else_case())); } +/*******************************************************************\ + +Function: jsil_typecheckt::typecheck_assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck_assign(code_assignt &code) { typecheck_expr(code.op0()); @@ -845,9 +1273,20 @@ void jsil_typecheckt::typecheck_assign(code_assignt &code) make_type_compatible(code.op0(), code.op1().type(), false); } -/// typecheking procedure declaration; any other symbols should have been -/// typechecked during typecheking of procedure declaration -/// \par parameters: any symbol +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck_non_type_symbol + + Inputs: any symbol + + Outputs: + + Purpose: typecheking procedure declaration; any other symbols + should have been typechecked during typecheking of procedure + declaration + +\*******************************************************************/ + void jsil_typecheckt::typecheck_non_type_symbol(symbolt &symbol) { assert(!symbol.is_type); @@ -880,6 +1319,18 @@ void jsil_typecheckt::typecheck_non_type_symbol(symbolt &symbol) } } +/*******************************************************************\ + +Function: java_bytecode_typecheckt::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsil_typecheckt::typecheck() { // The hash table iterators are not stable, @@ -910,6 +1361,18 @@ void jsil_typecheckt::typecheck() } } +/*******************************************************************\ + +Function: jsil_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_typecheck( symbol_tablet &symbol_table, message_handlert &message_handler) @@ -918,6 +1381,18 @@ bool jsil_typecheck( return jsil_typecheck.typecheck_main(); } +/*******************************************************************\ + +Function: jsil_typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_typecheck( exprt &expr, message_handlert &message_handler, diff --git a/src/jsil/jsil_typecheck.h b/src/jsil/jsil_typecheck.h index a1be82cfddb..68988a80273 100644 --- a/src/jsil/jsil_typecheck.h +++ b/src/jsil/jsil_typecheck.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, tautschn@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_TYPECHECK_H #define CPROVER_JSIL_JSIL_TYPECHECK_H diff --git a/src/jsil/jsil_types.cpp b/src/jsil/jsil_types.cpp index 68c75b8827a..ffccfd16bbe 100644 --- a/src/jsil/jsil_types.cpp +++ b/src/jsil/jsil_types.cpp @@ -6,13 +6,22 @@ Author: Daiva Naudziuniene, daivan@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #include #include "jsil_types.h" +/*******************************************************************\ + +Function: jsil_any_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_any_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -22,6 +31,18 @@ typet jsil_any_type() }); } +/*******************************************************************\ + +Function: jsil_value_or_empty_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_value_or_empty_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -30,6 +51,18 @@ typet jsil_value_or_empty_type() }); } +/*******************************************************************\ + +Function: jsil_value_or_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_value_or_reference_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -38,6 +71,18 @@ typet jsil_value_or_reference_type() }); } +/*******************************************************************\ + +Function: jsil_value_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_value_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -48,6 +93,18 @@ typet jsil_value_type() }); } +/*******************************************************************\ + +Function: jsil_prim_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_prim_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -57,6 +114,18 @@ typet jsil_prim_type() }); } +/*******************************************************************\ + +Function: jsil_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_reference_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -65,16 +134,52 @@ typet jsil_reference_type() }); } +/*******************************************************************\ + +Function: jsil_member_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_member_reference_type() { return typet("jsil_member_reference_type"); } +/*******************************************************************\ + +Function: jsil_variable_reference_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_variable_reference_type() { return typet("jsil_variable_reference_type"); } +/*******************************************************************\ + +Function: jsil_object_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_object_type() { return jsil_union_typet({ // NOLINT(whitespace/braces) @@ -83,36 +188,120 @@ typet jsil_object_type() }); } +/*******************************************************************\ + +Function: jsil_user_object_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_user_object_type() { return typet("jsil_user_object_type"); } +/*******************************************************************\ + +Function: jsil_builtin_object_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_builtin_object_type() { return typet("jsil_builtin_object_type"); } +/*******************************************************************\ + +Function: jsil_null_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_null_type() { return typet("jsil_null_type"); } +/*******************************************************************\ + +Function: jsil_undefined_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_undefined_type() { return typet("jsil_undefined_type"); } +/*******************************************************************\ + +Function: jsil_kind + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_kind() { return typet("jsil_kind"); } +/*******************************************************************\ + +Function: jsil_empty_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_empty_type() { return typet("jsil_empty_type"); } +/*******************************************************************\ + +Function: jsil_is_subtype + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_is_subtype(const typet &type1, const typet &type2) { if(type2.id()==ID_union) @@ -128,18 +317,54 @@ bool jsil_is_subtype(const typet &type1, const typet &type2) return type1.id()==type2.id(); } +/*******************************************************************\ + +Function: jsil_incompatible_types + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_incompatible_types(const typet &type1, const typet &type2) { return jsil_union_typet(type1).intersect_with( jsil_union_typet(type2)).components().empty(); } +/*******************************************************************\ + +Function: jsil_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet jsil_union(const typet &type1, const typet &type2) { return jsil_union_typet(type1) .union_with(jsil_union_typet(type2)).to_type(); } +/*******************************************************************\ + +Function: compare_components + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool compare_components( const union_typet::componentt &comp1, const union_typet::componentt &comp2) @@ -147,6 +372,18 @@ bool compare_components( return comp1.type().id() &types): union_typet() { @@ -165,6 +402,18 @@ jsil_union_typet::jsil_union_typet(const std::vector &types): std::sort(elements.begin(), elements.end(), compare_components); } +/*******************************************************************\ + +Function: jsil_union_typet::union_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + jsil_union_typet jsil_union_typet::union_with( const jsil_union_typet &other) const { @@ -182,6 +431,17 @@ jsil_union_typet jsil_union_typet::union_with( return result; } +/*******************************************************************\ + +Function: jsil_union_typet::intersect_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ jsil_union_typet jsil_union_typet::intersect_with( const jsil_union_typet &other) const { @@ -199,6 +459,18 @@ jsil_union_typet jsil_union_typet::intersect_with( return result; } +/*******************************************************************\ + +Function: jsil_union_typet::is_subtype + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool jsil_union_typet::is_subtype(const jsil_union_typet &other) const { auto it=components().begin(); @@ -232,6 +504,18 @@ bool jsil_union_typet::is_subtype(const jsil_union_typet &other) const return true; } +/*******************************************************************\ + +Function: jsil_union_typet::to_type() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &jsil_union_typet::to_type() const { auto &elements=components(); diff --git a/src/jsil/jsil_types.h b/src/jsil/jsil_types.h index b3b5a159b40..b27be7f3219 100644 --- a/src/jsil/jsil_types.h +++ b/src/jsil/jsil_types.h @@ -6,9 +6,6 @@ Author: Daiva Naudziuniene, daivan@amazon.com \*******************************************************************/ -/// \file -/// Jsil Language - #ifndef CPROVER_JSIL_JSIL_TYPES_H #define CPROVER_JSIL_JSIL_TYPES_H diff --git a/src/json/json_parser.cpp b/src/json/json_parser.cpp index 6a654753f21..04c6d7dbfde 100644 --- a/src/json/json_parser.cpp +++ b/src/json/json_parser.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com json_parsert json_parser; +/*******************************************************************\ + +Function: parse_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // 'do it all' function bool parse_json( std::istream &in, @@ -36,6 +48,18 @@ bool parse_json( return result; } +/*******************************************************************\ + +Function: parse_json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // 'do it all' function bool parse_json( const std::string &filename, diff --git a/src/langapi/language_ui.cpp b/src/langapi/language_ui.cpp index bfd11c2db49..73016a87874 100644 --- a/src/langapi/language_ui.cpp +++ b/src/langapi/language_ui.cpp @@ -18,7 +18,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "language_ui.h" #include "mode.h" -/// Constructor +/*******************************************************************\ + +Function: language_uit::language_uit + + Inputs: + + Outputs: + + Purpose: Constructor + +\*******************************************************************/ + language_uit::language_uit( const cmdlinet &cmdline, ui_message_handlert &_ui_message_handler): @@ -28,11 +39,34 @@ language_uit::language_uit( set_message_handler(ui_message_handler); } -/// Destructor +/*******************************************************************\ + +Function: language_uit::~language_uit + + Inputs: + + Outputs: + + Purpose: Destructor + +\*******************************************************************/ + language_uit::~language_uit() { } +/*******************************************************************\ + +Function: language_uit::parse() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_uit::parse() { for(unsigned i=0; i<_cmdline.args.size(); i++) @@ -44,6 +78,18 @@ bool language_uit::parse() return false; } +/*******************************************************************\ + +Function: language_uit::parse() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_uit::parse(const std::string &filename) { #ifdef _MSC_VER @@ -92,6 +138,18 @@ bool language_uit::parse(const std::string &filename) return false; } +/*******************************************************************\ + +Function: language_uit::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_uit::typecheck() { status() << "Converting" << eom; @@ -107,6 +165,18 @@ bool language_uit::typecheck() return false; } +/*******************************************************************\ + +Function: language_uit::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_uit::final() { language_files.set_message_handler(*message_handler); @@ -124,6 +194,18 @@ bool language_uit::final() return false; } +/*******************************************************************\ + +Function: language_uit::show_symbol_table + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void language_uit::show_symbol_table(bool brief) { switch(get_ui()) @@ -141,11 +223,35 @@ void language_uit::show_symbol_table(bool brief) } } +/*******************************************************************\ + +Function: language_uit::show_symbol_table_xml_ui + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void language_uit::show_symbol_table_xml_ui(bool brief) { error() << "cannot show symbol table in this format" << eom; } +/*******************************************************************\ + +Function: language_uit::show_symbol_table_plain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void language_uit::show_symbol_table_plain( std::ostream &out, bool brief) diff --git a/src/langapi/language_util.cpp b/src/langapi/language_util.cpp index 878c3943a32..d8c53ec9341 100644 --- a/src/langapi/language_util.cpp +++ b/src/langapi/language_util.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "language_util.h" #include "mode.h" +/*******************************************************************\ + +Function: get_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static languaget* get_language( const namespacet &ns, const irep_idt &identifier) @@ -36,6 +48,18 @@ static languaget* get_language( return ptr; } +/*******************************************************************\ + +Function: from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string from_expr( const namespacet &ns, const irep_idt &identifier, @@ -49,6 +73,18 @@ std::string from_expr( return result; } +/*******************************************************************\ + +Function: from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string from_type( const namespacet &ns, const irep_idt &identifier, @@ -62,6 +98,18 @@ std::string from_type( return result; } +/*******************************************************************\ + +Function: type_to_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type_to_name( const namespacet &ns, const irep_idt &identifier, @@ -75,18 +123,54 @@ std::string type_to_name( return result; } +/*******************************************************************\ + +Function: from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string from_expr(const exprt &expr) { symbol_tablet symbol_table; return from_expr(namespacet(symbol_table), "", expr); } +/*******************************************************************\ + +Function: from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string from_type(const typet &type) { symbol_tablet symbol_table; return from_type(namespacet(symbol_table), "", type); } +/*******************************************************************\ + +Function: to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt to_expr( const namespacet &ns, const irep_idt &identifier, @@ -104,6 +188,18 @@ exprt to_expr( return expr; } +/*******************************************************************\ + +Function: type_to_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string type_to_name(const typet &type) { symbol_tablet symbol_table; diff --git a/src/langapi/languages.cpp b/src/langapi/languages.cpp index 2d83653f590..31ab9d37e7a 100644 --- a/src/langapi/languages.cpp +++ b/src/langapi/languages.cpp @@ -8,11 +8,35 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include "languages.h" +/*******************************************************************\ + +Function: languagest::languagest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languagest::languagest(const namespacet &_ns, languaget *_language):ns(_ns) { language=_language; } +/*******************************************************************\ + +Function: languagest::~languagest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languagest::~languagest() { delete language; diff --git a/src/langapi/mode.cpp b/src/langapi/mode.cpp index 20801fb9ae8..525a9519afd 100644 --- a/src/langapi/mode.cpp +++ b/src/langapi/mode.cpp @@ -28,6 +28,18 @@ struct language_entryt typedef std::list languagest; languagest languages; +/*******************************************************************\ + +Function: register_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void register_language(language_factoryt factory) { languages.push_back(language_entryt()); @@ -37,6 +49,18 @@ void register_language(language_factoryt factory) languages.back().mode=l->id(); } +/*******************************************************************\ + +Function: get_language_from_mode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *get_language_from_mode(const irep_idt &mode) { for(languagest::const_iterator it=languages.begin(); @@ -48,6 +72,18 @@ languaget *get_language_from_mode(const irep_idt &mode) return NULL; } +/*******************************************************************\ + +Function: get_language_from_filename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *get_language_from_filename(const std::string &filename) { std::size_t ext_pos=filename.rfind('.'); @@ -82,6 +118,18 @@ languaget *get_language_from_filename(const std::string &filename) return NULL; } +/*******************************************************************\ + +Function: get_default_language + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + languaget *get_default_language() { assert(!languages.empty()); diff --git a/src/linking/linking.cpp b/src/linking/linking.cpp index 5ce07f2a30c..173d5b2cf4c 100644 --- a/src/linking/linking.cpp +++ b/src/linking/linking.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Linking - #include #include @@ -25,6 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "linking.h" #include "linking_class.h" +/*******************************************************************\ + +Function: linkingt::expr_to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string linkingt::expr_to_string( const namespacet &ns, const irep_idt &identifier, @@ -33,6 +42,18 @@ std::string linkingt::expr_to_string( return from_expr(ns, identifier, expr); } +/*******************************************************************\ + +Function: linkingt::type_to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string linkingt::type_to_string( const namespacet &ns, const irep_idt &identifier, @@ -41,6 +62,18 @@ std::string linkingt::type_to_string( return from_type(ns, identifier, type); } +/*******************************************************************\ + +Function: follow_tags_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static const typet &follow_tags_symbols( const namespacet &ns, const typet &type) @@ -57,6 +90,18 @@ static const typet &follow_tags_symbols( return type; } +/*******************************************************************\ + +Function: linkingt::type_to_string_verbose + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string linkingt::type_to_string_verbose( const namespacet &ns, const symbolt &symbol, @@ -111,6 +156,18 @@ std::string linkingt::type_to_string_verbose( return type_to_string(ns, symbol.name, type); } +/*******************************************************************\ + +Function: linkingt::detailed_conflict_report + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::detailed_conflict_report_rec( const symbolt &old_symbol, const symbolt &new_symbol, @@ -365,6 +422,18 @@ void linkingt::detailed_conflict_report_rec( #endif } +/*******************************************************************\ + +Function: linkingt::link_error + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::link_error( const symbolt &old_symbol, const symbolt &new_symbol, @@ -385,6 +454,18 @@ void linkingt::link_error( throw 0; } +/*******************************************************************\ + +Function: linkingt::link_warning + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::link_warning( const symbolt &old_symbol, const symbolt &new_symbol, @@ -403,6 +484,18 @@ void linkingt::link_warning( << type_to_string_verbose(ns, new_symbol) << eom; } +/*******************************************************************\ + +Function: linkingt::rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt linkingt::rename(const irep_idt id) { unsigned cnt=0; @@ -427,6 +520,18 @@ irep_idt linkingt::rename(const irep_idt id) } } +/*******************************************************************\ + +Function: linkingt::needs_renaming_non_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool linkingt::needs_renaming_non_type( const symbolt &old_symbol, const symbolt &new_symbol) @@ -441,6 +546,18 @@ bool linkingt::needs_renaming_non_type( return false; } +/*******************************************************************\ + +Function: linkingt::duplicate_code_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::duplicate_code_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -736,6 +853,18 @@ void linkingt::duplicate_code_symbol( } } +/*******************************************************************\ + +Function: linkingt::adjust_object_type_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool linkingt::adjust_object_type_rec( const typet &t1, const typet &t2, @@ -890,6 +1019,18 @@ bool linkingt::adjust_object_type_rec( return true; } +/*******************************************************************\ + +Function: linkingt::adjust_object_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool linkingt::adjust_object_type( const symbolt &old_symbol, const symbolt &new_symbol, @@ -905,6 +1046,18 @@ bool linkingt::adjust_object_type( return result; } +/*******************************************************************\ + +Function: linkingt::duplicate_object_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::duplicate_object_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -989,6 +1142,18 @@ void linkingt::duplicate_object_symbol( } } +/*******************************************************************\ + +Function: linkingt::duplicate_non_type_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::duplicate_non_type_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -1018,6 +1183,18 @@ void linkingt::duplicate_non_type_symbol( old_symbol.is_extern=old_symbol.is_extern && new_symbol.is_extern; } +/*******************************************************************\ + +Function: linkingt::duplicate_type_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::duplicate_type_symbol( symbolt &old_symbol, symbolt &new_symbol) @@ -1095,6 +1272,18 @@ void linkingt::duplicate_type_symbol( "unexpected difference between type symbols"); } +/*******************************************************************\ + +Function: linkingt::needs_renaming_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool linkingt::needs_renaming_type( const symbolt &old_symbol, const symbolt &new_symbol) @@ -1139,6 +1328,18 @@ bool linkingt::needs_renaming_type( return true; // different } +/*******************************************************************\ + +Function: linkingt::do_type_dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed) { // Any type that uses a symbol that will be renamed also @@ -1194,6 +1395,18 @@ void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed) } } +/*******************************************************************\ + +Function: linkingt::rename_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::rename_symbols(const id_sett &needs_to_be_renamed) { namespacet src_ns(src_symbol_table); @@ -1226,6 +1439,18 @@ void linkingt::rename_symbols(const id_sett &needs_to_be_renamed) } } +/*******************************************************************\ + +Function: linkingt::copy_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::copy_symbols() { // First apply the renaming @@ -1278,6 +1503,18 @@ void linkingt::copy_symbols() } } +/*******************************************************************\ + +Function: linkingt::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void linkingt::typecheck() { // We do this in three phases. We first figure out which symbols need to @@ -1314,6 +1551,18 @@ void linkingt::typecheck() copy_symbols(); } +/*******************************************************************\ + +Function: linking + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool linking( symbol_tablet &dest_symbol_table, symbol_tablet &new_symbol_table, diff --git a/src/linking/linking.h b/src/linking/linking.h index b565a65231e..22b54e55613 100644 --- a/src/linking/linking.h +++ b/src/linking/linking.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Linking - #ifndef CPROVER_LINKING_LINKING_H #define CPROVER_LINKING_LINKING_H diff --git a/src/linking/linking_class.h b/src/linking/linking_class.h index 274b430a709..dba9481f3ab 100644 --- a/src/linking/linking_class.h +++ b/src/linking/linking_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// ANSI-C Linking - #ifndef CPROVER_LINKING_LINKING_CLASS_H #define CPROVER_LINKING_LINKING_CLASS_H diff --git a/src/linking/remove_internal_symbols.cpp b/src/linking/remove_internal_symbols.cpp index 3aca40f8219..5b4a7b13625 100644 --- a/src/linking/remove_internal_symbols.cpp +++ b/src/linking/remove_internal_symbols.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Remove symbols that are internal only - #include #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening #include "remove_internal_symbols.h" +/*******************************************************************\ + +Function: get_symbols_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_symbols_rec( const namespacet &ns, const symbolt &symbol, @@ -61,15 +70,25 @@ void get_symbols_rec( } } -/// A symbol is EXPORTED if it is a * non-static function with body that is not -/// extern inline * symbol used in an EXPORTED symbol * type used in an EXPORTED -/// symbol -/// -/// Read -/// http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html -/// on "extern inline" -/// \par parameters: symbol table -/// \return symbol table, with internal symbols removed +/*******************************************************************\ + +Function: remove_internal_symbols + + Inputs: symbol table + + Outputs: symbol table, with internal symbols removed + + Purpose: A symbol is EXPORTED if it is a + * non-static function with body that is not extern inline + * symbol used in an EXPORTED symbol + * type used in an EXPORTED symbol + + Read + http://gcc.gnu.org/ml/gcc/2006-11/msg00006.html + on "extern inline" + +\*******************************************************************/ + void remove_internal_symbols( symbol_tablet &symbol_table) { diff --git a/src/linking/remove_internal_symbols.h b/src/linking/remove_internal_symbols.h index f9d8a465162..40711162e73 100644 --- a/src/linking/remove_internal_symbols.h +++ b/src/linking/remove_internal_symbols.h @@ -6,9 +6,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Remove symbols that are internal only - #ifndef CPROVER_LINKING_REMOVE_INTERNAL_SYMBOLS_H #define CPROVER_LINKING_REMOVE_INTERNAL_SYMBOLS_H diff --git a/src/linking/static_lifetime_init.cpp b/src/linking/static_lifetime_init.cpp index 6428fa3b39d..29f5005d685 100644 --- a/src/linking/static_lifetime_init.cpp +++ b/src/linking/static_lifetime_init.cpp @@ -23,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "static_lifetime_init.h" #include "zero_initializer.h" +/*******************************************************************\ + +Function: static_lifetime_init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool static_lifetime_init( symbol_tablet &symbol_table, const source_locationt &source_location, diff --git a/src/linking/zero_initializer.cpp b/src/linking/zero_initializer.cpp index 154b92217e2..9e96c48480b 100644 --- a/src/linking/zero_initializer.cpp +++ b/src/linking/zero_initializer.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Linking: Zero Initialization - #include #include @@ -59,6 +56,18 @@ class zero_initializert:public messaget const source_locationt &source_location); }; +/*******************************************************************\ + +Function: zero_initializert::zero_initializer_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt zero_initializert::zero_initializer_rec( const typet &type, const source_locationt &source_location) @@ -310,6 +319,18 @@ exprt zero_initializert::zero_initializer_rec( } } +/*******************************************************************\ + +Function: zero_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt zero_initializer( const typet &type, const source_locationt &source_location, @@ -320,6 +341,18 @@ exprt zero_initializer( return z_i(type, source_location); } +/*******************************************************************\ + +Function: zero_initializer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt zero_initializer( const typet &type, const source_locationt &source_location, diff --git a/src/linking/zero_initializer.h b/src/linking/zero_initializer.h index 3bb440b8b74..766fdf26784 100644 --- a/src/linking/zero_initializer.h +++ b/src/linking/zero_initializer.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Linking: Zero Initialization - #ifndef CPROVER_LINKING_ZERO_INITIALIZER_H #define CPROVER_LINKING_ZERO_INITIALIZER_H diff --git a/src/memory-models/mm2cpp.cpp b/src/memory-models/mm2cpp.cpp index 03f5c7fc2d0..bc3eb0d9e18 100644 --- a/src/memory-models/mm2cpp.cpp +++ b/src/memory-models/mm2cpp.cpp @@ -32,6 +32,18 @@ class mm2cppt void check_acyclic(const exprt &, unsigned indent); }; +/*******************************************************************\ + +Function: mm2cppt::text2c + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string mm2cppt::text2c(const irep_idt &src) { std::string result; @@ -49,6 +61,18 @@ std::string mm2cppt::text2c(const irep_idt &src) return result; } +/*******************************************************************\ + +Function: mm2cppt::check_acyclic + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mm2cppt::check_acyclic(const exprt &expr, unsigned indent) { if(expr.id()==ID_symbol) @@ -130,6 +154,18 @@ void mm2cppt::check_acyclic(const exprt &expr, unsigned indent) throw "acyclic cannot do "+expr.id_string(); } +/*******************************************************************\ + +Function: mm2cppt::instruction2cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mm2cppt::instruction2cpp(const codet &code, unsigned indent) { const irep_idt &statement=code.get_statement(); @@ -180,6 +216,18 @@ void mm2cppt::instruction2cpp(const codet &code, unsigned indent) } } +/*******************************************************************\ + +Function: mm2cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mm2cppt::operator()(const irept &instruction) { out << "// Generated by mmcc\n"; @@ -200,6 +248,18 @@ void mm2cppt::operator()(const irept &instruction) out << '\n'; } +/*******************************************************************\ + +Function: mm2cpp + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mm2cpp( const irep_idt &model_name, const irept &instruction, diff --git a/src/memory-models/mmcc_main.cpp b/src/memory-models/mmcc_main.cpp index 9e73843b3ce..a30d45515d5 100644 --- a/src/memory-models/mmcc_main.cpp +++ b/src/memory-models/mmcc_main.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// mmcc Main Module - #include #include "mmcc_parse_options.h" +/*******************************************************************\ + +Function: main / wmain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/memory-models/mmcc_parse_options.cpp b/src/memory-models/mmcc_parse_options.cpp index 02eea99d74f..859393f9726 100644 --- a/src/memory-models/mmcc_parse_options.cpp +++ b/src/memory-models/mmcc_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// mmcc Command Line Option Processing - #include #include @@ -20,12 +17,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "mm2cpp.h" #include "mmcc_parse_options.h" +/*******************************************************************\ + +Function: mmcc_parse_optionst::mmcc_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mmcc_parse_optionst::mmcc_parse_optionst(int argc, const char **argv): parse_options_baset(MMCC_OPTIONS, argc, argv) { } -/// invoke main modules +/*******************************************************************\ + +Function: mmcc_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int mmcc_parse_optionst::doit() { if(cmdline.isset("version")) @@ -72,6 +92,18 @@ int mmcc_parse_optionst::doit() return 0; } +/*******************************************************************\ + +Function: mmcc_parse_optionst::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int mmcc_parse_optionst::convert( std::istream &in, const std::string &file) @@ -93,7 +125,18 @@ int mmcc_parse_optionst::convert( return 0; } -/// display command line help +/*******************************************************************\ + +Function: mmcc_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void mmcc_parse_optionst::help() { std::cout << diff --git a/src/memory-models/mmcc_parse_options.h b/src/memory-models/mmcc_parse_options.h index 357ae91df20..07745b47944 100644 --- a/src/memory-models/mmcc_parse_options.h +++ b/src/memory-models/mmcc_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// mmcc Command Line Option Processing - #ifndef CPROVER_MEMORY_MODELS_MMCC_PARSE_OPTIONS_H #define CPROVER_MEMORY_MODELS_MMCC_PARSE_OPTIONS_H diff --git a/src/musketeer/cycles_visitor.cpp b/src/musketeer/cycles_visitor.cpp index 89d68e13ad5..762b667c6d2 100644 --- a/src/musketeer/cycles_visitor.cpp +++ b/src/musketeer/cycles_visitor.cpp @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// cycles visitor for computing edges involved for fencing - #include #include @@ -20,6 +17,18 @@ class instrumentert; /* implemented: BTWN1, BTWN4 */ #define BTWN1 +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* po^+ /\ U{C_1, ..., C_n} \/ delays */ void cycles_visitort::po_edges(std::set &edges) { @@ -244,6 +253,18 @@ void cycles_visitort::po_edges(std::set &edges) } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* C_j /\ po^+ /\ poWR */ void cycles_visitort::powr_constraint( const event_grapht::critical_cyclet &C_j, @@ -264,6 +285,18 @@ void cycles_visitort::powr_constraint( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* C_j /\ po^+ /\ poWW */ void cycles_visitort::poww_constraint( const event_grapht::critical_cyclet &C_j, @@ -284,6 +317,18 @@ void cycles_visitort::poww_constraint( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* C_j /\ po^+ /\ poRW */ void cycles_visitort::porw_constraint( const event_grapht::critical_cyclet &C_j, @@ -304,6 +349,18 @@ void cycles_visitort::porw_constraint( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* C_j /\ po^+ /\ poRR */ void cycles_visitort::porr_constraint( const event_grapht::critical_cyclet &C_j, @@ -324,6 +381,18 @@ void cycles_visitort::porr_constraint( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* C_j /\ comWR */ void cycles_visitort::com_constraint( const event_grapht::critical_cyclet &C_j, diff --git a/src/musketeer/cycles_visitor.h b/src/musketeer/cycles_visitor.h index 0b9b122eed8..f125b511668 100644 --- a/src/musketeer/cycles_visitor.h +++ b/src/musketeer/cycles_visitor.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// cycles visitor for computing edges involved for fencing - #ifndef CPROVER_MUSKETEER_CYCLES_VISITOR_H #define CPROVER_MUSKETEER_CYCLES_VISITOR_H diff --git a/src/musketeer/fence_assert.cpp b/src/musketeer/fence_assert.cpp index d44faf74689..06bea8537fc 100644 --- a/src/musketeer/fence_assert.cpp +++ b/src/musketeer/fence_assert.cpp @@ -7,11 +7,20 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for cycles affecting user-assertions and resolution - #include "fence_assert.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool fence_assert_insertert::find_assert( const event_grapht::critical_cyclet &cycle) const { @@ -19,6 +28,18 @@ bool fence_assert_insertert::find_assert( return true; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_assert_insertert::process_cycles_selection() { for(std::set::const_iterator diff --git a/src/musketeer/fence_assert.h b/src/musketeer/fence_assert.h index bc21b8b5319..7e18e1f8e56 100644 --- a/src/musketeer/fence_assert.h +++ b/src/musketeer/fence_assert.h @@ -7,9 +7,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for cycles affecting user-assertions and resolution - #ifndef CPROVER_MUSKETEER_FENCE_ASSERT_H #define CPROVER_MUSKETEER_FENCE_ASSERT_H diff --git a/src/musketeer/fence_inserter.cpp b/src/musketeer/fence_inserter.cpp index ea8388aecf5..20236dfb956 100644 --- a/src/musketeer/fence_inserter.cpp +++ b/src/musketeer/fence_inserter.cpp @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for all cycles and resolution - #include #include @@ -24,6 +21,18 @@ Author: Vincent Nimal class abstract_eventt; +/*******************************************************************\ + +Function: fence_insertert::fence_cost + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned fence_insertert::fence_cost(fence_typet f) const { switch(f) @@ -43,6 +52,18 @@ unsigned fence_insertert::fence_cost(fence_typet f) const return 0; } +/*******************************************************************\ + +Function: fence_insertert::compute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::compute() { compute_fence_options(); @@ -55,6 +76,18 @@ void fence_insertert::compute() instrumenter.message.result() << "no cycle concerned" << messaget::eom; } +/*******************************************************************\ + +Function: fence_insertert::preprocess + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::preprocess() { process_cycles_selection(); @@ -206,6 +239,18 @@ void fence_insertert::preprocess() } } +/*******************************************************************\ + +Function: fence_insertert::mip_set_var + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline fence_insertert::mip_set_var( ilpt &ilp, unsigned &i) @@ -308,6 +353,18 @@ void inline fence_insertert::mip_set_var( #endif } +/*******************************************************************\ + +Function: fence_insertert::mip_set_cst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline fence_insertert::mip_set_cst(ilpt &ilp, unsigned &i) { #ifdef HAVE_GLPK @@ -402,6 +459,18 @@ void inline fence_insertert::mip_set_cst(ilpt &ilp, unsigned &i) #endif } +/*******************************************************************\ + +Function: fence_insertert::mip_fill_matrix + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void inline fence_insertert::mip_fill_matrix( ilpt &ilp, unsigned &i, @@ -699,6 +768,18 @@ void inline fence_insertert::mip_fill_matrix( #endif } +/*******************************************************************\ + +Function: fence_insertert::solve() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::solve() { #ifdef HAVE_GLPK @@ -808,11 +889,35 @@ void fence_insertert::solve() #endif } +/*******************************************************************\ + +Function: fence_insertert::import_freq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::import_freq() { /* TODO */ } +/*******************************************************************\ + +Function: fence_insertert::print_to_file + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::print_to_file() { /* removes redundant (due to several call to the same fenced function) */ @@ -839,6 +944,18 @@ void fence_insertert::print_to_file() results.close(); } +/*******************************************************************\ + +Function: fence_insertert::print_to_file_2 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* prints final results */ void fence_insertert::print_to_file_2() { @@ -868,6 +985,18 @@ void fence_insertert::print_to_file_2() results.close(); } +/*******************************************************************\ + +Function: fence_insertert::print_to_file_3 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* prints final results */ void fence_insertert::print_to_file_3() { @@ -909,6 +1038,18 @@ void fence_insertert::print_to_file_3() results.close(); } +/*******************************************************************\ + +Function: fence_insertert::print_to_file_4 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* prints final results */ void fence_insertert::print_to_file_4() { @@ -953,6 +1094,18 @@ void fence_insertert::print_to_file_4() results.close(); } +/*******************************************************************\ + +Function: fence_insertert::to_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string fence_insertert::to_string(fence_typet f) const { switch(f) @@ -966,11 +1119,35 @@ std::string fence_insertert::to_string(fence_typet f) const assert(0); } +/*******************************************************************\ + +Function: fence_inserter::col_to_var + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline unsigned fence_insertert::col_to_var(unsigned u) const { return (u-u%fence_options)/fence_options+(u%fence_options!=0?1:0); } +/*******************************************************************\ + +Function: fence_insertert::col_to_fence + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline fence_insertert::fence_typet fence_insertert::col_to_fence(unsigned u) const { @@ -985,6 +1162,18 @@ inline fence_insertert::fence_typet fence_insertert::col_to_fence(unsigned u) assert(0); } +/*******************************************************************\ + +Function: fence_insertert::var_fence_to_col + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline unsigned fence_insertert::var_fence_to_col(fence_typet f, unsigned var) const { @@ -999,6 +1188,18 @@ inline unsigned fence_insertert::var_fence_to_col(fence_typet f, unsigned var) assert(0); } +/*******************************************************************\ + +Function: fence_insertert::compute_fence_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::compute_fence_options() { switch(model) @@ -1017,6 +1218,18 @@ void fence_insertert::compute_fence_options() } } +/*******************************************************************\ + +Function: fence_insertert::print_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_insertert::print_vars() const { instrumenter.message.statistics() @@ -1036,6 +1249,18 @@ void fence_insertert::print_vars() const << messaget::eom; } +/*******************************************************************\ + +Function: fence_insertert::get_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet fence_insertert::get_type(const irep_idt &id) { std::string copy=id2string(id); @@ -1081,6 +1306,18 @@ typet fence_insertert::get_type(const irep_idt &id) } } +/*******************************************************************\ + +Function: fence_insertert::type_component + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet fence_insertert::type_component( std::list::const_iterator it, std::list::const_iterator end, diff --git a/src/musketeer/fence_inserter.h b/src/musketeer/fence_inserter.h index 70676a01560..4d867b1ea90 100644 --- a/src/musketeer/fence_inserter.h +++ b/src/musketeer/fence_inserter.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for all cycles and resolution - #ifndef CPROVER_MUSKETEER_FENCE_INSERTER_H #define CPROVER_MUSKETEER_FENCE_INSERTER_H diff --git a/src/musketeer/fence_shared.cpp b/src/musketeer/fence_shared.cpp index d8de5c7e3b0..61d3651baf1 100644 --- a/src/musketeer/fence_shared.cpp +++ b/src/musketeer/fence_shared.cpp @@ -178,9 +178,20 @@ class fence_volatilet:public simple_insertiont {} }; -/// we can determine whether an access is volatile just by looking at the type -/// of the variables involved in the expression. We assume that the program is -/// correctly typed (i.e., volatile-marked) +/*******************************************************************\ + +Function: is_volatile + + Inputs: + + Outputs: + + Purpose: we can determine whether an access is volatile just by looking at + the type of the variables involved in the expression. We assume that the + program is correctly typed (i.e., volatile-marked) + +\*******************************************************************/ + bool fence_volatilet::is_volatile(const typet &src) const { if(src.get_bool(ID_C_volatile)) @@ -222,6 +233,18 @@ bool fence_volatilet::is_volatile(const typet &src) const return false; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_volatilet::compute() { std::cout << "--------" << std::endl; @@ -295,6 +318,18 @@ void fence_volatilet::compute() } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_all_sharedt::compute() { std::cout << "--------" << std::endl; @@ -412,6 +447,18 @@ void fence_all_sharedt::compute() } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_all_shared_aegt::compute() { message.status() << "--------" << messaget::eom; @@ -562,6 +609,18 @@ void fence_all_shared_aegt::fence_all_shared_aeg_explore( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_all_shared( message_handlert &message_handler, value_setst &value_sets, @@ -574,6 +633,18 @@ void fence_all_shared( instrumenter.do_it(); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_all_shared_aeg( message_handlert &message_handler, value_setst &value_sets, @@ -586,6 +657,18 @@ void fence_all_shared_aeg( instrumenter.do_it(); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_volatile( message_handlert &message_handler, value_setst &value_sets, diff --git a/src/musketeer/fence_shared.h b/src/musketeer/fence_shared.h index 370e39f817f..ecfb5ff4746 100644 --- a/src/musketeer/fence_shared.h +++ b/src/musketeer/fence_shared.h @@ -8,9 +8,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// (naive) Fence insertion - #ifndef CPROVER_MUSKETEER_FENCE_SHARED_H #define CPROVER_MUSKETEER_FENCE_SHARED_H diff --git a/src/musketeer/fence_user_def.cpp b/src/musketeer/fence_user_def.cpp index 8bf57a99b8c..f543efa7e97 100644 --- a/src/musketeer/fence_user_def.cpp +++ b/src/musketeer/fence_user_def.cpp @@ -7,11 +7,20 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for cycles affecting user-assertions and resolution - #include "fence_user_def.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool fence_user_def_insertert::contains_user_def( const event_grapht::critical_cyclet &cycle) const { @@ -31,6 +40,18 @@ bool fence_user_def_insertert::contains_user_def( return cycle.has_user_defined_fence; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_user_def_insertert::process_cycles_selection() { for(std::set::const_iterator diff --git a/src/musketeer/fence_user_def.h b/src/musketeer/fence_user_def.h index 04a1236fd46..1f95a4c84cf 100644 --- a/src/musketeer/fence_user_def.h +++ b/src/musketeer/fence_user_def.h @@ -7,9 +7,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP construction for cycles containing user-placed fences and resolution - #ifndef CPROVER_MUSKETEER_FENCE_USER_DEF_H #define CPROVER_MUSKETEER_FENCE_USER_DEF_H diff --git a/src/musketeer/fencer.cpp b/src/musketeer/fencer.cpp index 1f612d35e3b..4fc213908d4 100644 --- a/src/musketeer/fencer.cpp +++ b/src/musketeer/fencer.cpp @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Fence inference: Main - #include #include @@ -21,6 +18,18 @@ Author: Vincent Nimal #include "fence_assert.h" #include "fencer.h" +/*******************************************************************\ + +Function: fencer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_weak_memory( memory_modelt model, value_setst &value_sets, diff --git a/src/musketeer/fencer.h b/src/musketeer/fencer.h index b15cb631971..cc28d439497 100644 --- a/src/musketeer/fencer.h +++ b/src/musketeer/fencer.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Fence inference - #ifndef CPROVER_MUSKETEER_FENCER_H #define CPROVER_MUSKETEER_FENCER_H diff --git a/src/musketeer/graph_visitor.cpp b/src/musketeer/graph_visitor.cpp index 2ecca9e8651..a55a1bd22e5 100644 --- a/src/musketeer/graph_visitor.cpp +++ b/src/musketeer/graph_visitor.cpp @@ -6,15 +6,24 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// graph visitor for computing edges involved for fencing - #include "fence_inserter.h" #include "graph_visitor.h" /* implemented: BTWN1, BTWN4 */ #define BTWN1 +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::graph_explore( event_grapht &egraph, event_idt next, @@ -57,6 +66,18 @@ void const_graph_visitort::graph_explore( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::const_graph_explore( event_grapht &egraph, event_idt next, @@ -98,6 +119,18 @@ void const_graph_visitort::const_graph_explore( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::graph_explore_BC( event_grapht &egraph, event_idt next, @@ -160,6 +193,18 @@ void const_graph_visitort::graph_explore_BC( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::const_graph_explore_BC( event_grapht &egraph, event_idt next, @@ -215,6 +260,18 @@ void const_graph_visitort::const_graph_explore_BC( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::graph_explore_AC( event_grapht &egraph, event_idt next, @@ -275,6 +332,18 @@ void const_graph_visitort::graph_explore_AC( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::const_graph_explore_AC( event_grapht &egraph, event_idt next, @@ -331,6 +400,18 @@ void const_graph_visitort::const_graph_explore_AC( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::PT( const edget &e, std::set &edges) @@ -373,8 +454,18 @@ void const_graph_visitort::PT( edges.insert(fence_inserter.map_from_e[e]); } -/// \par parameters: e in comWR /\ C_j (invisible variables) -/// \return e's in po /\ C (problem variables) +/*******************************************************************\ + +Function: + + Inputs: e in comWR /\ C_j (invisible variables) + + Outputs: e's in po /\ C (problem variables) + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::CT( const edget &edge, std::set &edges) @@ -428,8 +519,18 @@ void const_graph_visitort::CT( } } -/// \par parameters: e in comWR /\ C_j (invisible variables) -/// \return e's in poRW/\ C (problem variables) +/*******************************************************************\ + +Function: + + Inputs: e in comWR /\ C_j (invisible variables) + + Outputs: e's in poRW/\ C (problem variables) + + Purpose: + +\*******************************************************************/ + void const_graph_visitort::CT_not_powr( const edget &edge, std::set &edges) diff --git a/src/musketeer/graph_visitor.h b/src/musketeer/graph_visitor.h index 2df40b7e1d3..0574cae885f 100644 --- a/src/musketeer/graph_visitor.h +++ b/src/musketeer/graph_visitor.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// graph visitor for computing edges involved for fencing - #ifndef CPROVER_MUSKETEER_GRAPH_VISITOR_H #define CPROVER_MUSKETEER_GRAPH_VISITOR_H diff --git a/src/musketeer/ilp.h b/src/musketeer/ilp.h index b8cbe4e9202..cecc47fb0a8 100644 --- a/src/musketeer/ilp.h +++ b/src/musketeer/ilp.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// ILP structure - #ifdef HAVE_GLPK #include #endif diff --git a/src/musketeer/languages.cpp b/src/musketeer/languages.cpp index a7e4497a038..92ceefa1a72 100644 --- a/src/musketeer/languages.cpp +++ b/src/musketeer/languages.cpp @@ -6,15 +6,24 @@ Module: Language Registration \*******************************************************************/ -/// \file -/// Language Registration - #include #include #include "musketeer_parse_options.h" +/*******************************************************************\ + +Function: goto_instrument_parse_optionst::register_languages + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_fence_inserter_parse_optionst::register_languages() { register_language(new_ansi_c_language); diff --git a/src/musketeer/musketeer_main.cpp b/src/musketeer/musketeer_main.cpp index b233c0080a0..238283400f8 100644 --- a/src/musketeer/musketeer_main.cpp +++ b/src/musketeer/musketeer_main.cpp @@ -6,11 +6,20 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Main Module - #include "musketeer_parse_options.h" +/*******************************************************************\ + +Function: main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int main(int argc, const char **argv) { goto_fence_inserter_parse_optionst parse_options(argc, argv); diff --git a/src/musketeer/musketeer_parse_options.cpp b/src/musketeer/musketeer_parse_options.cpp index cbebc767057..ae40a2f2318 100644 --- a/src/musketeer/musketeer_parse_options.cpp +++ b/src/musketeer/musketeer_parse_options.cpp @@ -6,9 +6,6 @@ Module: Main Module \*******************************************************************/ -/// \file -/// Main Module - #include #include #include @@ -49,6 +46,18 @@ Module: Main Module #include "replace_async.h" #include "infer_mode.h" +/*******************************************************************\ + +Function: goto_fence_inserter_parse_optionst::set_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_fence_inserter_parse_optionst::set_verbosity() { unsigned int v=8; // default @@ -63,7 +72,18 @@ void goto_fence_inserter_parse_optionst::set_verbosity() ui_message_handler.set_verbosity(v); } -/// invoke main modules +/*******************************************************************\ + +Function: goto_fence_inserter_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int goto_fence_inserter_parse_optionst::doit() { if(cmdline.isset("version")) @@ -130,6 +150,18 @@ int goto_fence_inserter_parse_optionst::doit() } } +/*******************************************************************\ + +Function: goto_fence_inserter_parse_optionst::get_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_fence_inserter_parse_optionst::get_goto_program( goto_functionst &goto_functions) { @@ -142,6 +174,18 @@ void goto_fence_inserter_parse_optionst::get_goto_program( config.set_from_symbol_table(symbol_table); } +/*******************************************************************\ + +Function: goto_fence_inserter_parse_optionst::instrument_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_fence_inserter_parse_optionst::instrument_goto_program( goto_functionst &goto_functions) { @@ -391,7 +435,18 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( label_properties(goto_functions); } -/// display command line help +/*******************************************************************\ + +Function: goto_fence_inserter_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void goto_fence_inserter_parse_optionst::help() { std::cout << diff --git a/src/musketeer/musketeer_parse_options.h b/src/musketeer/musketeer_parse_options.h index 13d0a07ef19..ca93c9de488 100644 --- a/src/musketeer/musketeer_parse_options.h +++ b/src/musketeer/musketeer_parse_options.h @@ -6,9 +6,6 @@ Module: Command Line Parsing \*******************************************************************/ -/// \file -/// Command Line Parsing - #ifndef CPROVER_MUSKETEER_MUSKETEER_PARSE_OPTIONS_H #define CPROVER_MUSKETEER_MUSKETEER_PARSE_OPTIONS_H diff --git a/src/musketeer/pensieve.cpp b/src/musketeer/pensieve.cpp index a870ae16045..649182e1696 100644 --- a/src/musketeer/pensieve.cpp +++ b/src/musketeer/pensieve.cpp @@ -16,6 +16,18 @@ Author: Vincent Nimal #include "pensieve.h" +/*******************************************************************\ + +Function: fencer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fence_pensieve( value_setst &value_sets, symbol_tablet &symbol_table, diff --git a/src/musketeer/pensieve.h b/src/musketeer/pensieve.h index 9513a26c433..298919f182f 100644 --- a/src/musketeer/pensieve.h +++ b/src/musketeer/pensieve.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Fence insertion following criteria of Pensieve (PPoPP'05) - #ifndef CPROVER_MUSKETEER_PENSIEVE_H #define CPROVER_MUSKETEER_PENSIEVE_H diff --git a/src/musketeer/propagate_const_function_pointers.cpp b/src/musketeer/propagate_const_function_pointers.cpp index 07838ce8d35..0fb2f0aad18 100644 --- a/src/musketeer/propagate_const_function_pointers.cpp +++ b/src/musketeer/propagate_const_function_pointers.cpp @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Constant Function Pointer Propagation - #include #include #include @@ -143,10 +140,20 @@ class const_function_pointer_propagationt } }; -/// \par parameters: 'it' pointing to the callsite to update, 'function' the -/// function -/// actually called, 'stack_scope' the place where the constant was -/// defined in the call stack +/*******************************************************************\ + +Function: + + Inputs: 'it' pointing to the callsite to update, 'function' the function + actually called, 'stack_scope' the place where the constant was + defined in the call stack + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_function_pointer_propagationt::dup_caller_and_inline_callee( const symbol_exprt &const_function, unsigned stack_scope) @@ -334,8 +341,19 @@ void const_function_pointer_propagationt::dup_caller_and_inline_callee( callsite_stack.swap(new_callsite_stack); } -/// adds const pointers (instantiated here or propagated) passed as arguments in -/// the map +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: adds const pointers (instantiated here or propagated) passed + as arguments in the map + +\*******************************************************************/ + void const_function_pointer_propagationt::arg_stackt::add_args( const symbol_exprt &const_function, goto_programt::instructionst::iterator it) @@ -413,6 +431,18 @@ void const_function_pointer_propagationt::arg_stackt::add_args( } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_function_pointer_propagationt::arg_stackt::remove_args() { /* remove the parameter names */ @@ -423,6 +453,18 @@ void const_function_pointer_propagationt::arg_stackt::remove_args() } } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void const_function_pointer_propagationt::propagate( const irep_idt &function_id) { @@ -543,6 +585,18 @@ void const_function_pointer_propagationt::propagate( functions_met.erase(function_id); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void propagate_const_function_pointers( symbol_tablet &symbol_table, goto_functionst &goto_functions, diff --git a/src/musketeer/propagate_const_function_pointers.h b/src/musketeer/propagate_const_function_pointers.h index af1b5497b41..0749a1ac4bd 100644 --- a/src/musketeer/propagate_const_function_pointers.h +++ b/src/musketeer/propagate_const_function_pointers.h @@ -6,9 +6,6 @@ Author: Vincent Nimal \*******************************************************************/ -/// \file -/// Constant Function Pointer Propagation - #ifndef CPROVER_MUSKETEER_PROPAGATE_CONST_FUNCTION_POINTERS_H #define CPROVER_MUSKETEER_PROPAGATE_CONST_FUNCTION_POINTERS_H diff --git a/src/path-symex/build_goto_trace.cpp b/src/path-symex/build_goto_trace.cpp index fed73f16457..4e7eafc2c94 100644 --- a/src/path-symex/build_goto_trace.cpp +++ b/src/path-symex/build_goto_trace.cpp @@ -6,12 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Build Goto Trace from State History - #include "build_goto_trace.h" -/// follow state history to build a goto trace +/*******************************************************************\ + +Function: build_goto_trace + + Inputs: + + Outputs: + + Purpose: follow state history to build a goto trace + +\*******************************************************************/ + void build_goto_trace( const path_symex_statet &state, const decision_proceduret &decision_procedure, diff --git a/src/path-symex/build_goto_trace.h b/src/path-symex/build_goto_trace.h index beb1a0e609d..e6fd1a6d493 100644 --- a/src/path-symex/build_goto_trace.h +++ b/src/path-symex/build_goto_trace.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Build Goto Trace from Path Symex History - // NOLINT(build/header_guard) as this file is also symlinked #ifndef CPROVER_PATH_SYMEX_BUILD_GOTO_TRACE_H #define CPROVER_PATH_SYMEX_BUILD_GOTO_TRACE_H diff --git a/src/path-symex/loc_ref.h b/src/path-symex/loc_ref.h index 8f192c79583..9a8ea0dc341 100644 --- a/src/path-symex/loc_ref.h +++ b/src/path-symex/loc_ref.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Locations - #ifndef CPROVER_PATH_SYMEX_LOC_REF_H #define CPROVER_PATH_SYMEX_LOC_REF_H diff --git a/src/path-symex/locs.cpp b/src/path-symex/locs.cpp index 8827605768d..fa8e9c4cbbd 100644 --- a/src/path-symex/locs.cpp +++ b/src/path-symex/locs.cpp @@ -6,17 +6,38 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Program Locations - #include "locs.h" +/*******************************************************************\ + +Function: locst::locst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + locst::locst( const namespacet &_ns): ns(_ns) { } +/*******************************************************************\ + +Function: locst::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void locst::build(const goto_functionst &goto_functions) { // build locations @@ -81,6 +102,18 @@ void locst::build(const goto_functionst &goto_functions) } } +/*******************************************************************\ + +Function: locst::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void locst::output(std::ostream &out) const { irep_idt function; diff --git a/src/path-symex/locs.h b/src/path-symex/locs.h index 67f52da1584..7f626a1d2bf 100644 --- a/src/path-symex/locs.h +++ b/src/path-symex/locs.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CFG made of Program Locations, built from goto_functionst - #ifndef CPROVER_PATH_SYMEX_LOCS_H #define CPROVER_PATH_SYMEX_LOCS_H diff --git a/src/path-symex/path_replay.cpp b/src/path-symex/path_replay.cpp index 6044692839c..9dcb0a0c920 100644 --- a/src/path-symex/path_replay.cpp +++ b/src/path-symex/path_replay.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dense Data Structure for Path Replay - #include "path_replay.h" +/*******************************************************************\ + +Function: path_replayt::get_branches + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void get_branches(path_symex_step_reft history) { // history trees are traversed effectively only backwards diff --git a/src/path-symex/path_replay.h b/src/path-symex/path_replay.h index 27b6359af9e..70861e8e5a8 100644 --- a/src/path-symex/path_replay.h +++ b/src/path-symex/path_replay.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dense Data Structure for Path Replay - #ifndef CPROVER_PATH_SYMEX_PATH_REPLAY_H #define CPROVER_PATH_SYMEX_PATH_REPLAY_H diff --git a/src/path-symex/path_symex.cpp b/src/path-symex/path_symex.cpp index fe366e142dd..eb58b330ab6 100644 --- a/src/path-symex/path_symex.cpp +++ b/src/path-symex/path_symex.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Concrete Symbolic Transformer - #include #include #include @@ -29,6 +26,18 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif +/*******************************************************************\ + +Function: path_symext::propagate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool path_symext::propagate(const exprt &src) { // propagate things that are 'simple enough' @@ -88,6 +97,18 @@ bool path_symext::propagate(const exprt &src) } } +/*******************************************************************\ + +Function: path_symext::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::assign( path_symex_statet &state, const exprt &lhs, @@ -131,6 +152,18 @@ void path_symext::assign( assign_rec(state, _guard, ssa_lhs, ssa_rhs); } +/*******************************************************************\ + +Function: path_symext::symex_malloc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline static typet c_sizeof_type_rec(const exprt &expr) { const irept &sizeof_type=expr.find(ID_C_c_sizeof_type); @@ -267,6 +300,18 @@ void path_symext::symex_malloc( } +/*******************************************************************\ + +Function: get_old_va_symb + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static irep_idt get_old_va_symbol( const path_symex_statet &state, const exprt &src) @@ -284,6 +329,18 @@ static irep_idt get_old_va_symbol( return irep_idt(); } +/*******************************************************************\ + +Function: path_symext::symex_va_arg_next + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::symex_va_arg_next( path_symex_statet &state, const exprt &lhs, @@ -343,6 +400,18 @@ void path_symext::symex_va_arg_next( assign(state, lhs, rhs); } +/*******************************************************************\ + +Function: path_symext::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::assign_rec( path_symex_statet &state, exprt::operandst &guard, @@ -610,6 +679,18 @@ void path_symext::assign_rec( } } +/*******************************************************************\ + +Function: path_symext::function_call_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::function_call_rec( path_symex_statet &state, const code_function_callt &call, @@ -793,6 +874,18 @@ void path_symext::function_call_rec( throw "TODO: function_call "+function.id_string(); } +/*******************************************************************\ + +Function: path_symext::return_from_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::return_from_function(path_symex_statet &state) { path_symex_statet::threadt &thread=state.threads[state.get_current_thread()]; @@ -828,6 +921,18 @@ void path_symext::return_from_function(path_symex_statet &state) } } +/*******************************************************************\ + +Function: path_symext::set_return_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::set_return_value( path_symex_statet &state, const exprt &v) @@ -840,6 +945,18 @@ void path_symext::set_return_value( thread.call_stack.back().return_rhs=v; } +/*******************************************************************\ + +Function: path_symext::do_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::do_goto( path_symex_statet &state, std::list &further_states) @@ -885,6 +1002,18 @@ void path_symext::do_goto( state.history->guard=negated_guard; } +/*******************************************************************\ + +Function: path_symext::do_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::do_goto( path_symex_statet &state, bool taken) @@ -921,6 +1050,18 @@ void path_symext::do_goto( } } +/*******************************************************************\ + +Function: path_symext::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::operator()( path_symex_statet &state, std::list &further_states) @@ -1083,6 +1224,18 @@ void path_symext::operator()( } } +/*******************************************************************\ + +Function: path_symext::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symext::operator()(path_symex_statet &state) { std::list further_states; @@ -1091,6 +1244,18 @@ void path_symext::operator()(path_symex_statet &state) throw "path_symext got unexpected further states"; } +/*******************************************************************\ + +Function: path_symex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex( path_symex_statet &state, std::list &further_states) @@ -1099,12 +1264,36 @@ void path_symex( path_symex(state, further_states); } +/*******************************************************************\ + +Function: path_symex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex(path_symex_statet &state) { path_symext path_symex; path_symex(state); } +/*******************************************************************\ + +Function: path_symex_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex_goto( path_symex_statet &state, bool taken) @@ -1113,6 +1302,18 @@ void path_symex_goto( path_symex.do_goto(state, taken); } +/*******************************************************************\ + +Function: path_symex_assert_fail + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex_assert_fail(path_symex_statet &state) { path_symext path_symex; diff --git a/src/path-symex/path_symex.h b/src/path-symex/path_symex.h index cc7a8912783..731ea87608e 100644 --- a/src/path-symex/path_symex.h +++ b/src/path-symex/path_symex.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Concrete Symbolic Transformer - // NOLINT(build/header_guard) as this file is also symlinked #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_H diff --git a/src/path-symex/path_symex_class.h b/src/path-symex/path_symex_class.h index 933b871e9fa..4eec3d4ff4c 100644 --- a/src/path-symex/path_symex_class.h +++ b/src/path-symex/path_symex_class.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Concrete Symbolic Transformer - #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_CLASS_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_CLASS_H diff --git a/src/path-symex/path_symex_history.cpp b/src/path-symex/path_symex_history.cpp index 502f3af19eb..7829f72c67a 100644 --- a/src/path-symex/path_symex_history.cpp +++ b/src/path-symex/path_symex_history.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// History of path-based symbolic simulator - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_symex_history.h" +/*******************************************************************\ + +Function: path_symex_stept::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex_stept::output(std::ostream &out) const { out << "PCs:"; @@ -36,6 +45,18 @@ void path_symex_stept::output(std::ostream &out) const out << "\n"; } +/*******************************************************************\ + +Function: path_symex_stept::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex_stept::convert(decision_proceduret &dest) const { if(ssa_rhs.is_not_nil()) @@ -45,6 +66,18 @@ void path_symex_stept::convert(decision_proceduret &dest) const dest << guard; } +/*******************************************************************\ + +Function: path_symex_step_reft::build_history + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_symex_step_reft::build_history( std::vector &dest) const { diff --git a/src/path-symex/path_symex_history.h b/src/path-symex/path_symex_history.h index 35cfcb6d591..3847138dc71 100644 --- a/src/path-symex/path_symex_history.h +++ b/src/path-symex/path_symex_history.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// History for path-based symbolic simulator - #ifndef CPROVER_PATH_SYMEX_PATH_SYMEX_HISTORY_H #define CPROVER_PATH_SYMEX_PATH_SYMEX_HISTORY_H diff --git a/src/path-symex/path_symex_state.cpp b/src/path-symex/path_symex_state.cpp index 55b7310e878..ebb7dda863a 100644 --- a/src/path-symex/path_symex_state.cpp +++ b/src/path-symex/path_symex_state.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// State of path-based symbolic simulator - #include #include #include @@ -26,6 +23,18 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif +/*******************************************************************\ + +Function: initial_state + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + path_symex_statet initial_state( var_mapt &var_map, const locst &locs, @@ -41,12 +50,36 @@ path_symex_statet initial_state( return s; } +/*******************************************************************\ + +Function: path_symex_statet::get_pc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + loc_reft path_symex_statet::get_pc() const { assert(current_thread #include @@ -21,6 +18,18 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif +/*******************************************************************\ + +Function: path_symex_statet::read + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::read(const exprt &src, bool propagate) { #ifdef DEBUG @@ -46,6 +55,18 @@ exprt path_symex_statet::read(const exprt &src, bool propagate) return tmp5; } +/*******************************************************************\ + +Function: path_symex_statet::expand_structs_and_arrays + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::expand_structs_and_arrays(const exprt &src) { #ifdef DEBUG @@ -159,6 +180,18 @@ exprt path_symex_statet::expand_structs_and_arrays(const exprt &src) return src; } +/*******************************************************************\ + +Function: path_symex_statet::array_theory + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::array_theory(const exprt &src, bool propagate) { // top-level constant-sized arrays only right now @@ -211,6 +244,18 @@ exprt path_symex_statet::array_theory(const exprt &src, bool propagate) return src; } +/*******************************************************************\ + +Function: path_symex_statet::instantiate_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::instantiate_rec( const exprt &src, bool propagate) @@ -303,6 +348,18 @@ exprt path_symex_statet::instantiate_rec( return src2; } +/*******************************************************************\ + +Function: path_symex_statet::read_symbol_member_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::read_symbol_member_index( const exprt &src, bool propagate) @@ -417,6 +474,18 @@ exprt path_symex_statet::read_symbol_member_index( } } +/*******************************************************************\ + +Function: path_symex_statet::is_symbol_member_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool path_symex_statet::is_symbol_member_index(const exprt &src) const { const typet final_type=src.type(); @@ -470,6 +539,18 @@ bool path_symex_statet::is_symbol_member_index(const exprt &src) const } } +/*******************************************************************\ + +Function: path_symex_statet::array_index_as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string path_symex_statet::array_index_as_string(const exprt &src) const { exprt tmp=simplify_expr(src, var_map.ns); @@ -481,6 +562,18 @@ std::string path_symex_statet::array_index_as_string(const exprt &src) const return "[*]"; } +/*******************************************************************\ + +Function: path_symex_statet::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::dereference_rec( const exprt &src, bool propagate) @@ -517,6 +610,18 @@ exprt path_symex_statet::dereference_rec( return src2; } +/*******************************************************************\ + +Function: path_symex_statet::instantiate_rec_address + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt path_symex_statet::instantiate_rec_address( const exprt &src, bool propagate) diff --git a/src/path-symex/var_map.cpp b/src/path-symex/var_map.cpp index 83193f4abc5..d981cf1cca9 100644 --- a/src/path-symex/var_map.cpp +++ b/src/path-symex/var_map.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Variable Numbering - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "var_map.h" +/*******************************************************************\ + +Function: var_mapt::var_infot::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + var_mapt::var_infot &var_mapt::operator()( const irep_idt &symbol, const irep_idt &suffix, @@ -44,6 +53,18 @@ var_mapt::var_infot &var_mapt::operator()( return result.first->second; } +/*******************************************************************\ + +Function: var_mapt::var_infot::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void var_mapt::var_infot::output(std::ostream &out) const { out << "full_identifier: " << full_identifier << "\n"; @@ -68,6 +89,18 @@ void var_mapt::var_infot::output(std::ostream &out) const out << "\n"; } +/*******************************************************************\ + +Function: var_mapt::init + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void var_mapt::init(var_infot &var_info) { if(has_prefix(id2string(var_info.symbol), "symex_dynamic::")) @@ -108,12 +141,36 @@ void var_mapt::init(var_infot &var_info) var_info.number=local_count++; } +/*******************************************************************\ + +Function: var_mapt::var_infot::ssa_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt var_mapt::var_infot::ssa_identifier() const { return id2string(full_identifier)+ "#"+std::to_string(ssa_counter); } +/*******************************************************************\ + +Function: var_mapt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void var_mapt::output(std::ostream &out) const { for(id_mapt::const_iterator diff --git a/src/path-symex/var_map.h b/src/path-symex/var_map.h index 11ffcdbdc49..cb5c7c7d9f5 100644 --- a/src/path-symex/var_map.h +++ b/src/path-symex/var_map.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Variable Numbering - #ifndef CPROVER_PATH_SYMEX_VAR_MAP_H #define CPROVER_PATH_SYMEX_VAR_MAP_H diff --git a/src/pointer-analysis/add_failed_symbols.cpp b/src/pointer-analysis/add_failed_symbols.cpp index ef8688285e7..0a8f757a6d8 100644 --- a/src/pointer-analysis/add_failed_symbols.cpp +++ b/src/pointer-analysis/add_failed_symbols.cpp @@ -6,20 +6,41 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #include #include #include #include "add_failed_symbols.h" +/*******************************************************************\ + +Function: failed_symbol_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt failed_symbol_id(const irep_idt &id) { return id2string(id)+"$object"; } +/*******************************************************************\ + +Function: add_failed_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table) { if(!symbol.is_lvalue) @@ -49,6 +70,18 @@ void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table) } } +/*******************************************************************\ + +Function: add_failed_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void add_failed_symbols(symbol_tablet &symbol_table) { // the symbol table iterators are not stable, and @@ -69,6 +102,18 @@ void add_failed_symbols(symbol_tablet &symbol_table) } } +/*******************************************************************\ + +Function: get_failed_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt get_failed_symbol( const symbol_exprt &expr, const namespacet &ns) diff --git a/src/pointer-analysis/add_failed_symbols.h b/src/pointer-analysis/add_failed_symbols.h index 2ae2228f564..ce1a3b97c9a 100644 --- a/src/pointer-analysis/add_failed_symbols.h +++ b/src/pointer-analysis/add_failed_symbols.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_ADD_FAILED_SYMBOLS_H #define CPROVER_POINTER_ANALYSIS_ADD_FAILED_SYMBOLS_H diff --git a/src/pointer-analysis/dereference.cpp b/src/pointer-analysis/dereference.cpp index e17d628e4f7..8638dff9e67 100644 --- a/src/pointer-analysis/dereference.cpp +++ b/src/pointer-analysis/dereference.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #ifdef DEBUG #include #include @@ -25,8 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "dereference.h" -/// \par parameters: expression, to be dereferenced -/// \return returns object after dereferencing +/*******************************************************************\ + +Function: dereferencet::operator() + + Inputs: expression, to be dereferenced + + Outputs: returns object after dereferencing + + Purpose: + +\*******************************************************************/ + exprt dereferencet::operator()(const exprt &pointer) { if(pointer.type().id()!=ID_pointer) @@ -46,6 +53,18 @@ exprt dereferencet::operator()(const exprt &pointer) type); } +/*******************************************************************\ + +Function: dereferencet::read_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dereferencet::read_object( const exprt &object, const exprt &offset, @@ -150,6 +169,18 @@ exprt dereferencet::read_object( return binary_exprt(object, byte_extract_id(), simplified_offset, dest_type); } +/*******************************************************************\ + +Function: dereferencet::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dereferencet::dereference_rec( const exprt &address, const exprt &offset, @@ -204,6 +235,18 @@ exprt dereferencet::dereference_rec( } } +/*******************************************************************\ + +Function: dereferencet::dereference_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dereferencet::dereference_if( const if_exprt &expr, const exprt &offset, @@ -216,6 +259,18 @@ exprt dereferencet::dereference_if( return if_exprt(expr.cond(), true_case, false_case); } +/*******************************************************************\ + +Function: dereferencet::dereference_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dereferencet::dereference_plus( const exprt &expr, const exprt &offset, @@ -251,6 +306,18 @@ exprt dereferencet::dereference_plus( return dereference_rec(pointer, new_offset, type); } +/*******************************************************************\ + +Function: dereferencet::dereference_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dereferencet::dereference_typecast( const typecast_exprt &expr, const exprt &offset, @@ -283,6 +350,18 @@ exprt dereferencet::dereference_typecast( throw "dereferencet: unexpected cast"; } +/*******************************************************************\ + +Function: dereferencet::type_compatible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool dereferencet::type_compatible( const typet &object_type, const typet &dereference_type) const diff --git a/src/pointer-analysis/dereference.h b/src/pointer-analysis/dereference.h index 968395b604f..5036f702cde 100644 --- a/src/pointer-analysis/dereference.h +++ b/src/pointer-analysis/dereference.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_DEREFERENCE_H diff --git a/src/pointer-analysis/dereference_callback.cpp b/src/pointer-analysis/dereference_callback.cpp index a28a51892e1..c13e2f359e4 100644 --- a/src/pointer-analysis/dereference_callback.cpp +++ b/src/pointer-analysis/dereference_callback.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #include "dereference_callback.h" +/*******************************************************************\ + +Function: dereference_callbackt::~dereference_callbackt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dereference_callbackt::~dereference_callbackt() { } diff --git a/src/pointer-analysis/dereference_callback.h b/src/pointer-analysis/dereference_callback.h index d02ea726f4b..9d9d1b69449 100644 --- a/src/pointer-analysis/dereference_callback.h +++ b/src/pointer-analysis/dereference_callback.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_DEREFERENCE_CALLBACK_H #define CPROVER_POINTER_ANALYSIS_DEREFERENCE_CALLBACK_H diff --git a/src/pointer-analysis/goto_program_dereference.cpp b/src/pointer-analysis/goto_program_dereference.cpp index 5665816cf67..3370abe7635 100644 --- a/src/pointer-analysis/goto_program_dereference.cpp +++ b/src/pointer-analysis/goto_program_dereference.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Dereferencing Operations on GOTO Programs - #include #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "goto_program_dereference.h" +/*******************************************************************\ + +Function: goto_program_dereferencet::has_failed_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_program_dereferencet::has_failed_symbol( const exprt &expr, const symbolt *&symbol) @@ -41,6 +50,18 @@ bool goto_program_dereferencet::has_failed_symbol( return false; } +/*******************************************************************\ + +Function: goto_program_dereferencet::is_valid_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool goto_program_dereferencet::is_valid_object( const irep_idt &identifier) { @@ -63,6 +84,18 @@ bool goto_program_dereferencet::is_valid_object( return false; } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference_failure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_failure( const std::string &property, const std::string &msg, @@ -92,6 +125,18 @@ void goto_program_dereferencet::dereference_failure( } } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_rec( exprt &expr, guardt &guard, @@ -229,6 +274,18 @@ void goto_program_dereferencet::dereference_rec( } } +/*******************************************************************\ + +Function: goto_program_dereferencet::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::get_value_set( const exprt &expr, value_setst::valuest &dest) @@ -236,6 +293,18 @@ void goto_program_dereferencet::get_value_set( value_sets.get_values(current_target, expr, dest); } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_expr( exprt &expr, const bool checks_only, @@ -252,6 +321,18 @@ void goto_program_dereferencet::dereference_expr( dereference_rec(expr, guard, mode); } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_program( goto_programt &goto_program, bool checks_only) @@ -276,6 +357,18 @@ void goto_program_dereferencet::dereference_program( } } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_program( goto_functionst &goto_functions, bool checks_only) @@ -287,6 +380,18 @@ void goto_program_dereferencet::dereference_program( dereference_program(it->second.body, checks_only); } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_instruction( goto_programt::targett target, bool checks_only) @@ -352,6 +457,18 @@ void goto_program_dereferencet::dereference_instruction( } } +/*******************************************************************\ + +Function: goto_program_dereferencet::dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::dereference_expression( goto_programt::const_targett target, exprt &expr) @@ -364,18 +481,54 @@ void goto_program_dereferencet::dereference_expression( dereference_expr(expr, false, value_set_dereferencet::modet::READ); } +/*******************************************************************\ + +Function: goto_program_dereferencet::pointer_checks + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::pointer_checks( goto_programt &goto_program) { dereference_program(goto_program, true); } +/*******************************************************************\ + +Function: goto_program_dereferencet::pointer_checks + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void goto_program_dereferencet::pointer_checks( goto_functionst &goto_functions) { dereference_program(goto_functions, true); } +/*******************************************************************\ + +Function: remove_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_pointers( goto_programt &goto_program, symbol_tablet &symbol_table, @@ -391,6 +544,18 @@ void remove_pointers( goto_program_dereference.dereference_program(goto_program); } +/*******************************************************************\ + +Function: remove_pointers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_pointers( goto_functionst &goto_functions, symbol_tablet &symbol_table, @@ -407,6 +572,18 @@ void remove_pointers( goto_program_dereference.dereference_program(it->second.body); } +/*******************************************************************\ + +Function: pointer_checks + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_checks( goto_programt &goto_program, symbol_tablet &symbol_table, @@ -419,6 +596,18 @@ void pointer_checks( goto_program_dereference.pointer_checks(goto_program); } +/*******************************************************************\ + +Function: pointer_checks + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_checks( goto_functionst &goto_functions, symbol_tablet &symbol_table, @@ -431,6 +620,18 @@ void pointer_checks( goto_program_dereference.pointer_checks(goto_functions); } +/*******************************************************************\ + +Function: dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dereference( goto_programt::const_targett target, exprt &expr, diff --git a/src/pointer-analysis/goto_program_dereference.h b/src/pointer-analysis/goto_program_dereference.h index c2fb0e9a1ff..33904035fdc 100644 --- a/src/pointer-analysis/goto_program_dereference.h +++ b/src/pointer-analysis/goto_program_dereference.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_POINTER_ANALYSIS_GOTO_PROGRAM_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_GOTO_PROGRAM_DEREFERENCE_H diff --git a/src/pointer-analysis/object_numbering.h b/src/pointer-analysis/object_numbering.h index 6e731bd072c..beddfb76ab6 100644 --- a/src/pointer-analysis/object_numbering.h +++ b/src/pointer-analysis/object_numbering.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_POINTER_ANALYSIS_OBJECT_NUMBERING_H #define CPROVER_POINTER_ANALYSIS_OBJECT_NUMBERING_H diff --git a/src/pointer-analysis/pointer_offset_sum.cpp b/src/pointer-analysis/pointer_offset_sum.cpp index ba6a17d2074..e0fa65ab519 100644 --- a/src/pointer-analysis/pointer_offset_sum.cpp +++ b/src/pointer-analysis/pointer_offset_sum.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Analysis - #include "pointer_offset_sum.h" +/*******************************************************************\ + +Function: pointer_offset_sum + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_offset_sum(const exprt &a, const exprt &b) { if(a.id()==ID_unknown) diff --git a/src/pointer-analysis/pointer_offset_sum.h b/src/pointer-analysis/pointer_offset_sum.h index e4e6dc238ff..c5569cf1685 100644 --- a/src/pointer-analysis/pointer_offset_sum.h +++ b/src/pointer-analysis/pointer_offset_sum.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_POINTER_OFFSET_SUM_H #define CPROVER_POINTER_ANALYSIS_POINTER_OFFSET_SUM_H diff --git a/src/pointer-analysis/rewrite_index.cpp b/src/pointer-analysis/rewrite_index.cpp index 1594267afbd..61e10530738 100644 --- a/src/pointer-analysis/rewrite_index.cpp +++ b/src/pointer-analysis/rewrite_index.cpp @@ -6,14 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #include #include "rewrite_index.h" -/// rewrite a[i] to *(a+i) +/*******************************************************************\ + +Function: rewrite_index + + Inputs: + + Outputs: + + Purpose: rewrite a[i] to *(a+i) + +\*******************************************************************/ + dereference_exprt rewrite_index(const index_exprt &index_expr) { dereference_exprt result; diff --git a/src/pointer-analysis/rewrite_index.h b/src/pointer-analysis/rewrite_index.h index 26cf5b19513..ee5f3b9bbfa 100644 --- a/src/pointer-analysis/rewrite_index.h +++ b/src/pointer-analysis/rewrite_index.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_REWRITE_INDEX_H #define CPROVER_POINTER_ANALYSIS_REWRITE_INDEX_H diff --git a/src/pointer-analysis/show_value_sets.cpp b/src/pointer-analysis/show_value_sets.cpp index b764f9738c9..cd5f4c84e17 100644 --- a/src/pointer-analysis/show_value_sets.cpp +++ b/src/pointer-analysis/show_value_sets.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show Value Sets - #include #include @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis.h" #include "show_value_sets.h" +/*******************************************************************\ + +Function: show_value_sets + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_value_sets( ui_message_handlert::uit ui, const goto_functionst &goto_functions, @@ -41,6 +50,18 @@ void show_value_sets( } } +/*******************************************************************\ + +Function: show_value_sets + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void show_value_sets( ui_message_handlert::uit ui, const goto_programt &goto_program, diff --git a/src/pointer-analysis/show_value_sets.h b/src/pointer-analysis/show_value_sets.h index d25b7addd4e..b98acbacd93 100644 --- a/src/pointer-analysis/show_value_sets.h +++ b/src/pointer-analysis/show_value_sets.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Show Value Sets - #ifndef CPROVER_POINTER_ANALYSIS_SHOW_VALUE_SETS_H #define CPROVER_POINTER_ANALYSIS_SHOW_VALUE_SETS_H diff --git a/src/pointer-analysis/value_set.cpp b/src/pointer-analysis/value_set.cpp index c2dce7b5e4e..b35952dc064 100644 --- a/src/pointer-analysis/value_set.cpp +++ b/src/pointer-analysis/value_set.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #include #include @@ -35,6 +32,18 @@ Author: Daniel Kroening, kroening@kroening.com const value_sett::object_map_dt value_sett::object_map_dt::blank; object_numberingt value_sett::object_numbering; +/*******************************************************************\ + +Function: value_sett::field_sensitive + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_sett::field_sensitive( const irep_idt &id, const typet &type, @@ -50,6 +59,18 @@ bool value_sett::field_sensitive( return ns.follow(type).id()==ID_struct; } +/*******************************************************************\ + +Function: value_sett::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + value_sett::entryt &value_sett::get_entry( const entryt &e, const typet &type, @@ -68,6 +89,18 @@ value_sett::entryt &value_sett::get_entry( return r.first->second; } +/*******************************************************************\ + +Function: value_sett::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_sett::insert( object_mapt &dest, unsigned n, @@ -93,6 +126,18 @@ bool value_sett::insert( } } +/*******************************************************************\ + +Function: value_sett::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::output( const namespacet &ns, std::ostream &out) const @@ -183,6 +228,18 @@ void value_sett::output( } } +/*******************************************************************\ + +Function: value_sett::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt value_sett::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -203,6 +260,18 @@ exprt value_sett::to_expr(object_map_dt::const_iterator it) const return od; } +/*******************************************************************\ + +Function: value_sett::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_sett::make_union(const value_sett::valuest &new_values) { bool result=false; @@ -242,6 +311,18 @@ bool value_sett::make_union(const value_sett::valuest &new_values) return result; } +/*******************************************************************\ + +Function: value_sett::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_sett::make_union(object_mapt &dest, const object_mapt &src) const { bool result=false; @@ -257,6 +338,18 @@ bool value_sett::make_union(object_mapt &dest, const object_mapt &src) const return result; } +/*******************************************************************\ + +Function: value_sett::eval_pointer_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_sett::eval_pointer_offset( exprt &expr, const namespacet &ns) const @@ -310,6 +403,18 @@ bool value_sett::eval_pointer_offset( return mod; } +/*******************************************************************\ + +Function: value_sett::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::get_value_set( const exprt &expr, value_setst::valuest &dest, @@ -331,6 +436,18 @@ void value_sett::get_value_set( #endif } +/*******************************************************************\ + +Function: value_sett::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::get_value_set( const exprt &expr, object_mapt &dest, @@ -344,6 +461,18 @@ void value_sett::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns); } +/*******************************************************************\ + +Function: value_sett::get_value_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -874,6 +1003,18 @@ void value_sett::get_value_set_rec( #endif } +/*******************************************************************\ + +Function: value_sett::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::dereference_rec( const exprt &src, exprt &dest) const @@ -892,6 +1033,18 @@ void value_sett::dereference_rec( dest=src; } +/*******************************************************************\ + +Function: value_sett::get_reference_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::get_reference_set( const exprt &expr, value_setst::valuest &dest, @@ -907,6 +1060,18 @@ void value_sett::get_reference_set( dest.push_back(to_expr(it)); } +/*******************************************************************\ + +Function: value_sett::get_reference_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::get_reference_set_rec( const exprt &expr, object_mapt &dest, @@ -1065,6 +1230,18 @@ void value_sett::get_reference_set_rec( insert(dest, exprt(ID_unknown, expr.type())); } +/*******************************************************************\ + +Function: value_sett::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::assign( const exprt &lhs, const exprt &rhs, @@ -1186,6 +1363,18 @@ void value_sett::assign( } } +/*******************************************************************\ + +Function: value_sett::do_free + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::do_free( const exprt &op, const namespacet &ns) @@ -1266,6 +1455,18 @@ void value_sett::do_free( } } +/*******************************************************************\ + +Function: value_sett::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1399,6 +1600,18 @@ void value_sett::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } +/*******************************************************************\ + +Function: value_sett::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1445,6 +1658,18 @@ void value_sett::do_function_call( // we could delete the dummy_arg_* now. } +/*******************************************************************\ + +Function: value_sett::do_end_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1457,6 +1682,18 @@ void value_sett::do_end_function( assign(lhs, rhs, ns, false, false); } +/*******************************************************************\ + +Function: value_sett::apply_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::apply_code( const codet &code, const namespacet &ns) @@ -1589,6 +1826,18 @@ void value_sett::apply_code( } } +/*******************************************************************\ + +Function: value_sett::guard + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_sett::guard( const exprt &expr, const namespacet &ns) @@ -1623,6 +1872,18 @@ void value_sett::guard( } } +/*******************************************************************\ + +Function: value_sett::make_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt value_sett::make_member( const exprt &src, const irep_idt &component_name, diff --git a/src/pointer-analysis/value_set.h b/src/pointer-analysis/value_set.h index 8fc7c0218f4..51bf74d48f2 100644 --- a/src/pointer-analysis/value_set.h +++ b/src/pointer-analysis/value_set.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_H diff --git a/src/pointer-analysis/value_set_analysis.cpp b/src/pointer-analysis/value_set_analysis.cpp index d1367f4e061..4e98c10aee4 100644 --- a/src/pointer-analysis/value_set_analysis.cpp +++ b/src/pointer-analysis/value_set_analysis.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation - #include #include #include @@ -18,18 +15,54 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis.h" +/*******************************************************************\ + +Function: value_set_analysist::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysist::initialize( const goto_programt &goto_program) { baset::initialize(goto_program); } +/*******************************************************************\ + +Function: value_set_analysist::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysist::initialize( const goto_functionst &goto_functions) { baset::initialize(goto_functions); } +/*******************************************************************\ + +Function: value_set_analysist::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysist::convert( const goto_programt &goto_program, const irep_idt &identifier, @@ -81,6 +114,18 @@ void value_set_analysist::convert( } } } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const goto_functionst &goto_functions, const value_set_analysist &value_set_analysis, @@ -99,6 +144,18 @@ void convert( } } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const goto_programt &goto_program, const value_set_analysist &value_set_analysis, diff --git a/src/pointer-analysis/value_set_analysis.h b/src/pointer-analysis/value_set_analysis.h index b41355abd73..3437b34af2c 100644 --- a/src/pointer-analysis/value_set_analysis.h +++ b/src/pointer-analysis/value_set_analysis.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_H diff --git a/src/pointer-analysis/value_set_analysis_fi.cpp b/src/pointer-analysis/value_set_analysis_fi.cpp index 63aaa330ac9..3ed2a07bc7d 100644 --- a/src/pointer-analysis/value_set_analysis_fi.cpp +++ b/src/pointer-analysis/value_set_analysis_fi.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation (Flow Insensitive) - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fi.h" +/*******************************************************************\ + +Function: value_set_analysis_fit::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::initialize( const goto_programt &goto_program) { @@ -26,6 +35,18 @@ void value_set_analysis_fit::initialize( add_vars(goto_program); } +/*******************************************************************\ + +Function: value_set_analysis_fit::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::initialize( const goto_functionst &goto_functions) { @@ -33,6 +54,18 @@ void value_set_analysis_fit::initialize( add_vars(goto_functions); } +/*******************************************************************\ + +Function: value_set_analysis_fit::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::add_vars( const goto_programt &goto_program) { @@ -81,6 +114,18 @@ void value_set_analysis_fit::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fit::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::get_entries( const symbolt &symbol, std::list &dest) @@ -88,6 +133,18 @@ void value_set_analysis_fit::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fit::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -125,6 +182,18 @@ void value_set_analysis_fit::get_entries_rec( } } +/*******************************************************************\ + +Function: value_set_analysis_fit::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::add_vars( const goto_functionst &goto_functions) { @@ -152,6 +221,18 @@ void value_set_analysis_fit::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fit::get_globals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fit::get_globals( std::list &dest) { @@ -162,6 +243,18 @@ void value_set_analysis_fit::get_globals( get_entries(it->second, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fit::check_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_analysis_fit::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fi.h b/src/pointer-analysis/value_set_analysis_fi.h index da50d27357c..e1c8f320cab 100644 --- a/src/pointer-analysis/value_set_analysis_fi.h +++ b/src/pointer-analysis/value_set_analysis_fi.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation (flow insensitive) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FI_H diff --git a/src/pointer-analysis/value_set_analysis_fivr.cpp b/src/pointer-analysis/value_set_analysis_fivr.cpp index dab177cc5f4..0180768250c 100644 --- a/src/pointer-analysis/value_set_analysis_fivr.cpp +++ b/src/pointer-analysis/value_set_analysis_fivr.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation (Flow Insensitive) - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fivr.h" +/*******************************************************************\ + +Function: value_set_analysis_fivrt::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::initialize( const goto_programt &goto_program) { @@ -26,6 +35,18 @@ void value_set_analysis_fivrt::initialize( add_vars(goto_program); } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::initialize( const goto_functionst &goto_functions) { @@ -33,6 +54,18 @@ void value_set_analysis_fivrt::initialize( add_vars(goto_functions); } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::add_vars( const goto_programt &goto_program) { @@ -71,6 +104,18 @@ void value_set_analysis_fivrt::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::get_entries( const symbolt &symbol, std::list &dest) @@ -78,6 +123,18 @@ void value_set_analysis_fivrt::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -115,6 +172,18 @@ void value_set_analysis_fivrt::get_entries_rec( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::add_vars( const goto_functionst &goto_functions) { @@ -142,6 +211,18 @@ void value_set_analysis_fivrt::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::get_globals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrt::get_globals( std::list &dest) { @@ -152,6 +233,18 @@ void value_set_analysis_fivrt::get_globals( get_entries(it->second, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fivrt::check_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_analysis_fivrt::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fivr.h b/src/pointer-analysis/value_set_analysis_fivr.h index 9161315f89a..e6e30cfb456 100644 --- a/src/pointer-analysis/value_set_analysis_fivr.h +++ b/src/pointer-analysis/value_set_analysis_fivr.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVR_H diff --git a/src/pointer-analysis/value_set_analysis_fivrns.cpp b/src/pointer-analysis/value_set_analysis_fivrns.cpp index 5fbd77522bf..1b7d2422186 100644 --- a/src/pointer-analysis/value_set_analysis_fivrns.cpp +++ b/src/pointer-analysis/value_set_analysis_fivrns.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation (Flow Insensitive, Validity Regions) - #include #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "value_set_analysis_fivrns.h" +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::initialize( const goto_programt &goto_program) { @@ -26,6 +35,18 @@ void value_set_analysis_fivrnst::initialize( add_vars(goto_program); } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::initialize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::initialize( const goto_functionst &goto_functions) { @@ -33,6 +54,18 @@ void value_set_analysis_fivrnst::initialize( add_vars(goto_functions); } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::add_vars( const goto_programt &goto_program) { @@ -71,6 +104,18 @@ void value_set_analysis_fivrnst::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::get_entries( const symbolt &symbol, std::list &dest) @@ -78,6 +123,18 @@ void value_set_analysis_fivrnst::get_entries( get_entries_rec(symbol.name, "", symbol.type, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::get_entries + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::get_entries_rec( const irep_idt &identifier, const std::string &suffix, @@ -115,6 +172,18 @@ void value_set_analysis_fivrnst::get_entries_rec( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::add_vars + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::add_vars( const goto_functionst &goto_functions) { @@ -142,6 +211,18 @@ void value_set_analysis_fivrnst::add_vars( } } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::get_globals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_analysis_fivrnst::get_globals( std::list &dest) { @@ -152,6 +233,18 @@ void value_set_analysis_fivrnst::get_globals( get_entries(it->second, dest); } +/*******************************************************************\ + +Function: value_set_analysis_fivrnst::check_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_analysis_fivrnst::check_type(const typet &type) { if(type.id()==ID_pointer) diff --git a/src/pointer-analysis/value_set_analysis_fivrns.h b/src/pointer-analysis/value_set_analysis_fivrns.h index e2a4e4d1306..b4d45524db2 100644 --- a/src/pointer-analysis/value_set_analysis_fivrns.h +++ b/src/pointer-analysis/value_set_analysis_fivrns.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ -/// \file -/// Value Set Analysis (Flow Insensitive, Validity Regions) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_ANALYSIS_FIVRNS_H diff --git a/src/pointer-analysis/value_set_dereference.cpp b/src/pointer-analysis/value_set_dereference.cpp index 754c1a5e9e0..411adddbe8e 100644 --- a/src/pointer-analysis/value_set_dereference.cpp +++ b/src/pointer-analysis/value_set_dereference.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution of ANSI-C - #ifdef DEBUG #include #endif @@ -45,11 +42,35 @@ Author: Daniel Kroening, kroening@kroening.com // global data, horrible unsigned int value_set_dereferencet::invalid_counter=0; +/*******************************************************************\ + +Function: value_set_dereferencet::has_dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_dereferencet::has_dereference(const exprt &expr) { return has_subexpr(expr, ID_dereference); } +/*******************************************************************\ + +Function: value_set_dereferencet::get_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt &value_set_dereferencet::get_symbol(const exprt &expr) { if(expr.id()==ID_member || expr.id()==ID_index) @@ -58,9 +79,19 @@ const exprt &value_set_dereferencet::get_symbol(const exprt &expr) return expr; } -/// \par parameters: expression dest, to be dereferenced under given guard, -/// and given mode -/// \return returns pointer after dereferencing +/*******************************************************************\ + +Function: value_set_dereferencet::dereference + + Inputs: expression dest, to be dereferenced under given guard, + and given mode + + Outputs: returns pointer after dereferencing + + Purpose: + +\*******************************************************************/ + exprt value_set_dereferencet::dereference( const exprt &pointer, const guardt &guard, @@ -211,6 +242,18 @@ exprt value_set_dereferencet::dereference( return value; } +/*******************************************************************\ + +Function: value_set_dereferencet::dereference_type_compare + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_dereferencet::dereference_type_compare( const typet &object_type, const typet &dereference_type) const @@ -244,6 +287,18 @@ bool value_set_dereferencet::dereference_type_compare( return false; } +/*******************************************************************\ + +Function: value_set_dereferencet::invalid_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_dereferencet::invalid_pointer( const exprt &pointer, const guardt &guard) @@ -261,6 +316,18 @@ void value_set_dereferencet::invalid_pointer( tmp_guard); } +/*******************************************************************\ + +Function: value_set_dereferencet::build_reference_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( const exprt &what, const modet mode, @@ -567,6 +634,18 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( return result; } +/*******************************************************************\ + +Function: value_set_dereferencet::valid_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_dereferencet::valid_check( const exprt &object, const guardt &guard, @@ -619,6 +698,18 @@ void value_set_dereferencet::valid_check( } } +/*******************************************************************\ + +Function: value_set_dereferencet::bounds_check + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_dereferencet::bounds_check( const index_exprt &expr, const guardt &guard) @@ -692,6 +783,18 @@ void value_set_dereferencet::bounds_check( } } +/*******************************************************************\ + +Function: value_set_dereferencet::memory_model + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline static unsigned bv_width( const typet &type, const namespacet &ns) @@ -761,6 +864,18 @@ bool value_set_dereferencet::memory_model( return memory_model_bytes(value, to_type, guard, offset); } +/*******************************************************************\ + +Function: value_set_dereferencet::memory_model_conversion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_dereferencet::memory_model_conversion( exprt &value, const typet &to_type, @@ -788,6 +903,18 @@ bool value_set_dereferencet::memory_model_conversion( return true; } +/*******************************************************************\ + +Function: value_set_dereferencet::memory_model_bytes + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_dereferencet::memory_model_bytes( exprt &value, const typet &to_type, diff --git a/src/pointer-analysis/value_set_dereference.h b/src/pointer-analysis/value_set_dereference.h index 4687d671ec6..19dde8e0f16 100644 --- a/src/pointer-analysis/value_set_dereference.h +++ b/src/pointer-analysis/value_set_dereference.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Dereferencing - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DEREFERENCE_H diff --git a/src/pointer-analysis/value_set_domain.cpp b/src/pointer-analysis/value_set_domain.cpp index 7ddfd6deb29..74656d23fe6 100644 --- a/src/pointer-analysis/value_set_domain.cpp +++ b/src/pointer-analysis/value_set_domain.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #include #include "value_set_domain.h" +/*******************************************************************\ + +Function: value_set_domaint::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_domaint::transform( const namespacet &ns, locationt from_l, diff --git a/src/pointer-analysis/value_set_domain.h b/src/pointer-analysis/value_set_domain.h index e59250a0bc0..df028b0d4e1 100644 --- a/src/pointer-analysis/value_set_domain.h +++ b/src/pointer-analysis/value_set_domain.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_H diff --git a/src/pointer-analysis/value_set_domain_fi.cpp b/src/pointer-analysis/value_set_domain_fi.cpp index 98e7509df3f..a5d0668fe90 100644 --- a/src/pointer-analysis/value_set_domain_fi.cpp +++ b/src/pointer-analysis/value_set_domain_fi.cpp @@ -7,13 +7,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Domain (Flow Insensitive) - #include #include "value_set_domain_fi.h" +/*******************************************************************\ + +Function: value_set_domain_fit::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_domain_fit::transform( const namespacet &ns, locationt from_l, diff --git a/src/pointer-analysis/value_set_domain_fi.h b/src/pointer-analysis/value_set_domain_fi.h index 24e2ac1be2c..ebcb9008f4c 100644 --- a/src/pointer-analysis/value_set_domain_fi.h +++ b/src/pointer-analysis/value_set_domain_fi.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FI_H diff --git a/src/pointer-analysis/value_set_domain_fivr.cpp b/src/pointer-analysis/value_set_domain_fivr.cpp index 8aa82787aa4..51e63dfb91f 100644 --- a/src/pointer-analysis/value_set_domain_fivr.cpp +++ b/src/pointer-analysis/value_set_domain_fivr.cpp @@ -7,13 +7,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Domain (Flow Insensitive, Sharing, Validity Regions) - #include #include "value_set_domain_fivr.h" +/*******************************************************************\ + +Function: value_set_domain_fivrt::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_domain_fivrt::transform( const namespacet &ns, locationt from_l, diff --git a/src/pointer-analysis/value_set_domain_fivr.h b/src/pointer-analysis/value_set_domain_fivr.h index 4ecb8879517..e1f82153191 100644 --- a/src/pointer-analysis/value_set_domain_fivr.h +++ b/src/pointer-analysis/value_set_domain_fivr.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Sharing, Validity Regions) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVR_H diff --git a/src/pointer-analysis/value_set_domain_fivrns.cpp b/src/pointer-analysis/value_set_domain_fivrns.cpp index 3688db0227c..8c8ef147dfa 100644 --- a/src/pointer-analysis/value_set_domain_fivrns.cpp +++ b/src/pointer-analysis/value_set_domain_fivrns.cpp @@ -7,13 +7,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Domain (Flow Insensitive, Validity Regions) - #include #include "value_set_domain_fivrns.h" +/*******************************************************************\ + +Function: value_set_domain_fivrnst::transform + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_domain_fivrnst::transform( const namespacet &ns, locationt from_l, diff --git a/src/pointer-analysis/value_set_domain_fivrns.h b/src/pointer-analysis/value_set_domain_fivrns.h index 4e7827e4617..62d4aeedc3e 100644 --- a/src/pointer-analysis/value_set_domain_fivrns.h +++ b/src/pointer-analysis/value_set_domain_fivrns.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Domain (Flow Insensitive, Validity Regions) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_DOMAIN_FIVRNS_H diff --git a/src/pointer-analysis/value_set_fi.cpp b/src/pointer-analysis/value_set_fi.cpp index 55eed196b91..1add85c924d 100644 --- a/src/pointer-analysis/value_set_fi.cpp +++ b/src/pointer-analysis/value_set_fi.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Sharing) - #include #include @@ -41,6 +38,18 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)!=(map).end(); \ (it)++) +/*******************************************************************\ + +Function: value_set_fit::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::output( const namespacet &ns, std::ostream &out) const @@ -135,6 +144,18 @@ void value_set_fit::output( } } +/*******************************************************************\ + +Function: value_set_fit::flatten + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::flatten( const entryt &e, object_mapt &dest) const @@ -151,6 +172,18 @@ void value_set_fit::flatten( #endif } +/*******************************************************************\ + +Function: value_set_fit::flatten_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::flatten_rec( const entryt &e, object_mapt &dest, @@ -222,6 +255,18 @@ void value_set_fit::flatten_rec( seen.erase(identifier + e.suffix); } +/*******************************************************************\ + +Function: value_set_fit::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt value_set_fit::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -242,6 +287,18 @@ exprt value_set_fit::to_expr(object_map_dt::const_iterator it) const return od; } +/*******************************************************************\ + +Function: value_set_fit::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fit::make_union(const value_set_fit::valuest &new_values) { assert(0); @@ -281,6 +338,18 @@ bool value_set_fit::make_union(const value_set_fit::valuest &new_values) return result; } +/*******************************************************************\ + +Function: value_set_fit::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fit::make_union(object_mapt &dest, const object_mapt &src) const { bool result=false; @@ -294,6 +363,18 @@ bool value_set_fit::make_union(object_mapt &dest, const object_mapt &src) const return result; } +/*******************************************************************\ + +Function: value_set_fit::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_value_set( const exprt &expr, std::list &value_set, @@ -356,6 +437,18 @@ void value_set_fit::get_value_set( #endif } +/*******************************************************************\ + +Function: value_set_fit::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_value_set( const exprt &expr, object_mapt &dest, @@ -368,6 +461,18 @@ void value_set_fit::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns, recset); } +/*******************************************************************\ + +Function: value_set_fit::get_value_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -685,6 +790,18 @@ void value_set_fit::get_value_set_rec( insert(dest, exprt(ID_unknown, original_type)); } +/*******************************************************************\ + +Function: value_set_fit::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::dereference_rec( const exprt &src, exprt &dest) const @@ -703,6 +820,18 @@ void value_set_fit::dereference_rec( dest=src; } +/*******************************************************************\ + +Function: value_set_fit::get_reference_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_reference_set( const exprt &expr, expr_sett &dest, @@ -752,6 +881,18 @@ void value_set_fit::get_reference_set( } } +/*******************************************************************\ + +Function: value_set_fit::get_reference_set_sharing + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_reference_set_sharing( const exprt &expr, expr_sett &dest, @@ -764,6 +905,18 @@ void value_set_fit::get_reference_set_sharing( dest.insert(to_expr(it)); } +/*******************************************************************\ + +Function: value_set_fit::get_reference_set_sharing_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::get_reference_set_sharing_rec( const exprt &expr, object_mapt &dest, @@ -962,6 +1115,18 @@ void value_set_fit::get_reference_set_sharing_rec( insert(dest, exprt(ID_unknown, expr.type())); } +/*******************************************************************\ + +Function: value_set_fit::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::assign( const exprt &lhs, const exprt &rhs, @@ -1125,6 +1290,18 @@ void value_set_fit::assign( } } +/*******************************************************************\ + +Function: value_set_fit::do_free + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::do_free( const exprt &op, const namespacet &ns) @@ -1202,6 +1379,18 @@ void value_set_fit::do_free( } } +/*******************************************************************\ + +Function: value_set_fit::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1352,6 +1541,18 @@ void value_set_fit::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } +/*******************************************************************\ + +Function: value_set_fit::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1401,6 +1602,18 @@ void value_set_fit::do_function_call( } } +/*******************************************************************\ + +Function: value_set_fit::do_end_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1414,6 +1627,18 @@ void value_set_fit::do_end_function( assign(lhs, rhs, ns); } +/*******************************************************************\ + +Function: value_set_fit::apply_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fit::apply_code( const exprt &code, const namespacet &ns) diff --git a/src/pointer-analysis/value_set_fi.h b/src/pointer-analysis/value_set_fi.h index 76f2666d836..13defa545ae 100644 --- a/src/pointer-analysis/value_set_fi.h +++ b/src/pointer-analysis/value_set_fi.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Sharing) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FI_H diff --git a/src/pointer-analysis/value_set_fivr.cpp b/src/pointer-analysis/value_set_fivr.cpp index 1bcb61205df..45e721137e0 100644 --- a/src/pointer-analysis/value_set_fivr.cpp +++ b/src/pointer-analysis/value_set_fivr.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Sharing, Validity Regions) - #include #include @@ -54,6 +51,18 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)++) \ if((map).is_valid_at((it)->first, from_function, from_target_index)) /* NOLINT(*) */ +/*******************************************************************\ + +Function: value_set_fivrt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::output( const namespacet &ns, std::ostream &out) const @@ -212,6 +221,18 @@ void value_set_fivrt::output( } } +/*******************************************************************\ + +Function: value_set_fivrt::flatten + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::flatten( const entryt &e, object_mapt &dest) const @@ -228,6 +249,18 @@ void value_set_fivrt::flatten( #endif } +/*******************************************************************\ + +Function: value_set_fivrt::flatten_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::flatten_rec( const entryt &e, object_mapt &dest, @@ -343,6 +376,18 @@ void value_set_fivrt::flatten_rec( seen.erase(identifier + e.suffix); } +/*******************************************************************\ + +Function: value_set_fivrt::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt value_set_fivrt::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -363,6 +408,18 @@ exprt value_set_fivrt::to_expr(object_map_dt::const_iterator it) const return od; } +/*******************************************************************\ + +Function: value_set_fivrt::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::make_union( object_mapt &dest, const object_mapt &src) const @@ -378,6 +435,18 @@ bool value_set_fivrt::make_union( return result; } +/*******************************************************************\ + +Function: value_set_fivrnst::make_valid_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::make_valid_union( object_mapt &dest, const object_mapt &src) const @@ -393,6 +462,18 @@ bool value_set_fivrt::make_valid_union( return result; } +/*******************************************************************\ + +Function: value_set_fivrt::copy_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::copy_objects( object_mapt &dest, const object_mapt &src) const @@ -407,6 +488,18 @@ void value_set_fivrt::copy_objects( } } +/*******************************************************************\ + +Function: value_set_fivrt::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_value_set( const exprt &expr, std::list &value_set, @@ -471,6 +564,18 @@ void value_set_fivrt::get_value_set( #endif } +/*******************************************************************\ + +Function: value_set_fivrt::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_value_set( const exprt &expr, object_mapt &dest, @@ -483,6 +588,18 @@ void value_set_fivrt::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns, recset); } +/*******************************************************************\ + +Function: value_set_fivrt::get_value_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -799,6 +916,18 @@ void value_set_fivrt::get_value_set_rec( insert_from(dest, exprt(ID_unknown, original_type)); } +/*******************************************************************\ + +Function: value_set_fivrt::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::dereference_rec( const exprt &src, exprt &dest) const @@ -817,6 +946,18 @@ void value_set_fivrt::dereference_rec( dest=src; } +/*******************************************************************\ + +Function: value_set_fivrt::get_reference_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_reference_set( const exprt &expr, expr_sett &dest, @@ -866,6 +1007,18 @@ void value_set_fivrt::get_reference_set( } } +/*******************************************************************\ + +Function: value_set_fivrt::get_reference_set_sharing + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_reference_set_sharing( const exprt &expr, expr_sett &dest, @@ -878,6 +1031,18 @@ void value_set_fivrt::get_reference_set_sharing( dest.insert(to_expr(it)); } +/*******************************************************************\ + +Function: value_set_fivrt::get_reference_set_sharing_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::get_reference_set_sharing_rec( const exprt &expr, object_mapt &dest, @@ -1078,6 +1243,18 @@ void value_set_fivrt::get_reference_set_sharing_rec( insert_from(dest, exprt(ID_unknown, expr.type())); } +/*******************************************************************\ + +Function: value_set_fivrt::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::assign( const exprt &lhs, const exprt &rhs, @@ -1237,6 +1414,18 @@ void value_set_fivrt::assign( } } +/*******************************************************************\ + +Function: value_set_fivrt::do_free + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::do_free( const exprt &op, const namespacet &ns) @@ -1318,6 +1507,18 @@ void value_set_fivrt::do_free( } } +/*******************************************************************\ + +Function: value_set_fivrt::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1492,6 +1693,18 @@ void value_set_fivrt::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } +/*******************************************************************\ + +Function: value_set_fivrt::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1559,6 +1772,18 @@ void value_set_fivrt::do_function_call( } } +/*******************************************************************\ + +Function: value_set_fivrt::do_end_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1572,6 +1797,18 @@ void value_set_fivrt::do_end_function( assign(lhs, rhs, ns); } +/*******************************************************************\ + +Function: value_set_fivrt::apply_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrt::apply_code( const exprt &code, const namespacet &ns) @@ -1668,6 +1905,18 @@ void value_set_fivrt::apply_code( "value_set_fivrt: unexpected statement: "+id2string(statement); } +/*******************************************************************\ + +Function: value_set_fivrt::insert_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::insert_to( object_mapt &dest, unsigned n, @@ -1709,6 +1958,18 @@ bool value_set_fivrt::insert_to( } } +/*******************************************************************\ + +Function: value_set_fivrt::insert_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::insert_from( object_mapt &dest, unsigned n, @@ -1750,6 +2011,18 @@ bool value_set_fivrt::insert_from( } } +/*******************************************************************\ + +Function: value_set_fivrt::object_map_dt::set_valid_at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::object_map_dt::set_valid_at( unsigned inx, const validity_ranget &vr) @@ -1763,6 +2036,18 @@ bool value_set_fivrt::object_map_dt::set_valid_at( return res; } +/*******************************************************************\ + +Function: value_set_fivrt::object_map_dt::set_valid_at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::object_map_dt::set_valid_at( unsigned inx, unsigned f, @@ -1834,6 +2119,18 @@ bool value_set_fivrt::object_map_dt::set_valid_at( return true; } +/*******************************************************************\ + +Function: value_set_fivrt::object_map_dt::is_valid_at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::object_map_dt::is_valid_at( unsigned inx, unsigned f, @@ -1864,6 +2161,18 @@ bool value_set_fivrt::object_map_dt::is_valid_at( return false; } +/*******************************************************************\ + +Function: value_set_fivrt::recursive_find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::recursive_find( const irep_idt &ident, const object_mapt &rhs, @@ -1903,6 +2212,18 @@ bool value_set_fivrt::recursive_find( return false; } +/*******************************************************************\ + +Function: value_set_fivrt::handover + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrt::handover(void) { bool changed=false; diff --git a/src/pointer-analysis/value_set_fivr.h b/src/pointer-analysis/value_set_fivr.h index 92c5ab45b37..e12563252ae 100644 --- a/src/pointer-analysis/value_set_fivr.h +++ b/src/pointer-analysis/value_set_fivr.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Sharing, Validity Regions) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVR_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVR_H diff --git a/src/pointer-analysis/value_set_fivrns.cpp b/src/pointer-analysis/value_set_fivrns.cpp index d3c81c945b5..c94afc8f95d 100644 --- a/src/pointer-analysis/value_set_fivrns.cpp +++ b/src/pointer-analysis/value_set_fivrns.cpp @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com, \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Validity Regions) - #include #include @@ -54,6 +51,18 @@ static const char *alloc_adapter_prefix="alloc_adaptor::"; (it)++) \ if((map).is_valid_at((it)->first, from_function, from_target_index)) /* NOLINT(*) */ +/*******************************************************************\ + +Function: value_set_fivrnst::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::output( const namespacet &ns, std::ostream &out) const @@ -65,6 +74,18 @@ void value_set_fivrnst::output( output_entry(v_it->second, ns, out); } +/*******************************************************************\ + +Function: value_set_fivrnst::output_entry + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::output_entry( const entryt &e, const namespacet &ns, @@ -199,6 +220,18 @@ void value_set_fivrnst::output_entry( out << " } \n"; } +/*******************************************************************\ + +Function: value_set_fivrnst::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt value_set_fivrnst::to_expr(object_map_dt::const_iterator it) const { const exprt &object=object_numbering[it->first]; @@ -219,6 +252,18 @@ exprt value_set_fivrnst::to_expr(object_map_dt::const_iterator it) const return od; } +/*******************************************************************\ + +Function: value_set_fivrnst::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::make_union( object_mapt &dest, const object_mapt &src) const @@ -234,6 +279,18 @@ bool value_set_fivrnst::make_union( return result; } +/*******************************************************************\ + +Function: value_set_fivrnst::make_valid_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::make_valid_union( object_mapt &dest, const object_mapt &src) const @@ -249,6 +306,18 @@ bool value_set_fivrnst::make_valid_union( return result; } +/*******************************************************************\ + +Function: value_set_fivrnst::copy_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::copy_objects( object_mapt &dest, const object_mapt &src) const @@ -263,6 +332,18 @@ void value_set_fivrnst::copy_objects( } } +/*******************************************************************\ + +Function: value_set_fivrnst::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::get_value_set( const exprt &expr, std::list &value_set, @@ -281,6 +362,18 @@ void value_set_fivrnst::get_value_set( #endif } +/*******************************************************************\ + +Function: value_set_fivrnst::get_value_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::get_value_set( const exprt &expr, object_mapt &dest, @@ -292,6 +385,18 @@ void value_set_fivrnst::get_value_set( get_value_set_rec(tmp, dest, "", tmp.type(), ns); } +/*******************************************************************\ + +Function: value_set_fivrnst::get_value_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::get_value_set_rec( const exprt &expr, object_mapt &dest, @@ -585,6 +690,18 @@ void value_set_fivrnst::get_value_set_rec( insert_from(dest, exprt(ID_unknown, original_type)); } +/*******************************************************************\ + +Function: value_set_fivrnst::dereference_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::dereference_rec( const exprt &src, exprt &dest) const @@ -603,6 +720,18 @@ void value_set_fivrnst::dereference_rec( dest=src; } +/*******************************************************************\ + +Function: value_set_fivrnst::get_reference_set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::get_reference_set( const exprt &expr, expr_sett &dest, @@ -615,6 +744,18 @@ void value_set_fivrnst::get_reference_set( dest.insert(to_expr(it)); } +/*******************************************************************\ + +Function: value_set_fivrnst::get_reference_set_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::get_reference_set_rec( const exprt &expr, object_mapt &dest, @@ -765,6 +906,18 @@ void value_set_fivrnst::get_reference_set_rec( insert_from(dest, exprt(ID_unknown, expr.type())); } +/*******************************************************************\ + +Function: value_set_fivrnst::assign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::assign( const exprt &lhs, const exprt &rhs, @@ -923,6 +1076,18 @@ void value_set_fivrnst::assign( } } +/*******************************************************************\ + +Function: value_set_fivrnst::do_free + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::do_free( const exprt &op, const namespacet &ns) @@ -1001,6 +1166,18 @@ void value_set_fivrnst::do_free( } } +/*******************************************************************\ + +Function: value_set_fivrnst::assign_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::assign_rec( const exprt &lhs, const object_mapt &values_rhs, @@ -1143,6 +1320,18 @@ void value_set_fivrnst::assign_rec( throw "assign NYI: `"+lhs.id_string()+"'"; } +/*******************************************************************\ + +Function: value_set_fivrnst::do_function_call + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::do_function_call( const irep_idt &function, const exprt::operandst &arguments, @@ -1210,6 +1399,18 @@ void value_set_fivrnst::do_function_call( } } +/*******************************************************************\ + +Function: value_set_fivrnst::do_end_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::do_end_function( const exprt &lhs, const namespacet &ns) @@ -1225,6 +1426,18 @@ void value_set_fivrnst::do_end_function( assign(lhs, rhs, ns); } +/*******************************************************************\ + +Function: value_set_fivrnst::apply_code + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void value_set_fivrnst::apply_code( const exprt &code, const namespacet &ns) @@ -1324,6 +1537,18 @@ void value_set_fivrnst::apply_code( } } +/*******************************************************************\ + +Function: value_set_fivrnst::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::insert_to( object_mapt &dest, unsigned n, @@ -1365,6 +1590,18 @@ bool value_set_fivrnst::insert_to( } } +/*******************************************************************\ + +Function: value_set_fivrnst::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::insert_from( object_mapt &dest, unsigned n, @@ -1406,6 +1643,18 @@ bool value_set_fivrnst::insert_from( } } +/*******************************************************************\ + +Function: value_set_fivrnst::object_map_dt::set_valid_at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::object_map_dt::set_valid_at( unsigned inx, unsigned f, @@ -1477,6 +1726,18 @@ bool value_set_fivrnst::object_map_dt::set_valid_at( return true; } +/*******************************************************************\ + +Function: value_set_fivrnst::object_map_dt::is_valid_at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::object_map_dt::is_valid_at( unsigned inx, unsigned f, @@ -1508,6 +1769,18 @@ bool value_set_fivrnst::object_map_dt::is_valid_at( return false; } +/*******************************************************************\ + +Function: value_set_fivrnst::handover + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool value_set_fivrnst::handover(void) { bool changed=false; diff --git a/src/pointer-analysis/value_set_fivrns.h b/src/pointer-analysis/value_set_fivrns.h index 5ce1d4464c6..f3afc204ef2 100644 --- a/src/pointer-analysis/value_set_fivrns.h +++ b/src/pointer-analysis/value_set_fivrns.h @@ -7,9 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set (Flow Insensitive, Validity Regions) - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVRNS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SET_FIVRNS_H diff --git a/src/pointer-analysis/value_sets.h b/src/pointer-analysis/value_sets.h index e230f72ebe7..5e39997b7e1 100644 --- a/src/pointer-analysis/value_sets.h +++ b/src/pointer-analysis/value_sets.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set Propagation - #ifndef CPROVER_POINTER_ANALYSIS_VALUE_SETS_H #define CPROVER_POINTER_ANALYSIS_VALUE_SETS_H diff --git a/src/solvers/cvc/cvc_conv.cpp b/src/solvers/cvc/cvc_conv.cpp index 66d7fd66088..55c1815b182 100644 --- a/src/solvers/cvc/cvc_conv.cpp +++ b/src/solvers/cvc/cvc_conv.cpp @@ -22,6 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cvc_conv.h" +/*******************************************************************\ + +Function: cvc_convt::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::print_assignment(std::ostream &out) const { // Boolean stuff @@ -32,6 +44,18 @@ void cvc_convt::print_assignment(std::ostream &out) const // others } +/*******************************************************************\ + +Function: cvc_convt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt cvc_convt::l_get(literalt l) const { if(l.is_true()) @@ -42,6 +66,18 @@ tvt cvc_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } +/*******************************************************************\ + +Function: cvc_convt::convert_binary_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_binary_expr(const exprt &expr, const exprt &op) { unsigned to_width= @@ -123,6 +159,18 @@ void cvc_convt::convert_binary_expr(const exprt &expr, const exprt &op) } } +/*******************************************************************\ + +Function: cvc_convt::convert_constant_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_constant_expr(const exprt &expr) { if(expr.type().id()==ID_unsignedbv || @@ -207,6 +255,18 @@ void cvc_convt::convert_constant_expr(const exprt &expr) throw "unknown constant: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: cvc_convt::convert_plus_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_plus_expr(const exprt &expr) { if(expr.operands().size()>=2) @@ -263,6 +323,18 @@ void cvc_convt::convert_plus_expr(const exprt &expr) assert(false); } +/*******************************************************************\ + +Function: cvc_convt::convert_typecast_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_typecast_expr(const exprt &expr) { assert(expr.operands().size()==1); @@ -301,6 +373,18 @@ void cvc_convt::convert_typecast_expr(const exprt &expr) throw "todo typecast4 ? -> "+expr.type().id_string(); } +/*******************************************************************\ + +Function: cvc_convt::convert_struct_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_struct_expr(const exprt &expr) { out << "(# "; @@ -327,6 +411,18 @@ void cvc_convt::convert_struct_expr(const exprt &expr) out << " #)"; } +/*******************************************************************\ + +Function: cvc_convt::convert_equality_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_equality_expr(const exprt &expr) { assert(expr.operands().size()==2); @@ -357,6 +453,18 @@ void cvc_convt::convert_equality_expr(const exprt &expr) } } +/*******************************************************************\ + +Function: cvc_convt::convert_comparison_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_comparison_expr(const exprt &expr) { assert(expr.operands().size()==2); @@ -404,6 +512,18 @@ void cvc_convt::convert_comparison_expr(const exprt &expr) } } +/*******************************************************************\ + +Function: cvc_convt::convert_minus_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_minus_expr(const exprt &expr) { if(expr.operands().size()==2) @@ -428,6 +548,18 @@ void cvc_convt::convert_minus_expr(const exprt &expr) assert(false); } +/*******************************************************************\ + +Function: cvc_convt::convert_with_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_with_expr(const exprt &expr) { assert(expr.operands().size()>=1); @@ -471,6 +603,18 @@ void cvc_convt::convert_with_expr(const exprt &expr) } } +/*******************************************************************\ + +Function: cvc_convt::convert_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -487,6 +631,18 @@ void cvc_convt::convert_literal(const literalt l) out << ")"; } +/*******************************************************************\ + +Function: cvc_convt::bin_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cvc_convt::bin_zero(unsigned bits) { assert(bits!=0); @@ -499,6 +655,18 @@ std::string cvc_convt::bin_zero(unsigned bits) return result; } +/*******************************************************************\ + +Function: cvc_convt::cvc_pointer_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cvc_convt::cvc_pointer_type() { assert(config.ansi_c.pointer_width!=0); @@ -506,12 +674,36 @@ std::string cvc_convt::cvc_pointer_type() std::to_string(config.ansi_c.pointer_width)+") #]"; } +/*******************************************************************\ + +Function: cvc_convt::array_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cvc_convt::array_index_type() { return std::string("BITVECTOR(")+ std::to_string(32)+")"; } +/*******************************************************************\ + +Function: cvc_convt::gen_array_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet cvc_convt::gen_array_index_type() { typet t(ID_signedbv); @@ -519,11 +711,35 @@ typet cvc_convt::gen_array_index_type() return t; } +/*******************************************************************\ + +Function: cvc_convt::array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cvc_convt::array_index(unsigned i) { return "0bin"+integer2binary(i, config.ansi_c.int_width); } +/*******************************************************************\ + +Function: cvc_convt::convert_array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_array_index(const exprt &expr) { if(expr.type()==gen_array_index_type()) @@ -538,6 +754,18 @@ void cvc_convt::convert_array_index(const exprt &expr) } } +/*******************************************************************\ + +Function: cvc_convt::convert_address_of_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_address_of_rec(const exprt &expr) { if(expr.id()==ID_symbol || @@ -623,6 +851,18 @@ void cvc_convt::convert_address_of_rec(const exprt &expr) throw "don't know how to take address of: "+expr.id_string(); } +/*******************************************************************\ + +Function: cvc_convt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_convt::convert(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -660,6 +900,18 @@ literalt cvc_convt::convert(const exprt &expr) return l; } +/*******************************************************************\ + +Function: cvc_convt::convert_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_identifier(const std::string &identifier) { for(std::string::const_iterator @@ -696,6 +948,18 @@ void cvc_convt::convert_identifier(const std::string &identifier) } } +/*******************************************************************\ + +Function: cvc_convt::convert_as_bv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_as_bv(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -715,11 +979,35 @@ void cvc_convt::convert_as_bv(const exprt &expr) convert_expr(expr); } +/*******************************************************************\ + +Function: cvc_convt::convert_array_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_array_value(const exprt &expr) { convert_as_bv(expr); } +/*******************************************************************\ + +Function: cvc_convt::convert_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_expr(const exprt &expr) { const exprt::operandst &op=expr.operands(); @@ -1158,6 +1446,18 @@ void cvc_convt::convert_expr(const exprt &expr) throw "convert_expr: "+expr.id_string()+" is unsupported"; } +/*******************************************************************\ + +Function: cvc_convt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::set_to(const exprt &expr, bool value) { if(value && expr.id()==ID_and) @@ -1219,6 +1519,18 @@ void cvc_convt::set_to(const exprt &expr, bool value) out << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::find_symbols(const exprt &expr) { find_symbols(expr.type()); @@ -1266,6 +1578,18 @@ void cvc_convt::find_symbols(const exprt &expr) } } +/*******************************************************************\ + +Function: cvc_convt::convert_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -1338,6 +1662,18 @@ void cvc_convt::convert_type(const typet &type) throw "unsupported type: "+type.id_string(); } +/*******************************************************************\ + +Function: cvc_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_convt::find_symbols(const typet &type) { if(type.id()==ID_array) diff --git a/src/solvers/cvc/cvc_dec.cpp b/src/solvers/cvc/cvc_dec.cpp index 86ee88b5c13..a30fdb2e614 100644 --- a/src/solvers/cvc/cvc_dec.cpp +++ b/src/solvers/cvc/cvc_dec.cpp @@ -29,6 +29,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "cvc_dec.h" +/*******************************************************************\ + +Function: cvc_temp_filet::cvc_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cvc_temp_filet::cvc_temp_filet() { temp_out_filename="cvc_dec_out_"+std::to_string(getpid())+".tmp"; @@ -38,6 +50,18 @@ cvc_temp_filet::cvc_temp_filet() std::ios_base::out | std::ios_base::trunc); } +/*******************************************************************\ + +Function: cvc_temp_filet::~cvc_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cvc_temp_filet::~cvc_temp_filet() { temp_out.close(); @@ -49,6 +73,18 @@ cvc_temp_filet::~cvc_temp_filet() unlink(temp_result_filename.c_str()); } +/*******************************************************************\ + +Function: cvc_dect::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt cvc_dect::dec_solve() { out << "QUERY FALSE;" << std::endl; @@ -70,6 +106,18 @@ decision_proceduret::resultt cvc_dect::dec_solve() return read_cvcl_result(); } +/*******************************************************************\ + +Function: cvc_dect::read_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT @@ -130,6 +178,18 @@ void cvc_dect::read_assert(std::istream &in, std::string &line) } } +/*******************************************************************\ + +Function: cvc_dect::read_cvcl_result + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt cvc_dect::read_cvcl_result() { std::ifstream in(temp_result_filename.c_str()); diff --git a/src/solvers/cvc/cvc_prop.cpp b/src/solvers/cvc/cvc_prop.cpp index 44ebd6b2137..27c499620ea 100644 --- a/src/solvers/cvc/cvc_prop.cpp +++ b/src/solvers/cvc/cvc_prop.cpp @@ -12,15 +12,51 @@ Author: Daniel Kroening, kroening@kroening.com #include "cvc_prop.h" +/*******************************************************************\ + +Function: cvc_propt::cvc_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + explicit cvc_propt::cvc_propt(std::ostream &_out):out(_out) { _no_variables=0; } +/*******************************************************************\ + +Function: cvc_propt::~cvc_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cvc_propt::~cvc_propt() { } +/*******************************************************************\ + +Function: cvc_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::land(literalt a, literalt b, literalt o) { out << "%% land" << std::endl; @@ -29,6 +65,18 @@ void cvc_propt::land(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lor(literalt a, literalt b, literalt o) { out << "%% lor" << std::endl; @@ -37,6 +85,18 @@ void cvc_propt::lor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lxor(literalt a, literalt b, literalt o) { out << "%% lxor" << std::endl; @@ -45,6 +105,18 @@ void cvc_propt::lxor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lnand(literalt a, literalt b, literalt o) { out << "%% lnand" << std::endl; @@ -53,6 +125,18 @@ void cvc_propt::lnand(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lnor(literalt a, literalt b, literalt o) { out << "%% lnor" << std::endl; @@ -61,6 +145,18 @@ void cvc_propt::lnor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lequal(literalt a, literalt b, literalt o) { out << "%% lequal" << std::endl; @@ -69,6 +165,18 @@ void cvc_propt::lequal(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::limplies(literalt a, literalt b, literalt o) { out << "%% limplies" << std::endl; @@ -77,6 +185,18 @@ void cvc_propt::limplies(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::land(const bvt &bv) { out << "%% land" << std::endl; @@ -95,6 +215,18 @@ literalt cvc_propt::land(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: cvc_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lor(const bvt &bv) { out << "%% lor" << std::endl; @@ -113,6 +245,18 @@ literalt cvc_propt::lor(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: cvc_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -130,6 +274,18 @@ literalt cvc_propt::lxor(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: cvc_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -153,6 +309,18 @@ literalt cvc_propt::land(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: cvc_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -176,6 +344,18 @@ literalt cvc_propt::lor(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: cvc_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -197,26 +377,86 @@ literalt cvc_propt::lxor(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: cvc_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lnand(literalt a, literalt b) { return !land(a, b); } +/*******************************************************************\ + +Function: cvc_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lnor(literalt a, literalt b) { return !lor(a, b); } +/*******************************************************************\ + +Function: cvc_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } +/*******************************************************************\ + +Function: cvc_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::limplies(literalt a, literalt b) { return lor(!a, b); } +/*******************************************************************\ + +Function: cvc_propt::lselect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -238,6 +478,18 @@ literalt cvc_propt::lselect(literalt a, literalt b, literalt c) return o; } +/*******************************************************************\ + +Function: cvc_propt::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::new_variable() { out << "l" << _no_variables << ": BOOLEAN;" << std::endl; @@ -247,6 +499,18 @@ literalt cvc_propt::new_variable() return l; } +/*******************************************************************\ + +Function: cvc_propt::def_cvc_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cvc_propt::def_cvc_literal() { out << "l" << _no_variables << ": BOOLEAN = "; @@ -256,6 +520,18 @@ literalt cvc_propt::def_cvc_literal() return l; } +/*******************************************************************\ + +Function: cvc_propt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cvc_propt::lcnf(const bvt &bv) { if(bv.empty()) @@ -292,6 +568,18 @@ void cvc_propt::lcnf(const bvt &bv) out << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: cvc_propt::cvc_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cvc_propt::cvc_literal(literalt l) { if(l==const_literal(false)) @@ -305,6 +593,18 @@ std::string cvc_propt::cvc_literal(literalt l) return "l"+std::to_string(l.var_no()); } +/*******************************************************************\ + +Function: cvc_propt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt cvc_propt::prop_solve() { out << "QUERY FALSE;" << std::endl; diff --git a/src/solvers/dplib/dplib_conv.cpp b/src/solvers/dplib/dplib_conv.cpp index 8fa0a6c0305..d9d7eefbb11 100644 --- a/src/solvers/dplib/dplib_conv.cpp +++ b/src/solvers/dplib/dplib_conv.cpp @@ -21,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_conv.h" +/*******************************************************************\ + +Function: dplib_convt::bin_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string dplib_convt::bin_zero(unsigned bits) { assert(bits!=0); @@ -29,6 +41,18 @@ std::string dplib_convt::bin_zero(unsigned bits) return result; } +/*******************************************************************\ + +Function: dplib_convt::dplib_pointer_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string dplib_convt::dplib_pointer_type() { assert(config.ansi_c.pointer_width!=0); @@ -36,11 +60,35 @@ std::string dplib_convt::dplib_pointer_type() std::to_string(config.ansi_c.pointer_width)+") #]"; } +/*******************************************************************\ + +Function: dplib_convt::array_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string dplib_convt::array_index_type() { return std::string("SIGNED [")+std::to_string(32)+"]"; } +/*******************************************************************\ + +Function: dplib_convt::gen_array_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet dplib_convt::gen_array_index_type() { typet t(ID_signedbv); @@ -48,11 +96,35 @@ typet dplib_convt::gen_array_index_type() return t; } +/*******************************************************************\ + +Function: dplib_convt::array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string dplib_convt::array_index(unsigned i) { return "0bin"+integer2binary(i, config.ansi_c.int_width); } +/*******************************************************************\ + +Function: dplib_convt::convert_array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_array_index(const exprt &expr) { if(expr.type()==gen_array_index_type()) @@ -67,6 +139,18 @@ void dplib_convt::convert_array_index(const exprt &expr) } } +/*******************************************************************\ + +Function: dplib_convt::convert_address_of_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_address_of_rec(const exprt &expr) { if(expr.id()==ID_symbol || @@ -150,6 +234,18 @@ void dplib_convt::convert_address_of_rec(const exprt &expr) throw "don't know how to take address of: "+expr.id_string(); } +/*******************************************************************\ + +Function: dplib_convt::convert_rest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_convt::convert_rest(const exprt &expr) { // dplib_prop.out << "%% E: " << expr << std::endl; @@ -172,6 +268,18 @@ literalt dplib_convt::convert_rest(const exprt &expr) return l; } +/*******************************************************************\ + +Function: dplib_convt::convert_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_identifier(const std::string &identifier) { for(std::string::const_iterator @@ -208,6 +316,18 @@ void dplib_convt::convert_identifier(const std::string &identifier) } } +/*******************************************************************\ + +Function: dplib_convt::convert_as_bv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_as_bv(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -220,11 +340,35 @@ void dplib_convt::convert_as_bv(const exprt &expr) convert_dplib_expr(expr); } +/*******************************************************************\ + +Function: dplib_convt::convert_array_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_array_value(const exprt &expr) { convert_as_bv(expr); } +/*******************************************************************\ + +Function: dplib_convt::convert_dplib_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_dplib_expr(const exprt &expr) { if(expr.id()==ID_symbol) @@ -961,6 +1105,18 @@ void dplib_convt::convert_dplib_expr(const exprt &expr) throw "convert_dplib_expr: "+expr.id_string()+" is unsupported"; } +/*******************************************************************\ + +Function: dplib_convt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::set_to(const exprt &expr, bool value) { if(value && expr.id()==ID_and) @@ -1025,6 +1181,18 @@ void dplib_convt::set_to(const exprt &expr, bool value) dplib_prop.out << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::find_symbols(const exprt &expr) { find_symbols(expr.type()); @@ -1072,6 +1240,18 @@ void dplib_convt::find_symbols(const exprt &expr) } } +/*******************************************************************\ + +Function: dplib_convt::convert_dplib_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::convert_dplib_type(const typet &type) { if(type.id()==ID_array) @@ -1155,6 +1335,18 @@ void dplib_convt::convert_dplib_type(const typet &type) throw "unsupported type: "+type.id_string(); } +/*******************************************************************\ + +Function: dplib_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_convt::find_symbols(const typet &type) { if(type.id()==ID_array) diff --git a/src/solvers/dplib/dplib_dec.cpp b/src/solvers/dplib/dplib_dec.cpp index fc101ded4ea..66369bdc1ff 100644 --- a/src/solvers/dplib/dplib_dec.cpp +++ b/src/solvers/dplib/dplib_dec.cpp @@ -28,6 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_dec.h" +/*******************************************************************\ + +Function: dplib_temp_filet::dplib_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dplib_temp_filet::dplib_temp_filet() { temp_out_filename="dplib_dec_out_"+std::to_string(getpid())+".tmp"; @@ -37,6 +49,18 @@ dplib_temp_filet::dplib_temp_filet() std::ios_base::out | std::ios_base::trunc); } +/*******************************************************************\ + +Function: dplib_temp_filet::~dplib_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dplib_temp_filet::~dplib_temp_filet() { temp_out.close(); @@ -48,6 +72,18 @@ dplib_temp_filet::~dplib_temp_filet() unlink(temp_result_filename.c_str()); } +/*******************************************************************\ + +Function: dplib_dect::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt dplib_dect::dec_solve() { dplib_prop.out << "QUERY FALSE;" << std::endl; @@ -71,6 +107,18 @@ decision_proceduret::resultt dplib_dect::dec_solve() return read_dplib_result(); } +/*******************************************************************\ + +Function: dplib_dect::read_assert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT @@ -130,6 +178,18 @@ void dplib_dect::read_assert(std::istream &in, std::string &line) } } +/*******************************************************************\ + +Function: dplib_dect::read_dplib_result + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt dplib_dect::read_dplib_result() { std::ifstream in(temp_result_filename.c_str()); diff --git a/src/solvers/dplib/dplib_prop.cpp b/src/solvers/dplib/dplib_prop.cpp index 751cfe48060..5153b6874de 100644 --- a/src/solvers/dplib/dplib_prop.cpp +++ b/src/solvers/dplib/dplib_prop.cpp @@ -13,12 +13,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "dplib_prop.h" +/*******************************************************************\ + +Function: dplib_propt::dplib_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dplib_propt::dplib_propt(std::ostream &_out):out(_out) { // we skip index 0 _no_variables=1; } +/*******************************************************************\ + +Function: dplib_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::land(literalt a, literalt b, literalt o) { out << "// land" << std::endl; @@ -27,6 +51,18 @@ void dplib_propt::land(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lor(literalt a, literalt b, literalt o) { out << "// lor" << std::endl; @@ -35,6 +71,18 @@ void dplib_propt::lor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lxor(literalt a, literalt b, literalt o) { out << "// lxor" << std::endl; @@ -43,6 +91,18 @@ void dplib_propt::lxor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lnand(literalt a, literalt b, literalt o) { out << "// lnand" << std::endl; @@ -51,6 +111,18 @@ void dplib_propt::lnand(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lnor(literalt a, literalt b, literalt o) { out << "// lnor" << std::endl; @@ -59,6 +131,18 @@ void dplib_propt::lnor(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lequal(literalt a, literalt b, literalt o) { out << "// lequal" << std::endl; @@ -67,6 +151,18 @@ void dplib_propt::lequal(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::limplies(literalt a, literalt b, literalt o) { out << "// limplies" << std::endl; @@ -75,6 +171,18 @@ void dplib_propt::limplies(literalt a, literalt b, literalt o) << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::land(const bvt &bv) { out << "// land" << std::endl; @@ -93,6 +201,18 @@ literalt dplib_propt::land(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: dplib_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lor(const bvt &bv) { out << "// lor" << std::endl; @@ -111,6 +231,18 @@ literalt dplib_propt::lor(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: dplib_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -128,6 +260,18 @@ literalt dplib_propt::lxor(const bvt &bv) return literal; } +/*******************************************************************\ + +Function: dplib_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -148,6 +292,18 @@ literalt dplib_propt::land(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: dplib_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -168,6 +324,18 @@ literalt dplib_propt::lor(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: dplib_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -186,26 +354,86 @@ literalt dplib_propt::lxor(literalt a, literalt b) return o; } +/*******************************************************************\ + +Function: dplib_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lnand(literalt a, literalt b) { return !land(a, b); } +/*******************************************************************\ + +Function: dplib_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lnor(literalt a, literalt b) { return !lor(a, b); } +/*******************************************************************\ + +Function: dplib_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } +/*******************************************************************\ + +Function: dplib_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::limplies(literalt a, literalt b) { return lor(!a, b); } +/*******************************************************************\ + +Function: dplib_propt::lselect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -227,6 +455,18 @@ literalt dplib_propt::lselect(literalt a, literalt b, literalt c) return o; } +/*******************************************************************\ + +Function: dplib_propt::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::new_variable() { _no_variables++; @@ -236,6 +476,18 @@ literalt dplib_propt::new_variable() return l; } +/*******************************************************************\ + +Function: dplib_propt::def_dplib_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt dplib_propt::def_dplib_literal() { _no_variables++; @@ -245,6 +497,18 @@ literalt dplib_propt::def_dplib_literal() return l; } +/*******************************************************************\ + +Function: dplib_propt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::lcnf(const bvt &bv) { if(bv.empty()) @@ -281,6 +545,18 @@ void dplib_propt::lcnf(const bvt &bv) out << ";" << std::endl << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::dplib_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string dplib_propt::dplib_literal(literalt l) { if(l==const_literal(false)) @@ -294,12 +570,36 @@ std::string dplib_propt::dplib_literal(literalt l) return "l"+std::to_string(l.var_no()); } +/*******************************************************************\ + +Function: dplib_propt::finish + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dplib_propt::finish() { // we want satisfiability out << "THEOREM false;" << std::endl; } +/*******************************************************************\ + +Function: dplib_propt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt dplib_propt::prop_solve() { finish(); diff --git a/src/solvers/flattening/arrays.cpp b/src/solvers/flattening/arrays.cpp index 92d7cee6ff3..10c29c2ae76 100644 --- a/src/solvers/flattening/arrays.cpp +++ b/src/solvers/flattening/arrays.cpp @@ -21,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "arrays.h" +/*******************************************************************\ + +Function: arrayst::arrayst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + arrayst::arrayst( const namespacet &_ns, propt &_prop):equalityt(_ns, _prop) @@ -29,6 +41,18 @@ arrayst::arrayst( incremental_cache = false; // for incremental solving } +/*******************************************************************\ + +Function: arrayst::record_array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void arrayst::record_array_index(const index_exprt &index) { // we are not allowed to put the index directly in the @@ -39,6 +63,18 @@ void arrayst::record_array_index(const index_exprt &index) update_indices.insert(number); } +/*******************************************************************\ + +Function: arrayst::record_array_equality + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt arrayst::record_array_equality( const equal_exprt &equality) { @@ -67,6 +103,18 @@ literalt arrayst::record_array_equality( return array_equalities.back().l; } +/*******************************************************************\ + +Function: arrayst::collect_indices + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void arrayst::collect_indices() { for(std::size_t i=0; isecond; } +/*******************************************************************\ + +Function: boolbvt::conversion_failed + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::conversion_failed(const exprt &expr) { ignoring(expr); @@ -150,6 +186,18 @@ bvt boolbvt::conversion_failed(const exprt &expr) return prop.new_variables(width); } +/*******************************************************************\ + +Function: boolbvt::convert_bitvector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_bitvector(const exprt &expr) { if(expr.type().id()==ID_bool) @@ -306,6 +354,18 @@ bvt boolbvt::convert_bitvector(const exprt &expr) return conversion_failed(expr); } +/*******************************************************************\ + +Function: boolbvt::convert_lambda + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_lambda(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -353,6 +413,18 @@ bvt boolbvt::convert_lambda(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::convert_bv_literals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_bv_literals(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -374,6 +446,18 @@ bvt boolbvt::convert_bv_literals(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::convert_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_symbol(const exprt &expr) { const typet &type=expr.type(); @@ -409,6 +493,18 @@ bvt boolbvt::convert_symbol(const exprt &expr) } +/*******************************************************************\ + +Function: boolbvt::convert_function_application + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_function_application( const function_application_exprt &expr) { @@ -420,6 +516,18 @@ bvt boolbvt::convert_function_application( } +/*******************************************************************\ + +Function: boolbvt::convert_rest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_rest(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -586,6 +694,18 @@ literalt boolbvt::convert_rest(const exprt &expr) return SUB::convert_rest(expr); } +/*******************************************************************\ + +Function: boolbvt::boolbv_set_equality_to_true + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr) { if(!equality_propagation) @@ -617,6 +737,18 @@ bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr) return true; } +/*******************************************************************\ + +Function: boolbvt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::set_to(const exprt &expr, bool value) { if(expr.type().id()!=ID_bool) @@ -638,6 +770,18 @@ void boolbvt::set_to(const exprt &expr, bool value) return SUB::set_to(expr, value); } +/*******************************************************************\ + +Function: boolbvt::make_bv_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::make_bv_expr(const typet &type, const bvt &bv, exprt &dest) { dest=exprt(ID_bv_literals, type); @@ -649,6 +793,18 @@ void boolbvt::make_bv_expr(const typet &type, const bvt &bv, exprt &dest) bv_sub[i].id(std::to_string(bv[i].get())); } +/*******************************************************************\ + +Function: boolbvt::make_bv_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::make_free_bv_expr(const typet &type, exprt &dest) { std::size_t width=boolbv_width(type); @@ -669,6 +825,18 @@ void boolbvt::make_free_bv_expr(const typet &type, exprt &dest) make_bv_expr(type, bv, dest); } +/*******************************************************************\ + +Function: boolbvt::is_unbounded_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool boolbvt::is_unbounded_array(const typet &type) const { if(type.id()==ID_symbol) @@ -693,6 +861,18 @@ bool boolbvt::is_unbounded_array(const typet &type) const return false; } +/*******************************************************************\ + +Function: boolbvt::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::print_assignment(std::ostream &out) const { for(boolbv_mapt::mappingt::const_iterator it=map.mapping.begin(); @@ -704,6 +884,18 @@ void boolbvt::print_assignment(std::ostream &out) const } } +/*******************************************************************\ + +Function: boolbvt::build_offset_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::build_offset_map(const struct_typet &src, offset_mapt &dest) { const struct_typet::componentst &components= diff --git a/src/solvers/flattening/boolbv_abs.cpp b/src/solvers/flattening/boolbv_abs.cpp index 8ee988ec68b..7c93353b45b 100644 --- a/src/solvers/flattening/boolbv_abs.cpp +++ b/src/solvers/flattening/boolbv_abs.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_abs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_abs(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_add_sub.cpp b/src/solvers/flattening/boolbv_add_sub.cpp index b1ba7878aa4..9bcb6281be6 100644 --- a/src/solvers/flattening/boolbv_add_sub.cpp +++ b/src/solvers/flattening/boolbv_add_sub.cpp @@ -14,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_add_sub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_add_sub(const exprt &expr) { const typet &type=ns.follow(expr.type()); diff --git a/src/solvers/flattening/boolbv_array.cpp b/src/solvers/flattening/boolbv_array.cpp index b06a48fbba1..e6a44279684 100644 --- a/src/solvers/flattening/boolbv_array.cpp +++ b/src/solvers/flattening/boolbv_array.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_array(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_array_of.cpp b/src/solvers/flattening/boolbv_array_of.cpp index 96618a81633..74056d2df50 100644 --- a/src/solvers/flattening/boolbv_array_of.cpp +++ b/src/solvers/flattening/boolbv_array_of.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_array_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_array_of(const array_of_exprt &expr) { if(expr.type().id()!=ID_array) diff --git a/src/solvers/flattening/boolbv_bitwise.cpp b/src/solvers/flattening/boolbv_bitwise.cpp index 9e97115d80e..52d48b19c77 100644 --- a/src/solvers/flattening/boolbv_bitwise.cpp +++ b/src/solvers/flattening/boolbv_bitwise.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_bitwise + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_bitwise(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_bv_rel.cpp b/src/solvers/flattening/boolbv_bv_rel.cpp index ab9a1df8b0c..8b2984e2343 100644 --- a/src/solvers/flattening/boolbv_bv_rel.cpp +++ b/src/solvers/flattening/boolbv_bv_rel.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_bv_rel + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_bv_rel(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_byte_extract.cpp b/src/solvers/flattening/boolbv_byte_extract.cpp index a19e77b9f04..2dd32ba35f7 100644 --- a/src/solvers/flattening/boolbv_byte_extract.cpp +++ b/src/solvers/flattening/boolbv_byte_extract.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" #include "flatten_byte_operators.h" +/*******************************************************************\ + +Function: map_bv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt map_bv(const endianness_mapt &map, const bvt &src) { assert(map.number_of_bits()==src.size()); @@ -33,6 +45,18 @@ bvt map_bv(const endianness_mapt &map, const bvt &src) return result; } +/*******************************************************************\ + +Function: boolbvt::convert_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr) { if(expr.operands().size()!=2) diff --git a/src/solvers/flattening/boolbv_byte_update.cpp b/src/solvers/flattening/boolbv_byte_update.cpp index 92ef6dd2a4c..7ff0408a661 100644 --- a/src/solvers/flattening/boolbv_byte_update.cpp +++ b/src/solvers/flattening/boolbv_byte_update.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_byte_update(const byte_update_exprt &expr) { if(expr.operands().size()!=3) diff --git a/src/solvers/flattening/boolbv_case.cpp b/src/solvers/flattening/boolbv_case.cpp index 849d982ee94..6a56f35fa7f 100644 --- a/src/solvers/flattening/boolbv_case.cpp +++ b/src/solvers/flattening/boolbv_case.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_case + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_case(const exprt &expr) { const std::vector &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_complex.cpp b/src/solvers/flattening/boolbv_complex.cpp index 592dc53c77f..3d5407537a2 100644 --- a/src/solvers/flattening/boolbv_complex.cpp +++ b/src/solvers/flattening/boolbv_complex.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_complex + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_complex(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -44,6 +56,18 @@ bvt boolbvt::convert_complex(const exprt &expr) return conversion_failed(expr); } +/*******************************************************************\ + +Function: boolbvt::convert_complex_real + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_complex_real(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); @@ -62,6 +86,18 @@ bvt boolbvt::convert_complex_real(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::convert_complex_imag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_complex_imag(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_concatenation.cpp b/src/solvers/flattening/boolbv_concatenation.cpp index fae48e3a9cc..ef3896053fe 100644 --- a/src/solvers/flattening/boolbv_concatenation.cpp +++ b/src/solvers/flattening/boolbv_concatenation.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_concatenation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_concatenation(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_cond.cpp b/src/solvers/flattening/boolbv_cond.cpp index 90c6a6133f3..4e966a69440 100644 --- a/src/solvers/flattening/boolbv_cond.cpp +++ b/src/solvers/flattening/boolbv_cond.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_cond + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_cond(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_constant.cpp b/src/solvers/flattening/boolbv_constant.cpp index e714651ead7..ebeb3a5a1db 100644 --- a/src/solvers/flattening/boolbv_constant.cpp +++ b/src/solvers/flattening/boolbv_constant.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_constant(const constant_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_constraint_select_one.cpp b/src/solvers/flattening/boolbv_constraint_select_one.cpp index cae2d16dfe6..c6c9b53bd50 100644 --- a/src/solvers/flattening/boolbv_constraint_select_one.cpp +++ b/src/solvers/flattening/boolbv_constraint_select_one.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_constraint_select_one + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_constraint_select_one(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_div.cpp b/src/solvers/flattening/boolbv_div.cpp index c8d6317c689..4689829c53f 100644 --- a/src/solvers/flattening/boolbv_div.cpp +++ b/src/solvers/flattening/boolbv_div.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_div(const div_exprt &expr) { if(expr.type().id()!=ID_unsignedbv && diff --git a/src/solvers/flattening/boolbv_equality.cpp b/src/solvers/flattening/boolbv_equality.cpp index 574e8f94d92..53cbb624815 100644 --- a/src/solvers/flattening/boolbv_equality.cpp +++ b/src/solvers/flattening/boolbv_equality.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "flatten_byte_operators.h" #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_equality + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_equality(const equal_exprt &expr) { if(!base_type_eq(expr.lhs().type(), expr.rhs().type(), ns)) @@ -61,6 +73,18 @@ literalt boolbvt::convert_equality(const equal_exprt &expr) return bv_utils.equal(bv0, bv1); } +/*******************************************************************\ + +Function: boolbvt::convert_verilog_case_equality + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_verilog_case_equality( const binary_relation_exprt &expr) { diff --git a/src/solvers/flattening/boolbv_extractbit.cpp b/src/solvers/flattening/boolbv_extractbit.cpp index c7ef6816c44..cdccc52f578 100644 --- a/src/solvers/flattening/boolbv_extractbit.cpp +++ b/src/solvers/flattening/boolbv_extractbit.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_extractbit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_extractbit(const extractbit_exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_extractbits.cpp b/src/solvers/flattening/boolbv_extractbits.cpp index 50f0a3b7b3d..5bf2ac0f4c4 100644 --- a/src/solvers/flattening/boolbv_extractbits.cpp +++ b/src/solvers/flattening/boolbv_extractbits.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_extractbits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_extractbits(const extractbits_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_floatbv_op.cpp b/src/solvers/flattening/boolbv_floatbv_op.cpp index f77b7a306d2..e4926dc617e 100644 --- a/src/solvers/flattening/boolbv_floatbv_op.cpp +++ b/src/solvers/flattening/boolbv_floatbv_op.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_floatbv_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) { const exprt &op0=expr.op(); // number to convert @@ -72,6 +84,18 @@ bvt boolbvt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) return conversion_failed(expr); } +/*******************************************************************\ + +Function: boolbvt::convert_floatbv_op + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_floatbv_op(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_get.cpp b/src/solvers/flattening/boolbv_get.cpp index 799bf269627..4eb285a0d9c 100644 --- a/src/solvers/flattening/boolbv_get.cpp +++ b/src/solvers/flattening/boolbv_get.cpp @@ -17,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" #include "boolbv_type.h" +/*******************************************************************\ + +Function: boolbvt::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolbvt::get(const exprt &expr) const { if(expr.id()==ID_symbol || @@ -64,6 +76,18 @@ exprt boolbvt::get(const exprt &expr) const return SUB::get(expr); } +/*******************************************************************\ + +Function: boolbvt::bv_get_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolbvt::bv_get_rec( const bvt &bv, const std::vector &unknown, @@ -276,6 +300,18 @@ exprt boolbvt::bv_get_rec( return nil_exprt(); } +/*******************************************************************\ + +Function: boolbvt::bv_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolbvt::bv_get(const bvt &bv, const typet &type) const { std::vector unknown; @@ -283,6 +319,18 @@ exprt boolbvt::bv_get(const bvt &bv, const typet &type) const return bv_get_rec(bv, unknown, 0, type); } +/*******************************************************************\ + +Function: boolbvt::bv_get_cache + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolbvt::bv_get_cache(const exprt &expr) const { if(expr.type().id()==ID_bool) // boolean? @@ -296,6 +344,18 @@ exprt boolbvt::bv_get_cache(const exprt &expr) const return bv_get(it->second, expr.type()); } +/*******************************************************************\ + +Function: boolbvt::bv_get_unbounded_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const { // first, try to get size @@ -413,6 +473,18 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const return result; } +/*******************************************************************\ + +Function: boolbvt::get_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer boolbvt::get_value( const bvt &bv, std::size_t offset, diff --git a/src/solvers/flattening/boolbv_ieee_float_rel.cpp b/src/solvers/flattening/boolbv_ieee_float_rel.cpp index 5694f1e029d..e97203566a8 100644 --- a/src/solvers/flattening/boolbv_ieee_float_rel.cpp +++ b/src/solvers/flattening/boolbv_ieee_float_rel.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_ieee_float_rel + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_ieee_float_rel(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_if.cpp b/src/solvers/flattening/boolbv_if.cpp index 8f73309d9db..97563633c5b 100644 --- a/src/solvers/flattening/boolbv_if.cpp +++ b/src/solvers/flattening/boolbv_if.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_if(const if_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_index.cpp b/src/solvers/flattening/boolbv_index.cpp index 199b067ba2b..ec1ef27dd98 100644 --- a/src/solvers/flattening/boolbv_index.cpp +++ b/src/solvers/flattening/boolbv_index.cpp @@ -14,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_index(const index_exprt &expr) { if(expr.id()!=ID_index) @@ -289,7 +301,18 @@ bvt boolbvt::convert_index(const index_exprt &expr) return bv; } -/// index operator with constant index +/*******************************************************************\ + +Function: boolbvt::convert_index + + Inputs: + + Outputs: + + Purpose: index operator with constant index + +\*******************************************************************/ + bvt boolbvt::convert_index( const exprt &array, const mp_integer &index) diff --git a/src/solvers/flattening/boolbv_map.cpp b/src/solvers/flattening/boolbv_map.cpp index 2eeaa6fc8fc..6c6e647a31c 100644 --- a/src/solvers/flattening/boolbv_map.cpp +++ b/src/solvers/flattening/boolbv_map.cpp @@ -17,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif +/*******************************************************************\ + +Function: boolbv_mapt::map_entryt::get_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string boolbv_mapt::map_entryt::get_value(const propt &prop) const { std::string result; @@ -45,6 +57,18 @@ std::string boolbv_mapt::map_entryt::get_value(const propt &prop) const return result; } +/*******************************************************************\ + +Function: boolbv_mapt::get_map_entry + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + boolbv_mapt::map_entryt &boolbv_mapt::get_map_entry( const irep_idt &identifier, const typet &type) @@ -71,6 +95,18 @@ boolbv_mapt::map_entryt &boolbv_mapt::get_map_entry( return map_entry; } +/*******************************************************************\ + +Function: boolbv_mapt::show + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbv_mapt::show() const { for(mappingt::const_iterator it=mapping.begin(); @@ -80,6 +116,18 @@ void boolbv_mapt::show() const } } +/*******************************************************************\ + +Function: boolbv_mapt::get_literals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbv_mapt::get_literals( const irep_idt &identifier, const typet &type, @@ -117,6 +165,18 @@ void boolbv_mapt::get_literals( } } +/*******************************************************************\ + +Function: boolbv_mapt::set_literals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbv_mapt::set_literals( const irep_idt &identifier, const typet &type, diff --git a/src/solvers/flattening/boolbv_member.cpp b/src/solvers/flattening/boolbv_member.cpp index 93194bcd0b0..c5c0a697e1e 100644 --- a/src/solvers/flattening/boolbv_member.cpp +++ b/src/solvers/flattening/boolbv_member.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_member(const member_exprt &expr) { const exprt &struct_op=expr.struct_op(); diff --git a/src/solvers/flattening/boolbv_mod.cpp b/src/solvers/flattening/boolbv_mod.cpp index 9603c9edc5a..a81e30e0fae 100644 --- a/src/solvers/flattening/boolbv_mod.cpp +++ b/src/solvers/flattening/boolbv_mod.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_mod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_mod(const mod_exprt &expr) { #if 0 diff --git a/src/solvers/flattening/boolbv_mult.cpp b/src/solvers/flattening/boolbv_mult.cpp index d97fe0d9b7d..4f7e91056bc 100644 --- a/src/solvers/flattening/boolbv_mult.cpp +++ b/src/solvers/flattening/boolbv_mult.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_mult(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_not.cpp b/src/solvers/flattening/boolbv_not.cpp index 1a7d81ef901..a5d0b2e4468 100644 --- a/src/solvers/flattening/boolbv_not.cpp +++ b/src/solvers/flattening/boolbv_not.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_not + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_not(const not_exprt &expr) { const bvt &op_bv=convert_bv(expr.op()); diff --git a/src/solvers/flattening/boolbv_onehot.cpp b/src/solvers/flattening/boolbv_onehot.cpp index 0a8983de949..d6af04966f8 100644 --- a/src/solvers/flattening/boolbv_onehot.cpp +++ b/src/solvers/flattening/boolbv_onehot.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_onehot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_onehot(const unary_exprt &expr) { bvt op=convert_bv(expr.op()); diff --git a/src/solvers/flattening/boolbv_overflow.cpp b/src/solvers/flattening/boolbv_overflow.cpp index dc9c7235b3b..72b65dfe1a0 100644 --- a/src/solvers/flattening/boolbv_overflow.cpp +++ b/src/solvers/flattening/boolbv_overflow.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_overflow(const exprt &expr) { const exprt::operandst &operands=expr.operands(); diff --git a/src/solvers/flattening/boolbv_power.cpp b/src/solvers/flattening/boolbv_power.cpp index a84c744b831..5b843a9fabb 100644 --- a/src/solvers/flattening/boolbv_power.cpp +++ b/src/solvers/flattening/boolbv_power.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_power + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_power(const binary_exprt &expr) { const typet &type=ns.follow(expr.type()); diff --git a/src/solvers/flattening/boolbv_quantifier.cpp b/src/solvers/flattening/boolbv_quantifier.cpp index 1d09818455c..7cfc7f9e03e 100644 --- a/src/solvers/flattening/boolbv_quantifier.cpp +++ b/src/solvers/flattening/boolbv_quantifier.cpp @@ -14,7 +14,19 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" -/// A method to detect equivalence between experts that can contain typecast +/*******************************************************************\ + +Function: expr_eq + + Inputs: + + Outputs: + + Purpose: A method to detect equivalence between experts that can + contain typecast + +\*******************************************************************/ + bool expr_eq(const exprt &expr1, const exprt &expr2) { exprt e1=expr1, e2=expr2; @@ -25,9 +37,20 @@ bool expr_eq(const exprt &expr1, const exprt &expr2) return e1==e2; } -/// To obtain the min value for the quantifier variable of the specified -/// forall/exists operator. The min variable is in the form of "!(var_expr > -/// constant)". +/*******************************************************************\ + +Function: get_quantifier_var_min + + Inputs: + + Outputs: + + Purpose: To obtain the min value for the quantifier variable + of the specified forall/exists operator. The min variable + is in the form of "!(var_expr > constant)". + +\*******************************************************************/ + exprt get_quantifier_var_min( const exprt &var_expr, const exprt &quantifier_expr) @@ -74,8 +97,19 @@ exprt get_quantifier_var_min( return res; } -/// To obtain the max value for the quantifier variable of the specified -/// forall/exists operator. +/*******************************************************************\ + +Function: get_quantifier_var_max + + Inputs: + + Outputs: + + Purpose: To obtain the max value for the quantifier variable + of the specified forall/exists operator. + +\*******************************************************************/ + exprt get_quantifier_var_max( const exprt &var_expr, const exprt &quantifier_expr) @@ -137,6 +171,18 @@ exprt get_quantifier_var_max( return res; } +/*******************************************************************\ + +Function: instantiate_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool instantiate_quantifier(exprt &expr, const namespacet &ns) { @@ -201,6 +247,18 @@ bool instantiate_quantifier(exprt &expr, return res; } +/*******************************************************************\ + +Function: boolbvt::convert_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_quantifier(const exprt &src) { exprt expr(src); @@ -217,6 +275,18 @@ literalt boolbvt::convert_quantifier(const exprt &src) return l; } +/*******************************************************************\ + +Function: boolbvt::post_process_quantifiers + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::post_process_quantifiers() { std::set instances; diff --git a/src/solvers/flattening/boolbv_reduction.cpp b/src/solvers/flattening/boolbv_reduction.cpp index 6557c37af1e..e863657066b 100644 --- a/src/solvers/flattening/boolbv_reduction.cpp +++ b/src/solvers/flattening/boolbv_reduction.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_reduction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt boolbvt::convert_reduction(const unary_exprt &expr) { const bvt &op_bv=convert_bv(expr.op()); @@ -48,6 +60,18 @@ literalt boolbvt::convert_reduction(const unary_exprt &expr) return l; } +/*******************************************************************\ + +Function: boolbvt::convert_bv_reduction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_bv_reduction(const unary_exprt &expr) { const bvt &op_bv=convert_bv(expr.op()); diff --git a/src/solvers/flattening/boolbv_replication.cpp b/src/solvers/flattening/boolbv_replication.cpp index 41c1ec42949..5983a1ae759 100644 --- a/src/solvers/flattening/boolbv_replication.cpp +++ b/src/solvers/flattening/boolbv_replication.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_replication + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_replication(const replication_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_shift.cpp b/src/solvers/flattening/boolbv_shift.cpp index e55a0e3e07f..f63be04c4a1 100644 --- a/src/solvers/flattening/boolbv_shift.cpp +++ b/src/solvers/flattening/boolbv_shift.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_shift + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_shift(const binary_exprt &expr) { const irep_idt &type_id=expr.type().id(); diff --git a/src/solvers/flattening/boolbv_struct.cpp b/src/solvers/flattening/boolbv_struct.cpp index 91d19fd4e25..e1b0b29593a 100644 --- a/src/solvers/flattening/boolbv_struct.cpp +++ b/src/solvers/flattening/boolbv_struct.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_struct(const struct_exprt &expr) { const struct_typet &struct_type=to_struct_type(ns.follow(expr.type())); diff --git a/src/solvers/flattening/boolbv_type.cpp b/src/solvers/flattening/boolbv_type.cpp index 60607b023fe..2f0d2a43e59 100644 --- a/src/solvers/flattening/boolbv_type.cpp +++ b/src/solvers/flattening/boolbv_type.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv_type.h" +/*******************************************************************\ + +Function: get_bvtype + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvtypet get_bvtype(const typet &type) { if(type.id()==ID_signedbv) diff --git a/src/solvers/flattening/boolbv_typecast.cpp b/src/solvers/flattening/boolbv_typecast.cpp index afea6ee8698..c0c2b9abb81 100644 --- a/src/solvers/flattening/boolbv_typecast.cpp +++ b/src/solvers/flattening/boolbv_typecast.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_bv_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_bv_typecast(const typecast_exprt &expr) { const typet &expr_type=ns.follow(expr.type()); @@ -31,6 +43,18 @@ bvt boolbvt::convert_bv_typecast(const typecast_exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::type_conversion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool boolbvt::type_conversion( const typet &src_type, const bvt &src, const typet &dest_type, bvt &dest) @@ -588,7 +612,18 @@ bool boolbvt::type_conversion( return true; } -/// conversion from bitvector types to boolean +/*******************************************************************\ + +Function: boolbvt::convert_typecast + + Inputs: + + Outputs: + + Purpose: conversion from bitvector types to boolean + +\*******************************************************************/ + literalt boolbvt::convert_typecast(const typecast_exprt &expr) { assert(expr.operands().size()==1); diff --git a/src/solvers/flattening/boolbv_unary_minus.cpp b/src/solvers/flattening/boolbv_unary_minus.cpp index 64154ac7528..032d453a877 100644 --- a/src/solvers/flattening/boolbv_unary_minus.cpp +++ b/src/solvers/flattening/boolbv_unary_minus.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" +/*******************************************************************\ + +Function: boolbvt::convert_unary_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_unary_minus(const unary_exprt &expr) { const typet &type=ns.follow(expr.type()); diff --git a/src/solvers/flattening/boolbv_union.cpp b/src/solvers/flattening/boolbv_union.cpp index 62ce2ab760d..92ac97d0c2c 100644 --- a/src/solvers/flattening/boolbv_union.cpp +++ b/src/solvers/flattening/boolbv_union.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_union(const union_exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_update.cpp b/src/solvers/flattening/boolbv_update.cpp index 62e887d5e04..2b485781f6b 100644 --- a/src/solvers/flattening/boolbv_update.cpp +++ b/src/solvers/flattening/boolbv_update.cpp @@ -17,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_update(const exprt &expr) { const exprt::operandst &ops=expr.operands(); @@ -41,6 +53,18 @@ bvt boolbvt::convert_update(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::convert_update_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_update_rec( const exprt::operandst &designators, std::size_t d, diff --git a/src/solvers/flattening/boolbv_vector.cpp b/src/solvers/flattening/boolbv_vector.cpp index 8a7b11739f5..499b79abe7b 100644 --- a/src/solvers/flattening/boolbv_vector.cpp +++ b/src/solvers/flattening/boolbv_vector.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_vector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_vector(const exprt &expr) { std::size_t width=boolbv_width(expr.type()); diff --git a/src/solvers/flattening/boolbv_width.cpp b/src/solvers/flattening/boolbv_width.cpp index 57fce3ccbc7..b52ea11fc8a 100644 --- a/src/solvers/flattening/boolbv_width.cpp +++ b/src/solvers/flattening/boolbv_width.cpp @@ -14,14 +14,50 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv_width.h" +/*******************************************************************\ + +Function: boolbv_widtht::boolbv_widtht + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + boolbv_widtht::boolbv_widtht(const namespacet &_ns):ns(_ns) { } +/*******************************************************************\ + +Function: boolbv_widtht::~boolbv_widtht + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + boolbv_widtht::~boolbv_widtht() { } +/*******************************************************************\ + +Function: boolbv_widtht::get_entry + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const { // check cache first @@ -216,6 +252,18 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const return entry; } +/*******************************************************************\ + +Function: boolbv_widtht::get_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const boolbv_widtht::membert &boolbv_widtht::get_member( const struct_typet &type, const irep_idt &member) const diff --git a/src/solvers/flattening/boolbv_with.cpp b/src/solvers/flattening/boolbv_with.cpp index 0e6079ebc6e..d98cd6be3b9 100644 --- a/src/solvers/flattening/boolbv_with.cpp +++ b/src/solvers/flattening/boolbv_with.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "boolbv.h" +/*******************************************************************\ + +Function: boolbvt::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt boolbvt::convert_with(const exprt &expr) { if(expr.operands().size()<3) @@ -65,6 +77,18 @@ bvt boolbvt::convert_with(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: boolbvt::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_with( const typet &type, const exprt &op1, @@ -95,6 +119,18 @@ void boolbvt::convert_with( throw 0; } +/*******************************************************************\ + +Function: boolbvt::convert_with_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_with_array( const array_typet &type, const exprt &op1, @@ -164,6 +200,18 @@ void boolbvt::convert_with_array( } } +/*******************************************************************\ + +Function: boolbvt::convert_with_bv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_with_bv( const typet &type, const exprt &op1, @@ -196,6 +244,18 @@ void boolbvt::convert_with_bv( } } +/*******************************************************************\ + +Function: boolbvt::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_with_struct( const struct_typet &type, const exprt &op1, @@ -252,6 +312,18 @@ void boolbvt::convert_with_struct( } } +/*******************************************************************\ + +Function: boolbvt::convert_with_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void boolbvt::convert_with_union( const union_typet &type, const exprt &op1, diff --git a/src/solvers/flattening/bv_minimize.cpp b/src/solvers/flattening/bv_minimize.cpp index c21426f64f5..9798f129ff8 100644 --- a/src/solvers/flattening/bv_minimize.cpp +++ b/src/solvers/flattening/bv_minimize.cpp @@ -12,6 +12,18 @@ Author: Georg Weissenbacher, georg.weissenbacher@inf.ethz.ch #include "bv_minimize.h" +/*******************************************************************\ + +Function: bv_minimizet::add_objective + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_minimizet::add_objective( prop_minimizet &prop_minimize, const exprt &objective) @@ -54,6 +66,18 @@ void bv_minimizet::add_objective( } } +/*******************************************************************\ + +Function: bv_minimizet::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_minimizet::operator()(const minimization_listt &symbols) { // build bit-wise objective function diff --git a/src/solvers/flattening/bv_minimize.h b/src/solvers/flattening/bv_minimize.h index c6c8023501b..03ba354e0d8 100644 --- a/src/solvers/flattening/bv_minimize.h +++ b/src/solvers/flattening/bv_minimize.h @@ -11,9 +11,6 @@ Purpose: Find a satisfying assignment that minimizes a given set \*******************************************************************/ -/// \file -/// SAT-optimizer for minimizing expressions - #ifndef CPROVER_SOLVERS_FLATTENING_BV_MINIMIZE_H #define CPROVER_SOLVERS_FLATTENING_BV_MINIMIZE_H diff --git a/src/solvers/flattening/bv_pointers.cpp b/src/solvers/flattening/bv_pointers.cpp index 4ac54b262c6..e026b6c3de7 100644 --- a/src/solvers/flattening/bv_pointers.cpp +++ b/src/solvers/flattening/bv_pointers.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_pointers.h" +/*******************************************************************\ + +Function: bv_pointerst::convert_rest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt bv_pointerst::convert_rest(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -88,6 +100,18 @@ literalt bv_pointerst::convert_rest(const exprt &expr) return SUB::convert_rest(expr); } +/*******************************************************************\ + +Function: bv_pointerst::bv_pointerst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_pointerst::bv_pointerst( const namespacet &_ns, propt &_prop): @@ -99,6 +123,18 @@ bv_pointerst::bv_pointerst( bits=config.ansi_c.pointer_width; } +/*******************************************************************\ + +Function: bv_pointerst::convert_address_of_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_pointerst::convert_address_of_rec( const exprt &expr, bvt &bv) @@ -211,6 +247,18 @@ bool bv_pointerst::convert_address_of_rec( return true; } +/*******************************************************************\ + +Function: bv_pointerst::convert_pointer_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_pointerst::convert_pointer_type(const exprt &expr) { if(!is_ptr(expr.type())) @@ -430,6 +478,18 @@ bvt bv_pointerst::convert_pointer_type(const exprt &expr) return conversion_failed(expr); } +/*******************************************************************\ + +Function: bv_pointerst::convert_bitvector + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_pointerst::convert_bitvector(const exprt &expr) { if(is_ptr(expr.type())) @@ -543,6 +603,18 @@ bvt bv_pointerst::convert_bitvector(const exprt &expr) return SUB::convert_bitvector(expr); } +/*******************************************************************\ + +Function: bv_pointerst::bv_get_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt bv_pointerst::bv_get_rec( const bvt &bv, const std::vector &unknown, @@ -597,6 +669,18 @@ exprt bv_pointerst::bv_get_rec( return result; } +/*******************************************************************\ + +Function: bv_pointerst::encode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_pointerst::encode(std::size_t addr, bvt &bv) { bv.resize(bits); @@ -610,6 +694,18 @@ void bv_pointerst::encode(std::size_t addr, bvt &bv) bv[offset_bits+i]=const_literal((addr&(std::size_t(1)< &pps) { assert(!pps.empty()); @@ -611,6 +953,18 @@ bvt bv_utilst::wallace_tree(const std::vector &pps) } } +/*******************************************************************\ + +Function: bv_utilst::unsigned_multiplier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::unsigned_multiplier(const bvt &_op0, const bvt &_op1) { #if 1 @@ -681,6 +1035,18 @@ bvt bv_utilst::unsigned_multiplier(const bvt &_op0, const bvt &_op1) #endif } +/*******************************************************************\ + +Function: bv_utilst::unsigned_multiplier_no_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::unsigned_multiplier_no_overflow( const bvt &op0, const bvt &op1) @@ -720,6 +1086,18 @@ bvt bv_utilst::unsigned_multiplier_no_overflow( return product; } +/*******************************************************************\ + +Function: bv_utilst::signed_multiplier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::signed_multiplier(const bvt &op0, const bvt &op1) { if(op0.empty() || op1.empty()) @@ -738,6 +1116,18 @@ bvt bv_utilst::signed_multiplier(const bvt &op0, const bvt &op1) return cond_negate(result, result_sign); } +/*******************************************************************\ + +Function: bv_utilst::cond_negate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::cond_negate(const bvt &bv, const literalt cond) { bvt neg_bv=negate(bv); @@ -751,12 +1141,36 @@ bvt bv_utilst::cond_negate(const bvt &bv, const literalt cond) return result; } +/*******************************************************************\ + +Function: bv_utilst::absolute_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::absolute_value(const bvt &bv) { assert(!bv.empty()); return cond_negate(bv, bv[bv.size()-1]); } +/*******************************************************************\ + +Function: bv_utilst::cond_negate_no_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::cond_negate_no_overflow(const bvt &bv, literalt cond) { prop.l_set_to( @@ -766,6 +1180,18 @@ bvt bv_utilst::cond_negate_no_overflow(const bvt &bv, literalt cond) return cond_negate(bv, cond); } +/*******************************************************************\ + +Function: bv_utilst::signed_multiplier_no_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::signed_multiplier_no_overflow( const bvt &op0, const bvt &op1) @@ -788,6 +1214,18 @@ bvt bv_utilst::signed_multiplier_no_overflow( return cond_negate_no_overflow(result, result_sign); } +/*******************************************************************\ + +Function: bv_utilst::multiplier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::multiplier( const bvt &op0, const bvt &op1, @@ -801,6 +1239,18 @@ bvt bv_utilst::multiplier( } } +/*******************************************************************\ + +Function: bv_utilst::multiplier_no_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::multiplier_no_overflow( const bvt &op0, const bvt &op1, @@ -816,6 +1266,18 @@ bvt bv_utilst::multiplier_no_overflow( } } +/*******************************************************************\ + +Function: bv_utilst::signed_divider + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_utilst::signed_divider( const bvt &op0, const bvt &op1, @@ -851,6 +1313,18 @@ void bv_utilst::signed_divider( rem[i]=prop.lselect(sign_0, neg_rem[i], rem[i]); } +/*******************************************************************\ + +Function: bv_utilst::divider + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_utilst::divider( const bvt &op0, const bvt &op1, @@ -870,6 +1344,18 @@ void bv_utilst::divider( } } +/*******************************************************************\ + +Function: bv_utilst::unsigned_divider + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_utilst::unsigned_divider( const bvt &op0, const bvt &op1, @@ -959,9 +1445,18 @@ void bv_utilst::unsigned_divider( #ifdef COMPACT_EQUAL_CONST // TODO : use for lt_or_le as well -/// The equal_const optimisation will be used on this bit-vector. -/// \par parameters: A bit-vector of a variable that is to be registered. -/// \return None. +/*******************************************************************\ + +Function: bv_utilst::equal_const_rec + + Inputs: A bit-vector of a variable that is to be registered. + + Outputs: None. + + Purpose: The equal_const optimisation will be used on this bit-vector. + +\*******************************************************************/ + void bv_utilst::equal_const_register(const bvt &var) { assert(!is_constant(var)); @@ -970,12 +1465,21 @@ void bv_utilst::equal_const_register(const bvt &var) } -/// The obvious recursive comparison, the interesting thing is that it is cached -/// so the literals are shared between constants. -/// \param Bit:vectors for a variable and a const to compare, note that -/// to avoid significant amounts of copying these are mutable and consumed. -/// \return The literal that is true if and only if all the bits in var and -/// const are equal. +/*******************************************************************\ + +Function: bv_utilst::equal_const_rec + + Inputs: Bit-vectors for a variable and a const to compare, note that + to avoid significant amounts of copying these are mutable and consumed. + + Outputs: The literal that is true if and only if all the bits in var + and const are equal. + + Purpose: The obvious recursive comparison, the interesting thing is + that it is cached so the literals are shared between constants. + +\*******************************************************************/ + literalt bv_utilst::equal_const_rec(bvt &var, bvt &constant) { std::size_t size = var.size(); @@ -1018,14 +1522,24 @@ literalt bv_utilst::equal_const_rec(bvt &var, bvt &constant) } } -/// An experimental encoding, aimed primarily at variable position access to -/// constant arrays. These generate a lot of comparisons of the form var = -/// small_const . It will introduce some additional literals and for variables -/// that have only a few comparisons with constants this may result in a net -/// increase in formula size. It is hoped that a 'sufficently advanced -/// preprocessor' will remove these. -/// \param Bit:vectors for a variable and a const to compare. -/// \return The literal that is true if and only if they are equal. +/*******************************************************************\ + +Function: bv_utilst::equal_const + + Inputs: Bit-vectors for a variable and a const to compare. + + Outputs: The literal that is true if and only if they are equal. + + Purpose: An experimental encoding, aimed primarily at variable + position access to constant arrays. These generate a lot of + comparisons of the form var = small_const . It will introduce some + additional literals and for variables that have only a few + comparisons with constants this may result in a net increase in + formula size. It is hoped that a 'sufficently advanced preprocessor' + will remove these. + +\*******************************************************************/ + literalt bv_utilst::equal_const(const bvt &var, const bvt &constant) { std::size_t size = constant.size(); @@ -1083,9 +1597,18 @@ literalt bv_utilst::equal_const(const bvt &var, const bvt &constant) #endif -/// Bit-blasting ID_equal and use in other encodings. -/// \param Bit:vectors for the two things to compare. -/// \return The literal that is true if and only if they are equal. +/*******************************************************************\ + +Function: bv_utilst::equal + + Inputs: Bit-vectors for the two things to compare. + + Outputs: The literal that is true if and only if they are equal. + + Purpose: Bit-blasting ID_equal and use in other encodings. + +\*******************************************************************/ + literalt bv_utilst::equal(const bvt &op0, const bvt &op1) { assert(op0.size()==op1.size()); @@ -1110,10 +1633,20 @@ literalt bv_utilst::equal(const bvt &op0, const bvt &op1) return prop.land(equal_bv); } -/// To provide a bitwise model of < or <=. -/// \par parameters: bvts for each input and whether they are signed and whether -/// a model of < or <= is required. -/// \return A literalt that models the value of the comparison. +/*******************************************************************\ + +Function: bv_utilst::lt_or_le + + Inputs: bvts for each input and whether they are signed and whether + a model of < or <= is required. + + Outputs: A literalt that models the value of the comparison. + + Purpose: To provide a bitwise model of < or <=. + +\*******************************************************************/ + + /* Some clauses are not needed for correctness but they remove models (effectively setting "don't care" bits) and so may be worth including.*/ @@ -1240,6 +1773,18 @@ literalt bv_utilst::lt_or_le( } } +/*******************************************************************\ + +Function: bv_utilst::unsigned_less_than + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt bv_utilst::unsigned_less_than( const bvt &op0, const bvt &op1) @@ -1252,6 +1797,18 @@ literalt bv_utilst::unsigned_less_than( #endif } +/*******************************************************************\ + +Function: bv_utilst::signed_less_than + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt bv_utilst::signed_less_than( const bvt &bv0, const bvt &bv1) @@ -1259,6 +1816,18 @@ literalt bv_utilst::signed_less_than( return lt_or_le(false, bv0, bv1, representationt::SIGNED); } +/*******************************************************************\ + +Function: bv_utilst::rel + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt bv_utilst::rel( const bvt &bv0, irep_idt id, @@ -1281,6 +1850,18 @@ literalt bv_utilst::rel( assert(false); } +/*******************************************************************\ + +Function: bv_utilst::is_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_utilst::is_constant(const bvt &bv) { forall_literals(it, bv) @@ -1290,6 +1871,18 @@ bool bv_utilst::is_constant(const bvt &bv) return true; } +/*******************************************************************\ + +Function: bv_utilst::cond_implies_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_utilst::cond_implies_equal( literalt cond, const bvt &a, @@ -1313,6 +1906,18 @@ void bv_utilst::cond_implies_equal( return; } +/*******************************************************************\ + +Function: bv_utilst::verilog_bv_has_x_or_z + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt bv_utilst::verilog_bv_has_x_or_z(const bvt &src) { bvt odd_bits; @@ -1328,6 +1933,18 @@ literalt bv_utilst::verilog_bv_has_x_or_z(const bvt &src) return prop.lor(odd_bits); } +/*******************************************************************\ + +Function: bv_utilst::verilog_bv_normal_bits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_utilst::verilog_bv_normal_bits(const bvt &src) { bvt even_bits; diff --git a/src/solvers/flattening/c_bit_field_replacement_type.cpp b/src/solvers/flattening/c_bit_field_replacement_type.cpp index a9876ac88de..5a81dc085d5 100644 --- a/src/solvers/flattening/c_bit_field_replacement_type.cpp +++ b/src/solvers/flattening/c_bit_field_replacement_type.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "c_bit_field_replacement_type.h" +/*******************************************************************\ + +Function: c_bit_field_replacement_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet c_bit_field_replacement_type( const c_bit_field_typet &src, const namespacet &ns) diff --git a/src/solvers/flattening/equality.cpp b/src/solvers/flattening/equality.cpp index 1cb03e9e753..63ca7e2e147 100644 --- a/src/solvers/flattening/equality.cpp +++ b/src/solvers/flattening/equality.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "equality.h" #include "bv_utils.h" +/*******************************************************************\ + +Function: equalityt::equality + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt equalityt::equality(const exprt &e1, const exprt &e2) { if(e1second); } +/*******************************************************************\ + +Function: equalityt::add_equality_constraints + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void equalityt::add_equality_constraints(const typestructt &typestruct) { std::size_t no_elements=typestruct.elements.size(); diff --git a/src/solvers/flattening/flatten_byte_operators.cpp b/src/solvers/flattening/flatten_byte_operators.cpp index df7435a26e9..68ad4b9197e 100644 --- a/src/solvers/flattening/flatten_byte_operators.cpp +++ b/src/solvers/flattening/flatten_byte_operators.cpp @@ -16,8 +16,19 @@ Author: Daniel Kroening, kroening@kroening.com #include "flatten_byte_operators.h" -/// rewrite byte extraction from an array to byte extraction from a -/// concatenation of array index expressions +/*******************************************************************\ + +Function: flatten_byte_extract + + Inputs: + + Outputs: + + Purpose: rewrite byte extraction from an array to byte extraction + from a concatenation of array index expressions + +\*******************************************************************/ + exprt flatten_byte_extract( const byte_extract_exprt &src, const namespacet &ns) @@ -165,6 +176,18 @@ exprt flatten_byte_extract( } } +/*******************************************************************\ + +Function: flatten_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt flatten_byte_update( const byte_update_exprt &src, const namespacet &ns, @@ -418,6 +441,18 @@ exprt flatten_byte_update( } } +/*******************************************************************\ + +Function: flatten_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt flatten_byte_update( const byte_update_exprt &src, const namespacet &ns) @@ -425,6 +460,18 @@ exprt flatten_byte_update( return flatten_byte_update(src, ns, false); } +/*******************************************************************\ + +Function: has_byte_operators + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_byte_operator(const exprt &src) { if(src.id()==ID_byte_update_little_endian || @@ -440,6 +487,18 @@ bool has_byte_operator(const exprt &src) return false; } +/*******************************************************************\ + +Function: flatten_byte_operators + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt flatten_byte_operators( const exprt &src, const namespacet &ns) diff --git a/src/solvers/flattening/functions.cpp b/src/solvers/flattening/functions.cpp index 161ec973c7f..6b23229c958 100644 --- a/src/solvers/flattening/functions.cpp +++ b/src/solvers/flattening/functions.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "functions.h" +/*******************************************************************\ + +Function: functionst::record + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void functionst::record( const function_application_exprt &function_application) { @@ -20,6 +32,18 @@ void functionst::record( insert(function_application); } +/*******************************************************************\ + +Function: functionst::add_function_constraints + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void functionst::add_function_constraints() { for(function_mapt::const_iterator it= @@ -29,6 +53,18 @@ void functionst::add_function_constraints() add_function_constraints(it->second); } +/*******************************************************************\ + +Function: functionst::add_function_constraints + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt functionst::arguments_equal(const exprt::operandst &o1, const exprt::operandst &o2) { @@ -55,6 +91,18 @@ exprt functionst::arguments_equal(const exprt::operandst &o1, return and_expr; } +/*******************************************************************\ + +Function: functionst::add_function_constraints + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void functionst::add_function_constraints(const function_infot &info) { // Do Ackermann's function reduction. diff --git a/src/solvers/flattening/functions.h b/src/solvers/flattening/functions.h index 0403e34189f..1708862e946 100644 --- a/src/solvers/flattening/functions.h +++ b/src/solvers/flattening/functions.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Uninterpreted Functions - #ifndef CPROVER_SOLVERS_FLATTENING_FUNCTIONS_H #define CPROVER_SOLVERS_FLATTENING_FUNCTIONS_H diff --git a/src/solvers/flattening/pointer_logic.cpp b/src/solvers/flattening/pointer_logic.cpp index b5f82567440..c2b9d1175d0 100644 --- a/src/solvers/flattening/pointer_logic.cpp +++ b/src/solvers/flattening/pointer_logic.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Logic - #include #include @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_logic.h" +/*******************************************************************\ + +Function: pointer_logict::is_dynamic_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool pointer_logict::is_dynamic_object(const exprt &expr) const { if(expr.type().get_bool("#dynamic")) @@ -31,6 +40,18 @@ bool pointer_logict::is_dynamic_object(const exprt &expr) const return false; } +/*******************************************************************\ + +Function: pointer_logict::get_dynamic_objects + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pointer_logict::get_dynamic_objects(std::vector &o) const { o.clear(); @@ -44,6 +65,18 @@ void pointer_logict::get_dynamic_objects(std::vector &o) const o.push_back(nr); } +/*******************************************************************\ + +Function: pointer_logict::add_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t pointer_logict::add_object(const exprt &expr) { // remove any index/member @@ -62,6 +95,18 @@ std::size_t pointer_logict::add_object(const exprt &expr) return objects.number(expr); } +/*******************************************************************\ + +Function: pointer_logict::pointer_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_logict::pointer_expr( std::size_t object, const typet &type) const @@ -70,6 +115,18 @@ exprt pointer_logict::pointer_expr( return pointer_expr(pointer, type); } +/*******************************************************************\ + +Function: pointer_logict::pointer_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_logict::pointer_expr( const pointert &pointer, const typet &type) const @@ -121,6 +178,18 @@ exprt pointer_logict::pointer_expr( return result; } +/*******************************************************************\ + +Function: pointer_logict::object_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_logict::object_rec( const mp_integer &offset, const typet &pointer_type, @@ -191,6 +260,18 @@ exprt pointer_logict::object_rec( return src; } +/*******************************************************************\ + +Function: pointer_logict::pointer_logict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + pointer_logict::pointer_logict(const namespacet &_ns):ns(_ns) { // add NULL @@ -201,6 +282,18 @@ pointer_logict::pointer_logict(const namespacet &_ns):ns(_ns) invalid_object=objects.number(exprt("INVALID")); } +/*******************************************************************\ + +Function: pointer_logict::~pointer_logict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + pointer_logict::~pointer_logict() { } diff --git a/src/solvers/flattening/pointer_logic.h b/src/solvers/flattening/pointer_logic.h index a0dc8b7fb50..bcf18ca69f7 100644 --- a/src/solvers/flattening/pointer_logic.h +++ b/src/solvers/flattening/pointer_logic.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Logic - #ifndef CPROVER_SOLVERS_FLATTENING_POINTER_LOGIC_H #define CPROVER_SOLVERS_FLATTENING_POINTER_LOGIC_H diff --git a/src/solvers/floatbv/float_approximation.cpp b/src/solvers/floatbv/float_approximation.cpp index 9cb84dd52e4..08e65162647 100644 --- a/src/solvers/floatbv/float_approximation.cpp +++ b/src/solvers/floatbv/float_approximation.cpp @@ -10,10 +10,34 @@ Author: Daniel Kroening, kroening@kroening.com #include "float_approximation.h" +/*******************************************************************\ + +Function: float_approximationt::~float_approximationt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + float_approximationt::~float_approximationt() { } +/*******************************************************************\ + +Function: float_approximationt::round_fraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_approximationt::normalization_shift(bvt &fraction, bvt &exponent) { // this thing is quadratic! @@ -63,6 +87,18 @@ void float_approximationt::normalization_shift(bvt &fraction, bvt &exponent) exponent=new_exponent; } +/*******************************************************************\ + +Function: float_approximationt::overapproximating_left_shift + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_approximationt::overapproximating_left_shift( const bvt &src, unsigned dist) { diff --git a/src/solvers/floatbv/float_approximation.h b/src/solvers/floatbv/float_approximation.h index daaaac8c7f3..c0a266b8fb6 100644 --- a/src/solvers/floatbv/float_approximation.h +++ b/src/solvers/floatbv/float_approximation.h @@ -6,9 +6,6 @@ Module: Floating Point with under/over-approximation \*******************************************************************/ -/// \file -/// Floating Point with under/over-approximation - #ifndef CPROVER_SOLVERS_FLOATBV_FLOAT_APPROXIMATION_H #define CPROVER_SOLVERS_FLOATBV_FLOAT_APPROXIMATION_H diff --git a/src/solvers/floatbv/float_bv.cpp b/src/solvers/floatbv/float_bv.cpp index 83121b75c78..0d07a9d8ee9 100644 --- a/src/solvers/floatbv/float_bv.cpp +++ b/src/solvers/floatbv/float_bv.cpp @@ -14,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "float_bv.h" +/*******************************************************************\ + +Function: float_bvt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::convert(const exprt &expr) { if(expr.id()==ID_abs) @@ -95,12 +107,36 @@ exprt float_bvt::convert(const exprt &expr) return nil_exprt(); } +/*******************************************************************\ + +Function: float_bvt::get_spec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_float_spect float_bvt::get_spec(const exprt &expr) { const floatbv_typet &type=to_floatbv_type(expr.type()); return ieee_float_spect(type); } +/*******************************************************************\ + +Function: float_bvt::abs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::abs(const exprt &op, const ieee_float_spect &spec) { // we mask away the sign bit, which is the most significand bit @@ -112,6 +148,18 @@ exprt float_bvt::abs(const exprt &op, const ieee_float_spect &spec) return bitand_exprt(op, mask); } +/*******************************************************************\ + +Function: float_bvt::negation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::negation(const exprt &op, const ieee_float_spect &spec) { // we flip the sign bit with an xor @@ -123,6 +171,18 @@ exprt float_bvt::negation(const exprt &op, const ieee_float_spect &spec) return bitxor_exprt(op, mask); } +/*******************************************************************\ + +Function: float_bvt::is_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::is_equal( const exprt &src0, const exprt &src1, @@ -145,6 +205,18 @@ exprt float_bvt::is_equal( not_exprt(nan)); } +/*******************************************************************\ + +Function: float_bvt::is_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::is_zero( const exprt &src, const ieee_float_spect &spec) @@ -164,6 +236,18 @@ exprt float_bvt::is_zero( return equal_exprt(bitand_exprt(src, mask), z.to_expr()); } +/*******************************************************************\ + +Function: float_bvt::exponent_all_ones + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::exponent_all_ones( const exprt &src, const ieee_float_spect &spec) @@ -173,6 +257,18 @@ exprt float_bvt::exponent_all_ones( return equal_exprt(exponent, all_ones); } +/*******************************************************************\ + +Function: float_bvt::exponent_all_zeros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::exponent_all_zeros( const exprt &src, const ieee_float_spect &spec) @@ -182,6 +278,18 @@ exprt float_bvt::exponent_all_zeros( return equal_exprt(exponent, all_zeros); } +/*******************************************************************\ + +Function: float_bvt::fraction_all_zeros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::fraction_all_zeros( const exprt &src, const ieee_float_spect &spec) @@ -192,6 +300,18 @@ exprt float_bvt::fraction_all_zeros( return equal_exprt(fraction, all_zeros); } +/*******************************************************************\ + +Function: float_bvt::rounding_mode_bitst::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_bvt::rounding_mode_bitst::get(const exprt &rm) { exprt round_to_even_const=from_integer(ieee_floatt::ROUND_TO_EVEN, rm.type()); @@ -207,6 +327,18 @@ void float_bvt::rounding_mode_bitst::get(const exprt &rm) round_to_zero=equal_exprt(rm, round_to_zero_const); } +/*******************************************************************\ + +Function: float_bvt::sign_bit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::sign_bit(const exprt &op) { const bitvector_typet &bv_type=to_bitvector_type(op.type()); @@ -214,6 +346,18 @@ exprt float_bvt::sign_bit(const exprt &op) return extractbit_exprt(op, width-1); } +/*******************************************************************\ + +Function: float_bvt::from_signed_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::from_signed_integer( const exprt &src, const exprt &rm, @@ -238,6 +382,18 @@ exprt float_bvt::from_signed_integer( return rounder(result, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::from_unsigned_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::from_unsigned_integer( const exprt &src, const exprt &rm, @@ -260,6 +416,18 @@ exprt float_bvt::from_unsigned_integer( return rounder(result, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::to_signed_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::to_signed_integer( const exprt &src, std::size_t dest_width, @@ -269,6 +437,18 @@ exprt float_bvt::to_signed_integer( return to_integer(src, dest_width, true, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::to_unsigned_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::to_unsigned_integer( const exprt &src, std::size_t dest_width, @@ -278,6 +458,18 @@ exprt float_bvt::to_unsigned_integer( return to_integer(src, dest_width, false, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::to_integer( const exprt &src, std::size_t dest_width, @@ -326,6 +518,18 @@ exprt float_bvt::to_integer( return result; } +/*******************************************************************\ + +Function: float_bvt::conversion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::conversion( const exprt &src, const exprt &rm, @@ -391,6 +595,18 @@ exprt float_bvt::conversion( } } +/*******************************************************************\ + +Function: float_bvt::isnormal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::isnormal( const exprt &src, const ieee_float_spect &spec) @@ -400,7 +616,18 @@ exprt float_bvt::isnormal( not_exprt(exponent_all_ones(src, spec))); } -/// Subtracts the exponents +/*******************************************************************\ + +Function: float_bvt::subtract_exponents + + Inputs: + + Outputs: + + Purpose: Subtracts the exponents + +\*******************************************************************/ + exprt float_bvt::subtract_exponents( const unbiased_floatt &src1, const unbiased_floatt &src2) @@ -421,6 +648,18 @@ exprt float_bvt::subtract_exponents( return minus_exprt(extended_exponent1, extended_exponent2); } +/*******************************************************************\ + +Function: float_bvt::add_sub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::add_sub( bool subtract, const exprt &op0, @@ -568,7 +807,18 @@ exprt float_bvt::add_sub( return rounder(result, rm, spec); } -/// Limits the shift distance +/*******************************************************************\ + +Function: float_bvt::limit_distance + + Inputs: + + Outputs: + + Purpose: Limits the shift distance + +\*******************************************************************/ + exprt float_bvt::limit_distance( const exprt &dist, mp_integer limit) @@ -595,6 +845,18 @@ exprt float_bvt::limit_distance( unsignedbv_typet(nb_bits).largest_expr()); } +/*******************************************************************\ + +Function: float_bvt::mul + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::mul( const exprt &src1, const exprt &src2, @@ -650,6 +912,18 @@ exprt float_bvt::mul( return rounder(result, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::div( const exprt &src1, const exprt &src2, @@ -742,6 +1016,18 @@ exprt float_bvt::div( return rounder(result, rm, spec); } +/*******************************************************************\ + +Function: float_bvt::relation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::relation( const exprt &src1, relt rel, @@ -833,6 +1119,18 @@ exprt float_bvt::relation( return false_exprt(); } +/*******************************************************************\ + +Function: float_bvt::isinf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::isinf( const exprt &src, const ieee_float_spect &spec) @@ -842,6 +1140,18 @@ exprt float_bvt::isinf( fraction_all_zeros(src, spec)); } +/*******************************************************************\ + +Function: float_bvt::isfinite + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::isfinite( const exprt &src, const ieee_float_spect &spec) @@ -849,7 +1159,18 @@ exprt float_bvt::isfinite( return not_exprt(or_exprt(isinf(src, spec), isnan(src, spec))); } -/// Gets the unbiased exponent in a floating-point bit-vector +/*******************************************************************\ + +Function: float_bvt::get_exponent + + Inputs: + + Outputs: + + Purpose: Gets the unbiased exponent in a floating-point bit-vector + +\*******************************************************************/ + exprt float_bvt::get_exponent( const exprt &src, const ieee_float_spect &spec) @@ -859,7 +1180,19 @@ exprt float_bvt::get_exponent( unsignedbv_typet(spec.e)); } -/// Gets the fraction without hidden bit in a floating-point bit-vector src +/*******************************************************************\ + +Function: float_bvt::get_fraction + + Inputs: + + Outputs: + + Purpose: Gets the fraction without hidden bit in a floating-point + bit-vector src + +\*******************************************************************/ + exprt float_bvt::get_fraction( const exprt &src, const ieee_float_spect &spec) @@ -869,6 +1202,18 @@ exprt float_bvt::get_fraction( unsignedbv_typet(spec.f)); } +/*******************************************************************\ + +Function: float_bvt::isnan + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::isnan( const exprt &src, const ieee_float_spect &spec) @@ -877,7 +1222,19 @@ exprt float_bvt::isnan( not_exprt(fraction_all_zeros(src, spec))); } -/// normalize fraction/exponent pair returns 'zero' if fraction is zero +/*******************************************************************\ + +Function: float_bvt::normalization_shift + + Inputs: + + Outputs: + + Purpose: normalize fraction/exponent pair + returns 'zero' if fraction is zero + +\*******************************************************************/ + void float_bvt::normalization_shift( exprt &fraction, exprt &exponent) @@ -926,7 +1283,19 @@ void float_bvt::normalization_shift( exponent=minus_exprt(exponent, exponent_delta); } -/// make sure exponent is not too small; the exponent is unbiased +/*******************************************************************\ + +Function: float_bvt::denormalization_shift + + Inputs: + + Outputs: + + Purpose: make sure exponent is not too small; + the exponent is unbiased + +\*******************************************************************/ + void float_bvt::denormalization_shift( exprt &fraction, exprt &exponent, @@ -1006,6 +1375,18 @@ void float_bvt::denormalization_shift( exponent); } +/*******************************************************************\ + +Function: float_bvt::rounder + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::rounder( const unbiased_floatt &src, const exprt &rm, @@ -1050,7 +1431,18 @@ exprt float_bvt::rounder( return pack(bias(result, spec), spec); } -/// rounding decision for fraction using sticky bit +/*******************************************************************\ + +Function: float_bvt::fraction_rounding_decision + + Inputs: + + Outputs: + + Purpose: rounding decision for fraction using sticky bit + +\*******************************************************************/ + exprt float_bvt::fraction_rounding_decision( const std::size_t dest_bits, const exprt sign, @@ -1114,6 +1506,18 @@ exprt float_bvt::fraction_rounding_decision( false_exprt())))); // otherwise zero } +/*******************************************************************\ + +Function: float_bvt::round_fraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_bvt::round_fraction( unbiased_floatt &result, const rounding_mode_bitst &rounding_mode_bits, @@ -1224,6 +1628,18 @@ void float_bvt::round_fraction( } } +/*******************************************************************\ + +Function: float_bvt::round_exponent + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_bvt::round_exponent( unbiased_floatt &result, const rounding_mode_bitst &rounding_mode_bits, @@ -1298,7 +1714,18 @@ void float_bvt::round_exponent( } } -/// takes an unbiased float, and applies the bias +/*******************************************************************\ + +Function: float_bvt::bias + + Inputs: + + Outputs: + + Purpose: takes an unbiased float, and applies the bias + +\*******************************************************************/ + float_bvt::biased_floatt float_bvt::bias( const unbiased_floatt &src, const ieee_float_spect &spec) @@ -1332,6 +1759,18 @@ float_bvt::biased_floatt float_bvt::bias( return result; } +/*******************************************************************\ + +Function: float_bvt::add_bias + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::add_bias( const exprt &src, const ieee_float_spect &spec) @@ -1342,6 +1781,18 @@ exprt float_bvt::add_bias( from_integer(spec.bias(), t)); } +/*******************************************************************\ + +Function: float_bvt::sub_bias + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::sub_bias( const exprt &src, const ieee_float_spect &spec) @@ -1352,6 +1803,18 @@ exprt float_bvt::sub_bias( from_integer(spec.bias(), t)); } +/*******************************************************************\ + +Function: float_bvt::unpack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + float_bvt::unbiased_floatt float_bvt::unpack( const exprt &src, const ieee_float_spect &spec) @@ -1385,6 +1848,18 @@ float_bvt::unbiased_floatt float_bvt::unpack( return result; } +/*******************************************************************\ + +Function: float_bvt::pack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::pack( const biased_floatt &src, const ieee_float_spect &spec) @@ -1420,6 +1895,18 @@ exprt float_bvt::pack( spec.to_type()); } +/*******************************************************************\ + +Function: float_bvt::sticky_right_shift + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt float_bvt::sticky_right_shift( const exprt &op, const exprt &dist, diff --git a/src/solvers/floatbv/float_utils.cpp b/src/solvers/floatbv/float_utils.cpp index 35cb12de2ab..3660aced265 100644 --- a/src/solvers/floatbv/float_utils.cpp +++ b/src/solvers/floatbv/float_utils.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "float_utils.h" +/*******************************************************************\ + +Function: float_utilst::set_rounding_mode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_utilst::set_rounding_mode(const bvt &src) { bvt round_to_even= @@ -30,6 +42,18 @@ void float_utilst::set_rounding_mode(const bvt &src) rounding_mode_bits.round_to_zero=bv_utils.equal(src, round_to_zero); } +/*******************************************************************\ + +Function: float_utilst::from_signed_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::from_signed_integer(const bvt &src) { unbiased_floatt result; @@ -48,6 +72,18 @@ bvt float_utilst::from_signed_integer(const bvt &src) return rounder(result); } +/*******************************************************************\ + +Function: float_utilst::from_unsigned_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::from_unsigned_integer(const bvt &src) { unbiased_floatt result; @@ -65,6 +101,18 @@ bvt float_utilst::from_unsigned_integer(const bvt &src) return rounder(result); } +/*******************************************************************\ + +Function: float_utilst::to_signed_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::to_signed_integer( const bvt &src, std::size_t dest_width) @@ -72,6 +120,18 @@ bvt float_utilst::to_signed_integer( return to_integer(src, dest_width, true); } +/*******************************************************************\ + +Function: float_utilst::to_unsigned_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::to_unsigned_integer( const bvt &src, std::size_t dest_width) @@ -79,6 +139,18 @@ bvt float_utilst::to_unsigned_integer( return to_integer(src, dest_width, false); } +/*******************************************************************\ + +Function: float_utilst::to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::to_integer( const bvt &src, std::size_t dest_width, @@ -138,6 +210,18 @@ bvt float_utilst::to_integer( throw "unsupported rounding mode"; } +/*******************************************************************\ + +Function: float_utilst::build_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::build_constant(const ieee_floatt &src) { unbiased_floatt result; @@ -151,6 +235,18 @@ bvt float_utilst::build_constant(const ieee_floatt &src) return pack(bias(result)); } +/*******************************************************************\ + +Function: float_utilst::conversion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::conversion( const bvt &src, const ieee_float_spect &dest_spec) @@ -218,6 +314,18 @@ bvt float_utilst::conversion( } } +/*******************************************************************\ + +Function: float_utilst::is_normal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_normal(const bvt &src) { return prop.land( @@ -225,7 +333,18 @@ literalt float_utilst::is_normal(const bvt &src) !exponent_all_ones(src)); } -/// Subtracts the exponents +/*******************************************************************\ + +Function: float_utilst::subtract_exponents + + Inputs: + + Outputs: + + Purpose: Subtracts the exponents + +\*******************************************************************/ + bvt float_utilst::subtract_exponents( const unbiased_floatt &src1, const unbiased_floatt &src2) @@ -242,6 +361,18 @@ bvt float_utilst::subtract_exponents( return bv_utils.sub(extended_exponent1, extended_exponent2); } +/*******************************************************************\ + +Function: float_utilst::add_sub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::add_sub( const bvt &src1, const bvt &src2, @@ -383,7 +514,18 @@ bvt float_utilst::add_sub( return rounder(result); } -/// Limits the shift distance +/*******************************************************************\ + +Function: float_utilst::limit_distance + + Inputs: + + Outputs: + + Purpose: Limits the shift distance + +\*******************************************************************/ + bvt float_utilst::limit_distance( const bvt &dist, mp_integer limit) @@ -407,6 +549,18 @@ bvt float_utilst::limit_distance( return result; } +/*******************************************************************\ + +Function: float_utilst::mul + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::mul(const bvt &src1, const bvt &src2) { // unpack @@ -459,6 +613,18 @@ bvt float_utilst::mul(const bvt &src1, const bvt &src2) return rounder(result); } +/*******************************************************************\ + +Function: float_utilst::div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::div(const bvt &src1, const bvt &src2) { // unpack @@ -538,6 +704,18 @@ bvt float_utilst::div(const bvt &src1, const bvt &src2) return rounder(result); } +/*******************************************************************\ + +Function: float_utilst::rem + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::rem(const bvt &src1, const bvt &src2) { /* The semantics of floating-point remainder implemented as below @@ -553,6 +731,18 @@ bvt float_utilst::rem(const bvt &src1, const bvt &src2) return sub(src1, mul(div(src1, src2), src2)); } +/*******************************************************************\ + +Function: float_utilst::negate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::negate(const bvt &src) { bvt result=src; @@ -562,6 +752,18 @@ bvt float_utilst::negate(const bvt &src) return result; } +/*******************************************************************\ + +Function: float_utilst::abs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::abs(const bvt &src) { bvt result=src; @@ -570,6 +772,18 @@ bvt float_utilst::abs(const bvt &src) return result; } +/*******************************************************************\ + +Function: float_utilst::relation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::relation( const bvt &src1, relt rel, @@ -652,6 +866,18 @@ literalt float_utilst::relation( return const_literal(false); } +/*******************************************************************\ + +Function: float_utilst::is_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_zero(const bvt &src) { assert(!src.empty()); @@ -661,6 +887,18 @@ literalt float_utilst::is_zero(const bvt &src) return bv_utils.is_zero(all_but_sign); } +/*******************************************************************\ + +Function: float_utilst::is_plus_inf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_plus_inf(const bvt &src) { bvt and_bv; @@ -670,6 +908,18 @@ literalt float_utilst::is_plus_inf(const bvt &src) return prop.land(and_bv); } +/*******************************************************************\ + +Function: float_utilst::infinity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_infinity(const bvt &src) { return prop.land( @@ -677,18 +927,53 @@ literalt float_utilst::is_infinity(const bvt &src) fraction_all_zeros(src)); } -/// Gets the unbiased exponent in a floating-point bit-vector +/*******************************************************************\ + +Function: float_utilst::get_exponent + + Inputs: + + Outputs: + + Purpose: Gets the unbiased exponent in a floating-point bit-vector + +\*******************************************************************/ + bvt float_utilst::get_exponent(const bvt &src) { return bv_utils.extract(src, spec.f, spec.f+spec.e-1); } -/// Gets the fraction without hidden bit in a floating-point bit-vector src +/*******************************************************************\ + +Function: float_utilst::get_fraction + + Inputs: + + Outputs: + + Purpose: Gets the fraction without hidden bit in a floating-point + bit-vector src + +\*******************************************************************/ + bvt float_utilst::get_fraction(const bvt &src) { return bv_utils.extract(src, 0, spec.f-1); } +/*******************************************************************\ + +Function: float_utilst::is_minus_inf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_minus_inf(const bvt &src) { bvt and_bv; @@ -698,12 +983,36 @@ literalt float_utilst::is_minus_inf(const bvt &src) return prop.land(and_bv); } +/*******************************************************************\ + +Function: float_utilst::is_NaN + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::is_NaN(const bvt &src) { return prop.land(exponent_all_ones(src), !fraction_all_zeros(src)); } +/*******************************************************************\ + +Function: float_utilst::exponent_all_ones + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::exponent_all_ones(const bvt &src) { bvt exponent=src; @@ -717,6 +1026,18 @@ literalt float_utilst::exponent_all_ones(const bvt &src) return bv_utils.is_all_ones(exponent); } +/*******************************************************************\ + +Function: float_utilst::exponent_all_zeros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::exponent_all_zeros(const bvt &src) { bvt exponent=src; @@ -730,6 +1051,18 @@ literalt float_utilst::exponent_all_zeros(const bvt &src) return bv_utils.is_zero(exponent); } +/*******************************************************************\ + +Function: float_utilst::fraction_all_zeros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt float_utilst::fraction_all_zeros(const bvt &src) { // does not include hidden bit @@ -739,7 +1072,19 @@ literalt float_utilst::fraction_all_zeros(const bvt &src) return bv_utils.is_zero(tmp); } -/// normalize fraction/exponent pair returns 'zero' if fraction is zero +/*******************************************************************\ + +Function: float_utilst::normalization_shift + + Inputs: + + Outputs: + + Purpose: normalize fraction/exponent pair + returns 'zero' if fraction is zero + +\*******************************************************************/ + void float_utilst::normalization_shift(bvt &fraction, bvt &exponent) { #if 0 @@ -824,7 +1169,19 @@ void float_utilst::normalization_shift(bvt &fraction, bvt &exponent) #endif } -/// make sure exponent is not too small; the exponent is unbiased +/*******************************************************************\ + +Function: float_utilst::denormalization_shift + + Inputs: + + Outputs: + + Purpose: make sure exponent is not too small; + the exponent is unbiased + +\*******************************************************************/ + void float_utilst::denormalization_shift(bvt &fraction, bvt &exponent) { mp_integer bias=spec.bias(); @@ -893,6 +1250,18 @@ void float_utilst::denormalization_shift(bvt &fraction, bvt &exponent) exponent); } +/*******************************************************************\ + +Function: float_utilst::rounder + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::rounder(const unbiased_floatt &src) { // incoming: some fraction (with explicit 1), @@ -933,7 +1302,18 @@ bvt float_utilst::rounder(const unbiased_floatt &src) return pack(bias(result)); } -/// rounding decision for fraction using sticky bit +/*******************************************************************\ + +Function: float_utilst::fraction_rounding_decision + + Inputs: + + Outputs: + + Purpose: rounding decision for fraction using sticky bit + +\*******************************************************************/ + literalt float_utilst::fraction_rounding_decision( const std::size_t dest_bits, const literalt sign, @@ -991,6 +1371,18 @@ literalt float_utilst::fraction_rounding_decision( prop.new_variable())))); // otherwise non-det } +/*******************************************************************\ + +Function: float_utilst::round_fraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_utilst::round_fraction(unbiased_floatt &result) { std::size_t fraction_size=spec.f+1; @@ -1083,6 +1475,18 @@ void float_utilst::round_fraction(unbiased_floatt &result) } } +/*******************************************************************\ + +Function: float_utilst::round_exponent + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void float_utilst::round_exponent(unbiased_floatt &result) { // do we need to enlarge the exponent? @@ -1148,7 +1552,18 @@ void float_utilst::round_exponent(unbiased_floatt &result) } } -/// takes an unbiased float, and applies the bias +/*******************************************************************\ + +Function: float_utilst::bias + + Inputs: + + Outputs: + + Purpose: takes an unbiased float, and applies the bias + +\*******************************************************************/ + float_utilst::biased_floatt float_utilst::bias(const unbiased_floatt &src) { biased_floatt result; @@ -1178,6 +1593,18 @@ float_utilst::biased_floatt float_utilst::bias(const unbiased_floatt &src) return result; } +/*******************************************************************\ + +Function: float_utilst::add_bias + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::add_bias(const bvt &src) { assert(src.size()==spec.e); @@ -1187,6 +1614,18 @@ bvt float_utilst::add_bias(const bvt &src) bv_utils.build_constant(spec.bias(), spec.e)); } +/*******************************************************************\ + +Function: float_utilst::sub_bias + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::sub_bias(const bvt &src) { assert(src.size()==spec.e); @@ -1196,6 +1635,18 @@ bvt float_utilst::sub_bias(const bvt &src) bv_utils.build_constant(spec.bias(), spec.e)); } +/*******************************************************************\ + +Function: float_utilst::unpack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + float_utilst::unbiased_floatt float_utilst::unpack(const bvt &src) { assert(src.size()==spec.width()); @@ -1225,6 +1676,18 @@ float_utilst::unbiased_floatt float_utilst::unpack(const bvt &src) return result; } +/*******************************************************************\ + +Function: float_utilst::pack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::pack(const biased_floatt &src) { assert(src.fraction.size()==spec.f); @@ -1256,6 +1719,18 @@ bvt float_utilst::pack(const biased_floatt &src) return result; } +/*******************************************************************\ + +Function: float_utilst::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_floatt float_utilst::get(const bvt &src) const { mp_integer int_value=0; @@ -1270,6 +1745,18 @@ ieee_floatt float_utilst::get(const bvt &src) const return result; } +/*******************************************************************\ + +Function: float_utilst::sticky_right_shift + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::sticky_right_shift( const bvt &op, const bvt &dist, @@ -1305,6 +1792,18 @@ bvt float_utilst::sticky_right_shift( return result; } +/*******************************************************************\ + +Function: float_utilst::debug1 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::debug1( const bvt &src1, const bvt &src2) @@ -1312,6 +1811,18 @@ bvt float_utilst::debug1( return src1; } +/*******************************************************************\ + +Function: float_utilst::debug1 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt float_utilst::debug2( const bvt &op0, const bvt &op1) diff --git a/src/solvers/miniBDD/example.cpp b/src/solvers/miniBDD/example.cpp index 4918b89a601..2dddc990d5a 100644 --- a/src/solvers/miniBDD/example.cpp +++ b/src/solvers/miniBDD/example.cpp @@ -7,10 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// A minimalistic BDD library, following Bryant's original paper and Andersen's -/// lecture notes - #include #include "miniBDD.h" diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index 2b337c2ec15..756a9dc6e52 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -7,10 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// A minimalistic BDD library, following Bryant's original paper and Andersen's -/// lecture notes - #include #include diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index f7dde020fe6..aab378edbae 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -7,10 +7,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// A minimalistic BDD library, following Bryant's original paper and Andersen's -/// lecture notes - #ifndef CPROVER_SOLVERS_MINIBDD_MINIBDD_H #define CPROVER_SOLVERS_MINIBDD_MINIBDD_H diff --git a/src/solvers/prop/aig.cpp b/src/solvers/prop/aig.cpp index 1134e39c3bd..791436646f9 100644 --- a/src/solvers/prop/aig.cpp +++ b/src/solvers/prop/aig.cpp @@ -12,22 +12,70 @@ Author: Daniel Kroening, kroening@kroening.com #include "aig.h" +/*******************************************************************\ + +Function: aigt::label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string aigt::label(nodest::size_type v) const { return "var("+std::to_string(v)+")"; } +/*******************************************************************\ + +Function: aigt::dot_label + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string aigt::dot_label(nodest::size_type v) const { return "var("+std::to_string(v)+")"; } +/*******************************************************************\ + +Function: aigt::get_terminals + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void aigt::get_terminals(terminalst &terminals) const { for(nodest::size_type n=0; n &n_pos, std::vector &n_neg) @@ -223,9 +400,18 @@ void aig_prop_solvert::compute_phase( } -/// Compact encoding for single usage variable -/// \par parameters: Two vectors of unsigned of size aig.nodes.size() -/// \return These vectors filled in with per node usage information +/*******************************************************************\ + +Function: aig_prop_solvert::usage_count + + Inputs: Two vectors of unsigned of size aig.nodes.size() + + Outputs: These vectors filled in with per node usage information + + Purpose: Compact encoding for single usage variable + +\*******************************************************************/ + void aig_prop_solvert::usage_count( std::vector &p_usage_count, std::vector &n_usage_count) @@ -333,10 +519,18 @@ void aig_prop_solvert::usage_count( #endif } -/// Convert one AIG node, including special handling of a couple of cases -/// \par parameters: The node to convert, the phases required and the usage -/// counts. -/// \return The node converted to CNF in the solver object. +/*******************************************************************\ + +Function: aig_prop_solvert::convert_node + + Inputs: The node to convert, the phases required and the usage counts. + + Outputs: The node converted to CNF in the solver object. + + Purpose: Convert one AIG node, including special handling of a couple of cases + +\*******************************************************************/ + void aig_prop_solvert::convert_node( unsigned n, const aigt::nodet &node, @@ -548,6 +742,18 @@ void aig_prop_solvert::convert_node( } } +/*******************************************************************\ + +Function: aig_prop_solvert::convert_aig + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void aig_prop_solvert::convert_aig() { // 1. Do variables diff --git a/src/solvers/prop/bdd_expr.cpp b/src/solvers/prop/bdd_expr.cpp index 9a885c031b7..91e06dfb08a 100644 --- a/src/solvers/prop/bdd_expr.cpp +++ b/src/solvers/prop/bdd_expr.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk \*******************************************************************/ -/// \file -/// Conversion between exprt and miniBDD - #include #include @@ -16,6 +13,18 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk #include "bdd_expr.h" +/*******************************************************************\ + +Function: bdd_exprt::from_expr_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mini_bddt bdd_exprt::from_expr_rec(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -94,11 +103,35 @@ mini_bddt bdd_exprt::from_expr_rec(const exprt &expr) } } +/*******************************************************************\ + +Function: bdd_exprt::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bdd_exprt::from_expr(const exprt &expr) { root=from_expr_rec(expr); } +/*******************************************************************\ + +Function: bdd_exprt::as_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt bdd_exprt::as_expr(const mini_bddt &r) const { if(r.is_constant()) @@ -135,6 +168,18 @@ exprt bdd_exprt::as_expr(const mini_bddt &r) const return if_exprt(n_expr, as_expr(r.high()), as_expr(r.low())); } +/*******************************************************************\ + +Function: bdd_exprt::as_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt bdd_exprt::as_expr() const { if(!root.is_initialized()) diff --git a/src/solvers/prop/bdd_expr.h b/src/solvers/prop/bdd_expr.h index c462a17e669..3c35aa5dc21 100644 --- a/src/solvers/prop/bdd_expr.h +++ b/src/solvers/prop/bdd_expr.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, michael.tautschnig@qmul.ac.uk \*******************************************************************/ -/// \file -/// Conversion between exprt and miniBDD - #ifndef CPROVER_SOLVERS_PROP_BDD_EXPR_H #define CPROVER_SOLVERS_PROP_BDD_EXPR_H diff --git a/src/solvers/prop/cover_goals.cpp b/src/solvers/prop/cover_goals.cpp index 1783983ccf9..b4f2e614bf3 100644 --- a/src/solvers/prop/cover_goals.cpp +++ b/src/solvers/prop/cover_goals.cpp @@ -6,19 +6,39 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Cover a set of goals incrementally - #include #include "literal_expr.h" #include "cover_goals.h" +/*******************************************************************\ + +Function: cover_goalst::~cover_goalst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cover_goalst::~cover_goalst() { } -/// Mark goals that are covered +/*******************************************************************\ + +Function: cover_goalst::mark + + Inputs: + + Outputs: + + Purpose: Mark goals that are covered + +\*******************************************************************/ + void cover_goalst::mark() { // notify observers @@ -38,7 +58,18 @@ void cover_goalst::mark() } } -/// Build clause +/*******************************************************************\ + +Function: cover_goalst::constaint + + Inputs: + + Outputs: + + Purpose: Build clause + +\*******************************************************************/ + void cover_goalst::constraint() { exprt::operandst disjuncts; @@ -57,7 +88,18 @@ void cover_goalst::constraint() prop_conv.set_to_true(disjunction(disjuncts)); } -/// Build clause +/*******************************************************************\ + +Function: cover_goalst::freeze_goal_variables + + Inputs: + + Outputs: + + Purpose: Build clause + +\*******************************************************************/ + void cover_goalst::freeze_goal_variables() { for(std::list::const_iterator @@ -68,7 +110,18 @@ void cover_goalst::freeze_goal_variables() prop_conv.set_frozen(g_it->condition); } -/// Try to cover all goals +/*******************************************************************\ + +Function: cover_goalst::operator() + + Inputs: + + Outputs: + + Purpose: Try to cover all goals + +\*******************************************************************/ + decision_proceduret::resultt cover_goalst::operator()() { _iterations=_number_covered=0; diff --git a/src/solvers/prop/cover_goals.h b/src/solvers/prop/cover_goals.h index 8851e188347..afb93c9e534 100644 --- a/src/solvers/prop/cover_goals.h +++ b/src/solvers/prop/cover_goals.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Cover a set of goals incrementally - #ifndef CPROVER_SOLVERS_PROP_COVER_GOALS_H #define CPROVER_SOLVERS_PROP_COVER_GOALS_H @@ -16,8 +13,16 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" -/// Try to cover some given set of goals incrementally. This can be seen as a -/// heuristic variant of SAT-based set-cover. No minimality guarantee. +/*******************************************************************\ + + Class: cover_gooalst + + Purpose: Try to cover some given set of goals incrementally. + This can be seen as a heuristic variant of + SAT-based set-cover. No minimality guarantee. + +\*******************************************************************/ + class cover_goalst:public messaget { public: diff --git a/src/solvers/prop/literal.cpp b/src/solvers/prop/literal.cpp index e00f3bb37be..d57da3e91a3 100644 --- a/src/solvers/prop/literal.cpp +++ b/src/solvers/prop/literal.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Literals - #include #include "literal.h" +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator << (std::ostream &out, literalt l) { if(l.is_constant()) diff --git a/src/solvers/prop/minimize.cpp b/src/solvers/prop/minimize.cpp index 8ae18a1787c..bdbc6661159 100644 --- a/src/solvers/prop/minimize.cpp +++ b/src/solvers/prop/minimize.cpp @@ -6,15 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Minimize some target function incrementally - #include #include "literal_expr.h" #include "minimize.h" -/// Add an objective +/*******************************************************************\ + +Function: prop_minimizet::objective + + Inputs: + + Outputs: + + Purpose: Add an objective + +\*******************************************************************/ + void prop_minimizet::objective( const literalt condition, const weightt weight) @@ -31,7 +39,18 @@ void prop_minimizet::objective( } } -/// Fix objectives that are satisfied +/*******************************************************************\ + +Function: prop_minimizet::fix + + Inputs: + + Outputs: + + Purpose: Fix objectives that are satisfied + +\*******************************************************************/ + void prop_minimizet::fix_objectives() { std::vector &entry=current->second; @@ -56,7 +75,19 @@ void prop_minimizet::fix_objectives() assert(found); } -/// Build constraints that require us to improve on at least one goal, greedily. +/*******************************************************************\ + +Function: prop_minimizet::constaint + + Inputs: + + Outputs: + + Purpose: Build constraints that require us to improve on + at least one goal, greedily. + +\*******************************************************************/ + literalt prop_minimizet::constraint() { std::vector &entry=current->second; @@ -88,7 +119,18 @@ literalt prop_minimizet::constraint() } } -/// Try to cover all objectives +/*******************************************************************\ + +Function: prop_minimizet::operator() + + Inputs: + + Outputs: + + Purpose: Try to cover all objectives + +\*******************************************************************/ + void prop_minimizet::operator()() { // we need to use assumptions diff --git a/src/solvers/prop/minimize.h b/src/solvers/prop/minimize.h index 3818a76b114..f546f8442ee 100644 --- a/src/solvers/prop/minimize.h +++ b/src/solvers/prop/minimize.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// SAT Minimizer - #ifndef CPROVER_SOLVERS_PROP_MINIMIZE_H #define CPROVER_SOLVERS_PROP_MINIMIZE_H @@ -18,8 +15,15 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" -/// Computes a satisfying assignment of minimal cost according to a const -/// function using incremental SAT +/*******************************************************************\ + + Class: prop_minimizet + + Purpose: Computes a satisfying assignment of minimal cost + according to a const function using incremental SAT + +\*******************************************************************/ + class prop_minimizet:public messaget { public: diff --git a/src/solvers/prop/prop.cpp b/src/solvers/prop/prop.cpp index 223f1bfe6f2..cb17cc9ce11 100644 --- a/src/solvers/prop/prop.cpp +++ b/src/solvers/prop/prop.cpp @@ -10,32 +10,88 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop.h" -/// asserts a==b in the propositional formula +/*******************************************************************\ + +Function: propt::set_equal + + Inputs: + + Outputs: + + Purpose: asserts a==b in the propositional formula + +\*******************************************************************/ + void propt::set_equal(literalt a, literalt b) { lcnf(a, !b); lcnf(!a, b); } +/*******************************************************************\ + +Function: propt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void propt::set_assignment(literalt a, bool value) { assert(false); } +/*******************************************************************\ + +Function: propt::copy_assignment_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void propt::copy_assignment_from(const propt &src) { assert(false); } -/// \return true iff the given literal is part of the final conflict +/*******************************************************************\ + +Function: propt::is_in_conflict + + Inputs: + + Outputs: true iff the given literal is part of the final conflict + + Purpose: + +\*******************************************************************/ + bool propt::is_in_conflict(literalt l) const { assert(false); return false; } -/// generates a bitvector of given width with new variables -/// \return bitvector +/*******************************************************************\ + +Function: propt::new_variables + + Inputs: width + + Outputs: bitvector + + Purpose: generates a bitvector of given width with new variables + +\*******************************************************************/ + bvt propt::new_variables(std::size_t width) { bvt result; diff --git a/src/solvers/prop/prop_assignment.cpp b/src/solvers/prop/prop_assignment.cpp index 96e2ec18296..f191a4c6c55 100644 --- a/src/solvers/prop/prop_assignment.cpp +++ b/src/solvers/prop/prop_assignment.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_assignment.h" +/*******************************************************************\ + +Function: prop_assignmentt::~prop_assignmentt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + prop_assignmentt::~prop_assignmentt() { } diff --git a/src/solvers/prop/prop_conv.cpp b/src/solvers/prop/prop_conv.cpp index 2356700a6f1..eac517bf2b6 100644 --- a/src/solvers/prop/prop_conv.cpp +++ b/src/solvers/prop/prop_conv.cpp @@ -18,23 +18,70 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv.h" #include "literal_expr.h" -/// determine whether a variable is in the final conflict +/*******************************************************************\ + +Function: prop_convt::is_in_conflict + + Inputs: + + Outputs: + + Purpose: determine whether a variable is in the final conflict + +\*******************************************************************/ + bool prop_convt::is_in_conflict(literalt l) const { assert(false); return false; } +/*******************************************************************\ + +Function: prop_convt::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_convt::set_assumptions(const bvt &) { assert(false); } +/*******************************************************************\ + +Function: prop_convt::set_frozen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_convt::set_frozen(const literalt) { assert(false); } +/*******************************************************************\ + +Function: prop_convt::set_frozen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_convt::set_frozen(const bvt &bv) { for(unsigned i=0; i result= @@ -82,7 +153,18 @@ literalt prop_conv_solvert::get_literal(const irep_idt &identifier) return literal; } -/// get a boolean value from counter example if not valid +/*******************************************************************\ + +Function: prop_conv_solvert::get_bool + + Inputs: + + Outputs: + + Purpose: get a boolean value from counter example if not valid + +\*******************************************************************/ + bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const { // trivial cases @@ -171,6 +253,18 @@ bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const return false; } +/*******************************************************************\ + +Function: prop_conv_solvert::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt prop_conv_solvert::convert(const exprt &expr) { if(!use_cache || @@ -205,6 +299,18 @@ literalt prop_conv_solvert::convert(const exprt &expr) return literal; } +/*******************************************************************\ + +Function: prop_conv_solvert::convert_bool + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt prop_conv_solvert::convert_bool(const exprt &expr) { if(expr.type().id()!=ID_bool) @@ -333,6 +439,18 @@ literalt prop_conv_solvert::convert_bool(const exprt &expr) return convert_rest(expr); } +/*******************************************************************\ + +Function: prop_conv_solvert::convert_rest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt prop_conv_solvert::convert_rest(const exprt &expr) { // fall through @@ -340,6 +458,18 @@ literalt prop_conv_solvert::convert_rest(const exprt &expr) return prop.new_variable(); } +/*******************************************************************\ + +Function: prop_conv_solvert::set_equality_to_true + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool prop_conv_solvert::set_equality_to_true(const equal_exprt &expr) { if(!equality_propagation) @@ -367,6 +497,18 @@ bool prop_conv_solvert::set_equality_to_true(const equal_exprt &expr) return true; } +/*******************************************************************\ + +Function: prop_conv_solvert::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_solvert::set_to(const exprt &expr, bool value) { if(expr.type().id()!=ID_bool) @@ -466,6 +608,18 @@ void prop_conv_solvert::set_to(const exprt &expr, bool value) prop.l_set_to(convert(expr), value); } +/*******************************************************************\ + +Function: prop_conv_solvert::ignoring + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_solvert::ignoring(const exprt &expr) { // fall through @@ -475,10 +629,34 @@ void prop_conv_solvert::ignoring(const exprt &expr) print(2, msg); } +/*******************************************************************\ + +Function: prop_conv_solvert::post_process + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_solvert::post_process() { } +/*******************************************************************\ + +Function: prop_conv_solvert::solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt prop_conv_solvert::dec_solve() { // post-processing isn't incremental yet @@ -503,6 +681,18 @@ decision_proceduret::resultt prop_conv_solvert::dec_solve() return resultt::D_ERROR; } +/*******************************************************************\ + +Function: prop_conv_solvert::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt prop_conv_solvert::get(const exprt &expr) const { tvt value; @@ -529,6 +719,18 @@ exprt prop_conv_solvert::get(const exprt &expr) const return tmp; } +/*******************************************************************\ + +Function: prop_conv_solvert::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_solvert::print_assignment(std::ostream &out) const { for(symbolst::const_iterator it=symbols.begin(); diff --git a/src/solvers/prop/prop_conv_store.cpp b/src/solvers/prop/prop_conv_store.cpp index d4428482367..9fb2c09a414 100644 --- a/src/solvers/prop/prop_conv_store.cpp +++ b/src/solvers/prop/prop_conv_store.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "prop_conv_store.h" +/*******************************************************************\ + +Function: prop_conv_storet::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_storet::set_to(const exprt &expr, bool value) { constraintt &constraint=constraints.add_constraint(); @@ -18,6 +30,18 @@ void prop_conv_storet::set_to(const exprt &expr, bool value) constraint.value=value; } +/*******************************************************************\ + +Function: prop_conv_storet::convert_rest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt prop_conv_storet::convert(const exprt &expr) { constraintt &constraint=constraints.add_constraint(); @@ -29,6 +53,18 @@ literalt prop_conv_storet::convert(const exprt &expr) return constraint.literal; } +/*******************************************************************\ + +Function: prop_conv_storet::constraintst::replay + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_storet::constraintst::replay(prop_convt &dest) const { for(constraint_listt::const_iterator @@ -38,6 +74,18 @@ void prop_conv_storet::constraintst::replay(prop_convt &dest) const it->replay(dest); } +/*******************************************************************\ + +Function: prop_conv_storet::constraintst::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_storet::constraintst::print(std::ostream &out) const { for(constraint_listt::const_iterator @@ -47,6 +95,18 @@ void prop_conv_storet::constraintst::print(std::ostream &out) const it->print(out); } +/*******************************************************************\ + +Function: prop_conv_storet::constraintt::replay + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_storet::constraintt::replay(prop_convt &dest) const { switch(type) @@ -64,6 +124,18 @@ void prop_conv_storet::constraintt::replay(prop_convt &dest) const } } +/*******************************************************************\ + +Function: prop_conv_storet::constraintt::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void prop_conv_storet::constraintt::print(std::ostream &out) const { switch(type) diff --git a/src/solvers/qbf/qbf_bdd_core.cpp b/src/solvers/qbf/qbf_bdd_core.cpp index 202e7026658..9fa58639ad0 100644 --- a/src/solvers/qbf/qbf_bdd_core.cpp +++ b/src/solvers/qbf/qbf_bdd_core.cpp @@ -21,6 +21,18 @@ Author: CM Wintersteiger /*! \cond */ // FIX FOR THE CUDD LIBRARY +/*******************************************************************\ + +Function: DD::getNode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline DdNode *DD::getNode() const { return node; @@ -30,11 +42,35 @@ inline DdNode *DD::getNode() const #include "qbf_bdd_core.h" +/*******************************************************************\ + +Function: qbf_bdd_certificatet::qbf_bdd_certificatet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_bdd_certificatet::qbf_bdd_certificatet(void) : qdimacs_coret() { bdd_manager=new Cudd(0, 0); } +/*******************************************************************\ + +Function: qbf_bdd_certificatet::~qbf_bdd_certificatet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_bdd_certificatet::~qbf_bdd_certificatet(void) { for(const BDD* model : model_bdds) @@ -48,6 +84,18 @@ qbf_bdd_certificatet::~qbf_bdd_certificatet(void) bdd_manager=NULL; } +/*******************************************************************\ + +Function: qbf_bdd_certificatet::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt qbf_bdd_certificatet::new_variable(void) { literalt l=qdimacs_coret::new_variable(); @@ -58,12 +106,36 @@ literalt qbf_bdd_certificatet::new_variable(void) return l; } +/*******************************************************************\ + +Function: qbf_bdd_coret::qbf_bdd_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_bdd_coret::qbf_bdd_coret() : qbf_bdd_certificatet() { matrix=new BDD(); *matrix=bdd_manager->bddOne(); } +/*******************************************************************\ + +Function: qbf_bdd_coret::~qbf_bdd_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_bdd_coret::~qbf_bdd_coret() { for(const BDD* variable : bdd_variable_map) @@ -80,17 +152,53 @@ qbf_bdd_coret::~qbf_bdd_coret() } } +/*******************************************************************\ + +Function: qbf_bdd_coret::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_bdd_coret::l_get(literalt a) const { assert(false); return tvt(false); } +/*******************************************************************\ + +Function: qbf_bdd_coret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_bdd_coret::solver_text() { return "QBF/BDD/CORE"; } +/*******************************************************************\ + +Function: qbf_bdd_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_bdd_coret::prop_solve() { { @@ -151,16 +259,52 @@ propt::resultt qbf_bdd_coret::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: qbf_bdd_coret::is_in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qbf_bdd_coret::is_in_core(literalt l) const { throw "nyi"; } +/*******************************************************************\ + +Function: qbf_bdd_coret::m_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qdimacs_coret::modeltypet qbf_bdd_coret::m_get(literalt a) const { throw "nyi"; } +/*******************************************************************\ + +Function: qbf_bdd_coret::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt qbf_bdd_coret::new_variable() { literalt res=qbf_bdd_certificatet::new_variable(); @@ -173,6 +317,18 @@ literalt qbf_bdd_coret::new_variable() return res; } +/*******************************************************************\ + +Function: qbf_bdd_coret::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_bdd_coret::lcnf(const bvt &bv) { bvt new_bv; @@ -195,6 +351,18 @@ void qbf_bdd_coret::lcnf(const bvt &bv) *matrix&=clause; } +/*******************************************************************\ + +Function: qbf_bdd_coret::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt qbf_bdd_coret::lor(literalt a, literalt b) { literalt nl=new_variable(); @@ -212,6 +380,18 @@ literalt qbf_bdd_coret::lor(literalt a, literalt b) return nl; } +/*******************************************************************\ + +Function: qbf_bdd_coret::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt qbf_bdd_coret::lor(const bvt &bv) { for(const literalt &literal : bv) @@ -239,6 +419,18 @@ literalt qbf_bdd_coret::lor(const bvt &bv) return nl; } +/*******************************************************************\ + +Function: qbf_bdd_coret::compress_certificate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_bdd_coret::compress_certificate(void) { status() << "Compressing Certificate" << eom; @@ -267,6 +459,18 @@ void qbf_bdd_coret::compress_certificate(void) } } +/*******************************************************************\ + +Function: qbf_bdd_certificatet::f_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt qbf_bdd_certificatet::f_get(literalt l) { quantifiert q; @@ -388,6 +592,18 @@ const exprt qbf_bdd_certificatet::f_get(literalt l) } } +/*******************************************************************\ + +Function: qbf_bdd_certificatet::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_bdd_certificatet::l_get(literalt a) const { const BDD &model=*model_bdds[a.var_no()]; diff --git a/src/solvers/qbf/qbf_quantor.cpp b/src/solvers/qbf/qbf_quantor.cpp index e5385c05ea5..a1ed0fa70e5 100644 --- a/src/solvers/qbf/qbf_quantor.cpp +++ b/src/solvers/qbf/qbf_quantor.cpp @@ -12,25 +12,85 @@ Author: Daniel Kroening, kroening@kroening.com #include "qbf_quantor.h" +/*******************************************************************\ + +Function: qbf_quantort::qbf_quantort + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_quantort::qbf_quantort() { } +/*******************************************************************\ + +Function: qbf_quantort::~qbf_quantort + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_quantort::~qbf_quantort() { } +/*******************************************************************\ + +Function: qbf_quantort::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_quantort::l_get(literalt a) const { assert(false); return tvt::unknown(); } +/*******************************************************************\ + +Function: qbf_quantort::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_quantort::solver_text() { return "Quantor"; } +/*******************************************************************\ + +Function: qbf_quantort::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_quantort::prop_solve() { { diff --git a/src/solvers/qbf/qbf_qube.cpp b/src/solvers/qbf/qbf_qube.cpp index 1c0c421cb8f..a52c99bac33 100644 --- a/src/solvers/qbf/qbf_qube.cpp +++ b/src/solvers/qbf/qbf_qube.cpp @@ -12,27 +12,87 @@ Author: CM Wintersteiger #include "qbf_qube.h" +/*******************************************************************\ + +Function: qbf_qubet::qbf_qubet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_qubet::qbf_qubet() { // skizzo crashes on broken lines break_lines=false; } +/*******************************************************************\ + +Function: qbf_qubet::~qbf_qubet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_qubet::~qbf_qubet() { } +/*******************************************************************\ + +Function: qbf_qubet::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_qubet::l_get(literalt a) const { assert(false); return tvt(false); } +/*******************************************************************\ + +Function: qbf_qubet::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_qubet::solver_text() { return "QuBE"; } +/*******************************************************************\ + +Function: qbf_qubet::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_qubet::prop_solve() { // sKizzo crashes on empty instances diff --git a/src/solvers/qbf/qbf_qube_core.cpp b/src/solvers/qbf/qbf_qube_core.cpp index c90424538c9..f5ea1d76610 100644 --- a/src/solvers/qbf/qbf_qube_core.cpp +++ b/src/solvers/qbf/qbf_qube_core.cpp @@ -14,21 +14,69 @@ Author: CM Wintersteiger #include "qbf_qube_core.h" +/*******************************************************************\ + +Function: qbf_qube_coret::qbf_qube_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_qube_coret::qbf_qube_coret() : qdimacs_coret() { break_lines=false; qbf_tmp_file="qube.qdimacs"; } +/*******************************************************************\ + +Function: qbf_qube_coret::~qbf_qube_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_qube_coret::~qbf_qube_coret() { } +/*******************************************************************\ + +Function: qbf_qube_coret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_qube_coret::solver_text() { return "QuBE w/ toplevel assignments"; } +/*******************************************************************\ + +Function: qbf_qube_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_qube_coret::prop_solve() { if(no_clauses()==0) @@ -117,11 +165,35 @@ propt::resultt qbf_qube_coret::prop_solve() } } +/*******************************************************************\ + +Function: qbf_qube_coret::is_in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qbf_qube_coret::is_in_core(literalt l) const { throw "not supported"; } +/*******************************************************************\ + +Function: qbf_qube_coret::m_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qdimacs_coret::modeltypet qbf_qube_coret::m_get(literalt a) const { throw "not supported"; diff --git a/src/solvers/qbf/qbf_skizzo.cpp b/src/solvers/qbf/qbf_skizzo.cpp index e89aa7ebcb3..1b665567323 100644 --- a/src/solvers/qbf/qbf_skizzo.cpp +++ b/src/solvers/qbf/qbf_skizzo.cpp @@ -12,27 +12,87 @@ Author: Daniel Kroening, kroening@kroening.com #include "qbf_skizzo.h" +/*******************************************************************\ + +Function: qbf_skizzot::qbf_skizzot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_skizzot::qbf_skizzot() { // skizzo crashes on broken lines break_lines=false; } +/*******************************************************************\ + +Function: qbf_skizzot::~qbf_skizzot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_skizzot::~qbf_skizzot() { } +/*******************************************************************\ + +Function: qbf_skizzot::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_skizzot::l_get(literalt a) const { assert(false); return tvt(false); } +/*******************************************************************\ + +Function: qbf_skizzot::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_skizzot::solver_text() { return "Skizzo"; } +/*******************************************************************\ + +Function: qbf_skizzot::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_skizzot::prop_solve() { // sKizzo crashes on empty instances diff --git a/src/solvers/qbf/qbf_skizzo_core.cpp b/src/solvers/qbf/qbf_skizzo_core.cpp index 39bd481833b..0b79ca216a6 100644 --- a/src/solvers/qbf/qbf_skizzo_core.cpp +++ b/src/solvers/qbf/qbf_skizzo_core.cpp @@ -16,6 +16,18 @@ Author: CM Wintersteiger /*! \cond */ // FIX FOR THE CUDD LIBRARY +/*******************************************************************\ + +Function: DD::getNode + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline DdNode *DD::getNode() const { return node; @@ -26,6 +38,18 @@ inline DdNode *DD::getNode() const #include "qbf_skizzo_core.h" +/*******************************************************************\ + +Function: qbf_skizzo_coret::qbf_skizzo_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_skizzo_coret::qbf_skizzo_coret(): qbf_bdd_certificatet() { @@ -34,15 +58,51 @@ qbf_skizzo_coret::qbf_skizzo_coret(): qbf_tmp_file="sKizzo.qdimacs"; } +/*******************************************************************\ + +Function: qbf_skizzo_coret::~qbf_skizzo_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_skizzo_coret::~qbf_skizzo_coret() { } +/*******************************************************************\ + +Function: qbf_skizzo_coret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_skizzo_coret::solver_text() { return "Skizzo/Core"; } +/*******************************************************************\ + +Function: qbf_skizzo_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_skizzo_coret::prop_solve() { // sKizzo crashes on empty instances @@ -129,16 +189,52 @@ propt::resultt qbf_skizzo_coret::prop_solve() } } +/*******************************************************************\ + +Function: qbf_skizzo_coret::is_in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qbf_skizzo_coret::is_in_core(literalt l) const { throw "nyi"; } +/*******************************************************************\ + +Function: qbf_skizzo_coret::m_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qdimacs_coret::modeltypet qbf_skizzo_coret::m_get(literalt a) const { throw "nyi"; } +/*******************************************************************\ + +Function: qbf_skizzo_coret::get_certificate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qbf_skizzo_coret::get_certificate(void) { std::string result_tmp_file="ozziKs.out"; diff --git a/src/solvers/qbf/qbf_squolem.cpp b/src/solvers/qbf/qbf_squolem.cpp index 6724a3f189e..a869603a737 100644 --- a/src/solvers/qbf/qbf_squolem.cpp +++ b/src/solvers/qbf/qbf_squolem.cpp @@ -7,31 +7,88 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Squolem Backend - #include "qbf_squolem.h" +/*******************************************************************\ + +Function: qbf_squolemt::qbf_squolemt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_squolemt::qbf_squolemt(): early_decision(false) { } +/*******************************************************************\ + +Function: qbf_squolemt::~qbf_squolemt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_squolemt::~qbf_squolemt() { squolem.reset(); } +/*******************************************************************\ + +Function: qbf_squolemt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_squolemt::l_get(literalt a) const { assert(false); } +/*******************************************************************\ + +Function: qbf_squolemt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_squolemt::solver_text() { return "Squolem"; } +/*******************************************************************\ + +Function: qbf_squolemt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_squolemt::prop_solve() { { @@ -69,6 +126,18 @@ propt::resultt qbf_squolemt::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: qbf_squolemt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolemt::lcnf(const bvt &bv) { if(early_decision) @@ -98,6 +167,18 @@ void qbf_squolemt::lcnf(const bvt &bv) early_decision=true; } +/*******************************************************************\ + +Function: qbf_squolemt::add_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolemt::add_quantifier(const quantifiert &quantifier) { squolem.quantifyVariableInner( @@ -107,12 +188,36 @@ void qbf_squolemt::add_quantifier(const quantifiert &quantifier) qdimacs_cnft::add_quantifier(quantifier); // necessary? } +/*******************************************************************\ + +Function: qbf_squolemt::set_no_variables + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolemt::set_no_variables(unsigned no) { squolem.setLastVariable(no+1); cnft::set_no_variables(no); } +/*******************************************************************\ + +Function: qbf_squolemt::set_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolemt::set_quantifier( const quantifiert::typet type, const literalt l) diff --git a/src/solvers/qbf/qbf_squolem.h b/src/solvers/qbf/qbf_squolem.h index 7210436fd4c..1780528fb32 100644 --- a/src/solvers/qbf/qbf_squolem.h +++ b/src/solvers/qbf/qbf_squolem.h @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Squolem Backend - #ifndef CPROVER_SOLVERS_QBF_QBF_SQUOLEM_H #define CPROVER_SOLVERS_QBF_QBF_SQUOLEM_H diff --git a/src/solvers/qbf/qbf_squolem_core.cpp b/src/solvers/qbf/qbf_squolem_core.cpp index 79d5476e421..00229cd8fee 100644 --- a/src/solvers/qbf/qbf_squolem_core.cpp +++ b/src/solvers/qbf/qbf_squolem_core.cpp @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Squolem Backend (with proofs) - #include #include @@ -18,11 +15,35 @@ Author: CM Wintersteiger #include "qbf_squolem_core.h" +/*******************************************************************\ + +Function: qbf_squolem_coret::qbf_squolem_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_squolem_coret::qbf_squolem_coret() : squolem(NULL) { setup(); } +/*******************************************************************\ + +Function: qbf_squolem_coret::setup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::setup(void) { quantifiers.clear(); @@ -44,6 +65,18 @@ void qbf_squolem_coret::setup(void) // squolem->options.set_predictOnLiteralBound(true); } +/*******************************************************************\ + +Function: qbf_squolem_coret::reset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::reset(void) { squolem->reset(); @@ -52,6 +85,18 @@ void qbf_squolem_coret::reset(void) setup(); } +/*******************************************************************\ + +Function: qbf_squolem_coret::~qbf_squolem_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_squolem_coret::~qbf_squolem_coret() { squolem->reset(); @@ -59,6 +104,18 @@ qbf_squolem_coret::~qbf_squolem_coret() squolem=NULL; } +/*******************************************************************\ + +Function: qbf_squolem_coret::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt qbf_squolem_coret::l_get(literalt a) const { if(a.is_true()) @@ -74,11 +131,35 @@ tvt qbf_squolem_coret::l_get(literalt a) const return tvt(tvt::tv_enumt::TV_UNKNOWN); } +/*******************************************************************\ + +Function: qbf_squolem_coret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string qbf_squolem_coret::solver_text() { return "Squolem (Certifying)"; } +/*******************************************************************\ + +Function: qbf_squolem_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt qbf_squolem_coret::prop_solve() { { @@ -106,11 +187,35 @@ propt::resultt qbf_squolem_coret::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: qbf_squolem_coret::is_in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qbf_squolem_coret::is_in_core(literalt l) const { return squolem->inCore(l.var_no()); } +/*******************************************************************\ + +Function: qbf_squolem_coret::m_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + qbf_squolem_coret::modeltypet qbf_squolem_coret::m_get(literalt a) const { if(squolem->modelIsTrue(a.var_no())) @@ -123,6 +228,18 @@ qbf_squolem_coret::modeltypet qbf_squolem_coret::m_get(literalt a) const return M_DONTCARE; } +/*******************************************************************\ + +Function: qbf_squolem_coret::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::lcnf(const bvt &bv) { if(early_decision) @@ -152,6 +269,18 @@ void qbf_squolem_coret::lcnf(const bvt &bv) early_decision=true; } +/*******************************************************************\ + +Function: qbf_squolem_coret::add_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::add_quantifier(const quantifiert &quantifier) { squolem->quantifyVariableInner( @@ -161,12 +290,36 @@ void qbf_squolem_coret::add_quantifier(const quantifiert &quantifier) qdimacs_cnft::add_quantifier(quantifier); // necessary? } +/*******************************************************************\ + +Function: qbf_squolem_coret::set_no_variables + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::set_no_variables(unsigned no) { squolem->setLastVariable(no+1); cnft::set_no_variables(no); } +/*******************************************************************\ + +Function: qbf_squolem_coret::set_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::set_quantifier( const quantifiert::typet type, const literalt l) @@ -175,16 +328,52 @@ void qbf_squolem_coret::set_quantifier( squolem->requantifyVariable(l.var_no(), type==quantifiert::UNIVERSAL); } +/*******************************************************************\ + +Function: qbf_squolem_coret::set_debug_filename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::set_debug_filename(const std::string &str) { squolem->options.set_debugFilename(str.c_str()); } +/*******************************************************************\ + +Function: qbf_squolem_coret::write_qdimacs_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qbf_squolem_coret::write_qdimacs_cnf(std::ostream &out) { squolem->saveQCNF(out); } +/*******************************************************************\ + +Function: qbf_squolem_coret::f_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt qbf_squolem_coret::f_get(literalt l) { if(squolem->isUniversal(l.var_no())) @@ -246,6 +435,18 @@ const exprt qbf_squolem_coret::f_get(literalt l) } } +/*******************************************************************\ + +Function: qbf_squolem_coret::f_get_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp) { Clause *p=wsp->negWits; @@ -288,6 +489,18 @@ const exprt qbf_squolem_coret::f_get_cnf(WitnessStack *wsp) return and_exprt(operands); } +/*******************************************************************\ + +Function: qbf_squolem_coret::f_get_dnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const exprt qbf_squolem_coret::f_get_dnf(WitnessStack *wsp) { Clause *p=wsp->posWits; diff --git a/src/solvers/qbf/qbf_squolem_core.h b/src/solvers/qbf/qbf_squolem_core.h index f00e00a79ac..3c6e96252b4 100644 --- a/src/solvers/qbf/qbf_squolem_core.h +++ b/src/solvers/qbf/qbf_squolem_core.h @@ -6,9 +6,6 @@ Author: CM Wintersteiger \*******************************************************************/ -/// \file -/// Squolem Backend (with Proofs) - #ifndef CPROVER_SOLVERS_QBF_QBF_SQUOLEM_CORE_H #define CPROVER_SOLVERS_QBF_QBF_SQUOLEM_CORE_H diff --git a/src/solvers/qbf/qdimacs_cnf.cpp b/src/solvers/qbf/qdimacs_cnf.cpp index cd5e43c59de..41e5484c369 100644 --- a/src/solvers/qbf/qdimacs_cnf.cpp +++ b/src/solvers/qbf/qdimacs_cnf.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "qdimacs_cnf.h" +/*******************************************************************\ + +Function: qdimacs_cnft::write_qdimacs_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qdimacs_cnft::write_qdimacs_cnf(std::ostream &out) { write_problem_line(out); @@ -18,6 +30,18 @@ void qdimacs_cnft::write_qdimacs_cnf(std::ostream &out) write_clauses(out); } +/*******************************************************************\ + +Function: qdimacs_cnft::write_prefix + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qdimacs_cnft::write_prefix(std::ostream &out) const { std::vector quantified; @@ -61,11 +85,35 @@ void qdimacs_cnft::write_prefix(std::ostream &out) const out << "e " << i << " 0" << std::endl; } +/*******************************************************************\ + +Function: qdimacs_cnft::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qdimacs_cnft::operator==(const qdimacs_cnft &other) const { return quantifiers==other.quantifiers && clauses==other.clauses; } +/*******************************************************************\ + +Function: qdimacs_cnft::set_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qdimacs_cnft::set_quantifier( const quantifiert::typet type, const literalt l) @@ -83,6 +131,18 @@ void qdimacs_cnft::set_quantifier( add_quantifier(type, l); } +/*******************************************************************\ + +Function: qdimacs_cnft::copy_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qdimacs_cnft::copy_to(qdimacs_cnft &cnf) const { cnf.set_no_variables(_no_variables); @@ -100,6 +160,18 @@ void qdimacs_cnft::copy_to(qdimacs_cnft &cnf) const cnf.lcnf(*it); } +/*******************************************************************\ + +Function: qdimacs_cnft::hash + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + size_t qdimacs_cnft::hash() const { size_t result=0; @@ -112,6 +184,18 @@ size_t qdimacs_cnft::hash() const return result^cnf_clause_listt::hash(); } +/*******************************************************************\ + +Function: qdimacs_cnft::is_quantified + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qdimacs_cnft::is_quantified(const literalt l) const { for(quantifierst::const_iterator it=quantifiers.begin(); @@ -123,6 +207,18 @@ bool qdimacs_cnft::is_quantified(const literalt l) const return false; } +/*******************************************************************\ + +Function: qdimacs_cnft::find_quantifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool qdimacs_cnft::find_quantifier(const literalt l, quantifiert &q) const { for(quantifierst::const_iterator it=quantifiers.begin(); diff --git a/src/solvers/qbf/qdimacs_core.cpp b/src/solvers/qbf/qdimacs_core.cpp index a3e445dbc6d..3ffb8ec6db2 100644 --- a/src/solvers/qbf/qdimacs_core.cpp +++ b/src/solvers/qbf/qdimacs_core.cpp @@ -11,6 +11,18 @@ Author: CM Wintersteiger #include "qdimacs_core.h" +/*******************************************************************\ + +Function: qdimacs_coret::simplify_extractbits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void qdimacs_coret::simplify_extractbits(exprt &expr) const { if(expr.id()==ID_and) diff --git a/src/solvers/refinement/bv_refinement.h b/src/solvers/refinement/bv_refinement.h index cbfef19d3a8..cc96bfccf45 100644 --- a/src/solvers/refinement/bv_refinement.h +++ b/src/solvers/refinement/bv_refinement.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Abstraction Refinement Loop - #ifndef CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H #define CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H diff --git a/src/solvers/refinement/bv_refinement_loop.cpp b/src/solvers/refinement/bv_refinement_loop.cpp index 844752a2137..3d39c16ac80 100644 --- a/src/solvers/refinement/bv_refinement_loop.cpp +++ b/src/solvers/refinement/bv_refinement_loop.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "bv_refinement.h" +/*******************************************************************\ + +Function: bv_refinementt::bv_refinementt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_refinementt::bv_refinementt( const namespacet &_ns, propt &_prop): bv_pointerst(_ns, _prop), @@ -25,10 +37,34 @@ bv_refinementt::bv_refinementt( assert(prop.has_is_in_conflict()); } +/*******************************************************************\ + +Function: bv_refinementt::~bv_refinementt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_refinementt::~bv_refinementt() { } +/*******************************************************************\ + +Function: bv_refinementt::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt bv_refinementt::dec_solve() { // do the usual post-processing @@ -89,6 +125,18 @@ decision_proceduret::resultt bv_refinementt::dec_solve() } } +/*******************************************************************\ + +Function: bv_refinementt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt bv_refinementt::prop_solve() { // this puts the underapproximations into effect @@ -119,6 +167,18 @@ decision_proceduret::resultt bv_refinementt::prop_solve() } } +/*******************************************************************\ + +Function: bv_refinementt::check_SAT + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::check_SAT() { progress=false; @@ -132,6 +192,18 @@ void bv_refinementt::check_SAT() check_SAT(*a_it); } +/*******************************************************************\ + +Function: bv_refinementt::check_UNSAT + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::check_UNSAT() { progress=false; @@ -143,6 +215,18 @@ void bv_refinementt::check_UNSAT() check_UNSAT(*a_it); } +/*******************************************************************\ + +Function: bv_refinementt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::set_to(const exprt &expr, bool value) { #if 0 @@ -161,6 +245,18 @@ void bv_refinementt::set_to(const exprt &expr, bool value) #endif } +/*******************************************************************\ + +Function: bv_refinementt::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::set_assumptions(const bvt &_assumptions) { parent_assumptions=_assumptions; diff --git a/src/solvers/refinement/refine_arithmetic.cpp b/src/solvers/refinement/refine_arithmetic.cpp index 6bbd1439cba..1f08874abfa 100644 --- a/src/solvers/refinement/refine_arithmetic.cpp +++ b/src/solvers/refinement/refine_arithmetic.cpp @@ -21,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com #define MAX_INTEGER_UNDERAPPROX 3 #define MAX_FLOAT_UNDERAPPROX 10 +/*******************************************************************\ + +Function: bv_refinementt::approximationt::add_over_assumption + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::approximationt::add_over_assumption(literalt l) { // if it's a constant already, give up @@ -28,6 +40,18 @@ void bv_refinementt::approximationt::add_over_assumption(literalt l) over_assumptions.push_back(l); } +/*******************************************************************\ + +Function: bv_refinementt::approximationt::add_under_assumption + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::approximationt::add_under_assumption(literalt l) { // if it's a constant already, give up @@ -35,6 +59,18 @@ void bv_refinementt::approximationt::add_under_assumption(literalt l) under_assumptions.push_back(l); } +/*******************************************************************\ + +Function: bv_refinementt::convert_floatbv_op + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_refinementt::convert_floatbv_op(const exprt &expr) { if(!do_arithmetic_refinement) @@ -49,6 +85,18 @@ bvt bv_refinementt::convert_floatbv_op(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: bv_refinementt::convert_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_refinementt::convert_mult(const exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -97,6 +145,18 @@ bvt bv_refinementt::convert_mult(const exprt &expr) return bv; } +/*******************************************************************\ + +Function: bv_refinementt::convert_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_refinementt::convert_div(const div_exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -115,6 +175,18 @@ bvt bv_refinementt::convert_div(const div_exprt &expr) return bv; } +/*******************************************************************\ + +Function: bv_refinementt::convert_mod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bvt bv_refinementt::convert_mod(const mod_exprt &expr) { if(!do_arithmetic_refinement || expr.type().id()==ID_fixedbv) @@ -133,6 +205,18 @@ bvt bv_refinementt::convert_mod(const mod_exprt &expr) return bv; } +/*******************************************************************\ + +Function: bv_refinementt::get_values + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_refinementt::get_values(approximationt &a) { std::size_t o=a.expr.operands().size(); @@ -156,8 +240,19 @@ void bv_refinementt::get_values(approximationt &a) a.result_value=get_value(a.result_bv); } -/// inspect if satisfying assignment extends to original formula, otherwise -/// refine overapproximation +/*******************************************************************\ + +Function: bv_refinementt::check_SAT + + Inputs: + + Outputs: + + Purpose: inspect if satisfying assignment extends to original + formula, otherwise refine overapproximation + +\*******************************************************************/ + void bv_refinementt::check_SAT(approximationt &a) { // get values @@ -363,8 +458,19 @@ void bv_refinementt::check_SAT(approximationt &a) a.over_state++; } -/// inspect if proof holds on original formula, otherwise refine -/// underapproximation +/*******************************************************************\ + +Function: bv_refinementt::check_UNSAT + + Inputs: + + Outputs: + + Purpose: inspect if proof holds on original formula, + otherwise refine underapproximation + +\*******************************************************************/ + void bv_refinementt::check_UNSAT(approximationt &a) { // part of the conflict? @@ -452,7 +558,18 @@ void bv_refinementt::check_UNSAT(approximationt &a) progress=true; } -/// check if an under-approximation is part of the conflict +/*******************************************************************\ + +Function: bv_refinementt::is_in_conflict + + Inputs: + + Outputs: + + Purpose: check if an under-approximation is part of the conflict + +\*******************************************************************/ + bool bv_refinementt::is_in_conflict(approximationt &a) { for(std::size_t i=0; i -/// generate array constraints +/*******************************************************************\ + +Function: bv_refinementt::post_process_arrays + + Inputs: + + Outputs: + + Purpose: generate array constraints + +\*******************************************************************/ + void bv_refinementt::post_process_arrays() { collect_indices(); @@ -32,7 +43,18 @@ void bv_refinementt::post_process_arrays() freeze_lazy_constraints(); } -/// check whether counterexample is spurious +/*******************************************************************\ + +Function: bv_refinementt::arrays_overapproximated + + Inputs: + + Outputs: + + Purpose: check whether counterexample is spurious + +\*******************************************************************/ + void bv_refinementt::arrays_overapproximated() { if(!do_array_refinement) @@ -103,7 +125,18 @@ void bv_refinementt::arrays_overapproximated() } -/// freeze symbols for incremental solving +/*******************************************************************\ + +Function: bv_refinementt::freeze_lazy_constraints + + Inputs: + + Outputs: + + Purpose: freeze symbols for incremental solving + +\*******************************************************************/ + void bv_refinementt::freeze_lazy_constraints() { if(!lazy_arrays) diff --git a/src/solvers/refinement/string_constraint.h b/src/solvers/refinement/string_constraint.h index c83d63cc69a..1bb460349b7 100644 --- a/src/solvers/refinement/string_constraint.h +++ b/src/solvers/refinement/string_constraint.h @@ -10,13 +10,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Defines string constraints. These are formulas talking about strings. We -/// implemented two forms of constraints: `string_constraintt` are formulas -/// of the form $\forall univ_var \in [lb,ub[. prem => body$, and -/// not_contains_constraintt of the form: $\forall x in [lb,ub[. p(x) => -/// \exists y in [lb,ub[. s1[x+y] != s2[y]$. - #ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_H #define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_H diff --git a/src/solvers/refinement/string_constraint_generator.h b/src/solvers/refinement/string_constraint_generator.h index 533e41a4212..94234b810de 100644 --- a/src/solvers/refinement/string_constraint_generator.h +++ b/src/solvers/refinement/string_constraint_generator.h @@ -10,13 +10,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints to link results from string functions with -/// their arguments. This is inspired by the PASS paper at HVC'13: "PASS: -/// String Solving with Parameterized Array and Interval Automaton" by Guodong -/// Li and Indradeep Ghosh, which gives examples of constraints for several -/// functions. - #ifndef CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H #define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H diff --git a/src/solvers/refinement/string_constraint_generator_code_points.cpp b/src/solvers/refinement/string_constraint_generator_code_points.cpp index ad44469d51e..16763dfc97c 100644 --- a/src/solvers/refinement/string_constraint_generator_code_points.cpp +++ b/src/solvers/refinement/string_constraint_generator_code_points.cpp @@ -7,9 +7,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for Java functions dealing with code points - #include /******************************************************************* \ @@ -73,12 +70,21 @@ string_exprt string_constraint_generatort::add_axioms_for_code_point( return res; } -/// the output is true when the character is a high surrogate for UTF-16 -/// encoding, see https://en.wikipedia.org/wiki/UTF-16 for more explenation -/// about the encoding; this is true when the character is in the range -/// 0xD800..0xDBFF -/// \par parameters: a character expression -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::is_high_surrogate + + Inputs: a character expression + + Outputs: a Boolean expression + + Purpose: the output is true when the character is a high surrogate for + UTF-16 encoding, see https://en.wikipedia.org/wiki/UTF-16 for + more explenation about the encoding; + this is true when the character is in the range 0xD800..0xDBFF + +\*******************************************************************/ + exprt string_constraint_generatort::is_high_surrogate(const exprt &chr) const { return and_exprt( @@ -86,12 +92,21 @@ exprt string_constraint_generatort::is_high_surrogate(const exprt &chr) const binary_relation_exprt(chr, ID_le, constant_char(0xDBFF, chr.type()))); } -/// the output is true when the character is a low surrogate for UTF-16 -/// encoding, see https://en.wikipedia.org/wiki/UTF-16 for more explenation -/// about the encoding; this is true when the character is in the range -/// 0xDC00..0xDFFF -/// \par parameters: a character expression -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::is_low_surrogate + + Inputs: a character expression + + Outputs: a Boolean expression + + Purpose: the output is true when the character is a low surrogate for + UTF-16 encoding, see https://en.wikipedia.org/wiki/UTF-16 for + more explenation about the encoding; + this is true when the character is in the range 0xDC00..0xDFFF + +\*******************************************************************/ + exprt string_constraint_generatort::is_low_surrogate(const exprt &chr) const { return and_exprt( @@ -99,14 +114,24 @@ exprt string_constraint_generatort::is_low_surrogate(const exprt &chr) const binary_relation_exprt(chr, ID_le, constant_char(0xDFFF, chr.type()))); } -/// the output corresponds to the unicode character given by the pair of -/// characters of inputs assuming it has been encoded in UTF-16, see -/// https://en.wikipedia.org/wiki/UTF-16 for more explenation about the -/// encoding; the operation we perform is: -/// pair_value=0x10000+(((char1%0x0800)*0x0400)+char2%0x0400) -/// \par parameters: two character expressions and a return type -/// char1 and char2 should be of type return_type -/// \return an integer expression of type return_type +/*******************************************************************\ + +Function: string_constraint_generatort::pair_value + + Inputs: two character expressions and a return type + char1 and char2 should be of type return_type + + Outputs: an integer expression of type return_type + + Purpose: the output corresponds to the unicode character given by the + pair of characters of inputs assuming it has been encoded in + UTF-16, see https://en.wikipedia.org/wiki/UTF-16 for + more explenation about the encoding; + the operation we perform is: + pair_value=0x10000+(((char1%0x0800)*0x0400)+char2%0x0400) + +\*******************************************************************/ + exprt pair_value(exprt char1, exprt char2, typet return_type) { exprt hex010000=from_integer(0x010000, return_type); @@ -118,10 +143,18 @@ exprt pair_value(exprt char1, exprt char2, typet return_type) return pair_value; } -/// add axioms corresponding to the String.codePointAt java function -/// \par parameters: function application with two arguments: a string and an -/// index -/// \return a integer expression corresponding to a code point +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_code_point_at + + Inputs: function application with two arguments: a string and an index + + Outputs: a integer expression corresponding to a code point + + Purpose: add axioms corresponding to the String.codePointAt java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_code_point_at( const function_application_exprt &f) { @@ -147,10 +180,18 @@ exprt string_constraint_generatort::add_axioms_for_code_point_at( return result; } -/// add axioms corresponding to the String.codePointBefore java function -/// \par parameters: function application with two arguments: a string and an -/// index -/// \return a integer expression corresponding to a code point +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_code_point_before + + Inputs: function application with two arguments: a string and an index + + Outputs: a integer expression corresponding to a code point + + Purpose: add axioms corresponding to the String.codePointBefore java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_code_point_before( const function_application_exprt &f) { @@ -178,11 +219,19 @@ exprt string_constraint_generatort::add_axioms_for_code_point_before( return result; } -/// add axioms giving approximate bounds on the result of the -/// String.codePointCount java function -/// \par parameters: function application with three arguments: a string and two -/// indexes -/// \return an integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_code_point_count + + Inputs: function application with three arguments: a string and two indexes + + Outputs: an integer expression + + Purpose: add axioms giving approximate bounds on the result of the + String.codePointCount java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_code_point_count( const function_application_exprt &f) { @@ -199,12 +248,21 @@ exprt string_constraint_generatort::add_axioms_for_code_point_count( return result; } -/// add axioms giving approximate bounds on the result of the -/// String.offsetByCodePointCount java function. We approximate the result by -/// saying the result is between index + offset and index + 2 * offset -/// \par parameters: function application with three arguments: a string and two -/// indexes -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_offset_by_code_point + + Inputs: function application with three arguments: a string and two indexes + + Outputs: a new string expression + + Purpose: add axioms giving approximate bounds on the result of the + String.offsetByCodePointCount java function. + We approximate the result by saying the result is + between index + offset and index + 2 * offset + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_offset_by_code_point( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_comparison.cpp b/src/solvers/refinement/string_constraint_generator_comparison.cpp index f926147d1d4..a51e2abe3cd 100644 --- a/src/solvers/refinement/string_constraint_generator_comparison.cpp +++ b/src/solvers/refinement/string_constraint_generator_comparison.cpp @@ -7,18 +7,23 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for function comparing strings, such as: -/// equals, equalsIgnoreCase, compareTo, hashCode, intern - #include -/// add axioms stating that the result is true exactly when the strings -/// represented by the arguments are equal. the variable ending in -/// `witness_unequal` is -1 if the length differs or an index at which the -/// strings are different -/// \par parameters: function application with two string arguments -/// \return a expression of Boolean type +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_equals + + Inputs: function application with two string arguments + + Outputs: a expression of Boolean type + + Purpose: add axioms stating that the result is true exactly when the strings + represented by the arguments are equal. + the variable ending in `witness_unequal` is -1 if the length differs + or an index at which the strings are different + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_equals( const function_application_exprt &f) { @@ -60,12 +65,20 @@ exprt string_constraint_generatort::add_axioms_for_equals( return tc_eq; } -/// returns an expression which is true when the two given characters are equal -/// when ignoring case for ASCII -/// \par parameters: two character expressions and constant character -/// expressions -/// representing 'a', 'A' and 'Z' -/// \return a expression of Boolean type +/*******************************************************************\ + +Function: string_constraint_generatort::character_equals_ignore_case + + Inputs: two character expressions and constant character expressions + representing 'a', 'A' and 'Z' + + Outputs: a expression of Boolean type + + Purpose: returns an expression which is true when the two given + characters are equal when ignoring case for ASCII + +\*******************************************************************/ + exprt string_constraint_generatort::character_equals_ignore_case( exprt char1, exprt char2, exprt char_a, exprt char_A, exprt char_Z) { @@ -92,9 +105,18 @@ exprt string_constraint_generatort::character_equals_ignore_case( return or_exprt(or_exprt(p1, p2), p3); } -/// add axioms corresponding to the String.equalsIgnoreCase java function -/// \par parameters: function application with two string arguments -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_equals_ignore_case + + Inputs: function application with two string arguments + + Outputs: a Boolean expression + + Purpose: add axioms corresponding to the String.equalsIgnoreCase java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_equals_ignore_case( const function_application_exprt &f) { @@ -144,10 +166,19 @@ exprt string_constraint_generatort::add_axioms_for_equals_ignore_case( return tc_eq; } -/// add axioms stating that if two strings are equal then their hash codes are -/// equals -/// \par parameters: function application with a string argument -/// \return a integer expression corresponding to the hash code of the string +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_hash_code + + Inputs: function application with a string argument + + Outputs: a integer expression corresponding to the hash code of the string + + Purpose: add axioms stating that if two strings are equal then their hash + codes are equals + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_hash_code( const function_application_exprt &f) { @@ -182,9 +213,18 @@ exprt string_constraint_generatort::add_axioms_for_hash_code( return hash; } -/// add axioms corresponding to the String.compareTo java function -/// \par parameters: function application with two string arguments -/// \return a integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_compare_to + + Inputs: function application with two string arguments + + Outputs: a integer expression + + Purpose: add axioms corresponding to the String.compareTo java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_compare_to( const function_application_exprt &f) { @@ -256,10 +296,19 @@ exprt string_constraint_generatort::add_axioms_for_compare_to( return res; } -/// add axioms stating that the return value for two equal string should be the -/// same -/// \par parameters: function application with one string argument -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_intern + + Inputs: function application with one string argument + + Outputs: a string expression + + Purpose: add axioms stating that the return value for two equal string + should be the same + +\*******************************************************************/ + symbol_exprt string_constraint_generatort::add_axioms_for_intern( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_concat.cpp b/src/solvers/refinement/string_constraint_generator_concat.cpp index 311427ec771..e6f360585bb 100644 --- a/src/solvers/refinement/string_constraint_generator_concat.cpp +++ b/src/solvers/refinement/string_constraint_generator_concat.cpp @@ -7,16 +7,21 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for functions adding content add the end of -/// strings - #include -/// add axioms to say that the returned string expression is equal to the -/// concatenation of the two string expressions given as input -/// \par parameters: two string expressions -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat + + Inputs: two string expressions + + Outputs: a new string expression + + Purpose: add axioms to say that the returned string expression is equal to + the concatenation of the two string expressions given as input + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat( const string_exprt &s1, const string_exprt &s2) { @@ -48,10 +53,20 @@ string_exprt string_constraint_generatort::add_axioms_for_concat( return res; } -/// add axioms to say that the returned string expression is equal to the -/// concatenation of the two string arguments of the function application -/// \par parameters: function application with two arguments which are strings -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat + + Inputs: function application with two arguments which are strings + + Outputs: a new string expression + + Purpose: add axioms to say that the returned string expression is equal to + the concatenation of the two string arguments of + the function application + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat( const function_application_exprt &f) { @@ -64,10 +79,18 @@ string_exprt string_constraint_generatort::add_axioms_for_concat( return add_axioms_for_concat(s1, s2); } -/// add axioms corresponding to the StringBuilder.append(I) java function -/// \par parameters: function application with two arguments: a string and an -/// integer -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_int + + Inputs: function application with two arguments: a string and an integer + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.append(I) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_int( const function_application_exprt &f) { @@ -78,10 +101,19 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_int( return add_axioms_for_concat(s1, s2); } -/// Add axioms corresponding to the StringBuilder.append(J) java function -/// \par parameters: function application with two arguments: a string and a -/// integer of type long -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_long + + Inputs: function application with two arguments: a string and a + integer of type long + + Outputs: a new string expression + + Purpose: Add axioms corresponding to the StringBuilder.append(J) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_long( const function_application_exprt &f) { @@ -91,9 +123,18 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_long( return add_axioms_for_concat(s1, s2); } -/// add axioms corresponding to the StringBuilder.append(Z) java function -/// \par parameters: function application two arguments: a string and a bool -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_bool + + Inputs: function application two arguments: a string and a bool + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.append(Z) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_bool( const function_application_exprt &f) { @@ -103,10 +144,18 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_bool( return add_axioms_for_concat(s1, s2); } -/// add axioms corresponding to the StringBuilder.append(C) java function -/// \par parameters: function application with two arguments: a string and a -/// char -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_char + + Inputs: function application with two arguments: a string and a char + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.append(C) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_char( const function_application_exprt &f) { @@ -116,10 +165,18 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_char( return add_axioms_for_concat(s1, s2); } -/// add axioms corresponding to the StringBuilder.append(D) java function -/// \par parameters: function application with two arguments: a string and a -/// double -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_double + + Inputs: function application with two arguments: a string and a double + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.append(D) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_double( const function_application_exprt &f) { @@ -130,10 +187,18 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_double( return add_axioms_for_concat(s1, s2); } -/// add axioms corresponding to the StringBuilder.append(F) java function -/// \par parameters: function application with two arguments: a string and a -/// float -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_float + + Inputs: function application with two arguments: a string and a float + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.append(F) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_float( const function_application_exprt &f) { @@ -144,10 +209,19 @@ string_exprt string_constraint_generatort::add_axioms_for_concat_float( return add_axioms_for_concat(s1, s2); } -/// Add axioms corresponding to the StringBuilder.appendCodePoint(I) function -/// \par parameters: function application with two arguments: a string and a -/// code point -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_concat_code_point + + Inputs: function application with two arguments: a string and a code point + + Outputs: a new string expression + + Purpose: Add axioms corresponding to the StringBuilder.appendCodePoint(I) + function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_concat_code_point( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_constants.cpp b/src/solvers/refinement/string_constraint_generator_constants.cpp index c5fb56658fb..2905c6a5f21 100644 --- a/src/solvers/refinement/string_constraint_generator_constants.cpp +++ b/src/solvers/refinement/string_constraint_generator_constants.cpp @@ -6,18 +6,24 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for constant strings - #include #include #include #include -/// extract java string from symbol expression when they are encoded inside the -/// symbol name -/// \par parameters: a symbol expression representing a java literal -/// \return a string constant +/*******************************************************************\ + +Function: string_constraint_generatort::extract_java_string + + Inputs: a symbol expression representing a java literal + + Outputs: a string constant + + Purpose: extract java string from symbol expression when they are encoded + inside the symbol name + +\*******************************************************************/ + irep_idt string_constraint_generatort::extract_java_string( const symbol_exprt &s) { @@ -28,10 +34,19 @@ irep_idt string_constraint_generatort::extract_java_string( return irep_idt(value); } -/// add axioms saying the returned string expression should be equal to the -/// string constant -/// \par parameters: a string constant -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_constant + + Inputs: a string constant + + Outputs: a string expression + + Purpose: add axioms saying the returned string expression should be equal + to the string constant + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_constant( irep_idt sval, const refined_string_typet &ref_type) { @@ -62,9 +77,18 @@ string_exprt string_constraint_generatort::add_axioms_for_constant( return res; } -/// add axioms to say that the returned string expression is empty -/// \par parameters: function application without argument -/// \return string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_empty_string + + Inputs: function application without argument + + Outputs: string expression + + Purpose: add axioms to say that the returned string expression is empty + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_empty_string( const function_application_exprt &f) { @@ -79,11 +103,19 @@ string_exprt string_constraint_generatort::add_axioms_for_empty_string( return res; } -/// add axioms to say that the returned string expression is equal to the string -/// literal -/// \par parameters: function application with an argument which is a string -/// literal -/// \return string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_literal + + Inputs: function application with an argument which is a string literal + + Outputs: string expression + + Purpose: add axioms to say that the returned string expression is equal to + the string literal + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_literal( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_indexof.cpp b/src/solvers/refinement/string_constraint_generator_indexof.cpp index 2e3e6424c36..9386639e594 100644 --- a/src/solvers/refinement/string_constraint_generator_indexof.cpp +++ b/src/solvers/refinement/string_constraint_generator_indexof.cpp @@ -7,19 +7,25 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for the family of indexOf and lastIndexOf java -/// functions - #include -/// Add axioms stating that the returned value is the index within str of the -/// first occurence of c starting the search at from_index, or -1 if no such -/// character occurs at or after position from_index. -/// \param str: a string expression -/// \param c: an expression representing a character -/// \param from_index: an expression representing an index in the string -/// \return a integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_index_of + + Inputs: + str - a string expression + c - an expression representing a character + from_index - an expression representing an index in the string + + Outputs: a integer expression + + Purpose: Add axioms stating that the returned value is the index within + str of the first occurence of c starting the search at from_index, + or -1 if no such character occurs at or after position from_index. + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_index_of( const string_exprt &str, const exprt &c, const exprt &from_index) { @@ -67,14 +73,25 @@ exprt string_constraint_generatort::add_axioms_for_index_of( return index; } -/// Add axioms stating that the returned value is the index within haystack of -/// the first occurence of needle starting the search at from_index, or -1 if -/// needle does not occur at or after position from_index. -/// \param haystack: a string expression -/// \param needle: a string expression -/// \param from_index: an expression representing an index in strings -/// \return an integer expression representing the first index of needle in -/// haystack after from_index, or -1 if there is none +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_index_of_string + + Inputs: + haystack - a string expression + needle - a string expression + from_index - an expression representing an index in strings + + Outputs: an integer expression representing the first index of needle in + haystack after from_index, or -1 if there is none + + Purpose: Add axioms stating that the returned value is the index within + haystack of the first occurence of needle starting the search at + from_index, or -1 if needle does not occur at or after position + from_index. + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_index_of_string( const string_exprt &haystack, const string_exprt &needle, @@ -174,15 +191,25 @@ exprt string_constraint_generatort::add_axioms_for_index_of_string( return offset; } -/// Add axioms stating that the returned value is the index within haystack of -/// the last occurence of needle starting the search backward at from_index (ie -/// the index is smaller or equal to from_index), or -1 if needle does not occur -/// before from_index. -/// \param haystack: a string expression -/// \param needle: a string expression -/// \param from_index: an expression representing an index in strings -/// \return an integer expression representing the last index of needle in -/// haystack before or at from_index, or -1 if there is none +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_last_index_of_string + + Inputs: + haystack - a string expression + needle - a string expression + from_index - an expression representing an index in strings + + Outputs: an integer expression representing the last index of needle in + haystack before or at from_index, or -1 if there is none + + Purpose: Add axioms stating that the returned value is the index within + haystack of the last occurence of needle starting the search + backward at from_index (ie the index is smaller or equal to + from_index), or -1 if needle does not occur before from_index. + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_last_index_of_string( const string_exprt &haystack, const string_exprt &needle, @@ -285,10 +312,20 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of_string( return offset; } -/// add axioms corresponding to the String.indexOf:(C), String.indexOf:(CI), -/// String.indexOf:(String), and String.indexOf:(String,I) java functions -/// \par parameters: function application with 2 or 3 arguments -/// \return a integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_index_of + + Inputs: function application with 2 or 3 arguments + + Outputs: a integer expression + + Purpose: add axioms corresponding to the String.indexOf:(C), + String.indexOf:(CI), String.indexOf:(String), and + String.indexOf:(String,I) java functions + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_index_of( const function_application_exprt &f) { @@ -319,14 +356,25 @@ exprt string_constraint_generatort::add_axioms_for_index_of( } } -/// Add axioms stating that the returned value is the index within str of the -/// last occurence of c starting the search backward at from_index, or -1 if no -/// such character occurs at or before position from_index. -/// \param str: a string expression -/// \param c: an expression representing a character -/// \param from_index: an expression representing an index in the string -/// \return an integer expression representing the last index of c in str before -/// or at from_index, or -1 if there is none +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_last_index_of + + Inputs: + str - a string expression + c - an expression representing a character + from_index - an expression representing an index in the string + + Outputs: an integer expression representing the last index of c in + str before or at from_index, or -1 if there is none + + Purpose: Add axioms stating that the returned value is the index within + str of the last occurence of c starting the search backward at + from_index, or -1 if no such character occurs at or before + position from_index. + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_last_index_of( const string_exprt &str, const exprt &c, const exprt &from_index) { @@ -380,11 +428,20 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of( return index; } -/// add axioms corresponding to the String.lastIndexOf:(C), -/// String.lastIndexOf:(CI), String.lastIndexOf:(String), and -/// String.lastIndexOf:(String,I) java functions -/// \par parameters: function application with 2 or 3 arguments -/// \return a integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_last_index_of + + Inputs: function application with 2 or 3 arguments + + Outputs: a integer expression + + Purpose: add axioms corresponding to the String.lastIndexOf:(C), + String.lastIndexOf:(CI), String.lastIndexOf:(String), and + String.lastIndexOf:(String,I) java functions + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_last_index_of( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_insert.cpp b/src/solvers/refinement/string_constraint_generator_insert.cpp index 0fb39e8a658..7a63279699e 100644 --- a/src/solvers/refinement/string_constraint_generator_insert.cpp +++ b/src/solvers/refinement/string_constraint_generator_insert.cpp @@ -6,15 +6,21 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for the family of insert Java functions - #include -/// add axioms stating that the result correspond to the first string where we -/// inserted the second one at possition offset -/// \par parameters: two string expression and an integer offset -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert + + Inputs: two string expression and an integer offset + + Outputs: a new string expression + + Purpose: add axioms stating that the result correspond to the first string + where we inserted the second one at possition offset + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert( const string_exprt &s1, const string_exprt &s2, const exprt &offset) { @@ -26,11 +32,21 @@ string_exprt string_constraint_generatort::add_axioms_for_insert( return add_axioms_for_concat(concat1, suf); } -/// add axioms corresponding to the StringBuilder.insert(int, CharSequence) and -/// StringBuilder.insert(int, CharSequence, int, int) java functions -/// \par parameters: function application with three arguments: two strings and -/// an index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert + + Inputs: function application with three arguments: two strings and an index + + Outputs: a new string expression + + Purpose: add axioms corresponding to the + StringBuilder.insert(int, CharSequence) + and StringBuilder.insert(int, CharSequence, int, int) + java functions + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert( const function_application_exprt &f) { @@ -52,11 +68,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert( } } -/// add axioms corresponding to the StringBuilder.insert(I) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset, and an integer -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_int + + Inputs: function application with three arguments: a string, an integer + offset, and an integer + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(I) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_int( const function_application_exprt &f) { @@ -67,11 +91,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_int( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert(J) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset and a long -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_long + + Inputs: function application with three arguments: a string, an integer + offset and a long + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(J) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_long( const function_application_exprt &f) { @@ -81,11 +113,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_long( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert(Z) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset, and a Boolean -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_bool + + Inputs: function application with three arguments: a string, an integer + offset, and a Boolean + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(Z) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_bool( const function_application_exprt &f) { @@ -95,11 +135,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_bool( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert(C) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset, and a character -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_char + + Inputs: function application with three arguments: a string, an integer + offset, and a character + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(C) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_char( const function_application_exprt &f) { @@ -109,11 +157,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_char( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert(D) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset, and a double -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_double + + Inputs: function application with three arguments: a string, an integer + offset, and a double + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(D) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_double( const function_application_exprt &f) { @@ -123,11 +179,19 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_double( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert(F) java function -/// \par parameters: function application with three arguments: a string, an -/// integer -/// offset, and a float -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_float + + Inputs: function application with three arguments: a string, an integer + offset, and a float + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert(F) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_float( const function_application_exprt &f) { @@ -137,13 +201,21 @@ string_exprt string_constraint_generatort::add_axioms_for_insert_float( return add_axioms_for_insert(s1, s2, args(f, 3)[1]); } -/// add axioms corresponding to the StringBuilder.insert:(I[CII) and -/// StringBuilder.insert:(I[C) java functions -/// \par parameters: function application with 4 arguments plus two optional -/// arguments: -/// a string, an offset index, a length, data array, an offset and a -/// count -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_insert_char_array + + Inputs: function application with 4 arguments plus two optional arguments: + a string, an offset index, a length, data array, an offset and a + count + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.insert:(I[CII) + and StringBuilder.insert:(I[C) java functions + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_insert_char_array( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_main.cpp b/src/solvers/refinement/string_constraint_generator_main.cpp index b7d8ad878e3..796b0554696 100644 --- a/src/solvers/refinement/string_constraint_generator_main.cpp +++ b/src/solvers/refinement/string_constraint_generator_main.cpp @@ -10,13 +10,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints to link results from string functions with -/// their arguments. This is inspired by the PASS paper at HVC'13: "PASS: -/// String Solving with Parameterized Array and Interval Automaton" by Guodong -/// Li and Indradeep Ghosh, which gives examples of constraints for several -/// functions. - #include #include #include @@ -27,22 +20,39 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com unsigned string_constraint_generatort::next_symbol_id=1; -/// generate constant character expression with character type. -/// \par parameters: integer representing a character, and a type for -/// characters; -/// we do not use char type here because in some languages -/// (for instance java) characters use more than 8 bits. -/// \return constant expression corresponding to the character. +/*******************************************************************\ + +Function: string_constraint_generatort::constant_char + + Inputs: integer representing a character, and a type for characters; + we do not use char type here because in some languages + (for instance java) characters use more than 8 bits. + + Outputs: constant expression corresponding to the character. + + Purpose: generate constant character expression with character type. + +\*******************************************************************/ + constant_exprt string_constraint_generatort::constant_char( int i, const typet &char_type) { return from_integer(i, char_type); } -/// generate a new symbol expression of the given type with some prefix -/// \par parameters: a prefix and a type -/// \return a symbol of type tp whose name starts with "string_refinement#" -/// followed by prefix +/*******************************************************************\ + +Function: string_constraint_generator::fresh_symbol + + Inputs: a prefix and a type + + Outputs: a symbol of type tp whose name starts with + "string_refinement#" followed by prefix + + Purpose: generate a new symbol expression of the given type with some prefix + +\*******************************************************************/ + symbol_exprt string_constraint_generatort::fresh_symbol( const irep_idt &prefix, const typet &type) { @@ -52,18 +62,37 @@ symbol_exprt string_constraint_generatort::fresh_symbol( return symbol_exprt(name, type); } -/// generate an index symbol to be used as an universaly quantified variable -/// \par parameters: a prefix -/// \return a symbol of index type whose name starts with the prefix +/*******************************************************************\ + +Function: string_constraint_generatort::fresh_univ_index + + Inputs: a prefix + + Outputs: a symbol of index type whose name starts with the prefix + + Purpose: generate an index symbol to be used as an universaly quantified + variable + +\*******************************************************************/ + symbol_exprt string_constraint_generatort::fresh_univ_index( const irep_idt &prefix, const typet &type) { return fresh_symbol(prefix, type); } -/// generate an index symbol which is existentially quantified -/// \par parameters: a prefix -/// \return a symbol of index type whose name starts with the prefix +/*******************************************************************\ + +Function: string_constraint_generatort::fresh_exist_index + + Inputs: a prefix + + Outputs: a symbol of index type whose name starts with the prefix + + Purpose: generate an index symbol which is existentially quantified + +\*******************************************************************/ + symbol_exprt string_constraint_generatort::fresh_exist_index( const irep_idt &prefix, const typet &type) { @@ -72,9 +101,18 @@ symbol_exprt string_constraint_generatort::fresh_exist_index( return s; } -/// generate a Boolean symbol which is existentially quantified -/// \par parameters: a prefix -/// \return a symbol of index type whose name starts with the prefix +/*******************************************************************\ + +Function: string_constraint_generatort::fresh_boolean + + Inputs: a prefix + + Outputs: a symbol of index type whose name starts with the prefix + + Purpose: generate a Boolean symbol which is existentially quantified + +\*******************************************************************/ + symbol_exprt string_constraint_generatort::fresh_boolean( const irep_idt &prefix) { @@ -83,11 +121,20 @@ symbol_exprt string_constraint_generatort::fresh_boolean( return b; } -/// Create a plus expression while adding extra constraints to axioms in order -/// to prevent overflows. -/// \param op1: First term of the sum -/// \param op2: Second term of the sum -/// \return A plus expression representing the sum of the arguments +/*******************************************************************\ + +Function: string_constraint_generatort::plus_exprt_with_overflow_check + + Inputs: + op1 - First term of the sum + op2 - Second term of the sum + + Outputs: A plus expression representing the sum of the arguments + + Purpose: Create a plus expression while adding extra constraints to + axioms in order to prevent overflows. + +\*******************************************************************/ plus_exprt string_constraint_generatort::plus_exprt_with_overflow_check( const exprt &op1, const exprt &op2) { @@ -110,9 +157,19 @@ plus_exprt string_constraint_generatort::plus_exprt_with_overflow_check( return sum; } -/// construct a string expression whose length and content are new variables -/// \par parameters: a type for string -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::fresh_string + + Inputs: a type for string + + Outputs: a string expression + + Purpose: construct a string expression whose length and content are new + variables + +\*******************************************************************/ + string_exprt string_constraint_generatort::fresh_string( const refined_string_typet &type) { @@ -124,10 +181,19 @@ string_exprt string_constraint_generatort::fresh_string( return str; } -/// casts an expression to a string expression, or fetches the actual -/// string_exprt in the case of a symbol. -/// \par parameters: an expression of refined string type -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::get_string_expr + + Inputs: an expression of refined string type + + Outputs: a string expression + + Purpose: casts an expression to a string expression, or fetches the + actual string_exprt in the case of a symbol. + +\*******************************************************************/ + string_exprt string_constraint_generatort::get_string_expr(const exprt &expr) { assert(refined_string_typet::is_refined_string_type(expr.type())); @@ -144,9 +210,18 @@ string_exprt string_constraint_generatort::get_string_expr(const exprt &expr) } } -/// create a new string_exprt as a conversion of a java string -/// \par parameters: a java string -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::convert_java_string_to_string_exprt + + Inputs: a java string + + Outputs: a string expression + + Purpose: create a new string_exprt as a conversion of a java string + +\*******************************************************************/ + string_exprt string_constraint_generatort::convert_java_string_to_string_exprt( const exprt &jls) { @@ -170,13 +245,26 @@ string_exprt string_constraint_generatort::convert_java_string_to_string_exprt( return string_exprt(length, java_content, type); } -/// adds standard axioms about the length of the string and its content: * its -/// length should be positive * it should not exceed max_string_length * if -/// force_printable_characters is true then all characters should belong to the -/// range of ASCII characters between ' ' and '~' -/// \param s: a string expression -/// \return a string expression that is linked to the argument through axioms -/// that are added to the list +/*******************************************************************\ + +Function: string_constraint_generatort::add_default_axioms + + Inputs: + s - a string expression + + Outputs: a string expression that is linked to the argument through + axioms that are added to the list + + Purpose: adds standard axioms about the length of the string and + its content: + * its length should be positive + * it should not exceed max_string_length + * if force_printable_characters is true then all characters + should belong to the range of ASCII characters between ' ' and '~' + + +\*******************************************************************/ + void string_constraint_generatort::add_default_axioms( const string_exprt &s) { @@ -197,11 +285,20 @@ void string_constraint_generatort::add_default_axioms( } } -/// obtain a refined string expression corresponding to a expression of type -/// string -/// \par parameters: an expression of refined string type -/// \return a string expression that is linked to the argument through axioms -/// that are added to the list +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_refined_string + + Inputs: an expression of refined string type + + Outputs: a string expression that is linked to the argument through + axioms that are added to the list + + Purpose: obtain a refined string expression corresponding to a expression + of type string + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_refined_string( const exprt &string) { @@ -242,9 +339,18 @@ string_exprt string_constraint_generatort::add_axioms_for_refined_string( } } -/// add axioms for an if expression which should return a string -/// \par parameters: an if expression -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_if + + Inputs: an if expression + + Outputs: a string expression + + Purpose: add axioms for an if expression which should return a string + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_if( const if_exprt &expr) { @@ -272,12 +378,21 @@ string_exprt string_constraint_generatort::add_axioms_for_if( return res; } -/// if a symbol representing a string is present in the symbol_to_string table, -/// returns the corresponding string, if the symbol is not yet present, creates -/// a new string with the correct type depending on whether the mode is java or -/// c, adds it to the table and returns it. -/// \par parameters: a symbol expression -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::find_or_add_string_of_symbol + + Inputs: a symbol expression + + Outputs: a string expression + + Purpose: if a symbol representing a string is present in the symbol_to_string + table, returns the corresponding string, if the symbol is not yet + present, creates a new string with the correct type depending on + whether the mode is java or c, adds it to the table and returns it. + +\*******************************************************************/ + string_exprt string_constraint_generatort::find_or_add_string_of_symbol( const symbol_exprt &sym, const refined_string_typet &ref_type) { @@ -287,11 +402,20 @@ string_exprt string_constraint_generatort::find_or_add_string_of_symbol( return entry.first->second; } -/// strings contained in this call are converted to objects of type -/// `string_exprt`, through adding axioms. Axioms are then added to enforce that -/// the result corresponds to the function application. -/// \par parameters: an expression containing a function application -/// \return expression corresponding to the result of the function application +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_function_application + + Inputs: an expression containing a function application + + Outputs: expression corresponding to the result of the function application + + Purpose: strings contained in this call are converted to objects of type + `string_exprt`, through adding axioms. Axioms are then added to + enforce that the result corresponds to the function application. + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_function_application( const function_application_exprt &expr) { @@ -485,11 +609,20 @@ exprt string_constraint_generatort::add_axioms_for_function_application( return res; } -/// add axioms to say that the returned string expression is equal to the -/// argument of the function application -/// \par parameters: function application with one argument, which is a string, -/// or three arguments: string, integer offset and count -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_copy + + Inputs: function application with one argument, which is a string, + or three arguments: string, integer offset and count + + Outputs: a new string expression + + Purpose: add axioms to say that the returned string expression is equal to + the argument of the function application + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_copy( const function_application_exprt &f) { @@ -509,10 +642,18 @@ string_exprt string_constraint_generatort::add_axioms_for_copy( } } -/// add axioms corresponding to the String.valueOf([C) java function -/// \par parameters: an expression corresponding to a java object of type char -/// array -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_java_char_array + + Inputs: an expression corresponding to a java object of type char array + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf([C) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_java_char_array( const exprt &char_array) { @@ -526,9 +667,18 @@ string_exprt string_constraint_generatort::add_axioms_for_java_char_array( return res; } -/// for an expression of the form `array[0]` returns `array` -/// \par parameters: an expression of type char -/// \return an array expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_char_pointer + + Inputs: an expression of type char + + Outputs: an array expression + + Purpose: for an expression of the form `array[0]` returns `array` + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_char_pointer( const function_application_exprt &fun) { @@ -540,9 +690,18 @@ exprt string_constraint_generatort::add_axioms_for_char_pointer( return exprt(); } -/// add axioms corresponding to the String.length java function -/// \par parameters: function application with one string argument -/// \return a string expression of index type +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_length + + Inputs: function application with one string argument + + Outputs: a string expression of index type + + Purpose: add axioms corresponding to the String.length java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_length( const function_application_exprt &f) { @@ -550,13 +709,21 @@ exprt string_constraint_generatort::add_axioms_for_length( return str.length(); } -/// add axioms stating that the content of the returned string equals to the -/// content of the array argument, starting at offset and with `count` -/// characters -/// \par parameters: a length expression, an array expression, a offset index, -/// and a -/// count index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_char_array + + Inputs: a length expression, an array expression, a offset index, and a + count index + + Outputs: a new string expression + + Purpose: add axioms stating that the content of the returned string + equals to the content of the array argument, starting at offset and + with `count` characters + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_char_array( const exprt &length, const exprt &data, @@ -585,11 +752,20 @@ string_exprt string_constraint_generatort::add_axioms_from_char_array( return str; } -/// add axioms corresponding to the String.:(I[CII) and -/// String.:(I[C) java functions -/// function application with 2 arguments and 2 additional optional -/// \param arguments: length, char array, offset and count -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_char_array + + Inputs: function application with 2 arguments and 2 additional optional + arguments: length, char array, offset and count + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.:(I[CII) + and String.:(I[C) java functions + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_char_array( const function_application_exprt &f) { @@ -612,18 +788,36 @@ string_exprt string_constraint_generatort::add_axioms_from_char_array( return add_axioms_from_char_array(tab_length, data, offset, count); } -/// expression true exactly when the index is positive -/// \par parameters: an index expression -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_is_positive_index + + Inputs: an index expression + + Outputs: a Boolean expression + + Purpose: expression true exactly when the index is positive + +\*******************************************************************/ + exprt string_constraint_generatort::axiom_for_is_positive_index(const exprt &x) { return binary_relation_exprt( x, ID_ge, from_integer(0, x.type())); } -/// add axioms stating that the returned value is equal to the argument -/// \par parameters: function application with one character argument -/// \return a new character expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_char_literal + + Inputs: function application with one character argument + + Outputs: a new character expression + + Purpose: add axioms stating that the returned value is equal to the argument + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_char_literal( const function_application_exprt &f) { @@ -649,11 +843,19 @@ exprt string_constraint_generatort::add_axioms_for_char_literal( } } -/// add axioms stating that the character of the string at the given position is -/// equal to the returned value -/// \par parameters: function application with two arguments: a string and an -/// integer -/// \return a character expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_char_at + + Inputs: function application with two arguments: a string and an integer + + Outputs: a character expression + + Purpose: add axioms stating that the character of the string at the given + position is equal to the returned value + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_char_at( const function_application_exprt &f) { @@ -664,9 +866,18 @@ exprt string_constraint_generatort::add_axioms_for_char_at( return char_sym; } -/// add axioms corresponding to the String.toCharArray java function -/// \par parameters: function application with one string argument -/// \return a char array expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_to_char_array + + Inputs: function application with one string argument + + Outputs: a char array expression + + Purpose: add axioms corresponding to the String.toCharArray java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_to_char_array( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_testing.cpp b/src/solvers/refinement/string_constraint_generator_testing.cpp index 878441cd0d1..55a6f45f4f7 100644 --- a/src/solvers/refinement/string_constraint_generator_testing.cpp +++ b/src/solvers/refinement/string_constraint_generator_testing.cpp @@ -7,15 +7,22 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for string functions that return Boolean values - #include -/// add axioms stating that the returned expression is true exactly when the -/// first string is a prefix of the second one, starting at position offset -/// \par parameters: a prefix string, a string and an integer offset -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_is_prefix + + Inputs: a prefix string, a string and an integer offset + + Outputs: a Boolean expression + + Purpose: add axioms stating that the returned expression is true exactly + when the first string is a prefix of the second one, starting at + position offset + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_is_prefix( const string_exprt &prefix, const string_exprt &str, const exprt &offset) { @@ -62,12 +69,20 @@ exprt string_constraint_generatort::add_axioms_for_is_prefix( return isprefix; } -/// add axioms corresponding to the String.isPrefix java function -/// \par parameters: a function application with 2 or 3 arguments and a Boolean -/// telling -/// whether the prefix is the second argument (when swap_arguments is -/// true) or the first argument -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_is_prefix + + Inputs: a function application with 2 or 3 arguments and a Boolean telling + whether the prefix is the second argument (when swap_arguments is + true) or the first argument + + Outputs: a Boolean expression + + Purpose: add axioms corresponding to the String.isPrefix java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_is_prefix( const function_application_exprt &f, bool swap_arguments) { @@ -83,10 +98,19 @@ exprt string_constraint_generatort::add_axioms_for_is_prefix( return typecast_exprt(add_axioms_for_is_prefix(s0, s1, offset), f.type()); } -/// add axioms stating that the returned value is true exactly when the argument -/// string is empty -/// \par parameters: function application with a string argument -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_is_empty + + Inputs: function application with a string argument + + Outputs: a Boolean expression + + Purpose: add axioms stating that the returned value is true exactly when + the argument string is empty + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_is_empty( const function_application_exprt &f) { @@ -103,12 +127,20 @@ exprt string_constraint_generatort::add_axioms_for_is_empty( return typecast_exprt(is_empty, f.type()); } -/// add axioms corresponding to the String.isSuffix java function -/// \par parameters: a function application with 2 or 3 arguments and a Boolean -/// telling -/// whether the suffix is the second argument (when swap_arguments is -/// true) or the first argument -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_is_suffix + + Inputs: a function application with 2 or 3 arguments and a Boolean telling + whether the suffix is the second argument (when swap_arguments is + true) or the first argument + + Outputs: a Boolean expression + + Purpose: add axioms corresponding to the String.isSuffix java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_is_suffix( const function_application_exprt &f, bool swap_arguments) { @@ -158,9 +190,19 @@ exprt string_constraint_generatort::add_axioms_for_is_suffix( return tc_issuffix; } -/// tells whether the given string is a constant -/// \param expr: a string expression -/// \return a Boolean +/*******************************************************************\ + +Function: string_constraint_generatort::is_constant_string + + Inputs: + expr - a string expression + + Outputs: a Boolean + + Purpose: tells whether the given string is a constant + +\*******************************************************************/ + bool string_constraint_generatort::is_constant_string( const string_exprt &expr) const { @@ -177,9 +219,18 @@ bool string_constraint_generatort::is_constant_string( return true; } -/// add axioms corresponding to the String.contains java function -/// \par parameters: function application with two string arguments -/// \return a Boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_contains + + Inputs: function application with two string arguments + + Outputs: a Boolean expression + + Purpose: add axioms corresponding to the String.contains java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_contains( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_transformation.cpp b/src/solvers/refinement/string_constraint_generator_transformation.cpp index 599ae3af9dd..c110f636c43 100644 --- a/src/solvers/refinement/string_constraint_generator_transformation.cpp +++ b/src/solvers/refinement/string_constraint_generator_transformation.cpp @@ -7,20 +7,25 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for string transformations, that is, functions -/// taking one string and returning another - #include -/// add axioms to say that the returned string expression has length given by -/// the second argument and whose characters are equal to those of the first -/// argument for the positions which are defined in both strings -/// \par parameters: function application with two arguments, the first of which -/// is -/// a string and the second an integer which should have same type has -/// return by get_index_type() -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_set_length + + Inputs: function application with two arguments, the first of which is + a string and the second an integer which should have same type has + return by get_index_type() + + Outputs: a new string expression + + Purpose: add axioms to say that the returned string expression has length + given by the second argument and whose characters are equal to + those of the first argument for the positions which are defined in + both strings + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_set_length( const function_application_exprt &f) { @@ -58,13 +63,21 @@ string_exprt string_constraint_generatort::add_axioms_for_set_length( } -/// add axioms corresponding to the String.substring java function Warning: the -/// specification may not be correct for the case where the string is shorter -/// than the end index -/// \par parameters: function application with one string argument, one start -/// index -/// argument and an optional end index argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_substring + + Inputs: function application with one string argument, one start index + argument and an optional end index argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.substring java function + Warning: the specification may not be correct for the case where the + string is shorter than the end index + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_substring( const function_application_exprt &f) { @@ -85,12 +98,20 @@ string_exprt string_constraint_generatort::add_axioms_for_substring( return add_axioms_for_substring(str, i, j); } -/// add axioms stating that the returned string expression is equal to the input -/// one starting at `start` and ending before `end` -/// \par parameters: a string expression, an expression for the start index, and -/// an -/// expression for the end index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_substring + + Inputs: a string expression, an expression for the start index, and an + expression for the end index + + Outputs: a new string expression + + Purpose: add axioms stating that the returned string expression is equal + to the input one starting at `start` and ending before `end` + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_substring( const string_exprt &str, const exprt &start, const exprt &end) { @@ -127,9 +148,18 @@ string_exprt string_constraint_generatort::add_axioms_for_substring( return res; } -/// add axioms corresponding to the String.trim java function -/// \par parameters: function application with one string argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_trim + + Inputs: function application with one string argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.trim java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_trim( const function_application_exprt &expr) { @@ -203,9 +233,18 @@ string_exprt string_constraint_generatort::add_axioms_for_trim( return res; } -/// add axioms corresponding to the String.toLowerCase java function -/// \par parameters: function application with one string argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_to_lower_case + + Inputs: function application with one string argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.toLowerCase java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_to_lower_case( const function_application_exprt &expr) { @@ -247,9 +286,18 @@ string_exprt string_constraint_generatort::add_axioms_for_to_lower_case( return res; } -/// add axioms corresponding to the String.toUpperCase java function -/// \par parameters: function application with one string argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_to_upper_case + + Inputs: function application with one string argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.toUpperCase java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_to_upper_case( const function_application_exprt &expr) { @@ -290,13 +338,22 @@ string_exprt string_constraint_generatort::add_axioms_for_to_upper_case( } -/// add axioms corresponding stating that the result is similar to that of the -/// StringBuilder.setCharAt java function Warning: this may be underspecified in -/// the case wher the index exceed the length of the string -/// \par parameters: function application with three arguments, the first is a -/// string -/// the second an index and the third a character -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_char_set + + Inputs: function application with three arguments, the first is a string + the second an index and the third a character + + Outputs: a new string expression + + Purpose: add axioms corresponding stating that the result is similar to + that of the StringBuilder.setCharAt java function + Warning: this may be underspecified in the case wher the index exceed + the length of the string + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_char_set( const function_application_exprt &f) { @@ -317,11 +374,19 @@ string_exprt string_constraint_generatort::add_axioms_for_char_set( return res; } -/// add axioms corresponding to the String.replace java function -/// \par parameters: function application with three arguments, the first is a -/// string, -/// the second and the third are characters -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_replace + + Inputs: function application with three arguments, the first is a string, + the second and the third are characters + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.replace java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_replace( const function_application_exprt &f) { @@ -351,11 +416,20 @@ string_exprt string_constraint_generatort::add_axioms_for_replace( return res; } -/// add axioms corresponding to the StringBuilder.deleteCharAt java function -/// \par parameters: function application with two arguments, the first is a -/// string -/// and the second is an index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_delete_char_at + + Inputs: function application with two arguments, the first is a string + and the second is an index + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.deleteCharAt java + function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_delete_char_at( const function_application_exprt &f) { @@ -367,11 +441,20 @@ string_exprt string_constraint_generatort::add_axioms_for_delete_char_at( plus_exprt_with_overflow_check(args(f, 2)[1], index_one)); } -/// add axioms stating that the returned string corresponds to the input one -/// where we removed characters between the positions start (included) and end -/// (not included) -/// \par parameters: a string expression, a start index and an end index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_delete + + Inputs: a string expression, a start index and an end index + + Outputs: a new string expression + + Purpose: add axioms stating that the returned string corresponds to the input + one where we removed characters between the positions + start (included) and end (not included) + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_delete( const string_exprt &str, const exprt &start, const exprt &end) { @@ -383,10 +466,19 @@ string_exprt string_constraint_generatort::add_axioms_for_delete( return add_axioms_for_concat(str1, str2); } -/// add axioms corresponding to the StringBuilder.delete java function -/// \par parameters: function application with three arguments: a string -/// expression, a start index and an end index -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_delete + + Inputs: function application with three arguments: a string + expression, a start index and an end index + + Outputs: a new string expression + + Purpose: add axioms corresponding to the StringBuilder.delete java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_delete( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_constraint_generator_valueof.cpp b/src/solvers/refinement/string_constraint_generator_valueof.cpp index 9ad1845c9d0..d967e5bb820 100644 --- a/src/solvers/refinement/string_constraint_generator_valueof.cpp +++ b/src/solvers/refinement/string_constraint_generator_valueof.cpp @@ -7,16 +7,21 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Generates string constraints for functions generating strings from other -/// types, in particular int, long, float, double, char, bool - #include #include -/// add axioms corresponding to the String.valueOf(I) java function -/// \par parameters: function application with one integer argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_int + + Inputs: function application with one integer argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(I) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_int( const function_application_exprt &expr) { @@ -24,9 +29,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int( return add_axioms_from_int(args(expr, 1)[0], MAX_INTEGER_LENGTH, ref_type); } -/// add axioms corresponding to the String.valueOf(J) java function -/// \par parameters: function application with one long argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_long + + Inputs: function application with one long argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(J) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_long( const function_application_exprt &expr) { @@ -34,9 +48,18 @@ string_exprt string_constraint_generatort::add_axioms_from_long( return add_axioms_from_int(args(expr, 1)[0], MAX_LONG_LENGTH, ref_type); } -/// add axioms corresponding to the String.valueOf(F) java function -/// \par parameters: function application with one float argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_float + + Inputs: function application with one float argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(F) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_float( const function_application_exprt &f) { @@ -44,9 +67,18 @@ string_exprt string_constraint_generatort::add_axioms_from_float( return add_axioms_from_float(args(f, 1)[0], ref_type, false); } -/// add axioms corresponding to the String.valueOf(D) java function -/// \par parameters: function application with one double argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_double + + Inputs: function application with one double argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(D) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_double( const function_application_exprt &f) { @@ -54,12 +86,20 @@ string_exprt string_constraint_generatort::add_axioms_from_double( return add_axioms_from_float(args(f, 1)[0], ref_type, true); } -/// add axioms corresponding to the String.valueOf(F) java function Warning: we -/// currently only have partial specification -/// \par parameters: float expression and Boolean signaling that the argument -/// has -/// double precision -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_float + + Inputs: float expression and Boolean signaling that the argument has + double precision + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(F) java function + Warning: we currently only have partial specification + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_float( const exprt &f, const refined_string_typet &ref_type, bool double_precision) { @@ -151,9 +191,18 @@ string_exprt string_constraint_generatort::add_axioms_from_float( } -/// add axioms corresponding to the String.valueOf(Z) java function -/// \par parameters: function application with on Boolean argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_bool + + Inputs: function application with on Boolean argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(Z) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_bool( const function_application_exprt &f) { @@ -162,10 +211,19 @@ string_exprt string_constraint_generatort::add_axioms_from_bool( } -/// add axioms stating that the returned string equals "true" when the Boolean -/// expression is true and "false" when it is false -/// \par parameters: Boolean expression -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_bool + + Inputs: Boolean expression + + Outputs: a new string expression + + Purpose: add axioms stating that the returned string equals "true" when + the Boolean expression is true and "false" when it is false + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_bool( const exprt &b, const refined_string_typet &ref_type) { @@ -207,12 +265,21 @@ string_exprt string_constraint_generatort::add_axioms_from_bool( return res; } -/// add axioms to say the string corresponds to the result of String.valueOf(I) -/// or String.valueOf(J) java functions applied on the integer expression -/// \par parameters: a signed integer expression, and a maximal size for the -/// string -/// representation -/// \return a string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_int + + Inputs: a signed integer expression, and a maximal size for the string + representation + + Outputs: a string expression + + Purpose: add axioms to say the string corresponds to the result of + String.valueOf(I) or String.valueOf(J) java functions applied on the + integer expression + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_int( const exprt &i, size_t max_size, const refined_string_typet &ref_type) { @@ -316,10 +383,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int( return res; } -/// returns the value represented by the character -/// \par parameters: a character expression in the following set: -/// 0123456789abcdef -/// \return an integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::int_of_hex_char + + Inputs: a character expression in the following set: 0123456789abcdef + + Outputs: an integer expression + + Purpose: returns the value represented by the character + +\*******************************************************************/ + exprt string_constraint_generatort::int_of_hex_char(const exprt &chr) const { exprt zero_char=constant_char('0', chr.type()); @@ -331,10 +406,19 @@ exprt string_constraint_generatort::int_of_hex_char(const exprt &chr) const minus_exprt(chr, zero_char)); } -/// add axioms stating that the returned string corresponds to the integer -/// argument written in hexadecimal -/// \par parameters: one integer argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_int_hex + + Inputs: one integer argument + + Outputs: a new string expression + + Purpose: add axioms stating that the returned string corresponds to the + integer argument written in hexadecimal + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_int_hex( const exprt &i, const refined_string_typet &ref_type) { @@ -388,9 +472,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int_hex( return res; } -/// add axioms corresponding to the Integer.toHexString(I) java function -/// \par parameters: function application with integer argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_int_hex + + Inputs: function application with integer argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the Integer.toHexString(I) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_int_hex( const function_application_exprt &f) { @@ -398,9 +491,18 @@ string_exprt string_constraint_generatort::add_axioms_from_int_hex( return add_axioms_from_int_hex(args(f, 1)[0], ref_type); } -/// add axioms corresponding to the String.valueOf(C) java function -/// \par parameters: function application one char argument -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_char + + Inputs: function application one char argument + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf(C) java function + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_char( const function_application_exprt &f) { @@ -408,10 +510,19 @@ string_exprt string_constraint_generatort::add_axioms_from_char( return add_axioms_from_char(args(f, 1)[0], ref_type); } -/// add axioms stating that the returned string has length 1 and the character -/// it contains correspond to the input expression -/// \par parameters: one expression of type char -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_from_char + + Inputs: one expression of type char + + Outputs: a new string expression + + Purpose: add axioms stating that the returned string has length 1 and + the character it contains correspond to the input expression + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_from_char( const exprt &c, const refined_string_typet &ref_type) { @@ -421,10 +532,19 @@ string_exprt string_constraint_generatort::add_axioms_from_char( return res; } -/// add axioms corresponding to the String.valueOf([C) and String.valueOf([CII) -/// functions -/// \par parameters: function application with one or three arguments -/// \return a new string expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_value_of + + Inputs: function application with one or three arguments + + Outputs: a new string expression + + Purpose: add axioms corresponding to the String.valueOf([C) and + String.valueOf([CII) functions + +\*******************************************************************/ + string_exprt string_constraint_generatort::add_axioms_for_value_of( const function_application_exprt &f) { @@ -458,10 +578,19 @@ string_exprt string_constraint_generatort::add_axioms_for_value_of( } } -/// add axioms making the return value true if the given string is a correct -/// number -/// \par parameters: function application with one string expression -/// \return an boolean expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_correct_number_format + + Inputs: function application with one string expression + + Outputs: an boolean expression + + Purpose: add axioms making the return value true if the given string is + a correct number + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_correct_number_format( const string_exprt &str, std::size_t max_size) { @@ -513,9 +642,18 @@ exprt string_constraint_generatort::add_axioms_for_correct_number_format( return correct; } -/// add axioms corresponding to the Integer.parseInt java function -/// \par parameters: function application with one string expression -/// \return an integer expression +/*******************************************************************\ + +Function: string_constraint_generatort::add_axioms_for_parse_int + + Inputs: function application with one string expression + + Outputs: an integer expression + + Purpose: add axioms corresponding to the Integer.parseInt java function + +\*******************************************************************/ + exprt string_constraint_generatort::add_axioms_for_parse_int( const function_application_exprt &f) { diff --git a/src/solvers/refinement/string_refinement.cpp b/src/solvers/refinement/string_refinement.cpp index 257fbf51e48..3c28e6f8fa3 100644 --- a/src/solvers/refinement/string_refinement.cpp +++ b/src/solvers/refinement/string_refinement.cpp @@ -10,13 +10,6 @@ Author: Alberto Griggio, alberto.griggio@gmail.com \*******************************************************************/ -/// \file -/// String support via creating string constraints and progressively -/// instantiating the universal constraints as needed. The procedure is -/// described in the PASS paper at HVC'13: "PASS: String Solving with -/// Parameterized Array and Interval Automaton" by Guodong Li and Indradeep -/// Ghosh. - #include #include #include @@ -29,6 +22,19 @@ Author: Alberto Griggio, alberto.griggio@gmail.com #include #include +/*******************************************************************\ + +Constructor: string_refinementt + + Inputs: + _ns - a namespace + _prop - a decision procedure + refinement_bound - a bound on the number of refinements + + Purpose: refinement_bound is a bound on the number of refinement allowed. + +\*******************************************************************/ + string_refinementt::string_refinementt( const namespacet &_ns, propt &_prop, @@ -40,31 +46,62 @@ string_refinementt::string_refinementt( non_empty_string(false) { } -/// Add constraints on the size of strings used in the program. -/// \param i: maximum length which is allowed for strings. -/// by default the strings length has no other limit -/// than the maximal integer according to the type of their -/// length, for instance 2^31-1 for Java. +/*******************************************************************\ + +Function: string_refinementt::set_max_string_length + + Inputs: + i - maximum length which is allowed for strings. + by default the strings length has no other limit + than the maximal integer according to the type of their + length, for instance 2^31-1 for Java. + + Purpose: Add constraints on the size of strings used in the + program. + +\*******************************************************************/ + void string_refinementt::set_max_string_length(size_t i) { generator.max_string_length=i; } -/// Add constraints on the size of nondet character arrays to ensure they have -/// length at least 1 +/*******************************************************************\ + +Function: string_refinementt::set_max_string_length + + Purpose: Add constraints on the size of nondet character arrays + to ensure they have length at least 1 + +\*******************************************************************/ + void string_refinementt::enforce_non_empty_string() { non_empty_string=true; } -/// Add constraints on characters used in the program to ensure they are -/// printable +/*******************************************************************\ + +Function: string_refinementt::enforce_printable_characters + + Purpose: Add constraints on characters used in the program + to ensure they are printable + +\*******************************************************************/ + void string_refinementt::enforce_printable_characters() { generator.force_printable_characters=true; } -/// display the current index set, for debugging +/*******************************************************************\ + +Function: string_refinementt::display_index_set + + Purpose: display the current index set, for debugging + +\*******************************************************************/ + void string_refinementt::display_index_set() { std::size_t count=0; @@ -90,8 +127,15 @@ void string_refinementt::display_index_set() << " newly added)" << eom; } -/// compute the index set for all formulas, instantiate the formulas with the -/// found indexes, and add them as lemmas. +/*******************************************************************\ + +Function: string_refinementt::add_instantiations + + Purpose: compute the index set for all formulas, instantiate the formulas + with the found indexes, and add them as lemmas. + +\*******************************************************************/ + void string_refinementt::add_instantiations() { debug() << "string_constraint_generatort::add_instantiations: " @@ -118,10 +162,19 @@ void string_refinementt::add_instantiations() } } -/// keeps a map of symbols to expressions, such as none of the mapped values -/// exist as a key -/// \param lhs: a symbol expression -/// \param rhs: an expression to map it to +/*******************************************************************\ + +Function: string_refinementt::add_symbol_to_symbol_map() + + Inputs: + lhs - a symbol expression + rhs - an expression to map it to + + Purpose: keeps a map of symbols to expressions, such as none of the + mapped values exist as a key + +\*******************************************************************/ + void string_refinementt::add_symbol_to_symbol_map( const exprt &lhs, const exprt &rhs) { @@ -143,8 +196,16 @@ void string_refinementt::add_symbol_to_symbol_map( } } -/// add axioms if the rhs is a character array -/// \par parameters: the rhs and lhs of an equality over character arrays +/*******************************************************************\ + +Function: string_refinementt::set_char_array_equality() + + Inputs: the rhs and lhs of an equality over character arrays + + Purpose: add axioms if the rhs is a character array + +\*******************************************************************/ + void string_refinementt::set_char_array_equality( const exprt &lhs, const exprt &rhs) { @@ -169,9 +230,19 @@ void string_refinementt::set_char_array_equality( // equality. Note that this might not be the case for other languages. } -/// remove functions applications and create the necessary axioms -/// \par parameters: an expression containing function applications -/// \return an epression containing no function application +/*******************************************************************\ + +Function: string_refinementt::substitute_function_applications() + + Inputs: an expression containing function applications + + Outputs: an epression containing no function application + + Purpose: remove functions applications and create the necessary + axioms + +\*******************************************************************/ + exprt string_refinementt::substitute_function_applications(exprt expr) { for(size_t i=0; i -/// 2, y -> -1. +/*******************************************************************\ + +Function: string_refinementt::map_representation_of_sum + + Inputs: an expression with only addition and substraction + + Outputs: a map where each leaf of the input is mapped to the number of times + it is added. For instance, expression $x + x - y$ would give the map + x -> 2, y -> -1. + +\*******************************************************************/ + std::map string_refinementt::map_representation_of_sum( const exprt &f) const { @@ -1099,10 +1336,18 @@ std::map string_refinementt::map_representation_of_sum( return elems; } -/// \par parameters: a map from expressions to integers -/// \return a expression for the sum of each element in the map a number of -/// times given by the corresponding integer in the map. For a map x -> 2, y -/// -> -1 would give an expression $x + x - y$. +/*******************************************************************\ + +Function: string_refinementt::sum_over_map + + Inputs: a map from expressions to integers + + Outputs: a expression for the sum of each element in the map a number of + times given by the corresponding integer in the map. + For a map x -> 2, y -> -1 would give an expression $x + x - y$. + +\*******************************************************************/ + exprt string_refinementt::sum_over_map( std::map &m, const typet &type, bool negated) const { @@ -1172,21 +1417,37 @@ exprt string_refinementt::sum_over_map( return index_const; } -/// \par parameters: an expression with only plus and minus expr -/// \return an equivalent expression in a cannonical form +/*******************************************************************\ + +Function: string_refinementt::simplify_sum + + Inputs: an expression with only plus and minus expr + + Outputs: an equivalent expression in a cannonical form + +\*******************************************************************/ + exprt string_refinementt::simplify_sum(const exprt &f) const { std::map map=map_representation_of_sum(f); return sum_over_map(map, f.type()); } -/// \par parameters: a symbol qvar, an expression val, an expression f -/// containing + and − -/// operations in which qvar should appear exactly once. -/// \return an expression corresponding of $f^{−1}(val)$ where $f$ is seen as -/// a function of $qvar$, i.e. the value that is necessary for qvar for f to -/// be equal to val. For instance, if `f` corresponds to the expression $q + -/// x$, `compute_inverse_function(q,v,f)` returns an expression for $v - x$. +/*******************************************************************\ + +Function: string_refinementt::compute_inverse_function + + Inputs: a symbol qvar, an expression val, an expression f containing + and − + operations in which qvar should appear exactly once. + + Outputs: an expression corresponding of $f^{−1}(val)$ where $f$ is seen as a + function of $qvar$, i.e. the value that is necessary for qvar for f + to be equal to val. For instance, if `f` corresponds to the expression + $q + x$, `compute_inverse_function(q,v,f)` returns an expression for + $v - x$. + +\*******************************************************************/ + exprt string_refinementt::compute_inverse_function( const exprt &qvar, const exprt &val, const exprt &f) { @@ -1236,9 +1497,18 @@ class find_qvar_visitort: public const_expr_visitort } }; -/// look for the symbol and return true if it is found -/// \par parameters: an index expression and a symbol qvar -/// \return a Boolean +/*******************************************************************\ + +Function: find_qvar + + Inputs: an index expression and a symbol qvar + + Outputs: a Boolean + + Purpose: look for the symbol and return true if it is found + +\*******************************************************************/ + static bool find_qvar(const exprt index, const symbol_exprt &qvar) { find_qvar_visitort v2(qvar); @@ -1246,9 +1516,17 @@ static bool find_qvar(const exprt index, const symbol_exprt &qvar) return v2.found; } -/// add to the index set all the indices that appear in the formulas and the -/// upper bound minus one -/// \par parameters: a list of string constraints +/*******************************************************************\ + +Function: string_refinementt::initial_index_set + + Inputs: a list of string constraints + + Purpose: add to the index set all the indices that appear in the formulas + and the upper bound minus one + +\*******************************************************************/ + void string_refinementt::initial_index_set( const std::vector &string_axioms) { @@ -1256,17 +1534,32 @@ void string_refinementt::initial_index_set( initial_index_set(axiom); } -/// add to the index set all the indices that appear in the formulas -/// \par parameters: a list of string constraints +/*******************************************************************\ + +Function: string_refinementt::update_index_set + + Inputs: a list of string constraints + + Purpose: add to the index set all the indices that appear in the formulas + +\*******************************************************************/ + void string_refinementt::update_index_set(const std::vector &cur) { for(const auto &axiom : cur) update_index_set(axiom); } -/// add to the index set all the indices that appear in the formula and the -/// upper bound minus one -/// \par parameters: a string constraint +/*******************************************************************\ + +Function: string_refinementt::initial_index_set + + Inputs: a string constraint + + Purpose: add to the index set all the indices that appear in the formula + and the upper bound minus one + +\*******************************************************************/ void string_refinementt::add_to_index_set(const exprt &s, exprt i) { simplify(i, ns); @@ -1327,8 +1620,16 @@ void string_refinementt::initial_index_set(const string_constraintt &axiom) } } -/// add to the index set all the indices that appear in the formula -/// \par parameters: a string constraint +/*******************************************************************\ + +Function: string_refinementt::update_index_set + + Inputs: a string constraint + + Purpose: add to the index set all the indices that appear in the formula + +\*******************************************************************/ + void string_refinementt::update_index_set(const exprt &formula) { std::list to_process; @@ -1376,10 +1677,20 @@ class find_index_visitort: public const_expr_visitort } }; -/// find an index used in the expression for str, for instance with arguments -/// (str[k] == 'a') and str, the function should return k -/// \par parameters: a formula expr and a char array str -/// \return an index expression +/*******************************************************************\ + +Function: string_refinementt::update_index_set + + Inputs: a formula expr and a char array str + + Outputs: an index expression + + Purpose: find an index used in the expression for str, for instance + with arguments (str[k] == 'a') and str, the function should + return k + +\*******************************************************************/ + exprt find_index(const exprt &expr, const exprt &str) { find_index_visitort v1(str); @@ -1391,13 +1702,21 @@ exprt find_index(const exprt &expr, const exprt &str) catch (exprt i) { return i; } } -/// \par parameters: a universally quantified formula `axiom`, an array of char -/// variable `str`, and an index expression `val`. -/// \return substitute `qvar` the universally quantified variable of `axiom`, by -/// an index `val`, in `axiom`, so that the index used for `str` equals `val`. -/// For instance, if `axiom` corresponds to $\forall q. s[q+x]='a' && -/// t[q]='b'$, `instantiate(axom,s,v)` would return an expression for -/// $s[v]='a' && t[v-x]='b'$. +/*******************************************************************\ + +Function: string_refinementt::instantiate + + Inputs: a universally quantified formula `axiom`, an array of char + variable `str`, and an index expression `val`. + + Outputs: substitute `qvar` the universally quantified variable of `axiom`, by + an index `val`, in `axiom`, so that the index used for `str` equals + `val`. For instance, if `axiom` corresponds to + $\forall q. s[q+x]='a' && t[q]='b'$, `instantiate(axom,s,v)` + would return an expression for $s[v]='a' && t[v-x]='b'$. + +\*******************************************************************/ + exprt string_refinementt::instantiate( const string_constraintt &axiom, const exprt &str, const exprt &val) { @@ -1419,10 +1738,18 @@ exprt string_refinementt::instantiate( return implies_exprt(bounds, instance); } -/// instantiate a quantified formula representing `not_contains` by substituting -/// the quantifiers and generating axioms -/// \par parameters: a quantified formula representing `not_contains`, and a -/// list to which to add the created lemmas to +/*******************************************************************\ + +Function: string_refinementt::instantiate_not_contains + + Inputs: a quantified formula representing `not_contains`, and a + list to which to add the created lemmas to + + Purpose: instantiate a quantified formula representing `not_contains` + by substituting the quantifiers and generating axioms + +\*******************************************************************/ + void string_refinementt::instantiate_not_contains( const string_not_contains_constraintt &axiom, std::list &new_lemmas) { @@ -1474,9 +1801,18 @@ void string_refinementt::instantiate_not_contains( } } -/// replace array-lists by 'with' expressions -/// \par parameters: an expression containing array-list expressions -/// \return an epression containing no array-list +/*******************************************************************\ + +Function: string_refinementt::substitute_array_lists() + + Inputs: an expression containing array-list expressions + + Outputs: an epression containing no array-list + + Purpose: replace array-lists by 'with' expressions + +\*******************************************************************/ + exprt string_refinementt::substitute_array_lists(exprt expr) const { for(size_t i=0; i void string_refinementt::pad_vector( std::vector &concrete_array, diff --git a/src/solvers/sat/cnf.cpp b/src/solvers/sat/cnf.cpp index 98f4a1fb7d2..a69947df8f4 100644 --- a/src/solvers/sat/cnf.cpp +++ b/src/solvers/sat/cnf.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CNF Generation, via Tseitin - #include #include #include @@ -17,10 +14,19 @@ Author: Daniel Kroening, kroening@kroening.com #include "cnf.h" // #define VERBOSE -/// Tseitin encoding of conjunction of two literals -/// \par parameters: Two input signals to the AND gate, one output -/// \return Side effect: add clauses that encodes relation between inputs/output -/// via lcnf +/*******************************************************************\ + +Function: cnft::gate_and + + Inputs: Two input signals to the AND gate, one output + + Outputs: Side effect: add clauses that encodes relation between + inputs/output via lcnf + + Purpose: Tseitin encoding of conjunction of two literals + +\*******************************************************************/ + void cnft::gate_and(literalt a, literalt b, literalt o) { // a*b=c <==> (a + o')( b + o')(a'+b'+o) @@ -42,8 +48,18 @@ void cnft::gate_and(literalt a, literalt b, literalt o) lcnf(lits); } -/// Tseitin encoding of disjunction of two literals -/// \par parameters: Two input signals to the OR gate, one output +/*******************************************************************\ + +Function: cnft::gate_or + + Inputs: Two input signals to the OR gate, one output + + Outputs: + + Purpose: Tseitin encoding of disjunction of two literals + +\*******************************************************************/ + void cnft::gate_or(literalt a, literalt b, literalt o) { // a+b=c <==> (a' + c)( b' + c)(a + b + c') @@ -64,8 +80,18 @@ void cnft::gate_or(literalt a, literalt b, literalt o) lcnf(lits); } -/// Tseitin encoding of XOR of two literals -/// \par parameters: Two input signals to the XOR gate, one output +/*******************************************************************\ + +Function: cnft::gate_xor + + Inputs: Two input signals to the XOR gate, one output + + Outputs: + + Purpose: Tseitin encoding of XOR of two literals + +\*******************************************************************/ + void cnft::gate_xor(literalt a, literalt b, literalt o) { // a xor b = o <==> (a' + b' + o') @@ -95,8 +121,18 @@ void cnft::gate_xor(literalt a, literalt b, literalt o) lcnf(lits); } -/// Tseitin encoding of NAND of two literals -/// \par parameters: Two input signals to the NAND gate, one output +/*******************************************************************\ + +Function: cnft::gate_nand + + Inputs: Two input signals to the NAND gate, one output + + Outputs: + + Purpose: Tseitin encoding of NAND of two literals + +\*******************************************************************/ + void cnft::gate_nand(literalt a, literalt b, literalt o) { // a Nand b = o <==> (a + o)( b + o)(a' + b' + o') @@ -117,8 +153,18 @@ void cnft::gate_nand(literalt a, literalt b, literalt o) lcnf(lits); } -/// Tseitin encoding of NOR of two literals -/// \par parameters: Two input signals to the NOR gate, one output +/*******************************************************************\ + +Function: cnft::gate_nor + + Inputs: Two input signals to the NOR gate, one output + + Outputs: + + Purpose: Tseitin encoding of NOR of two literals + +\*******************************************************************/ + void cnft::gate_nor(literalt a, literalt b, literalt o) { // a Nor b = o <==> (a' + o')( b' + o')(a + b + o) @@ -139,23 +185,52 @@ void cnft::gate_nor(literalt a, literalt b, literalt o) lcnf(lits); } -/// Tseitin encoding of equality between two literals -/// \par parameters: Two input signals to the EQUAL gate, one output +/*******************************************************************\ + +Function: cnft::gate_equal + + Inputs: Two input signals to the EQUAL gate, one output + + Outputs: + + Purpose: Tseitin encoding of equality between two literals + +\*******************************************************************/ + void cnft::gate_equal(literalt a, literalt b, literalt o) { gate_xor(a, b, !o); } -/// Tseitin encoding of implication between two literals -/// \par parameters: Two input signals to the IMPLIES gate, one output +/*******************************************************************\ + +Function: cnft::gate_implies + + Inputs: Two input signals to the IMPLIES gate, one output + + Outputs: + + Purpose: Tseitin encoding of implication between two literals + +\*******************************************************************/ + void cnft::gate_implies(literalt a, literalt b, literalt o) { gate_or(!a, b, o); } -/// Tseitin encoding of conjunction between multiple literals -/// \par parameters: Any number of inputs to the AND gate -/// \return Output signal of the AND gate as literal +/*******************************************************************\ + +Function: cnft::land + + Inputs: Any number of inputs to the AND gate + + Outputs: Output signal of the AND gate as literal + + Purpose: Tseitin encoding of conjunction between multiple literals + +\*******************************************************************/ + literalt cnft::land(const bvt &bv) { if(bv.empty()) @@ -196,9 +271,18 @@ literalt cnft::land(const bvt &bv) return literal; } -/// Tseitin encoding of disjunction between multiple literals -/// \par parameters: Any number of inputs to the OR gate -/// \return Output signal of the OR gate as literal +/*******************************************************************\ + +Function: cnft::lor + + Inputs: Any number of inputs to the OR gate + + Outputs: Output signal of the OR gate as literal + + Purpose: Tseitin encoding of disjunction between multiple literals + +\*******************************************************************/ + literalt cnft::lor(const bvt &bv) { if(bv.empty()) @@ -239,9 +323,18 @@ literalt cnft::lor(const bvt &bv) return literal; } -/// Tseitin encoding of XOR between multiple literals -/// \par parameters: Any number of inputs to the XOR gate -/// \return Output signal of the XOR gate as literal +/*******************************************************************\ + +Function: cnft::lxor + + Inputs: Any number of inputs to the XOR gate + + Outputs: Output signal of the XOR gate as literal + + Purpose: Tseitin encoding of XOR between multiple literals + +\*******************************************************************/ + literalt cnft::lxor(const bvt &bv) { if(bv.empty()) @@ -259,8 +352,18 @@ literalt cnft::lxor(const bvt &bv) return literal; } -/// \par parameters: Two inputs to the AND gate -/// \return Output signal of the AND gate as literal +/*******************************************************************\ + +Function: cnft::land + + Inputs: Two inputs to the AND gate + + Outputs: Output signal of the AND gate as literal + + Purpose: + +\*******************************************************************/ + literalt cnft::land(literalt a, literalt b) { if(a.is_true() || b.is_false()) @@ -275,8 +378,18 @@ literalt cnft::land(literalt a, literalt b) return o; } -/// \par parameters: Two inputs to the OR gate -/// \return Output signal of the OR gate as literal +/*******************************************************************\ + +Function: cnft::lor + + Inputs: Two inputs to the OR gate + + Outputs: Output signal of the OR gate as literal + + Purpose: + +\*******************************************************************/ + literalt cnft::lor(literalt a, literalt b) { if(a.is_false() || b.is_true()) @@ -291,8 +404,18 @@ literalt cnft::lor(literalt a, literalt b) return o; } -/// \par parameters: Two inputs to the XOR gate -/// \return Output signal of the XOR gate as literal +/*******************************************************************\ + +Function: cnft::lxor + + Inputs: Two inputs to the XOR gate + + Outputs: Output signal of the XOR gate as literal + + Purpose: + +\*******************************************************************/ + literalt cnft::lxor(literalt a, literalt b) { if(a.is_false()) @@ -313,30 +436,86 @@ literalt cnft::lxor(literalt a, literalt b) return o; } -/// \par parameters: Two inputs to the NAND gate -/// \return Output signal of the NAND gate as literal +/*******************************************************************\ + +Function: cnft::lnand + + Inputs: Two inputs to the NAND gate + + Outputs: Output signal of the NAND gate as literal + + Purpose: + +\*******************************************************************/ + literalt cnft::lnand(literalt a, literalt b) { return !land(a, b); } -/// \par parameters: Two inputs to the NOR gate -/// \return Output signal of the NOR gate as literal +/*******************************************************************\ + +Function: cnft::lnor + + Inputs: Two inputs to the NOR gate + + Outputs: Output signal of the NOR gate as literal + + Purpose: + +\*******************************************************************/ + literalt cnft::lnor(literalt a, literalt b) { return !lor(a, b); } +/*******************************************************************\ + +Function: cnft::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cnft::lequal(literalt a, literalt b) { return !lxor(a, b); } +/*******************************************************************\ + +Function: cnft::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt cnft::limplies(literalt a, literalt b) { return lor(!a, b); } +/*******************************************************************\ + +Function: cnft::lselect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // Tino observed slow-downs up to 50% with OPTIMAL_COMPACT_ITE. #define COMPACT_ITE @@ -381,8 +560,18 @@ literalt cnft::lselect(literalt a, literalt b, literalt c) #endif } -/// Generate a new variable and return it as a literal -/// \return New variable as literal +/*******************************************************************\ + +Function: cnft::new_variable + + Inputs: + + Outputs: New variable as literal + + Purpose: Generate a new variable and return it as a literal + +\*******************************************************************/ + literalt cnft::new_variable() { literalt l; @@ -393,9 +582,18 @@ literalt cnft::new_variable() return l; } -/// eliminate duplicates from given vector of literals -/// \par parameters: set of literals given as vector -/// \return set of literals, duplicates removed +/*******************************************************************\ + +Function: cnft::eliminate_duplicates + + Inputs: set of literals given as vector + + Outputs: set of literals, duplicates removed + + Purpose: eliminate duplicates from given vector of literals + +\*******************************************************************/ + bvt cnft::eliminate_duplicates(const bvt &bv) { std::set s; @@ -410,8 +608,19 @@ bvt cnft::eliminate_duplicates(const bvt &bv) return dest; } -/// filter 'true' from clause, eliminate duplicates, recognise trivially -/// satisfied clauses +/*******************************************************************\ + +Function: cnft::process_clause + + Inputs: + + Outputs: + + Purpose: filter 'true' from clause, eliminate duplicates, + recognise trivially satisfied clauses + +\*******************************************************************/ + bool cnft::process_clause(const bvt &bv, bvt &dest) { dest.clear(); diff --git a/src/solvers/sat/cnf.h b/src/solvers/sat/cnf.h index 236de673374..644d62999e4 100644 --- a/src/solvers/sat/cnf.h +++ b/src/solvers/sat/cnf.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CNF Generation, via Tseitin - #ifndef CPROVER_SOLVERS_SAT_CNF_H #define CPROVER_SOLVERS_SAT_CNF_H diff --git a/src/solvers/sat/cnf_clause_list.cpp b/src/solvers/sat/cnf_clause_list.cpp index cb68ddad24b..629a7363795 100644 --- a/src/solvers/sat/cnf_clause_list.cpp +++ b/src/solvers/sat/cnf_clause_list.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// CNF Generation - #include #include #include "cnf_clause_list.h" +/*******************************************************************\ + +Function: cnf_clause_listt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cnf_clause_listt::lcnf(const bvt &bv) { bvt new_bv; @@ -24,12 +33,36 @@ void cnf_clause_listt::lcnf(const bvt &bv) clauses.push_back(new_bv); } +/*******************************************************************\ + +Function: cnf_clause_list_assignmentt::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cnf_clause_list_assignmentt::print_assignment(std::ostream &out) const { for(unsigned v=1; v +/*******************************************************************\ + +Function: dimacs_cnft::dimacs_cnft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dimacs_cnft::dimacs_cnft():break_lines(false) { } +/*******************************************************************\ + +Function: dimacs_cnf_dumpt::dimacs_cnf_dumpt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + dimacs_cnf_dumpt::dimacs_cnf_dumpt(std::ostream &_out):out(_out) { } +/*******************************************************************\ + +Function: dimacs_cnft::write_dimacs_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dimacs_cnft::write_dimacs_cnf(std::ostream &out) { write_problem_line(out); write_clauses(out); } +/*******************************************************************\ + +Function: dimacs_cnft::write_problem_line + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dimacs_cnft::write_problem_line(std::ostream &out) { // We start counting at 1, thus there is one variable fewer. @@ -31,6 +79,18 @@ void dimacs_cnft::write_problem_line(std::ostream &out) << clauses.size() << "\n"; } +/*******************************************************************\ + +Function: write_dimacs_clause + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void write_dimacs_clause( const bvt &clause, std::ostream &out, @@ -57,6 +117,18 @@ static void write_dimacs_clause( out << "0" << "\n"; } +/*******************************************************************\ + +Function: dimacs_cnft::write_clauses + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dimacs_cnft::write_clauses(std::ostream &out) { for(clausest::const_iterator it=clauses.begin(); @@ -64,6 +136,18 @@ void dimacs_cnft::write_clauses(std::ostream &out) write_dimacs_clause(*it, out, break_lines); } +/*******************************************************************\ + +Function: dimacs_cnf_dumpt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void dimacs_cnf_dumpt::lcnf(const bvt &bv) { write_dimacs_clause(bv, out, true); diff --git a/src/solvers/sat/pbs_dimacs_cnf.cpp b/src/solvers/sat/pbs_dimacs_cnf.cpp index a648a2cb8e1..5c45f8e0a09 100644 --- a/src/solvers/sat/pbs_dimacs_cnf.cpp +++ b/src/solvers/sat/pbs_dimacs_cnf.cpp @@ -13,6 +13,18 @@ Author: Alex Groce #include "pbs_dimacs_cnf.h" +/*******************************************************************\ + +Function: pbs_dimacs_cnft::write_dimacs_cnf_pb + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out) { double d_sum=0; @@ -52,6 +64,18 @@ void pbs_dimacs_cnft::write_dimacs_pb(std::ostream &out) // std::cout << "exit: No Lit.=" << no_variables () << "\n"; } +/*******************************************************************\ + +Function: pbs_dimacs_cnft::pbs_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool pbs_dimacs_cnft::pbs_solve() { // std::cout << "solve: No Lit.=" << no_variables () << "\n"; @@ -176,6 +200,18 @@ bool pbs_dimacs_cnft::pbs_solve() return satisfied; } +/*******************************************************************\ + +Function: pbs_dimacs_cnft::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt pbs_dimacs_cnft::prop_solve() { std::ofstream file("temp.cnf"); @@ -216,6 +252,18 @@ propt::resultt pbs_dimacs_cnft::prop_solve() return resultt::P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: pbs_dimacs_cnft::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt pbs_dimacs_cnft::l_get(literalt a) const { int dimacs_lit=a.dimacs(); diff --git a/src/solvers/sat/read_dimacs_cnf.cpp b/src/solvers/sat/read_dimacs_cnf.cpp index f3996fb13de..42e63a5e9e2 100644 --- a/src/solvers/sat/read_dimacs_cnf.cpp +++ b/src/solvers/sat/read_dimacs_cnf.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Reading DIMACS CNF - #include #include // for abs() @@ -18,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com // #define VERBOSE +/*******************************************************************\ + +Function: cnft::read_dimacs_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void read_dimacs_cnf(std::istream &in, cnft &dest) { #define DELIMITERS "\t\n\v\f\r " diff --git a/src/solvers/sat/read_dimacs_cnf.h b/src/solvers/sat/read_dimacs_cnf.h index 96bb752867a..2a0c0cb3950 100644 --- a/src/solvers/sat/read_dimacs_cnf.h +++ b/src/solvers/sat/read_dimacs_cnf.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Reading DIMACS CNF - #ifndef CPROVER_SOLVERS_SAT_READ_DIMACS_CNF_H #define CPROVER_SOLVERS_SAT_READ_DIMACS_CNF_H diff --git a/src/solvers/sat/resolution_proof.cpp b/src/solvers/sat/resolution_proof.cpp index 76cc6c5f69f..20c10498a96 100644 --- a/src/solvers/sat/resolution_proof.cpp +++ b/src/solvers/sat/resolution_proof.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "resolution_proof.h" +/*******************************************************************\ + +Function: resolution_prooft::build_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void resolution_prooft::build_core(std::vector &in_core) { diff --git a/src/solvers/sat/satcheck_booleforce.cpp b/src/solvers/sat/satcheck_booleforce.cpp index 2bbe9da61aa..16a23f152f9 100644 --- a/src/solvers/sat/satcheck_booleforce.cpp +++ b/src/solvers/sat/satcheck_booleforce.cpp @@ -16,21 +16,69 @@ extern "C" #include "booleforce.h" } +/*******************************************************************\ + +Function: satcheck_booleforcet::satcheck_booleforcet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_booleforcet::satcheck_booleforcet() { booleforce_set_trace(false); } +/*******************************************************************\ + +Function: satcheck_booleforce_coret::satcheck_booleforce_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_booleforce_coret::satcheck_booleforce_coret() { booleforce_set_trace(true); } +/*******************************************************************\ + +Function: satcheck_booleforce_baset::~satcheck_booleforce_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_booleforce_baset::~satcheck_booleforce_baset() { booleforce_reset(); } +/*******************************************************************\ + +Function: satcheck_booleforce_baset::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_booleforce_baset::l_get(literalt a) const { assert(status==SAT); @@ -60,11 +108,35 @@ tvt satcheck_booleforce_baset::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_booleforce_Baset::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_booleforce_baset::solver_text() { return std::string("Booleforce version ")+booleforce_version(); } +/*******************************************************************\ + +Function: satcheck_booleforce_baset::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_booleforce_baset::lcnf(const bvt &bv) { bvt tmp; @@ -81,6 +153,18 @@ void satcheck_booleforce_baset::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_booleforce_baset::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_booleforce_baset::prop_solve() { assert(status==SAT || status==INIT); @@ -125,6 +209,18 @@ propt::resultt satcheck_booleforce_baset::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: satcheck_booleforce_coret::in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool satcheck_booleforce_coret::is_in_core(literalt l) const { return booleforce_var_in_core(l.var_no()); diff --git a/src/solvers/sat/satcheck_glucose.cpp b/src/solvers/sat/satcheck_glucose.cpp index 9d559111069..152716d8157 100644 --- a/src/solvers/sat/satcheck_glucose.cpp +++ b/src/solvers/sat/satcheck_glucose.cpp @@ -24,6 +24,18 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_GLUCOSE" #endif +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const bvt &bv, Glucose::vec &dest) { dest.capacity(bv.size()); @@ -33,6 +45,18 @@ void convert(const bvt &bv, Glucose::vec &dest) dest.push(Glucose::mkLit(it->var_no(), it->sign())); } +/*******************************************************************\ + +Function: satcheck_glucose_baset::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template tvt satcheck_glucose_baset::l_get(literalt a) const { @@ -61,6 +85,18 @@ tvt satcheck_glucose_baset::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::set_polarity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_glucose_baset::set_polarity(literalt a, bool value) { @@ -69,16 +105,52 @@ void satcheck_glucose_baset::set_polarity(literalt a, bool value) solver->setPolarity(a.var_no(), value); } +/*******************************************************************\ + +Function: satcheck_glucose_no_simplifiert::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_glucose_no_simplifiert::solver_text() { return "Glucose Syrup without simplifier"; } +/*******************************************************************\ + +Function: satcheck_glucose_simplifiert::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_glucose_simplifiert::solver_text() { return "Glucose Syrup with simplifier"; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::add_variables + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_glucose_baset::add_variables() { @@ -86,6 +158,18 @@ void satcheck_glucose_baset::add_variables() solver->newVar(); } +/*******************************************************************\ + +Function: satcheck_glucose_baset::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_glucose_baset::lcnf(const bvt &bv) { @@ -111,6 +195,18 @@ void satcheck_glucose_baset::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template propt::resultt satcheck_glucose_baset::prop_solve() { @@ -169,6 +265,18 @@ propt::resultt satcheck_glucose_baset::prop_solve() return P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_glucose_baset::set_assignment(literalt a, bool value) { @@ -183,12 +291,36 @@ void satcheck_glucose_baset::set_assignment(literalt a, bool value) solver->model[v]=Glucose::lbool(value); } +/*******************************************************************\ + +Function: satcheck_glucose_baset::satcheck_glucose_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template satcheck_glucose_baset::satcheck_glucose_baset(T *_solver): solver(_solver) { } +/*******************************************************************\ + +Function: satcheck_glucose_baset::~satcheck_glucose_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> satcheck_glucose_baset::~satcheck_glucose_baset() { @@ -201,6 +333,18 @@ satcheck_glucose_baset::~satcheck_glucose_baset() delete solver; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::is_in_conflict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template bool satcheck_glucose_baset::is_in_conflict(literalt a) const { @@ -213,6 +357,18 @@ bool satcheck_glucose_baset::is_in_conflict(literalt a) const return false; } +/*******************************************************************\ + +Function: satcheck_glucose_baset::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_glucose_baset::set_assumptions(const bvt &bv) { @@ -222,16 +378,52 @@ void satcheck_glucose_baset::set_assumptions(const bvt &bv) assert(!it->is_constant()); } +/*******************************************************************\ + +Function: satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_glucose_no_simplifiert::satcheck_glucose_no_simplifiert(): satcheck_glucose_baset(new Glucose::Solver) { } +/*******************************************************************\ + +Function: satcheck_glucose_simplifiert::satcheck_glucose_simplifiert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_glucose_simplifiert::satcheck_glucose_simplifiert(): satcheck_glucose_baset(new Glucose::SimpSolver) { } +/*******************************************************************\ + +Function: satcheck_glucose_simplifiert::set_frozen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_glucose_simplifiert::set_frozen(literalt a) { if(!a.is_constant()) @@ -241,6 +433,18 @@ void satcheck_glucose_simplifiert::set_frozen(literalt a) } } +/*******************************************************************\ + +Function: satcheck_glucose_simplifiert::is_eliminated + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool satcheck_glucose_simplifiert::is_eliminated(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_limmat.cpp b/src/solvers/sat/satcheck_limmat.cpp index d1c92d81b58..a8393cf30e8 100644 --- a/src/solvers/sat/satcheck_limmat.cpp +++ b/src/solvers/sat/satcheck_limmat.cpp @@ -16,17 +16,53 @@ extern "C" #include "limmat.h" } +/*******************************************************************\ + +Function: satcheck_limmatt::satcheck_limmatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_limmatt::satcheck_limmatt() { solver=new_Limmat(NULL); } +/*******************************************************************\ + +Function: satcheck_limmatt::~satcheck_limmatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_limmatt::~satcheck_limmatt() { if(solver!=NULL) delete_Limmat(solver); } +/*******************************************************************\ + +Function: satcheck_limmatt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_limmatt::l_get(literalt a) const { if(a.is_true()) @@ -52,11 +88,35 @@ tvt satcheck_limmatt::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_limmatt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_limmatt::solver_text() { return std::string("Limmat version ")+version_Limmat(); } +/*******************************************************************\ + +Function: satcheck_limmatt::copy_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_limmatt::copy_cnf() { for(clausest::iterator it=clauses.begin(); @@ -78,6 +138,18 @@ void satcheck_limmatt::copy_cnf() } } +/*******************************************************************\ + +Function: satcheck_limmatt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_limmatt::prop_solve() { copy_cnf(); diff --git a/src/solvers/sat/satcheck_lingeling.cpp b/src/solvers/sat/satcheck_lingeling.cpp index 90aa2824c98..18237a903ab 100644 --- a/src/solvers/sat/satcheck_lingeling.cpp +++ b/src/solvers/sat/satcheck_lingeling.cpp @@ -21,6 +21,18 @@ extern "C" #error "Expected HAVE_LINGELING" #endif +/*******************************************************************\ + +Function: satcheck_lingelingt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_lingelingt::l_get(literalt a) const { if(a.is_constant()) @@ -42,11 +54,35 @@ tvt satcheck_lingelingt::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_lingelingt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_lingelingt::solver_text() { return "Lingeling"; } +/*******************************************************************\ + +Function: satcheck_lingelingt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_lingelingt::lcnf(const bvt &bv) { bvt new_bv; @@ -62,6 +98,18 @@ void satcheck_lingelingt::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_lingelingt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_lingelingt::prop_solve() { assert(status!=ERROR); @@ -98,22 +146,70 @@ propt::resultt satcheck_lingelingt::prop_solve() return P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: satcheck_lingelingt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_lingelingt::set_assignment(literalt a, bool value) { assert(false); } +/*******************************************************************\ + +Function: satcheck_lingelingt::satcheck_lingelingt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_lingelingt::satcheck_lingelingt() : solver(lglinit()) { } +/*******************************************************************\ + +Function: satcheck_lingelingt::satcheck_lingelingt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_lingelingt::~satcheck_lingelingt() { lglrelease(solver); solver=0; } +/*******************************************************************\ + +Function: satcheck_lingelingt::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_lingelingt::set_assumptions(const bvt &bv) { assumptions=bv; @@ -122,16 +218,40 @@ void satcheck_lingelingt::set_assumptions(const bvt &bv) assert(!it->is_constant()); } +/*******************************************************************\ + +Function: satcheck_lingelingt::set_frozen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_lingelingt::set_frozen(literalt a) { if(!a.is_constant()) lglfreeze(solver, a.dimacs()); } -/// Returns true if an assumed literal is in conflict if the formula is UNSAT. -/// -/// NOTE: if the literal is not in the assumption it causes an -/// assertion failure in lingeling. +/*******************************************************************\ + +Function: satcheck_lingelingt::is_in_conflict + + Inputs: + + Outputs: + + Purpose: Returns true if an assumed literal is in conflict if the + formula is UNSAT. + + NOTE: if the literal is not in the assumption it causes an + assertion failure in lingeling. + +\*******************************************************************/ + bool satcheck_lingelingt::is_in_conflict(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_minisat.cpp b/src/solvers/sat/satcheck_minisat.cpp index 637985357c7..b615d04e112 100644 --- a/src/solvers/sat/satcheck_minisat.cpp +++ b/src/solvers/sat/satcheck_minisat.cpp @@ -20,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_MINISAT" #endif +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const bvt &bv, vec &dest) { dest.growTo(bv.size()); @@ -28,6 +40,14 @@ void convert(const bvt &bv, vec &dest) dest[i]=Lit(bv[i].var_no(), bv[i].sign()); } +/*******************************************************************\ + + Class: minisat_prooft + + Purpose: + +\*******************************************************************/ + class minisat_prooft:public ProofTraverser { public: @@ -56,6 +76,18 @@ class minisat_prooft:public ProofTraverser simple_prooft resolution_proof; }; +/*******************************************************************\ + +Function: minisat_prooft::chain + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void minisat_prooft::chain(const vec &cs, const vec &xs) { assert(cs.size()==xs.size()+1); @@ -80,6 +112,18 @@ void minisat_prooft::chain(const vec &cs, const vec &xs) } } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_minisat1_baset::l_get(literalt a) const { if(a.is_true()) @@ -105,17 +149,53 @@ tvt satcheck_minisat1_baset::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_minisat1_baset::solver_text() { return "MiniSAT 1.14p"; } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::add_variables + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_minisat1_baset::add_variables() { while((unsigned)solver->nVars()newVar(); } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_minisat1_baset::lcnf(const bvt &bv) { bvt new_bv; @@ -143,6 +223,18 @@ void satcheck_minisat1_baset::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_minisat1_baset::prop_solve() { assert(status!=ERROR); @@ -188,6 +280,18 @@ propt::resultt satcheck_minisat1_baset::prop_solve() return P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_minisat1_baset::set_assignment(literalt a, bool value) { unsigned v=a.var_no(); @@ -197,6 +301,18 @@ void satcheck_minisat1_baset::set_assignment(literalt a, bool value) solver->model[v]=lbool(value); } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::is_in_conflict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool satcheck_minisat1_baset::is_in_conflict(literalt a) const { int v=a.var_no(); @@ -210,6 +326,18 @@ bool satcheck_minisat1_baset::is_in_conflict(literalt a) const return false; } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_minisat1_baset::set_assumptions(const bvt &bv) { assumptions=bv; @@ -220,12 +348,36 @@ void satcheck_minisat1_baset::set_assumptions(const bvt &bv) assert(!it->is_constant()); } +/*******************************************************************\ + +Function: satcheck_minisat1t::satcheck_minisat1t + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1t::satcheck_minisat1t() { empty_clause_added=false; solver=new Solver; } +/*******************************************************************\ + +Function: satcheck_minisat1_prooft::satcheck_minisat1_prooft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1_prooft::satcheck_minisat1_prooft():satcheck_minisat1t() { minisat_proof=new minisat_prooft; @@ -234,30 +386,102 @@ satcheck_minisat1_prooft::satcheck_minisat1_prooft():satcheck_minisat1t() solver->proof=proof; } +/*******************************************************************\ + +Function: satcheck_minisat1_prooft::~satcheck_minisat1_prooft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1_prooft::~satcheck_minisat1_prooft() { delete proof; delete minisat_proof; } +/*******************************************************************\ + +Function: satcheck_minisat1_coret::satcheck_minisat1_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1_coret::satcheck_minisat1_coret() { } +/*******************************************************************\ + +Function: satcheck_minisat1_coret::~satcheck_minisat1_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1_coret::~satcheck_minisat1_coret() { } +/*******************************************************************\ + +Function: satcheck_minisat1_baset::~satcheck_minisat1_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat1_baset::~satcheck_minisat1_baset() { delete solver; } +/*******************************************************************\ + +Function: satcheck_minisat1_prooft::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_minisat1_prooft::solver_text() { return "MiniSAT + Proof"; } +/*******************************************************************\ + +Function: satcheck_minisat1_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_minisat1_coret::prop_solve() { propt::resultt r; @@ -273,11 +497,35 @@ propt::resultt satcheck_minisat1_coret::prop_solve() return r; } +/*******************************************************************\ + +Function: satcheck_minisat1_coret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_minisat1_coret::solver_text() { return "MiniSAT + Core"; } +/*******************************************************************\ + +Function: satcheck_minisat1_prooft::get_resolution_proof + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + simple_prooft &satcheck_minisat1_prooft::get_resolution_proof() { return minisat_proof->resolution_proof; diff --git a/src/solvers/sat/satcheck_minisat2.cpp b/src/solvers/sat/satcheck_minisat2.cpp index bd522867b10..eaccd29db64 100644 --- a/src/solvers/sat/satcheck_minisat2.cpp +++ b/src/solvers/sat/satcheck_minisat2.cpp @@ -24,6 +24,18 @@ Author: Daniel Kroening, kroening@kroening.com #error "Expected HAVE_MINISAT2" #endif +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert(const bvt &bv, Minisat::vec &dest) { dest.capacity(bv.size()); @@ -33,6 +45,18 @@ void convert(const bvt &bv, Minisat::vec &dest) dest.push(Minisat::mkLit(it->var_no(), it->sign())); } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template tvt satcheck_minisat2_baset::l_get(literalt a) const { @@ -61,6 +85,18 @@ tvt satcheck_minisat2_baset::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::set_polarity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_minisat2_baset::set_polarity(literalt a, bool value) { @@ -69,16 +105,52 @@ void satcheck_minisat2_baset::set_polarity(literalt a, bool value) solver->setPolarity(a.var_no(), value); } +/*******************************************************************\ + +Function: satcheck_minisat_no_simplifiert::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_minisat_no_simplifiert::solver_text() { return "MiniSAT 2.2.1 without simplifier"; } +/*******************************************************************\ + +Function: satcheck_minisat_simplifiert::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_minisat_simplifiert::solver_text() { return "MiniSAT 2.2.1 with simplifier"; } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::add_variables + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_minisat2_baset::add_variables() { @@ -86,6 +158,18 @@ void satcheck_minisat2_baset::add_variables() solver->newVar(); } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_minisat2_baset::lcnf(const bvt &bv) { @@ -111,6 +195,18 @@ void satcheck_minisat2_baset::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template propt::resultt satcheck_minisat2_baset::prop_solve() { @@ -178,6 +274,18 @@ propt::resultt satcheck_minisat2_baset::prop_solve() } } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_minisat2_baset::set_assignment(literalt a, bool value) { @@ -192,12 +300,36 @@ void satcheck_minisat2_baset::set_assignment(literalt a, bool value) solver->model[v]=Minisat::lbool(value); } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::satcheck_minisat2_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template satcheck_minisat2_baset::satcheck_minisat2_baset(T *_solver): solver(_solver) { } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::~satcheck_minisat2_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> satcheck_minisat2_baset::~satcheck_minisat2_baset() { @@ -210,6 +342,18 @@ satcheck_minisat2_baset::~satcheck_minisat2_baset() delete solver; } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::is_in_conflict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template bool satcheck_minisat2_baset::is_in_conflict(literalt a) const { @@ -222,6 +366,18 @@ bool satcheck_minisat2_baset::is_in_conflict(literalt a) const return false; } +/*******************************************************************\ + +Function: satcheck_minisat2_baset::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void satcheck_minisat2_baset::set_assumptions(const bvt &bv) { @@ -235,16 +391,52 @@ void satcheck_minisat2_baset::set_assumptions(const bvt &bv) } } +/*******************************************************************\ + +Function: satcheck_minisat_no_simplifiert::satcheck_minisat_no_simplifiert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat_no_simplifiert::satcheck_minisat_no_simplifiert(): satcheck_minisat2_baset(new Minisat::Solver) { } +/*******************************************************************\ + +Function: satcheck_minisat_simplifiert::satcheck_minisat_simplifiert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_minisat_simplifiert::satcheck_minisat_simplifiert(): satcheck_minisat2_baset(new Minisat::SimpSolver) { } +/*******************************************************************\ + +Function: satcheck_minisat_simplifiert::set_frozen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_minisat_simplifiert::set_frozen(literalt a) { if(!a.is_constant()) @@ -254,6 +446,18 @@ void satcheck_minisat_simplifiert::set_frozen(literalt a) } } +/*******************************************************************\ + +Function: satcheck_minisat_simplifiert::is_eliminated + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool satcheck_minisat_simplifiert::is_eliminated(literalt a) const { assert(!a.is_constant()); diff --git a/src/solvers/sat/satcheck_picosat.cpp b/src/solvers/sat/satcheck_picosat.cpp index a4bd562fa47..7c3417592a3 100644 --- a/src/solvers/sat/satcheck_picosat.cpp +++ b/src/solvers/sat/satcheck_picosat.cpp @@ -21,6 +21,18 @@ extern "C" #error "Expected HAVE_PICOSAT" #endif +/*******************************************************************\ + +Function: satcheck_picosatt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_picosatt::l_get(literalt a) const { if(a.is_constant()) @@ -42,11 +54,35 @@ tvt satcheck_picosatt::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_picosatt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_picosatt::solver_text() { return "PicoSAT"; } +/*******************************************************************\ + +Function: satcheck_picosatt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_picosatt::lcnf(const bvt &bv) { bvt new_bv; @@ -64,6 +100,18 @@ void satcheck_picosatt::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_picosatt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_picosatt::prop_solve() { assert(status!=ERROR); @@ -99,21 +147,69 @@ propt::resultt satcheck_picosatt::prop_solve() return P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: satcheck_picosatt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_picosatt::set_assignment(literalt a, bool value) { assert(false); } +/*******************************************************************\ + +Function: satcheck_picosatt::satcheck_picosatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_picosatt::satcheck_picosatt() { picosat = picosat_init(); } +/*******************************************************************\ + +Function: satcheck_picosatt::~satcheck_picosatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_picosatt::~satcheck_picosatt() { picosat_reset(picosat); } +/*******************************************************************\ + +Function: satcheck_picosatt::is_in_conflict + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool satcheck_picosatt::is_in_conflict(literalt a) const { assert(!a.is_constant()); @@ -121,6 +217,18 @@ bool satcheck_picosatt::is_in_conflict(literalt a) const return picosat_failed_assumption(picosat, a.dimacs())!=0; } +/*******************************************************************\ + +Function: satcheck_picosatt::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_picosatt::set_assumptions(const bvt &bv) { assumptions=bv; diff --git a/src/solvers/sat/satcheck_precosat.cpp b/src/solvers/sat/satcheck_precosat.cpp index 5041985a3a6..7589d085678 100644 --- a/src/solvers/sat/satcheck_precosat.cpp +++ b/src/solvers/sat/satcheck_precosat.cpp @@ -20,6 +20,18 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #define precosat_lit(a) ((a).var_no()*2 + !(a).sign()) +/*******************************************************************\ + +Function: satcheck_precosatt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_precosatt::l_get(literalt a) const { if(a.is_constant()) @@ -41,11 +53,35 @@ tvt satcheck_precosatt::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_precosatt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_precosatt::solver_text() { return "PrecoSAT"; } +/*******************************************************************\ + +Function: satcheck_precosatt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_precosatt::lcnf(const bvt &bv) { bvt new_bv; @@ -61,6 +97,18 @@ void satcheck_precosatt::lcnf(const bvt &bv) clause_counter++; } +/*******************************************************************\ + +Function: satcheck_precosatt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_precosatt::prop_solve() { assert(status!=ERROR); @@ -94,22 +142,70 @@ propt::resultt satcheck_precosatt::prop_solve() return P_UNSATISFIABLE; } +/*******************************************************************\ + +Function: satcheck_precosatt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_precosatt::set_assignment(literalt a, bool value) { assert(false); } +/*******************************************************************\ + +Function: satcheck_precosatt::satcheck_precosatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_precosatt::satcheck_precosatt() : solver(new PrecoSat::Solver()) { solver->init(); } +/*******************************************************************\ + +Function: satcheck_precosatt::~satcheck_precosatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_precosatt::~satcheck_precosatt() { delete solver; } +/*******************************************************************\ + +Function: satcheck_precosatt::set_assumptions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + /* void satcheck_precosatt::set_assumptions(const bvt &bv) { diff --git a/src/solvers/sat/satcheck_smvsat.cpp b/src/solvers/sat/satcheck_smvsat.cpp index d1f14d50f7c..8064900735d 100644 --- a/src/solvers/sat/satcheck_smvsat.cpp +++ b/src/solvers/sat/satcheck_smvsat.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +/*******************************************************************\ + +Function: satcheck_smvsatt::satcheck_smvsatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_smvsatt::satcheck_smvsatt() { satsolver= @@ -24,14 +36,50 @@ satcheck_smvsatt::satcheck_smvsatt() init_const(); } +/*******************************************************************\ + +Function: satcheck_smvsat_coret::satcheck_smvsat_coret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_smvsat_coret::satcheck_smvsat_coret() { } +/*******************************************************************\ + +Function: satcheck_smvsatt::~satcheck_smvsatt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_smvsatt::~satcheck_smvsatt() { } +/*******************************************************************\ + +Function: satcheck_smvsatt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_smvsatt::l_get(literalt a) const { assert(status==SAT); @@ -57,11 +105,35 @@ tvt satcheck_smvsatt::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_smvsatt::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_smvsatt::solver_text() { return std::string("SMVSAT"); } +/*******************************************************************\ + +Function: satcheck_smvsatt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_smvsatt::lcnf(const bvt &bv) { bvt tmp; @@ -84,6 +156,18 @@ void satcheck_smvsatt::lcnf(const bvt &bv) delete[] lits; } +/*******************************************************************\ + +Function: satcheck_smvsatt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_smvsatt::prop_solve() { int result=sat_instance_solve(satsolver); @@ -126,6 +210,18 @@ propt::resultt satcheck_smvsatt::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: satcheck_smvsat_coret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_smvsat_coret::prop_solve() { propt::resultt result=satcheck_smvsatt::prop_solve(); @@ -138,6 +234,18 @@ propt::resultt satcheck_smvsat_coret::prop_solve() return result; } +/*******************************************************************\ + +Function: satcheck_smvsat_interpolatort::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_smvsat_interpolatort::lcnf(const bvt &bv) { bvt tmp; @@ -163,6 +271,18 @@ void satcheck_smvsat_interpolatort::lcnf(const bvt &bv) delete[] lits; } +/*******************************************************************\ + +Function: satcheck_smvsat_interpolatort::interpolate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_smvsat_interpolatort::interpolate(exprt &dest) { // crate instance @@ -187,6 +307,18 @@ void satcheck_smvsat_interpolatort::interpolate(exprt &dest) delete interpolator_satsolver; } +/*******************************************************************\ + +Function: satcheck_smvsat_interpolatort::build_aig + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_smvsat_interpolatort::build_aig( // NOLINTNEXTLINE(readability/identifiers) struct interpolator &interpolator_satsolver, diff --git a/src/solvers/sat/satcheck_zchaff.cpp b/src/solvers/sat/satcheck_zchaff.cpp index 53d78065311..6697d6b3c6c 100644 --- a/src/solvers/sat/satcheck_zchaff.cpp +++ b/src/solvers/sat/satcheck_zchaff.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include +/*******************************************************************\ + +Function: satcheck_zchaff_baset::satcheck_zchaff_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zchaff_baset::satcheck_zchaff_baset(CSolver *_solver):solver(_solver) { status=INIT; @@ -20,10 +32,34 @@ satcheck_zchaff_baset::satcheck_zchaff_baset(CSolver *_solver):solver(_solver) solver->set_variable_number(0); } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::~satcheck_zchaff_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zchaff_baset::~satcheck_zchaff_baset() { } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_zchaff_baset::l_get(literalt a) const { assert(status==SAT); @@ -50,11 +86,35 @@ tvt satcheck_zchaff_baset::l_get(literalt a) const return result; } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_zchaff_baset::solver_text() { return solver->version(); } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::copy_cnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_zchaff_baset::copy_cnf() { assert(status==INIT); @@ -69,6 +129,18 @@ void satcheck_zchaff_baset::copy_cnf() reinterpret_cast(&((*it)[0])), it->size()); } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_zchaff_baset::prop_solve() { // this is *not* incremental @@ -155,6 +227,18 @@ propt::resultt satcheck_zchaff_baset::prop_solve() return P_ERROR; } +/*******************************************************************\ + +Function: satcheck_zchaff_baset::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void satcheck_zchaff_baset::set_assignment(literalt a, bool value) { unsigned v=a.var_no(); @@ -163,11 +247,35 @@ void satcheck_zchaff_baset::set_assignment(literalt a, bool value) solver->variables()[v].set_value(value); } +/*******************************************************************\ + +Function: satcheck_zchafft::satcheck_zchafft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zchafft::satcheck_zchafft(): satcheck_zchaff_baset(new CSolver) { } +/*******************************************************************\ + +Function: satcheck_zchafft::~satcheck_zchafft + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zchafft::~satcheck_zchafft() { delete solver; diff --git a/src/solvers/sat/satcheck_zcore.cpp b/src/solvers/sat/satcheck_zcore.cpp index 5dda83fce65..5079259d6cf 100644 --- a/src/solvers/sat/satcheck_zcore.cpp +++ b/src/solvers/sat/satcheck_zcore.cpp @@ -15,25 +15,85 @@ Author: Daniel Kroening, kroening@kroening.com #include +/*******************************************************************\ + +Function: satcheck_zcoret::satcheck_zcoret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zcoret::satcheck_zcoret() { } +/*******************************************************************\ + +Function: satcheck_zcoret::~satcheck_zcoret + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + satcheck_zcoret::~satcheck_zcoret() { } +/*******************************************************************\ + +Function: satcheck_zcoret::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt satcheck_zcoret::l_get(literalt a) const { assert(false); return tvt(tvt::tv_enumt::TV_UNKNOWN); } +/*******************************************************************\ + +Function: satcheck_zcoret::solver_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string satcheck_zcoret::solver_text() { return "ZCore"; } +/*******************************************************************\ + +Function: satcheck_zcoret::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt satcheck_zcoret::prop_solve() { // We start counting at 1, thus there is one variable fewer. diff --git a/src/solvers/smt1/smt1_conv.cpp b/src/solvers/smt1/smt1_conv.cpp index 4dd4bff4220..e9b71d87956 100644 --- a/src/solvers/smt1/smt1_conv.cpp +++ b/src/solvers/smt1/smt1_conv.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// SMT Version 1 Backend - #include #include @@ -31,6 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt1_conv.h" +/*******************************************************************\ + +Function: smt1_convt::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::print_assignment(std::ostream &out) const { // Boolean stuff @@ -41,6 +50,18 @@ void smt1_convt::print_assignment(std::ostream &out) const // others } +/*******************************************************************\ + +Function: smt1_convt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt smt1_convt::l_get(literalt l) const { if(l.is_true()) @@ -51,6 +72,18 @@ tvt smt1_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } +/*******************************************************************\ + +Function: smt1_convt::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_convt::dec_solve() { write_footer(); @@ -58,6 +91,18 @@ decision_proceduret::resultt smt1_convt::dec_solve() return decision_proceduret::resultt::D_ERROR; } +/*******************************************************************\ + +Function: smt1_convt::write_header + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::write_header() { out << "(benchmark " << benchmark << "\n"; @@ -66,6 +111,18 @@ void smt1_convt::write_header() out << ":logic " << logic << " ; SMT1" << "\n"; } +/*******************************************************************\ + +Function: smt1_convt::write_footer() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::write_footer() { out << "\n"; @@ -73,6 +130,18 @@ void smt1_convt::write_footer() out << ") ; benchmark" << "\n"; } +/*******************************************************************\ + +Function: smt1_convt::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt1_convt::get(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -114,6 +183,18 @@ exprt smt1_convt::get(const exprt &expr) const return nil_exprt(); } +/*******************************************************************\ + +Function: smt1_convt::ce_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt1_convt::ce_value( const typet &type, const std::string &index, @@ -228,6 +309,18 @@ exprt smt1_convt::ce_value( return nil_exprt(); } +/*******************************************************************\ + +Function: smt1_convt::array_index_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet smt1_convt::array_index_type() const { signedbv_typet t; @@ -235,6 +328,18 @@ typet smt1_convt::array_index_type() const return t; } +/*******************************************************************\ + +Function: smt1_convt::array_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::array_index(const exprt &expr) { if(expr.type().id()==ID_integer) @@ -248,6 +353,18 @@ void smt1_convt::array_index(const exprt &expr) convert_expr(tmp, true); } +/*******************************************************************\ + +Function: smt1_convt::convert_address_of_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_address_of_rec( const exprt &expr, const pointer_typet &result_type) @@ -349,6 +466,18 @@ void smt1_convt::convert_address_of_rec( throw "don't know how to take address of: "+expr.id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_byte_extract( const byte_extract_exprt &expr, bool bool_as_bv) @@ -358,6 +487,18 @@ void smt1_convt::convert_byte_extract( convert_expr(flattened_expr, bool_as_bv); } +/*******************************************************************\ + +Function: smt1_convt::convert_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_byte_update( const exprt &expr, bool bool_as_bv) @@ -435,6 +576,18 @@ void smt1_convt::convert_byte_update( } } +/*******************************************************************\ + +Function: smt1_convt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_convt::convert(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -471,6 +624,18 @@ literalt smt1_convt::convert(const exprt &expr) return l; } +/*******************************************************************\ + +Function: smt1_convt::convert_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt1_convt::convert_identifier(const irep_idt &identifier) { std::string s=id2string(identifier), dest; @@ -524,6 +689,18 @@ std::string smt1_convt::convert_identifier(const irep_idt &identifier) return dest; } +/*******************************************************************\ + +Function: smt1_convt::convert_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_expr(const exprt &expr, bool bool_as_bv) { if(expr.id()==ID_symbol) @@ -1333,6 +1510,18 @@ void smt1_convt::convert_expr(const exprt &expr, bool bool_as_bv) expr.id_string()+"' is unsupported"; } +/*******************************************************************\ + +Function: smt1_convt::convert_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_typecast( const typecast_exprt &expr, bool bool_as_bv) @@ -1714,6 +1903,18 @@ void smt1_convt::convert_typecast( throw "TODO typecast4 ? -> "+dest_type.id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_struct(const exprt &expr) { const struct_typet &struct_type=to_struct_type(expr.type()); @@ -1768,6 +1969,18 @@ void smt1_convt::convert_struct(const exprt &expr) } } +/*******************************************************************\ + +Function: smt1_convt::convert_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_union(const exprt &expr) { const union_typet &union_type=to_union_type(expr.type()); @@ -1797,6 +2010,18 @@ void smt1_convt::convert_union(const exprt &expr) } } +/*******************************************************************\ + +Function: smt1_convt::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_constant( const constant_exprt &expr, bool bool_as_bv) @@ -1898,6 +2123,18 @@ void smt1_convt::convert_constant( throw "unknown constant: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_mod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_mod(const mod_exprt &expr) { assert(expr.operands().size()==2); @@ -1919,6 +2156,18 @@ void smt1_convt::convert_mod(const mod_exprt &expr) throw "unsupported type for mod: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_is_dynamic_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_is_dynamic_object( const exprt &expr, bool bool_as_bv) @@ -1968,6 +2217,18 @@ void smt1_convt::convert_is_dynamic_object( from_bool_end(expr.type(), bool_as_bv); } +/*******************************************************************\ + +Function: smt1_convt::convert_relation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_relation(const exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==2); @@ -2033,6 +2294,18 @@ void smt1_convt::convert_relation(const exprt &expr, bool bool_as_bv) from_bool_end(expr.type(), bool_as_bv); } +/*******************************************************************\ + +Function: smt1_convt::convert_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_plus(const plus_exprt &expr) { assert(expr.operands().size()>=2); @@ -2113,6 +2386,18 @@ void smt1_convt::convert_plus(const plus_exprt &expr) throw "unsupported type for +: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_floatbv_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_floatbv_plus(const exprt &expr) { assert(expr.operands().size()==3); @@ -2121,6 +2406,18 @@ void smt1_convt::convert_floatbv_plus(const exprt &expr) throw "todo: floatbv_plus"; } +/*******************************************************************\ + +Function: smt1_convt::convert_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_minus(const minus_exprt &expr) { assert(expr.operands().size()==2); @@ -2160,6 +2457,18 @@ void smt1_convt::convert_minus(const minus_exprt &expr) throw "unsupported type for -: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_floatbv_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_floatbv_minus(const exprt &expr) { assert(expr.operands().size()==3); @@ -2168,6 +2477,18 @@ void smt1_convt::convert_floatbv_minus(const exprt &expr) throw "todo: floatbv_minus"; } +/*******************************************************************\ + +Function: smt1_convt::convert_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_div(const div_exprt &expr) { assert(expr.operands().size()==2); @@ -2207,6 +2528,18 @@ void smt1_convt::convert_div(const div_exprt &expr) throw "unsupported type for /: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_floatbv_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_floatbv_div(const exprt &expr) { assert(expr.operands().size()==3); @@ -2215,6 +2548,18 @@ void smt1_convt::convert_floatbv_div(const exprt &expr) throw "todo: floatbv_div"; } +/*******************************************************************\ + +Function: smt1_convt::convert_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_mult(const mult_exprt &expr) { assert(expr.operands().size()>=2); @@ -2278,6 +2623,18 @@ void smt1_convt::convert_mult(const mult_exprt &expr) throw "unsupported type for *: "+expr.type().id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_floatbv_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_floatbv_mult(const exprt &expr) { assert(expr.operands().size()==3); @@ -2286,6 +2643,18 @@ void smt1_convt::convert_floatbv_mult(const exprt &expr) throw "todo: floatbv_mult"; } +/*******************************************************************\ + +Function: smt1_convt::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_with(const exprt &expr) { // get rid of "with" that has more than three operands @@ -2626,6 +2995,18 @@ void smt1_convt::convert_with(const exprt &expr) } } +/*******************************************************************\ + +Function: smt1_convt::convert_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_update(const exprt &expr) { assert(expr.operands().size()==3); @@ -2634,6 +3015,18 @@ void smt1_convt::convert_update(const exprt &expr) throw "smt1_convt::convert_update to be implemented"; } +/*******************************************************************\ + +Function: smt1_convt::convert_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_index(const index_exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==2); @@ -2685,6 +3078,18 @@ void smt1_convt::convert_index(const index_exprt &expr, bool bool_as_bv) } } +/*******************************************************************\ + +Function: smt1_convt::convert_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_member(const member_exprt &expr, bool bool_as_bv) { assert(expr.operands().size()==1); @@ -2735,10 +3140,34 @@ void smt1_convt::convert_member(const member_exprt &expr, bool bool_as_bv) from_bv_end(expr.type(), bool_as_bv); } +/*******************************************************************\ + +Function: smt1_convt::convert_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_overflow(const exprt &expr) { } +/*******************************************************************\ + +Function: smt1_convt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::set_to(const exprt &expr, bool value) { if(expr.id()==ID_and && value) @@ -2781,6 +3210,18 @@ void smt1_convt::set_to(const exprt &expr, bool value) out << "\n"; } +/*******************************************************************\ + +Function: smt1_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::find_symbols(const exprt &expr) { const typet &type=expr.type(); @@ -2908,6 +3349,18 @@ void smt1_convt::find_symbols(const exprt &expr) } } +/*******************************************************************\ + +Function: smt1_convt::convert_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -2970,6 +3423,18 @@ void smt1_convt::convert_type(const typet &type) throw "unsupported type: "+type.id_string(); } +/*******************************************************************\ + +Function: smt1_convt::convert_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -2988,6 +3453,18 @@ void smt1_convt::convert_literal(const literalt l) } } +/*******************************************************************\ + +Function: smt1_convt::from_bv_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::from_bv_begin(const typet &type, bool bool_as_bv) { // this turns bv[1] into a predicate if needed @@ -2995,6 +3472,18 @@ void smt1_convt::from_bv_begin(const typet &type, bool bool_as_bv) out << "(= "; } +/*******************************************************************\ + +Function: smt1_convt::from_bv_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::from_bv_end(const typet &type, bool bool_as_bv) { // this turns bv[1] into a predicate if needed @@ -3002,6 +3491,18 @@ void smt1_convt::from_bv_end(const typet &type, bool bool_as_bv) out << " bv1[1])"; } +/*******************************************************************\ + +Function: smt1_convt::from_bool_begin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::from_bool_begin(const typet &type, bool bool_as_bv) { // this turns a predicate into bv[1] if needed @@ -3009,6 +3510,18 @@ void smt1_convt::from_bool_begin(const typet &type, bool bool_as_bv) out << "(ite "; } +/*******************************************************************\ + +Function: smt1_convt::from_bool_end + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::from_bool_end(const typet &type, bool bool_as_bv) { // this turns a predicate into bv[1] if needed @@ -3016,12 +3529,36 @@ void smt1_convt::from_bool_end(const typet &type, bool bool_as_bv) out << " bv1[1] bv0[1])"; } +/*******************************************************************\ + +Function: smt1_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::find_symbols(const typet &type) { std::set rec_stack; find_symbols_rec(type, rec_stack); } +/*******************************************************************\ + +Function: smt1_convt::find_symbols_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::find_symbols_rec( const typet &type, std::set &recstack) @@ -3072,6 +3609,18 @@ void smt1_convt::find_symbols_rec( } } +/*******************************************************************\ + +Function: smt1_convt::binary2struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt1_convt::binary2struct( const struct_typet &type, const std::string &binary) const @@ -3106,6 +3655,18 @@ exprt smt1_convt::binary2struct( return e; } +/*******************************************************************\ + +Function: smt1_convt::binary2union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt1_convt::binary2union( const union_typet &type, const std::string &binary) const @@ -3136,6 +3697,18 @@ exprt smt1_convt::binary2union( return e; } +/*******************************************************************\ + +Function: smt1_convt::flatten_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::flatten_array(const exprt &op) { const array_typet array_type=to_array_type(op.type()); @@ -3183,6 +3756,18 @@ void smt1_convt::flatten_array(const exprt &op) #endif } +/*******************************************************************\ + +Function: smt1_convt::convert_nary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_convt::convert_nary( const exprt &expr, const irep_idt op_string, diff --git a/src/solvers/smt1/smt1_conv.h b/src/solvers/smt1/smt1_conv.h index f152423df1c..4a078a0d772 100644 --- a/src/solvers/smt1/smt1_conv.h +++ b/src/solvers/smt1/smt1_conv.h @@ -7,9 +7,6 @@ Revision: Roberto Bruttomesso, roberto.bruttomesso@unisi.ch \*******************************************************************/ -/// \file -/// SMT Version 1 Backend - #ifndef CPROVER_SOLVERS_SMT1_SMT1_CONV_H #define CPROVER_SOLVERS_SMT1_SMT1_CONV_H diff --git a/src/solvers/smt1/smt1_dec.cpp b/src/solvers/smt1/smt1_dec.cpp index 1b39527a59d..fc01925d883 100644 --- a/src/solvers/smt1/smt1_dec.cpp +++ b/src/solvers/smt1/smt1_dec.cpp @@ -26,6 +26,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt1_dec.h" +/*******************************************************************\ + +Function: smt1_dect::decision_procedure_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt1_dect::decision_procedure_text() const { return "SMT1 "+logic+" using "+ @@ -40,6 +52,18 @@ std::string smt1_dect::decision_procedure_text() const "(unknown)"); } +/*******************************************************************\ + +Function: smt1_temp_filet::smt1_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt1_temp_filet::smt1_temp_filet() { temp_out_filename=get_temporary_file("smt1_dec_out_", ""); @@ -49,6 +73,18 @@ smt1_temp_filet::smt1_temp_filet() std::ios_base::out | std::ios_base::trunc); } +/*******************************************************************\ + +Function: smt1_temp_filet::~smt1_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt1_temp_filet::~smt1_temp_filet() { temp_out.close(); @@ -60,6 +96,18 @@ smt1_temp_filet::~smt1_temp_filet() unlink(temp_result_filename.c_str()); } +/*******************************************************************\ + +Function: smt1_dect::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::dec_solve() { // SMT1 is really not incremental @@ -178,7 +226,18 @@ decision_proceduret::resultt smt1_dect::dec_solve() } } -/// read model produced by Boolector +/*******************************************************************\ + +Function: smt1_dect::read_result_boolector + + Inputs: + + Outputs: + + Purpose: read model produced by Boolector + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_boolector(std::istream &in) { std::string line; @@ -262,11 +321,35 @@ decision_proceduret::resultt smt1_dect::read_result_boolector(std::istream &in) return resultt::D_ERROR; } +/*******************************************************************\ + +Function: smt1_dect::read_result_opensmt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_opensmt(std::istream &in) { return resultt::D_ERROR; } +/*******************************************************************\ + +Function: smt1_dect::read_result_yices + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_yices(std::istream &in) { std::string line; @@ -287,6 +370,18 @@ decision_proceduret::resultt smt1_dect::read_result_yices(std::istream &in) return resultt::D_ERROR; } +/*******************************************************************\ + +Function: smt1_dect::mathsat_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt1_dect::mathsat_value(const std::string &src) { std::size_t pos=src.find('['); @@ -304,6 +399,18 @@ std::string smt1_dect::mathsat_value(const std::string &src) return ""; } +/*******************************************************************\ + +Function: smt1_dect::read_result_mathsat + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_mathsat(std::istream &in) { std::string line; @@ -374,6 +481,18 @@ decision_proceduret::resultt smt1_dect::read_result_mathsat(std::istream &in) return res; } +/*******************************************************************\ + +Function: smt1_dect::read_result_z3 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_z3(std::istream &in) { std::string line; @@ -430,6 +549,18 @@ decision_proceduret::resultt smt1_dect::read_result_z3(std::istream &in) return res; } +/*******************************************************************\ + +Function: smt1_dect::string_to_expr_z3 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool smt1_dect::string_to_expr_z3( const typet &type, const std::string &value, @@ -546,6 +677,18 @@ bool smt1_dect::string_to_expr_z3( return false; } +/*******************************************************************\ + +Function: smt1_dect::read_result_cvc3 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt1_dect::read_result_cvc3(std::istream &in) { std::string line; diff --git a/src/solvers/smt1/smt1_prop.cpp b/src/solvers/smt1/smt1_prop.cpp index bdbc0dbfbce..e39dfedde80 100644 --- a/src/solvers/smt1/smt1_prop.cpp +++ b/src/solvers/smt1/smt1_prop.cpp @@ -13,6 +13,18 @@ Revisions: Roberto Bruttomesso, roberto.bruttomesso@unisi.ch #include "smt1_prop.h" +/*******************************************************************\ + +Function: smt1_propt::smt1_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt1_propt::smt1_propt( const std::string &benchmark, const std::string &source, @@ -26,10 +38,34 @@ smt1_propt::smt1_propt( _no_variables=0; } +/*******************************************************************\ + +Function: smt1_propt::~smt1_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt1_propt::~smt1_propt() { } +/*******************************************************************\ + +Function: smt1_propt::finalize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_propt::finalize() { out << "\n"; @@ -37,6 +73,18 @@ void smt1_propt::finalize() out << ") ; benchmark" << "\n"; } +/*******************************************************************\ + +Function: smt1_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::land(const bvt &bv) { out << "\n"; @@ -54,6 +102,18 @@ literalt smt1_propt::land(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt1_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lor(const bvt &bv) { out << "\n"; @@ -71,6 +131,18 @@ literalt smt1_propt::lor(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt1_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -93,6 +165,18 @@ literalt smt1_propt::lxor(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt1_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -119,6 +203,18 @@ literalt smt1_propt::land(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt1_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -145,6 +241,18 @@ literalt smt1_propt::lor(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt1_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -169,26 +277,86 @@ literalt smt1_propt::lxor(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt1_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lnand(literalt a, literalt b) { return !land(a, b); } +/*******************************************************************\ + +Function: smt1_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lnor(literalt a, literalt b) { return !lor(a, b); } +/*******************************************************************\ + +Function: smt1_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } +/*******************************************************************\ + +Function: smt1_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::limplies(literalt a, literalt b) { return lor(!a, b); } +/*******************************************************************\ + +Function: smt1_propt::lselect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -219,6 +387,18 @@ literalt smt1_propt::lselect(literalt a, literalt b, literalt c) return l; } +/*******************************************************************\ + +Function: smt1_propt::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt1_propt::new_variable() { literalt l; @@ -230,6 +410,18 @@ literalt smt1_propt::new_variable() return l; } +/*******************************************************************\ + +Function: smt1_propt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_propt::lcnf(const bvt &bv) { out << "\n"; @@ -253,6 +445,18 @@ void smt1_propt::lcnf(const bvt &bv) out << "\n"; } +/*******************************************************************\ + +Function: smt1_propt::smt1_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt1_propt::smt1_literal(literalt l) { if(l==const_literal(false)) @@ -268,6 +472,18 @@ std::string smt1_propt::smt1_literal(literalt l) return v; } +/*******************************************************************\ + +Function: smt1_propt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt smt1_propt::l_get(literalt literal) const { if(literal.is_true()) @@ -282,6 +498,18 @@ tvt smt1_propt::l_get(literalt literal) const return literal.sign()?!r:r; } +/*******************************************************************\ + +Function: smt1_propt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt1_propt::set_assignment(literalt literal, bool value) { if(literal.is_true() || literal.is_false()) @@ -292,6 +520,18 @@ void smt1_propt::set_assignment(literalt literal, bool value) assignment[v]=tvt(value); } +/*******************************************************************\ + +Function: smt1_propt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt smt1_propt::prop_solve() { return P_ERROR; diff --git a/src/solvers/smt2/smt2_conv.cpp b/src/solvers/smt2/smt2_conv.cpp index c764c210bec..37a3647ed71 100644 --- a/src/solvers/smt2/smt2_conv.cpp +++ b/src/solvers/smt2/smt2_conv.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// SMT Backend - #include #include @@ -47,6 +44,18 @@ Author: Daniel Kroening, kroening@kroening.com // General todos #define TODO(S) throw "TODO: " S +/*******************************************************************\ + +Function: smt2_convt::print_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::print_assignment(std::ostream &out) const { // Boolean stuff @@ -57,6 +66,18 @@ void smt2_convt::print_assignment(std::ostream &out) const // others } +/*******************************************************************\ + +Function: smt2_convt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt smt2_convt::l_get(literalt l) const { if(l.is_true()) @@ -67,6 +88,18 @@ tvt smt2_convt::l_get(literalt l) const return tvt(boolean_assignment[l.var_no()]^l.sign()); } +/*******************************************************************\ + +Function: smt2_convt::write_header + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::write_header() { out << "; SMT 2" << "\n"; @@ -94,6 +127,18 @@ void smt2_convt::write_header() out << "(set-logic " << logic << ")" << "\n"; } +/*******************************************************************\ + +Function: smt2_convt::write_footer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::write_footer(std::ostream &out) { out << "\n"; @@ -131,6 +176,18 @@ void smt2_convt::write_footer(std::ostream &out) out << "; end of SMT2 file" << "\n"; } +/*******************************************************************\ + +Function: smt2_convt::define_object_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::define_object_size( const irep_idt &id, const exprt &expr) @@ -168,6 +225,18 @@ void smt2_convt::define_object_size( } } +/*******************************************************************\ + +Function: smt2_convt::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt2_convt::dec_solve() { write_footer(out); @@ -175,6 +244,18 @@ decision_proceduret::resultt smt2_convt::dec_solve() return decision_proceduret::resultt::D_ERROR; } +/*******************************************************************\ + +Function: smt2_convt::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::get(const exprt &expr) const { if(expr.id()==ID_symbol) @@ -198,6 +279,18 @@ exprt smt2_convt::get(const exprt &expr) const return nil_exprt(); } +/*******************************************************************\ + +Function: smt2_convt::parse_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt smt2_convt::parse_literal( const irept &src, const typet &type) @@ -318,6 +411,18 @@ constant_exprt smt2_convt::parse_literal( UNEXPECTEDCASE("smt2_convt::parse_literal can't do type "+type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::parse_array + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::parse_array( const irept &src, const array_typet &type) @@ -348,6 +453,18 @@ exprt smt2_convt::parse_array( return nil_exprt(); } +/*******************************************************************\ + +Function: smt2_convt::parse_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::parse_union( const irept &src, const union_typet &type) @@ -363,6 +480,18 @@ exprt smt2_convt::parse_union( return union_exprt(first.get_name(), converted, type); } +/*******************************************************************\ + +Function: smt2_convt::parse_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::parse_struct( const irept &src, const struct_typet &type) @@ -424,6 +553,18 @@ exprt smt2_convt::parse_struct( return result; } +/*******************************************************************\ + +Function: smt2_convt::parse_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::parse_rec(const irept &src, const typet &_type) { const typet &type=ns.follow(_type); @@ -475,6 +616,18 @@ exprt smt2_convt::parse_rec(const irept &src, const typet &_type) return nil_exprt(); } +/*******************************************************************\ + +Function: smt2_convt::convert_address_of_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_address_of_rec( const exprt &expr, const pointer_typet &result_type) @@ -570,6 +723,18 @@ void smt2_convt::convert_address_of_rec( UNEXPECTEDCASE("don't know how to take address of: "+expr.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_byte_extract(const byte_extract_exprt &expr) { // we just run the flattener @@ -579,6 +744,18 @@ void smt2_convt::convert_byte_extract(const byte_extract_exprt &expr) unflatten(wheret::END, expr.type()); } +/*******************************************************************\ + +Function: smt2_convt::convert_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_byte_update(const byte_update_exprt &expr) { assert(expr.operands().size()==3); @@ -683,6 +860,18 @@ void smt2_convt::convert_byte_update(const byte_update_exprt &expr) #endif } +/*******************************************************************\ + +Function: smt2_convt::convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_convt::convert(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -715,6 +904,18 @@ literalt smt2_convt::convert(const exprt &expr) return l; } +/*******************************************************************\ + +Function: smt2_convt::convert_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_literal(const literalt l) { if(l==const_literal(false)) @@ -735,6 +936,18 @@ void smt2_convt::convert_literal(const literalt l) } } +/*******************************************************************\ + +Function: smt2_convt::convert_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt2_convt::convert_identifier(const irep_idt &identifier) { // Backslashes are disallowed in quoted symbols just for simplicity. @@ -766,6 +979,18 @@ std::string smt2_convt::convert_identifier(const irep_idt &identifier) return result; } +/*******************************************************************\ + +Function: smt2_convt::type2id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt2_convt::type2id(const typet &type) const { if(type.id()==ID_floatbv) @@ -800,12 +1025,36 @@ std::string smt2_convt::type2id(const typet &type) const } } +/*******************************************************************\ + +Function: smt2_convt::floatbv_suffix + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt2_convt::floatbv_suffix(const exprt &expr) const { assert(!expr.operands().empty()); return "_"+type2id(expr.op0().type())+"->"+type2id(expr.type()); } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv(const exprt &expr) { assert(!use_FPA_theory); @@ -839,6 +1088,18 @@ void smt2_convt::convert_floatbv(const exprt &expr) out << ')'; } +/*******************************************************************\ + +Function: smt2_convt::convert_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_expr(const exprt &expr) { // huge monster case split over expression id @@ -1789,6 +2050,18 @@ void smt2_convt::convert_expr(const exprt &expr) "smt2_convt::convert_expr: `"+expr.id_string()+"' is unsupported"); } +/*******************************************************************\ + +Function: smt2_convt::convert_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_typecast(const typecast_exprt &expr) { assert(expr.operands().size()==1); @@ -2273,6 +2546,18 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) "TODO typecast8 "+src_type.id_string()+" -> "+dest_type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) { const exprt &src=expr.op(); @@ -2419,6 +2704,18 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::convert_struct + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_struct(const struct_exprt &expr) { const struct_typet &struct_type=to_struct_type(expr.type()); @@ -2481,7 +2778,18 @@ void smt2_convt::convert_struct(const struct_exprt &expr) } } -/// produce a flat bit-vector for a given array of fixed size +/*******************************************************************\ + +Function: smt2_convt::flatten_array + + Inputs: + + Outputs: + + Purpose: produce a flat bit-vector for a given array of fixed size + +\*******************************************************************/ + void smt2_convt::flatten_array(const exprt &expr) { const array_typet &array_type= @@ -2516,6 +2824,18 @@ void smt2_convt::flatten_array(const exprt &expr) out << ")"; // let } +/*******************************************************************\ + +Function: smt2_convt::convert_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_union(const union_exprt &expr) { const union_typet &union_type=to_union_type(expr.type()); @@ -2549,6 +2869,18 @@ void smt2_convt::convert_union(const union_exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::convert_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_constant(const constant_exprt &expr) { const typet &expr_type=expr.type(); @@ -2685,6 +3017,18 @@ void smt2_convt::convert_constant(const constant_exprt &expr) UNEXPECTEDCASE("unknown constant: "+expr_type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_mod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_mod(const mod_exprt &expr) { assert(expr.operands().size()==2); @@ -2706,6 +3050,18 @@ void smt2_convt::convert_mod(const mod_exprt &expr) UNEXPECTEDCASE("unsupported type for mod: "+expr.type().id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_is_dynamic_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_is_dynamic_object(const exprt &expr) { std::vector dynamic_objects; @@ -2745,6 +3101,18 @@ void smt2_convt::convert_is_dynamic_object(const exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::convert_relation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_relation(const exprt &expr) { assert(expr.operands().size()==2); @@ -2830,6 +3198,18 @@ void smt2_convt::convert_relation(const exprt &expr) "unsupported type for "+expr.id_string()+": "+op_type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_plus(const plus_exprt &expr) { if(expr.operands().size()==0) @@ -2946,10 +3326,19 @@ void smt2_convt::convert_plus(const plus_exprt &expr) } } -/// Converting a constant or symbolic rounding mode to SMT-LIB. Only called when -/// use_FPA_theory is enabled -/// \par parameters: The expression representing the rounding mode. -/// \return SMT-LIB output to out. +/*******************************************************************\ + +Function: smt2_convt::convert_rounding_mode_FPA + + Inputs: The expression representing the rounding mode. + + Outputs: SMT-LIB output to out. + + Purpose: Converting a constant or symbolic rounding mode to SMT-LIB. + Only called when use_FPA_theory is enabled + +\*******************************************************************/ + void smt2_convt::convert_rounding_mode_FPA(const exprt &expr) { assert(use_FPA_theory); @@ -3006,6 +3395,18 @@ void smt2_convt::convert_rounding_mode_FPA(const exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv_plus(const ieee_float_op_exprt &expr) { const typet &type=expr.type(); @@ -3042,6 +3443,18 @@ void smt2_convt::convert_floatbv_plus(const ieee_float_op_exprt &expr) convert_floatbv(expr); } +/*******************************************************************\ + +Function: smt2_convt::convert_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_minus(const minus_exprt &expr) { assert(expr.operands().size()==2); @@ -3135,6 +3548,18 @@ void smt2_convt::convert_minus(const minus_exprt &expr) UNEXPECTEDCASE("unsupported type for -: "+expr.type().id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv_minus(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3154,6 +3579,18 @@ void smt2_convt::convert_floatbv_minus(const ieee_float_op_exprt &expr) convert_floatbv(expr); } +/*******************************************************************\ + +Function: smt2_convt::convert_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_div(const div_exprt &expr) { assert(expr.operands().size()==2); @@ -3200,6 +3637,18 @@ void smt2_convt::convert_div(const div_exprt &expr) UNEXPECTEDCASE("unsupported type for /: "+expr.type().id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv_div(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3219,6 +3668,18 @@ void smt2_convt::convert_floatbv_div(const ieee_float_op_exprt &expr) convert_floatbv(expr); } +/*******************************************************************\ + +Function: smt2_convt::convert_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_mult(const mult_exprt &expr) { assert(expr.operands().size()>=2); @@ -3292,6 +3753,18 @@ void smt2_convt::convert_mult(const mult_exprt &expr) UNEXPECTEDCASE("unsupported type for *: "+expr.type().id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_floatbv_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_floatbv_mult(const ieee_float_op_exprt &expr) { assert(expr.operands().size()==3); @@ -3311,6 +3784,18 @@ void smt2_convt::convert_floatbv_mult(const ieee_float_op_exprt &expr) convert_floatbv(expr); } +/*******************************************************************\ + +Function: smt2_convt::convert_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_with(const with_exprt &expr) { // get rid of "with" that has more than three operands @@ -3558,6 +4043,18 @@ void smt2_convt::convert_with(const with_exprt &expr) expr.type().id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_update(const exprt &expr) { assert(expr.operands().size()==3); @@ -3565,6 +4062,18 @@ void smt2_convt::convert_update(const exprt &expr) TODO("smt2_convt::convert_update to be implemented"); } +/*******************************************************************\ + +Function: smt2_convt::convert_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_index(const index_exprt &expr) { assert(expr.operands().size()==2); @@ -3667,6 +4176,18 @@ void smt2_convt::convert_index(const index_exprt &expr) "index with unsupported array type: "+array_op_type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::convert_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_member(const member_exprt &expr) { assert(expr.operands().size()==1); @@ -3732,6 +4253,18 @@ void smt2_convt::convert_member(const member_exprt &expr) "convert_member on an unexpected type "+struct_op_type.id_string()); } +/*******************************************************************\ + +Function: smt2_convt::flatten2bv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::flatten2bv(const exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -3828,6 +4361,18 @@ void smt2_convt::flatten2bv(const exprt &expr) convert_expr(expr); } +/*******************************************************************\ + +Function: smt2_convt::unflatten + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::unflatten( wheret where, const typet &type, @@ -3943,11 +4488,35 @@ void smt2_convt::unflatten( } } +/*******************************************************************\ + +Function: smt2_convt::convert_overflow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_overflow(const exprt &expr) { UNREACHABLE; } +/*******************************************************************\ + +Function: smt2_convt::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::set_to(const exprt &expr, bool value) { if(expr.id()==ID_and && value) @@ -4036,6 +4605,18 @@ void smt2_convt::set_to(const exprt &expr, bool value) return; } +/*******************************************************************\ + +Function: smt2_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::find_symbols(const exprt &expr) { // recursive call on type @@ -4229,6 +4810,18 @@ void smt2_convt::find_symbols(const exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::use_array_theory + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool smt2_convt::use_array_theory(const exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -4251,6 +4844,18 @@ bool smt2_convt::use_array_theory(const exprt &expr) } } +/*******************************************************************\ + +Function: smt2_convt::convert_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::convert_type(const typet &type) { if(type.id()==ID_array) @@ -4402,12 +5007,36 @@ void smt2_convt::convert_type(const typet &type) } } +/*******************************************************************\ + +Function: smt2_convt::find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::find_symbols(const typet &type) { std::set recstack; find_symbols_rec(type, recstack); } +/*******************************************************************\ + +Function: smt2_convt::find_symbols_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::find_symbols_rec( const typet &type, std::set &recstack) @@ -4604,6 +5233,18 @@ void smt2_convt::find_symbols_rec( } } +/*******************************************************************\ + +Function: smt2_convt::letify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::letify(exprt &expr) { seen_expressionst map; @@ -4614,6 +5255,18 @@ exprt smt2_convt::letify(exprt &expr) return letify_rec(expr, let_order, map, 0); } +/*******************************************************************\ + +Function: smt2_convt::letify_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::letify_rec( exprt &expr, std::vector &let_order, @@ -4638,6 +5291,18 @@ exprt smt2_convt::letify_rec( return let; } +/*******************************************************************\ + +Function: smt2_convt::collect_bindings + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_convt::collect_bindings( exprt &expr, seen_expressionst &map, @@ -4669,6 +5334,18 @@ void smt2_convt::collect_bindings( let_order.push_back(expr); } +/*******************************************************************\ + +Function: smt2_convt::substitute_let + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt smt2_convt::substitute_let( exprt &expr, const seen_expressionst &map) diff --git a/src/solvers/smt2/smt2_dec.cpp b/src/solvers/smt2/smt2_dec.cpp index 51fb59952a8..9a9c5d1fc62 100644 --- a/src/solvers/smt2/smt2_dec.cpp +++ b/src/solvers/smt2/smt2_dec.cpp @@ -26,6 +26,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt2_dec.h" #include "smt2irep.h" +/*******************************************************************\ + +Function: smt2_dect::decision_procedure_text + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt2_dect::decision_procedure_text() const { return "SMT2 "+logic+ @@ -42,6 +54,18 @@ std::string smt2_dect::decision_procedure_text() const "(unknown)"); } +/*******************************************************************\ + +Function: smt2_temp_filet::smt2_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt2_temp_filet::smt2_temp_filet() { temp_out_filename=get_temporary_file("smt2_dec_out_", ""); @@ -51,6 +75,18 @@ smt2_temp_filet::smt2_temp_filet() std::ios_base::out | std::ios_base::trunc); } +/*******************************************************************\ + +Function: smt2_temp_filet::~smt2_temp_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt2_temp_filet::~smt2_temp_filet() { temp_out.close(); @@ -62,6 +98,18 @@ smt2_temp_filet::~smt2_temp_filet() unlink(temp_result_filename.c_str()); } +/*******************************************************************\ + +Function: smt2_dect::dec_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt2_dect::dec_solve() { // we write the problem into a file @@ -168,6 +216,18 @@ decision_proceduret::resultt smt2_dect::dec_solve() return read_result(in); } +/*******************************************************************\ + +Function: smt2_dect::read_result + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + decision_proceduret::resultt smt2_dect::read_result(std::istream &in) { std::string line; diff --git a/src/solvers/smt2/smt2_parser.cpp b/src/solvers/smt2/smt2_parser.cpp index e7bd42b44b4..96439833c11 100644 --- a/src/solvers/smt2/smt2_parser.cpp +++ b/src/solvers/smt2/smt2_parser.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt2_parser.h" +/*******************************************************************\ + +Function: smt2_parsert::is_simple_symbol_character + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool smt2_parsert::is_simple_symbol_character(char ch) { // any non-empty sequence of letters, digits and the characters @@ -24,6 +36,18 @@ bool smt2_parsert::is_simple_symbol_character(char ch) ch=='?' || ch=='/'; } +/*******************************************************************\ + +Function: smt2_parsert::get_simple_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_simple_symbol() { // any non-empty sequence of letters, digits and the characters @@ -49,6 +73,18 @@ void smt2_parsert::get_simple_symbol() // eof -- this is ok here } +/*******************************************************************\ + +Function: smt2_parsert::get_decimal_numeral + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_decimal_numeral() { // we accept any sequence of digits and dots @@ -72,6 +108,18 @@ void smt2_parsert::get_decimal_numeral() // eof -- this is ok here } +/*******************************************************************\ + +Function: smt2_parsert::get_bin_numeral + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_bin_numeral() { // we accept any sequence of '0' or '1' @@ -97,6 +145,18 @@ void smt2_parsert::get_bin_numeral() // eof -- this is ok here } +/*******************************************************************\ + +Function: smt2_parsert::get_hex_numeral + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_hex_numeral() { // we accept any sequence of '0'-'9', 'a'-'f', 'A'-'F' @@ -122,6 +182,18 @@ void smt2_parsert::get_hex_numeral() // eof -- this is ok here } +/*******************************************************************\ + +Function: smt2_parsert::get_quoted_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_quoted_symbol() { // any sequence of printable ASCII characters (including space, @@ -142,6 +214,18 @@ void smt2_parsert::get_quoted_symbol() // Hmpf. Eof before end of quoted string. This is an error. } +/*******************************************************************\ + +Function: smt2_parsert::get_string_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::get_string_literal() { buffer.clear(); @@ -173,6 +257,18 @@ void smt2_parsert::get_string_literal() error("EOF within string literal"); } +/*******************************************************************\ + +Function: smt2_parsert::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_parsert::operator()() { char ch; diff --git a/src/solvers/smt2/smt2_prop.cpp b/src/solvers/smt2/smt2_prop.cpp index 5ba2cbae409..d1f7f8bd21f 100644 --- a/src/solvers/smt2/smt2_prop.cpp +++ b/src/solvers/smt2/smt2_prop.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "smt2_prop.h" +/*******************************************************************\ + +Function: smt2_propt::smt2_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt2_propt::smt2_propt( const std::string &benchmark, const std::string &source, @@ -35,10 +47,34 @@ smt2_propt::smt2_propt( _no_variables=0; } +/*******************************************************************\ + +Function: smt2_propt::~smt2_propt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + smt2_propt::~smt2_propt() { } +/*******************************************************************\ + +Function: smt2_propt::finalize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_propt::finalize() { out << "\n"; @@ -59,6 +95,18 @@ void smt2_propt::finalize() out << "; end of SMT2 file" << "\n"; } +/*******************************************************************\ + +Function: smt2_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::land(const bvt &bv) { out << "\n"; @@ -76,6 +124,18 @@ literalt smt2_propt::land(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt2_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lor(const bvt &bv) { out << "\n"; @@ -93,6 +153,18 @@ literalt smt2_propt::lor(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt2_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lxor(const bvt &bv) { if(bv.empty()) @@ -115,6 +187,18 @@ literalt smt2_propt::lxor(const bvt &bv) return l; } +/*******************************************************************\ + +Function: smt2_propt::land + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::land(literalt a, literalt b) { if(a==const_literal(true)) @@ -141,6 +225,18 @@ literalt smt2_propt::land(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt2_propt::lor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lor(literalt a, literalt b) { if(a==const_literal(false)) @@ -167,6 +263,18 @@ literalt smt2_propt::lor(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt2_propt::lxor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lxor(literalt a, literalt b) { if(a==const_literal(false)) @@ -191,26 +299,86 @@ literalt smt2_propt::lxor(literalt a, literalt b) return l; } +/*******************************************************************\ + +Function: smt2_propt::lnand + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lnand(literalt a, literalt b) { return !land(a, b); } +/*******************************************************************\ + +Function: smt2_propt::lnor + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lnor(literalt a, literalt b) { return !lor(a, b); } +/*******************************************************************\ + +Function: smt2_propt::lequal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lequal(literalt a, literalt b) { return !lxor(a, b); } +/*******************************************************************\ + +Function: smt2_propt::limplies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::limplies(literalt a, literalt b) { return lor(!a, b); } +/*******************************************************************\ + +Function: smt2_propt::lselect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::lselect(literalt a, literalt b, literalt c) { if(a==const_literal(true)) @@ -241,6 +409,18 @@ literalt smt2_propt::lselect(literalt a, literalt b, literalt c) return l; } +/*******************************************************************\ + +Function: smt2_propt::new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::new_variable() { literalt l; @@ -252,6 +432,18 @@ literalt smt2_propt::new_variable() return l; } +/*******************************************************************\ + +Function: smt2_propt::define_new_variable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + literalt smt2_propt::define_new_variable() { literalt l; @@ -265,6 +457,18 @@ literalt smt2_propt::define_new_variable() return l; } +/*******************************************************************\ + +Function: smt2_propt::lcnf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_propt::lcnf(const bvt &bv) { out << "\n"; @@ -288,6 +492,18 @@ void smt2_propt::lcnf(const bvt &bv) out << ")" << "\n"; } +/*******************************************************************\ + +Function: smt2_propt::smt2_literal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string smt2_propt::smt2_literal(literalt l) { if(l==const_literal(false)) @@ -305,6 +521,18 @@ std::string smt2_propt::smt2_literal(literalt l) return v; } +/*******************************************************************\ + +Function: smt2_propt::l_get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt smt2_propt::l_get(literalt literal) const { if(literal.is_true()) @@ -319,6 +547,18 @@ tvt smt2_propt::l_get(literalt literal) const return literal.sign()?!r:r; } +/*******************************************************************\ + +Function: smt2_propt::set_assignment + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void smt2_propt::set_assignment(literalt literal, bool value) { if(literal.is_true() || literal.is_false()) @@ -329,6 +569,18 @@ void smt2_propt::set_assignment(literalt literal, bool value) assignment[v]=tvt(value); } +/*******************************************************************\ + +Function: smt2_propt::prop_solve + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + propt::resultt smt2_propt::prop_solve() { return P_ERROR; diff --git a/src/symex/path_search.cpp b/src/symex/path_search.cpp index d90ffcbd49e..8d8e684c2cb 100644 --- a/src/symex/path_search.cpp +++ b/src/symex/path_search.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Path-based Symbolic Execution - #include #include @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_search.h" +/*******************************************************************\ + +Function: path_searcht::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + path_searcht::resultt path_searcht::operator()( const goto_functionst &goto_functions) { @@ -150,6 +159,18 @@ path_searcht::resultt path_searcht::operator()( return number_of_failed_properties==0?resultt::SAFE:resultt::UNSAFE; } +/*******************************************************************\ + +Function: path_searcht::report_statistics + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_searcht::report_statistics() { std::size_t number_of_visited_locations=0; @@ -187,6 +208,18 @@ void path_searcht::report_statistics() << sat_time << "s SAT" << messaget::eom; } +/*******************************************************************\ + +Function: path_searcht::pick_state + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_searcht::pick_state() { switch(search_heuristic) @@ -207,6 +240,18 @@ void path_searcht::pick_state() } } +/*******************************************************************\ + +Function: path_searcht::do_show_vcc + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_searcht::do_show_vcc(statet &state) { // keep statistics @@ -259,7 +304,18 @@ void path_searcht::do_show_vcc(statet &state) out << eom; } -/// decide whether to drop a state +/*******************************************************************\ + +Function: path_searcht::drop_state + + Inputs: + + Outputs: + + Purpose: decide whether to drop a state + +\*******************************************************************/ + bool path_searcht::drop_state(const statet &state) { goto_programt::const_targett pc=state.get_instruction(); @@ -311,6 +367,18 @@ bool path_searcht::drop_state(const statet &state) return false; } +/*******************************************************************\ + +Function: path_searcht::check_assertion + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_searcht::check_assertion(statet &state) { // keep statistics @@ -358,6 +426,18 @@ void path_searcht::check_assertion(statet &state) sat_time+=current_time()-sat_start_time; } +/*******************************************************************\ + +Function: path_searcht::is_feasible + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool path_searcht::is_feasible(statet &state) { status() << "Feasibility check" << eom; @@ -378,6 +458,18 @@ bool path_searcht::is_feasible(statet &state) return result; } +/*******************************************************************\ + +Function: path_searcht::initialize_property_map + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void path_searcht::initialize_property_map( const goto_functionst &goto_functions) { diff --git a/src/symex/path_search.h b/src/symex/path_search.h index ca570819cc8..49fc621b84e 100644 --- a/src/symex/path_search.h +++ b/src/symex/path_search.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Path-based Symbolic Execution - #ifndef CPROVER_SYMEX_PATH_SEARCH_H #define CPROVER_SYMEX_PATH_SEARCH_H diff --git a/src/symex/symex_cover.cpp b/src/symex/symex_cover.cpp index 50c6a549885..cb0b81254c4 100644 --- a/src/symex/symex_cover.cpp +++ b/src/symex/symex_cover.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symex Test Suite Generation - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "symex_parse_options.h" +/*******************************************************************\ + +Function: symex_parse_optionst::get_test + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string symex_parse_optionst::get_test(const goto_tracet &goto_trace) { bool first=true; @@ -43,6 +52,18 @@ std::string symex_parse_optionst::get_test(const goto_tracet &goto_trace) return test; } +/*******************************************************************\ + +Function: symex_parse_optionst::report_cover + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::report_cover( const path_searcht::property_mapt &property_map) { diff --git a/src/symex/symex_main.cpp b/src/symex/symex_main.cpp index 2407aad561c..9407efd6c28 100644 --- a/src/symex/symex_main.cpp +++ b/src/symex/symex_main.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symex Main Module - #include #include "symex_parse_options.h" +/*******************************************************************\ + +Function: main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef _MSC_VER int wmain(int argc, const wchar_t **argv_wide) { diff --git a/src/symex/symex_parse_options.cpp b/src/symex/symex_parse_options.cpp index 6802eb36ef6..c7b284383c7 100644 --- a/src/symex/symex_parse_options.cpp +++ b/src/symex/symex_parse_options.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symex Command Line Options Processing - #include #include #include @@ -54,6 +51,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "path_search.h" #include "symex_parse_options.h" +/*******************************************************************\ + +Function: symex_parse_optionst::symex_parse_optionst + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + symex_parse_optionst::symex_parse_optionst(int argc, const char **argv): parse_options_baset(SYMEX_OPTIONS, argc, argv), language_uit(cmdline, ui_message_handler), @@ -61,6 +70,18 @@ symex_parse_optionst::symex_parse_optionst(int argc, const char **argv): { } +/*******************************************************************\ + +Function: symex_parse_optionst::eval_verbosity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::eval_verbosity() { // this is our default verbosity @@ -78,6 +99,18 @@ void symex_parse_optionst::eval_verbosity() ui_message_handler.set_verbosity(v); } +/*******************************************************************\ + +Function: symex_parse_optionst::get_command_line_options + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::get_command_line_options(optionst &options) { if(config.set(cmdline)) @@ -112,7 +145,18 @@ void symex_parse_optionst::get_command_line_options(optionst &options) options.set_option("error-label", cmdline.get_values("error-label")); } -/// invoke main modules +/*******************************************************************\ + +Function: symex_parse_optionst::doit + + Inputs: + + Outputs: + + Purpose: invoke main modules + +\*******************************************************************/ + int symex_parse_optionst::doit() { if(cmdline.isset("version")) @@ -252,6 +296,18 @@ int symex_parse_optionst::doit() #endif } +/*******************************************************************\ + +Function: symex_parse_optionst::set_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_parse_optionst::set_properties() { try @@ -281,6 +337,18 @@ bool symex_parse_optionst::set_properties() return false; } +/*******************************************************************\ + +Function: symex_parse_optionst::process_goto_program + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool symex_parse_optionst::process_goto_program(const optionst &options) { try @@ -395,6 +463,18 @@ bool symex_parse_optionst::process_goto_program(const optionst &options) return false; } +/*******************************************************************\ + +Function: symex_parse_optionst::report_properties + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::report_properties( const path_searcht::property_mapt &property_map) { @@ -462,6 +542,18 @@ void symex_parse_optionst::report_properties( } } +/*******************************************************************\ + +Function: symex_parse_optionst::report_success + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::report_success() { result() << "VERIFICATION SUCCESSFUL" << eom; @@ -485,6 +577,18 @@ void symex_parse_optionst::report_success() } } +/*******************************************************************\ + +Function: symex_parse_optionst::show_counterexample + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::show_counterexample( const goto_tracet &error_trace) { @@ -510,6 +614,18 @@ void symex_parse_optionst::show_counterexample( } } +/*******************************************************************\ + +Function: symex_parse_optionst::report_failure + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symex_parse_optionst::report_failure() { result() << "VERIFICATION FAILED" << eom; @@ -533,7 +649,18 @@ void symex_parse_optionst::report_failure() } } -/// display command line help +/*******************************************************************\ + +Function: symex_parse_optionst::help + + Inputs: + + Outputs: + + Purpose: display command line help + +\*******************************************************************/ + void symex_parse_optionst::help() { std::cout << diff --git a/src/symex/symex_parse_options.h b/src/symex/symex_parse_options.h index b4fc6fe2e1c..4a149e2147f 100644 --- a/src/symex/symex_parse_options.h +++ b/src/symex/symex_parse_options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Command Line Parsing - #ifndef CPROVER_SYMEX_SYMEX_PARSE_OPTIONS_H #define CPROVER_SYMEX_SYMEX_PARSE_OPTIONS_H diff --git a/src/util/arith_tools.cpp b/src/util/arith_tools.cpp index 8cc9367612e..37e96ec8ef8 100644 --- a/src/util/arith_tools.cpp +++ b/src/util/arith_tools.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "arith_tools.h" +/*******************************************************************\ + +Function: to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool to_integer(const exprt &expr, mp_integer &int_value) { if(!expr.is_constant()) @@ -22,6 +34,18 @@ bool to_integer(const exprt &expr, mp_integer &int_value) return to_integer(to_constant_expr(expr), int_value); } +/*******************************************************************\ + +Function: to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool to_integer(const constant_exprt &expr, mp_integer &int_value) { const irep_idt &value=expr.get_value(); @@ -89,9 +113,18 @@ bool to_integer(const constant_exprt &expr, mp_integer &int_value) return true; } -/// convert a positive integer expression to an unsigned int -/// \par parameters: a constant expression and a reference to an unsigned int -/// \return an error flag +/*******************************************************************\ + +Function: to_unsigned_integer + + Inputs: a constant expression and a reference to an unsigned int + + Outputs: an error flag + + Purpose: convert a positive integer expression to an unsigned int + +\*******************************************************************/ + bool to_unsigned_integer(const constant_exprt &expr, unsigned &uint_value) { mp_integer i; @@ -106,6 +139,18 @@ bool to_unsigned_integer(const constant_exprt &expr, unsigned &uint_value) } } +/*******************************************************************\ + +Function: from_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt from_integer( const mp_integer &int_value, const typet &type) @@ -206,7 +251,18 @@ constant_exprt from_integer( } } -/// ceil(log2(size)) +/*******************************************************************\ + +Function: address_bits + + Inputs: + + Outputs: + + Purpose: ceil(log2(size)) + +\*******************************************************************/ + mp_integer address_bits(const mp_integer &size) { mp_integer result, x=2; @@ -216,9 +272,18 @@ mp_integer address_bits(const mp_integer &size) return result; } -/// A multi-precision implementation of the power operator. -/// \par parameters: Two mp_integers, base and exponent -/// \return One mp_integer with the value base^{exponent} +/*******************************************************************\ + +Function: power + + Inputs: Two mp_integers, base and exponent + + Outputs: One mp_integer with the value base^{exponent} + + Purpose: A multi-precision implementation of the power operator. + +\*******************************************************************/ + mp_integer power(const mp_integer &base, const mp_integer &exponent) { @@ -270,12 +335,36 @@ mp_integer power(const mp_integer &base, return result; } +/*******************************************************************\ + +Function: mp_min + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void mp_min(mp_integer &a, const mp_integer &b) { if(ba) diff --git a/src/util/array_name.cpp b/src/util/array_name.cpp index cd0c22dac61..d29d60f77fc 100644 --- a/src/util/array_name.cpp +++ b/src/util/array_name.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Misc Utilities - #include "array_name.h" #include "expr.h" #include "namespace.h" #include "symbol.h" #include "ssa_expr.h" +/*******************************************************************\ + +Function: goto_checkt::array_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string array_name( const namespacet &ns, const exprt &expr) diff --git a/src/util/array_name.h b/src/util/array_name.h index e3aee4e57a3..8c797668a65 100644 --- a/src/util/array_name.h +++ b/src/util/array_name.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Misc Utilities - #ifndef CPROVER_UTIL_ARRAY_NAME_H #define CPROVER_UTIL_ARRAY_NAME_H diff --git a/src/util/base_type.cpp b/src/util/base_type.cpp index 2fc72ca6881..340d13116a0 100644 --- a/src/util/base_type.cpp +++ b/src/util/base_type.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Base Type Computation - #include #include @@ -17,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "symbol.h" +/*******************************************************************\ + +Function: base_type_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void base_type_rec( typet &type, const namespacet &ns, std::set &symb) { @@ -75,12 +84,36 @@ void base_type_rec( } } +/*******************************************************************\ + +Function: base_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void base_type(typet &type, const namespacet &ns) { std::set symb; base_type_rec(type, ns, symb); } +/*******************************************************************\ + +Function: base_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void base_type(exprt &expr, const namespacet &ns) { base_type(expr.type(), ns); @@ -89,6 +122,18 @@ void base_type(exprt &expr, const namespacet &ns) base_type(*it, ns); } +/*******************************************************************\ + +Function: base_type_eqt::base_type_eq_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool base_type_eqt::base_type_eq_rec( const typet &type1, const typet &type2) @@ -237,6 +282,18 @@ bool base_type_eqt::base_type_eq_rec( return tmp1==tmp2; } +/*******************************************************************\ + +Function: base_type_eqt::base_type_eq_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool base_type_eqt::base_type_eq_rec( const exprt &expr1, const exprt &expr2) @@ -266,6 +323,18 @@ bool base_type_eqt::base_type_eq_rec( return true; } +/*******************************************************************\ + +Function: base_type_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool base_type_eq( const typet &type1, const typet &type2, @@ -275,6 +344,18 @@ bool base_type_eq( return base_type_eq.base_type_eq(type1, type2); } +/*******************************************************************\ + +Function: base_type_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool base_type_eq( const exprt &expr1, const exprt &expr2, diff --git a/src/util/base_type.h b/src/util/base_type.h index 833fd855cca..41e2fe6df4f 100644 --- a/src/util/base_type.h +++ b/src/util/base_type.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Base Type Computation - #ifndef CPROVER_UTIL_BASE_TYPE_H #define CPROVER_UTIL_BASE_TYPE_H @@ -29,6 +26,14 @@ bool base_type_eq( const exprt &expr2, const namespacet &ns); +/*******************************************************************\ + + Class: base_type_eqt + + Purpose: + +\*******************************************************************/ + class base_type_eqt { public: diff --git a/src/util/bv_arithmetic.cpp b/src/util/bv_arithmetic.cpp index 6df5fe6c187..4e077ad0a1e 100644 --- a/src/util/bv_arithmetic.cpp +++ b/src/util/bv_arithmetic.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "bv_arithmetic.h" +/*******************************************************************\ + +Function: bv_spect::to_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet bv_spect::to_type() const { if(is_signed) @@ -22,18 +34,54 @@ typet bv_spect::to_type() const return unsignedbv_typet(width); } +/*******************************************************************\ + +Function: bv_spect::max_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer bv_spect::max_value() const { return is_signed?power(2, width-1)-1: power(2, width)-1; } +/*******************************************************************\ + +Function: bv_spect::min_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer bv_spect::min_value() const { return is_signed?-power(2, width-1): 0; } +/*******************************************************************\ + +Function: bv_spect::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_spect::from_type(const typet &type) { if(type.id()==ID_unsignedbv) @@ -46,11 +94,35 @@ void bv_spect::from_type(const typet &type) width=unsafe_string2unsigned(type.get_string(ID_width)); } +/*******************************************************************\ + +Function: bv_arithmetict::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_arithmetict::print(std::ostream &out) const { out << to_ansi_c_string(); } +/*******************************************************************\ + +Function: bv_arithmetict::format + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string bv_arithmetict::format(const format_spect &format_spec) const { std::string result; @@ -60,12 +132,36 @@ std::string bv_arithmetict::format(const format_spect &format_spec) const return result; } +/*******************************************************************\ + +Function: bv_arithmetict::from_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_arithmetict::from_integer(const mp_integer &i) { value=i; adjust(); } +/*******************************************************************\ + +Function: bv_arithmetict::adjust + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_arithmetict::adjust() { mp_integer p=power(2, spec.width); @@ -75,6 +171,18 @@ void bv_arithmetict::adjust() value-=p; } +/*******************************************************************\ + +Function: bv_arithmetict::pack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer bv_arithmetict::pack() const { if(value>=0) @@ -82,6 +190,18 @@ mp_integer bv_arithmetict::pack() const return value+power(2, spec.width); } +/*******************************************************************\ + +Function: bv_arithmetict::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt bv_arithmetict::to_expr() const { constant_exprt result(spec.to_type()); @@ -89,6 +209,18 @@ exprt bv_arithmetict::to_expr() const return result; } +/*******************************************************************\ + +Function: operator /= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_arithmetict &bv_arithmetict::operator/=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -101,6 +233,18 @@ bv_arithmetict &bv_arithmetict::operator/=(const bv_arithmetict &other) return *this; } +/*******************************************************************\ + +Function: operator *= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_arithmetict &bv_arithmetict::operator*=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -111,6 +255,18 @@ bv_arithmetict &bv_arithmetict::operator*=(const bv_arithmetict &other) return *this; } +/*******************************************************************\ + +Function: operator += + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_arithmetict &bv_arithmetict::operator+=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -121,6 +277,18 @@ bv_arithmetict &bv_arithmetict::operator+=(const bv_arithmetict &other) return *this; } +/*******************************************************************\ + +Function: operator -= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_arithmetict &bv_arithmetict::operator -= (const bv_arithmetict &other) { assert(other.spec==spec); @@ -131,6 +299,18 @@ bv_arithmetict &bv_arithmetict::operator -= (const bv_arithmetict &other) return *this; } +/*******************************************************************\ + +Function: operator %= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bv_arithmetict &bv_arithmetict::operator%=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -141,47 +321,155 @@ bv_arithmetict &bv_arithmetict::operator%=(const bv_arithmetict &other) return *this; } +/*******************************************************************\ + +Function: operator < + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator<(const bv_arithmetict &other) { return value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator>(const bv_arithmetict &other) { return value>other.value; } +/*******************************************************************\ + +Function: bv_arithmetict::operator>= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator>=(const bv_arithmetict &other) { return value>=other.value; } +/*******************************************************************\ + +Function: bv_arithmetict::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator==(const bv_arithmetict &other) { return value==other.value; } +/*******************************************************************\ + +Function: bv_arithmetict::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator==(int i) { return value==i; } +/*******************************************************************\ + +Function: bv_arithmetict::operator!= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool bv_arithmetict::operator!=(const bv_arithmetict &other) { return value!=other.value; } +/*******************************************************************\ + +Function: bv_arithmetict::change_spec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_arithmetict::change_spec(const bv_spect &dest_spec) { spec=dest_spec; adjust(); } +/*******************************************************************\ + +Function: bv_arithmetict::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void bv_arithmetict::from_expr(const exprt &expr) { assert(expr.is_constant()); diff --git a/src/util/byte_operators.cpp b/src/util/byte_operators.cpp index 6e73ff27731..46e7d3f218e 100644 --- a/src/util/byte_operators.cpp +++ b/src/util/byte_operators.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "byte_operators.h" #include "config.h" +/*******************************************************************\ + +Function: byte_extract_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt byte_extract_id() { switch(config.ansi_c.endianness) @@ -26,6 +38,18 @@ irep_idt byte_extract_id() } } +/*******************************************************************\ + +Function: byte_update_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irep_idt byte_update_id() { switch(config.ansi_c.endianness) diff --git a/src/util/cmdline.cpp b/src/util/cmdline.cpp index 7ac516ab36f..56d6a7a1a6c 100644 --- a/src/util/cmdline.cpp +++ b/src/util/cmdline.cpp @@ -12,21 +12,69 @@ Author: Daniel Kroening, kroening@kroening.com #include "cmdline.h" +/*******************************************************************\ + +Function: cmdlinet::cmdlinet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cmdlinet::cmdlinet() { } +/*******************************************************************\ + +Function: cmdlinet::~cmdlinet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + cmdlinet::~cmdlinet() { clear(); } +/*******************************************************************\ + +Function: cmdlinet::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cmdlinet::clear() { options.clear(); args.clear(); } +/*******************************************************************\ + +Function: cmdlinet::isset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cmdlinet::isset(char option) const { int i=getoptnr(option); @@ -35,6 +83,18 @@ bool cmdlinet::isset(char option) const return options[i].isset; } +/*******************************************************************\ + +Function: cmdlinet::isset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool cmdlinet::isset(const char *option) const { int i=getoptnr(option); @@ -43,6 +103,18 @@ bool cmdlinet::isset(const char *option) const return options[i].isset; } +/*******************************************************************\ + +Function: cmdlinet::get_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cmdlinet::get_value(char option) const { int i=getoptnr(option); @@ -53,6 +125,18 @@ std::string cmdlinet::get_value(char option) const return options[i].values.front(); } +/*******************************************************************\ + +Function: cmdlinet::set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cmdlinet::set(const std::string &option) { int i=getoptnr(option); @@ -61,6 +145,18 @@ void cmdlinet::set(const std::string &option) options[i].isset=true; } +/*******************************************************************\ + +Function: cmdlinet::set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void cmdlinet::set(const std::string &option, const std::string &value) { int i=getoptnr(option); @@ -70,6 +166,18 @@ void cmdlinet::set(const std::string &option, const std::string &value) options[i].values.push_back(value); } +/*******************************************************************\ + +Function: cmdlinet::get_values + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::list &cmdlinet::get_values(char option) const { int i=getoptnr(option); @@ -77,6 +185,18 @@ const std::list &cmdlinet::get_values(char option) const return options[i].values; } +/*******************************************************************\ + +Function: cmdlinet::get_value + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string cmdlinet::get_value(const char *option) const { int i=getoptnr(option); @@ -87,6 +207,18 @@ std::string cmdlinet::get_value(const char *option) const return options[i].values.front(); } +/*******************************************************************\ + +Function: cmdlinet::get_values + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::list &cmdlinet::get_values( const std::string &option) const { @@ -95,6 +227,18 @@ const std::list &cmdlinet::get_values( return options[i].values; } +/*******************************************************************\ + +Function: cmdlinet::getoptnr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int cmdlinet::getoptnr(char option) const { for(unsigned i=0; i #include "decision_procedure.h" +/*******************************************************************\ + +Function: decision_proceduret::in_core + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool decision_proceduret::in_core(const exprt &expr) { assert(false); diff --git a/src/util/decision_procedure.h b/src/util/decision_procedure.h index 65caffab17e..a3c1cf05710 100644 --- a/src/util/decision_procedure.h +++ b/src/util/decision_procedure.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Decision Procedure Interface - #ifndef CPROVER_UTIL_DECISION_PROCEDURE_H #define CPROVER_UTIL_DECISION_PROCEDURE_H diff --git a/src/util/dstring.cpp b/src/util/dstring.cpp index 18602127ea1..4fa9769be23 100644 --- a/src/util/dstring.cpp +++ b/src/util/dstring.cpp @@ -6,7 +6,4 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Container for C-Strings - #include "dstring.h" diff --git a/src/util/dstring.h b/src/util/dstring.h index ae25a395071..bda6dece8e6 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Container for C-Strings - #ifndef CPROVER_UTIL_DSTRING_H #define CPROVER_UTIL_DSTRING_H diff --git a/src/util/endianness_map.cpp b/src/util/endianness_map.cpp index 0813541962d..d030df0c75e 100644 --- a/src/util/endianness_map.cpp +++ b/src/util/endianness_map.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "endianness_map.h" #include "namespace.h" +/*******************************************************************\ + +Function: endianness_mapt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void endianness_mapt::output(std::ostream &out) const { for(std::vector::const_iterator it=map.begin(); @@ -27,6 +39,18 @@ void endianness_mapt::output(std::ostream &out) const } } +/*******************************************************************\ + +Function: endianness_mapt::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void endianness_mapt::build(const typet &src, bool little_endian) { if(little_endian) @@ -35,6 +59,18 @@ void endianness_mapt::build(const typet &src, bool little_endian) build_big_endian(src); } +/*******************************************************************\ + +Function: endianness_mapt::build_little_endian + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void endianness_mapt::build_little_endian(const typet &src) { mp_integer s=pointer_offset_bits(src, ns); // error is -1 @@ -48,6 +84,18 @@ void endianness_mapt::build_little_endian(const typet &src) map.push_back(i); } +/*******************************************************************\ + +Function: endianness_mapt::build_big_endian + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void endianness_mapt::build_big_endian(const typet &src) { if(src.id()==ID_symbol) diff --git a/src/util/expr.cpp b/src/util/expr.cpp index f6b4b0cad4c..3b480e4bfe2 100644 --- a/src/util/expr.cpp +++ b/src/util/expr.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Expression Representation - #include #include @@ -23,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "arith_tools.h" #include "std_expr.h" +/*******************************************************************\ + +Function: exprt::move_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::move_to_operands(exprt &expr) { operandst &op=operands(); @@ -30,6 +39,18 @@ void exprt::move_to_operands(exprt &expr) op.back().swap(expr); } +/*******************************************************************\ + +Function: exprt::move_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::move_to_operands(exprt &e1, exprt &e2) { operandst &op=operands(); @@ -42,6 +63,18 @@ void exprt::move_to_operands(exprt &e1, exprt &e2) op.back().swap(e2); } +/*******************************************************************\ + +Function: exprt::move_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::move_to_operands(exprt &e1, exprt &e2, exprt &e3) { operandst &op=operands(); @@ -56,11 +89,35 @@ void exprt::move_to_operands(exprt &e1, exprt &e2, exprt &e3) op.back().swap(e3); } +/*******************************************************************\ + +Function: exprt::copy_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::copy_to_operands(const exprt &expr) { operands().push_back(expr); } +/*******************************************************************\ + +Function: exprt::copy_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::copy_to_operands(const exprt &e1, const exprt &e2) { operandst &op=operands(); @@ -71,6 +128,18 @@ void exprt::copy_to_operands(const exprt &e1, const exprt &e2) op.push_back(e2); } +/*******************************************************************\ + +Function: exprt::copy_to_operands + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::copy_to_operands( const exprt &e1, const exprt &e2, @@ -85,6 +154,18 @@ void exprt::copy_to_operands( op.push_back(e3); } +/*******************************************************************\ + +Function: exprt::make_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::make_typecast(const typet &_type) { exprt new_expr(ID_typecast); @@ -95,6 +176,18 @@ void exprt::make_typecast(const typet &_type) swap(new_expr); } +/*******************************************************************\ + +Function: exprt::make_not + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::make_not() { if(is_true()) @@ -123,11 +216,35 @@ void exprt::make_not() swap(new_expr); } +/*******************************************************************\ + +Function: exprt::is_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_constant() const { return id()==ID_constant; } +/*******************************************************************\ + +Function: exprt::is_true + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_true() const { return is_constant() && @@ -135,6 +252,18 @@ bool exprt::is_true() const get(ID_value)!=ID_false; } +/*******************************************************************\ + +Function: exprt::is_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_false() const { return is_constant() && @@ -142,24 +271,72 @@ bool exprt::is_false() const get(ID_value)==ID_false; } +/*******************************************************************\ + +Function: exprt::make_bool + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::make_bool(bool value) { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, value?ID_true:ID_false); } +/*******************************************************************\ + +Function: exprt::make_true + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::make_true() { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, ID_true); } +/*******************************************************************\ + +Function: exprt::make_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::make_false() { *this=exprt(ID_constant, typet(ID_bool)); set(ID_value, ID_false); } +/*******************************************************************\ + +Function: exprt::negate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::negate() { const irep_idt &type_id=type().id(); @@ -225,11 +402,35 @@ void exprt::negate() } } +/*******************************************************************\ + +Function: exprt::is_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_boolean() const { return type().id()==ID_bool; } +/*******************************************************************\ + +Function: exprt::is_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_zero() const { if(is_constant()) @@ -274,6 +475,18 @@ bool exprt::is_zero() const return false; } +/*******************************************************************\ + +Function: exprt::is_one + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::is_one() const { if(is_constant()) @@ -315,6 +528,18 @@ bool exprt::is_one() const return false; } +/*******************************************************************\ + +Function: exprt::sum + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::sum(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -368,6 +593,18 @@ bool exprt::sum(const exprt &expr) return true; } +/*******************************************************************\ + +Function: exprt::mul + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::mul(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -421,6 +658,18 @@ bool exprt::mul(const exprt &expr) return true; } +/*******************************************************************\ + +Function: exprt::subtract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool exprt::subtract(const exprt &expr) { if(!is_constant() || !expr.is_constant()) @@ -460,6 +709,18 @@ bool exprt::subtract(const exprt &expr) return true; } +/*******************************************************************\ + +Function: exprt::find_source_location + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const source_locationt &exprt::find_source_location() const { const source_locationt &l=source_location(); @@ -477,6 +738,18 @@ const source_locationt &exprt::find_source_location() const return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: exprt::visit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::visit(expr_visitort &visitor) { std::stack stack; @@ -495,6 +768,18 @@ void exprt::visit(expr_visitort &visitor) } } +/*******************************************************************\ + +Function: exprt::visit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void exprt::visit(const_expr_visitort &visitor) const { std::stack stack; diff --git a/src/util/expr_util.cpp b/src/util/expr_util.cpp index 18bd849fcf7..d5a28e4f5fa 100644 --- a/src/util/expr_util.cpp +++ b/src/util/expr_util.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "arith_tools.h" +/*******************************************************************\ + +Function: make_next_state + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void make_next_state(exprt &expr) { Forall_operands(it, expr) @@ -24,6 +36,18 @@ void make_next_state(exprt &expr) expr.id(ID_next_symbol); } +/*******************************************************************\ + +Function: make_binary + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt make_binary(const exprt &expr) { const exprt::operandst &operands=expr.operands(); @@ -55,6 +79,18 @@ exprt make_binary(const exprt &expr) return previous; } +/*******************************************************************\ + +Function: make_with_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + with_exprt make_with_expr(const update_exprt &src) { const exprt::operandst &designator=src.designator(); @@ -86,6 +122,18 @@ with_exprt make_with_expr(const update_exprt &src) return result; } +/*******************************************************************\ + +Function: is_not_zero + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt is_not_zero( const exprt &src, const namespacet &ns) @@ -115,6 +163,18 @@ exprt is_not_zero( return comparison; } +/*******************************************************************\ + +Function: boolean_negate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt boolean_negate(const exprt &src) { if(src.id()==ID_not && src.operands().size()==1) @@ -127,6 +187,18 @@ exprt boolean_negate(const exprt &src) return not_exprt(src); } +/*******************************************************************\ + +Function: has_subexpr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_subexpr(const exprt &src, const irep_idt &id) { if(src.id()==id) @@ -139,6 +211,18 @@ bool has_subexpr(const exprt &src, const irep_idt &id) return false; } +/*******************************************************************\ + +Function: lift_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + if_exprt lift_if(const exprt &src, std::size_t operand_number) { assert(operand_number #if defined(__linux__) || \ @@ -40,7 +37,18 @@ Date: January 2012 #include "file_util.h" -/// \return current working directory +/*******************************************************************\ + +Function: get_current_working_directory + + Inputs: none + + Outputs: current working directory + + Purpose: + +\*******************************************************************/ + std::string get_current_working_directory() { unsigned bsize=50; @@ -63,7 +71,18 @@ std::string get_current_working_directory() return working_directory; } -/// deletes all files in 'path' and then the directory itself +/*******************************************************************\ + +Function: delete_directory + + Inputs: path + + Outputs: + + Purpose: deletes all files in 'path' and then the directory itself + +\*******************************************************************/ + #ifdef _WIN32 void delete_directory_utf16(const std::wstring &path) @@ -123,8 +142,19 @@ void delete_directory(const std::string &path) #endif } -/// \par parameters: directory name and file name -/// \return concatenation of directory and file, if the file path is relative +/*******************************************************************\ + +Function: concat_dir_file + + Inputs: directory name and file name + + Outputs: concatenation of directory and file, if the file path is + relative + + Purpose: + +\*******************************************************************/ + std::string concat_dir_file( const std::string &directory, const std::string &file_name) diff --git a/src/util/find_macros.cpp b/src/util/find_macros.cpp index 01c9a3547b5..8e2e249ada6 100644 --- a/src/util/find_macros.cpp +++ b/src/util/find_macros.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "symbol.h" +/*******************************************************************\ + +Function: find_macros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_macros( const exprt &src, const namespacet &ns, diff --git a/src/util/find_symbols.cpp b/src/util/find_symbols.cpp index bb60d29eedf..b62ea77b368 100644 --- a/src/util/find_symbols.cpp +++ b/src/util/find_symbols.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com enum class kindt { F_TYPE, F_TYPE_NON_PTR, F_EXPR, F_BOTH }; +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols( const exprt &src, find_symbols_sett &dest) @@ -20,6 +32,18 @@ void find_symbols( find_symbols(src, dest, true, true); } +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols( const exprt &src, find_symbols_sett &dest, @@ -36,6 +60,18 @@ void find_symbols( } } +/*******************************************************************\ + +Function: has_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_symbol( const exprt &src, const find_symbols_sett &symbols, @@ -55,6 +91,18 @@ bool has_symbol( return false; } +/*******************************************************************\ + +Function: has_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool has_symbol( const exprt &src, const find_symbols_sett &symbols) @@ -62,6 +110,18 @@ bool has_symbol( return has_symbol(src, symbols, true, true); } +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols( const exprt &src, std::set &dest) @@ -75,6 +135,18 @@ void find_symbols( } } +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols( const exprt &src, std::set &dest) @@ -88,6 +160,18 @@ void find_symbols( } } +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest); void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest) @@ -113,6 +197,18 @@ void find_symbols(kindt kind, const exprt &src, find_symbols_sett &dest) find_symbols(kind, static_cast(va_arg_type), dest); } +/*******************************************************************\ + +Function: find_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest) { if(kind!=kindt::F_TYPE_NON_PTR || @@ -177,16 +273,52 @@ void find_symbols(kindt kind, const typet &src, find_symbols_sett &dest) } } +/*******************************************************************\ + +Function: find_type_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_type_symbols(const exprt &src, find_symbols_sett &dest) { find_symbols(kindt::F_TYPE, src, dest); } +/*******************************************************************\ + +Function: find_type_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_type_symbols(const typet &src, find_symbols_sett &dest) { find_symbols(kindt::F_TYPE, src, dest); } +/*******************************************************************\ + +Function: find_non_pointer_type_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_non_pointer_type_symbols( const exprt &src, find_symbols_sett &dest) @@ -194,6 +326,18 @@ void find_non_pointer_type_symbols( find_symbols(kindt::F_TYPE_NON_PTR, src, dest); } +/*******************************************************************\ + +Function: find_non_pointer_type_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_non_pointer_type_symbols( const typet &src, find_symbols_sett &dest) @@ -201,11 +345,35 @@ void find_non_pointer_type_symbols( find_symbols(kindt::F_TYPE_NON_PTR, src, dest); } +/*******************************************************************\ + +Function: find_type_and_expr_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest) { find_symbols(kindt::F_BOTH, src, dest); } +/*******************************************************************\ + +Function: find_type_and_expr_symbols + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void find_type_and_expr_symbols(const typet &src, find_symbols_sett &dest) { find_symbols(kindt::F_BOTH, src, dest); diff --git a/src/util/fixedbv.cpp b/src/util/fixedbv.cpp index b1635836d93..d1703d85ca9 100644 --- a/src/util/fixedbv.cpp +++ b/src/util/fixedbv.cpp @@ -11,34 +11,106 @@ Author: Daniel Kroening, kroening@kroening.com #include "fixedbv.h" #include "arith_tools.h" +/*******************************************************************\ + +Function: fixedbv_spect::fixedbv_spect + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + fixedbv_spect::fixedbv_spect(const fixedbv_typet &type) { integer_bits=type.get_integer_bits(); width=type.get_width(); } +/*******************************************************************\ + +Function: fixedbvt::fixedbvt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + fixedbvt::fixedbvt(const constant_exprt &expr) { from_expr(expr); } +/*******************************************************************\ + +Function: fixedbvt::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fixedbvt::from_expr(const constant_exprt &expr) { spec=fixedbv_spect(to_fixedbv_type(expr.type())); v=binary2integer(id2string(expr.get_value()), true); } +/*******************************************************************\ + +Function: fixedbvt::from_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fixedbvt::from_integer(const mp_integer &i) { v=i*power(2, spec.get_fraction_bits()); } +/*******************************************************************\ + +Function: fixedbvt::to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer fixedbvt::to_integer() const { // this rounds to zero, i.e., we just divide return v/power(2, spec.get_fraction_bits()); } +/*******************************************************************\ + +Function: fixedbvt::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt fixedbvt::to_expr() const { fixedbv_typet type; @@ -50,6 +122,18 @@ constant_exprt fixedbvt::to_expr() const return expr; } +/*******************************************************************\ + +Function: fixedbvt::round + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fixedbvt::round(const fixedbv_spect &dest_spec) { std::size_t old_fraction_bits=spec.width-spec.integer_bits; @@ -83,11 +167,35 @@ void fixedbvt::round(const fixedbv_spect &dest_spec) spec=dest_spec; } +/*******************************************************************\ + +Function: fixedbvt::negate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void fixedbvt::negate() { v=-v; } +/*******************************************************************\ + +Function: fixedbvt::operator* + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + fixedbvt &fixedbvt::operator*=(const fixedbvt &o) { v*=o.v; @@ -102,6 +210,18 @@ fixedbvt &fixedbvt::operator*=(const fixedbvt &o) return *this; } +/*******************************************************************\ + +Function: fixedbvt::operator/= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + fixedbvt &fixedbvt::operator/=(const fixedbvt &o) { v*=power(2, o.spec.get_fraction_bits()); @@ -110,11 +230,35 @@ fixedbvt &fixedbvt::operator/=(const fixedbvt &o) return *this; } +/*******************************************************************\ + +Function: fixedbvt::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool fixedbvt::operator==(int i) const { return v==power(2, spec.get_fraction_bits())*i; } +/*******************************************************************\ + +Function: fixedbvt::format + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string fixedbvt::format( const format_spect &format_spec) const { diff --git a/src/util/format_constant.cpp b/src/util/format_constant.cpp index 5175ce46c69..a63b1d01555 100644 --- a/src/util/format_constant.cpp +++ b/src/util/format_constant.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr.h" #include "std_expr.h" +/*******************************************************************\ + +Function: format_constantt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string format_constantt::operator()(const exprt &expr) { if(expr.is_constant()) diff --git a/src/util/format_number_range.cpp b/src/util/format_number_range.cpp index c3cc9d24b9c..cca3bbf154c 100644 --- a/src/util/format_number_range.cpp +++ b/src/util/format_number_range.cpp @@ -6,18 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Format vector of numbers into a compressed range - #include #include #include #include "format_number_range.h" -/// create shorter representation for output -/// \par parameters: vector of numbers -/// \return string of compressed number range representation +/*******************************************************************\ + +Function: format_number_range::operator() + + Inputs: vector of numbers + + Outputs: string of compressed number range representation + + Purpose: create shorter representation for output + +\*******************************************************************/ + std::string format_number_ranget::operator()(std::vector &numbers) { std::string number_range; diff --git a/src/util/format_number_range.h b/src/util/format_number_range.h index 493b82abc99..7ff016e9c4d 100644 --- a/src/util/format_number_range.h +++ b/src/util/format_number_range.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Format vector of numbers into a compressed range - #ifndef CPROVER_UTIL_FORMAT_NUMBER_RANGE_H #define CPROVER_UTIL_FORMAT_NUMBER_RANGE_H diff --git a/src/util/fresh_symbol.cpp b/src/util/fresh_symbol.cpp index 7fb9d7f286a..fbe6f09b871 100644 --- a/src/util/fresh_symbol.cpp +++ b/src/util/fresh_symbol.cpp @@ -6,19 +6,27 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Fresh auxiliary symbol creation - #include "fresh_symbol.h" -/// Installs a fresh-named symbol with the requested name pattern -/// \par parameters: `type`: type of new symbol -/// `name_prefix`, `basename_prefix`: new symbol will be named -/// name_prefix::basename_prefix$num unless name_prefix is empty, in which -/// case the :: prefix is omitted. -/// `source_location`: new symbol source loc -/// `symbol_mode`: new symbol mode -/// `symbol_table`: table to add the new symbol to +/*******************************************************************\ + +Function: get_fresh_aux_symbol + + Inputs: `type`: type of new symbol + `name_prefix`, `basename_prefix`: + new symbol will be named name_prefix::basename_prefix$num + unless name_prefix is empty, in which case the :: prefix + is omitted. + `source_location`: new symbol source loc + `symbol_mode`: new symbol mode + `symbol_table`: table to add the new symbol to + + Outputs: + + Purpose: Installs a fresh-named symbol with the requested name pattern + +\*******************************************************************/ + symbolt &get_fresh_aux_symbol( const typet &type, const std::string &name_prefix, diff --git a/src/util/fresh_symbol.h b/src/util/fresh_symbol.h index a176a16a551..c3b2749cbe3 100644 --- a/src/util/fresh_symbol.h +++ b/src/util/fresh_symbol.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// Fresh auxiliary symbol creation - #ifndef CPROVER_UTIL_FRESH_SYMBOL_H #define CPROVER_UTIL_FRESH_SYMBOL_H diff --git a/src/util/get_base_name.cpp b/src/util/get_base_name.cpp index 73984e0e2f5..3f7bb186937 100644 --- a/src/util/get_base_name.cpp +++ b/src/util/get_base_name.cpp @@ -10,9 +10,18 @@ Author: CM Wintersteiger #include "get_base_name.h" -/// cleans a filename from path and extension -/// \par parameters: a string -/// \return a new string +/*******************************************************************\ + +Function: get_base_name + + Inputs: a string + + Outputs: a new string + + Purpose: cleans a filename from path and extension + +\*******************************************************************/ + std::string get_base_name(const std::string &in, bool strip_suffix) { size_t r=std::string::npos; diff --git a/src/util/get_module.cpp b/src/util/get_module.cpp index 655c64c6653..e4afd21400f 100644 --- a/src/util/get_module.cpp +++ b/src/util/get_module.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Find module symbol using name - #include #include @@ -26,6 +23,18 @@ typedef std::list symbolptr_listt; for(symbolptr_listt::iterator it=(list).begin(); \ it!=(list).end(); ++it) +/*******************************************************************\ + +Function: get_module_by_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &get_module_by_name( const symbol_tablet &symbol_table, const std::string &module, @@ -71,6 +80,18 @@ const symbolt &get_module_by_name( return *symbolptr_list.front(); } +/*******************************************************************\ + +Function: get_module + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const symbolt &get_module( const symbol_tablet &symbol_table, const std::string &module, diff --git a/src/util/get_module.h b/src/util/get_module.h index 73eda37dfbb..1f1063c073c 100644 --- a/src/util/get_module.h +++ b/src/util/get_module.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Find module symbol using name - #ifndef CPROVER_UTIL_GET_MODULE_H #define CPROVER_UTIL_GET_MODULE_H diff --git a/src/util/graph.cpp b/src/util/graph.cpp index 2d80781f41a..07fabf150da 100644 --- a/src/util/graph.cpp +++ b/src/util/graph.cpp @@ -6,7 +6,4 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// A Template Class for Graphs - #include "graph.h" diff --git a/src/util/graph.h b/src/util/graph.h index 4a49719f7a2..42988914362 100644 --- a/src/util/graph.h +++ b/src/util/graph.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// A Template Class for Graphs - #ifndef CPROVER_UTIL_GRAPH_H #define CPROVER_UTIL_GRAPH_H @@ -258,6 +255,18 @@ class grapht bool non_trivial) const; }; +/*******************************************************************\ + +Function: grapht::add_undirected_edge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::add_undirected_edge(node_indext a, node_indext b) { @@ -271,6 +280,18 @@ void grapht::add_undirected_edge(node_indext a, node_indext b) nb.add_in(a); } +/*******************************************************************\ + +Function: grapht::remove_undirected_edge + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::remove_undirected_edge(node_indext a, node_indext b) { @@ -282,6 +303,18 @@ void grapht::remove_undirected_edge(node_indext a, node_indext b) nb.in.erase(a); } +/*******************************************************************\ + +Function: grapht::remove_in_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::remove_in_edges(node_indext n) { @@ -297,6 +330,18 @@ void grapht::remove_in_edges(node_indext n) node.in.clear(); } +/*******************************************************************\ + +Function: grapht::remove_out_edges + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::remove_out_edges(node_indext n) { @@ -312,6 +357,18 @@ void grapht::remove_out_edges(node_indext n) node.out.clear(); } +/*******************************************************************\ + +Function: grapht::shortest_path + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::shortest_path( node_indext src, @@ -403,6 +460,18 @@ void grapht::shortest_path( } } +/*******************************************************************\ + +Function: grapht::visit_reachable + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::visit_reachable(node_indext src) { @@ -428,6 +497,18 @@ void grapht::visit_reachable(node_indext src) } } +/*******************************************************************\ + +Function: grapht::connected_subgraphs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template std::size_t grapht::connected_subgraphs( std::vector &subgraph_nr) @@ -473,6 +554,18 @@ std::size_t grapht::connected_subgraphs( return nr; } +/*******************************************************************\ + +Function: grapht::tarjan + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::tarjan(tarjant &t, node_indext v) { @@ -517,6 +610,18 @@ void grapht::tarjan(tarjant &t, node_indext v) } } +/*******************************************************************\ + +Function: grapht::SCCs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template std::size_t grapht::SCCs(std::vector &subgraph_nr) { @@ -529,6 +634,18 @@ std::size_t grapht::SCCs(std::vector &subgraph_nr) return t.scc_count; } +/*******************************************************************\ + +Function: grapht::make_chordal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::make_chordal() { @@ -565,6 +682,18 @@ void grapht::make_chordal() } } +/*******************************************************************\ + +Function: grapht::output_dot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::output_dot(std::ostream &out) const { @@ -572,6 +701,18 @@ void grapht::output_dot(std::ostream &out) const output_dot_node(out, n); } +/*******************************************************************\ + +Function: grapht::output_dot_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template void grapht::output_dot_node(std::ostream &out, node_indext n) const { diff --git a/src/util/guard.cpp b/src/util/guard.cpp index d77f157176c..da9cc130723 100644 --- a/src/util/guard.cpp +++ b/src/util/guard.cpp @@ -6,15 +6,24 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Symbolic Execution - #include #include "std_expr.h" #include "simplify_utils.h" #include "guard.h" +/*******************************************************************\ + +Function: guardt::as_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void guardt::guard_expr(exprt &dest) const { if(is_true()) @@ -39,6 +48,18 @@ void guardt::guard_expr(exprt &dest) const } #if 0 +/*******************************************************************\ + +Function: guardt::as_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt guardt::as_expr(guard_listt::const_iterator it) const { if(it==guard_list.end()) @@ -60,6 +81,18 @@ exprt guardt::as_expr(guard_listt::const_iterator it) const } #endif +/*******************************************************************\ + +Function: guardt::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void guardt::add(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -89,6 +122,18 @@ void guardt::add(const exprt &expr) op.push_back(expr); } +/*******************************************************************\ + +Function: operator -= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + guardt &operator -= (guardt &g1, const guardt &g2) { if(g1.id()!=ID_and || g2.id()!=ID_and) @@ -118,6 +163,18 @@ guardt &operator -= (guardt &g1, const guardt &g2) return g1; } +/*******************************************************************\ + +Function: operator |= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + guardt &operator |= (guardt &g1, const guardt &g2) { if(g2.is_false() || g1.is_true()) @@ -203,6 +260,18 @@ guardt &operator |= (guardt &g1, const guardt &g2) } #if 0 +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator << (std::ostream &out, const guardt &g) { forall_expr_list(it, g.guard_list) @@ -210,6 +279,18 @@ std::ostream &operator << (std::ostream &out, const guardt &g) return out; } +/*******************************************************************\ + +Function: guardt::is_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #define forall_guard(it, guard_list) \ for(guardt::guard_listt::const_iterator it=(guard_list).begin(); \ it!=(guard_list).end(); ++it) @@ -223,6 +304,18 @@ bool guardt::is_false() const return false; } +/*******************************************************************\ + +Function: guardt::make_false + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void guardt::make_false() { guard_list.clear(); diff --git a/src/util/guard.h b/src/util/guard.h index a923680e2ad..215ac58ba02 100644 --- a/src/util/guard.h +++ b/src/util/guard.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Guard Data Structure - #ifndef CPROVER_UTIL_GUARD_H #define CPROVER_UTIL_GUARD_H diff --git a/src/util/identifier.cpp b/src/util/identifier.cpp index fef77e314e0..96074d9c43e 100644 --- a/src/util/identifier.cpp +++ b/src/util/identifier.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "identifier.h" +/*******************************************************************\ + +Function: identifiert::as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string identifiert::as_string() const { std::string result; @@ -25,6 +37,18 @@ std::string identifiert::as_string() const return result; } +/*******************************************************************\ + +Function: identifiert::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void identifiert::parse(const std::string &s) { std::string component; diff --git a/src/util/ieee_float.cpp b/src/util/ieee_float.cpp index fac8ccdf582..73290f70654 100644 --- a/src/util/ieee_float.cpp +++ b/src/util/ieee_float.cpp @@ -19,11 +19,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "ieee_float.h" +/*******************************************************************\ + +Function: ieee_float_spect::bias + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_float_spect::bias() const { return power(2, e-1)-1; } +/*******************************************************************\ + +Function: ieee_float_spect::to_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + floatbv_typet ieee_float_spect::to_type() const { floatbv_typet result; @@ -34,16 +58,52 @@ floatbv_typet ieee_float_spect::to_type() const return result; } +/*******************************************************************\ + +Function: ieee_float_spect::max_exponent + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_float_spect::max_exponent() const { return power(2, e)-1; } +/*******************************************************************\ + +Function: ieee_float_spect::max_fraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_float_spect::max_fraction() const { return power(2, f)-1; } +/*******************************************************************\ + +Function: ieee_float_spect::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_float_spect::from_type(const floatbv_typet &type) { std::size_t width=type.get_width(); @@ -56,11 +116,35 @@ void ieee_float_spect::from_type(const floatbv_typet &type) e=e-1; // no hidden bit } +/*******************************************************************\ + +Function: ieee_floatt::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::print(std::ostream &out) const { out << to_ansi_c_string(); } +/*******************************************************************\ + +Function: ieee_floatt::format + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string ieee_floatt::format(const format_spect &format_spec) const { std::string result; @@ -121,6 +205,18 @@ std::string ieee_floatt::format(const format_spect &format_spec) const return result; } +/*******************************************************************\ + +Function: ieee_floatt::base10_digits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_floatt::base10_digits(const mp_integer &src) { mp_integer tmp=src; @@ -130,6 +226,18 @@ mp_integer ieee_floatt::base10_digits(const mp_integer &src) return result; } +/*******************************************************************\ + +Function: ieee_floatt::to_string_decimal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string ieee_floatt::to_string_decimal(std::size_t precision) const { std::string result; @@ -221,8 +329,20 @@ std::string ieee_floatt::to_string_decimal(std::size_t precision) const return result; } -/// format as [-]d.ddde+-d Note that printf always produces at least two digits -/// for the exponent. +/*******************************************************************\ + +Function: ieee_floatt::to_string_scientific + + Inputs: + + Outputs: + + Purpose: format as [-]d.ddde+-d + Note that printf always produces at least two digits + for the exponent. + +\*******************************************************************/ + std::string ieee_floatt::to_string_scientific(std::size_t precision) const { std::string result; @@ -310,6 +430,18 @@ std::string ieee_floatt::to_string_scientific(std::size_t precision) const return result; } +/*******************************************************************\ + +Function: ieee_floatt::unpack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::unpack(const mp_integer &i) { assert(spec.f!=0); @@ -360,11 +492,35 @@ void ieee_floatt::unpack(const mp_integer &i) } } +/*******************************************************************\ + +Function: ieee_floatt::is_normal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::is_normal() const { return fraction>=power(2, spec.f); } +/*******************************************************************\ + +Function: ieee_floatt::pack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_floatt::pack() const { mp_integer result=0; @@ -403,6 +559,18 @@ mp_integer ieee_floatt::pack() const return result; } +/*******************************************************************\ + +Function: ieee_floatt::extract_base2 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::extract_base2( mp_integer &_fraction, mp_integer &_exponent) const @@ -427,6 +595,18 @@ void ieee_floatt::extract_base2( } } +/*******************************************************************\ + +Function: ieee_floatt::extract_base10 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::extract_base10( mp_integer &_fraction, mp_integer &_exponent) const @@ -463,6 +643,18 @@ void ieee_floatt::extract_base10( } } +/*******************************************************************\ + +Function: ieee_floatt::build + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::build( const mp_integer &_fraction, const mp_integer &_exponent) @@ -476,7 +668,18 @@ void ieee_floatt::build( align(); } -/// compute f * (10^e) +/*******************************************************************\ + +Function: ieee_floatt::from_base10 + + Inputs: + + Outputs: + + Purpose: compute f * (10^e) + +\*******************************************************************/ + void ieee_floatt::from_base10( const mp_integer &_fraction, const mp_integer &_exponent) @@ -506,6 +709,18 @@ void ieee_floatt::from_base10( align(); } +/*******************************************************************\ + +Function: ieee_floatt::from_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::from_integer(const mp_integer &i) { NaN_flag=infinity_flag=sign_flag=false; @@ -514,6 +729,18 @@ void ieee_floatt::from_integer(const mp_integer &i) align(); } +/*******************************************************************\ + +Function: ieee_floatt::align + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::align() { // NaN? @@ -634,6 +861,18 @@ void ieee_floatt::align() exponent=0; } +/*******************************************************************\ + +Function: ieee_floatt::divide_and_round + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::divide_and_round( mp_integer &fraction, const mp_integer &factor) @@ -684,6 +923,18 @@ void ieee_floatt::divide_and_round( } } +/*******************************************************************\ + +Function: ieee_floatt::to_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt ieee_floatt::to_expr() const { constant_exprt result(spec.to_type()); @@ -691,6 +942,18 @@ constant_exprt ieee_floatt::to_expr() const return result; } +/*******************************************************************\ + +Function: operator /= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_floatt &ieee_floatt::operator/=(const ieee_floatt &other) { assert(other.spec.f==spec.f); @@ -765,6 +1028,18 @@ ieee_floatt &ieee_floatt::operator/=(const ieee_floatt &other) return *this; } +/*******************************************************************\ + +Function: operator *= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_floatt &ieee_floatt::operator*=(const ieee_floatt &other) { assert(other.spec.f==spec.f); @@ -801,6 +1076,18 @@ ieee_floatt &ieee_floatt::operator*=(const ieee_floatt &other) return *this; } +/*******************************************************************\ + +Function: operator += + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_floatt &ieee_floatt::operator+=(const ieee_floatt &other) { ieee_floatt _other=other; @@ -890,6 +1177,18 @@ ieee_floatt &ieee_floatt::operator+=(const ieee_floatt &other) return *this; } +/*******************************************************************\ + +Function: operator -= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other) { ieee_floatt _other=other; @@ -897,6 +1196,18 @@ ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other) return (*this)+=_other; } +/*******************************************************************\ + +Function: ieee_floatt::operator< + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator<(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -943,6 +1254,18 @@ bool ieee_floatt::operator<(const ieee_floatt &other) const return fraction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator>(const ieee_floatt &other) const { return other<*this; } +/*******************************************************************\ + +Function: ieee_floatt::operator>= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator>=(const ieee_floatt &other) const { return other<=*this; } +/*******************************************************************\ + +Function: ieee_floatt::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator==(const ieee_floatt &other) const { // packed equality! @@ -998,6 +1357,18 @@ bool ieee_floatt::operator==(const ieee_floatt &other) const sign_flag==other.sign_flag; } +/*******************************************************************\ + +Function: ieee_floatt::ieee_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::ieee_equal(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -1008,6 +1379,18 @@ bool ieee_floatt::ieee_equal(const ieee_floatt &other) const return *this==other; } +/*******************************************************************\ + +Function: ieee_floatt::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator==(int i) const { ieee_floatt other(spec); @@ -1015,11 +1398,35 @@ bool ieee_floatt::operator==(int i) const return *this==other; } +/*******************************************************************\ + +Function: ieee_floatt::operator!= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::operator!=(const ieee_floatt &other) const { return !(*this==other); } +/*******************************************************************\ + +Function: ieee_floatt::ieee_not_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const { if(NaN_flag || other.NaN_flag) @@ -1030,6 +1437,18 @@ bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const return *this!=other; } +/*******************************************************************\ + +Function: ieee_floatt::change_spec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::change_spec(const ieee_float_spect &dest_spec) { mp_integer _exponent=exponent-spec.f; @@ -1049,12 +1468,36 @@ void ieee_floatt::change_spec(const ieee_float_spect &dest_spec) build(_fraction, _exponent); } +/*******************************************************************\ + +Function: ieee_floatt::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::from_expr(const constant_exprt &expr) { spec=ieee_float_spect(to_floatbv_type(expr.type())); unpack(binary2integer(id2string(expr.get_value()), false)); } +/*******************************************************************\ + +Function: ieee_floatt::to_integer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer ieee_floatt::to_integer() const { if(NaN_flag || infinity_flag || is_zero()) @@ -1076,6 +1519,18 @@ mp_integer ieee_floatt::to_integer() const return result; } +/*******************************************************************\ + +Function: ieee_floatt::from_double + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::from_double(const double d) { spec.f=52; @@ -1096,6 +1551,18 @@ void ieee_floatt::from_double(const double d) unpack(u.i); } +/*******************************************************************\ + +Function: ieee_floatt::from_float + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::from_float(const float f) { spec.f=23; @@ -1115,6 +1582,18 @@ void ieee_floatt::from_float(const float f) unpack(u.i); } +/*******************************************************************\ + +Function: ieee_floatt::make_NaN + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::make_NaN() { NaN_flag=true; @@ -1124,6 +1603,18 @@ void ieee_floatt::make_NaN() infinity_flag=false; } +/*******************************************************************\ + +Function: ieee_floatt::make_fltmax + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::make_fltmax() { mp_integer bit_pattern= @@ -1131,11 +1622,35 @@ void ieee_floatt::make_fltmax() unpack(bit_pattern); } +/*******************************************************************\ + +Function: ieee_floatt::make_fltmin + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::make_fltmin() { unpack(power(2, spec.f)); } +/*******************************************************************\ + +Function: ieee_floatt::make_plus_infinity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::make_plus_infinity() { NaN_flag=false; @@ -1145,24 +1660,71 @@ void ieee_floatt::make_plus_infinity() infinity_flag=true; } +/*******************************************************************\ + +Function: ieee_floatt::make_minus_infinity + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ieee_floatt::make_minus_infinity() { make_plus_infinity(); sign_flag=true; } +/*******************************************************************\ + +Function: ieee_floatt::is_double + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::is_double() const { return spec.f==52 && spec.e==11; } +/*******************************************************************\ + +Function: ieee_floatt::is_float + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool ieee_floatt::is_float() const { return spec.f==23 && spec.e==8; } -/// Note that calling from_double -> to_double can return different bit patterns -/// for NaN. +/*******************************************************************\ + +Function: ieee_floatt::to_double + + Inputs: + + Outputs: + + Purpose: Note that calling from_double -> to_double can return different bit + patterns for NaN. + +\*******************************************************************/ + double ieee_floatt::to_double() const { union { double f; uint64_t i; } a; @@ -1190,8 +1752,19 @@ double ieee_floatt::to_double() const return a.f; } -/// Note that calling from_float -> to_float can return different bit patterns -/// for NaN. +/*******************************************************************\ + +Function: ieee_floatt::to_float + + Inputs: + + Outputs: + + Purpose: Note that calling from_float -> to_float can return different bit + patterns for NaN. + +\*******************************************************************/ + float ieee_floatt::to_float() const { if(sizeof(unsigned)!=sizeof(float)) @@ -1224,8 +1797,20 @@ float ieee_floatt::to_float() const return a.f; } -/// Sets *this to the next representable number closer to plus infinity (greater -/// = true) or minus infinity (greater = false). +/*******************************************************************\ + +Function: ieee_floatt::next_representable + + Inputs: + + Outputs: + + Purpose: Sets *this to the next representable number closer to + plus infinity (greater = true) or minus infinity + (greater = false). + +\*******************************************************************/ + void ieee_floatt::next_representable(bool greater) { if(is_NaN()) diff --git a/src/util/infix.h b/src/util/infix.h index 0ff47c646c1..2fcc1338d5d 100644 --- a/src/util/infix.h +++ b/src/util/infix.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris.smowton@diffblue.com \*******************************************************************/ -/// \file -/// String infix shorthand - #ifndef CPROVER_UTIL_INFIX_H #define CPROVER_UTIL_INFIX_H diff --git a/src/util/irep.cpp b/src/util/irep.cpp index d2bbbd59085..886f8ce9d7b 100644 --- a/src/util/irep.cpp +++ b/src/util/irep.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Internal Representation - #include #include @@ -31,6 +28,18 @@ irept nil_rep_storage; irept::dt irept::empty_d; #endif +/*******************************************************************\ + +Function: named_subt_lower_bound + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef SUB_IS_LIST static inline bool named_subt_order( const std::pair &a, @@ -52,6 +61,18 @@ static inline irept::named_subt::iterator named_subt_lower_bound( } #endif +/*******************************************************************\ + +Function: get_nil_irep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irept &get_nil_irep() { if(nil_rep_storage.id().empty()) // initialized? @@ -59,6 +80,18 @@ const irept &get_nil_irep() return nil_rep_storage; } +/*******************************************************************\ + +Function: irept::detach + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef SHARING void irept::detach() { @@ -95,6 +128,18 @@ void irept::detach() } #endif +/*******************************************************************\ + +Function: irept::remove_ref + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef SHARING void irept::remove_ref(dt *old_data) { @@ -133,8 +178,19 @@ void irept::remove_ref(dt *old_data) } #endif -/// Does the same as remove_ref, but using an explicit stack instead of -/// recursion. +/*******************************************************************\ + +Function: irept::nonrecursive_destructor + + Inputs: + + Outputs: + + Purpose: Does the same as remove_ref, but + using an explicit stack instead of recursion. + +\*******************************************************************/ + #ifdef SHARING void irept::nonrecursive_destructor(dt *old_data) { @@ -191,6 +247,18 @@ void irept::nonrecursive_destructor(dt *old_data) } #endif +/*******************************************************************\ + +Function: irept::move_to_named_sub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irept::move_to_named_sub(const irep_namet &name, irept &irep) { #ifdef SHARING @@ -200,6 +268,18 @@ void irept::move_to_named_sub(const irep_namet &name, irept &irep) irep.clear(); } +/*******************************************************************\ + +Function: irept::move_to_sub + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irept::move_to_sub(irept &irep) { #ifdef SHARING @@ -209,6 +289,18 @@ void irept::move_to_sub(irept &irep) get_sub().back().swap(irep); } +/*******************************************************************\ + +Function: irept::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irep_idt &irept::get(const irep_namet &name) const { const named_subt &s= @@ -236,36 +328,120 @@ const irep_idt &irept::get(const irep_namet &name) const return it->second.id(); } +/*******************************************************************\ + +Function: irept::get_bool + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool irept::get_bool(const irep_namet &name) const { return get(name)==ID_1; } +/*******************************************************************\ + +Function: irept::get_int + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int irept::get_int(const irep_namet &name) const { return unsafe_string2int(get_string(name)); } +/*******************************************************************\ + +Function: irept::get_unsigned_int + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned int irept::get_unsigned_int(const irep_namet &name) const { return unsafe_string2unsigned(get_string(name)); } +/*******************************************************************\ + +Function: irept::get_size_t + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t irept::get_size_t(const irep_namet &name) const { return unsafe_string2size_t(get_string(name)); } +/*******************************************************************\ + +Function: irept::get_long_long + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + long long irept::get_long_long(const irep_namet &name) const { return unsafe_string2signedlonglong(get_string(name)); } +/*******************************************************************\ + +Function: irept::set + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irept::set(const irep_namet &name, const long long value) { add(name).id(std::to_string(value)); } +/*******************************************************************\ + +Function: irept::remove + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irept::remove(const irep_namet &name) { named_subt &s= @@ -281,6 +457,18 @@ void irept::remove(const irep_namet &name) #endif } +/*******************************************************************\ + +Function: irept::find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irept &irept::find(const irep_namet &name) const { const named_subt &s= @@ -302,6 +490,18 @@ const irept &irept::find(const irep_namet &name) const return it->second; } +/*******************************************************************\ + +Function: irept::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irept &irept::add(const irep_namet &name) { named_subt &s= @@ -320,6 +520,18 @@ irept &irept::add(const irep_namet &name) #endif } +/*******************************************************************\ + +Function: irept::add + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irept &irept::add(const irep_namet &name, const irept &irep) { named_subt &s= @@ -346,6 +558,18 @@ irept &irept::add(const irep_namet &name, const irept &irep) #endif } +/*******************************************************************\ + +Function: irept::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #ifdef IREP_HASH_STATS unsigned long long irep_cmp_cnt=0; unsigned long long irep_cmp_ne_cnt=0; @@ -376,6 +600,18 @@ bool irept::operator==(const irept &other) const return true; } +/*******************************************************************\ + +Function: irept::full_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool irept::full_eq(const irept &other) const { #ifdef SHARING @@ -425,7 +661,18 @@ bool irept::full_eq(const irept &other) const return true; } -/// defines ordering on the internal represenation +/*******************************************************************\ + +Function: irept::ordering + + Inputs: + + Outputs: + + Purpose: defines ordering on the internal represenation + +\*******************************************************************/ + bool irept::ordering(const irept &other) const { return compare(other)<0; @@ -491,7 +738,18 @@ bool irept::ordering(const irept &other) const #endif } -/// defines ordering on the internal represenation +/*******************************************************************\ + +Function: irept::compare + + Inputs: + + Outputs: + + Purpose: defines ordering on the internal represenation + +\*******************************************************************/ + int irept::compare(const irept &i) const { int r; @@ -557,12 +815,36 @@ int irept::compare(const irept &i) const return 0; } -/// defines ordering on the internal represenation +/*******************************************************************\ + +Function: irept::operator< + + Inputs: + + Outputs: + + Purpose: defines ordering on the internal represenation + +\*******************************************************************/ + bool irept::operator<(const irept &other) const { return ordering(other); } +/*******************************************************************\ + +Function: irept::hash + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + + #ifdef IREP_HASH_STATS unsigned long long irep_hash_cnt=0; #endif @@ -598,6 +880,18 @@ std::size_t irept::hash() const return result; } +/*******************************************************************\ + +Function: irept::full_hash + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t irept::full_hash() const { const irept::subt &sub=get_sub(); @@ -627,12 +921,36 @@ std::size_t irept::full_hash() const return result; } +/*******************************************************************\ + +Function: indent + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void indent_str(std::string &s, unsigned indent) { for(unsigned i=0; i0 && indent>max_indent) diff --git a/src/util/irep_hash.cpp b/src/util/irep_hash.cpp index a68776d00cd..96a00a27595 100644 --- a/src/util/irep_hash.cpp +++ b/src/util/irep_hash.cpp @@ -6,7 +6,4 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ -/// \file -/// irep hash functions - #include "irep_hash.h" diff --git a/src/util/irep_hash.h b/src/util/irep_hash.h index ce4ef52da76..b0d24221ff3 100644 --- a/src/util/irep_hash.h +++ b/src/util/irep_hash.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ -/// \file -/// irep hash functions - #ifndef CPROVER_UTIL_IREP_HASH_H #define CPROVER_UTIL_IREP_HASH_H @@ -77,6 +74,18 @@ std::size_t basic_hash_combine( std::size_t h1, std::size_t h2); +/*******************************************************************\ + +Function: basic_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> inline std::size_t basic_hash_combine<32>( std::size_t h1, @@ -85,6 +94,18 @@ inline std::size_t basic_hash_combine<32>( return ROTL32(h1, 7)^h2; } +/*******************************************************************\ + +Function: basic_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> inline std::size_t basic_hash_combine<64>( std::size_t h1, @@ -106,6 +127,18 @@ inline std::size_t basic_hash_combine<64>( #endif } +/*******************************************************************\ + +Function: basic_hash_finalize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + inline std::size_t basic_hash_finalize( std::size_t h1, std::size_t len) @@ -142,6 +175,18 @@ std::size_t murmurhash2a_hash_finalize( std::size_t h1, std::size_t len); +/*******************************************************************\ + +Function: murmurhash2a_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static FORCE_INLINE uint32_t mmix32(uint32_t h1, uint32_t h2) { const int r=24; @@ -164,7 +209,18 @@ inline std::size_t murmurhash2a_hash_combine<32>( return mmix32(h1, h2); } -/// force all bits of a hash block to avalanche +/*******************************************************************\ + +Function: murmurhash2a_hash_finalize + + Inputs: + + Outputs: + + Purpose: force all bits of a hash block to avalanche + +\*******************************************************************/ + template<> inline std::size_t murmurhash2a_hash_finalize<32>( std::size_t h1, @@ -181,6 +237,18 @@ inline std::size_t murmurhash2a_hash_finalize<32>( return h1; } +/*******************************************************************\ + +Function: murmurhash2a_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static FORCE_INLINE uint64_t mmix64(uint64_t h1, uint64_t h2) { const int r=47; @@ -205,7 +273,18 @@ inline std::size_t murmurhash2a_hash_combine<64>( return mmix64(h1, h2); } -/// force all bits of a hash block to avalanche +/*******************************************************************\ + +Function: murmurhash2a_hash_finalize + + Inputs: + + Outputs: + + Purpose: force all bits of a hash block to avalanche + +\*******************************************************************/ + template<> inline std::size_t murmurhash2a_hash_finalize<64>( std::size_t h1, @@ -249,6 +328,18 @@ std::size_t murmurhash3_hash_finalize( std::size_t h1, std::size_t len); +/*******************************************************************\ + +Function: murmurhash3_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> inline std::size_t murmurhash3_hash_combine<32>( std::size_t h1, @@ -268,7 +359,18 @@ inline std::size_t murmurhash3_hash_combine<32>( return h1; } -/// force all bits of a hash block to avalanche +/*******************************************************************\ + +Function: murmurhash3_hash_finalize + + Inputs: + + Outputs: + + Purpose: force all bits of a hash block to avalanche + +\*******************************************************************/ + static FORCE_INLINE uint32_t fmix32(uint32_t h) { h^=h>>16; @@ -290,6 +392,18 @@ inline std::size_t murmurhash3_hash_finalize<32>( return fmix32(h1); } +/*******************************************************************\ + +Function: murmurhash3_hash_combine + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template<> inline std::size_t murmurhash3_hash_combine<64>( std::size_t h1, @@ -315,7 +429,18 @@ inline std::size_t murmurhash3_hash_combine<64>( return h1; } -/// force all bits of a hash block to avalanche +/*******************************************************************\ + +Function: murmurhash3_hash_finalize + + Inputs: + + Outputs: + + Purpose: force all bits of a hash block to avalanche + +\*******************************************************************/ + static FORCE_INLINE uint64_t fmix64(uint64_t h) { // a brief experiment with supposedly better constants from diff --git a/src/util/irep_hash_container.cpp b/src/util/irep_hash_container.cpp index 82f6b812484..5d17b3d3f9f 100644 --- a/src/util/irep_hash_container.cpp +++ b/src/util/irep_hash_container.cpp @@ -6,13 +6,22 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Hashing IREPs - #include "irep_hash_container.h" #include "irep.h" #include "irep_hash.h" +/*******************************************************************\ + +Function: irep_hash_container_baset::number + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + size_t irep_hash_container_baset::number(const irept &irep) { // the ptr-hash provides a speedup of up to 3x @@ -31,6 +40,18 @@ size_t irep_hash_container_baset::number(const irept &irep) return id; } +/*******************************************************************\ + +Function: irep_hash_container_baset::vector_hasht::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + size_t irep_hash_container_baset::vector_hasht::operator()( const packedt &p) const { @@ -40,6 +61,18 @@ size_t irep_hash_container_baset::vector_hasht::operator()( return result; } +/*******************************************************************\ + +Function: irep_hash_container_baset::pack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irep_hash_container_baset::pack( const irept &irep, packedt &packed) diff --git a/src/util/irep_hash_container.h b/src/util/irep_hash_container.h index 382130659e0..6edaaf0c21c 100644 --- a/src/util/irep_hash_container.h +++ b/src/util/irep_hash_container.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// IREP Hash Container - #ifndef CPROVER_UTIL_IREP_HASH_CONTAINER_H #define CPROVER_UTIL_IREP_HASH_CONTAINER_H diff --git a/src/util/irep_ids.cpp b/src/util/irep_ids.cpp index 15ff849a058..bb67b275f0a 100644 --- a/src/util/irep_ids.cpp +++ b/src/util/irep_ids.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Internal Representation - #include #include "irep_ids.h" @@ -42,6 +39,18 @@ const char *irep_ids_table[]= #include "irep_ids.def" // NOLINT(build/include) +/*******************************************************************\ + +Function: initialize_string_container + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void initialize_string_container() { // this is called by the constructor of string_containert diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h index 2202c95c62b..c456840ef5f 100644 --- a/src/util/irep_ids.h +++ b/src/util/irep_ids.h @@ -6,9 +6,6 @@ Author: Reuben Thomas, reuben.thomas@me.com \*******************************************************************/ -/// \file -/// util - #ifndef CPROVER_UTIL_IREP_IDS_H #define CPROVER_UTIL_IREP_IDS_H diff --git a/src/util/irep_serialization.cpp b/src/util/irep_serialization.cpp index 466460d92dd..3d5734bbb43 100644 --- a/src/util/irep_serialization.cpp +++ b/src/util/irep_serialization.cpp @@ -8,15 +8,24 @@ Date: May 2007 \*******************************************************************/ -/// \file -/// binary irep conversions with hashing - #include #include #include "irep_serialization.h" #include "string_hash.h" +/*******************************************************************\ + +Function: irep_serializationt::write_irep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irep_serializationt::write_irep( std::ostream &out, const irept &irep) @@ -46,6 +55,18 @@ void irep_serializationt::write_irep( out.put(0); // terminator } +/*******************************************************************\ + +Function: irep_serializationt::reference_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irep_serializationt::reference_convert( std::istream &in, irept &irep) @@ -64,6 +85,18 @@ void irep_serializationt::reference_convert( } } +/*******************************************************************\ + +Function: irep_serializationt::read_irep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irep_serializationt::read_irep( std::istream &in, irept &irep) @@ -99,6 +132,18 @@ void irep_serializationt::read_irep( } } +/*******************************************************************\ + +Function: irep_serializationt::reference_convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void irep_serializationt::reference_convert( const irept &irep, std::ostream &out) @@ -121,9 +166,18 @@ void irep_serializationt::reference_convert( } } -/// inserts an irep into the hashtable -/// \par parameters: a size_t and an irep -/// \return true on success, false otherwise +/*******************************************************************\ + +Function: irep_serializationt::insert_on_write + + Inputs: a size_t and an irep + + Outputs: true on success, false otherwise + + Purpose: inserts an irep into the hashtable + +\*******************************************************************/ + std::size_t irep_serializationt::insert_on_write(std::size_t h) { std::pair res= @@ -136,10 +190,19 @@ std::size_t irep_serializationt::insert_on_write(std::size_t h) return res.first->second; } -/// inserts an irep into the hashtable, but only the id-hashtable (only to be -/// used upon reading ireps from a file) -/// \par parameters: a size_t and an irep -/// \return true on success, false otherwise +/*******************************************************************\ + +Function: irep_serializationt::insert_on_read + + Inputs: a size_t and an irep + + Outputs: true on success, false otherwise + + Purpose: inserts an irep into the hashtable, but only the id-hashtable + (only to be used upon reading ireps from a file) + +\*******************************************************************/ + std::size_t irep_serializationt::insert_on_read( std::size_t id, const irept &i) @@ -159,9 +222,19 @@ std::size_t irep_serializationt::insert_on_read( return id; } -/// outputs 4 characters for a long, most-significand byte first -/// \par parameters: an output stream and a number -/// \return nothing +/*******************************************************************\ + +Function: write_gb_word + + Inputs: an output stream and a number + + Outputs: nothing + + Purpose: outputs 4 characters for a long, + most-significand byte first + +\*******************************************************************/ + void write_gb_word(std::ostream &out, std::size_t u) { // we write 7 bits each time, until we have zero @@ -181,9 +254,18 @@ void write_gb_word(std::ostream &out, std::size_t u) } } -/// reads 4 characters and builds a long int from them -/// \par parameters: a stream -/// \return a long +/*******************************************************************\ + +Function: irep_serializationt::read_gb_word + + Inputs: a stream + + Outputs: a long + + Purpose: reads 4 characters and builds a long int from them + +\*******************************************************************/ + std::size_t irep_serializationt::read_gb_word(std::istream &in) { std::size_t res=0; @@ -202,9 +284,18 @@ std::size_t irep_serializationt::read_gb_word(std::istream &in) return res; } -/// outputs the string and then a zero byte. -/// \par parameters: an output stream and a string -/// \return nothing +/*******************************************************************\ + +Function: write_gb_string + + Inputs: an output stream and a string + + Outputs: nothing + + Purpose: outputs the string and then a zero byte. + +\*******************************************************************/ + void write_gb_string(std::ostream &out, const std::string &s) { for(std::string::const_iterator it=s.begin(); @@ -219,9 +310,18 @@ void write_gb_string(std::ostream &out, const std::string &s) out.put(0); } -/// reads a string from the stream -/// \par parameters: a stream -/// \return a string +/*******************************************************************\ + +Function: irep_serializationt::read_gb_string + + Inputs: a stream + + Outputs: a string + + Purpose: reads a string from the stream + +\*******************************************************************/ + irep_idt irep_serializationt::read_gb_string(std::istream &in) { char c; @@ -243,9 +343,18 @@ irep_idt irep_serializationt::read_gb_string(std::istream &in) return irep_idt(std::string(read_buffer.data(), length)); } -/// outputs the string reference -/// \par parameters: an output stream and a string -/// \return nothing +/*******************************************************************\ + +Function: irep_serializationt::write_string_ref + + Inputs: an output stream and a string + + Outputs: nothing + + Purpose: outputs the string reference + +\*******************************************************************/ + void irep_serializationt::write_string_ref( std::ostream &out, const irep_idt &s) @@ -264,9 +373,18 @@ void irep_serializationt::write_string_ref( } } -/// reads a string reference from the stream -/// \par parameters: a stream -/// \return a string +/*******************************************************************\ + +Function: irep_serializationt::read_string_ref + + Inputs: a stream + + Outputs: a string + + Purpose: reads a string reference from the stream + +\*******************************************************************/ + irep_idt irep_serializationt::read_string_ref(std::istream &in) { std::size_t id = read_gb_word(in); diff --git a/src/util/irep_serialization.h b/src/util/irep_serialization.h index 6162826475a..715e042300d 100644 --- a/src/util/irep_serialization.h +++ b/src/util/irep_serialization.h @@ -8,9 +8,6 @@ Date: May 2007 \*******************************************************************/ -/// \file -/// binary irep conversions with hashing - #ifndef CPROVER_UTIL_IREP_SERIALIZATION_H #define CPROVER_UTIL_IREP_SERIALIZATION_H diff --git a/src/util/json.cpp b/src/util/json.cpp index f2d10caf8b2..39769a8c5c2 100644 --- a/src/util/json.cpp +++ b/src/util/json.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com const jsont jsont::null_json_object(jsont::kindt::J_NULL); +/*******************************************************************\ + +Function: jsont::escape_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsont::escape_string(const std::string &src, std::ostream &out) { for(const auto &ch : src) @@ -50,6 +62,18 @@ void jsont::escape_string(const std::string &src, std::ostream &out) } } +/*******************************************************************\ + +Function: jsont::output_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsont::output_rec(std::ostream &out, unsigned indent) const { switch(kind) @@ -133,6 +157,18 @@ void jsont::output_rec(std::ostream &out, unsigned indent) const } } +/*******************************************************************\ + +Function: jsont::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void jsont::swap(jsont &other) { std::swap(other.kind, kind); diff --git a/src/util/json_expr.cpp b/src/util/json_expr.cpp index fde6862270c..d2d3550e6ff 100644 --- a/src/util/json_expr.cpp +++ b/src/util/json_expr.cpp @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Expressions in JSON - #include "namespace.h" #include "expr.h" #include "json.h" @@ -23,6 +20,18 @@ Author: Peter Schrammel #include "json_expr.h" +/*******************************************************************\ + +Function: simplify_json_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static exprt simplify_json_expr( const exprt &src, const namespacet &ns) @@ -66,6 +75,18 @@ static exprt simplify_json_expr( return src; } +/*******************************************************************\ + +Function: json + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + json_objectt json(const source_locationt &location) { json_objectt result; @@ -89,13 +110,24 @@ json_objectt json(const source_locationt &location) return result; } -/// Output a CBMC type in json. -/// The `mode` argument is used to correctly report types. -/// \param type: a type -/// \param ns: a namespace -/// \param mode: language in which the code was written; for now ID_C and -/// ID_java are supported -/// \return a json object +/*******************************************************************\ + +Function: json + + Inputs: + type - a type + ns - a namespace + mode - language in which the code was written; + for now ID_C and ID_java are supported + + Outputs: a json object + + Purpose: + Output a CBMC type in json. + The `mode` argument is used to correctly report types. + +\*******************************************************************/ + json_objectt json( const typet &type, const namespacet &ns, @@ -198,13 +230,24 @@ json_objectt json( return result; } -/// Output a CBMC expression in json. -/// The mode is used to correctly report types. -/// \param expr: an expression -/// \param ns: a namespace -/// \param mode: language in which the code was written; for now ID_C and -/// ID_java are supported -/// \return a json object +/*******************************************************************\ + +Function: json + + Inputs: + expr - an expression + ns - a namespace + mode - language in which the code was written; + for now ID_C and ID_java are supported + + Outputs: a json object + + Purpose: + Output a CBMC expression in json. + The mode is used to correctly report types. + +\*******************************************************************/ + json_objectt json( const exprt &expr, const namespacet &ns, diff --git a/src/util/json_expr.h b/src/util/json_expr.h index 6b9a124680b..61f6977a1ff 100644 --- a/src/util/json_expr.h +++ b/src/util/json_expr.h @@ -6,9 +6,6 @@ Author: Peter Schrammel \*******************************************************************/ -/// \file -/// Expressions in JSON - #ifndef CPROVER_UTIL_JSON_EXPR_H #define CPROVER_UTIL_JSON_EXPR_H diff --git a/src/util/json_irep.cpp b/src/util/json_irep.cpp index 7f8c0b58b16..2740228d1db 100644 --- a/src/util/json_irep.cpp +++ b/src/util/json_irep.cpp @@ -6,27 +6,46 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ -/// \file -/// Util - #include "irep.h" #include "json.h" #include "json_irep.h" #include -/// To convert to JSON from an irep structure by recurssively generating JSON -/// for the different sub trees. -/// \param include_comments: when writing JSON, should the comments -/// sub tree be included. +/*******************************************************************\ + +Function: json_irept::json_irept + + Inputs: + include_comments - when writing JSON, should the comments + sub tree be included. + + Outputs: + + Purpose: To convert to JSON from an irep structure by recurssively + generating JSON for the different sub trees. + +\*******************************************************************/ + json_irept::json_irept(bool include_comments): include_comments(include_comments) {} -/// To convert to JSON from an irep structure by recurssively generating JSON -/// for the different sub trees. -/// \param irep: The irep structure to turn into json -/// \param json: The json object to be filled up. +/*******************************************************************\ + +Function: json_irept::convert_from_irep + + Inputs: + irep - The irep structure to turn into json + json - The json object to be filled up. + + Outputs: + + Purpose: To convert to JSON from an irep structure by recurssively + generating JSON for the different sub trees. + +\*******************************************************************/ + void json_irept::convert_from_irep(const irept &irep, jsont &json) const { json_objectt &irep_object=json.make_object(); @@ -41,12 +60,24 @@ void json_irept::convert_from_irep(const irept &irep, jsont &json) const } } -/// To convert to JSON from a list of ireps that are in an unlabelled subtree. -/// The parent JSON object will get a key called sub_tree_id and the value shall -/// be an array of JSON objects generated from each of the sub trees -/// \param sub_tree_id: the name to give the subtree in the parent object -/// \param sub_trees: the list of subtrees to parse -/// \param parent: the parent JSON object who should be added to +/*******************************************************************\ + +Function: json_irept::convert_sub_tree + + Inputs: + sub_tree_id - the name to give the subtree in the parent object + sub_trees - the list of subtrees to parse + parent - the parent JSON object who should be added to + + Outputs: + + Purpose: To convert to JSON from a list of ireps that are in an + unlabelled subtree. The parent JSON object will get a key + called sub_tree_id and the value shall be an array of JSON + objects generated from each of the sub trees + +\*******************************************************************/ + void json_irept::convert_sub_tree( const std::string &sub_tree_id, const irept::subt &sub_trees, @@ -65,13 +96,25 @@ void json_irept::convert_sub_tree( } } -/// To convert to JSON from a map of ireps that are in a named subtree. The -/// parent JSON object will get a key called sub_tree_id and the value shall be -/// a JSON object whose keys shall be the name of the sub tree and the value -/// will be the object generated from the sub tree. -/// \param sub_tree_id: the name to give the subtree in the parent object -/// \param sub_trees: the map of subtrees to parse -/// \param parent: the parent JSON object who should be added to +/*******************************************************************\ + +Function: json_irept::convert_named_sub_tree + + Inputs: + sub_tree_id - the name to give the subtree in the parent object + sub_trees - the map of subtrees to parse + parent - the parent JSON object who should be added to + + Outputs: + + Purpose: To convert to JSON from a map of ireps that are in a + named subtree. The parent JSON object will get a key + called sub_tree_id and the value shall be a JSON object + whose keys shall be the name of the sub tree and the value + will be the object generated from the sub tree. + +\*******************************************************************/ + void json_irept::convert_named_sub_tree( const std::string &sub_tree_id, const irept::named_subt &sub_trees, @@ -90,9 +133,18 @@ void json_irept::convert_named_sub_tree( } } -/// Deserialize a JSON irep representation. -/// \param input: json object to convert -/// \return result - irep equivalent of input +/*******************************************************************\ + +Function: json_irept::convert_from_json + + Inputs: input - json object to convert + + Outputs: result - irep equivalent of input + + Purpose: Deserialize a JSON irep representation. + +\*******************************************************************/ + void json_irept::convert_from_json(const jsont &in, irept &out) const { std::vector have_keys; diff --git a/src/util/json_irep.h b/src/util/json_irep.h index 83c8a6902d8..20a364d31e9 100644 --- a/src/util/json_irep.h +++ b/src/util/json_irep.h @@ -6,9 +6,6 @@ Author: Thomas Kiley, thomas.kiley@diffblue.com \*******************************************************************/ -/// \file -/// Util - #ifndef CPROVER_UTIL_JSON_IREP_H #define CPROVER_UTIL_JSON_IREP_H diff --git a/src/util/language.cpp b/src/util/language.cpp index 35758547b8f..ddb41979040 100644 --- a/src/util/language.cpp +++ b/src/util/language.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Abstract interface to support a programming language - #include "language.h" #include "expr.h" #include @@ -17,22 +14,70 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +/*******************************************************************\ + +Function: languaget::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool languaget::final(symbol_tablet &symbol_table) { return false; } +/*******************************************************************\ + +Function: languaget::interfaces + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool languaget::interfaces(symbol_tablet &symbol_table) { return false; } +/*******************************************************************\ + +Function: languaget::dependencies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void languaget::dependencies( const std::string &module, std::set &modules) { } +/*******************************************************************\ + +Function: languaget::from_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool languaget::from_expr( const exprt &expr, std::string &code, @@ -42,6 +87,18 @@ bool languaget::from_expr( return false; } +/*******************************************************************\ + +Function: languaget::from_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool languaget::from_type( const typet &type, std::string &code, @@ -51,6 +108,18 @@ bool languaget::from_type( return false; } +/*******************************************************************\ + +Function: languaget::type_to_name + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool languaget::type_to_name( const typet &type, std::string &name, @@ -62,19 +131,41 @@ bool languaget::type_to_name( return false; } -/// Turn on or off stub generation. -/// \param should_generate_stubs: Should stub generation be enabled +/*******************************************************************\ + +Function: languaget::set_should_generate_opaque_method_stubs + + Inputs: + should_generate_stubs - Should stub generation be enabled + + Outputs: + + Purpose: Turn on or off stub generation. + +\*******************************************************************/ void languaget::set_should_generate_opaque_method_stubs( bool should_generate_stubs) { generate_opaque_stubs=should_generate_stubs; } -/// When there are opaque methods (e.g. ones where we don't have a body), we -/// create a stub function in the goto program and mark it as opaque so the -/// interpreter fills in appropriate values for it. This will only happen if -/// generate_opaque_stubs is enabled. -/// \param symbol_table: the symbol table for the program +/*******************************************************************\ + +Function: languaget::generate_opaque_method_stubs + + Inputs: + symbol_table - the symbol table for the program + + Outputs: + + Purpose: When there are opaque methods (e.g. ones where we don't + have a body), we create a stub function in the goto + program and mark it as opaque so the interpreter fills in + appropriate values for it. This will only happen if + generate_opaque_stubs is enabled. + +\*******************************************************************/ + void languaget::generate_opaque_method_stubs(symbol_tablet &symbol_table) { if(generate_opaque_stubs) @@ -102,13 +193,24 @@ void languaget::generate_opaque_method_stubs(symbol_tablet &symbol_table) } } -/// To generate the stub function for the opaque function in question. The -/// identifier is used in the flag to the interpreter that the function is -/// opaque. This function should be implemented in the languages. -/// \param symbol: the function symbol which is opaque -/// \param symbol_table: the symbol table -/// \return The identifier of the return variable. ID_nil if the function -/// doesn't return anything. +/*******************************************************************\ + +Function: languaget::generate_opaque_stub_body + + Inputs: + symbol - the function symbol which is opaque + symbol_table - the symbol table + + Outputs: The identifier of the return variable. ID_nil if the function + doesn't return anything. + + Purpose: To generate the stub function for the opaque function in + question. The identifier is used in the flag to the interpreter + that the function is opaque. This function should be implemented + in the languages. + +\*******************************************************************/ + irep_idt languaget::generate_opaque_stub_body( symbolt &symbol, symbol_tablet &symbol_table) @@ -116,14 +218,24 @@ irep_idt languaget::generate_opaque_stub_body( return ID_nil; } -/// To build the parameter symbol and choose its name. This should be -/// implemented in each language. -/// \param function_symbol: the symbol of an opaque function -/// \param parameter_index: the index of the parameter within the the parameter -/// list -/// \param parameter_type: the type of the parameter -/// \return A named symbol to be added to the symbol table representing one of -/// the parameters in this opaque function. +/*******************************************************************\ + +Function: languaget::build_stub_parameter_symbol + + Inputs: + function_symbol - the symbol of an opaque function + parameter_index - the index of the parameter within the + the parameter list + parameter_type - the type of the parameter + + Outputs: A named symbol to be added to the symbol table representing + one of the parameters in this opaque function. + + Purpose: To build the parameter symbol and choose its name. This should + be implemented in each language. + +\*******************************************************************/ + parameter_symbolt languaget::build_stub_parameter_symbol( const symbolt &function_symbol, size_t parameter_index, @@ -136,11 +248,21 @@ parameter_symbolt languaget::build_stub_parameter_symbol( return parameter_symbolt(); } -/// To get the name of the symbol to be used for the return value of the -/// function. Generates a name like to_return_function_name -/// \param function_id: the function that has a return value -/// \return the identifier to use for the symbol that will store the return -/// value of this function. +/*******************************************************************\ + +Function: languaget::get_stub_return_symbol_name + + Inputs: + function_id - the function that has a return value + + Outputs: the identifier to use for the symbol that will store the + return value of this function. + + Purpose: To get the name of the symbol to be used for the return value + of the function. Generates a name like to_return_function_name + +\*******************************************************************/ + irep_idt languaget::get_stub_return_symbol_name(const irep_idt &function_id) { std::ostringstream return_symbol_name_builder; @@ -149,11 +271,22 @@ irep_idt languaget::get_stub_return_symbol_name(const irep_idt &function_id) } -/// To identify if a given symbol is an opaque function and hence needs to be -/// stubbed. We explicitly exclude CPROVER functions, if they have no body it is -/// because we haven't generated it yet. -/// \param symbol: the symbol to be checked -/// \return True if the symbol is an opaque (e.g. non-bodied) function +/*******************************************************************\ + +Function: languaget::is_symbol_opaque_function + + Inputs: + symbol - the symbol to be checked + + Outputs: True if the symbol is an opaque (e.g. non-bodied) function + + Purpose: To identify if a given symbol is an opaque function and + hence needs to be stubbed. We explicitly exclude CPROVER + functions, if they have no body it is because we haven't + generated it yet. + +\*******************************************************************/ + bool languaget::is_symbol_opaque_function(const symbolt &symbol) { std::set headers; @@ -168,10 +301,23 @@ bool languaget::is_symbol_opaque_function(const symbolt &symbol) !is_internal; } -/// To create stub parameter symbols for each parameter the function has and -/// assign their IDs into the parameters identifier. -/// \param function_symbol: the symbol of an opaque function -/// \param symbol_table: the symbol table to add the new parameter symbols into +/*******************************************************************\ + +Function: languaget::generate_opaque_parameter_symbols + + Inputs: + function_symbol - the symbol of an opaque function + symbol_table - the symbol table to add the new parameter + symbols into + + Outputs: + + Purpose: To create stub parameter symbols for each parameter the + function has and assign their IDs into the parameters + identifier. + +\*******************************************************************/ + void languaget::generate_opaque_parameter_symbols( symbolt &function_symbol, symbol_tablet &symbol_table) diff --git a/src/util/language.h b/src/util/language.h index fac0e13aed7..73ead1cd8e4 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Abstract interface to support a programming language - #ifndef CPROVER_UTIL_LANGUAGE_H #define CPROVER_UTIL_LANGUAGE_H diff --git a/src/util/language_file.cpp b/src/util/language_file.cpp index df74812ff5a..b0fbb47c2f9 100644 --- a/src/util/language_file.cpp +++ b/src/util/language_file.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "language.h" #include "language_file.h" +/*******************************************************************\ + +Function: language_filet::language_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + language_filet::language_filet(const language_filet &rhs): modules(rhs.modules), language(rhs.language==NULL?NULL:rhs.language->new_language()), @@ -18,12 +30,36 @@ language_filet::language_filet(const language_filet &rhs): { } +/*******************************************************************\ + +Function: language_filet::~language_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + language_filet::~language_filet() { if(language!=NULL) delete language; } +/*******************************************************************\ + +Function: language_filet::get_modules + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void language_filet::get_modules() { language->modules_provided(modules); @@ -36,6 +72,18 @@ void language_filet::convert_lazy_method( language->convert_lazy_method(id, symbol_table); } +/*******************************************************************\ + +Function: language_filest::show_parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void language_filest::show_parse(std::ostream &out) { for(file_mapt::iterator it=file_map.begin(); @@ -43,8 +91,19 @@ void language_filest::show_parse(std::ostream &out) it->second.language->show_parse(out); } -/// Turn on or off stub generation for all the languages -/// \param should_generate_stubs: Should stub generation be enabled +/*******************************************************************\ + +Function: language_filest::set_should_generate_opqaue_method_stubs + + Inputs: + should_generate_stubs - Should stub generation be enabled + + Outputs: + + Purpose: Turn on or off stub generation for all the languages + +\*******************************************************************/ + void language_filest::set_should_generate_opaque_method_stubs( bool stubs_enabled) { @@ -55,6 +114,17 @@ void language_filest::set_should_generate_opaque_method_stubs( } } +/*******************************************************************\ +Function: language_filest::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::parse() { for(file_mapt::iterator it=file_map.begin(); @@ -88,6 +158,18 @@ bool language_filest::parse() return false; } +/*******************************************************************\ + +Function: language_filest::typecheck + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::typecheck(symbol_tablet &symbol_table) { // typecheck interfaces @@ -162,6 +244,18 @@ bool language_filest::typecheck(symbol_tablet &symbol_table) return false; } +/*******************************************************************\ + +Function: language_filest::final + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::final( symbol_tablet &symbol_table) { @@ -178,6 +272,18 @@ bool language_filest::final( return false; } +/*******************************************************************\ + +Function: language_filest::interfaces + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::interfaces( symbol_tablet &symbol_table) { @@ -191,6 +297,18 @@ bool language_filest::interfaces( return false; } +/*******************************************************************\ + +Function: language_filest::typecheck_module + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::typecheck_module( symbol_tablet &symbol_table, const std::string &module) @@ -208,6 +326,18 @@ bool language_filest::typecheck_module( return typecheck_module(symbol_table, it->second); } +/*******************************************************************\ + +Function: language_filest::typecheck_module + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool language_filest::typecheck_module( symbol_tablet &symbol_table, language_modulet &module) diff --git a/src/util/lispexpr.cpp b/src/util/lispexpr.cpp index 76de8584642..7b19fe5db37 100644 --- a/src/util/lispexpr.cpp +++ b/src/util/lispexpr.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "lispexpr.h" +/*******************************************************************\ + +Function: lispexprt::expr2string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string lispexprt::expr2string() const { std::string result; @@ -49,12 +61,36 @@ std::string lispexprt::expr2string() const return result; } +/*******************************************************************\ + +Function: lispexprt::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool lispexprt::parse(const std::string &s) { std::string::size_type ptr=0; return parse(s, ptr); } +/*******************************************************************\ + +Function: lispexprt::parse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool lispexprt::parse( const std::string &s, std::string::size_type &ptr) @@ -147,6 +183,18 @@ bool lispexprt::parse( return false; } +/*******************************************************************\ + +Function: escape + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string escape(const std::string &s) { std::string result; @@ -162,6 +210,18 @@ std::string escape(const std::string &s) return result; } +/*******************************************************************\ + +Function: test_lispexpr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int test_lispexpr() { std::string line; diff --git a/src/util/lispirep.cpp b/src/util/lispirep.cpp index 6eda56855b8..75e926e8107 100644 --- a/src/util/lispirep.cpp +++ b/src/util/lispirep.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "irep.h" #include "lispexpr.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void lisp2irep(const lispexprt &src, irept &dest) { dest.make_nil(); diff --git a/src/util/memory_info.cpp b/src/util/memory_info.cpp index 14cf8245e77..af4f2ef1d52 100644 --- a/src/util/memory_info.cpp +++ b/src/util/memory_info.cpp @@ -25,6 +25,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "memory_info.h" +/*******************************************************************\ + +Function: memory_info + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void memory_info(std::ostream &out) { #if defined(__linux__) && defined(__GLIBC__) diff --git a/src/util/merge_irep.cpp b/src/util/merge_irep.cpp index f31716e1140..6b8d4a6924a 100644 --- a/src/util/merge_irep.cpp +++ b/src/util/merge_irep.cpp @@ -9,6 +9,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "irep_hash.h" #include "merge_irep.h" +/*******************************************************************\ + +Function: to_be_merged_irept::hash + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t to_be_merged_irept::hash() const { std::size_t result=hash_string(id()); @@ -32,6 +44,18 @@ std::size_t to_be_merged_irept::hash() const return result; } +/*******************************************************************\ + +Function: to_be_merged_irept::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const { if(id()!=other.id()) @@ -71,6 +95,18 @@ bool to_be_merged_irept::operator == (const to_be_merged_irept &other) const return true; } +/*******************************************************************\ + +Function: merged_irepst::merged + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const merged_irept &merged_irepst::merged(const irept &irep) { // first see if it's already a merged_irep @@ -113,6 +149,18 @@ const merged_irept &merged_irepst::merged(const irept &irep) static_cast(*result.first)); } +/*******************************************************************\ + +Function: merge_irept::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void merge_irept::operator()(irept &irep) { // only useful if there is sharing @@ -121,6 +169,18 @@ void merge_irept::operator()(irept &irep) #endif } +/*******************************************************************\ + +Function: merge_irept::merged + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irept &merge_irept::merged(const irept &irep) { irep_storet::const_iterator entry=irep_store.find(irep); @@ -161,6 +221,18 @@ const irept &merge_irept::merged(const irept &irep) return *irep_store.insert(new_irep).first; } +/*******************************************************************\ + +Function: merge_full_irept::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void merge_full_irept::operator()(irept &irep) { // only useful if there is sharing @@ -169,6 +241,18 @@ void merge_full_irept::operator()(irept &irep) #endif } +/*******************************************************************\ + +Function: merge_full_irept::merged + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irept &merge_full_irept::merged(const irept &irep) { irep_storet::const_iterator entry=irep_store.find(irep); diff --git a/src/util/message.cpp b/src/util/message.cpp index 6d9a1a22191..21a67433609 100644 --- a/src/util/message.cpp +++ b/src/util/message.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "message.h" +/*******************************************************************\ + +Function: message_handlert::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void message_handlert::print( unsigned level, const std::string &message, @@ -53,12 +65,36 @@ void message_handlert::print( print(level, dest); } +/*******************************************************************\ + +Function: messaget::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void messaget::print(unsigned level, const std::string &message) { if(message_handler!=NULL) message_handler->print(level, message); } +/*******************************************************************\ + +Function: messaget::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void messaget::print( unsigned level, const std::string &message, @@ -70,10 +106,34 @@ void messaget::print( location); } +/*******************************************************************\ + +Function: message_clientt::~message_clientt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + message_clientt::~message_clientt() { } +/*******************************************************************\ + +Function: message_clientt::set_message_handler + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void message_clientt::set_message_handler( message_handlert &_message_handler) { diff --git a/src/util/mp_arith.cpp b/src/util/mp_arith.cpp index de248a60494..6a9082b6823 100644 --- a/src/util/mp_arith.cpp +++ b/src/util/mp_arith.cpp @@ -21,6 +21,18 @@ Author: Daniel Kroening, kroening@kroening.com typedef BigInt::ullong_t ullong_t; // NOLINT(readability/identifiers) typedef BigInt::llong_t llong_t; // NOLINT(readability/identifiers) +/*******************************************************************\ + +Function: >> + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer operator>>(const mp_integer &a, const mp_integer &b) { mp_integer power=::power(2, b); @@ -39,20 +51,54 @@ mp_integer operator>>(const mp_integer &a, const mp_integer &b) } } +/*******************************************************************\ + +Function: << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer operator<<(const mp_integer &a, const mp_integer &b) { return a*power(2, b); } +/*******************************************************************\ + +Function: << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<(std::ostream &out, const mp_integer &n) { out << integer2string(n); return out; } -/// \par parameters: string of '0'-'9' etc. most significant digit first -/// base of number representation -/// \return mp_integer +/*******************************************************************\ + +Function: string2integer + + Inputs: string of '0'-'9' etc. most significant digit first + base of number representation + + Outputs: mp_integer + + Purpose: + +\*******************************************************************/ + const mp_integer string2integer(const std::string &n, unsigned base) { for(unsigned i=0; i=0); @@ -203,6 +305,18 @@ std::size_t integer2size_t(const mp_integer &n) return (std::size_t)ull; } +/*******************************************************************\ + +Function: integer2unsigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned integer2unsigned(const mp_integer &n) { assert(n>=0); @@ -211,45 +325,105 @@ unsigned integer2unsigned(const mp_integer &n) return (unsigned)ull; } -/// bitwise or bitwise operations only make sense on native objects, hence the -/// largest object size should be the largest available c++ integer size -/// (currently long long) +/*******************************************************************\ + +Function: bitwise_or + + Inputs: + + Outputs: + + Purpose: bitwise or + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer bitwise_or(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()|b.to_ulong(); return result; } -/// bitwise and bitwise operations only make sense on native objects, hence the -/// largest object size should be the largest available c++ integer size -/// (currently long long) +/*******************************************************************\ + +Function: bitwise_and + + Inputs: + + Outputs: + + Purpose: bitwise and + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer bitwise_and(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()&b.to_ulong(); return result; } -/// bitwise xor bitwise operations only make sense on native objects, hence the -/// largest object size should be the largest available c++ integer size -/// (currently long long) +/*******************************************************************\ + +Function: bitwise_xor + + Inputs: + + Outputs: + + Purpose: bitwise xor + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer bitwise_xor(const mp_integer &a, const mp_integer &b) { ullong_t result=a.to_ulong()^b.to_ulong(); return result; } -/// bitwise negation bitwise operations only make sense on native objects, hence -/// the largest object size should be the largest available c++ integer size -/// (currently long long) +/*******************************************************************\ + +Function: bitwise_neg + + Inputs: + + Outputs: + + Purpose: bitwise negation + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer bitwise_neg(const mp_integer &a) { ullong_t result=~a.to_ulong(); return result; } -/// arithmetic left shift bitwise operations only make sense on native objects, -/// hence the largest object size should be the largest available c++ integer -/// size (currently long long) +/*******************************************************************\ + +Function: arith_left_shift + + Inputs: + + Outputs: + + Purpose: arithmetic left shift + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer arith_left_shift( const mp_integer &a, const mp_integer &b, @@ -267,9 +441,21 @@ mp_integer arith_left_shift( return result&mask; } -/// arithmetic right shift (loads sign on MSB) bitwise operations only make -/// sense on native objects, hence the largest object size should be the largest -/// available c++ integer size (currently long long) +/*******************************************************************\ + +Function: arith_right_shift + + Inputs: + + Outputs: + + Purpose: arithmetic right shift (loads sign on MSB) + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer arith_right_shift( const mp_integer &a, const mp_integer &b, @@ -286,9 +472,21 @@ mp_integer arith_right_shift( return result; } -/// logic left shift bitwise operations only make sense on native objects, hence -/// the largest object size should be the largest available c++ integer size -/// (currently long long) +/*******************************************************************\ + +Function: logic_left_shift + + Inputs: + + Outputs: + + Purpose: logic left shift + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer logic_left_shift( const mp_integer &a, const mp_integer &b, @@ -311,9 +509,21 @@ mp_integer logic_left_shift( return result; } -/// logic right shift (loads 0 on MSB) bitwise operations only make sense on -/// native objects, hence the largest object size should be the largest -/// available c++ integer size (currently long long) +/*******************************************************************\ + +Function: logic_right_shift + + Inputs: + + Outputs: + + Purpose: logic right shift (loads 0 on MSB) + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer logic_right_shift( const mp_integer &a, const mp_integer &b, @@ -327,9 +537,21 @@ mp_integer logic_right_shift( return result; } -/// rotates right (MSB=LSB) bitwise operations only make sense on native -/// objects, hence the largest object size should be the largest available c++ -/// integer size (currently long long) +/*******************************************************************\ + +Function: rotate_right + + Inputs: + + Outputs: + + Purpose: rotates right (MSB=LSB) + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer rotate_right( const mp_integer &a, const mp_integer &b, @@ -346,9 +568,21 @@ mp_integer rotate_right( return result; } -/// rotate left (LSB=MSB) bitwise operations only make sense on native objects, -/// hence the largest object size should be the largest available c++ integer -/// size (currently long long) +/*******************************************************************\ + +Function: rotate_left + + Inputs: + + Outputs: + + Purpose: rotate left (LSB=MSB) + bitwise operations only make sense on native objects, hence the + largest object size should be the largest available c++ integer + size (currently long long) + +\*******************************************************************/ + mp_integer rotate_left( const mp_integer &a, const mp_integer &b, diff --git a/src/util/namespace.cpp b/src/util/namespace.cpp index 4aeff9046e1..1abf0fb1c59 100644 --- a/src/util/namespace.cpp +++ b/src/util/namespace.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Namespace - #include #include @@ -19,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_types.h" #include "namespace.h" +/*******************************************************************\ + +Function: get_max + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned get_max( const std::string &prefix, const symbol_tablet::symbolst &symbols) @@ -35,10 +44,34 @@ unsigned get_max( return max_nr; } +/*******************************************************************\ + +Function: namespace_baset::~namespace_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + namespace_baset::~namespace_baset() { } +/*******************************************************************\ + +Function: namespace_baset::follow_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void namespace_baset::follow_symbol(irept &irep) const { while(irep.id()==ID_symbol) @@ -62,6 +95,18 @@ void namespace_baset::follow_symbol(irept &irep) const } } +/*******************************************************************\ + +Function: namespace_baset::follow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &namespace_baset::follow(const typet &src) const { if(src.id()!=ID_symbol) @@ -79,6 +124,18 @@ const typet &namespace_baset::follow(const typet &src) const } } +/*******************************************************************\ + +Function: namespace_baset::follow_tag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &namespace_baset::follow_tag(const union_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -87,6 +144,18 @@ const typet &namespace_baset::follow_tag(const union_tag_typet &src) const return symbol.type; } +/*******************************************************************\ + +Function: namespace_baset::follow_tag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &namespace_baset::follow_tag(const struct_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -95,6 +164,18 @@ const typet &namespace_baset::follow_tag(const struct_tag_typet &src) const return symbol.type; } +/*******************************************************************\ + +Function: namespace_baset::follow_tag + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const typet &namespace_baset::follow_tag(const c_enum_tag_typet &src) const { const symbolt &symbol=lookup(src.get_identifier()); @@ -103,6 +184,18 @@ const typet &namespace_baset::follow_tag(const c_enum_tag_typet &src) const return symbol.type; } +/*******************************************************************\ + +Function: namespace_baset::follow_macros + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void namespace_baset::follow_macros(exprt &expr) const { if(expr.id()==ID_symbol) @@ -122,6 +215,18 @@ void namespace_baset::follow_macros(exprt &expr) const follow_macros(*it); } +/*******************************************************************\ + +Function: namespace_baset::get_max + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned namespacet::get_max(const std::string &prefix) const { unsigned m=0; @@ -135,6 +240,18 @@ unsigned namespacet::get_max(const std::string &prefix) const return m; } +/*******************************************************************\ + +Function: namespacet::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool namespacet::lookup( const irep_idt &name, const symbolt *&symbol) const @@ -166,6 +283,18 @@ bool namespacet::lookup( return true; } +/*******************************************************************\ + +Function: multi_namespacet::get_max + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned multi_namespacet::get_max(const std::string &prefix) const { unsigned m=0; @@ -179,6 +308,18 @@ unsigned multi_namespacet::get_max(const std::string &prefix) const return m; } +/*******************************************************************\ + +Function: multi_namespacet::lookup + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool multi_namespacet::lookup( const irep_idt &name, const symbolt *&symbol) const diff --git a/src/util/nondet_bool.h b/src/util/nondet_bool.h index af628d3456e..6aee700b889 100644 --- a/src/util/nondet_bool.h +++ b/src/util/nondet_bool.h @@ -6,17 +6,24 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ -/// \file -/// Nondeterministic boolean helper - #ifndef CPROVER_UTIL_NONDET_BOOL_H #define CPROVER_UTIL_NONDET_BOOL_H #include #include -/// \par parameters: Desired type (C_bool or plain bool) -/// \return nondet expr of that type +/*******************************************************************\ + +Function: get_nondet_bool + + Inputs: Desired type (C_bool or plain bool) + + Outputs: nondet expr of that type + + Purpose: + +\*******************************************************************/ + inline exprt get_nondet_bool(const typet &type) { // We force this to 0 and 1 and won't consider diff --git a/src/util/nondet_ifthenelse.cpp b/src/util/nondet_ifthenelse.cpp index d02f1ecd114..ae2f9040977 100644 --- a/src/util/nondet_ifthenelse.cpp +++ b/src/util/nondet_ifthenelse.cpp @@ -6,9 +6,6 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ -/// \file -/// Nondeterministic if-then-else - #include "nondet_ifthenelse.h" #include @@ -42,14 +39,31 @@ static symbolt &new_tmp_symbol( return *symbol_ptr; } -/// Emits instructions and defines labels for the beginning of a -/// nondeterministic if-else diamond. Code is emitted to the `result_code` -/// member of this object's associated `java_object_factoryt` instance `state`. -/// The caller should use the following pattern (where *this is an instance of -/// java_object_factoryt): ``` nondet_ifthenelset diamond(*this, "name"); -/// diamond.begin_if(); result_code.copy_to_operands(Some if-branch code) -/// diamond.begin_else(); result_code.copy_to_operands(Some else-branch code) -/// diamond.finish(); ``` +/*******************************************************************\ + +Function: nondet_ifthenelset::begin_if + + Inputs: + + Outputs: + + Purpose: Emits instructions and defines labels for the beginning of + a nondeterministic if-else diamond. Code is emitted to the + `result_code` member of this object's associated + `java_object_factoryt` instance `state`. + The caller should use the following pattern (where *this + is an instance of java_object_factoryt): + ``` + nondet_ifthenelset diamond(*this, "name"); + diamond.begin_if(); + result_code.copy_to_operands(Some if-branch code) + diamond.begin_else(); + result_code.copy_to_operands(Some else-branch code) + diamond.finish(); + ``` + +\*******************************************************************/ + void nondet_ifthenelset::begin_if() { static size_t nondet_ifthenelse_count=0; @@ -82,15 +96,38 @@ void nondet_ifthenelset::begin_if() result_code.move_to_operands(test); } -/// Terminates the if-block and begins the else-block of a nondet if-then-else -/// diamond. See ::begin_if for detail. +/*******************************************************************\ + +Function: nondet_ifthenelset::begin_else + + Inputs: + + Outputs: + + Purpose: Terminates the if-block and begins the else-block of a + nondet if-then-else diamond. See ::begin_if for detail. + +\*******************************************************************/ + void nondet_ifthenelset::begin_else() { result_code.copy_to_operands(code_gotot(join_label.get_label())); result_code.copy_to_operands(else_label); } -/// Concludes a nondet if-then-else diamond. See ::begin_if for detail. +/*******************************************************************\ + +Function: nondet_ifthenelset::finish + + Inputs: + + Outputs: + + Purpose: Concludes a nondet if-then-else diamond. + See ::begin_if for detail. + +\*******************************************************************/ + void nondet_ifthenelset::finish() { result_code.move_to_operands(join_label); diff --git a/src/util/nondet_ifthenelse.h b/src/util/nondet_ifthenelse.h index 664a6bdf1b2..c6ee25afcab 100644 --- a/src/util/nondet_ifthenelse.h +++ b/src/util/nondet_ifthenelse.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ -/// \file -/// Nondeterministic if-then-else - #ifndef CPROVER_UTIL_NONDET_IFTHENELSE_H #define CPROVER_UTIL_NONDET_IFTHENELSE_H diff --git a/src/util/options.cpp b/src/util/options.cpp index 85b59d64fad..e1cb8a369db 100644 --- a/src/util/options.cpp +++ b/src/util/options.cpp @@ -6,12 +6,21 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Options - #include "string2int.h" #include "options.h" +/*******************************************************************\ + +Function: optionst::set_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void optionst::set_option(const std::string &option, const std::string &value) { @@ -20,42 +29,126 @@ void optionst::set_option(const std::string &option, value_list.push_back(value); } +/*******************************************************************\ + +Function: optionst::set_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void optionst::set_option(const std::string &option, const bool value) { set_option(option, std::string(value?"1":"0")); } +/*******************************************************************\ + +Function: optionst::set_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void optionst::set_option(const std::string &option, const signed int value) { set_option(option, std::to_string(value)); } +/*******************************************************************\ + +Function: optionst::set_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void optionst::set_option(const std::string &option, const unsigned int value) { set_option(option, std::to_string(value)); } +/*******************************************************************\ + +Function: optionst::get_bool_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool optionst::get_bool_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?false:(std::stoi(value)!=0); } +/*******************************************************************\ + +Function: optionst::get_signed_int_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + signed int optionst::get_signed_int_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?0:std::stoi(value); } +/*******************************************************************\ + +Function: optionst::get_unsigned_int_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned int optionst::get_unsigned_int_option(const std::string &option) const { const std::string value=get_option(option); return value.empty()?0:safe_string2unsigned(value); } +/*******************************************************************\ + +Function: optionst::get_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const std::string optionst::get_option(const std::string &option) const { option_mapt::const_iterator it= @@ -69,6 +162,18 @@ const std::string optionst::get_option(const std::string &option) const return it->second.front(); } +/*******************************************************************\ + +Function: optionst::get_list_option + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const optionst::value_listt &optionst::get_list_option( const std::string &option) const { diff --git a/src/util/options.h b/src/util/options.h index 1a558a37331..118c365c992 100644 --- a/src/util/options.h +++ b/src/util/options.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Options - #ifndef CPROVER_UTIL_OPTIONS_H #define CPROVER_UTIL_OPTIONS_H diff --git a/src/util/parse_options.cpp b/src/util/parse_options.cpp index 1e61d7e6664..f674d9717e6 100644 --- a/src/util/parse_options.cpp +++ b/src/util/parse_options.cpp @@ -19,6 +19,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "parse_options.h" #include "signal_catcher.h" +/*******************************************************************\ + +Function: parse_options_baset::parse_options_baset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + parse_options_baset::parse_options_baset( const std::string &_optstring, int argc, const char **argv) { @@ -26,16 +38,52 @@ parse_options_baset::parse_options_baset( parse_result=cmdline.parse(argc, argv, optstring.c_str()); } +/*******************************************************************\ + +Function: parse_options_baset::help + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_options_baset::help() { } +/*******************************************************************\ + +Function: parse_options_baset::usage_error + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parse_options_baset::usage_error() { std::cerr << "Usage error!\n\n"; help(); } +/*******************************************************************\ + +Function: parse_options_baset::main + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int parse_options_baset::main() { if(parse_result) diff --git a/src/util/parser.cpp b/src/util/parser.cpp index 488389d5e49..539ed1f0e63 100644 --- a/src/util/parser.cpp +++ b/src/util/parser.cpp @@ -15,6 +15,18 @@ int isatty(int f) } #endif +/*******************************************************************\ + +Function: _newstack + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt &_newstack(parsert &parser, unsigned &x) { x=(unsigned)parser.stack.size(); @@ -26,6 +38,18 @@ exprt &_newstack(parsert &parser, unsigned &x) return parser.stack.back(); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void parsert::parse_error( const std::string &message, const std::string &before) diff --git a/src/util/parser.h b/src/util/parser.h index b450de7f614..f8792a75c66 100644 --- a/src/util/parser.h +++ b/src/util/parser.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Parser utilities - #ifndef CPROVER_UTIL_PARSER_H #define CPROVER_UTIL_PARSER_H diff --git a/src/util/pipe_stream.cpp b/src/util/pipe_stream.cpp index 6a7c1461764..104dd3a2075 100644 --- a/src/util/pipe_stream.cpp +++ b/src/util/pipe_stream.cpp @@ -6,9 +6,6 @@ Module: A stdin/stdout pipe as STL stream \*******************************************************************/ -/// \file -/// A stdin/stdout pipe as STL stream - #include #include #include @@ -29,7 +26,18 @@ Module: A stdin/stdout pipe as STL stream #define READ_BUFFER_SIZE 1024 -/// Constructor for external process +/*******************************************************************\ + +Function: pipe_streamt::pipe_streamt + + Inputs: + + Outputs: + + Purpose: Constructor for external process + +\*******************************************************************/ + pipe_streamt::pipe_streamt( const std::string &_executable, const std::list &_args): @@ -42,9 +50,19 @@ pipe_streamt::pipe_streamt( #endif } -/// Starts an external process. A new process is forked and run returns -/// immediately. -/// \return Returns -1 if an error occurs. +/*******************************************************************\ + +Function: pipe_streamt::run + + Inputs: + + Outputs: Returns -1 if an error occurs. + + Purpose: Starts an external process. A new process is forked and + run returns immediately. + +\*******************************************************************/ + #ifdef _WIN32 int pipe_streamt::run() @@ -186,7 +204,18 @@ int pipe_streamt::run() #endif -/// Wait for the process to terminate +/*******************************************************************\ + +Function: pipe_streamt::wait + + Inputs: + + Outputs: + + Purpose: Wait for the process to terminate + +\*******************************************************************/ + int pipe_streamt::wait() { #ifdef _WIN32 @@ -213,7 +242,18 @@ int pipe_streamt::wait() #endif } -/// Constructor +/*******************************************************************\ + +Function: filedescriptor_streambuft::filedescriptor_streambuft + + Inputs: + + Outputs: + + Purpose: Constructor + +\*******************************************************************/ + filedescriptor_streambuft::filedescriptor_streambuft(): #ifdef _WIN32 proc_in(INVALID_HANDLE_VALUE), @@ -227,7 +267,18 @@ filedescriptor_streambuft::filedescriptor_streambuft(): setg(in_buffer, in_buffer, in_buffer); } -/// Destructor +/*******************************************************************\ + +Function: filedescriptor_streambuft::~filedescriptor_streambuft + + Inputs: + + Outputs: + + Purpose: Destructor + +\*******************************************************************/ + filedescriptor_streambuft::~filedescriptor_streambuft() { #ifdef _WIN32 @@ -251,7 +302,18 @@ filedescriptor_streambuft::~filedescriptor_streambuft() delete in_buffer; } -/// write one character to the piped process +/*******************************************************************\ + +Function: filedescriptor_streambuft::overflow + + Inputs: + + Outputs: + + Purpose: write one character to the piped process + +\*******************************************************************/ + std::streambuf::int_type filedescriptor_streambuft::overflow( std::streambuf::int_type character) { @@ -272,7 +334,18 @@ std::streambuf::int_type filedescriptor_streambuft::overflow( return character; } -/// write a number of character to the piped process +/*******************************************************************\ + +Function: filedescriptor_streambuft::xsputn + + Inputs: + + Outputs: + + Purpose: write a number of character to the piped process + +\*******************************************************************/ + std::streamsize filedescriptor_streambuft::xsputn( const char* str, std::streamsize count) { @@ -285,7 +358,18 @@ std::streamsize filedescriptor_streambuft::xsputn( #endif } -/// read a character from the piped process +/*******************************************************************\ + +Function: filedescriptor_streambuft::underflow + + Inputs: + + Outputs: + + Purpose: read a character from the piped process + +\*******************************************************************/ + std::streambuf::int_type filedescriptor_streambuft::underflow() { if(gptr()==0) @@ -312,7 +396,18 @@ std::streambuf::int_type filedescriptor_streambuft::underflow() return traits_type::to_int_type(*gptr()); } -/// read a number of characters from the piped process +/*******************************************************************\ + +Function: filedescriptor_streambuft::xsgetn + + Inputs: + + Outputs: + + Purpose: read a number of characters from the piped process + +\*******************************************************************/ + std::streamsize filedescriptor_streambuft::xsgetn( char *target, std::streamsize count) { @@ -335,7 +430,18 @@ std::streamsize filedescriptor_streambuft::xsgetn( return (available + xsgetn(target+available, count-available)); } -/// determine number of available characters in stream +/*******************************************************************\ + +Function: filedescriptor_streambuft::showmanyc + + Inputs: + + Outputs: + + Purpose: determine number of available characters in stream + +\*******************************************************************/ + std::streamsize filedescriptor_streambuft::showmanyc() { if(gptr()==0) @@ -347,6 +453,12 @@ std::streamsize filedescriptor_streambuft::showmanyc() return 0; } +/*******************************************************************\ + + Brief demonstration of the pipe_streamt class + +\*******************************************************************/ + #ifdef UNIT #include diff --git a/src/util/pipe_stream.h b/src/util/pipe_stream.h index e03169ffd1a..b2b5bcea533 100644 --- a/src/util/pipe_stream.h +++ b/src/util/pipe_stream.h @@ -6,9 +6,6 @@ Module: A stdin/stdout pipe as STL stream \*******************************************************************/ -/// \file -/// A stdin/stdout pipe as STL stream - #ifndef CPROVER_UTIL_PIPE_STREAM_H #define CPROVER_UTIL_PIPE_STREAM_H diff --git a/src/util/pointer_offset_size.cpp b/src/util/pointer_offset_size.cpp index ea26479544b..43e7dd0d5a9 100644 --- a/src/util/pointer_offset_size.cpp +++ b/src/util/pointer_offset_size.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Logic - #include #include "expr.h" @@ -59,6 +56,18 @@ member_offset_iterator &member_offset_iterator::operator++() return *this; } +/*******************************************************************\ + +Function: member_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer member_offset( const struct_typet &type, const irep_idt &member, @@ -79,6 +88,18 @@ mp_integer member_offset( return offsets->second; } +/*******************************************************************\ + +Function: pointer_offset_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer pointer_offset_size( const typet &type, const namespacet &ns) @@ -89,6 +110,18 @@ mp_integer pointer_offset_size( return bits/8+(((bits%8)==0)?0:1); } +/*******************************************************************\ + +Function: pointer_offset_bits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer pointer_offset_bits( const typet &type, const namespacet &ns) @@ -218,6 +251,18 @@ mp_integer pointer_offset_bits( return mp_integer(-1); } +/*******************************************************************\ + +Function: member_offset_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt member_offset_expr( const member_exprt &member_expr, const namespacet &ns) @@ -233,6 +278,18 @@ exprt member_offset_expr( return nil_exprt(); } +/*******************************************************************\ + +Function: member_offset_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt member_offset_expr( const struct_typet &type, const irep_idt &member, @@ -274,6 +331,18 @@ exprt member_offset_expr( return result; } +/*******************************************************************\ + +Function: size_of_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt size_of_expr( const typet &type, const namespacet &ns) @@ -457,6 +526,18 @@ exprt size_of_expr( return nil_exprt(); } +/*******************************************************************\ + +Function: compute_pointer_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer compute_pointer_offset( const exprt &expr, const namespacet &ns) @@ -516,6 +597,18 @@ mp_integer compute_pointer_offset( return -1; // don't know } +/*******************************************************************\ + +Function: build_sizeof_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt build_sizeof_expr( const constant_exprt &expr, const namespacet &ns) diff --git a/src/util/pointer_offset_size.h b/src/util/pointer_offset_size.h index aeb62e03d74..e6f7ae15314 100644 --- a/src/util/pointer_offset_size.h +++ b/src/util/pointer_offset_size.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Pointer Logic - #ifndef CPROVER_UTIL_POINTER_OFFSET_SIZE_H #define CPROVER_UTIL_POINTER_OFFSET_SIZE_H diff --git a/src/util/pointer_predicates.cpp b/src/util/pointer_predicates.cpp index fe546d08277..53427d056e2 100644 --- a/src/util/pointer_predicates.cpp +++ b/src/util/pointer_predicates.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Various predicates over pointers in programs - #include "cprover_prefix.h" #include "namespace.h" #include "std_expr.h" @@ -20,6 +17,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_predicates.h" +/*******************************************************************\ + +Function: pointer_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_object(const exprt &p) { return unary_exprt( @@ -27,23 +36,71 @@ exprt pointer_object(const exprt &p) unsignedbv_typet(config.ansi_c.pointer_width)); } +/*******************************************************************\ + +Function: same_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt same_object(const exprt &p1, const exprt &p2) { return equal_exprt(pointer_object(p1), pointer_object(p2)); } +/*******************************************************************\ + +Function: object_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt object_size(const exprt &pointer) { typet type=signedbv_typet(config.ansi_c.pointer_width); return unary_exprt(ID_object_size, pointer, type); } +/*******************************************************************\ + +Function: pointer_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_offset(const exprt &pointer) { typet type=signedbv_typet(config.ansi_c.pointer_width); return unary_exprt(ID_pointer_offset, pointer, type); } +/*******************************************************************\ + +Function: malloc_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt malloc_object(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_malloc_object! @@ -52,6 +109,18 @@ exprt malloc_object(const exprt &pointer, const namespacet &ns) return same_object(pointer, malloc_object_symbol.symbol_expr()); } +/*******************************************************************\ + +Function: deallocated + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt deallocated(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_deallocated! @@ -60,6 +129,18 @@ exprt deallocated(const exprt &pointer, const namespacet &ns) return same_object(pointer, deallocated_symbol.symbol_expr()); } +/*******************************************************************\ + +Function: dead_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dead_object(const exprt &pointer, const namespacet &ns) { // we check __CPROVER_dead_object! @@ -68,16 +149,52 @@ exprt dead_object(const exprt &pointer, const namespacet &ns) return same_object(pointer, deallocated_symbol.symbol_expr()); } +/*******************************************************************\ + +Function: dynamic_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dynamic_size(const namespacet &ns) { return ns.lookup(CPROVER_PREFIX "malloc_size").symbol_expr(); } +/*******************************************************************\ + +Function: pointer_object_has_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt pointer_object_has_type(const exprt &pointer, const typet &type) { return false_exprt(); } +/*******************************************************************\ + +Function: dynamic_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dynamic_object(const exprt &pointer) { exprt dynamic_expr(ID_dynamic_object, bool_typet()); @@ -85,11 +202,35 @@ exprt dynamic_object(const exprt &pointer) return dynamic_expr; } +/*******************************************************************\ + +Function: good_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt good_pointer(const exprt &pointer) { return unary_exprt(ID_good_pointer, pointer, bool_typet()); } +/*******************************************************************\ + +Function: good_pointer_def + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt good_pointer_def( const exprt &pointer, const namespacet &ns) @@ -146,12 +287,36 @@ exprt good_pointer_def( good_other); } +/*******************************************************************\ + +Function: null_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt null_object(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); return same_object(null_pointer, pointer); } +/*******************************************************************\ + +Function: integer_address + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt integer_address(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); @@ -159,17 +324,53 @@ exprt integer_address(const exprt &pointer) notequal_exprt(null_pointer, pointer)); } +/*******************************************************************\ + +Function: null_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt null_pointer(const exprt &pointer) { null_pointer_exprt null_pointer(to_pointer_type(pointer.type())); return same_object(pointer, null_pointer); } +/*******************************************************************\ + +Function: invalid_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt invalid_pointer(const exprt &pointer) { return unary_exprt(ID_invalid_pointer, pointer, bool_typet()); } +/*******************************************************************\ + +Function: dynamic_object_lower_bound + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dynamic_object_lower_bound( const exprt &pointer, const namespacet &ns, @@ -178,6 +379,18 @@ exprt dynamic_object_lower_bound( return object_lower_bound(pointer, ns, offset); } +/*******************************************************************\ + +Function: dynamic_object_upper_bound + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt dynamic_object_upper_bound( const exprt &pointer, const typet &dereference_type, @@ -208,6 +421,18 @@ exprt dynamic_object_upper_bound( return binary_relation_exprt(sum, op, malloc_size); } +/*******************************************************************\ + +Function: object_upper_bound + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt object_upper_bound( const exprt &pointer, const typet &dereference_type, @@ -239,6 +464,18 @@ exprt object_upper_bound( return binary_relation_exprt(sum, op, object_size_expr); } +/*******************************************************************\ + +Function: object_lower_bound + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt object_lower_bound( const exprt &pointer, const namespacet &ns, diff --git a/src/util/pointer_predicates.h b/src/util/pointer_predicates.h index 201d094f50a..9f3ee3980fd 100644 --- a/src/util/pointer_predicates.h +++ b/src/util/pointer_predicates.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Various predicates over pointers in programs - #ifndef CPROVER_UTIL_POINTER_PREDICATES_H #define CPROVER_UTIL_POINTER_PREDICATES_H diff --git a/src/util/preprocessor.h b/src/util/preprocessor.h index 64919612319..248a85d0402 100644 --- a/src/util/preprocessor.h +++ b/src/util/preprocessor.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Preprocessing Base Class - #ifndef CPROVER_UTIL_PREPROCESSOR_H #define CPROVER_UTIL_PREPROCESSOR_H diff --git a/src/util/rational.cpp b/src/util/rational.cpp index f43b5915a28..45dfdec86db 100644 --- a/src/util/rational.cpp +++ b/src/util/rational.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Rational Numbers - #include #include #include "rational.h" +/*******************************************************************\ + +Function: rationalt::operator+= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt &rationalt::operator+=(const rationalt &n) { rationalt tmp(n); @@ -23,6 +32,18 @@ rationalt &rationalt::operator+=(const rationalt &n) return *this; } +/*******************************************************************\ + +Function: rationalt::operator-= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt &rationalt::operator-=(const rationalt &n) { rationalt tmp(n); @@ -32,12 +53,36 @@ rationalt &rationalt::operator-=(const rationalt &n) return *this; } +/*******************************************************************\ + +Function: rationalt::operator-= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt &rationalt::operator-() { numerator.negate(); return *this; } +/*******************************************************************\ + +Function: rationalt::operator*= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt &rationalt::operator*=(const rationalt &n) { numerator*=n.numerator; @@ -46,6 +91,18 @@ rationalt &rationalt::operator*=(const rationalt &n) return *this; } +/*******************************************************************\ + +Function: rationalt::operator/= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt &rationalt::operator/=(const rationalt &n) { assert(!n.numerator.is_zero()); @@ -55,6 +112,18 @@ rationalt &rationalt::operator/=(const rationalt &n) return *this; } +/*******************************************************************\ + +Function: rationalt::normalize + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rationalt::normalize() { // first do sign @@ -75,6 +144,18 @@ void rationalt::normalize() } } +/*******************************************************************\ + +Function: rationalt::same_denominator + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rationalt::same_denominator(rationalt &n) { if(denominator==n.denominator) @@ -88,12 +169,36 @@ void rationalt::same_denominator(rationalt &n) n.denominator=t; } +/*******************************************************************\ + +Function: rationalt::invert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rationalt::invert() { assert(numerator!=0); std::swap(numerator, denominator); } +/*******************************************************************\ + +Function: inverse + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rationalt inverse(const rationalt &n) { rationalt tmp(n); @@ -101,6 +206,18 @@ rationalt inverse(const rationalt &n) return tmp; } +/*******************************************************************\ + +Function: operator<< + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<(std::ostream &out, const rationalt &a) { std::string d=integer2string(a.get_numerator()); diff --git a/src/util/rational_tools.cpp b/src/util/rational_tools.cpp index 140241a9179..3e57beefc91 100644 --- a/src/util/rational_tools.cpp +++ b/src/util/rational_tools.cpp @@ -6,14 +6,23 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Rational Numbers - #include "rational.h" #include "std_types.h" #include "rational_tools.h" +/*******************************************************************\ + +Function: power10 + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static mp_integer power10(size_t i) { mp_integer result=1; @@ -24,6 +33,18 @@ static mp_integer power10(size_t i) return result; } +/*******************************************************************\ + +Function: to_rational + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool to_rational(const exprt &expr, rationalt &rational_value) { if(expr.id()!=ID_constant) @@ -78,6 +99,18 @@ bool to_rational(const exprt &expr, rationalt &rational_value) return false; } +/*******************************************************************\ + +Function: from_rational + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt from_rational(const rationalt &a) { std::string d=integer2string(a.get_numerator()); diff --git a/src/util/ref_expr_set.cpp b/src/util/ref_expr_set.cpp index 2b9fc3b213d..7e54107fd52 100644 --- a/src/util/ref_expr_set.cpp +++ b/src/util/ref_expr_set.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #include "ref_expr_set.h" const ref_expr_set_dt ref_expr_set_dt::blank; diff --git a/src/util/ref_expr_set.h b/src/util/ref_expr_set.h index 349619c233f..d7846d092d1 100644 --- a/src/util/ref_expr_set.h +++ b/src/util/ref_expr_set.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Value Set - #ifndef CPROVER_UTIL_REF_EXPR_SET_H #define CPROVER_UTIL_REF_EXPR_SET_H diff --git a/src/util/reference_counting.h b/src/util/reference_counting.h index d394bc3be9e..e6746f3c3a6 100644 --- a/src/util/reference_counting.h +++ b/src/util/reference_counting.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Reference Counting - #ifndef CPROVER_UTIL_REFERENCE_COUNTING_H #define CPROVER_UTIL_REFERENCE_COUNTING_H diff --git a/src/util/refined_string_type.cpp b/src/util/refined_string_type.cpp index 29f73f88da6..0625149cf83 100644 --- a/src/util/refined_string_type.cpp +++ b/src/util/refined_string_type.cpp @@ -10,16 +10,18 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Type for string expressions used by the string solver. These string -/// expressions contain a field `length`, of type `index_type`, a field -/// `content` of type `content_type`. This module also defines functions to -/// recognise the C and java string types. - #include #include "refined_string_type.h" +/*******************************************************************\ + +Constructor: refined_string_typet::refined_string_typet + + Inputs: type of characters + +\*******************************************************************/ + refined_string_typet::refined_string_typet( const typet &index_type, const typet &char_type) { @@ -30,8 +32,16 @@ refined_string_typet::refined_string_typet( set_tag(CPROVER_PREFIX"refined_string_type"); } -/// \par parameters: a type -/// \return Boolean telling whether the input is a refined string type +/*******************************************************************\ + +Function: refined_string_typet::is_refined_string_type + + Inputs: a type + + Outputs: Boolean telling whether the input is a refined string type + +\*******************************************************************/ + bool refined_string_typet::is_refined_string_type(const typet &type) { return diff --git a/src/util/refined_string_type.h b/src/util/refined_string_type.h index efa8a0987ec..a0cb7500e7f 100644 --- a/src/util/refined_string_type.h +++ b/src/util/refined_string_type.h @@ -10,12 +10,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// Type for string expressions used by the string solver. These string -/// expressions contain a field `length`, of type `index_type`, a field -/// `content` of type `content_type`. This module also defines functions to -/// recognise the C and java string types. - #ifndef CPROVER_UTIL_REFINED_STRING_TYPE_H #define CPROVER_UTIL_REFINED_STRING_TYPE_H diff --git a/src/util/rename.cpp b/src/util/rename.cpp index c095d420bd8..b121edb6acb 100644 --- a/src/util/rename.cpp +++ b/src/util/rename.cpp @@ -13,17 +13,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "expr.h" #include "namespace.h" -/// automated variable renaming -/// \par parameters: symbol to be renamed, namespace -/// \return new symbol +/*******************************************************************\ + +Function: get_new_name + + Inputs: symbol to be renamed, namespace + + Outputs: new symbol + + Purpose: automated variable renaming + +\*******************************************************************/ + void get_new_name(symbolt &symbol, const namespacet &ns) { get_new_name(symbol.name, ns); } -/// automated variable renaming -/// \par parameters: symbol to be renamed, namespace -/// \return new symbol +/*******************************************************************\ + +Function: get_new_name + + Inputs: symbol to be renamed, namespace + + Outputs: new symbol + + Purpose: automated variable renaming + +\*******************************************************************/ + void get_new_name(irep_idt &new_name, const namespacet &ns) { const symbolt *symbol; @@ -35,9 +53,19 @@ void get_new_name(irep_idt &new_name, const namespacet &ns) new_name=prefix+std::to_string(ns.get_max(prefix)+1); } -/// automated variable renaming -/// \par parameters: expression, old name, new name -/// \return modifies the expression returns false iff something was renamed +/*******************************************************************\ + +Function: rename + + Inputs: expression, old name, new name + + Outputs: modifies the expression + returns false iff something was renamed + + Purpose: automated variable renaming + +\*******************************************************************/ + bool rename(exprt &expr, const irep_idt &old_name, const irep_idt &new_name) { diff --git a/src/util/rename_symbol.cpp b/src/util/rename_symbol.cpp index fff2e220345..c6930a01d87 100644 --- a/src/util/rename_symbol.cpp +++ b/src/util/rename_symbol.cpp @@ -10,14 +10,50 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "rename_symbol.h" +/*******************************************************************\ + +Function: rename_symbolt::rename_symbolt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rename_symbolt::rename_symbolt() { } +/*******************************************************************\ + +Function: rename_symbolt::~rename_symbolt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + rename_symbolt::~rename_symbolt() { } +/*******************************************************************\ + +Function: rename_symbolt::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void rename_symbolt::insert( const symbol_exprt &old_expr, const symbol_exprt &new_expr) @@ -25,6 +61,18 @@ void rename_symbolt::insert( insert_expr(old_expr.get_identifier(), new_expr.get_identifier()); } +/*******************************************************************\ + +Function: rename_symbolt::rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool rename_symbolt::rename(exprt &dest) const { bool result=true; @@ -71,6 +119,18 @@ bool rename_symbolt::rename(exprt &dest) const return result; } +/*******************************************************************\ + +Function: rename_symbolt::have_to_rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool rename_symbolt::have_to_rename(const exprt &dest) const { if(expr_map.empty() && type_map.empty()) @@ -105,6 +165,18 @@ bool rename_symbolt::have_to_rename(const exprt &dest) const return false; } +/*******************************************************************\ + +Function: rename_symbolt::rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool rename_symbolt::rename(typet &dest) const { if(!have_to_rename(dest)) @@ -191,6 +263,18 @@ bool rename_symbolt::rename(typet &dest) const return result; } +/*******************************************************************\ + +Function: rename_symbolt::have_to_rename + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool rename_symbolt::have_to_rename(const typet &dest) const { if(expr_map.empty() && type_map.empty()) diff --git a/src/util/replace_expr.cpp b/src/util/replace_expr.cpp index b4a8e97b086..fc419aa59fa 100644 --- a/src/util/replace_expr.cpp +++ b/src/util/replace_expr.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "replace_expr.h" +/*******************************************************************\ + +Function: replace_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_expr(const exprt &what, const exprt &by, exprt &dest) { if(dest==what) @@ -24,6 +36,18 @@ bool replace_expr(const exprt &what, const exprt &by, exprt &dest) return result; } +/*******************************************************************\ + +Function: replace_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_expr(const replace_mapt &what, exprt &dest) { { diff --git a/src/util/replace_symbol.cpp b/src/util/replace_symbol.cpp index 5f69ea7f158..4dce48d8b93 100644 --- a/src/util/replace_symbol.cpp +++ b/src/util/replace_symbol.cpp @@ -10,14 +10,50 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "replace_symbol.h" +/*******************************************************************\ + +Function: replace_symbolt::replace_symbolt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + replace_symbolt::replace_symbolt() { } +/*******************************************************************\ + +Function: replace_symbolt::~replace_symbolt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + replace_symbolt::~replace_symbolt() { } +/*******************************************************************\ + +Function: replace_symbolt::insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void replace_symbolt::insert( const symbol_exprt &old_expr, const exprt &new_expr) @@ -26,6 +62,18 @@ void replace_symbolt::insert( old_expr.get_identifier(), new_expr)); } +/*******************************************************************\ + +Function: replace_symbolt::replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_symbolt::replace(exprt &dest) const { bool result=true; @@ -72,6 +120,18 @@ bool replace_symbolt::replace(exprt &dest) const return result; } +/*******************************************************************\ + +Function: replace_symbolt::have_to_replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_symbolt::have_to_replace(const exprt &dest) const { // first look at type @@ -103,6 +163,18 @@ bool replace_symbolt::have_to_replace(const exprt &dest) const return false; } +/*******************************************************************\ + +Function: replace_symbolt::replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_symbolt::replace(typet &dest) const { if(!have_to_replace(dest)) @@ -164,6 +236,18 @@ bool replace_symbolt::replace(typet &dest) const return result; } +/*******************************************************************\ + +Function: replace_symbolt::have_to_replace + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool replace_symbolt::have_to_replace(const typet &dest) const { if(dest.has_subtype()) diff --git a/src/util/run.cpp b/src/util/run.cpp index 41df754c551..8a8a1c68659 100644 --- a/src/util/run.cpp +++ b/src/util/run.cpp @@ -33,6 +33,18 @@ Date: August 2012 #include "run.h" +/*******************************************************************\ + +Function: run_shell + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int run_shell(const std::string &command) { std::string shell="/bin/sh"; @@ -42,6 +54,18 @@ int run_shell(const std::string &command) return run(shell, argv, "", ""); } +/*******************************************************************\ + +Function: run + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int run( const std::string &what, const std::vector &argv, diff --git a/src/util/safe_pointer.h b/src/util/safe_pointer.h index 152eb3242d9..47e52ac13fe 100644 --- a/src/util/safe_pointer.h +++ b/src/util/safe_pointer.h @@ -6,9 +6,6 @@ Author: Chris Smowton, chris@smowton.net \*******************************************************************/ -/// \file -/// Simple checked pointers - #ifndef CPROVER_UTIL_SAFE_POINTER_H #define CPROVER_UTIL_SAFE_POINTER_H diff --git a/src/util/sharing_map.h b/src/util/sharing_map.h index 8cbfcce4002..23f08d0bb06 100644 --- a/src/util/sharing_map.h +++ b/src/util/sharing_map.h @@ -6,9 +6,6 @@ Author: Daniel Poetzl \*******************************************************************/ -/// \file -/// Sharing map - #ifndef CPROVER_UTIL_SHARING_MAP_H #define CPROVER_UTIL_SHARING_MAP_H @@ -214,6 +211,18 @@ class sharing_mapt void gather_all(const node_type &n, delta_viewt &delta_view) const; }; +/*******************************************************************\ + +Function: get_view + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT(void)::get_view(viewt &view) const { assert(view.empty()); @@ -250,6 +259,18 @@ SHARING_MAPT(void)::get_view(viewt &view) const while(!stack.empty()); } +/*******************************************************************\ + +Function: gather_all + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT(void)::gather_all(const node_type &n, delta_viewt &delta_view) const { @@ -286,6 +307,18 @@ SHARING_MAPT(void)::gather_all(const node_type &n, delta_viewt &delta_view) while(!stack.empty()); } +/*******************************************************************\ + +Function: get_delta_view + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT(void)::get_delta_view( const self_type &other, delta_viewt &delta_view, @@ -392,6 +425,18 @@ SHARING_MAPT(void)::get_delta_view( while(!stack.empty()); } +/*******************************************************************\ + +Function: get_container_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k) { size_t key=hash()(k); @@ -408,6 +453,18 @@ SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k) return p; } +/*******************************************************************\ + +Function: get_container_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const { size_t key=hash()(k); @@ -428,6 +485,18 @@ SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const return p; } +/*******************************************************************\ + +Function: get_leaf_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(const, node_type *)::get_leaf_node(const key_type &k) const { const node_type *p=get_container_node(k); @@ -439,6 +508,18 @@ SHARING_MAPT2(const, node_type *)::get_leaf_node(const key_type &k) const return p; } +/*******************************************************************\ + +Function: erase + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, size_type)::erase( const key_type &k, const tvt &key_exists) @@ -491,6 +572,18 @@ SHARING_MAPT2(, size_type)::erase( return 1; } +/*******************************************************************\ + +Function: erase_all + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, size_type)::erase_all( const keyst &ks, const tvt &key_exists) @@ -505,6 +598,18 @@ SHARING_MAPT2(, size_type)::erase_all( return cnt; } +/*******************************************************************\ + +Function: insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, const_find_type)::insert( const key_type &k, const mapped_type &m, @@ -528,6 +633,18 @@ SHARING_MAPT2(, const_find_type)::insert( return const_find_type(as_const(p)->get_value(), true); } +/*******************************************************************\ + +Function: insert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, const_find_type)::insert( const value_type &p, const tvt &key_exists) @@ -535,6 +652,18 @@ SHARING_MAPT2(, const_find_type)::insert( return insert(p.first, p.second, key_exists); } +/*******************************************************************\ + +Function: place + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, find_type)::place( const key_type &k, const mapped_type &m) @@ -553,12 +682,36 @@ SHARING_MAPT2(, find_type)::place( return find_type(p->get_value(), true); } +/*******************************************************************\ + +Function: place + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, find_type)::place( const value_type &p) { return place(p.first, p.second); } +/*******************************************************************\ + +Function: find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, find_type)::find( const key_type &k, const tvt &key_exists) @@ -578,6 +731,18 @@ SHARING_MAPT2(, find_type)::find( } +/*******************************************************************\ + +Function: find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, const_find_type)::find(const key_type &k) const { const node_type *p=get_leaf_node(k); @@ -588,6 +753,18 @@ SHARING_MAPT2(, const_find_type)::find(const key_type &k) const return const_find_type(p->get_value(), true); } +/*******************************************************************\ + +Function: at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, mapped_type &)::at( const key_type &k, const tvt &key_exists) @@ -600,6 +777,18 @@ SHARING_MAPT2(, mapped_type &)::at( return r.first; } +/*******************************************************************\ + +Function: at + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(const, mapped_type &)::at(const key_type &k) const { const_find_type r=find(k); @@ -609,6 +798,18 @@ SHARING_MAPT2(const, mapped_type &)::at(const key_type &k) const return r.first; } +/*******************************************************************\ + +Function: operator[] + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + SHARING_MAPT2(, mapped_type &)::operator[](const key_type &k) { return place(k, mapped_type()).first; diff --git a/src/util/sharing_node.h b/src/util/sharing_node.h index 9f8cc0a4416..1e3d29a413e 100644 --- a/src/util/sharing_node.h +++ b/src/util/sharing_node.h @@ -6,9 +6,6 @@ Author: Daniel Poetzl \*******************************************************************/ -/// \file -/// Sharing node - #ifndef CPROVER_UTIL_SHARING_NODE_H #define CPROVER_UTIL_SHARING_NODE_H diff --git a/src/util/signal_catcher.cpp b/src/util/signal_catcher.cpp index d06c8356eee..b0178340543 100644 --- a/src/util/signal_catcher.cpp +++ b/src/util/signal_catcher.cpp @@ -28,6 +28,18 @@ Author: Daniel Kroening, kroening@kroening.com std::vector pids_of_children; #endif +/*******************************************************************\ + +Function: install_signal_catcher + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void install_signal_catcher() { #if defined(_WIN32) @@ -45,6 +57,18 @@ void install_signal_catcher() #endif } +/*******************************************************************\ + +Function: remove_signal_catcher + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void remove_signal_catcher() { #if defined(_WIN32) @@ -61,6 +85,18 @@ void remove_signal_catcher() #endif } +/*******************************************************************\ + +Function: signal_catcher + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void signal_catcher(int sig) { #if defined(_WIN32) diff --git a/src/util/simplify_expr.cpp b/src/util/simplify_expr.cpp index 8ac00c44083..837138258d0 100644 --- a/src/util/simplify_expr.cpp +++ b/src/util/simplify_expr.cpp @@ -63,6 +63,18 @@ struct simplify_expr_cachet simplify_expr_cachet simplify_expr_cache; #endif +/*******************************************************************\ + +Function: simplify_exprt::simplify_abs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_abs(exprt &expr) { if(expr.operands().size()!=1) @@ -103,6 +115,18 @@ bool simplify_exprt::simplify_abs(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_sign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_sign(exprt &expr) { if(expr.operands().size()!=1) @@ -133,6 +157,18 @@ bool simplify_exprt::simplify_sign(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_popcount + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_popcount(exprt &expr) { if(expr.operands().size()!=1) @@ -164,6 +200,18 @@ bool simplify_exprt::simplify_popcount(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_typecast(exprt &expr) { if(expr.operands().size()!=1) @@ -711,6 +759,18 @@ bool simplify_exprt::simplify_typecast(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_dereference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_dereference(exprt &expr) { const exprt &pointer=to_dereference_expr(expr).pointer(); @@ -769,6 +829,18 @@ bool simplify_exprt::simplify_dereference(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_implies + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_implies( exprt &expr, const exprt &cond, @@ -860,6 +932,18 @@ bool simplify_exprt::simplify_if_implies( return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_recursive + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_recursive( exprt &expr, const exprt &cond, @@ -892,6 +976,18 @@ bool simplify_exprt::simplify_if_recursive( return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_conj + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_conj( exprt &expr, const exprt &cond) @@ -913,6 +1009,18 @@ bool simplify_exprt::simplify_if_conj( return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_disj + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_disj( exprt &expr, const exprt &cond) @@ -934,6 +1042,18 @@ bool simplify_exprt::simplify_if_disj( return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_branch + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_branch( exprt &trueexpr, exprt &falseexpr, @@ -966,6 +1086,18 @@ bool simplify_exprt::simplify_if_branch( return tresult && fresult; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_cond + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_cond(exprt &expr) { bool result=true; @@ -1002,6 +1134,18 @@ bool simplify_exprt::simplify_if_cond(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if_preorder + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if_preorder(if_exprt &expr) { exprt &cond=expr.cond(); @@ -1087,6 +1231,18 @@ bool simplify_exprt::simplify_if_preorder(if_exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_if + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_if(if_exprt &expr) { exprt &cond=expr.cond(); @@ -1195,6 +1351,18 @@ bool simplify_exprt::simplify_if(if_exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::get_values + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::get_values( const exprt &expr, value_listt &value_list) @@ -1221,6 +1389,18 @@ bool simplify_exprt::get_values( return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_lambda + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_lambda(exprt &expr) { bool result=true; @@ -1228,6 +1408,18 @@ bool simplify_exprt::simplify_lambda(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_with + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_with(exprt &expr) { bool result=true; @@ -1301,6 +1493,18 @@ bool simplify_exprt::simplify_with(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_update(exprt &expr) { if(expr.operands().size()!=3) @@ -1358,6 +1562,18 @@ bool simplify_exprt::simplify_update(exprt &expr) return false; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_object(exprt &expr) { if(expr.id()==ID_plus) @@ -1449,6 +1665,18 @@ bool simplify_exprt::simplify_object(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::bits2expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt simplify_exprt::bits2expr( const std::string &bits, const typet &_type, @@ -1563,6 +1791,18 @@ exprt simplify_exprt::bits2expr( return nil_exprt(); } +/*******************************************************************\ + +Function: simplify_exprt::expr2bits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string simplify_exprt::expr2bits( const exprt &expr, bool little_endian) @@ -1623,6 +1863,18 @@ std::string simplify_exprt::expr2bits( return ""; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_byte_extract + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) { // lift up any ID_if on the object @@ -1873,6 +2125,18 @@ bool simplify_exprt::simplify_byte_extract(byte_extract_exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_byte_update + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr) { // byte_update(byte_update(root, offset, value), offset, value2) => @@ -2145,6 +2409,18 @@ bool simplify_exprt::simplify_byte_update(byte_update_exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_node_preorder + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_node_preorder(exprt &expr) { bool result=true; @@ -2170,6 +2446,18 @@ bool simplify_exprt::simplify_node_preorder(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_node(exprt &expr) { if(!expr.has_operands()) @@ -2303,7 +2591,19 @@ bool simplify_exprt::simplify_node(exprt &expr) return result; } -/// \return returns true if expression unchanged; returns false if changed +/*******************************************************************\ + +Function: simplify_exprt::simplify_rec + + Inputs: + + Outputs: returns true if expression unchanged; + returns false if changed + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_rec(exprt &expr) { // look up in cache @@ -2363,6 +2663,18 @@ bool simplify_exprt::simplify_rec(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify(exprt &expr) { #ifdef DEBUG_ON_DEMAND @@ -2377,11 +2689,35 @@ bool simplify_exprt::simplify(exprt &expr) return res; } +/*******************************************************************\ + +Function: simplify + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify(exprt &expr, const namespacet &ns) { return simplify_exprt(ns).simplify(expr); } +/*******************************************************************\ + +Function: simplify_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt simplify_expr(const exprt &src, const namespacet &ns) { exprt tmp=src; diff --git a/src/util/simplify_expr_array.cpp b/src/util/simplify_expr_array.cpp index 8be90d2e74e..f00c039a6ef 100644 --- a/src/util/simplify_expr_array.cpp +++ b/src/util/simplify_expr_array.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "arith_tools.h" #include "pointer_offset_size.h" +/*******************************************************************\ + +Function: simplify_exprt::simplify_index + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_index(exprt &expr) { bool result=true; diff --git a/src/util/simplify_expr_boolean.cpp b/src/util/simplify_expr_boolean.cpp index b1a34c77ec7..b747047cf98 100644 --- a/src/util/simplify_expr_boolean.cpp +++ b/src/util/simplify_expr_boolean.cpp @@ -14,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "namespace.h" #include "std_expr.h" +/*******************************************************************\ + +Function: simplify_exprt::simplify_boolean + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_boolean(exprt &expr) { if(!expr.has_operands()) @@ -187,6 +199,18 @@ bool simplify_exprt::simplify_boolean(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_not + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_not(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_expr_floatbv.cpp b/src/util/simplify_expr_floatbv.cpp index e0be11988c8..7115e23024a 100644 --- a/src/util/simplify_expr_floatbv.cpp +++ b/src/util/simplify_expr_floatbv.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_expr.h" #include "arith_tools.h" +/*******************************************************************\ + +Function: simplify_exprt::simplify_isinf + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_isinf(exprt &expr) { if(expr.operands().size()!=1) @@ -33,6 +45,18 @@ bool simplify_exprt::simplify_isinf(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_isnan + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_isnan(exprt &expr) { if(expr.operands().size()!=1) @@ -48,6 +72,18 @@ bool simplify_exprt::simplify_isnan(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_isnormal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_isnormal(exprt &expr) { if(expr.operands().size()!=1) @@ -63,6 +99,18 @@ bool simplify_exprt::simplify_isnormal(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_abs + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #if 0 bool simplify_exprt::simplify_abs(exprt &expr) { @@ -105,6 +153,18 @@ bool simplify_exprt::simplify_abs(exprt &expr) } #endif +/*******************************************************************\ + +Function: simplify_exprt::simplify_sign + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #if 0 bool simplify_exprt::simplify_sign(exprt &expr) { @@ -137,6 +197,18 @@ bool simplify_exprt::simplify_sign(exprt &expr) } #endif +/*******************************************************************\ + +Function: simplify_exprt::simplify_floatbv_typecast + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) { // These casts usually reduce precision, and thus, usually round. @@ -266,6 +338,18 @@ bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_floatbv_op + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_floatbv_op(exprt &expr) { const typet &type=ns.follow(expr.type()); @@ -329,6 +413,18 @@ bool simplify_exprt::simplify_floatbv_op(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_ieee_float_relation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_ieee_float_relation(exprt &expr) { assert(expr.id()==ID_ieee_float_equal || diff --git a/src/util/simplify_expr_int.cpp b/src/util/simplify_expr_int.cpp index 03c67b80014..c9c8a7f12a0 100644 --- a/src/util/simplify_expr_int.cpp +++ b/src/util/simplify_expr_int.cpp @@ -22,6 +22,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "rational_tools.h" #include "ieee_float.h" +/*******************************************************************\ + +Function: simplify_exprt::simplify_bswap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_bswap(exprt &expr) { if(expr.type().id()==ID_unsignedbv && @@ -54,6 +66,18 @@ bool simplify_exprt::simplify_bswap(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_mult + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_mult(exprt &expr) { // check to see if it is a number type @@ -159,6 +183,18 @@ bool simplify_exprt::simplify_mult(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_div + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_div(exprt &expr) { if(!is_number(expr.type())) @@ -279,6 +315,18 @@ bool simplify_exprt::simplify_div(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_mod + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_mod(exprt &expr) { if(!is_number(expr.type())) @@ -328,6 +376,18 @@ bool simplify_exprt::simplify_mod(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_plus(exprt &expr) { if(!is_number(expr.type()) && @@ -485,6 +545,18 @@ bool simplify_exprt::simplify_plus(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_minus(exprt &expr) { if(!is_number(expr.type()) && @@ -544,6 +616,18 @@ bool simplify_exprt::simplify_minus(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_bitwise + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_bitwise(exprt &expr) { if(!is_bitvector_type(expr.type())) @@ -714,6 +798,18 @@ bool simplify_exprt::simplify_bitwise(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_extractbit + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_extractbit(exprt &expr) { const typet &op0_type=expr.op0().type(); @@ -748,6 +844,18 @@ bool simplify_exprt::simplify_extractbit(exprt &expr) return false; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_concatenation + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_concatenation(exprt &expr) { bool result=true; @@ -835,6 +943,18 @@ bool simplify_exprt::simplify_concatenation(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_shifts + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_shifts(exprt &expr) { if(!is_number(expr.type())) @@ -947,6 +1067,18 @@ bool simplify_exprt::simplify_shifts(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_power + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_power(exprt &expr) { if(!is_number(expr.type())) @@ -969,7 +1101,18 @@ bool simplify_exprt::simplify_power(exprt &expr) return false; } -/// Simplifies extracting of bits from a constant. +/*******************************************************************\ + +Function: simplify_exprt::simplify_extractbits + + Inputs: + + Outputs: + + Purpose: Simplifies extracting of bits from a constant. + +\*******************************************************************/ + bool simplify_exprt::simplify_extractbits(exprt &expr) { assert(expr.operands().size()==3); @@ -1018,6 +1161,18 @@ bool simplify_exprt::simplify_extractbits(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_unary_plus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_unary_plus(exprt &expr) { if(expr.operands().size()!=1) @@ -1028,6 +1183,18 @@ bool simplify_exprt::simplify_unary_plus(exprt &expr) return false; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_unary_minus + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_unary_minus(exprt &expr) { if(expr.operands().size()!=1) @@ -1105,6 +1272,18 @@ bool simplify_exprt::simplify_unary_minus(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_bitnot + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_bitnot(exprt &expr) { if(!expr.has_operands()) @@ -1141,7 +1320,18 @@ bool simplify_exprt::simplify_bitnot(exprt &expr) return true; } -/// simplifies inequalities !=, <=, <, >=, >, and also == +/*******************************************************************\ + +Function: simplify_exprt::simplify_inequality + + Inputs: + + Outputs: + + Purpose: simplifies inequalities !=, <=, <, >=, >, and also == + +\*******************************************************************/ + bool simplify_exprt::simplify_inequality(exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1358,6 +1548,18 @@ bool simplify_exprt::simplify_inequality(exprt &expr) return false; } +/*******************************************************************\ + +Function: simplify_exprt::eliminate_common_addends + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::eliminate_common_addends( exprt &op0, exprt &op1) @@ -1406,6 +1608,18 @@ bool simplify_exprt::eliminate_common_addends( return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_inequality_not_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_inequality_not_constant(exprt &expr) { exprt::operandst &operands=expr.operands(); @@ -1532,7 +1746,18 @@ bool simplify_exprt::simplify_inequality_not_constant(exprt &expr) return true; } -/// \par parameters: an inequality with a constant on the RHS +/*******************************************************************\ + +Function: simplify_exprt::simplify_inequality_constant + + Inputs: an inequality with a constant on the RHS + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_inequality_constant(exprt &expr) { // the constant is always on the RHS diff --git a/src/util/simplify_expr_pointer.cpp b/src/util/simplify_expr_pointer.cpp index 64800f286f8..9bc2496f5ff 100644 --- a/src/util/simplify_expr_pointer.cpp +++ b/src/util/simplify_expr_pointer.cpp @@ -20,6 +20,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "prefix.h" #include "pointer_predicates.h" +/*******************************************************************\ + +Function: is_dereference_integer_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool is_dereference_integer_object( const exprt &expr, mp_integer &address) @@ -49,6 +61,18 @@ static bool is_dereference_integer_object( return false; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_address_of_arg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_address_of_arg(exprt &expr) { if(expr.id()==ID_index) @@ -168,6 +192,18 @@ bool simplify_exprt::simplify_address_of_arg(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_address_of(exprt &expr) { if(expr.operands().size()!=1) @@ -210,6 +246,18 @@ bool simplify_exprt::simplify_address_of(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_pointer_offset + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_pointer_offset(exprt &expr) { if(expr.operands().size()!=1) @@ -387,6 +435,18 @@ bool simplify_exprt::simplify_pointer_offset(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_inequality_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_inequality_address_of(exprt &expr) { assert(expr.type().id()==ID_bool); @@ -428,6 +488,18 @@ bool simplify_exprt::simplify_inequality_address_of(exprt &expr) return true; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_inequality_pointer_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_inequality_pointer_object(exprt &expr) { assert(expr.type().id()==ID_bool); @@ -460,6 +532,18 @@ bool simplify_exprt::simplify_inequality_pointer_object(exprt &expr) return false; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_pointer_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_pointer_object(exprt &expr) { if(expr.operands().size()!=1) @@ -488,6 +572,18 @@ bool simplify_exprt::simplify_pointer_object(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_dynamic_object + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_dynamic_object(exprt &expr) { if(expr.operands().size()!=1) @@ -544,6 +640,18 @@ bool simplify_exprt::simplify_dynamic_object(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_invalid_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_invalid_pointer(exprt &expr) { if(expr.operands().size()!=1) @@ -573,6 +681,18 @@ bool simplify_exprt::simplify_invalid_pointer(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::objects_equal + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt simplify_exprt::objects_equal(const exprt &a, const exprt &b) { if(a==b) @@ -597,6 +717,18 @@ tvt simplify_exprt::objects_equal(const exprt &a, const exprt &b) return tvt::unknown(); } +/*******************************************************************\ + +Function: simplify_exprt::objects_equal_address_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + tvt simplify_exprt::objects_equal_address_of(const exprt &a, const exprt &b) { if(a==b) @@ -621,6 +753,18 @@ tvt simplify_exprt::objects_equal_address_of(const exprt &a, const exprt &b) return tvt::unknown(); } +/*******************************************************************\ + +Function: simplify_exprt::simplify_object_size + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_object_size(exprt &expr) { if(expr.operands().size()!=1) @@ -667,6 +811,18 @@ bool simplify_exprt::simplify_object_size(exprt &expr) return result; } +/*******************************************************************\ + +Function: simplify_exprt::simplify_good_pointer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_good_pointer(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_expr_struct.cpp b/src/util/simplify_expr_struct.cpp index 52695450157..a59c355e72c 100644 --- a/src/util/simplify_expr_struct.cpp +++ b/src/util/simplify_expr_struct.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "pointer_offset_size.h" #include "arith_tools.h" +/*******************************************************************\ + +Function: simplify_exprt::simplify_member + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool simplify_exprt::simplify_member(exprt &expr) { if(expr.operands().size()!=1) diff --git a/src/util/simplify_utils.cpp b/src/util/simplify_utils.cpp index b814e685103..ff5abf78930 100644 --- a/src/util/simplify_utils.cpp +++ b/src/util/simplify_utils.cpp @@ -10,9 +10,20 @@ Author: Daniel Kroening, kroening@kroening.com #include "simplify_utils.h" -/// sort operands of an expression according to ordering defined by operator< -/// \par parameters: operand list -/// \return modifies operand list returns true iff nothing was changed +/*******************************************************************\ + +Function: simplify_exprt::sort_operands + + Inputs: operand list + + Outputs: modifies operand list + returns true iff nothing was changed + + Purpose: sort operands of an expression according to ordering + defined by operator< + +\*******************************************************************/ + bool sort_operands(exprt::operandst &operands) { bool do_sort=false; @@ -37,7 +48,19 @@ bool sort_operands(exprt::operandst &operands) return false; } -/// produce canonical ordering for associative and commutative binary operators +/*******************************************************************\ + +Function: sort_and_join + + Inputs: + + Outputs: + + Purpose: produce canonical ordering for associative and commutative + binary operators + +\*******************************************************************/ + // The entries // { ID_plus, ID_floatbv }, // { ID_mult, ID_floatbv }, @@ -119,6 +142,18 @@ static const struct saj_tablet &sort_and_join( return saj_table[i]; } +/*******************************************************************\ + +Function: sort_and_join + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool sort_and_join(exprt &expr) { bool result=true; diff --git a/src/util/source_location.cpp b/src/util/source_location.cpp index 8fb3935cc74..7583b40b496 100644 --- a/src/util/source_location.cpp +++ b/src/util/source_location.cpp @@ -11,7 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "source_location.h" #include "file_util.h" -/// \par parameters: print_cwd, print the absolute path to the file +/*******************************************************************\ + +Function: source_locationt::as_string + + Inputs: print_cwd, print the absolute path to the file + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string source_locationt::as_string(bool print_cwd) const { std::string dest; @@ -61,6 +72,18 @@ std::string source_locationt::as_string(bool print_cwd) const return dest; } +/*******************************************************************\ + +Function: operator<< + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator << ( std::ostream &out, const source_locationt &source_location) diff --git a/src/util/sparse_vector.h b/src/util/sparse_vector.h index 226564d636e..193e9a68a01 100644 --- a/src/util/sparse_vector.h +++ b/src/util/sparse_vector.h @@ -6,9 +6,6 @@ Author: Romain Brenguier \*******************************************************************/ -/// \file -/// Sparse Vectors - #ifndef CPROVER_UTIL_SPARSE_VECTOR_H #define CPROVER_UTIL_SPARSE_VECTOR_H diff --git a/src/util/ssa_expr.cpp b/src/util/ssa_expr.cpp index 3252d90c241..affd2907eb5 100644 --- a/src/util/ssa_expr.cpp +++ b/src/util/ssa_expr.cpp @@ -13,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ssa_expr.h" +/*******************************************************************\ + +Function: build_identifier_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static void build_ssa_identifier_rec( const exprt &expr, const irep_idt &l0, @@ -79,6 +91,18 @@ bool ssa_exprt::can_build_identifier(const exprt &expr) return false; } +/*******************************************************************\ + +Function: ssa_exprt::build_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::pair ssa_exprt::build_identifier( const exprt &expr, const irep_idt &l0, diff --git a/src/util/std_code.cpp b/src/util/std_code.cpp index e5b5fa2eb60..d7a4f2aa0fd 100644 --- a/src/util/std_code.cpp +++ b/src/util/std_code.cpp @@ -9,16 +9,52 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_code.h" #include "std_expr.h" +/*******************************************************************\ + +Function: code_declt::get_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irep_idt &code_declt::get_identifier() const { return to_symbol_expr(symbol()).get_identifier(); } +/*******************************************************************\ + +Function: code_deadt::get_identifier + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const irep_idt &code_deadt::get_identifier() const { return to_symbol_expr(symbol()).get_identifier(); } +/*******************************************************************\ + +Function: codet::make_block + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + code_blockt &codet::make_block() { if(get_statement()==ID_block) @@ -34,6 +70,18 @@ code_blockt &codet::make_block() return static_cast(*this); } +/*******************************************************************\ + +Function: codet::first_statement + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + codet &codet::first_statement() { const irep_idt &statement=get_statement(); @@ -49,6 +97,18 @@ codet &codet::first_statement() return *this; } +/*******************************************************************\ + +Function: first_statement + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const codet &codet::first_statement() const { const irep_idt &statement=get_statement(); @@ -64,6 +124,18 @@ const codet &codet::first_statement() const return *this; } +/*******************************************************************\ + +Function: codet::last_statement + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + codet &codet::last_statement() { const irep_idt &statement=get_statement(); @@ -79,6 +151,18 @@ codet &codet::last_statement() return *this; } +/*******************************************************************\ + +Function: codet::last_statement + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const codet &codet::last_statement() const { const irep_idt &statement=get_statement(); @@ -94,8 +178,20 @@ const codet &codet::last_statement() const return *this; } -/// Add all the codets from extra_block to the current code_blockt -/// \param extra_block: The input code_blockt +/*******************************************************************\ + +Function: code_blockt::append + + Inputs: + extra_block - The input code_blockt + + Outputs: + + Purpose: Add all the codets from extra_block to the current + code_blockt + +\*******************************************************************/ + void code_blockt::append(const code_blockt &extra_block) { operands().reserve(operands().size()+extra_block.operands().size()); diff --git a/src/util/std_expr.cpp b/src/util/std_expr.cpp index d6e1b1d2a47..4cb9eeff9cc 100644 --- a/src/util/std_expr.cpp +++ b/src/util/std_expr.cpp @@ -17,12 +17,36 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_types.h" #include "std_expr.h" +/*******************************************************************\ + +Function: constant_exprt::value_is_zero_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool constant_exprt::value_is_zero_string() const { const std::string val=id2string(get_value()); return val.find_first_not_of('0')==std::string::npos; } +/*******************************************************************\ + +Function: disjunction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt disjunction(const exprt::operandst &op) { if(op.empty()) @@ -47,6 +71,18 @@ unsigned int dynamic_object_exprt::get_instance() const return std::stoul(id2string(to_constant_expr(op0()).get_value())); } +/*******************************************************************\ + +Function: conjunction + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + exprt conjunction(const exprt::operandst &op) { if(op.empty()) @@ -61,7 +97,18 @@ exprt conjunction(const exprt::operandst &op) } } -/// Build an object_descriptor_exprt from a given expr +/*******************************************************************\ + +Function: build_object_descriptor_rec + + Inputs: + + Outputs: + + Purpose: Build an object_descriptor_exprt from a given expr + +\*******************************************************************/ + static void build_object_descriptor_rec( const namespacet &ns, const exprt &expr, @@ -121,7 +168,18 @@ static void build_object_descriptor_rec( } } -/// Build an object_descriptor_exprt from a given expr +/*******************************************************************\ + +Function: object_descriptor_exprt::build + + Inputs: + + Outputs: + + Purpose: Build an object_descriptor_exprt from a given expr + +\*******************************************************************/ + void object_descriptor_exprt::build( const exprt &expr, const namespacet &ns) @@ -137,11 +195,35 @@ void object_descriptor_exprt::build( assert(root_object().type().id()!=ID_empty); } +/*******************************************************************\ + +Function: constant_exprt::integer_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt constant_exprt::integer_constant(unsigned v) { return constant_exprt(std::to_string(v), integer_typet()); } +/*******************************************************************\ + +Function: shift_exprt::shift_exprt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + shift_exprt::shift_exprt( const exprt &_src, const irep_idt &_id, @@ -150,6 +232,18 @@ shift_exprt::shift_exprt( { } +/*******************************************************************\ + +Function: extractbit_exprt::extractbit_exprt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + extractbit_exprt::extractbit_exprt( const exprt &_src, const std::size_t _index): @@ -158,6 +252,18 @@ extractbit_exprt::extractbit_exprt( { } +/*******************************************************************\ + +Function: extractbit_exprt::extractbits_exprt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + extractbits_exprt::extractbits_exprt( const exprt &_src, const std::size_t _upper, diff --git a/src/util/std_types.cpp b/src/util/std_types.cpp index 3f0ad44a8bd..e6244ab5c9b 100644 --- a/src/util/std_types.cpp +++ b/src/util/std_types.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "std_types.h" #include "std_expr.h" +/*******************************************************************\ + +Function: fixedbv_typet::get_integer_bits + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t fixedbv_typet::get_integer_bits() const { const irep_idt integer_bits=get(ID_integer_bits); @@ -18,6 +30,18 @@ std::size_t fixedbv_typet::get_integer_bits() const return unsafe_string2unsigned(id2string(integer_bits)); } +/*******************************************************************\ + +Function: floatbv_typet::get_f + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t floatbv_typet::get_f() const { const irep_idt &f=get(ID_f); @@ -25,6 +49,18 @@ std::size_t floatbv_typet::get_f() const return unsafe_string2unsigned(id2string(f)); } +/*******************************************************************\ + +Function: struct_union_typet::component_number + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t struct_union_typet::component_number( const irep_idt &component_name) const { @@ -47,6 +83,18 @@ std::size_t struct_union_typet::component_number( return 0; } +/*******************************************************************\ + +Function: struct_union_typet::get_component + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const struct_union_typet::componentt &struct_union_typet::get_component( const irep_idt &component_name) const { @@ -64,6 +112,18 @@ const struct_union_typet::componentt &struct_union_typet::get_component( return static_cast(get_nil_irep()); } +/*******************************************************************\ + +Function: struct_union_typet::component_type + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + typet struct_union_typet::component_type( const irep_idt &component_name) const { @@ -72,6 +132,18 @@ typet struct_union_typet::component_type( return c.type(); } +/*******************************************************************\ + +Function: struct_typet::is_prefix_of + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool struct_typet::is_prefix_of(const struct_typet &other) const { const componentst &ot_components=other.components(); @@ -101,83 +173,275 @@ bool struct_typet::is_prefix_of(const struct_typet &other) const return true; // ok, *this is a prefix of ot } +/*******************************************************************\ + +Function: is_reference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_reference(const typet &type) { return type.id()==ID_pointer && type.get_bool(ID_C_reference); } +/*******************************************************************\ + +Function: is_rvalue_reference + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_rvalue_reference(const typet &type) { return type.id()==ID_pointer && type.get_bool(ID_C_rvalue_reference); } +/*******************************************************************\ + +Function: range_typet::set_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void range_typet::set_from(const mp_integer &from) { set(ID_from, integer2string(from)); } +/*******************************************************************\ + +Function: range_typet::set_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void range_typet::set_to(const mp_integer &to) { set(ID_to, integer2string(to)); } +/*******************************************************************\ + +Function: range_typet::get_from + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer range_typet::get_from() const { return string2integer(get_string(ID_from)); } +/*******************************************************************\ + +Function: range_typet::get_to + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer range_typet::get_to() const { return string2integer(get_string(ID_to)); } +/*******************************************************************\ + +Function: signedbv_typet::smallest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer signedbv_typet::smallest() const { return -power(2, get_width()-1); } +/*******************************************************************\ + +Function: signedbv_typet::largest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer signedbv_typet::largest() const { return power(2, get_width()-1)-1; } +/*******************************************************************\ + +Function: signedbv_typet::zero_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt signedbv_typet::zero_expr() const { return to_constant_expr(from_integer(0, *this)); } +/*******************************************************************\ + +Function: signedbv_typet::smallest_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt signedbv_typet::smallest_expr() const { return to_constant_expr(from_integer(smallest(), *this)); } +/*******************************************************************\ + +Function: signedbv_typet::largest_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt signedbv_typet::largest_expr() const { return to_constant_expr(from_integer(largest(), *this)); } +/*******************************************************************\ + +Function: unsignedbv_typet::smallest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer unsignedbv_typet::smallest() const { return 0; } +/*******************************************************************\ + +Function: unsignedbv_typet::largest + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + mp_integer unsignedbv_typet::largest() const { return power(2, get_width())-1; } +/*******************************************************************\ + +Function: unsignedbv_typet::zero_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt unsignedbv_typet::zero_expr() const { return to_constant_expr(from_integer(0, *this)); } +/*******************************************************************\ + +Function: unsignedbv_typet::smallest_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt unsignedbv_typet::smallest_expr() const { return to_constant_expr(from_integer(smallest(), *this)); } +/*******************************************************************\ + +Function: unsignedbv_typet::largest_expr + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + constant_exprt unsignedbv_typet::largest_expr() const { return to_constant_expr(from_integer(largest(), *this)); diff --git a/src/util/string2int.cpp b/src/util/string2int.cpp index 7a1c10da48b..224e5779858 100644 --- a/src/util/string2int.cpp +++ b/src/util/string2int.cpp @@ -13,6 +13,18 @@ Author: Michael Tautschnig, michael.tautschnig@cs.ox.ac.uk #include "string2int.h" +/*******************************************************************\ + +Function: str2number + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + template inline T str2number(const char *str, int base, bool safe) { @@ -48,31 +60,103 @@ inline T str2number(const char *str, int base, bool safe) return (T)val; } +/*******************************************************************\ + +Function: safe_string2unsigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned safe_string2unsigned(const std::string &str, int base) { return str2number(str.c_str(), base, true); } +/*******************************************************************\ + +Function: safe_string2size_t + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t safe_string2size_t(const std::string &str, int base) { return str2number(str.c_str(), base, true); } +/*******************************************************************\ + +Function: unsafe_string2int + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + int unsafe_string2int(const std::string &str, int base) { return str2number(str.c_str(), base, false); } +/*******************************************************************\ + +Function: unsafe_string2unsigned + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned unsafe_string2unsigned(const std::string &str, int base) { return str2number(str.c_str(), base, false); } +/*******************************************************************\ + +Function: unsafe_string2size_t + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::size_t unsafe_string2size_t(const std::string &str, int base) { return str2number(str.c_str(), base, false); } +/*******************************************************************\ + +Function: unsafe_string2signedlonglong + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + signed long long int unsafe_string2signedlonglong( const std::string &str, int base) @@ -80,6 +164,18 @@ signed long long int unsafe_string2signedlonglong( return str2number(str.c_str(), base, false); } +/*******************************************************************\ + +Function: unsafe_string2unsignedlonglong + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned long long int unsafe_string2unsignedlonglong( const std::string &str, int base) diff --git a/src/util/string_container.cpp b/src/util/string_container.cpp index 189d721b8ed..1b1603631d0 100644 --- a/src/util/string_container.cpp +++ b/src/util/string_container.cpp @@ -6,19 +6,40 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Container for C-Strings - #include #include "string_container.h" string_containert string_container; +/*******************************************************************\ + +Function: string_ptrt::string_ptrt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + string_ptrt::string_ptrt(const char *_s):s(_s), len(strlen(_s)) { } +/*******************************************************************\ + +Function: string_ptrt::operator== + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool string_ptrt::operator==(const string_ptrt &other) const { if(len!=other.len) @@ -27,6 +48,18 @@ bool string_ptrt::operator==(const string_ptrt &other) const return len==0 || memcmp(s, other.s, len)==0; } +/*******************************************************************\ + +Function: string_containert::string_containert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void initialize_string_container(); string_containert::string_containert() @@ -38,10 +71,34 @@ string_containert::string_containert() initialize_string_container(); } +/*******************************************************************\ + +Function: string_containert::~string_containert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + string_containert::~string_containert() { } +/*******************************************************************\ + +Function: string_containert::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned string_containert::get(const char *s) { string_ptrt string_ptr(s); @@ -65,6 +122,18 @@ unsigned string_containert::get(const char *s) return r; } +/*******************************************************************\ + +Function: string_containert::get + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned string_containert::get(const std::string &s) { string_ptrt string_ptr(s); diff --git a/src/util/string_container.h b/src/util/string_container.h index 59a5daff0b8..cbd8d0d320b 100644 --- a/src/util/string_container.h +++ b/src/util/string_container.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Container for C-Strings - #ifndef CPROVER_UTIL_STRING_CONTAINER_H #define CPROVER_UTIL_STRING_CONTAINER_H diff --git a/src/util/string_expr.h b/src/util/string_expr.h index cdb801988ae..ff19a8c8259 100644 --- a/src/util/string_expr.h +++ b/src/util/string_expr.h @@ -6,9 +6,6 @@ Author: Romain Brenguier, romain.brenguier@diffblue.com \*******************************************************************/ -/// \file -/// String expressions for the string solver - #ifndef CPROVER_UTIL_STRING_EXPR_H #define CPROVER_UTIL_STRING_EXPR_H diff --git a/src/util/string_hash.cpp b/src/util/string_hash.cpp index ee212232fa7..c59a0a61280 100644 --- a/src/util/string_hash.cpp +++ b/src/util/string_hash.cpp @@ -6,11 +6,20 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// string hasing - #include "string_hash.h" +/*******************************************************************\ + +Function: hash_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + size_t hash_string(const std::string &s) { size_t h=0; @@ -22,6 +31,18 @@ size_t hash_string(const std::string &s) return h; } +/*******************************************************************\ + +Function: hash_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + size_t hash_string(const char *s) { size_t h=0; diff --git a/src/util/string_hash.h b/src/util/string_hash.h index 021cb95b341..41f45adeda0 100644 --- a/src/util/string_hash.h +++ b/src/util/string_hash.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// string hashing - #ifndef CPROVER_UTIL_STRING_HASH_H #define CPROVER_UTIL_STRING_HASH_H diff --git a/src/util/string_utils.cpp b/src/util/string_utils.cpp index 04697b78d91..9fb81dfa08c 100644 --- a/src/util/string_utils.cpp +++ b/src/util/string_utils.cpp @@ -12,6 +12,18 @@ Author: Daniel Poetzl #include "string_utils.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string strip_string(const std::string &s) { auto pred=[](char c){ return std::isspace(c); }; @@ -30,6 +42,18 @@ std::string strip_string(const std::string &s) return s.substr(i, (j-i+1)); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void split_string( const std::string &s, char delim, @@ -80,6 +104,18 @@ void split_string( result.push_back(""); } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void split_string( const std::string &s, char delim, diff --git a/src/util/substitute.cpp b/src/util/substitute.cpp index 10d49b78d65..d83ad9361fe 100644 --- a/src/util/substitute.cpp +++ b/src/util/substitute.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "substitute.h" +/*******************************************************************\ + +Function: substitute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void substitute( std::string &dest, const std::string &what, diff --git a/src/util/symbol.cpp b/src/util/symbol.cpp index ed1b2b42d27..d2883832faf 100644 --- a/src/util/symbol.cpp +++ b/src/util/symbol.cpp @@ -12,6 +12,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "source_location.h" #include "std_expr.h" +/*******************************************************************\ + +Function: symbolt::show + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symbolt::show(std::ostream &out) const { out << " " << name << '\n'; @@ -65,6 +77,18 @@ void symbolt::show(std::ostream &out) const out << '\n'; } +/*******************************************************************\ + +Function: operator<< + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator<<(std::ostream &out, const symbolt &symbol) { @@ -72,6 +96,18 @@ std::ostream &operator<<(std::ostream &out, return out; } +/*******************************************************************\ + +Function: symbolt::to_irep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + irept symbolt::to_irep() const { irept dest; @@ -122,6 +158,18 @@ irept symbolt::to_irep() const return dest; } +/*******************************************************************\ + +Function: symbolt::from_irep + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symbolt::from_irep(const irept &src) { type=static_cast(src.find(ID_type)); @@ -152,6 +200,18 @@ void symbolt::from_irep(const irept &src) is_volatile=src.get_bool("is_volatile"); } +/*******************************************************************\ + +Function: symbolt::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void symbolt::swap(symbolt &b) { #define SYM_SWAP1(x) x.swap(b.x) @@ -185,8 +245,18 @@ void symbolt::swap(symbolt &b) SYM_SWAP2(is_volatile); } -/// produces a symbol_exprt for a symbol -/// \return symbol_exprt +/*******************************************************************\ + +Function: symbolt::symbol_expr + + Inputs: symbol + + Outputs: symbol_exprt + + Purpose: produces a symbol_exprt for a symbol + +\*******************************************************************/ + symbol_exprt symbolt::symbol_expr() const { return symbol_exprt(name, type); diff --git a/src/util/symbol_table.cpp b/src/util/symbol_table.cpp index 2a6e71f137f..37053b7737b 100644 --- a/src/util/symbol_table.cpp +++ b/src/util/symbol_table.cpp @@ -10,11 +10,21 @@ Author: Daniel Kroening, kroening@kroening.com #include "symbol_table.h" -/// Add a new symbol to the symbol table -/// \param symbol: The symbol to be added to the symbol table -/// \return Returns a boolean indicating whether the process failed, which -/// should only happen if there is a symbol with the same name already in the -/// symbol table +/*******************************************************************\ + +Function: symbol_tablet::add + + Inputs: + symbol - The symbol to be added to the symbol table + + Outputs: Returns a boolean indicating whether the process failed, + which should only happen if there is a symbol with the same + name already in the symbol table + + Purpose: Add a new symbol to the symbol table + +\*******************************************************************/ + bool symbol_tablet::add(const symbolt &symbol) { if(!symbols.insert(std::pair(symbol.name, symbol)).second) @@ -28,21 +38,35 @@ bool symbol_tablet::add(const symbolt &symbol) return false; } -/// Move a symbol into the symbol table. If there is already a symbol with the -/// same name then symbol is unchanged, new_symbol points to the symbol with the -/// same name and true is returned. Otherwise, the symbol is moved into the -/// symbol table, symbol is set to be empty, new_symbol points to its new -/// location in the symbol table and false is returned -/// \param symbol: The symbol to be added to the symbol table -/// \param new_symbol: Pointer which the function will set to either point to -/// the symbol in the symbol table with the same name or to the symbol that -/// has been successfully moved into the symbol table -/// \return Returns a boolean indicating whether the process failed, which -/// should only happen if there is a symbol with the same name already in the -/// symbol table. If the process failed then symbol is unchanged and -/// new_symbol points to the symbol with the same name. If the process -/// succeeded symbol is set to be empty and new_symbol points to its new -/// location in the symbol table +/*******************************************************************\ + +Function: symbol_tablet::move + + Inputs: + symbol - The symbol to be added to the symbol table + new_symbol - Pointer which the function will set to either point + to the symbol in the symbol table with the same name + or to the symbol that has been successfully moved + into the symbol table + + Outputs: Returns a boolean indicating whether the process failed, + which should only happen if there is a symbol with the + same name already in the symbol table. If the process + failed then symbol is unchanged and new_symbol points to + the symbol with the same name. If the process succeeded + symbol is set to be empty and new_symbol points to its new + location in the symbol table + + Purpose: Move a symbol into the symbol table. If there is already + a symbol with the same name then symbol is unchanged, + new_symbol points to the symbol with the same name and + true is returned. Otherwise, the symbol is moved into the + symbol table, symbol is set to be empty, new_symbol points + to its new location in the symbol table and false is + returned + +\*******************************************************************/ + bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) { symbolt tmp; @@ -67,9 +91,19 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) return false; } -/// Remove a symbol from the symbol table -/// \param name: The name of the symbol to remove -/// \return Returns a boolean indicating whether the process failed +/*******************************************************************\ + +Function: symbol_tablet::remove + + Inputs: + name - The name of the symbol to remove + + Outputs: Returns a boolean indicating whether the process failed + + Purpose: Remove a symbol from the symbol table + +\*******************************************************************/ + bool symbol_tablet::remove(const irep_idt &name) { symbolst::iterator entry=symbols.find(name); @@ -104,8 +138,19 @@ bool symbol_tablet::remove(const irep_idt &name) return false; } -/// Print the contents of the symbol table -/// \param out: The ostream to direct output to +/*******************************************************************\ + +Function: symbol_tablet::show + + Inputs: + out - The ostream to direct output to + + Outputs: + + Purpose: Print the contents of the symbol table + +\*******************************************************************/ + void symbol_tablet::show(std::ostream &out) const { out << "\n" << "Symbols:" << "\n"; @@ -114,10 +159,20 @@ void symbol_tablet::show(std::ostream &out) const out << it->second; } -/// Find a symbol in the symbol table. Throws a string if no such symbol is -/// found. -/// \param identifier: The name of the symbol to look for -/// \return The symbol in the symbol table with the correct name +/*******************************************************************\ + +Function: symbol_tablet::lookup + + Inputs: + identifier - The name of the symbol to look for + + Outputs: The symbol in the symbol table with the correct name + + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. + +\*******************************************************************/ + const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const { symbolst::const_iterator it=symbols.find(identifier); @@ -128,10 +183,20 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const return it->second; } -/// Find a symbol in the symbol table. Throws a string if no such symbol is -/// found. -/// \param identifier: The name of the symbol to look for -/// \return The symbol in the symbol table with the correct name +/*******************************************************************\ + +Function: symbol_tablet::lookup + + Inputs: + identifier - The name of the symbol to look for + + Outputs: The symbol in the symbol table with the correct name + + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. + +\*******************************************************************/ + symbolt &symbol_tablet::lookup(const irep_idt &identifier) { symbolst::iterator it=symbols.find(identifier); @@ -142,9 +207,20 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier) return it->second; } -/// Print the contents of the symbol table -/// \param out: The ostream to direct output to -/// \param symbol_table: The symbol table to print out +/*******************************************************************\ + +Function: operator << + + Inputs: + out - The ostream to direct output to + symbol_table - The symbol table to print out + + Outputs: + + Purpose: Print the contents of the symbol table + +\*******************************************************************/ + std::ostream &operator << (std::ostream &out, const symbol_tablet &symbol_table) { symbol_table.show(out); diff --git a/src/util/tempdir.cpp b/src/util/tempdir.cpp index f9d4f15956c..e160c664558 100644 --- a/src/util/tempdir.cpp +++ b/src/util/tempdir.cpp @@ -28,6 +28,18 @@ Author: CM Wintersteiger #include "tempdir.h" #include "file_util.h" +/*******************************************************************\ + +Function: get_temporary_directory + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string get_temporary_directory(const std::string &name_template) { std::string result; @@ -74,26 +86,86 @@ std::string get_temporary_directory(const std::string &name_template) return result; } +/*******************************************************************\ + +Function: temp_dirt::temp_dirt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + temp_dirt::temp_dirt(const std::string &name_template) { path=get_temporary_directory(name_template); } +/*******************************************************************\ + +Function: temp_dirt::operator() + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string temp_dirt::operator()(const std::string &file) { return concat_dir_file(path, file); } +/*******************************************************************\ + +Function: temp_dirt::~temp_dirt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void temp_dirt::clear() { delete_directory(path); } +/*******************************************************************\ + +Function: temp_dirt::~temp_dirt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + temp_dirt::~temp_dirt() { clear(); } +/*******************************************************************\ + +Function: temp_working_dirt::temp_working_dirt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + temp_working_dirt::temp_working_dirt(const std::string &name_template): temp_dirt(name_template) { @@ -102,6 +174,18 @@ temp_working_dirt::temp_working_dirt(const std::string &name_template): assert(false); } +/*******************************************************************\ + +Function: temp_working_dirt::~temp_working_dirt + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + temp_working_dirt::~temp_working_dirt() { if(chdir(old_working_directory.c_str())!=0) diff --git a/src/util/tempfile.cpp b/src/util/tempfile.cpp index 24a76bdc81a..023043e232f 100644 --- a/src/util/tempfile.cpp +++ b/src/util/tempfile.cpp @@ -34,8 +34,19 @@ Author: Daniel Kroening #include "tempfile.h" -/// Substitute for mkstemps (OpenBSD standard) for Windows, where it is -/// unavailable. +/*******************************************************************\ + +Function: my_mkstemps + + Inputs: + + Outputs: + + Purpose: Substitute for mkstemps (OpenBSD standard) for Windows, + where it is unavailable. + +\*******************************************************************/ + #ifdef _WIN32 #define mkstemps my_mkstemps int my_mkstemps(char *template_str, int suffix_len) @@ -81,6 +92,18 @@ int my_mkstemps(char *template_str, int suffix_len) } #endif +/*******************************************************************\ + +Function: get_temporary_file + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string get_temporary_file( const std::string &prefix, const std::string &suffix) @@ -127,6 +150,18 @@ std::string get_temporary_file( return result; } +/*******************************************************************\ + +Function: temporary_filet::~temporary_filet + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + temporary_filet::~temporary_filet() { if(!name.empty()) diff --git a/src/util/time_stopping.cpp b/src/util/time_stopping.cpp index f41b3401fd6..3dda40c9ee5 100644 --- a/src/util/time_stopping.cpp +++ b/src/util/time_stopping.cpp @@ -8,9 +8,6 @@ Date: February 2004 \*******************************************************************/ -/// \file -/// Time Stopping - #include #if defined(_WIN32) && !defined(__MINGW32__) @@ -44,6 +41,18 @@ void gettimeofday(struct timeval* p, struct timezone *tz) } #endif +/*******************************************************************\ + +Function: current_time + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + absolute_timet current_time() { // NOLINTNEXTLINE(readability/identifiers) @@ -56,11 +65,35 @@ absolute_timet current_time() return absolute_timet(tv.tv_usec/1000+(unsigned long long)tv.tv_sec*1000); } +/*******************************************************************\ + +Function: operator << + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::ostream &operator << (std::ostream &out, const time_periodt &period) { return out << static_cast(period.get_t())/1000; } +/*******************************************************************\ + +Function: time_periodt::as_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string time_periodt::as_string() const { std::ostringstream out; diff --git a/src/util/time_stopping.h b/src/util/time_stopping.h index d09a4a91077..9187ce2529c 100644 --- a/src/util/time_stopping.h +++ b/src/util/time_stopping.h @@ -8,9 +8,6 @@ Date: February 2004 \*******************************************************************/ -/// \file -/// Time Stopping - #ifndef CPROVER_UTIL_TIME_STOPPING_H #define CPROVER_UTIL_TIME_STOPPING_H diff --git a/src/util/timer.cpp b/src/util/timer.cpp index 63b561174cc..655dcb21ffb 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -8,18 +8,39 @@ Module: Time Stopping \*******************************************************************/ -/// \file -/// Time Stopping - #include #include #include "timer.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + timert::~timert() { } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void timert::start() { assert(!started); @@ -29,6 +50,18 @@ void timert::start() nr_starts++; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void timert::stop() { assert(started); @@ -38,6 +71,18 @@ void timert::stop() _total_time += _latest_time; } +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void timert::clear() { _total_time.clear(); diff --git a/src/util/timer.h b/src/util/timer.h index 79d60082f65..dcdba700542 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Time Stopping - #ifndef CPROVER_UTIL_TIMER_H #define CPROVER_UTIL_TIMER_H diff --git a/src/util/type.cpp b/src/util/type.cpp index aa745def82d..fa33c7ea58b 100644 --- a/src/util/type.cpp +++ b/src/util/type.cpp @@ -8,11 +8,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "type.h" +/*******************************************************************\ + +Function: typet::copy_to_subtypes + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void typet::copy_to_subtypes(const typet &type) { subtypes().push_back(type); } +/*******************************************************************\ + +Function: typet::move_to_subtypes + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void typet::move_to_subtypes(typet &type) { subtypest &sub=subtypes(); @@ -20,6 +44,18 @@ void typet::move_to_subtypes(typet &type) sub.back().swap(type); } +/*******************************************************************\ + +Function: is_number + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool is_number(const typet &type) { const irep_idt &id=type.id(); diff --git a/src/util/type_eq.cpp b/src/util/type_eq.cpp index 0166c347789..0a63181b04f 100644 --- a/src/util/type_eq.cpp +++ b/src/util/type_eq.cpp @@ -6,9 +6,6 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -/// \file -/// Type Checking - #include #include "type_eq.h" @@ -16,6 +13,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "symbol.h" #include "namespace.h" +/*******************************************************************\ + +Function: type_eq + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool type_eq(const typet &type1, const typet &type2, const namespacet &ns) { if(type1==type2) diff --git a/src/util/typecheck.cpp b/src/util/typecheck.cpp index f359b380b34..67b695e53fa 100644 --- a/src/util/typecheck.cpp +++ b/src/util/typecheck.cpp @@ -8,6 +8,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "typecheck.h" +/*******************************************************************\ + +Function: + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool typecheckt::typecheck_main() { try diff --git a/src/util/ui_message.cpp b/src/util/ui_message.cpp index 57869c71432..25f6eac92dc 100644 --- a/src/util/ui_message.cpp +++ b/src/util/ui_message.cpp @@ -16,6 +16,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "ui_message.h" #include "cmdline.h" +/*******************************************************************\ + +Function: ui_message_handlert::ui_message_handlert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ui_message_handlert::ui_message_handlert( uit __ui, const std::string &program):_ui(__ui) { @@ -48,6 +60,18 @@ ui_message_handlert::ui_message_handlert( } } +/*******************************************************************\ + +Function: ui_message_handlert::ui_message_handlert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ui_message_handlert::ui_message_handlert( const class cmdlinet &cmdline, const std::string &program): @@ -59,6 +83,18 @@ ui_message_handlert::ui_message_handlert( { } +/*******************************************************************\ + +Function: ui_message_handlert::~ui_message_handlert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + ui_message_handlert::~ui_message_handlert() { switch(get_ui()) @@ -76,6 +112,18 @@ ui_message_handlert::~ui_message_handlert() } } +/*******************************************************************\ + +Function: ui_message_handlert::level_string + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const char *ui_message_handlert::level_string(unsigned level) { if(level==1) @@ -86,6 +134,18 @@ const char *ui_message_handlert::level_string(unsigned level) return "STATUS-MESSAGE"; } +/*******************************************************************\ + +Function: ui_message_handlert::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ui_message_handlert::print( unsigned level, const std::string &message) @@ -113,6 +173,18 @@ void ui_message_handlert::print( } } +/*******************************************************************\ + +Function: ui_message_handlert::print + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ui_message_handlert::print( unsigned level, const std::string &message, @@ -148,6 +220,18 @@ void ui_message_handlert::print( } } +/*******************************************************************\ + +Function: ui_message_handlert::ui_msg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ui_message_handlert::ui_msg( const std::string &type, const std::string &msg1, @@ -169,6 +253,18 @@ void ui_message_handlert::ui_msg( } } +/*******************************************************************\ + +Function: ui_message_handlert::xml_ui_msg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ui_message_handlert::xml_ui_msg( const std::string &type, const std::string &msg1, @@ -189,6 +285,18 @@ void ui_message_handlert::xml_ui_msg( std::cout << std::endl; } +/*******************************************************************\ + +Function: ui_message_handlert::json_ui_msg + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void ui_message_handlert::json_ui_msg( const std::string &type, const std::string &msg1, diff --git a/src/util/unicode.cpp b/src/util/unicode.cpp index 16bba113b9b..4c997f1a6c3 100644 --- a/src/util/unicode.cpp +++ b/src/util/unicode.cpp @@ -18,14 +18,36 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -/// Determine endianness of the architecture -/// \return True if the architecture is little_endian +/*******************************************************************\ + +Function: is_little_endian_arch + + Inputs: + + Outputs: True if the architecture is little_endian + + Purpose: Determine endianness of the architecture + +\*******************************************************************/ + bool is_little_endian_arch() { uint32_t i=1; return reinterpret_cast(i); } +/*******************************************************************\ + +Function: narrow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + #define BUFSIZE 100 std::string narrow(const wchar_t *s) @@ -53,6 +75,18 @@ std::string narrow(const wchar_t *s) #endif } +/*******************************************************************\ + +Function: widen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::wstring widen(const char *s) { #ifdef _WIN32 @@ -78,6 +112,18 @@ std::wstring widen(const char *s) #endif } +/*******************************************************************\ + +Function: narrow + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::string narrow(const std::wstring &s) { #ifdef _WIN32 @@ -95,6 +141,18 @@ std::string narrow(const std::wstring &s) #endif } +/*******************************************************************\ + +Function: widen + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + std::wstring widen(const std::string &s) { #ifdef _WIN32 @@ -112,8 +170,18 @@ std::wstring widen(const std::string &s) #endif } -/// Appends a unicode character to a utf8-encoded string -/// \par parameters: character to append, string to append to +/*******************************************************************\ + +Function: utf8_append_code + + Inputs: character to append, string to append to + + Outputs: + + Purpose: Appends a unicode character to a utf8-encoded string + +\*******************************************************************/ + static void utf8_append_code(unsigned int c, std::string &result) { if(c<=0x7f) @@ -138,8 +206,19 @@ static void utf8_append_code(unsigned int c, std::string &result) } } -/// \param utf32:encoded wide string -/// \return utf8-encoded string with the same unicode characters as the input. +/*******************************************************************\ + +Function: utf32_to_utf8 + + Inputs: utf32-encoded wide string + + Outputs: utf8-encoded string with the same unicode characters + as the input. + + Purpose: + +\*******************************************************************/ + std::string utf32_to_utf8(const std::basic_string &s) { std::string result; @@ -152,6 +231,18 @@ std::string utf32_to_utf8(const std::basic_string &s) return result; } +/*******************************************************************\ + +Function: narrow_argv + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + const char **narrow_argv(int argc, const wchar_t **argv_wide) { if(argv_wide==NULL) @@ -167,9 +258,18 @@ const char **narrow_argv(int argc, const wchar_t **argv_wide) return argv_narrow; } -/// A helper function for dealing with different UTF16 endians -/// \par parameters: A 16-bit integer -/// \return A 16-bit integer with bytes swapped +/*******************************************************************\ + +Function: do_swap_bytes + + Inputs: A 16-bit integer + + Outputs: A 16-bit integer with bytes swapped + + Purpose: A helper function for dealing with different UTF16 endians + +\*******************************************************************/ + uint16_t do_swap_bytes(uint16_t x) { uint16_t b1=x & 0xFF; @@ -207,10 +307,19 @@ void utf16_append_code(unsigned int code, bool swap_bytes, std::wstring &result) } -/// \par parameters: String in UTF-8 format, bool value indicating whether the -/// endianness should be different from the architecture one. -/// \return String in UTF-16 format. The encoding follows the endianness of the -/// architecture iff swap_bytes is true. +/*******************************************************************\ + +Function: utf8_to_utf16 + + Inputs: String in UTF-8 format, bool value indicating whether the + endianness should be different from the architecture one. + + Outputs: String in UTF-16 format. The encoding follows the + endianness of the architecture iff swap_bytes is true. + + Purpose: + +\*******************************************************************/ std::wstring utf8_to_utf16(const std::string& in, bool swap_bytes) { std::wstring result; @@ -270,24 +379,55 @@ std::wstring utf8_to_utf16(const std::string& in, bool swap_bytes) return result; } -/// \par parameters: String in UTF-8 format -/// \return String in UTF-16BE format +/*******************************************************************\ + +Function: utf8_to_utf16_big_endian + + Inputs: String in UTF-8 format + + Outputs: String in UTF-16BE format + + Purpose: + +\*******************************************************************/ + std::wstring utf8_to_utf16_big_endian(const std::string& in) { bool swap_bytes=is_little_endian_arch(); return utf8_to_utf16(in, swap_bytes); } -/// \par parameters: String in UTF-8 format -/// \return String in UTF-16LE format +/*******************************************************************\ + +Function: utf8_to_utf16_little_endian + + Inputs: String in UTF-8 format + + Outputs: String in UTF-16LE format + + Purpose: + +\*******************************************************************/ + std::wstring utf8_to_utf16_little_endian(const std::string& in) { bool swap_bytes=!is_little_endian_arch(); return utf8_to_utf16(in, swap_bytes); } -/// \par parameters: String in UTF-16LE format -/// \return String in US-ASCII format, with \uxxxx escapes for other characters +/*******************************************************************\ + +Function: utf16_little_endian_to_ascii + + Inputs: String in UTF-16LE format + + Outputs: String in US-ASCII format, with \uxxxx escapes for other + characters + + Purpose: + +\*******************************************************************/ + std::string utf16_little_endian_to_ascii(const std::wstring& in) { std::ostringstream result; diff --git a/src/util/union_find.cpp b/src/util/union_find.cpp index 6dc80af058a..f37975f32eb 100644 --- a/src/util/union_find.cpp +++ b/src/util/union_find.cpp @@ -10,6 +10,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "union_find.h" +/*******************************************************************\ + +Function: unsigned_union_find::make_union + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unsigned_union_find::make_union(size_type j, size_type k) { check_index(j); @@ -38,6 +50,18 @@ void unsigned_union_find::make_union(size_type j, size_type k) } } +/*******************************************************************\ + +Function: unsigned_union_find::isolate + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unsigned_union_find::isolate(size_type a) { check_index(a); @@ -71,6 +95,18 @@ void unsigned_union_find::isolate(size_type a) nodes[a].count=1; } +/*******************************************************************\ + +Function: unsigned_union_find::re_root + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unsigned_union_find::re_root(size_type old_root, size_type new_root) { check_index(old_root); @@ -105,6 +141,18 @@ void unsigned_union_find::re_root(size_type old_root, size_type new_root) } } +/*******************************************************************\ + +Function: unsigned_union_find::get_other + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned_union_find::size_type unsigned_union_find::get_other(size_type a) { check_index(a); @@ -121,6 +169,18 @@ unsigned_union_find::size_type unsigned_union_find::get_other(size_type a) return 0; } +/*******************************************************************\ + +Function: unsigned_union_find::intersection + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void unsigned_union_find::intersection( const unsigned_union_find &other) { @@ -142,6 +202,18 @@ void unsigned_union_find::intersection( swap(new_sets); } +/*******************************************************************\ + +Function: unsigned_union_find::find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + unsigned_union_find::size_type unsigned_union_find::find(size_type a) const { if(a>=size()) diff --git a/src/util/xml.cpp b/src/util/xml.cpp index 5e198639e7a..aa784c96604 100644 --- a/src/util/xml.cpp +++ b/src/util/xml.cpp @@ -11,6 +11,18 @@ Author: Daniel Kroening, kroening@kroening.com #include "string2int.h" #include "xml.h" +/*******************************************************************\ + +Function: xmlt::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::clear() { data.clear(); @@ -19,6 +31,18 @@ void xmlt::clear() elements.clear(); } +/*******************************************************************\ + +Function: xmlt::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::swap(xmlt &xml) { xml.data.swap(data); @@ -27,6 +51,18 @@ void xmlt::swap(xmlt &xml) xml.name.swap(name); } +/*******************************************************************\ + +Function: xmlt::output + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::output(std::ostream &out, unsigned indent) const { // 'name' needs to be set, or we produce mal-formed @@ -73,7 +109,18 @@ void xmlt::output(std::ostream &out, unsigned indent) const out << '<' << '/' << name << '>' << "\n"; } -/// escaping for XML elements +/*******************************************************************\ + +Function: xmlt::escape + + Inputs: + + Outputs: + + Purpose: escaping for XML elements + +\*******************************************************************/ + void xmlt::escape(const std::string &s, std::ostream &out) { for(const auto ch : s) @@ -109,8 +156,20 @@ void xmlt::escape(const std::string &s, std::ostream &out) } } -/// escaping for XML attributes, assuming that double quotes " are used -/// consistently, not single quotes +/*******************************************************************\ + +Function: xmlt::escape_attribute + + Inputs: + + Outputs: + + Purpose: escaping for XML attributes, assuming that + double quotes " are used consistently, + not single quotes + +\*******************************************************************/ + void xmlt::escape_attribute(const std::string &s, std::ostream &out) { for(const auto ch : s) @@ -143,11 +202,35 @@ void xmlt::escape_attribute(const std::string &s, std::ostream &out) } } +/*******************************************************************\ + +Function: xmlt::do_indent + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::do_indent(std::ostream &out, unsigned indent) { out << std::string(indent, ' '); } +/*******************************************************************\ + +Function: xmlt::find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + xmlt::elementst::const_iterator xmlt::find(const std::string &name) const { for(elementst::const_iterator it=elements.begin(); @@ -159,6 +242,18 @@ xmlt::elementst::const_iterator xmlt::find(const std::string &name) const return elements.end(); } +/*******************************************************************\ + +Function: xmlt::find + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + xmlt::elementst::iterator xmlt::find(const std::string &name) { for(elementst::iterator it=elements.begin(); @@ -170,6 +265,18 @@ xmlt::elementst::iterator xmlt::find(const std::string &name) return elements.end(); } +/*******************************************************************\ + +Function: xmlt::set_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::set_attribute( const std::string &attribute, unsigned value) @@ -177,6 +284,18 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } +/*******************************************************************\ + +Function: xmlt::set_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::set_attribute( const std::string &attribute, unsigned long value) @@ -184,6 +303,18 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } +/*******************************************************************\ + +Function: xmlt::set_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::set_attribute( const std::string &attribute, unsigned long long value) @@ -191,6 +322,18 @@ void xmlt::set_attribute( set_attribute(attribute, std::to_string(value)); } +/*******************************************************************\ + +Function: xmlt::set_attribute + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xmlt::set_attribute( const std::string &attribute, const std::string &value) @@ -206,9 +349,18 @@ void xmlt::set_attribute( } } -/// takes a string and unescapes any xml style escaped symbols -/// \par parameters: a string -/// \return the unescaped string +/*******************************************************************\ + +Function: xmlt::unescape + + Inputs: a string + + Outputs: the unescaped string + + Purpose: takes a string and unescapes any xml style escaped symbols + +\*******************************************************************/ + std::string xmlt::unescape(const std::string &str) { std::string result(""); diff --git a/src/util/xml_expr.cpp b/src/util/xml_expr.cpp index c027025af82..236c844f6e5 100644 --- a/src/util/xml_expr.cpp +++ b/src/util/xml_expr.cpp @@ -8,9 +8,6 @@ Author: Daniel Kroening \*******************************************************************/ -/// \file -/// Expressions in XML - #include "namespace.h" #include "expr.h" #include "xml.h" @@ -22,6 +19,18 @@ Author: Daniel Kroening #include "xml_expr.h" +/*******************************************************************\ + +Function: xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + xmlt xml(const source_locationt &location) { xmlt result; @@ -43,6 +52,18 @@ xmlt xml(const source_locationt &location) return result; } +/*******************************************************************\ + +Function: xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + xmlt xml( const typet &type, const namespacet &ns) @@ -138,6 +159,18 @@ xmlt xml( return result; } +/*******************************************************************\ + +Function: xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + xmlt xml( const exprt &expr, const namespacet &ns) diff --git a/src/util/xml_irep.cpp b/src/util/xml_irep.cpp index 2dad57871e1..92bad4df40c 100644 --- a/src/util/xml_irep.cpp +++ b/src/util/xml_irep.cpp @@ -15,6 +15,18 @@ Author: Daniel Kroening #include "irep.h" #include "xml.h" +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const irept &irep, xmlt &xml) @@ -43,6 +55,18 @@ void convert( } } +/*******************************************************************\ + +Function: convert + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void convert( const xmlt &xml, irept &irep) diff --git a/src/xmllang/graphml.cpp b/src/xmllang/graphml.cpp index 54d19654ec1..e96abaa74ee 100644 --- a/src/xmllang/graphml.cpp +++ b/src/xmllang/graphml.cpp @@ -6,9 +6,6 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ -/// \file -/// Read/write graphs as GraphML - #include #include @@ -23,6 +20,18 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk typedef std::map name_mapt; +/*******************************************************************\ + +Function: add_node + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static graphmlt::node_indext add_node( const std::string &name, name_mapt &name_to_node, @@ -36,6 +45,18 @@ static graphmlt::node_indext add_node( return entry.first->second; } +/*******************************************************************\ + +Function: build_graph_rec + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool build_graph_rec( const xmlt &xml, name_mapt &name_to_node, @@ -147,6 +168,18 @@ static bool build_graph_rec( return false; } +/*******************************************************************\ + +Function: build_graph + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + static bool build_graph( const xmlt &xml, graphmlt &dest, @@ -181,6 +214,18 @@ static bool build_graph( return err; } +/*******************************************************************\ + +Function: read_graphml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool read_graphml( std::istream &is, graphmlt &dest, @@ -195,6 +240,18 @@ bool read_graphml( return build_graph(xml, dest, entry); } +/*******************************************************************\ + +Function: read_graphml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool read_graphml( const std::string &filename, graphmlt &dest, @@ -209,6 +266,18 @@ bool read_graphml( return build_graph(xml, dest, entry); } +/*******************************************************************\ + +Function: write_graphml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + bool write_graphml(const graphmlt &src, std::ostream &os) { xmlt graphml("graphml"); diff --git a/src/xmllang/graphml.h b/src/xmllang/graphml.h index 3b399d48c3b..1ef5aaedae1 100644 --- a/src/xmllang/graphml.h +++ b/src/xmllang/graphml.h @@ -6,9 +6,6 @@ Author: Michael Tautschnig, mt@eecs.qmul.ac.uk \*******************************************************************/ -/// \file -/// Read/write graphs as GraphML - #ifndef CPROVER_XMLLANG_GRAPHML_H #define CPROVER_XMLLANG_GRAPHML_H diff --git a/src/xmllang/xml_parse_tree.cpp b/src/xmllang/xml_parse_tree.cpp index 766a34d2816..b18bda862a5 100644 --- a/src/xmllang/xml_parse_tree.cpp +++ b/src/xmllang/xml_parse_tree.cpp @@ -8,11 +8,35 @@ Author: Daniel Kroening, kroening@kroening.com #include "xml_parse_tree.h" +/*******************************************************************\ + +Function: xml_parse_treet::swap + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xml_parse_treet::swap(xml_parse_treet &xml_parse_tree) { xml_parse_tree.element.swap(element); } +/*******************************************************************\ + +Function: xml_parse_treet::clear + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + void xml_parse_treet::clear() { xml.clear(); diff --git a/src/xmllang/xml_parser.cpp b/src/xmllang/xml_parser.cpp index 4a657a557e7..f56ee14e202 100644 --- a/src/xmllang/xml_parser.cpp +++ b/src/xmllang/xml_parser.cpp @@ -14,6 +14,18 @@ Author: Daniel Kroening, kroening@kroening.com xml_parsert xml_parser; +/*******************************************************************\ + +Function: parse_xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // 'do it all' function bool parse_xml( std::istream &in, @@ -37,6 +49,18 @@ bool parse_xml( return result; } +/*******************************************************************\ + +Function: parse_xml + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + // 'do it all' function bool parse_xml( const std::string &filename,